From patchwork Sun Jan 10 16:18:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Crispin X-Patchwork-Id: 7997281 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E03EABEEE5 for ; Sun, 10 Jan 2016 16:19:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EBCF42024D for ; Sun, 10 Jan 2016 16:19:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 137FC20251 for ; Sun, 10 Jan 2016 16:19:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIIiC-0002mW-NR; Sun, 10 Jan 2016 16:19:24 +0000 Received: from arrakis.dune.hu ([78.24.191.176]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aIIiA-0002ik-Mo for linux-mediatek@lists.infradead.org; Sun, 10 Jan 2016 16:19:23 +0000 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id DAC9328C0D8; Sun, 10 Jan 2016 17:18:26 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from localhost.localdomain (p548C90F7.dip0.t-ipconnect.de [84.140.144.247]) by arrakis.dune.hu (Postfix) with ESMTPSA; Sun, 10 Jan 2016 17:18:26 +0100 (CET) From: John Crispin To: Matthias Brugger Subject: [PATCH 3/4] mfd: mediatek: add support for different Slave types Date: Sun, 10 Jan 2016 17:18:48 +0100 Message-Id: <1452442729-27154-4-git-send-email-blogic@openwrt.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1452442729-27154-1-git-send-email-blogic@openwrt.org> References: <1452442729-27154-1-git-send-email-blogic@openwrt.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160110_081922_965658_CA96309D X-CRM114-Status: GOOD ( 13.76 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: John Crispin --- drivers/mfd/mt6397-core.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/drivers/mfd/mt6397-core.c b/drivers/mfd/mt6397-core.c index 75ad0fe..51e194b 100644 --- a/drivers/mfd/mt6397-core.c +++ b/drivers/mfd/mt6397-core.c @@ -24,6 +24,9 @@ #define MT6397_RTC_BASE 0xe000 #define MT6397_RTC_SIZE 0x3e +#define MT6391_CID_CODE 0x91 +#define MT6397_CID_CODE 0x97 + static const struct resource mt6397_rtc_resources[] = { { .start = MT6397_RTC_BASE, @@ -232,6 +235,7 @@ static SIMPLE_DEV_PM_OPS(mt6397_pm_ops, mt6397_irq_suspend, static int mt6397_probe(struct platform_device *pdev) { int ret; + unsigned int id; struct mt6397_chip *mt6397; mt6397 = devm_kzalloc(&pdev->dev, sizeof(*mt6397), GFP_KERNEL); @@ -239,10 +243,6 @@ static int mt6397_probe(struct platform_device *pdev) return -ENOMEM; mt6397->dev = &pdev->dev; - mt6397->int_con[0] = MT6397_INT_CON0; - mt6397->int_con[1] = MT6397_INT_CON1; - mt6397->int_status[0] = MT6397_INT_STATUS0; - mt6397->int_status[1] = MT6397_INT_STATUS1; /* * mt6397 MFD is child device of soc pmic wrapper. @@ -254,6 +254,29 @@ static int mt6397_probe(struct platform_device *pdev) platform_set_drvdata(pdev, mt6397); + ret = regmap_read(mt6397->regmap, MT6397_CID, &id); + if (ret) { + dev_err(mt6397->dev, "Failed to read chip id: %d\n", ret); + goto fail_irq; + } + + switch (id & 0xff) { + case MT6397_CID_CODE: + case MT6391_CID_CODE: + mt6397->int_con[0] = MT6397_INT_CON0; + mt6397->int_con[1] = MT6397_INT_CON1; + mt6397->int_status[0] = MT6397_INT_STATUS0; + mt6397->int_status[1] = MT6397_INT_STATUS1; + ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs, + ARRAY_SIZE(mt6397_devs), NULL, 0, NULL); + break; + + default: + dev_err(&pdev->dev, "unsupported chip: %d\n", id); + ret = -ENODEV; + break; + } + mt6397->irq = platform_get_irq(pdev, 0); if (mt6397->irq > 0) { ret = mt6397_irq_init(mt6397); @@ -261,10 +284,11 @@ static int mt6397_probe(struct platform_device *pdev) return ret; } - ret = mfd_add_devices(&pdev->dev, -1, mt6397_devs, - ARRAY_SIZE(mt6397_devs), NULL, 0, NULL); - if (ret) +fail_irq: + if (ret) { + irq_domain_remove(mt6397->irq_domain); dev_err(&pdev->dev, "failed to add child devices: %d\n", ret); + } return ret; }