From patchwork Fri Oct 18 09:51:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21113 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8D02C25D9E for ; Fri, 18 Oct 2013 09:51:54 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id b4sf4165604qen.3 for ; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=/6Ow0MCLSWCnWCeuNU0MfpeMPKQg/2BsFU4/zuxxMBc=; b=UFEpJEju8MXjAuvmRPYzj/0lCMA+Z7E2+jfO7AyP5H0IOASFjTpS/IbFDK8dFmgMiG K/ZtDGGMBXKTeVHxrxc4GBsEsd91qHJNOMIpOoN4g512DI3PHNowKd8sTn8mgaCCiRCA D23i6WR7JHSALAahZGvqmD/q/kzhE6ns3ME5caJhgy8I4f2cOWJ1P8QoDe26zUbJ+9Q9 wvKtsYW4t/a4BVe7Q9TKml6AqokGBSUSAKfZErEuLz9Upzacikm4B6qEBAT8oNkJIQ0K EFwdmPgmfN7oK4hb1oQFAh3zZohE8qFH5Bsn6BqcWypzdse/SlT51T7G1YJWUxyymCuE QGxw== X-Received: by 10.224.128.131 with SMTP id k3mr2830238qas.0.1382089914406; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.20 with SMTP id u20ls1240749qeb.92.gmail; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) X-Received: by 10.220.58.1 with SMTP id e1mr1337021vch.0.1382089914273; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id bq2si141110vcb.115.2013.10.18.02.51.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 02:51:54 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.50; Received: by mail-vb0-f50.google.com with SMTP id x14so1704201vbb.37 for ; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) X-Gm-Message-State: ALoCoQmVkw59FCuqMIuwMRZW5nYQVqmsBsfcMMnCQMVzhFlq5K5YaENyeikfp+3kUAE44DqCHtsN X-Received: by 10.58.208.130 with SMTP id me2mr1306282vec.13.1382089914170; Fri, 18 Oct 2013 02:51:54 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp22750vcz; Fri, 18 Oct 2013 02:51:53 -0700 (PDT) X-Received: by 10.180.78.167 with SMTP id c7mr1487854wix.25.1382089913280; Fri, 18 Oct 2013 02:51:53 -0700 (PDT) Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by mx.google.com with ESMTPS id hk7si265792wjb.15.2013.10.18.02.51.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 18 Oct 2013 02:51:53 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.45 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=74.125.82.45; Received: by mail-wg0-f45.google.com with SMTP id z12so3566905wgg.24 for ; Fri, 18 Oct 2013 02:51:52 -0700 (PDT) X-Received: by 10.194.122.99 with SMTP id lr3mr1699804wjb.21.1382089912844; Fri, 18 Oct 2013 02:51:52 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id c10sm25307030wie.11.2013.10.18.02.51.50 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 18 Oct 2013 02:51:52 -0700 (PDT) From: Linus Walleij To: devicetree@vger.kernel.org, Samuel Ortiz , Lee Jones Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH 2/5 v2] mfd: tc3589x: Detect the precise version Date: Fri, 18 Oct 2013 11:51:45 +0200 Message-Id: <1382089905-20730-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Instead of detecting the "tc3589x" and hard-coding the number of GPIO pins to 24, encode all the possible subtypes and set the number of GPIO pins from the type. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Compress the switch tree to the two variables we currently have to deal with. --- drivers/mfd/tc3589x.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 70f4909f..87ea51d 100644 --- a/drivers/mfd/tc3589x.c +++ b/drivers/mfd/tc3589x.c @@ -16,6 +16,19 @@ #include #include +/** + * enum tc3589x_version - indicates the TC3589x version + */ +enum tc3589x_version { + TC3589X_TC35890, + TC3589X_TC35892, + TC3589X_TC35893, + TC3589X_TC35894, + TC3589X_TC35895, + TC3589X_TC35896, + TC3589X_UNKNOWN, +}; + #define TC3589x_CLKMODE_MODCTL_SLEEP 0x0 #define TC3589x_CLKMODE_MODCTL_OPERATION (1 << 0) @@ -361,7 +374,21 @@ static int tc3589x_probe(struct i2c_client *i2c, tc3589x->i2c = i2c; tc3589x->pdata = pdata; tc3589x->irq_base = pdata->irq_base; - tc3589x->num_gpio = id->driver_data; + + switch (id->driver_data) { + case TC3589X_TC35893: + case TC3589X_TC35895: + case TC3589X_TC35896: + tc3589x->num_gpio = 20; + break; + case TC3589X_TC35890: + case TC3589X_TC35892: + case TC3589X_TC35894: + case TC3589X_UNKNOWN: + default: + tc3589x->num_gpio = 24; + break; + } i2c_set_clientdata(i2c, tc3589x); @@ -432,7 +459,13 @@ static int tc3589x_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(tc3589x_dev_pm_ops, tc3589x_suspend, tc3589x_resume); static const struct i2c_device_id tc3589x_id[] = { - { "tc3589x", 24 }, + { "tc35890", TC3589X_TC35890 }, + { "tc35892", TC3589X_TC35892 }, + { "tc35893", TC3589X_TC35893 }, + { "tc35894", TC3589X_TC35894 }, + { "tc35895", TC3589X_TC35895 }, + { "tc35896", TC3589X_TC35896 }, + { "tc3589x", TC3589X_UNKNOWN }, { } }; MODULE_DEVICE_TABLE(i2c, tc3589x_id);