From patchwork Fri Feb 7 10:04:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 3601511 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 41E699F344 for ; Fri, 7 Feb 2014 11:36:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4EDAE200FE for ; Fri, 7 Feb 2014 11:36:03 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 465E8200D5 for ; Fri, 7 Feb 2014 11:36:02 +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 1WBiMj-0000Ax-NA; Fri, 07 Feb 2014 10:08:58 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBiLl-00024V-Qw; Fri, 07 Feb 2014 10:07:57 +0000 Received: from mailout3.w1.samsung.com ([210.118.77.13]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WBiKE-0001k6-2C for linux-arm-kernel@lists.infradead.org; Fri, 07 Feb 2014 10:06:30 +0000 Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N0M00GEYEOPHH70@mailout3.w1.samsung.com> for linux-arm-kernel@lists.infradead.org; Fri, 07 Feb 2014 10:05:13 +0000 (GMT) X-AuditID: cbfec7f5-b7fc96d000004885-ce-52f4afd93833 Received: from eusync3.samsung.com ( [203.254.199.213]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 25.A5.18565.9DFA4F25; Fri, 07 Feb 2014 10:05:13 +0000 (GMT) Received: from AMDC1943.digital.local ([106.116.151.171]) by eusync3.samsung.com (Oracle Communications Messaging Server 7u4-23.01(7.0.4.23.0) 64bit (built Aug 10 2011)) with ESMTPA id <0N0M00ISREO95580@eusync3.samsung.com>; Fri, 07 Feb 2014 10:05:13 +0000 (GMT) From: Krzysztof Kozlowski To: MyungJoo Ham , Chanwoo Choi , Samuel Ortiz , Lee Jones , Mark Brown , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 07/15] extcon: max14577: Choose muic_irqs according to device type Date: Fri, 07 Feb 2014 11:04:39 +0100 Message-id: <1391767487-10017-8-git-send-email-k.kozlowski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1391767487-10017-1-git-send-email-k.kozlowski@samsung.com> References: <1391767487-10017-1-git-send-email-k.kozlowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Vd2b678EGRybyWGxccZ6VoupD5+w WVz/8pzV4vULQ4uzTW/YLe5/PcposenxNVaLy7vmsFmsPXKX3eJ24wo2i9PdrA7cHptWdbJ5 3Lm2h81j3slAj81L6j36tqxi9Pi8SS6ALYrLJiU1J7MstUjfLoEr4+yms6wFKxUqtt38yN7A +Fiqi5GTQ0LAROLExqlsELaYxIV764FsLg4hgaWMEtM3fGGCcPqYJE6duw9WxSZgLLF5+RKw KhGBFiaJ9+v3M4IkmAWOMko8WWYIYgsLhEtc29/DAmKzCKhK3Dv/lRnE5hVwl9h79yLQVA6g dQoScybZgIQ5BTwktjw4xwpiCwGV/FrWwz6BkXcBI8MqRtHU0uSC4qT0XCO94sTc4tK8dL3k /NxNjJAA/LqDcekxq0OMAhyMSjy8iis+BwmxJpYVV+YeYpTgYFYS4dVY+yVIiDclsbIqtSg/ vqg0J7X4ECMTB6dUA+Nk4T9yioeWc1V1LHdsud7Uk3T83m6OLO33m9aY2QZeXRC0sydDtJ4n TL6txTTk2KsbDTckvv3JZ7Z+5L5jeu6O6SreLu5su64qNSz487Sx6aCywbLHcwOZvAWkL6vX LjiU0vnGoWbLWqMvQcuCP9zS2TBH8zCj0ub2N8KHbUOfzvmd++poQq0SS3FGoqEWc1FxIgAN 9kenHgIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140207_050622_271549_51E9CAA3 X-CRM114-Status: GOOD ( 15.74 ) X-Spam-Score: -7.4 (-------) Cc: Kyungmin Park , Bartlomiej Zolnierkiewicz , Krzysztof Kozlowski , Marek Szyprowski 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.7 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, 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 This patch continues the preparation for adding support for max77836 device to existing max14577 driver. During probe choose muic_irqs according to device type. Currently there are only "max14577_muic_irqs" but later patch will add max77836 interrupts. Signed-off-by: Krzysztof Kozlowski Cc: Kyungmin Park Cc: Marek Szyprowski Acked-by: Chanwoo Choi Tested-by: Chanwoo Choi --- drivers/extcon/extcon-max14577.c | 65 ++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c index fb343f4042d2..e986a9b92b60 100644 --- a/drivers/extcon/extcon-max14577.c +++ b/drivers/extcon/extcon-max14577.c @@ -39,6 +39,29 @@ enum max14577_muic_status { MAX14577_MUIC_STATUS_END, }; +/** + * struct max14577_muic_irq + * @irq: the index of irq list of MUIC device. + * @name: the name of irq. + * @virq: the virtual irq to use irq domain + */ +struct max14577_muic_irq { + unsigned int irq; + const char *name; + unsigned int virq; +}; + +static struct max14577_muic_irq max14577_muic_irqs[] = { + { MAXIM_IRQ_INT1_ADC, "muic-ADC" }, + { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" }, + { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" }, + { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" }, + { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" }, + { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" }, + { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" }, + { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" }, +}; + struct max14577_muic_info { struct device *dev; struct maxim_core *maxim_core; @@ -47,6 +70,8 @@ struct max14577_muic_info { int prev_chg_type; u8 status[MAX14577_MUIC_STATUS_END]; + struct max14577_muic_irq *muic_irqs; + unsigned int muic_irqs_num; bool irq_adc; bool irq_chg; struct work_struct irq_work; @@ -73,29 +98,6 @@ enum max14577_muic_cable_group { MAX14577_CABLE_GROUP_CHG, }; -/** - * struct max14577_muic_irq - * @irq: the index of irq list of MUIC device. - * @name: the name of irq. - * @virq: the virtual irq to use irq domain - */ -struct max14577_muic_irq { - unsigned int irq; - const char *name; - unsigned int virq; -}; - -static struct max14577_muic_irq max14577_muic_irqs[] = { - { MAXIM_IRQ_INT1_ADC, "muic-ADC" }, - { MAXIM_IRQ_INT1_ADCLOW, "muic-ADCLOW" }, - { MAXIM_IRQ_INT1_ADCERR, "muic-ADCError" }, - { MAXIM_IRQ_INT2_CHGTYP, "muic-CHGTYP" }, - { MAXIM_IRQ_INT2_CHGDETRUN, "muic-CHGDETRUN" }, - { MAXIM_IRQ_INT2_DCDTMR, "muic-DCDTMR" }, - { MAXIM_IRQ_INT2_DBCHG, "muic-DBCHG" }, - { MAXIM_IRQ_INT2_VBVOLT, "muic-VBVOLT" }, -}; - /* Define supported accessory type */ enum max14577_muic_acc_type { MAX14577_MUIC_ADC_GROUND = 0x0, @@ -541,9 +543,9 @@ static irqreturn_t max14577_muic_irq_handler(int irq, void *data) * However we only need to know whether it was ADC, charger * or both interrupts so decode IRQ and turn on proper flags. */ - for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) - if (irq == max14577_muic_irqs[i].virq) - irq_type = max14577_muic_irqs[i].irq; + for (i = 0; i < info->muic_irqs_num; i++) + if (irq == info->muic_irqs[i].virq) + irq_type = info->muic_irqs[i].irq; switch (irq_type) { case MAXIM_IRQ_INT1_ADC: @@ -646,9 +648,16 @@ static int max14577_muic_probe(struct platform_device *pdev) INIT_WORK(&info->irq_work, max14577_muic_irq_work); + switch (maxim_core->dev_type) { + case MAXIM_DEVICE_TYPE_MAX14577: + default: + info->muic_irqs = max14577_muic_irqs; + info->muic_irqs_num = ARRAY_SIZE(max14577_muic_irqs); + } + /* Support irq domain for max14577 MUIC device */ - for (i = 0; i < ARRAY_SIZE(max14577_muic_irqs); i++) { - struct max14577_muic_irq *muic_irq = &max14577_muic_irqs[i]; + for (i = 0; i < info->muic_irqs_num; i++) { + struct max14577_muic_irq *muic_irq = &info->muic_irqs[i]; unsigned int virq = 0; virq = regmap_irq_get_virq(maxim_core->irq_data_muic,