From patchwork Mon Aug 20 14:25:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 144641 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4065519ljj; Mon, 20 Aug 2018 07:46:48 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy7idhYs8+z9mHZ94AnBzE2QK/uGsp+49omVXmV8IuL9nT4tBqL2U/Ci2KRFTJyTKssg5/t X-Received: by 2002:a50:b37a:: with SMTP id r55-v6mr55904562edd.145.1534776408206; Mon, 20 Aug 2018 07:46:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534776408; cv=none; d=google.com; s=arc-20160816; b=s4YtNmeHUULzqOfWNxtMtgSuoXtdnV//ZgTyECkY8xYWeB8313SAUDqCu6C0KYjmmP 9XF1pCpNZRJ+RosL1ZPS9oQhlv0s6/7ynLneDcLsFuVa6oFTpMSQgUV4EVpUPWqCLqVZ RSTO8+NFVZcJ9hsS2NaD+1WWmejkgR9sU1Y7ZElxwWKFHBixVSbT1rh+kwOPRst/u2JE E0Qq1gGXe2Eh9lG1ddZ11BmybBlT0NKeEaqSopF8oIg4iRlgmUkX2HUA9YLg49qiigj4 kL9U67rWxh9PdO6exa0Aoat3aG4PhqlwrN0WbmMH7vJHeROtce5/IgjBzqqHAHqQC4zJ kBhA== 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=G4rMwivqWqdj+SXGJnzWtZwva1FilqtzYvQgAQ+vB0w=; b=WGyIYndDmds6IHU23/uJIUGmZWS4hdunEP8DAhp0CNzeXct8u7MkqcnSOLby5BgpWh Ia6TKVumxBVPnnq4Ys3GNjPIeFJ0TF+Ga0X7PNSRiV3zzVBE85dxXwQF3dwir4fCiVxp w5C3mO1NQDwctHxa7cvqxU782LYOhutcdJm5xkkfDlmsAIoo3yFY7T7S409ETb7dBOwN 2FFhPhL0mKxRA/nBa7aPs6PRiUPcaGO58/I+AD9onepYWlkitiKObAcLij0siM3K7lGf sB7UD/umkYSKng+fGKL9PWDx02MGLUX5cHjnfGSC2cmjAv+YYhTn2MeGNldekdn5nmKd uudQ== 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 z42-v6si1192608edb.410.2018.08.20.07.46.47; Mon, 20 Aug 2018 07:46:48 -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 CA402C21E3B; Mon, 20 Aug 2018 14:34: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 58588C21E53; Mon, 20 Aug 2018 14:32:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 927F3C21E6A; Mon, 20 Aug 2018 14:32:16 +0000 (UTC) Received: from esa3.microchip.iphmx.com (esa3.microchip.iphmx.com [68.232.153.233]) by lists.denx.de (Postfix) with ESMTPS id 70C3EC21E30 for ; Mon, 20 Aug 2018 14:32:09 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.53,265,1531810800"; d="scan'208";a="18413287" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Aug 2018 07:32:08 -0700 Received: from eh-station.mchp-main.com (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Mon, 20 Aug 2018 07:32:08 -0700 From: Eugen Hristev To: Date: Mon, 20 Aug 2018 17:25:45 +0300 Message-ID: <1534775173-14209-7-git-send-email-eugen.hristev@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1534775173-14209-1-git-send-email-eugen.hristev@microchip.com> References: <1534775173-14209-1-git-send-email-eugen.hristev@microchip.com> MIME-Version: 1.0 Cc: Maxime Ripard , nicolas.ferre@microchip.com Subject: [U-Boot] [PATCH v3 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, +};