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: 3065521 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5D587BF924 for ; Fri, 18 Oct 2013 09:53:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C75E204E2 for ; Fri, 18 Oct 2013 09:53:00 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 96918204D3 for ; Fri, 18 Oct 2013 09:52:58 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX6jO-0002hf-Fp; Fri, 18 Oct 2013 09:52:30 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX6jD-0005zQ-5v; Fri, 18 Oct 2013 09:52:19 +0000 Received: from mail-wg0-f49.google.com ([74.125.82.49]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VX6j8-0005xq-AS for linux-arm-kernel@lists.infradead.org; Fri, 18 Oct 2013 09:52:15 +0000 Received: by mail-wg0-f49.google.com with SMTP id x12so3418489wgg.28 for ; Fri, 18 Oct 2013 02:51:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/6Ow0MCLSWCnWCeuNU0MfpeMPKQg/2BsFU4/zuxxMBc=; b=eGBhQ0mSbIAid2n5MC7EqV5nkHpC4SL6YDFu6DwwgyKuNgLbH58z0NnoyTtAADYrOT LCf5zSMQWPCra2wwKsYzJ7ObFbZmJWCITUO5u8VzqUpjjCiMSd33HjyuLP+jv41xxlpZ gBaD4vP/DBpBOJ5l82uaJAzeMXkeTfdaYoE8VGDsOd+YaXlF03bY70GG6TlBUrWpTsZb 6fU+31vH8hjJmVJ8nxR3/zr1alLzTLptno0sdnyJ2xSRidz0YY7HFkyQExpaM5qzoHvN wyyyN0MyuuONVpPtfFRbKqfOTiQuwnMfwXig9sZTTciZpfm3ryL0g5odc/FQCp+GZp8n bAqw== X-Gm-Message-State: ALoCoQkiXLxrsJvKXtECGGfUJv3Yu/NTSZsc4Q1Rp+Fd36l4oemXHaNrD6jiZSJ+Hjeqkvi8cTeM 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 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131018_055214_508404_50E9B320 X-CRM114-Status: GOOD ( 13.26 ) X-Spam-Score: -2.6 (--) Cc: Linus Walleij , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);