From patchwork Wed Jun 7 10:32:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 9771245 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7586A6034B for ; Wed, 7 Jun 2017 10:33:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 501A5268AE for ; Wed, 7 Jun 2017 10:33:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 42C0628471; Wed, 7 Jun 2017 10:33:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C6E7E268AE for ; Wed, 7 Jun 2017 10:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=8ychTvD9EYTFXyGO2w8sc+JFq7/y4acMAgoKi9g+WMY=; b=EuQxLM5hTrVq8uEWzODFUGI8Ti +jtjwdf2IBy9dOSJX99eLNpgDSUUOB4VMiALiFFlLbEZ1qhomNFfvosUFd1ZF4KlZX0BV5rjmuqnf dSDPfKGopuOIGocH1WyyOT+wV/LEvcocXqpThdLJXGx1loFrp/Y0XKcsDF8zBypRy1pbJTJl2J7o2 DjbtJFzCpQJ8z1RVZDlOTmDIH1Ots2Cvt+bJXgwcvpvuqCHWf2dZcf/2yzybCnkGJZvMV1gholSGO vDCVzoNS53JiVgvvHtOfBIxYarPkw6TCD8GbQ8bIc88wEs28GlwldX97GFvZPODiJ7jUgCy+JpECz BCugxKZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dIYHP-0002LO-Nb; Wed, 07 Jun 2017 10:33:35 +0000 Received: from bhuna.collabora.co.uk ([46.235.227.227]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dIYHB-00024S-HY for linux-arm-kernel@lists.infradead.org; Wed, 07 Jun 2017 10:33:23 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 26EB026B8E4 From: Enric Balletbo i Serra To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH 4/4] mfd: tps65217: Instantiate sub-devices from device tree Date: Wed, 7 Jun 2017 12:32:42 +0200 Message-Id: <20170607103242.16008-4-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170607103242.16008-1-enric.balletbo@collabora.com> References: <20170607103242.16008-1-enric.balletbo@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170607_033321_872826_A01FE4A8 X-CRM114-Status: GOOD ( 14.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Daniel Thompson , Tony Lindgren , Jingoo Han , Dmitry Torokhov , Russell King , Rob Herring , Richard Purdie , Jacek Anaszewski , Pavel Machek , javier@dowhile0.org, Lee Jones MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The driver boots only via device tree but currently all the MFD sub-devices are instatiated independently of the device tree configuration, i.e although tps65217-charger is disabled by default it's instantiated by the MFD driver. Instead of register all sub-devices, if the TPS65217 device tree node has a sub-node enabled, try to instatiate them as MFD sub-devices but not instantiate sub-nodes that are not enabled. Signed-off-by: Enric Balletbo i Serra --- drivers/mfd/tps65217.c | 56 +++++++------------------------------------- include/linux/mfd/tps65217.h | 6 ----- 2 files changed, 9 insertions(+), 53 deletions(-) diff --git a/drivers/mfd/tps65217.c b/drivers/mfd/tps65217.c index f769c7d..9effdda 100644 --- a/drivers/mfd/tps65217.c +++ b/drivers/mfd/tps65217.c @@ -33,14 +33,7 @@ #include #include -static struct resource charger_resources[] = { - DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_AC, "AC"), - DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_USB, "USB"), -}; - -static struct resource pb_resources[] = { - DEFINE_RES_IRQ_NAMED(TPS65217_IRQ_PB, "PB"), -}; +#define TPS65217_NUM_IRQ 3 static void tps65217_irq_lock(struct irq_data *data) { @@ -86,29 +79,6 @@ static struct irq_chip tps65217_irq_chip = { .irq_disable = tps65217_irq_disable, }; -static struct mfd_cell tps65217s[] = { - { - .name = "tps65217-pmic", - .of_compatible = "ti,tps65217-pmic", - }, - { - .name = "tps65217-bl", - .of_compatible = "ti,tps65217-bl", - }, - { - .name = "tps65217-charger", - .num_resources = ARRAY_SIZE(charger_resources), - .resources = charger_resources, - .of_compatible = "ti,tps65217-charger", - }, - { - .name = "tps65217-pwrbutton", - .num_resources = ARRAY_SIZE(pb_resources), - .resources = pb_resources, - .of_compatible = "ti,tps65217-pwrbutton", - }, -}; - static irqreturn_t tps65217_irq_thread(int irq, void *data) { struct tps65217 *tps = data; @@ -359,23 +329,8 @@ static int tps65217_probe(struct i2c_client *client, return ret; } - if (client->irq) { + if (client->irq) tps65217_irq_init(tps, client->irq); - } else { - int i; - - /* Don't tell children about IRQ resources which won't fire */ - for (i = 0; i < ARRAY_SIZE(tps65217s); i++) - tps65217s[i].num_resources = 0; - } - - ret = devm_mfd_add_devices(tps->dev, -1, tps65217s, - ARRAY_SIZE(tps65217s), NULL, 0, - tps->irq_domain); - if (ret < 0) { - dev_err(tps->dev, "mfd_add_devices failed: %d\n", ret); - return ret; - } ret = tps65217_reg_read(tps, TPS65217_REG_CHIPID, &version); if (ret < 0) { @@ -384,6 +339,13 @@ static int tps65217_probe(struct i2c_client *client, return ret; } + ret = of_platform_populate(client->dev.of_node, NULL, NULL, + &client->dev); + if (ret) { + dev_err(&client->dev, "Failed to register sub-devices\n"); + return ret; + } + /* Set the PMIC to shutdown on PWR_EN toggle */ if (status_off) { ret = tps65217_set_bits(tps, TPS65217_REG_STATUS, diff --git a/include/linux/mfd/tps65217.h b/include/linux/mfd/tps65217.h index eac2857..dfc51f5 100644 --- a/include/linux/mfd/tps65217.h +++ b/include/linux/mfd/tps65217.h @@ -236,12 +236,6 @@ struct tps65217_bl_pdata { int dft_brightness; }; -/* Interrupt numbers */ -#define TPS65217_IRQ_USB 0 -#define TPS65217_IRQ_AC 1 -#define TPS65217_IRQ_PB 2 -#define TPS65217_NUM_IRQ 3 - /** * struct tps65217_board - packages regulator init data * @tps65217_regulator_data: regulator initialization values