From patchwork Mon Oct 12 14:31:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 54766 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id 87CF122DB6 for ; Mon, 12 Oct 2015 14:32:12 +0000 (UTC) Received: by lbbti1 with SMTP id ti1sf70735430lbb.3 for ; Mon, 12 Oct 2015 07:32:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=jr7G8I00bmuw2PI9j/+b8F8WioDVEaP/6dVM+Yr/xOE=; b=Bc5QUCoMAD/ABeslRovuiMXJbOfX7LWdNPsZCMQ4o8ts74IH4QcQ/FJ0E2bsTU59k0 mNHVKfgppjenLpyAbfvR+dKajC48A6Ck6YEKXKF1sajI+G1uQOozWyMRfjCfknq+PU+/ 8swCPzZMxfAjRH6+mt24s9njuHcSLQv8kgA5keLnKRvIt43rLqP67GiZ+K/l3ALngIMX NISwkBVlhwlnTbxZyYRQPx2xbg64Srvs/E1pF06bO0OitChx6QysOJOdB5v6t42pViba PRCq47Y2CmmlMutubFOh8XiNFcrXAPsO1XACjxJ3orKjZnqV7lI0/0m+5O573+McjZkH P09Q== X-Gm-Message-State: ALoCoQneYes5UVghQbeo+wPJtlII5bX4ll/TRfoArZARGCTeR7PiLelLnImyXJCbPUCYlaiYkL0x X-Received: by 10.112.209.73 with SMTP id mk9mr5681707lbc.14.1444660331564; Mon, 12 Oct 2015 07:32:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.39.6 with SMTP id n6ls494371lfn.36.gmail; Mon, 12 Oct 2015 07:32:11 -0700 (PDT) X-Received: by 10.112.148.38 with SMTP id tp6mr12652972lbb.110.1444660331258; Mon, 12 Oct 2015 07:32:11 -0700 (PDT) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com. [209.85.217.171]) by mx.google.com with ESMTPS id az8si11404212lbc.148.2015.10.12.07.32.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Oct 2015 07:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) client-ip=209.85.217.171; Received: by lbbck17 with SMTP id ck17so24692130lbb.1 for ; Mon, 12 Oct 2015 07:32:11 -0700 (PDT) X-Received: by 10.25.28.81 with SMTP id c78mr4305382lfc.29.1444660330956; Mon, 12 Oct 2015 07:32:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp1583002lbq; Mon, 12 Oct 2015 07:32:10 -0700 (PDT) X-Received: by 10.182.133.9 with SMTP id oy9mr15757294obb.41.1444660329844; Mon, 12 Oct 2015 07:32:09 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r185si8948881oib.19.2015.10.12.07.32.09; Mon, 12 Oct 2015 07:32:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752698AbbJLOcD (ORCPT + 30 others); Mon, 12 Oct 2015 10:32:03 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:33484 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752266AbbJLOcA (ORCPT ); Mon, 12 Oct 2015 10:32:00 -0400 Received: by wicge5 with SMTP id ge5so20235797wic.0 for ; Mon, 12 Oct 2015 07:31:59 -0700 (PDT) X-Received: by 10.180.37.130 with SMTP id y2mr11634309wij.9.1444660319079; Mon, 12 Oct 2015 07:31:59 -0700 (PDT) Received: from localhost.localdomain (LPoitiers-656-1-62-228.w90-63.abo.wanadoo.fr. [90.63.143.228]) by smtp.gmail.com with ESMTPSA id az6sm11102907wib.12.2015.10.12.07.31.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Oct 2015 07:31:58 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang Cc: linux-i2c , LKML , Patrick Titiano , Bartosz Golaszewski Subject: [PATCH 3/9] eeprom: at24: tie up an additional address for at24cs series Date: Mon, 12 Oct 2015 16:31:15 +0200 Message-Id: <1444660281-19150-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444660281-19150-1-git-send-email-bgolaszewski@baylibre.com> References: <1444660281-19150-1-git-send-email-bgolaszewski@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: bgolaszewski@baylibre.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.171 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The at24cs series EEPROM chips have an additional read-only memory area, that is visible on a different i2c slave address. Tie it up with a dummy device. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index c6cb7f8..3a75a52 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -102,6 +102,8 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_BITMASK(x) (BIT(x) - 1) +#define AT24CS_SERIAL_ADDR(addr) (addr + 0x08) + /* create non-zero magic value for given eeprom parameters */ #define AT24_DEVICE_MAGIC(_len, _flags) \ ((1 << AT24_SIZE_FLAGS | (_flags)) \ @@ -543,6 +545,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) if (chip.flags & AT24_FLAG_TAKE8ADDR) num_addresses = 8; + else if (chip.flags & AT24_FLAG_SERIAL) + num_addresses = 2; else num_addresses = DIV_ROUND_UP(chip.byte_len, (chip.flags & AT24_FLAG_ADDR16) ? 65536 : 256); @@ -601,12 +605,30 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) at24->client[0] = client; /* use dummy devices for multiple-address chips */ - for (i = 1; i < num_addresses; i++) { - at24->client[i] = i2c_new_dummy(client->adapter, + if (at24->chip.flags & AT24_FLAG_TAKE8ADDR) { + for (i = 1; i < num_addresses; i++) { + at24->client[i] = i2c_new_dummy(client->adapter, + client->addr + i); + if (!at24->client[i]) { + dev_err(&client->dev, + "address 0x%02x unavailable\n", client->addr + i); - if (!at24->client[i]) { + err = -EADDRINUSE; + goto err_clients; + } + } + } + + /* + * at24cs series tie up an additional address for the memory area + * contining the serial number + */ + if (at24->chip.flags & AT24_FLAG_SERIAL) { + at24->client[1] = i2c_new_dummy(client->adapter, + AT24CS_SERIAL_ADDR(client->addr)); + if (!at24->client[1]) { dev_err(&client->dev, "address 0x%02x unavailable\n", - client->addr + i); + AT24CS_SERIAL_ADDR(client->addr)); err = -EADDRINUSE; goto err_clients; }