mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Ujfalusi <peter.ujfalusi@ti.com>
To: Samuel Ortiz <sameo@linux.intel.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Linus Walleij <linus.walleij@stericsson.com>
Cc: linux-kernel@vger.kernel.org, peter.ujfalusi@ti.com,
	Sergio Aguirre <saaguirre@ti.com>
Subject: [PATCH 2/3] mfd: twl6040: Add twl6040-gpio child
Date: Wed, 18 Jul 2012 11:20:19 +0200	[thread overview]
Message-ID: <1342603220-13287-3-git-send-email-peter.ujfalusi@ti.com> (raw)
In-Reply-To: <1342603220-13287-1-git-send-email-peter.ujfalusi@ti.com>

Add needed platform data structure and code to be able to load
the GPO child of twl6040.
Update the devicetree binding documentation at the same time.

Signed-off-by: Sergio Aguirre <saaguirre@ti.com>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
---
 Documentation/devicetree/bindings/mfd/twl6040.txt |    4 +++
 drivers/mfd/twl6040-core.c                        |   27 +++++++++++++++++++++
 include/linux/mfd/twl6040.h                       |    9 ++++++-
 3 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/Documentation/devicetree/bindings/mfd/twl6040.txt b/Documentation/devicetree/bindings/mfd/twl6040.txt
index c855240..2a3d55c 100644
--- a/Documentation/devicetree/bindings/mfd/twl6040.txt
+++ b/Documentation/devicetree/bindings/mfd/twl6040.txt
@@ -10,6 +10,8 @@ Required properties:
 - reg: must be 0x4b for i2c address
 - interrupts: twl6040 has one interrupt line connecteded to the main SoC
 - interrupt-parent: The parent interrupt controller
+- gpio-controller:
+- #gpio-cells = <1>: twl6040 provides GPO lines.
 - twl6040,audpwron-gpio: Power on GPIO line for the twl6040
 
 - vio-supply: Regulator for the twl6040 VIO supply
@@ -29,6 +31,8 @@ Required properties:
 - ti,viblmotor-res: Resistance parameter for left motor
 - ti,viblmotor-res: Resistance parameter for right motor
 
+- ti,use-gpo: Set it to <1> if the GPO functionality is in use
+
 Optional properties within vibra { } section:
 - vddvibl_uV: If the vddvibl default voltage need to be changed
 - vddvibr_uV: If the vddvibr default voltage need to be changed
diff --git a/drivers/mfd/twl6040-core.c b/drivers/mfd/twl6040-core.c
index b0fad0f..8ea5b9e 100644
--- a/drivers/mfd/twl6040-core.c
+++ b/drivers/mfd/twl6040-core.c
@@ -59,6 +59,22 @@ static bool twl6040_has_vibra(struct twl6040_platform_data *pdata,
 	return false;
 }
 
+static bool twl6040_has_gpo(struct twl6040_platform_data *pdata,
+			      struct device_node *node)
+{
+	int use_gpo;
+
+	if (pdata && pdata->gpo)
+		return true;
+
+#ifdef CONFIG_OF
+	if (!of_property_read_u32(node, "ti,use-gpo", &use_gpo) && use_gpo)
+		return true;
+#endif
+
+	return false;
+}
+
 int twl6040_reg_read(struct twl6040 *twl6040, unsigned int reg)
 {
 	int ret;
@@ -631,6 +647,17 @@ static int __devinit twl6040_probe(struct i2c_client *client,
 		children++;
 	}
 
+	if (twl6040_has_gpo(pdata, node)) {
+		cell = &twl6040->cells[children];
+		cell->name = "twl6040-gpo";
+
+		if (pdata && pdata->gpo) {
+			cell->platform_data = pdata->gpo;
+			cell->pdata_size = sizeof(*pdata->gpo);
+		}
+		children++;
+	}
+
 	ret = mfd_add_devices(&client->dev, -1, twl6040->cells, children,
 			      NULL, 0);
 	if (ret)
diff --git a/include/linux/mfd/twl6040.h b/include/linux/mfd/twl6040.h
index 269b706..8991532 100644
--- a/include/linux/mfd/twl6040.h
+++ b/include/linux/mfd/twl6040.h
@@ -158,7 +158,7 @@
 #define TWL6040_VIBROCDET		0x20
 #define TWL6040_TSHUTDET                0x40
 
-#define TWL6040_CELLS			2
+#define TWL6040_CELLS			3
 
 #define TWL6040_REV_ES1_0		0x00
 #define TWL6040_REV_ES1_1		0x01 /* Rev ES1.1 and ES1.2 */
@@ -176,6 +176,8 @@
 #define TWL6040_SYSCLK_SEL_LPPLL	0
 #define TWL6040_SYSCLK_SEL_HPPLL	1
 
+#define TWL6040_GPO_MAX	3
+
 struct twl6040_codec_data {
 	u16 hs_left_step;
 	u16 hs_right_step;
@@ -192,12 +194,17 @@ struct twl6040_vibra_data {
 	int vddvibr_uV;			/* VDDVIBR volt, set 0 for fixed reg */
 };
 
+struct twl6040_gpo_data {
+	int gpio_base;
+};
+
 struct twl6040_platform_data {
 	int audpwron_gpio;	/* audio power-on gpio */
 	unsigned int irq_base;
 
 	struct twl6040_codec_data *codec;
 	struct twl6040_vibra_data *vibra;
+	struct twl6040_gpo_data *gpo;
 };
 
 struct regmap;
-- 
1.7.8.6


  parent reply	other threads:[~2012-07-18  9:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18  9:20 [PATCH 0/3] MFD/GPIO: Add twl6040 GPO driver Peter Ujfalusi
2012-07-18  9:20 ` [PATCH 1/3] mfd: twl6040: Fix GPO mask Peter Ujfalusi
2012-07-27 22:45   ` Linus Walleij
2012-07-30 14:17     ` Peter Ujfalusi
2012-07-18  9:20 ` Peter Ujfalusi [this message]
2012-07-27 22:50   ` [PATCH 2/3] mfd: twl6040: Add twl6040-gpio child Linus Walleij
2012-07-30 14:13     ` Peter Ujfalusi
2012-08-09 11:55       ` Mark Brown
2012-08-09 12:10         ` Peter Ujfalusi
2012-07-18  9:20 ` [PATCH 3/3] gpio: Add basic support for TWL6040 GPOs Peter Ujfalusi
2012-07-27 22:55   ` Linus Walleij
2012-07-27 22:43 ` [PATCH 0/3] MFD/GPIO: Add twl6040 GPO driver Linus Walleij

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=1342603220-13287-3-git-send-email-peter.ujfalusi@ti.com \
    --to=peter.ujfalusi@ti.com \
    --cc=grant.likely@secretlab.ca \
    --cc=linus.walleij@stericsson.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saaguirre@ti.com \
    --cc=sameo@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®