From patchwork Tue Oct 15 21:14:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 21060 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f72.google.com (mail-vb0-f72.google.com [209.85.212.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 04A2720D84 for ; Tue, 15 Oct 2013 21:14:05 +0000 (UTC) Received: by mail-vb0-f72.google.com with SMTP id f12sf17370861vbg.7 for ; Tue, 15 Oct 2013 14:14:05 -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=jN6s2e6Qc4Kd45/Za4OJzJxfeQ2EtL7rcfadPhlQH7A=; b=OUopT6123srd+y8QnzdpUeif3NJxmKs3NjKqwFCoTxUKRApH3RBreyyDrzU9+SJ4sJ 36XeBw6XhoNoSIemLaYPFMVJmM/AnJyCUZv7G7dGWIqSX1p+JYa4cILAw2RG4AXFyxTq 3NsIhSzweiYlEMsXMyDQMRkuwDEn1BnCERxZA9hCwle+3xXQ5fa5LrrPzBVFUId0DErw qkS/rpU3PIjUI6SURZn+ifDc42YJO1bjRhmxSh/rhFAWWKFuxKMCc92JfR1DlGx+C2L4 lGwb1wRQ2Hq5EI0hIV6TMAleyfUZ+0p2jwzA0d4tNYqaEUNesn7QLqf+MQV6GbKqajEk R/4w== X-Received: by 10.58.54.97 with SMTP id i1mr1485982vep.40.1381871645580; Tue, 15 Oct 2013 14:14:05 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.70.228 with SMTP id p4ls344904qeu.43.gmail; Tue, 15 Oct 2013 14:14:05 -0700 (PDT) X-Received: by 10.58.133.77 with SMTP id pa13mr2674261veb.21.1381871645467; Tue, 15 Oct 2013 14:14:05 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id qg2si4013373veb.50.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:14:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id if17so5426035vcb.4 for ; Tue, 15 Oct 2013 14:14:05 -0700 (PDT) X-Gm-Message-State: ALoCoQmkl+xTDUP6OlobnW2NYpAS0BF0VXcgxDvIQCl/Le0lg/mk9PKneff11DDcwoebkd6Exaax X-Received: by 10.52.35.136 with SMTP id h8mr33933110vdj.6.1381871645386; Tue, 15 Oct 2013 14:14:05 -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 u4csp328979vcz; Tue, 15 Oct 2013 14:14:04 -0700 (PDT) X-Received: by 10.180.12.45 with SMTP id v13mr21040739wib.57.1381871644321; Tue, 15 Oct 2013 14:14:04 -0700 (PDT) Received: from mail-wi0-f172.google.com (mail-wi0-f172.google.com [209.85.212.172]) by mx.google.com with ESMTPS id df6si27874526wjc.144.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:14:04 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.172 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.212.172; Received: by mail-wi0-f172.google.com with SMTP id ez12so2271880wid.11 for ; Tue, 15 Oct 2013 14:14:03 -0700 (PDT) X-Received: by 10.180.185.145 with SMTP id fc17mr19781071wic.60.1381871643659; Tue, 15 Oct 2013 14:14:03 -0700 (PDT) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id pi6sm361179wic.3.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 15 Oct 2013 14:14:02 -0700 (PDT) From: Linus Walleij To: Samuel Ortiz , Lee Jones , devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Linus Walleij Subject: [PATCH 2/5] mfd: tc3589x: detect the precise version Date: Tue, 15 Oct 2013 23:14:00 +0200 Message-Id: <1381871640-22262-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.220.173 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 --- drivers/mfd/tc3589x.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/drivers/mfd/tc3589x.c b/drivers/mfd/tc3589x.c index 70f4909f..0eabbb0 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,33 @@ 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_TC35890: + tc3589x->num_gpio = 24; + break; + case TC3589X_TC35892: + tc3589x->num_gpio = 24; + break; + case TC3589X_TC35893: + tc3589x->num_gpio = 20; + break; + case TC3589X_TC35894: + tc3589x->num_gpio = 24; + break; + case TC3589X_TC35895: + tc3589x->num_gpio = 20; + break; + case TC3589X_TC35896: + tc3589x->num_gpio = 20; + break; + case TC3589X_UNKNOWN: + tc3589x->num_gpio = 24; + break; + default: + tc3589x->num_gpio = 24; + break; + } i2c_set_clientdata(i2c, tc3589x); @@ -432,7 +471,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);