From patchwork Tue Oct 20 08:43:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 55281 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id 52B7223024 for ; Tue, 20 Oct 2015 08:43:59 +0000 (UTC) Received: by wikv3 with SMTP id v3sf6601421wik.1 for ; Tue, 20 Oct 2015 01:43:58 -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=HhVsd0Z1Cy+pQpMqtj3IFJJSk8pFnKvwywgSyIiqW0GVygG/ZfW9vErZnchm+otlTL s+d7Enfzw5mvNOwJrMTBobcEkLLXnF6QRkKvXOUkCgWIZQWPZeWhdpld69mWaDT8Ul5R dAzgbBp91mVsalWnElmDwIMj11gNexo6uHuNnd+xQD70nzRP/FMviVvuG8lkYBW4YXOg q3aocIvQey/ZsLVsybcu67rOauc8kwPnxsEwxGLTz9rdJ+NWSObHcc5jU2PbPxJCp820 v4zPfh8WFfBFY6j3gsuUKfF8fkavavCWrb+2KL6HhOeuCnlf8Cpelt8sMD6y09hpdms4 8pFA== X-Gm-Message-State: ALoCoQkDiC80yBCMlRj7Yn0hhd+ppzJBT6DfVyIC348ZSYmdF/l/HYq1a959tF+uoaR+ZguWm+Qs X-Received: by 10.112.145.227 with SMTP id sx3mr372639lbb.12.1445330638587; Tue, 20 Oct 2015 01:43:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.20.202 with SMTP id 71ls50502lfu.95.gmail; Tue, 20 Oct 2015 01:43:58 -0700 (PDT) X-Received: by 10.112.135.9 with SMTP id po9mr1070922lbb.56.1445330638423; Tue, 20 Oct 2015 01:43:58 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id rc10si1421954lbb.160.2015.10.20.01.43.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 01:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbes7 with SMTP id es7so9766432lbb.2 for ; Tue, 20 Oct 2015 01:43:58 -0700 (PDT) X-Received: by 10.112.135.9 with SMTP id po9mr1070915lbb.56.1445330638275; Tue, 20 Oct 2015 01:43:58 -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 w3csp1941649lbq; Tue, 20 Oct 2015 01:43:57 -0700 (PDT) X-Received: by 10.68.129.231 with SMTP id nz7mr2602188pbb.53.1445330637245; Tue, 20 Oct 2015 01:43:57 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id uh9si3619836pac.58.2015.10.20.01.43.56; Tue, 20 Oct 2015 01:43:57 -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 S932161AbbJTInu (ORCPT + 28 others); Tue, 20 Oct 2015 04:43:50 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:38330 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753664AbbJTInp (ORCPT ); Tue, 20 Oct 2015 04:43:45 -0400 Received: by wicll6 with SMTP id ll6so17215810wic.1 for ; Tue, 20 Oct 2015 01:43:44 -0700 (PDT) X-Received: by 10.180.187.178 with SMTP id ft18mr3237871wic.10.1445330624113; Tue, 20 Oct 2015 01:43:44 -0700 (PDT) Received: from localhost.localdomain (cag06-6-78-235-100-105.fbx.proxad.net. [78.235.100.105]) by smtp.gmail.com with ESMTPSA id kr10sm2390754wjc.25.2015.10.20.01.43.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Oct 2015 01:43:43 -0700 (PDT) From: Bartosz Golaszewski To: Wolfram Sang Cc: linux-i2c , LKML , Bartosz Golaszewski Subject: [RESEND PATCH 3/9] eeprom: at24: tie up an additional address for at24cs series Date: Tue, 20 Oct 2015 10:43:21 +0200 Message-Id: <1445330607-12470-4-git-send-email-bgolaszewski@baylibre.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445330607-12470-1-git-send-email-bgolaszewski@baylibre.com> References: <1445330607-12470-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.169 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; }