From patchwork Tue Sep 18 07:35:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 146880 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp4708289ljw; Tue, 18 Sep 2018 00:45:14 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaSfDQVJVKMWaToMo3GyHABJcdbQ5IdgbLXXLlB6U6u/tWtOypRHVOVJ5vJyETOeASA97aI X-Received: by 2002:a50:8c45:: with SMTP id p63-v6mr49160897edp.84.1537256714827; Tue, 18 Sep 2018 00:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537256714; cv=none; d=google.com; s=arc-20160816; b=ZWEyzPIY+Dkab6u9xKP6/2UFgY4UiLTM+sirkk24zpVqrIQoZZGDRjSp9x3sbzOYh/ 7rPQcuDf8G29D6ko1qAFWP1ivxN4mIwI6r8AxvFkdU64ErlKvw2dUl7LUIuP7zMVg7e8 aLtxCX1JY1iFZXvakkGat2UO25tLktTLBj1UIw0qGTmg/00wzDk5wXpmVbM/xriKpogT ckk5XcWObLG/rTQV065/npldvgC1QhyNItgwLiBTEygtMfZSSKz0CJsNJxRr9rP7gA8D zYLV7xnf4PNcuBqeCXLCGxczg1UJ6oCWIf0vkd8cv1mAOcKg4G+Dn8W5E7q5xQ/ZA+KT so+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :cc:mime-version:references:in-reply-to:message-id:date:to:from; bh=G4rMwivqWqdj+SXGJnzWtZwva1FilqtzYvQgAQ+vB0w=; b=Rz38H0nK8mckTPDrUNc+orho0LW8UhFbNpQmg6kkjCED0jcGnKfTl695RiJrMWTNDm jKCnH3M4RxFX9mH7Z7FeTw9pM9HpJQIlBel32QGEsMAigdJFKhDehLJcqeXJBeV0lFFU UZKWs5Z3XGUXVHMBE4+nK8BtPZxQAKoLjlpxtWKRz60GISB6G6xcCCxr6qsBEzb1wpje VMcSD4VMe17DpiZps8WcNrJinUzgPCMRSfbjFf33/8L+2Zdo3cpzrwxlKedWSClg7+ZX e6M4rK2KVGA66gII6W0bY0jXZrhOhthTa8sbIMy2TgikVIFAifDJQLcLfBzKTmys16Tv 0shg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id 92-v6si5004861edj.173.2018.09.18.00.45.14; Tue, 18 Sep 2018 00:45:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 5F3FEC21E56; Tue, 18 Sep 2018 07:43:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 87F9AC21EC3; Tue, 18 Sep 2018 07:40:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 309CAC21EBE; Tue, 18 Sep 2018 07:40:40 +0000 (UTC) Received: from esa2.microchip.iphmx.com (esa2.microchip.iphmx.com [68.232.149.84]) by lists.denx.de (Postfix) with ESMTPS id 3C0A1C21E68 for ; Tue, 18 Sep 2018 07:40:34 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.53,389,1531810800"; d="scan'208";a="20067716" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 18 Sep 2018 00:40:33 -0700 Received: from eh-station.mchp-main.com (10.10.76.4) by chn-sv-exch06.mchp-main.com (10.10.76.107) with Microsoft SMTP Server id 14.3.352.0; Tue, 18 Sep 2018 00:40:33 -0700 From: Eugen Hristev To: , Date: Tue, 18 Sep 2018 10:35:29 +0300 Message-ID: <1537256157-18001-7-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537256157-18001-1-git-send-email-eugen.hristev@microchip.com> References: <1537256157-18001-1-git-send-email-eugen.hristev@microchip.com> MIME-Version: 1.0 Cc: maxime.ripard@bootlin.com, Maxime Ripard , nicolas.ferre@microchip.com Subject: [U-Boot] [PATCH v4 06/34] W1-EEPROM: add support for Maxim DS24 eeprom families X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Maxime Ripard Add a driver that supports Maxim 1 wire EEPROMs families DS24B33 and DS2431. Can be extended for other families as well. Signed-off-by: Maxime Ripard [eugen.hristev@microchip.com: reworked driver] Signed-off-by: Eugen Hristev --- drivers/w1-eeprom/Kconfig | 6 +++++ drivers/w1-eeprom/Makefile | 2 ++ drivers/w1-eeprom/ds24xxx.c | 55 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 drivers/w1-eeprom/ds24xxx.c diff --git a/drivers/w1-eeprom/Kconfig b/drivers/w1-eeprom/Kconfig index d5ddc80..20ec549 100644 --- a/drivers/w1-eeprom/Kconfig +++ b/drivers/w1-eeprom/Kconfig @@ -12,6 +12,12 @@ config W1_EEPROM if W1_EEPROM +config W1_EEPROM_DS24XXX + bool "Enable Maxim DS24 families EEPROM support" + depends on W1 + help + Maxim DS24 EEPROMs 1-Wire EEPROM support + endif endmenu diff --git a/drivers/w1-eeprom/Makefile b/drivers/w1-eeprom/Makefile index b72950e..3f4aa13 100644 --- a/drivers/w1-eeprom/Makefile +++ b/drivers/w1-eeprom/Makefile @@ -1,2 +1,4 @@ obj-$(CONFIG_W1_EEPROM) += w1-eeprom-uclass.o +obj-$(CONFIG_W1_EEPROM_DS24XXX) += ds24xxx.o + diff --git a/drivers/w1-eeprom/ds24xxx.c b/drivers/w1-eeprom/ds24xxx.c new file mode 100644 index 0000000..56186e5 --- /dev/null +++ b/drivers/w1-eeprom/ds24xxx.c @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * + * Copyright (c) 2015 Free Electrons + * Copyright (c) 2015 NextThing Co + * Copyright (c) 2018 Microchip Technology, Inc. + * + */ + +#include +#include +#include +#include +#include + +#define W1_F2D_READ_EEPROM 0xf0 + +static int ds24xxx_read_buf(struct udevice *dev, unsigned int offset, + u8 *buf, unsigned int count) +{ + w1_reset_select(dev); + + w1_write_byte(dev, W1_F2D_READ_EEPROM); + w1_write_byte(dev, offset & 0xff); + w1_write_byte(dev, offset >> 8); + + return w1_read_buf(dev, buf, count); +} + +static int ds24xxx_probe(struct udevice *dev) +{ + struct w1_device *w1; + + w1 = dev_get_platdata(dev); + w1->id = 0; + return 0; +} + +static const struct w1_eeprom_ops ds24xxx_ops = { + .read_buf = ds24xxx_read_buf, +}; + +static const struct udevice_id ds24xxx_id[] = { + { .compatible = "maxim,ds24b33", .data = W1_FAMILY_DS24B33 }, + { .compatible = "maxim,ds2431", .data = W1_FAMILY_DS2431 }, + { }, +}; + +U_BOOT_DRIVER(ds24xxx) = { + .name = "ds24xxx", + .id = UCLASS_W1_EEPROM, + .of_match = ds24xxx_id, + .ops = &ds24xxx_ops, + .probe = ds24xxx_probe, +};