From patchwork Thu Jul 19 09:57:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 142335 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1551213ljj; Thu, 19 Jul 2018 03:12:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpewZEzr4+4fxE56kjyzTmuoJQ1lM0n77jliCKzZaLexYZRHL6AgCOK2DBgscYgm2nf68mcW X-Received: by 2002:a50:b2a6:: with SMTP id p35-v6mr10765360edd.215.1531995136799; Thu, 19 Jul 2018 03:12:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531995136; cv=none; d=google.com; s=arc-20160816; b=xTwuiQvSxZwwovQYYp+6E85yA13QkmmocQ9319PxF8smMod5htDBFoQxxpzLx8Cnf5 pJTGPyaoiPR2IpPLDY4jqn26QiWHmn/zouDdQifT3yp7lNThmcuSXkmgKKPDnNhHMtPM GFG3n380VdUpm2V2bU1q9swablXwbezI/EPTTQj5mpaz4euwDwUM7Y/NgucO538FAoC9 YjIx9rgSXfy2AYZ3M7cyGRW+s96yGJlM3B7Xije3XQVCTRYEgQfUAKdTzOcuRzDMHr0C FQrIB/15QT1AMLaWChT7eZx7Rm01+zBfpr3k14appP2ZipCKwHBUxVOrWvJ1FKc2f7YL /HTg== 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 :arc-authentication-results; bh=pJB7Jnu9V8o4hmIxMJShMsf+mpRufajlq6P05J8f3e0=; b=NlcgIOBzCxCkXrafSfeG3/VK0faNUhaO69X3czugFrz+0unD/Cwum2rbooS+M04Swv LGT55Kh7rZE7dLwb9O6Kh/dGlZDegfZ5792eT7p56zyP4GwMzYlkQcZ4wqtVlH3ufVOY nT19CPujgRjc5QmVK2HJTNW9VwntYEF6epl4DQvr3ixRoDYcbo/6JyReEg02uxs9JqpB 2saZ7pICDPw8VnhLC6T/qR2oV1pDF/TClhQ2P1+yakV/5+MmNLhy+poXpTDN0cy/5i+f 7Dgc/lNjRJKxWfAC1E+Z0NpnsTLL3tjkPBOhbATopeGdlDS0Dii0KLovU5+X3UxjDxVZ NfTQ== 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 l22-v6si4211096eda.370.2018.07.19.03.12.16; Thu, 19 Jul 2018 03:12:16 -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 4F904C21E3B; Thu, 19 Jul 2018 10:09:19 +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 BC51FC21E88; Thu, 19 Jul 2018 10:03:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 22212C21F63; Thu, 19 Jul 2018 10:02:48 +0000 (UTC) Received: from esa4.microchip.iphmx.com (esa4.microchip.iphmx.com [68.232.154.123]) by lists.denx.de (Postfix) with ESMTPS id 38BC4C21EA1 for ; Thu, 19 Jul 2018 10:02:43 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.51,374,1526367600"; d="scan'208";a="16185311" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 19 Jul 2018 03:02:42 -0700 Received: from eh-station.mchp-main.com (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Thu, 19 Jul 2018 03:02:42 -0700 From: Eugen Hristev To: Date: Thu, 19 Jul 2018 12:57:53 +0300 Message-ID: <1531994288-19423-6-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1531994288-19423-1-git-send-email-eugen.hristev@microchip.com> References: <1531994288-19423-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 05/20] 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 | 46 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 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..423aa99 --- /dev/null +++ b/drivers/w1-eeprom/ds24xxx.c @@ -0,0 +1,46 @@ +/* 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 const struct w1_eeprom_ops ds24xxx_ops = { + .read_buf = ds24xxx_read_buf, +}; + +U_BOOT_DRIVER(ds24b33) = { + .name = "ds24b33", + .id = UCLASS_W1_EEPROM, + .ops = &ds24xxx_ops, +}; + +U_BOOT_DRIVER(ds2431) = { + .name = "ds2431", + .id = UCLASS_W1_EEPROM, + .ops = &ds24xxx_ops, +}; + +U_BOOT_W1_DEVICE(ds24b33, W1_FAMILY_DS24B33); +U_BOOT_W1_DEVICE(ds2431, W1_FAMILY_DS2431);