All of lore.kernel.org
 help / color / mirror / Atom feed
From: Enric Balletbo i Serra <enric.balletbo@collabora.com>
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
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Lee Jones <lee.jones@linaro.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	Richard Purdie <rpurdie@rpsys.net>,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	Pavel Machek <pavel@ucw.cz>, Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Russell King <linux@armlinux.org.uk>,
	Tony Lindgren <tony@atomide.com>,
	javier@dowhile0.org
Subject: [PATCH 4/4] mfd: tps65217: Instantiate sub-devices from device tree
Date: Wed,  7 Jun 2017 12:32:42 +0200	[thread overview]
Message-ID: <20170607103242.16008-4-enric.balletbo@collabora.com> (raw)
In-Reply-To: <20170607103242.16008-1-enric.balletbo@collabora.com>

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 <enric.balletbo@collabora.com>
---
 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 <linux/mfd/core.h>
 #include <linux/mfd/tps65217.h>
 
-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
-- 
2.9.3

WARNING: multiple messages have this Message-ID (diff)
From: enric.balletbo@collabora.com (Enric Balletbo i Serra)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] mfd: tps65217: Instantiate sub-devices from device tree
Date: Wed,  7 Jun 2017 12:32:42 +0200	[thread overview]
Message-ID: <20170607103242.16008-4-enric.balletbo@collabora.com> (raw)
In-Reply-To: <20170607103242.16008-1-enric.balletbo@collabora.com>

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 <enric.balletbo@collabora.com>
---
 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 <linux/mfd/core.h>
 #include <linux/mfd/tps65217.h>
 
-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
-- 
2.9.3

  parent reply	other threads:[~2017-06-07 10:32 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-07 10:32 [PATCH 1/4] dt-bindings: tps65217: Update binding documentation Enric Balletbo i Serra
2017-06-07 10:32 ` Enric Balletbo i Serra
2017-06-07 10:32 ` Enric Balletbo i Serra
2017-06-07 10:32 ` [PATCH 2/4] ARM: dts: tps65217: Add backlight and pmic device Enric Balletbo i Serra
2017-06-07 10:32   ` Enric Balletbo i Serra
2017-06-07 10:32 ` [PATCH 3/4] regulator: tps65217: Fix module autoload for devices registered via OF Enric Balletbo i Serra
2017-06-07 10:32   ` Enric Balletbo i Serra
2017-06-07 10:32 ` Enric Balletbo i Serra [this message]
2017-06-07 10:32   ` [PATCH 4/4] mfd: tps65217: Instantiate sub-devices from device tree Enric Balletbo i Serra
2017-06-07 16:05   ` Grygorii Strashko
2017-06-07 16:05     ` Grygorii Strashko
2017-06-07 16:05     ` Grygorii Strashko
2017-06-08 13:16     ` Enric Balletbo Serra
2017-06-08 13:16       ` Enric Balletbo Serra
2017-06-08 13:16       ` Enric Balletbo Serra
2017-06-08 17:11       ` Grygorii Strashko
2017-06-08 17:11         ` Grygorii Strashko
2017-06-08 17:11         ` Grygorii Strashko
     [not found]         ` <578f348c-509f-79d3-9770-73c9fcffe19c-l0cyMroinI0@public.gmane.org>
2017-06-08 21:35           ` Enric Balletbo Serra
2017-06-08 21:35             ` Enric Balletbo Serra
2017-06-08 21:35             ` Enric Balletbo Serra
2017-06-08 22:30             ` Javier Martinez Canillas
2017-06-08 22:30               ` Javier Martinez Canillas
2017-06-08 22:30               ` Javier Martinez Canillas
2017-06-08 23:47               ` Grygorii Strashko
2017-06-08 23:47                 ` Grygorii Strashko
2017-06-08 23:47                 ` Grygorii Strashko
2017-06-09  0:00                 ` Javier Martinez Canillas
2017-06-09  0:00                   ` Javier Martinez Canillas
2017-06-09  0:00                   ` Javier Martinez Canillas
2017-06-09  9:55                   ` Enric Balletbo Serra
2017-06-09  9:55                     ` Enric Balletbo Serra
2017-06-09  9:55                     ` Enric Balletbo Serra
2017-06-09 14:03 ` [PATCH 1/4] dt-bindings: tps65217: Update binding documentation Rob Herring
2017-06-09 14:03   ` Rob Herring
2017-06-09 22:30   ` Enric Balletbo Serra
2017-06-09 22:30     ` Enric Balletbo Serra
2017-06-09 22:30     ` Enric Balletbo Serra
2017-06-13 14:43     ` Rob Herring
2017-06-13 14:43       ` Rob Herring
2017-06-13 14:43       ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170607103242.16008-4-enric.balletbo@collabora.com \
    --to=enric.balletbo@collabora.com \
    --cc=daniel.thompson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jacek.anaszewski@gmail.com \
    --cc=javier@dowhile0.org \
    --cc=jingoohan1@gmail.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pavel@ucw.cz \
    --cc=robh+dt@kernel.org \
    --cc=rpurdie@rpsys.net \
    --cc=tony@atomide.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.