linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/26] AB8500 MFD overhaul
@ 2013-01-15 12:55 Lee Jones
  2013-01-15 12:55 ` [PATCH 01/26] mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back Lee Jones
                   ` (25 more replies)
  0 siblings, 26 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: arnd, linus.walleij, sameo

Hi Sam,

So, "what the hell is this?" I hear you cry. Well, my team and
I are in the mists of an delta upstreaming torrent. As I'm sure
you've heard, ST-Ericsson's kernel delta is getting pretty big
now. There have been some excellent, interesting changes and
one way or another we need to sync them with Mainline. There is
also a big push to update the internal kernel with Mainline
changes too.

There are ~125 patches in drivers/mfd (lucky you) which are
currently held as delta. I'm hoping to whittle them down a
little, but whichever way you look at it, it's a lot of code.

I'd really appreciate it if you'd allow a little leniency with
regards to this and subsequent patch-sets. Some of the earlier
patches introduce some small issues which are ironed out in
latter patches. Some issues will still exist and the end of the
push, but I have every intention of fixing those once everything
is in. Please feel free to make comments on any
issues that you see, but instead of fixing them up right away,
I'd rather make a list of them and address them at the end, if
they're still present.

Thanks in advance.

Kind regards,
Lee

 drivers/mfd/ab8500-core.c                 |   12 +-
 drivers/mfd/ab8500-debugfs.c              | 1247 +++++++++++++++++++++++++++--
 drivers/mfd/ab8500-gpadc.c                |   90 ++-
 drivers/mfd/ab8500-sysctrl.c              |   93 +++
 drivers/mfd/abx500-core.c                 |   16 +
 drivers/misc/ab8500-pwm.c                 |  282 +++++++
 include/linux/mfd/ab8500/pwmleds.h        |   20 +
 include/linux/mfd/abx500.h                |    2 +
 include/linux/mfd/abx500/ab8500-sysctrl.h |    5 +
 include/linux/mfd/abx500/ab8500.h         |   14 +
 10 files changed, 1697 insertions(+), 84 deletions(-)


^ permalink raw reply	[flat|nested] 55+ messages in thread

* [PATCH 01/26] mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead Lee Jones
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: arnd, linus.walleij, sameo, Lee Jones

The kernel allows us to specify a function call-back which will be
invoked when a system power-off request has been received. Here we
provide one which is to be used when shutting down AB8500 based
platforms.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/ab8500-sysctrl.c      |   22 ++++++++++++++++++++++
 include/linux/mfd/abx500/ab8500.h |    2 ++
 2 files changed, 24 insertions(+)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index c28d4eb..799fb5e 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -7,12 +7,29 @@
 #include <linux/err.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/signal.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500/ab8500-sysctrl.h>
 
 static struct device *sysctrl_dev;
 
+void ab8500_power_off(void)
+{
+	sigset_t old;
+	sigset_t all;
+
+	sigfillset(&all);
+
+	if (!sigprocmask(SIG_BLOCK, &all, &old)) {
+		(void)ab8500_sysctrl_set(AB8500_STW4500CTRL1,
+					 AB8500_STW4500CTRL1_SWOFF |
+					 AB8500_STW4500CTRL1_SWRESET4500N);
+		(void)sigprocmask(SIG_SETMASK, &old, NULL);
+	}
+}
+
 static inline bool valid_bank(u8 bank)
 {
 	return ((bank == AB8500_SYS_CTRL1_BLOCK) ||
@@ -51,7 +68,12 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
 
 static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
 {
+	struct ab8500_platform_data *plat;
+
 	sysctrl_dev = &pdev->dev;
+	plat = dev_get_platdata(pdev->dev.parent);
+	if (plat->pm_power_off)
+		pm_power_off = ab8500_power_off;
 	return 0;
 }
 
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 1491044..96840c4 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -274,6 +274,7 @@ struct ab8500_codec_platform_data;
 /**
  * struct ab8500_platform_data - AB8500 platform data
  * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used
+ * @pm_power_off: Should machine pm power off hook be registered or not
  * @init: board-specific initialization after detection of ab8500
  * @num_regulator_reg_init: number of regulator init registers
  * @regulator_reg_init: regulator init registers
@@ -282,6 +283,7 @@ struct ab8500_codec_platform_data;
  */
 struct ab8500_platform_data {
 	int irq_base;
+	bool pm_power_off;
 	void (*init) (struct ab8500 *);
 	int num_regulator_reg_init;
 	struct ab8500_regulator_reg_init *regulator_reg_init;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
  2013-01-15 12:55 ` [PATCH 01/26] mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:52   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 03/26] mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known Lee Jones
                   ` (23 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

If a changer is attached on power off, reboot the system
into charging mode instead of powering it off.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
---
 drivers/mfd/ab8500-sysctrl.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 799fb5e..01b0669 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -8,7 +8,9 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
+#include <linux/reboot.h>
 #include <linux/signal.h>
+#include <linux/power_supply.h>
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
 #include <linux/mfd/abx500/ab8500-sysctrl.h>
@@ -19,6 +21,31 @@ void ab8500_power_off(void)
 {
 	sigset_t old;
 	sigset_t all;
+	static char *pss[] = {"ab8500_ac", "ab8500_usb"};
+	int i;
+
+	/*
+	 * If we have a charger connected and we're powering off,
+	 * reboot into charge-only mode.
+	 */
+
+	for (i = 0; i < ARRAY_SIZE(pss); i++) {
+		union power_supply_propval val;
+		struct power_supply *psy;
+		int ret;
+
+		psy = power_supply_get_by_name(pss[i]);
+		if (!psy)
+			continue;
+		ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
+
+		if (!ret && val.intval) {
+			printk(KERN_INFO
+			       "Charger \"%s\" is connected. Rebooting.\n",
+			       pss[i]);
+			machine_restart(NULL);
+		}
+	}
 
 	sigfillset(&all);
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 03/26] mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
  2013-01-15 12:55 ` [PATCH 01/26] mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back Lee Jones
  2013-01-15 12:55 ` [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 04/26] mfd: ab8500-sysctrl.c: Provide charging as reset reason Lee Jones
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

When a charger is connected, we usually want AB8500 based systems to
reboot into charging-only mode. However, if the battery type cannot
be identified this would be futile, so we'll just shut the system
down instead.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
---
 drivers/mfd/ab8500-sysctrl.c |   27 ++++++++++++++++++++++-----
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 01b0669..26216e7 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -23,6 +23,10 @@ void ab8500_power_off(void)
 	sigset_t all;
 	static char *pss[] = {"ab8500_ac", "ab8500_usb"};
 	int i;
+	bool charger_present = false;
+	union power_supply_propval val;
+	struct power_supply *psy;
+	int ret;
 
 	/*
 	 * If we have a charger connected and we're powering off,
@@ -30,23 +34,36 @@ void ab8500_power_off(void)
 	 */
 
 	for (i = 0; i < ARRAY_SIZE(pss); i++) {
-		union power_supply_propval val;
-		struct power_supply *psy;
-		int ret;
-
 		psy = power_supply_get_by_name(pss[i]);
 		if (!psy)
 			continue;
+
 		ret = psy->get_property(psy, POWER_SUPPLY_PROP_ONLINE, &val);
 
 		if (!ret && val.intval) {
+			charger_present = true;
+			break;
+		}
+	}
+
+	if (!charger_present)
+		goto shutdown;
+
+	/* Check if battery is known */
+	psy = power_supply_get_by_name("ab8500_btemp");
+	if (psy) {
+		ret = psy->get_property(psy, POWER_SUPPLY_PROP_TECHNOLOGY,
+					&val);
+		if (!ret && val.intval != POWER_SUPPLY_TECHNOLOGY_UNKNOWN) {
 			printk(KERN_INFO
-			       "Charger \"%s\" is connected. Rebooting.\n",
+			       "Charger \"%s\" is connected with known battery."
+			       " Rebooting.\n",
 			       pss[i]);
 			machine_restart(NULL);
 		}
 	}
 
+shutdown:
 	sigfillset(&all);
 
 	if (!sigprocmask(SIG_BLOCK, &all, &old)) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 04/26] mfd: ab8500-sysctrl.c: Provide charging as reset reason
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (2 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 03/26] mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution Lee Jones
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

It's possible to supply a string to provide a reason for
triggering a restart. In this case our reason is to enter
charging-only mode, as a charger was found to be present.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
---
 drivers/mfd/ab8500-sysctrl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 26216e7..cf58f69 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -59,7 +59,7 @@ void ab8500_power_off(void)
 			       "Charger \"%s\" is connected with known battery."
 			       " Rebooting.\n",
 			       pss[i]);
-			machine_restart(NULL);
+			machine_restart("charging");
 		}
 	}
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (3 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 04/26] mfd: ab8500-sysctrl.c: Provide charging as reset reason Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:52   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers Lee Jones
                   ` (20 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

The resolution of msleep is related to HZ, so with HZ set to
100 any msleep of less than 10ms will become ~10ms.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Bibek BASU <bibek.basu@stericsson.com>
Tested-by: Bibek BASU <bibek.basu@stericsson.com>
---
 drivers/mfd/ab8500-gpadc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 29d72a2..3883b93 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -344,7 +344,7 @@ int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel)
 		  * Delay might be needed for ABB8500 cut 3.0, if not, remove
 		  * when hardware will be available
 		  */
-			msleep(1);
+			mdelay(1);
 			break;
 		}
 		/* Intentional fallthrough */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (4 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:52   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 07/26] mfd: ab8500-sysctrl: export read/write symbols Lee Jones
                   ` (19 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Kennet Wallden, Lee Jones

From: Kennet Wallden <kennet.wallden@stericsson.com>

Add the possibility to pass configuration settings for
SysCl1kReqRfClkBuf to SysClk8ReqRfClkBuf via platform data.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Kennet Wallden <kennet.wallden@stericsson.com>
Reviewed-by: Karl-Johan PERNTZ <karl-johan.perntz@stericsson.com>
Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
---
 drivers/mfd/ab8500-sysctrl.c              |   25 +++++++++++++++++++++++++
 include/linux/mfd/abx500/ab8500-sysctrl.h |    5 +++++
 include/linux/mfd/abx500/ab8500.h         |    2 ++
 3 files changed, 32 insertions(+)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index cf58f69..19a024e 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -113,11 +113,36 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
 static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
 {
 	struct ab8500_platform_data *plat;
+	struct ab8500_sysctrl_platform_data *pdata;
 
 	sysctrl_dev = &pdev->dev;
 	plat = dev_get_platdata(pdev->dev.parent);
 	if (plat->pm_power_off)
 		pm_power_off = ab8500_power_off;
+
+	pdata = plat->sysctrl;
+
+	if (pdata) {
+		int ret;
+		int i;
+		int j;
+		for (i = AB8500_SYSCLKREQ1RFCLKBUF;
+		     i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) {
+			j = i - AB8500_SYSCLKREQ1RFCLKBUF;
+			ret = ab8500_sysctrl_write(i, 0xff,
+						   pdata->initial_req_buf_config[j]);
+			dev_dbg(&pdev->dev,
+				"Setting SysClkReq%dRfClkBuf 0x%X\n",
+				j + 1,
+				pdata->initial_req_buf_config[j]);
+			if (ret < 0) {
+				dev_err(&pdev->dev,
+					"unable to set sysClkReq%dRfClkBuf: "
+					"%d\n", j + 1, ret);
+			}
+		}
+	}
+
 	return 0;
 }
 
diff --git a/include/linux/mfd/abx500/ab8500-sysctrl.h b/include/linux/mfd/abx500/ab8500-sysctrl.h
index 10eb509..ebf12e7 100644
--- a/include/linux/mfd/abx500/ab8500-sysctrl.h
+++ b/include/linux/mfd/abx500/ab8500-sysctrl.h
@@ -37,6 +37,11 @@ static inline int ab8500_sysctrl_clear(u16 reg, u8 bits)
 	return ab8500_sysctrl_write(reg, bits, 0);
 }
 
+/* Configuration data for SysClkReq1RfClkBuf - SysClkReq8RfClkBuf */
+struct ab8500_sysctrl_platform_data {
+	u8 initial_req_buf_config[8];
+};
+
 /* Registers */
 #define AB8500_TURNONSTATUS		0x100
 #define AB8500_RESETSTATUS		0x101
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 96840c4..3f4e6d1 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -270,6 +270,7 @@ struct regulator_reg_init;
 struct regulator_init_data;
 struct ab8500_gpio_platform_data;
 struct ab8500_codec_platform_data;
+struct ab8500_sysctrl_platform_data;
 
 /**
  * struct ab8500_platform_data - AB8500 platform data
@@ -291,6 +292,7 @@ struct ab8500_platform_data {
 	struct regulator_init_data *regulator;
 	struct ab8500_gpio_platform_data *gpio;
 	struct ab8500_codec_platform_data *codec;
+	struct ab8500_sysctrl_platform_data *sysctrl;
 };
 
 extern int __devinit ab8500_init(struct ab8500 *ab8500,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 07/26] mfd: ab8500-sysctrl: export read/write symbols
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (5 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 08/26] mfd: abx500-core: Provide an API to dump all ABx500 registers Lee Jones
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

Export ab8500_sysctrl_read() and ab8500_sysctrl_write() symobols.

They will be used by LTP test cases.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
---
 drivers/mfd/ab8500-sysctrl.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
index 19a024e..5a61e94 100644
--- a/drivers/mfd/ab8500-sysctrl.c
+++ b/drivers/mfd/ab8500-sysctrl.c
@@ -94,6 +94,7 @@ int ab8500_sysctrl_read(u16 reg, u8 *value)
 	return abx500_get_register_interruptible(sysctrl_dev, bank,
 		(u8)(reg & 0xFF), value);
 }
+EXPORT_SYMBOL(ab8500_sysctrl_read);
 
 int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
 {
@@ -109,6 +110,7 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
 	return abx500_mask_and_set_register_interruptible(sysctrl_dev, bank,
 		(u8)(reg & 0xFF), mask, value);
 }
+EXPORT_SYMBOL(ab8500_sysctrl_write);
 
 static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
 {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 08/26] mfd: abx500-core: Provide an API to dump all ABx500 registers
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (6 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 07/26] mfd: ab8500-sysctrl: export read/write symbols Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs Lee Jones
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Mian Yousaf Kaukab, Lee Jones

From: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>

Some drivers can detect subsystem failures e.g. shared memory driver
can detect modem sub system failures. It would be helpful in analyzing
these failures if AB register dump is available at that point. This
patch adds the API for the drivers to dump AB registers in the kernel
log.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
---
 drivers/mfd/abx500-core.c  |   16 ++++++++++++++++
 include/linux/mfd/abx500.h |    2 ++
 2 files changed, 18 insertions(+)

diff --git a/drivers/mfd/abx500-core.c b/drivers/mfd/abx500-core.c
index 7ce65f4..9818afb 100644
--- a/drivers/mfd/abx500-core.c
+++ b/drivers/mfd/abx500-core.c
@@ -153,6 +153,22 @@ int abx500_startup_irq_enabled(struct device *dev, unsigned int irq)
 }
 EXPORT_SYMBOL(abx500_startup_irq_enabled);
 
+void abx500_dump_all_banks(void)
+{
+	struct abx500_ops *ops;
+	struct device dummy_child = {0};
+	struct abx500_device_entry *dev_entry;
+
+	list_for_each_entry(dev_entry, &abx500_list, list) {
+		dummy_child.parent = dev_entry->dev;
+		ops = &dev_entry->ops;
+
+		if ((ops != NULL) && (ops->dump_all_banks != NULL))
+			ops->dump_all_banks(&dummy_child);
+	}
+}
+EXPORT_SYMBOL(abx500_dump_all_banks);
+
 MODULE_AUTHOR("Mattias Wallin <mattias.wallin@stericsson.com>");
 MODULE_DESCRIPTION("ABX500 core driver");
 MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/abx500.h b/include/linux/mfd/abx500.h
index 5d5298d..2667af4 100644
--- a/include/linux/mfd/abx500.h
+++ b/include/linux/mfd/abx500.h
@@ -326,6 +326,7 @@ int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,
 int abx500_get_chip_id(struct device *dev);
 int abx500_event_registers_startup_state_get(struct device *dev, u8 *event);
 int abx500_startup_irq_enabled(struct device *dev, unsigned int irq);
+void abx500_dump_all_banks(void);
 
 struct abx500_ops {
 	int (*get_chip_id) (struct device *);
@@ -336,6 +337,7 @@ struct abx500_ops {
 	int (*mask_and_set_register) (struct device *, u8, u8, u8, u8);
 	int (*event_registers_startup_state_get) (struct device *, u8 *);
 	int (*startup_irq_enabled) (struct device *, unsigned int);
+	void (*dump_all_banks) (struct device *);
 };
 
 int abx500_register_ops(struct device *core_dev, struct abx500_ops *ops);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (7 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 08/26] mfd: abx500-core: Provide an API to dump all ABx500 registers Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:52   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ Lee Jones
                   ` (16 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: arnd, linus.walleij, sameo, Lee Jones

Allow users to subscribe to and view IRQ events live from debugfs.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/ab8500-debugfs.c |  197 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 197 insertions(+)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index c4cb806..71df8e4 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -11,6 +11,9 @@
 #include <linux/module.h>
 #include <linux/debugfs.h>
 #include <linux/platform_device.h>
+#include <linux/interrupt.h>
+#include <linux/kobject.h>
+#include <linux/slab.h>
 
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
@@ -18,6 +21,9 @@
 static u32 debug_bank;
 static u32 debug_address;
 
+static int irq_first;
+static int irq_last;
+
 /**
  * struct ab8500_reg_range
  * @first: the first address of the range
@@ -354,6 +360,21 @@ static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
 	},
 };
 
+static irqreturn_t ab8500_debug_handler(int irq, void *data)
+{
+	char buf[16];
+	struct kobject *kobj = (struct kobject *)data;
+
+	/*
+	 * This makes it possible to use poll for events (POLLPRI | POLLERR)
+	 * from userspace on sysfs file named irq-<nr>
+	 */
+	sprintf(buf, "irq-%d", irq);
+	sysfs_notify(kobj, NULL, buf);
+
+	return IRQ_HANDLED;
+}
+
 static int ab8500_registers_print(struct seq_file *s, void *p)
 {
 	struct device *dev = s->private;
@@ -519,6 +540,130 @@ static ssize_t ab8500_val_write(struct file *file,
 	return count;
 }
 
+static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
+{
+	seq_printf(s, "%d\n", irq_first);
+
+	return 0;
+}
+
+static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
+					     struct file *file)
+{
+	return single_open(file, ab8500_subscribe_unsubscribe_print,
+			   inode->i_private);
+}
+
+/*
+ * This function is used for all interrupts and will always print
+ * the same string. It is however this file sysfs_notify called on.
+ * Userspace should read this file and then poll. When an event occur
+ * the blocking poll will be released.
+ */
+static ssize_t show_irq(struct device *dev,
+			struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "irq\n");
+}
+
+static struct device_attribute *dev_attr[AB8500_NR_IRQS];
+static char *event_name[AB8500_NR_IRQS];
+
+static ssize_t ab8500_subscribe_write(struct file *file,
+				      const char __user *user_buf,
+				      size_t count, loff_t *ppos)
+{
+	struct device *dev = ((struct seq_file *)(file->private_data))->private;
+	char buf[32];
+	int buf_size;
+	unsigned long user_val;
+	int err;
+
+	/* Get userspace string and assure termination */
+	buf_size = min(count, (sizeof(buf)-1));
+	if (copy_from_user(buf, user_buf, buf_size))
+		return -EFAULT;
+	buf[buf_size] = 0;
+
+	err = strict_strtoul(buf, 0, &user_val);
+	if (err)
+		return -EINVAL;
+	if (user_val < irq_first) {
+		dev_err(dev, "debugfs error input < %d\n", irq_first);
+		return -EINVAL;
+	}
+	if (user_val > irq_last) {
+		dev_err(dev, "debugfs error input > %d\n", irq_last);
+		return -EINVAL;
+	}
+
+	/*
+	 * This will create a sysfs file named irq-<nr> which userspace can
+	 * use to select or poll and get the AB8500 events
+	 */
+	dev_attr[user_val] = kmalloc(sizeof(struct device_attribute),
+				     GFP_KERNEL);
+	event_name[user_val] = kmalloc(buf_size, GFP_KERNEL);
+	sprintf(event_name[user_val], "irq-%lu", user_val);
+	dev_attr[user_val]->show = show_irq;
+	dev_attr[user_val]->store = NULL;
+	dev_attr[user_val]->attr.name = event_name[user_val];
+	dev_attr[user_val]->attr.mode = S_IRUGO;
+	err = sysfs_create_file(&dev->kobj, &dev_attr[user_val]->attr);
+	if (err < 0) {
+		printk(KERN_ERR "sysfs_create_file failed %d\n", err);
+		return err;
+	}
+
+	err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
+				   0, "ab8500-debug", &dev->kobj);
+	if (err < 0) {
+		printk(KERN_ERR "request_threaded_irq failed %d, %lu\n",
+                       err, user_val);
+		return err;
+	}
+
+	return buf_size;
+}
+
+static ssize_t ab8500_unsubscribe_write(struct file *file,
+					const char __user *user_buf,
+					size_t count, loff_t *ppos)
+{
+	struct device *dev = ((struct seq_file *)(file->private_data))->private;
+	char buf[32];
+	int buf_size;
+	unsigned long user_val;
+	int err;
+
+	/* Get userspace string and assure termination */
+	buf_size = min(count, (sizeof(buf)-1));
+	if (copy_from_user(buf, user_buf, buf_size))
+		return -EFAULT;
+	buf[buf_size] = 0;
+
+	err = strict_strtoul(buf, 0, &user_val);
+	if (err)
+		return -EINVAL;
+	if (user_val < irq_first) {
+		dev_err(dev, "debugfs error input < %d\n", irq_first);
+		return -EINVAL;
+	}
+	if (user_val > irq_last) {
+		dev_err(dev, "debugfs error input > %d\n", irq_last);
+		return -EINVAL;
+	}
+
+	free_irq(user_val, &dev->kobj);
+	kfree(event_name[user_val]);
+	kfree(dev_attr[user_val]);
+
+	if (dev_attr[user_val])
+		sysfs_remove_file(&dev->kobj, &dev_attr[user_val]->attr);
+
+	return buf_size;
+}
+
 static const struct file_operations ab8500_bank_fops = {
 	.open = ab8500_bank_open,
 	.write = ab8500_bank_write,
@@ -546,17 +691,51 @@ static const struct file_operations ab8500_val_fops = {
 	.owner = THIS_MODULE,
 };
 
+static const struct file_operations ab8500_subscribe_fops = {
+	.open = ab8500_subscribe_unsubscribe_open,
+	.write = ab8500_subscribe_write,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static const struct file_operations ab8500_unsubscribe_fops = {
+	.open = ab8500_subscribe_unsubscribe_open,
+	.write = ab8500_unsubscribe_write,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
 static struct dentry *ab8500_dir;
 static struct dentry *ab8500_reg_file;
 static struct dentry *ab8500_bank_file;
 static struct dentry *ab8500_address_file;
 static struct dentry *ab8500_val_file;
+static struct dentry *ab8500_subscribe_file;
+static struct dentry *ab8500_unsubscribe_file;
 
 static int __devinit ab8500_debug_probe(struct platform_device *plf)
 {
 	debug_bank = AB8500_MISC;
 	debug_address = AB8500_REV_REG & 0x00FF;
 
+	irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
+	if (irq_first < 0) {
+		dev_err(&plf->dev, "First irq not found, err %d\n",
+			irq_first);
+		return irq_first;
+	}
+
+	irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
+	if (irq_last < 0) {
+		dev_err(&plf->dev, "Last irq not found, err %d\n",
+			irq_last);
+		return irq_last;
+	}
+
 	ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
 	if (!ab8500_dir)
 		goto exit_no_debugfs;
@@ -582,8 +761,26 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	if (!ab8500_val_file)
 		goto exit_destroy_address;
 
+	ab8500_subscribe_file =
+		debugfs_create_file("irq-subscribe",
+				    (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev,
+				    &ab8500_subscribe_fops);
+	if (!ab8500_subscribe_file)
+		goto exit_destroy_val;
+
+	ab8500_unsubscribe_file =
+		debugfs_create_file("irq-unsubscribe",
+				    (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev,
+				    &ab8500_unsubscribe_fops);
+	if (!ab8500_unsubscribe_file)
+		goto exit_destroy_subscribe;
+
 	return 0;
 
+exit_destroy_subscribe:
+	debugfs_remove(ab8500_subscribe_file);
+exit_destroy_val:
+	debugfs_remove(ab8500_val_file);
 exit_destroy_address:
 	debugfs_remove(ab8500_address_file);
 exit_destroy_bank:
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (8 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:53   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 11/26] mfd: ab8500-debugfs: Keep count of IRQs in debugfs Lee Jones
                   ` (15 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: arnd, linus.walleij, sameo, Lee Jones

Ensure the device wakes up if the debugfs IRQ fires if we're
in suspend mode.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/ab8500-debugfs.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 71df8e4..b3ddc23 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -616,7 +616,8 @@ static ssize_t ab8500_subscribe_write(struct file *file,
 	}
 
 	err = request_threaded_irq(user_val, NULL, ab8500_debug_handler,
-				   0, "ab8500-debug", &dev->kobj);
+				   IRQF_SHARED | IRQF_NO_SUSPEND,
+				   "ab8500-debug", &dev->kobj);
 	if (err < 0) {
 		printk(KERN_ERR "request_threaded_irq failed %d, %lu\n",
                        err, user_val);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 11/26] mfd: ab8500-debugfs: Keep count of IRQs in debugfs
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (9 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer Lee Jones
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Mattias Wallin, Lee Jones

From: Mattias Wallin <mattias.wallin@stericsson.com>

This patch adds a counter to the sysfs file dynamically created
by debugfs. It also fixes an array index error.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
Reviewed-by: Mattias NILSSON <mattias.i.nilsson@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |   77 +++++++++++++++++++++++++++++-------------
 1 file changed, 53 insertions(+), 24 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index b3ddc23..03eacf1 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -23,6 +23,10 @@ static u32 debug_address;
 
 static int irq_first;
 static int irq_last;
+static u32 irq_count[AB8500_NR_IRQS];
+
+static struct device_attribute *dev_attr[AB8500_NR_IRQS];
+static char *event_name[AB8500_NR_IRQS];
 
 /**
  * struct ab8500_reg_range
@@ -364,12 +368,15 @@ static irqreturn_t ab8500_debug_handler(int irq, void *data)
 {
 	char buf[16];
 	struct kobject *kobj = (struct kobject *)data;
+	unsigned int irq_abb = irq - irq_first;
 
+	if (irq_abb < AB8500_NR_IRQS)
+		irq_count[irq_abb]++;
 	/*
 	 * This makes it possible to use poll for events (POLLPRI | POLLERR)
-	 * from userspace on sysfs file named irq-<nr>
+	 * from userspace on sysfs file named <irq-nr>
 	 */
-	sprintf(buf, "irq-%d", irq);
+	sprintf(buf, "%d", irq);
 	sysfs_notify(kobj, NULL, buf);
 
 	return IRQ_HANDLED;
@@ -555,19 +562,26 @@ static int ab8500_subscribe_unsubscribe_open(struct inode *inode,
 }
 
 /*
- * This function is used for all interrupts and will always print
- * the same string. It is however this file sysfs_notify called on.
- * Userspace should read this file and then poll. When an event occur
+ * Userspace should use poll() on this file. When an event occur
  * the blocking poll will be released.
  */
 static ssize_t show_irq(struct device *dev,
 			struct device_attribute *attr, char *buf)
 {
-	return sprintf(buf, "irq\n");
-}
+	unsigned long name;
+	unsigned int irq_index;
+	int err;
 
-static struct device_attribute *dev_attr[AB8500_NR_IRQS];
-static char *event_name[AB8500_NR_IRQS];
+	err = strict_strtoul(attr->attr.name, 0, &name);
+	if (err)
+		return err;
+
+	irq_index = name - irq_first;
+	if (irq_index >= AB8500_NR_IRQS)
+		return -EINVAL;
+	else
+		return sprintf(buf, "%u\n", irq_count[irq_index]);
+}
 
 static ssize_t ab8500_subscribe_write(struct file *file,
 				      const char __user *user_buf,
@@ -578,6 +592,7 @@ static ssize_t ab8500_subscribe_write(struct file *file,
 	int buf_size;
 	unsigned long user_val;
 	int err;
+	unsigned int irq_index;
 
 	/* Get userspace string and assure termination */
 	buf_size = min(count, (sizeof(buf)-1));
@@ -597,19 +612,23 @@ static ssize_t ab8500_subscribe_write(struct file *file,
 		return -EINVAL;
 	}
 
+	irq_index = user_val - irq_first;
+	if (irq_index >= AB8500_NR_IRQS)
+		return -EINVAL;
+
 	/*
-	 * This will create a sysfs file named irq-<nr> which userspace can
+	 * This will create a sysfs file named <irq-nr> which userspace can
 	 * use to select or poll and get the AB8500 events
 	 */
-	dev_attr[user_val] = kmalloc(sizeof(struct device_attribute),
-				     GFP_KERNEL);
-	event_name[user_val] = kmalloc(buf_size, GFP_KERNEL);
-	sprintf(event_name[user_val], "irq-%lu", user_val);
-	dev_attr[user_val]->show = show_irq;
-	dev_attr[user_val]->store = NULL;
-	dev_attr[user_val]->attr.name = event_name[user_val];
-	dev_attr[user_val]->attr.mode = S_IRUGO;
-	err = sysfs_create_file(&dev->kobj, &dev_attr[user_val]->attr);
+	dev_attr[irq_index] = kmalloc(sizeof(struct device_attribute),
+		GFP_KERNEL);
+	event_name[irq_index] = kmalloc(buf_size, GFP_KERNEL);
+	sprintf(event_name[irq_index], "%lu", user_val);
+	dev_attr[irq_index]->show = show_irq;
+	dev_attr[irq_index]->store = NULL;
+	dev_attr[irq_index]->attr.name = event_name[irq_index];
+	dev_attr[irq_index]->attr.mode = S_IRUGO;
+	err = sysfs_create_file(&dev->kobj, &dev_attr[irq_index]->attr);
 	if (err < 0) {
 		printk(KERN_ERR "sysfs_create_file failed %d\n", err);
 		return err;
@@ -621,6 +640,7 @@ static ssize_t ab8500_subscribe_write(struct file *file,
 	if (err < 0) {
 		printk(KERN_ERR "request_threaded_irq failed %d, %lu\n",
                        err, user_val);
+		sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
 		return err;
 	}
 
@@ -636,6 +656,7 @@ static ssize_t ab8500_unsubscribe_write(struct file *file,
 	int buf_size;
 	unsigned long user_val;
 	int err;
+	unsigned int irq_index;
 
 	/* Get userspace string and assure termination */
 	buf_size = min(count, (sizeof(buf)-1));
@@ -655,12 +676,20 @@ static ssize_t ab8500_unsubscribe_write(struct file *file,
 		return -EINVAL;
 	}
 
-	free_irq(user_val, &dev->kobj);
-	kfree(event_name[user_val]);
-	kfree(dev_attr[user_val]);
+	irq_index = user_val - irq_first;
+	if (irq_index >= AB8500_NR_IRQS)
+		return -EINVAL;
+
+	/* Set irq count to 0 when unsubscribe */
+	irq_count[irq_index] = 0;
+
+	if (dev_attr[irq_index])
+		sysfs_remove_file(&dev->kobj, &dev_attr[irq_index]->attr);
 
-	if (dev_attr[user_val])
-		sysfs_remove_file(&dev->kobj, &dev_attr[user_val]->attr);
+
+	free_irq(user_val, &dev->kobj);
+	kfree(event_name[irq_index]);
+	kfree(dev_attr[irq_index]);
 
 	return buf_size;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (10 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 11/26] mfd: ab8500-debugfs: Keep count of IRQs in debugfs Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 13:06   ` Mark Brown
  2013-01-15 12:55 ` [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry Lee Jones
                   ` (13 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Lee Jones, Mark Brown

Partly for coding style reasons, but mostly because sparse warns on it.

This patch is a completion of a previous patch my Mark Brown.

Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/ab8500-debugfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 03eacf1..4f36907 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -60,7 +60,7 @@ struct ab8500_prcmu_ranges {
 static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
 	[0x0] = {
 		.num_ranges = 0,
-		.range = 0,
+		.range = NULL,
 	},
 	[AB8500_SYS_CTRL1_BLOCK] = {
 		.num_ranges = 3,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (11 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:53   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings Lee Jones
                   ` (12 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, carriere etienne, Lee Jones

From: carriere etienne <etienne.carriere@stericsson.com>

Add debugfs entry ab8500/hwreg to read/write bit-field in AB8500 registers.
Check the debugfs entries usage from heading comments in ab8500-debugfs.c

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: carriere etienne <etienne.carriere@stericsson.com>
Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |  388 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 336 insertions(+), 52 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 4f36907..78a8e0c 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -4,6 +4,72 @@
  * Author: Mattias Wallin <mattias.wallin@stericsson.com> for ST-Ericsson.
  * License Terms: GNU General Public License v2
  */
+/*
+ * AB8500 register access
+ * ======================
+ *
+ * read:
+ * # echo BANK  >  <debugfs>/ab8500/register-bank
+ * # echo ADDR  >  <debugfs>/ab8500/register-address
+ * # cat <debugfs>/ab8500/register-value
+ *
+ * write:
+ * # echo BANK  >  <debugfs>/ab8500/register-bank
+ * # echo ADDR  >  <debugfs>/ab8500/register-address
+ * # echo VALUE >  <debugfs>/ab8500/register-value
+ *
+ * read all registers from a bank:
+ * # echo BANK  >  <debugfs>/ab8500/register-bank
+ * # cat <debugfs>/ab8500/all-bank-register
+ *
+ * BANK   target AB8500 register bank
+ * ADDR   target AB8500 register address
+ * VALUE  decimal or 0x-prefixed hexadecimal
+ *
+ *
+ * User Space notification on AB8500 IRQ
+ * =====================================
+ *
+ * Allows user space entity to be notified when target AB8500 IRQ occurs.
+ * When subscribed, a sysfs entry is created in ab8500.i2c platform device.
+ * One can pool this file to get target IRQ occurence information.
+ *
+ * subscribe to an AB8500 IRQ:
+ * # echo IRQ  >  <debugfs>/ab8500/irq-subscribe
+ *
+ * unsubscribe from an AB8500 IRQ:
+ * # echo IRQ  >  <debugfs>/ab8500/irq-unsubscribe
+ *
+ *
+ * AB8500 register formated read/write access
+ * ==========================================
+ *
+ * Read:  read data, data>>SHIFT, data&=MASK, output data
+ *        [0xABCDEF98] shift=12 mask=0xFFF => 0x00000CDE
+ * Write: read data, data &= ~(MASK<<SHIFT), data |= (VALUE<<SHIFT), write data
+ *        [0xABCDEF98] shift=12 mask=0xFFF value=0x123 => [0xAB123F98]
+ *
+ * Usage:
+ * # echo "CMD [OPTIONS] BANK ADRESS [VALUE]" > $debugfs/ab8500/hwreg
+ *
+ * CMD      read      read access
+ *          write     write access
+ *
+ * BANK     target reg bank
+ * ADDRESS  target reg address
+ * VALUE    (write) value to be updated
+ *
+ * OPTIONS
+ *  -d|-dec            (read) output in decimal
+ *  -h|-hexa           (read) output in 0x-hexa (default)
+ *  -l|-w|-b           32bit (default), 16bit or 8bit reg access
+ *  -m|-mask MASK      0x-hexa mask (default 0xFFFFFFFF)
+ *  -s|-shift SHIFT    bit shift value (read:left, write:right)
+ *  -o|-offset OFFSET  address offset to add to ADDRESS value
+ *
+ * Warning: bit shift operation is applied to bit-mask.
+ * Warning: bit shift direction depends on read or right command.
+ */
 
 #include <linux/seq_file.h>
 #include <linux/uaccess.h>
@@ -18,6 +84,11 @@
 #include <linux/mfd/abx500.h>
 #include <linux/mfd/abx500/ab8500.h>
 
+#ifdef CONFIG_DEBUG_FS
+#include <linux/string.h>
+#include <linux/ctype.h>
+#endif
+
 static u32 debug_bank;
 static u32 debug_address;
 
@@ -52,6 +123,25 @@ struct ab8500_prcmu_ranges {
 	const struct ab8500_reg_range *range;
 };
 
+/* hwreg- "mask" and "shift" entries ressources */
+struct hwreg_cfg {
+	u32  bank;      /* target bank */
+	u32  addr;      /* target address */
+	uint fmt;       /* format */
+	uint mask;      /* read/write mask, applied before any bit shift */
+	int  shift;     /* bit shift (read:right shift, write:left shift */
+};
+/* fmt bit #0: 0=hexa, 1=dec */
+#define REG_FMT_DEC(c) ((c)->fmt & 0x1)
+#define REG_FMT_HEX(c) (!REG_FMT_DEC(c))
+
+static struct hwreg_cfg hwreg_cfg = {
+	.addr = 0,			/* default: invalid phys addr */
+	.fmt = 0,			/* default: 32bit access, hex output */
+	.mask = 0xFFFFFFFF,	/* default: no mask */
+	.shift = 0,			/* default: no bit shift */
+};
+
 #define AB8500_NAME_STRING "ab8500"
 #define AB8500_NUM_BANKS 22
 
@@ -547,6 +637,203 @@ static ssize_t ab8500_val_write(struct file *file,
 	return count;
 }
 
+/*
+ * - HWREG DB8500 formated routines
+ */
+static int ab8500_hwreg_print(struct seq_file *s, void *d)
+{
+	struct device *dev = s->private;
+	int ret;
+	u8 regvalue;
+
+	ret = abx500_get_register_interruptible(dev,
+		(u8)hwreg_cfg.bank, (u8)hwreg_cfg.addr, &regvalue);
+	if (ret < 0) {
+		dev_err(dev, "abx500_get_reg fail %d, %d\n",
+			ret, __LINE__);
+		return -EINVAL;
+	}
+
+	if (hwreg_cfg.shift >= 0)
+		regvalue >>= hwreg_cfg.shift;
+	else
+		regvalue <<= -hwreg_cfg.shift;
+	regvalue &= hwreg_cfg.mask;
+
+	if (REG_FMT_DEC(&hwreg_cfg))
+		seq_printf(s, "%d\n", regvalue);
+	else
+		seq_printf(s, "0x%02X\n", regvalue);
+	return 0;
+}
+
+static int ab8500_hwreg_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_hwreg_print, inode->i_private);
+}
+
+/*
+ * return length of an ASCII numerical value, 0 is string is not a
+ * numerical value.
+ * string shall start at value 1st char.
+ * string can be tailed with \0 or space or newline chars only.
+ * value can be decimal or hexadecimal (prefixed 0x or 0X).
+ */
+static int strval_len(char *b)
+{
+	char *s = b;
+	if ((*s == '0') && ((*(s+1) == 'x') || (*(s+1) == 'X'))) {
+		s += 2;
+		for (; *s && (*s != ' ') && (*s != '\n'); s++) {
+			if (!isxdigit(*s))
+				return 0;
+		}
+	} else {
+		if (*s == '-')
+			s++;
+		for (; *s && (*s != ' ') && (*s != '\n'); s++) {
+			if (!isdigit(*s))
+				return 0;
+		}
+	}
+	return (int) (s-b);
+}
+
+/*
+ * parse hwreg input data.
+ * update global hwreg_cfg only if input data syntax is ok.
+ */
+static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
+		struct device *dev)
+{
+	uint write, val = 0;
+	struct hwreg_cfg loc = {
+		.bank = 0,          /* default: invalid phys addr */
+		.addr = 0,          /* default: invalid phys addr */
+		.fmt = 0,           /* default: 32bit access, hex output */
+		.mask = 0xFFFFFFFF, /* default: no mask */
+		.shift = 0,         /* default: no bit shift */
+	};
+
+	/* read or write ? */
+	if (!strncmp(b, "read ", 5)) {
+		write = 0;
+		b += 5;
+	} else if (!strncmp(b, "write ", 6)) {
+		write = 1;
+		b += 6;
+	} else
+		return -EINVAL;
+
+	/* OPTIONS -l|-w|-b -s -m -o */
+	while ((*b == ' ') || (*b == '-')) {
+		if (*(b-1) != ' ') {
+			b++;
+			continue;
+		}
+		if ((!strncmp(b, "-d ", 3)) ||
+				(!strncmp(b, "-dec ", 5))) {
+			b += (*(b+2) == ' ') ? 3 : 5;
+			loc.fmt |= (1<<0);
+		} else if ((!strncmp(b, "-h ", 3)) ||
+				(!strncmp(b, "-hex ", 5))) {
+			b += (*(b+2) == ' ') ? 3 : 5;
+			loc.fmt &= ~(1<<0);
+		} else if ((!strncmp(b, "-m ", 3)) ||
+				(!strncmp(b, "-mask ", 6))) {
+			b += (*(b+2) == ' ') ? 3 : 6;
+			if (strval_len(b) == 0)
+				return -EINVAL;
+			loc.mask = simple_strtoul(b, &b, 0);
+		} else if ((!strncmp(b, "-s ", 3)) ||
+				(!strncmp(b, "-shift ", 7))) {
+			b += (*(b+2) == ' ') ? 3 : 7;
+			if (strval_len(b) == 0)
+				return -EINVAL;
+			loc.shift = simple_strtol(b, &b, 0);
+		} else {
+			return -EINVAL;
+		}
+	}
+	/* get arg BANK and ADDRESS */
+	if (strval_len(b) == 0)
+		return -EINVAL;
+	loc.bank = simple_strtoul(b, &b, 0);
+	while (*b == ' ')
+		b++;
+	if (strval_len(b) == 0)
+		return -EINVAL;
+	loc.addr = simple_strtoul(b, &b, 0);
+
+	if (write) {
+		while (*b == ' ')
+			b++;
+		if (strval_len(b) == 0)
+			return -EINVAL;
+		val = simple_strtoul(b, &b, 0);
+	}
+
+	/* args are ok, update target cfg (mainly for read) */
+	*cfg = loc;
+
+#if ABB_HWREG_DEBUG
+	pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d
+			value=0x%X\n", (write) ? "write" : "read",
+			REG_FMT_DEC(cfg) ? "decimal" : "hexa",
+			cfg->addr, cfg->mask, cfg->shift, val);
+#endif
+
+	if (write) {
+		u8  regvalue;
+		int ret = abx500_get_register_interruptible(dev,
+			(u8)cfg->bank, (u8)cfg->addr, &regvalue);
+		if (ret < 0) {
+			dev_err(dev, "abx500_get_reg fail %d, %d\n",
+				ret, __LINE__);
+			return -EINVAL;
+		}
+
+		if (cfg->shift >= 0) {
+			regvalue &= ~(cfg->mask << (cfg->shift));
+			val = (val & cfg->mask) << (cfg->shift);
+		} else {
+			regvalue &= ~(cfg->mask >> (-cfg->shift));
+			val = (val & cfg->mask) >> (-cfg->shift);
+		}
+		val = val | regvalue;
+
+		ret = abx500_set_register_interruptible(dev,
+			(u8)cfg->bank, (u8)cfg->addr, (u8)val);
+		if (ret < 0) {
+			pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
+			return -EINVAL;
+		}
+
+	}
+	return 0;
+}
+
+static ssize_t ab8500_hwreg_write(struct file *file,
+	const char __user *user_buf, size_t count, loff_t *ppos)
+{
+	struct device *dev = ((struct seq_file *)(file->private_data))->private;
+	char buf[128];
+	int buf_size, ret;
+
+	/* Get userspace string and assure termination */
+	buf_size = min(count, (sizeof(buf)-1));
+	if (copy_from_user(buf, user_buf, buf_size))
+		return -EFAULT;
+	buf[buf_size] = 0;
+
+	/* get args and process */
+	ret = hwreg_common_write(buf, &hwreg_cfg, dev);
+	return (ret) ? ret : buf_size;
+}
+
+/*
+ * - irq subscribe/unsubscribe stuff
+ */
 static int ab8500_subscribe_unsubscribe_print(struct seq_file *s, void *p)
 {
 	seq_printf(s, "%d\n", irq_first);
@@ -694,6 +981,10 @@ static ssize_t ab8500_unsubscribe_write(struct file *file,
 	return buf_size;
 }
 
+/*
+ * - several deubgfs nodes fops
+ */
+
 static const struct file_operations ab8500_bank_fops = {
 	.open = ab8500_bank_open,
 	.write = ab8500_bank_write,
@@ -739,16 +1030,20 @@ static const struct file_operations ab8500_unsubscribe_fops = {
 	.owner = THIS_MODULE,
 };
 
+static const struct file_operations ab8500_hwreg_fops = {
+	.open = ab8500_hwreg_open,
+	.write = ab8500_hwreg_write,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
 static struct dentry *ab8500_dir;
-static struct dentry *ab8500_reg_file;
-static struct dentry *ab8500_bank_file;
-static struct dentry *ab8500_address_file;
-static struct dentry *ab8500_val_file;
-static struct dentry *ab8500_subscribe_file;
-static struct dentry *ab8500_unsubscribe_file;
 
 static int __devinit ab8500_debug_probe(struct platform_device *plf)
 {
+	struct dentry *file;
 	debug_bank = AB8500_MISC;
 	debug_address = AB8500_REV_REG & 0x00FF;
 
@@ -768,70 +1063,59 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 
 	ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
 	if (!ab8500_dir)
-		goto exit_no_debugfs;
+		goto err;
 
-	ab8500_reg_file = debugfs_create_file("all-bank-registers",
+	file = debugfs_create_file("all-bank-registers",
 		S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops);
-	if (!ab8500_reg_file)
-		goto exit_destroy_dir;
+	if (!file)
+		goto err;
 
-	ab8500_bank_file = debugfs_create_file("register-bank",
+	file = debugfs_create_file("register-bank",
 		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_bank_fops);
-	if (!ab8500_bank_file)
-		goto exit_destroy_reg;
+	if (!file)
+		goto err;
 
-	ab8500_address_file = debugfs_create_file("register-address",
+	file = debugfs_create_file("register-address",
 		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
 		&ab8500_address_fops);
-	if (!ab8500_address_file)
-		goto exit_destroy_bank;
+	if (!file)
+		goto err;
 
-	ab8500_val_file = debugfs_create_file("register-value",
+	file = debugfs_create_file("register-value",
 		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_val_fops);
-	if (!ab8500_val_file)
-		goto exit_destroy_address;
-
-	ab8500_subscribe_file =
-		debugfs_create_file("irq-subscribe",
-				    (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev,
-				    &ab8500_subscribe_fops);
-	if (!ab8500_subscribe_file)
-		goto exit_destroy_val;
-
-	ab8500_unsubscribe_file =
-		debugfs_create_file("irq-unsubscribe",
-				    (S_IRUGO | S_IWUGO), ab8500_dir, &plf->dev,
-				    &ab8500_unsubscribe_fops);
-	if (!ab8500_unsubscribe_file)
-		goto exit_destroy_subscribe;
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("irq-subscribe",
+		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
+		&ab8500_subscribe_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("irq-unsubscribe",
+		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
+		&ab8500_unsubscribe_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("hwreg",
+		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
+		&ab8500_hwreg_fops);
+	if (!file)
+		goto err;
 
 	return 0;
 
-exit_destroy_subscribe:
-	debugfs_remove(ab8500_subscribe_file);
-exit_destroy_val:
-	debugfs_remove(ab8500_val_file);
-exit_destroy_address:
-	debugfs_remove(ab8500_address_file);
-exit_destroy_bank:
-	debugfs_remove(ab8500_bank_file);
-exit_destroy_reg:
-	debugfs_remove(ab8500_reg_file);
-exit_destroy_dir:
-	debugfs_remove(ab8500_dir);
-exit_no_debugfs:
+err:
+	if (ab8500_dir)
+		debugfs_remove_recursive(ab8500_dir);
 	dev_err(&plf->dev, "failed to create debugfs entries.\n");
 	return -ENOMEM;
 }
 
 static int __devexit ab8500_debug_remove(struct platform_device *plf)
 {
-	debugfs_remove(ab8500_val_file);
-	debugfs_remove(ab8500_address_file);
-	debugfs_remove(ab8500_bank_file);
-	debugfs_remove(ab8500_reg_file);
-	debugfs_remove(ab8500_dir);
-
+	debugfs_remove_recursive(ab8500_dir);
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (12 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-27 23:53   ` Samuel Ortiz
  2013-01-15 12:55 ` [PATCH 15/26] mfd: ab8500-debugfs: Export all AB8500 ADCs as debugfs nodes Lee Jones
                   ` (11 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Philippe Langlais, Lee Jones,
	Philippe Langlais

From: Philippe Langlais <philippe.langlais@stericsson.com>

Some simple fixes regarding pre-processor usage.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
---
 drivers/mfd/ab8500-debugfs.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 78a8e0c..7698d30 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -776,9 +776,9 @@ static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
 	/* args are ok, update target cfg (mainly for read) */
 	*cfg = loc;
 
-#if ABB_HWREG_DEBUG
-	pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d
-			value=0x%X\n", (write) ? "write" : "read",
+#ifdef ABB_HWREG_DEBUG
+	pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d"
+			"value=0x%X\n", (write) ? "write" : "read",
 			REG_FMT_DEC(cfg) ? "decimal" : "hexa",
 			cfg->addr, cfg->mask, cfg->shift, val);
 #endif
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 15/26] mfd: ab8500-debugfs: Export all AB8500 ADCs as debugfs nodes
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (13 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 16/26] mfd: ab8500-debugfs: Set the USB charging current to 300mA for ABV3 Lee Jones
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, John Beckett, Lee Jones

From: John Beckett <john.beckett@stericsson.com>

Allow a user to take a glimpse into the inner workings of the
AB8500 Analogue-to-Digital Converters, via debugfs.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: John Beckett <john.beckett@stericsson.com>
Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |  486 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 465 insertions(+), 21 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 7698d30..aedbcb0 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -82,7 +82,7 @@
 #include <linux/slab.h>
 
 #include <linux/mfd/abx500.h>
-#include <linux/mfd/abx500/ab8500.h>
+#include <linux/mfd/abx500/ab8500-gpadc.h>
 
 #ifdef CONFIG_DEBUG_FS
 #include <linux/string.h>
@@ -143,6 +143,7 @@ static struct hwreg_cfg hwreg_cfg = {
 };
 
 #define AB8500_NAME_STRING "ab8500"
+#define AB8500_ADC_NAME_STRING "gpadc"
 #define AB8500_NUM_BANKS 22
 
 #define AB8500_REV_REG 0x80
@@ -672,6 +673,382 @@ static int ab8500_hwreg_open(struct inode *inode, struct file *file)
 	return single_open(file, ab8500_hwreg_print, inode->i_private);
 }
 
+static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
+{
+	int bat_ctrl_raw;
+	int bat_ctrl_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL);
+	bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+			BAT_CTRL, bat_ctrl_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			bat_ctrl_convert, bat_ctrl_raw);
+}
+
+static int ab8500_gpadc_bat_ctrl_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_bat_ctrl_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_bat_ctrl_fops = {
+	.open = ab8500_gpadc_bat_ctrl_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
+{
+	int btemp_ball_raw;
+	int btemp_ball_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL);
+	btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
+			btemp_ball_raw);
+
+	return seq_printf(s,
+			"%d,0x%X\n", btemp_ball_convert, btemp_ball_raw);
+}
+
+static int ab8500_gpadc_btemp_ball_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_btemp_ball_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_btemp_ball_fops = {
+	.open = ab8500_gpadc_btemp_ball_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
+{
+	int main_charger_v_raw;
+	int main_charger_v_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V);
+	main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+			MAIN_CHARGER_V, main_charger_v_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			main_charger_v_convert, main_charger_v_raw);
+}
+
+static int ab8500_gpadc_main_charger_v_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_main_charger_v_print,
+			inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_main_charger_v_fops = {
+	.open = ab8500_gpadc_main_charger_v_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
+{
+	int acc_detect1_raw;
+	int acc_detect1_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1);
+	acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
+			acc_detect1_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			acc_detect1_convert, acc_detect1_raw);
+}
+
+static int ab8500_gpadc_acc_detect1_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_acc_detect1_print,
+			inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_acc_detect1_fops = {
+	.open = ab8500_gpadc_acc_detect1_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
+{
+	int acc_detect2_raw;
+	int acc_detect2_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2);
+	acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+	    ACC_DETECT2, acc_detect2_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			acc_detect2_convert, acc_detect2_raw);
+}
+
+static int ab8500_gpadc_acc_detect2_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_acc_detect2_print,
+	    inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_acc_detect2_fops = {
+	.open = ab8500_gpadc_acc_detect2_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
+{
+	int aux1_raw;
+	int aux1_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1);
+	aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
+			aux1_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			aux1_convert, aux1_raw);
+}
+
+static int ab8500_gpadc_aux1_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_aux1_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_aux1_fops = {
+	.open = ab8500_gpadc_aux1_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
+{
+	int aux2_raw;
+	int aux2_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2);
+	aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
+			aux2_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			aux2_convert, aux2_raw);
+}
+
+static int ab8500_gpadc_aux2_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_aux2_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_aux2_fops = {
+	.open = ab8500_gpadc_aux2_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
+{
+	int main_bat_v_raw;
+	int main_bat_v_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V);
+	main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
+			main_bat_v_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			main_bat_v_convert, main_bat_v_raw);
+}
+
+static int ab8500_gpadc_main_bat_v_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_main_bat_v_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_main_bat_v_fops = {
+	.open = ab8500_gpadc_main_bat_v_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
+{
+	int vbus_v_raw;
+	int vbus_v_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V);
+	vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
+			vbus_v_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			vbus_v_convert, vbus_v_raw);
+}
+
+static int ab8500_gpadc_vbus_v_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_vbus_v_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_vbus_v_fops = {
+	.open = ab8500_gpadc_vbus_v_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
+{
+	int main_charger_c_raw;
+	int main_charger_c_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C);
+	main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+			MAIN_CHARGER_C, main_charger_c_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			main_charger_c_convert, main_charger_c_raw);
+}
+
+static int ab8500_gpadc_main_charger_c_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_main_charger_c_print,
+			inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_main_charger_c_fops = {
+	.open = ab8500_gpadc_main_charger_c_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
+{
+	int usb_charger_c_raw;
+	int usb_charger_c_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C);
+	usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+	    USB_CHARGER_C, usb_charger_c_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			usb_charger_c_convert, usb_charger_c_raw);
+}
+
+static int ab8500_gpadc_usb_charger_c_open(struct inode *inode,
+		struct file *file)
+{
+	return single_open(file, ab8500_gpadc_usb_charger_c_print,
+	    inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_usb_charger_c_fops = {
+	.open = ab8500_gpadc_usb_charger_c_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
+{
+	int bk_bat_v_raw;
+	int bk_bat_v_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V);
+	bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
+			BK_BAT_V, bk_bat_v_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			bk_bat_v_convert, bk_bat_v_raw);
+}
+
+static int ab8500_gpadc_bk_bat_v_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_bk_bat_v_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_bk_bat_v_fops = {
+	.open = ab8500_gpadc_bk_bat_v_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
+static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
+{
+	int die_temp_raw;
+	int die_temp_convert;
+	struct ab8500_gpadc *gpadc;
+
+	gpadc = ab8500_gpadc_get();
+	die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP);
+	die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
+			die_temp_raw);
+
+	return seq_printf(s, "%d,0x%X\n",
+			die_temp_convert, die_temp_raw);
+}
+
+static int ab8500_gpadc_die_temp_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_gpadc_die_temp_print, inode->i_private);
+}
+
+static const struct file_operations ab8500_gpadc_die_temp_fops = {
+	.open = ab8500_gpadc_die_temp_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
 /*
  * return length of an ASCII numerical value, 0 is string is not a
  * numerical value.
@@ -1040,6 +1417,7 @@ static const struct file_operations ab8500_hwreg_fops = {
 };
 
 static struct dentry *ab8500_dir;
+static struct dentry *ab8500_gpadc_dir;
 
 static int __devinit ab8500_debug_probe(struct platform_device *plf)
 {
@@ -1050,14 +1428,14 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
 	if (irq_first < 0) {
 		dev_err(&plf->dev, "First irq not found, err %d\n",
-			irq_first);
+				irq_first);
 		return irq_first;
 	}
 
 	irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
 	if (irq_last < 0) {
 		dev_err(&plf->dev, "Last irq not found, err %d\n",
-			irq_last);
+				irq_last);
 		return irq_last;
 	}
 
@@ -1065,42 +1443,108 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	if (!ab8500_dir)
 		goto err;
 
-	file = debugfs_create_file("all-bank-registers",
-		S_IRUGO, ab8500_dir, &plf->dev, &ab8500_registers_fops);
+	ab8500_gpadc_dir = debugfs_create_dir(AB8500_ADC_NAME_STRING,
+	    ab8500_dir);
+	if (!ab8500_gpadc_dir)
+		goto err;
+
+	file = debugfs_create_file("all-bank-registers", S_IRUGO,
+	    ab8500_dir, &plf->dev, &ab8500_registers_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_bank_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("register-address", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_address_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("register-value", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_val_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("irq-subscribe", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_subscribe_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("hwreg", (S_IRUGO | S_IWUSR),
+	    ab8500_dir, &plf->dev, &ab8500_hwreg_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("bat_ctrl", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bat_ctrl_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("btemp_ball", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_btemp_ball_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("main_charger_v", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_v_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("acc_detect1", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect1_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("acc_detect2", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_acc_detect2_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("adc_aux1", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux1_fops);
+	if (!file)
+		goto err;
+
+	file = debugfs_create_file("adc_aux2", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_aux2_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("register-bank",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_bank_fops);
+	file = debugfs_create_file("main_bat_v", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_bat_v_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("register-address",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
-		&ab8500_address_fops);
+	file = debugfs_create_file("vbus_v", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_vbus_v_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("register-value",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev, &ab8500_val_fops);
+	file = debugfs_create_file("main_charger_c", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_main_charger_c_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("irq-subscribe",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
-		&ab8500_subscribe_fops);
+	file = debugfs_create_file("usb_charger_c", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_usb_charger_c_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("irq-unsubscribe",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
-		&ab8500_unsubscribe_fops);
+	file = debugfs_create_file("bk_bat_v", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_bk_bat_v_fops);
 	if (!file)
 		goto err;
 
-	file = debugfs_create_file("hwreg",
-		(S_IRUGO | S_IWUSR), ab8500_dir, &plf->dev,
-		&ab8500_hwreg_fops);
+	file = debugfs_create_file("die_temp", (S_IRUGO | S_IWUSR),
+	    ab8500_gpadc_dir, &plf->dev, &ab8500_gpadc_die_temp_fops);
 	if (!file)
 		goto err;
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 16/26] mfd: ab8500-debugfs: Set the USB charging current to 300mA for ABV3
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (14 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 15/26] mfd: ab8500-debugfs: Export all AB8500 ADCs as debugfs nodes Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 17/26] mfd: ab8500-debugfs: add debugfs node to read all registers Lee Jones
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Philippe Langlais, Lee Jones,
	thirupathi.chippakurthy

From: Philippe Langlais <philippe.langlais@stericsson.com>

In case of AB-V3, the eye diagram related issues are resolved.
So, set the device charging current to 300mA when connected to
standard host. Also, add the USB PHY tuning values to improve
the USB eye diagram

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: <thirupathi.chippakurthy@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index aedbcb0..a231faf 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -144,7 +144,7 @@ static struct hwreg_cfg hwreg_cfg = {
 
 #define AB8500_NAME_STRING "ab8500"
 #define AB8500_ADC_NAME_STRING "gpadc"
-#define AB8500_NUM_BANKS 22
+#define AB8500_NUM_BANKS 24
 
 #define AB8500_REV_REG 0x80
 
@@ -316,7 +316,7 @@ static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
 		},
 	},
 	[AB8500_CHARGER] = {
-		.num_ranges = 8,
+		.num_ranges = 9,
 		.range = (struct ab8500_reg_range[]) {
 			{
 				.first = 0x00,
@@ -350,6 +350,10 @@ static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
 				.first = 0xC0,
 				.last = 0xC2,
 			},
+			{
+				.first = 0xf5,
+				.last =	0xf6,
+			},
 		},
 	},
 	[AB8500_GAS_GAUGE] = {
@@ -369,6 +373,24 @@ static struct ab8500_prcmu_ranges debug_ranges[AB8500_NUM_BANKS] = {
 			},
 		},
 	},
+	[AB8500_DEVELOPMENT] = {
+		.num_ranges = 1,
+		.range = (struct ab8500_reg_range[]) {
+			{
+				.first = 0x00,
+				.last = 0x00,
+			},
+		},
+	},
+	[AB8500_DEBUG] = {
+		.num_ranges = 1,
+		.range = (struct ab8500_reg_range[]) {
+			{
+				.first = 0x05,
+				.last = 0x07,
+			},
+		},
+	},
 	[AB8500_AUDIO] = {
 		.num_ranges = 1,
 		.range = (struct ab8500_reg_range[]) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 17/26] mfd: ab8500-debugfs: add debugfs node to read all registers
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (15 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 16/26] mfd: ab8500-debugfs: Set the USB charging current to 300mA for ABV3 Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 18/26] mfd: ab8500-core: Allow the possibility to dump all AB8500 registers Lee Jones
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Mian Yousaf Kaukab, Lee Jones

From: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>

Update the ab8500_registers_print() to reuse it from multiple places.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |   95 +++++++++++++++++++++++++++++++++++-------
 1 file changed, 81 insertions(+), 14 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index a231faf..a1ce55e 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -495,15 +495,12 @@ static irqreturn_t ab8500_debug_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-static int ab8500_registers_print(struct seq_file *s, void *p)
+/* Prints to seq_file or log_buf */
+static int ab8500_registers_print(struct device *dev, u32 bank,
+				struct seq_file *s)
 {
-	struct device *dev = s->private;
 	unsigned int i;
-	u32 bank = debug_bank;
-
-	seq_printf(s, AB8500_NAME_STRING " register values:\n");
 
-	seq_printf(s, " bank %u:\n", bank);
 	for (i = 0; i < debug_ranges[bank].num_ranges; i++) {
 		u32 reg;
 
@@ -520,22 +517,42 @@ static int ab8500_registers_print(struct seq_file *s, void *p)
 				return err;
 			}
 
-			err = seq_printf(s, "  [%u/0x%02X]: 0x%02X\n", bank,
-				reg, value);
-			if (err < 0) {
-				dev_err(dev, "seq_printf overflow\n");
-				/* Error is not returned here since
-				 * the output is wanted in any case */
-				return 0;
+			if (s) {
+				err = seq_printf(s, "  [%u/0x%02X]: 0x%02X\n",
+					bank, reg, value);
+				if (err < 0) {
+					dev_err(dev,
+					"seq_printf overflow bank=%d reg=%d\n",
+						bank, reg);
+					/* Error is not returned here since
+					 * the output is wanted in any case */
+					return 0;
+				}
+			} else {
+				printk(KERN_INFO" [%u/0x%02X]: 0x%02X\n", bank,
+					reg, value);
 			}
 		}
 	}
 	return 0;
 }
 
+static int ab8500_print_bank_registers(struct seq_file *s, void *p)
+{
+	struct device *dev = s->private;
+	u32 bank = debug_bank;
+
+	seq_printf(s, AB8500_NAME_STRING " register values:\n");
+
+	seq_printf(s, " bank %u:\n", bank);
+
+	ab8500_registers_print(dev, bank, s);
+	return 0;
+}
+
 static int ab8500_registers_open(struct inode *inode, struct file *file)
 {
-	return single_open(file, ab8500_registers_print, inode->i_private);
+	return single_open(file, ab8500_print_bank_registers, inode->i_private);
 }
 
 static const struct file_operations ab8500_registers_fops = {
@@ -546,6 +563,51 @@ static const struct file_operations ab8500_registers_fops = {
 	.owner = THIS_MODULE,
 };
 
+static int ab8500_print_all_banks(struct seq_file *s, void *p)
+{
+	struct device *dev = s->private;
+	unsigned int i;
+	int err;
+
+	seq_printf(s, AB8500_NAME_STRING " register values:\n");
+
+	for (i = 1; i < AB8500_NUM_BANKS; i++) {
+		err = seq_printf(s, " bank %u:\n", i);
+		if (err < 0)
+			dev_err(dev, "seq_printf overflow, bank=%d\n", i);
+
+		ab8500_registers_print(dev, i, s);
+	}
+	return 0;
+}
+
+static int ab8500_all_banks_open(struct inode *inode, struct file *file)
+{
+	struct seq_file *s;
+	int err;
+
+	err = single_open(file, ab8500_print_all_banks, inode->i_private);
+	if (!err) {
+		/* Default buf size in seq_read is not enough */
+		s = (struct seq_file *)file->private_data;
+		s->size = (PAGE_SIZE * 2);
+		s->buf = kmalloc(s->size, GFP_KERNEL);
+		if (!s->buf) {
+			single_release(inode, file);
+			err = -ENOMEM;
+		}
+	}
+	return err;
+}
+
+static const struct file_operations ab8500_all_banks_fops = {
+	.open = ab8500_all_banks_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
 static int ab8500_bank_print(struct seq_file *s, void *p)
 {
 	return seq_printf(s, "%d\n", debug_bank);
@@ -1475,6 +1537,11 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	if (!file)
 		goto err;
 
+	file = debugfs_create_file("all-banks", S_IRUGO,
+	    ab8500_dir, &plf->dev, &ab8500_all_banks_fops);
+	if (!file)
+		goto err;
+
 	file = debugfs_create_file("register-bank", (S_IRUGO | S_IWUSR),
 	    ab8500_dir, &plf->dev, &ab8500_bank_fops);
 	if (!file)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 18/26] mfd: ab8500-core: Allow the possibility to dump all AB8500 registers
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (16 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 17/26] mfd: ab8500-debugfs: add debugfs node to read all registers Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:55 ` [PATCH 19/26] mfd: ab8500-debugfs: Allow number of IRQs to be provided more dynamically Lee Jones
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Mian Yousaf Kaukab, Lee Jones

From: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>

Implement an API so that a user may dump all AB8500 registers
via debugfs file access.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Reviewed-by: Linus WALLEIJ <linus.walleij@stericsson.com>
Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
---
 drivers/mfd/ab8500-core.c         |    1 +
 drivers/mfd/ab8500-debugfs.c      |   13 +++++++++++++
 include/linux/mfd/abx500/ab8500.h |    6 ++++++
 3 files changed, 20 insertions(+)

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 1667c77..0f84fc0 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -319,6 +319,7 @@ static struct abx500_ops ab8500_ops = {
 	.mask_and_set_register = ab8500_mask_and_set_register,
 	.event_registers_startup_state_get = NULL,
 	.startup_irq_enabled = NULL,
+	.dump_all_banks = ab8500_dump_all_banks,
 };
 
 static void ab8500_irq_lock(struct irq_data *data)
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index a1ce55e..ec57e43 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -581,6 +581,19 @@ static int ab8500_print_all_banks(struct seq_file *s, void *p)
 	return 0;
 }
 
+/* Dump registers to kernel log */
+void ab8500_dump_all_banks(struct device *dev)
+{
+	unsigned int i;
+
+	printk(KERN_INFO"ab8500 register values:\n");
+
+	for (i = 1; i < AB8500_NUM_BANKS; i++) {
+		printk(KERN_INFO" bank %u:\n", i);
+		ab8500_registers_print(dev, i, NULL);
+	}
+}
+
 static int ab8500_all_banks_open(struct inode *inode, struct file *file)
 {
 	struct seq_file *s;
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 3f4e6d1..4c8d966 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -345,4 +345,10 @@ static inline int is_ab8500_2p0(struct ab8500 *ab)
 	return (is_ab8500(ab) && (ab->chip_id == AB8500_CUT2P0));
 }
 
+#ifdef CONFIG_AB8500_DEBUG
+void ab8500_dump_all_banks(struct device *dev);
+#else
+static inline void ab8500_dump_all_banks(struct device *dev) {}
+#endif
+
 #endif /* MFD_AB8500_H */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 19/26] mfd: ab8500-debugfs: Allow number of IRQs to be provided more dynamically
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (17 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 18/26] mfd: ab8500-core: Allow the possibility to dump all AB8500 registers Lee Jones
@ 2013-01-15 12:55 ` Lee Jones
  2013-01-15 12:56 ` [PATCH 20/26] mfd ab8500-gpadc: Introduce new AB version detection Lee Jones
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:55 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel; +Cc: arnd, linus.walleij, sameo, Lee Jones

From: Linus Walleij <linus.walleij@stericsson.com>

With the introduction of new AB* platforms, it's important to allow
as much code reuse as possible. By allowing a system's number of IRQs
to be dynamically passed, we can reuse almost all of the -debugfs
driver.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |   51 +++++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index ec57e43..d23b6cc 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -94,10 +94,11 @@ static u32 debug_address;
 
 static int irq_first;
 static int irq_last;
-static u32 irq_count[AB8500_NR_IRQS];
+static u32 *irq_count;
+static int num_irqs;
 
-static struct device_attribute *dev_attr[AB8500_NR_IRQS];
-static char *event_name[AB8500_NR_IRQS];
+static struct device_attribute **dev_attr;
+static char **event_name;
 
 /**
  * struct ab8500_reg_range
@@ -483,7 +484,7 @@ static irqreturn_t ab8500_debug_handler(int irq, void *data)
 	struct kobject *kobj = (struct kobject *)data;
 	unsigned int irq_abb = irq - irq_first;
 
-	if (irq_abb < AB8500_NR_IRQS)
+	if (irq_abb < num_irqs)
 		irq_count[irq_abb]++;
 	/*
 	 * This makes it possible to use poll for events (POLLPRI | POLLERR)
@@ -1338,7 +1339,7 @@ static ssize_t show_irq(struct device *dev,
 		return err;
 
 	irq_index = name - irq_first;
-	if (irq_index >= AB8500_NR_IRQS)
+	if (irq_index >= num_irqs)
 		return -EINVAL;
 	else
 		return sprintf(buf, "%u\n", irq_count[irq_index]);
@@ -1374,7 +1375,7 @@ static ssize_t ab8500_subscribe_write(struct file *file,
 	}
 
 	irq_index = user_val - irq_first;
-	if (irq_index >= AB8500_NR_IRQS)
+	if (irq_index >= num_irqs)
 		return -EINVAL;
 
 	/*
@@ -1438,7 +1439,7 @@ static ssize_t ab8500_unsubscribe_write(struct file *file,
 	}
 
 	irq_index = user_val - irq_first;
-	if (irq_index >= AB8500_NR_IRQS)
+	if (irq_index >= num_irqs)
 		return -EINVAL;
 
 	/* Set irq count to 0 when unsubscribe */
@@ -1519,21 +1520,40 @@ static struct dentry *ab8500_gpadc_dir;
 static int __devinit ab8500_debug_probe(struct platform_device *plf)
 {
 	struct dentry *file;
+	int ret = -ENOMEM;
+	struct ab8500 *ab8500;
 	debug_bank = AB8500_MISC;
 	debug_address = AB8500_REV_REG & 0x00FF;
 
+	ab8500 = dev_get_drvdata(plf->dev.parent);
+	num_irqs = ab8500->mask_size;
+
+	irq_count = kzalloc(sizeof(irq_count)*num_irqs, GFP_KERNEL);
+	if (!irq_count)
+		return -ENOMEM;
+
+	dev_attr = kzalloc(sizeof(*dev_attr)*num_irqs,GFP_KERNEL);
+	if (!dev_attr)
+		goto out_freeirq_count;
+
+	event_name = kzalloc(sizeof(*event_name)*num_irqs, GFP_KERNEL);
+	if (!event_name)
+		goto out_freedev_attr;
+
 	irq_first = platform_get_irq_byname(plf, "IRQ_FIRST");
 	if (irq_first < 0) {
 		dev_err(&plf->dev, "First irq not found, err %d\n",
 				irq_first);
-		return irq_first;
+		ret = irq_first;
+		goto out_freeevent_name;
 	}
 
 	irq_last = platform_get_irq_byname(plf, "IRQ_LAST");
 	if (irq_last < 0) {
 		dev_err(&plf->dev, "Last irq not found, err %d\n",
 				irq_last);
-		return irq_last;
+		ret = irq_last;
+                goto out_freeevent_name;
 	}
 
 	ab8500_dir = debugfs_create_dir(AB8500_NAME_STRING, NULL);
@@ -1656,12 +1676,23 @@ err:
 	if (ab8500_dir)
 		debugfs_remove_recursive(ab8500_dir);
 	dev_err(&plf->dev, "failed to create debugfs entries.\n");
-	return -ENOMEM;
+out_freeevent_name:
+	kfree(event_name);
+out_freedev_attr:
+	kfree(dev_attr);
+out_freeirq_count:
+	kfree(irq_count);
+
+	return ret;
 }
 
 static int __devexit ab8500_debug_remove(struct platform_device *plf)
 {
 	debugfs_remove_recursive(ab8500_dir);
+	kfree(event_name);
+	kfree(dev_attr);
+	kfree(irq_count);
+
 	return 0;
 }
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 20/26] mfd ab8500-gpadc: Introduce new AB version detection
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (18 preceding siblings ...)
  2013-01-15 12:55 ` [PATCH 19/26] mfd: ab8500-debugfs: Allow number of IRQs to be provided more dynamically Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-15 12:56 ` [PATCH 21/26] mfd: ab8500-debugfs: Add interrupt debug Lee Jones
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Michel JAOUEN, Lee Jones,
	Maxime Coquelin, Bengt Jonsson

From: Michel JAOUEN <michel.jaouen@stericsson.com>

Add support for AB8505 and AB9540

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Maxime Coquelin <maxime.coquelin@stericsson.com>
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
---
 drivers/mfd/ab8500-gpadc.c |   15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 3883b93..6f97c599 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -102,10 +102,10 @@ struct adc_cal_data {
 
 /**
  * struct ab8500_gpadc - AB8500 GPADC device information
- * @chip_id			ABB chip id
  * @dev:			pointer to the struct device
  * @node:			a list of AB8500 GPADCs, hence prepared for
 				reentrance
+ * @parent:			pointer to the struct ab8500
  * @ab8500_gpadc_complete:	pointer to the struct completion, to indicate
  *				the completion of gpadc conversion
  * @ab8500_gpadc_lock:		structure of type mutex
@@ -114,9 +114,9 @@ struct adc_cal_data {
  * @cal_data			array of ADC calibration data structs
  */
 struct ab8500_gpadc {
-	u8 chip_id;
 	struct device *dev;
 	struct list_head node;
+	struct ab8500 *parent;
 	struct completion ab8500_gpadc_complete;
 	struct mutex ab8500_gpadc_lock;
 	struct regulator *regu;
@@ -332,7 +332,7 @@ int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel)
 			EN_BUF | EN_ICHAR);
 		break;
 	case BTEMP_BALL:
-		if (gpadc->chip_id >= AB8500_CUT3P0) {
+		if (!is_ab8500_2p0_or_earlier(gpadc->parent)) {
 			/* Turn on btemp pull-up on ABB 3.0 */
 			ret = abx500_mask_and_set_register_interruptible(
 				gpadc->dev,
@@ -591,6 +591,7 @@ static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
 	}
 
 	gpadc->dev = &pdev->dev;
+	gpadc->parent = dev_get_drvdata(pdev->dev.parent);
 	mutex_init(&gpadc->ab8500_gpadc_lock);
 
 	/* Initialize completion used to notify completion of conversion */
@@ -607,14 +608,6 @@ static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
 		goto fail;
 	}
 
-	/* Get Chip ID of the ABB ASIC  */
-	ret = abx500_get_chip_id(gpadc->dev);
-	if (ret < 0) {
-		dev_err(gpadc->dev, "failed to get chip ID\n");
-		goto fail_irq;
-	}
-	gpadc->chip_id = (u8) ret;
-
 	/* VTVout LDO used to power up ab8500-GPADC */
 	gpadc->regu = regulator_get(&pdev->dev, "vddadc");
 	if (IS_ERR(gpadc->regu)) {
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 21/26] mfd: ab8500-debugfs: Add interrupt debug
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (19 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 20/26] mfd ab8500-gpadc: Introduce new AB version detection Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-15 12:56 ` [PATCH 22/26] mfd: ab8500-gpadc: Add runtime pm support Lee Jones
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Bengt Jonsson, Lee Jones

From: Bengt Jonsson <bengt.g.jonsson@stericsson.com>

This patch adds an entry in debugfs to check number of interrupts
from the AB.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
Reviewed-by: Rabin VINCENT <rabin.vincent@stericsson.com>
---
 drivers/mfd/ab8500-core.c         |    1 +
 drivers/mfd/ab8500-debugfs.c      |   49 +++++++++++++++++++++++++++++++++++++
 include/linux/mfd/abx500/ab8500.h |    2 ++
 3 files changed, 52 insertions(+)

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 0f84fc0..580adf3 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -521,6 +521,7 @@ static irqreturn_t ab8500_irq(int irq, void *dev)
 			int virq = ab8500_irq_get_virq(ab8500, line);
 
 			handle_nested_irq(virq);
+			ab8500_debug_register_interrupt(line);
 			value &= ~(1 << bit);
 
 		} while (value);
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index d23b6cc..8e405af 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -737,6 +737,35 @@ static ssize_t ab8500_val_write(struct file *file,
 }
 
 /*
+ * Interrupt status
+ */
+static u32 num_interrupts[AB8500_MAX_NR_IRQS];
+static int num_interrupt_lines;
+
+void ab8500_debug_register_interrupt(int line)
+{
+	if (line < num_interrupt_lines)
+		num_interrupts[line]++;
+}
+
+static int ab8500_interrupts_print(struct seq_file *s, void *p)
+{
+	int line;
+
+	seq_printf(s, "irq:  number of\n");
+
+	for (line = 0; line < num_interrupt_lines; line++)
+		seq_printf(s, "%3i:  %6i\n", line, num_interrupts[line]);
+
+	return 0;
+}
+
+static int ab8500_interrupts_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, ab8500_interrupts_print, inode->i_private);
+}
+
+/*
  * - HWREG DB8500 formated routines
  */
 static int ab8500_hwreg_print(struct seq_file *s, void *d)
@@ -1487,6 +1516,14 @@ static const struct file_operations ab8500_val_fops = {
 	.owner = THIS_MODULE,
 };
 
+static const struct file_operations ab8500_interrupts_fops = {
+	.open = ab8500_interrupts_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.owner = THIS_MODULE,
+};
+
 static const struct file_operations ab8500_subscribe_fops = {
 	.open = ab8500_subscribe_unsubscribe_open,
 	.write = ab8500_subscribe_write,
@@ -1595,6 +1632,18 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	if (!file)
 		goto err;
 
+	if (is_ab8500(ab8500))
+		num_interrupt_lines = AB8500_NR_IRQS;
+	else if (is_ab8505(ab8500))
+		num_interrupt_lines = AB8505_NR_IRQS;
+	else if (is_ab9540(ab8500))
+		num_interrupt_lines = AB9540_NR_IRQS;
+
+	file = debugfs_create_file("interrupts", (S_IRUGO),
+	    ab8500_dir, &plf->dev, &ab8500_interrupts_fops);
+	if (!file)
+		goto err;
+
 	file = debugfs_create_file("irq-unsubscribe", (S_IRUGO | S_IWUSR),
 	    ab8500_dir, &plf->dev, &ab8500_unsubscribe_fops);
 	if (!file)
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 4c8d966..83de910 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -347,8 +347,10 @@ static inline int is_ab8500_2p0(struct ab8500 *ab)
 
 #ifdef CONFIG_AB8500_DEBUG
 void ab8500_dump_all_banks(struct device *dev);
+void ab8500_debug_register_interrupt(int line);
 #else
 static inline void ab8500_dump_all_banks(struct device *dev) {}
+static inline void ab8500_debug_register_interrupt(int line) {}
 #endif
 
 #endif /* MFD_AB8500_H */
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 22/26] mfd: ab8500-gpadc: Add runtime pm support
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (20 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 21/26] mfd: ab8500-debugfs: Add interrupt debug Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-15 12:56 ` [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink Lee Jones
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

Add runtime pm support to speed up multiple ADC reads in a row.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Ulf HANSSON <ulf.hansson@stericsson.com>
---
 drivers/mfd/ab8500-gpadc.c |   70 ++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 64 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 6f97c599..1fd8f78 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/delay.h>
+#include <linux/pm_runtime.h>
 #include <linux/platform_device.h>
 #include <linux/completion.h>
 #include <linux/regulator/consumer.h>
@@ -82,6 +83,9 @@
 /* This is used to not lose precision when dividing to get gain and offset */
 #define CALIB_SCALE			1000
 
+/* Time in ms before disabling regulator */
+#define GPADC_AUDOSUSPEND_DELAY		1
+
 enum cal_channels {
 	ADC_INPUT_VMAIN = 0,
 	ADC_INPUT_BTEMP,
@@ -282,8 +286,9 @@ int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel)
 		return -ENODEV;
 
 	mutex_lock(&gpadc->ab8500_gpadc_lock);
+
 	/* Enable VTVout LDO this is required for GPADC */
-	regulator_enable(gpadc->regu);
+	pm_runtime_get_sync(gpadc->dev);
 
 	/* Check if ADC is not busy, lock and proceed */
 	do {
@@ -397,8 +402,10 @@ int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel)
 		dev_err(gpadc->dev, "gpadc_conversion: disable gpadc failed\n");
 		goto out;
 	}
-	/* Disable VTVout LDO this is required for GPADC */
-	regulator_disable(gpadc->regu);
+
+	pm_runtime_mark_last_busy(gpadc->dev);
+	pm_runtime_put_autosuspend(gpadc->dev);
+
 	mutex_unlock(&gpadc->ab8500_gpadc_lock);
 
 	return (high_data << 8) | low_data;
@@ -412,7 +419,9 @@ out:
 	 */
 	(void) abx500_set_register_interruptible(gpadc->dev, AB8500_GPADC,
 		AB8500_GPADC_CTRL1_REG, DIS_GPADC);
-	regulator_disable(gpadc->regu);
+
+	pm_runtime_put(gpadc->dev);
+
 	mutex_unlock(&gpadc->ab8500_gpadc_lock);
 	dev_err(gpadc->dev,
 		"gpadc_conversion: Failed to AD convert channel %d\n", channel);
@@ -571,6 +580,30 @@ static void ab8500_gpadc_read_calibration_data(struct ab8500_gpadc *gpadc)
 		gpadc->cal_data[ADC_INPUT_VBAT].offset);
 }
 
+static int ab8500_gpadc_runtime_suspend(struct device *dev)
+{
+	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
+
+	regulator_disable(gpadc->regu);
+	return 0;
+}
+
+static int ab8500_gpadc_runtime_resume(struct device *dev)
+{
+	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
+
+	regulator_enable(gpadc->regu);
+	return 0;
+}
+
+static int ab8500_gpadc_runtime_idle(struct device *dev)
+{
+	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
+
+	pm_runtime_suspend(dev);
+	return 0;
+}
+
 static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
 {
 	int ret = 0;
@@ -615,6 +648,16 @@ static int __devinit ab8500_gpadc_probe(struct platform_device *pdev)
 		dev_err(gpadc->dev, "failed to get vtvout LDO\n");
 		goto fail_irq;
 	}
+
+	platform_set_drvdata(pdev, gpadc);
+
+	regulator_enable(gpadc->regu);
+
+	pm_runtime_set_autosuspend_delay(gpadc->dev, GPADC_AUDOSUSPEND_DELAY);
+	pm_runtime_use_autosuspend(gpadc->dev);
+	pm_runtime_set_active(gpadc->dev);
+	pm_runtime_enable(gpadc->dev);
+
 	ab8500_gpadc_read_calibration_data(gpadc);
 	list_add_tail(&gpadc->node, &ab8500_gpadc_list);
 	dev_dbg(gpadc->dev, "probe success\n");
@@ -635,19 +678,34 @@ static int __devexit ab8500_gpadc_remove(struct platform_device *pdev)
 	list_del(&gpadc->node);
 	/* remove interrupt  - completion of Sw ADC conversion */
 	free_irq(gpadc->irq, gpadc);
-	/* disable VTVout LDO that is being used by GPADC */
-	regulator_put(gpadc->regu);
+
+	pm_runtime_get_sync(gpadc->dev);
+	pm_runtime_disable(gpadc->dev);
+
+	regulator_disable(gpadc->regu);
+
+	pm_runtime_set_suspended(gpadc->dev);
+
+	pm_runtime_put_noidle(gpadc->dev);
+
 	kfree(gpadc);
 	gpadc = NULL;
 	return 0;
 }
 
+static const struct dev_pm_ops ab8500_gpadc_pm_ops = {
+	SET_RUNTIME_PM_OPS(ab8500_gpadc_runtime_suspend,
+			   ab8500_gpadc_runtime_resume,
+			   ab8500_gpadc_runtime_idle)
+};
+
 static struct platform_driver ab8500_gpadc_driver = {
 	.probe = ab8500_gpadc_probe,
 	.remove = __devexit_p(ab8500_gpadc_remove),
 	.driver = {
 		.name = "ab8500-gpadc",
 		.owner = THIS_MODULE,
+		.pm = &ab8500_gpadc_pm_ops,
 	},
 };
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (21 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 22/26] mfd: ab8500-gpadc: Add runtime pm support Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-27 23:53   ` Samuel Ortiz
  2013-01-15 12:56 ` [PATCH 24/26] mfd: ab8500-debugfs: sizeof() mismatch bugfix Lee Jones
                   ` (2 subsequent siblings)
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Naga Radhesh, Lee Jones

From: Naga Radhesh <naga.radheshy@stericsson.com>

Enable support for PWM OUT LED blinking for AB8505. Instead of
having 3 pwm instances from ab8500 core file add it as platform data.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com>
Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com>
Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
---
 drivers/mfd/ab8500-core.c          |   10 --
 drivers/misc/ab8500-pwm.c          |  282 ++++++++++++++++++++++++++++++++++++
 include/linux/mfd/ab8500/pwmleds.h |   20 +++
 include/linux/mfd/abx500/ab8500.h  |    2 +
 4 files changed, 304 insertions(+), 10 deletions(-)
 create mode 100644 drivers/misc/ab8500-pwm.c
 create mode 100644 include/linux/mfd/ab8500/pwmleds.h

diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index 580adf3..c758469 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1015,16 +1015,6 @@ static struct mfd_cell __devinitdata abx500_common_devs[] = {
 		.id = 1,
 	},
 	{
-		.name = "ab8500-pwm",
-		.of_compatible = "stericsson,ab8500-pwm",
-		.id = 2,
-	},
-	{
-		.name = "ab8500-pwm",
-		.of_compatible = "stericsson,ab8500-pwm",
-		.id = 3,
-	},
-	{
 		.name = "ab8500-leds",
 		.of_compatible = "stericsson,ab8500-leds",
 	},
diff --git a/drivers/misc/ab8500-pwm.c b/drivers/misc/ab8500-pwm.c
new file mode 100644
index 0000000..d7a6276
--- /dev/null
+++ b/drivers/misc/ab8500-pwm.c
@@ -0,0 +1,282 @@
+/*
+ * Copyright (C) ST-Ericsson SA 2010
+ *
+ * Author: Arun R Murthy <arun.murthy@stericsson.com>
+ * License terms: GNU General Public License (GPL) version 2
+ */
+#include <linux/err.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/pwm.h>
+#include <linux/clk.h>
+#include <linux/mfd/abx500.h>
+#include <linux/mfd/abx500/ab8500.h>
+#include <linux/module.h>
+#include <linux/mfd/ab8500/pwmleds.h>
+/*
+ * PWM Out generators
+ * Bank: 0x10
+ */
+#define AB8500_PWM_OUT_CTRL1_REG	0x60
+#define AB8500_PWM_OUT_CTRL2_REG	0x61
+#define AB8500_PWM_OUT_CTRL7_REG	0x66
+#define AB8505_PWM_OUT_BLINK_CTRL1_REG  0x68
+#define AB8505_PWM_OUT_BLINK_CTRL4_REG  0x6B
+#define AB8505_PWM_OUT_BLINK_CTRL_DUTYBIT 4
+#define AB8505_PWM_OUT_BLINK_DUTYMASK (0x0F << AB8505_PWM_OUT_BLINK_CTRL_DUTYBIT)
+
+
+/* backlight driver constants */
+#define ENABLE_PWM			1
+#define DISABLE_PWM			0
+
+struct pwm_device {
+	struct device *dev;
+	struct list_head node;
+	struct clk *clk;
+	const char *label;
+	unsigned int pwm_id;
+	unsigned int blink_en;
+	struct ab8500 *parent;
+	bool clk_enabled;
+};
+
+static LIST_HEAD(pwm_list);
+
+int pwm_config_blink(struct pwm_device *pwm, int duty_ns, int period_ns)
+{
+	int ret;
+	unsigned int value;
+	u8 reg;
+	if ((!is_ab8505(pwm->parent)) || (!pwm->blink_en)) {
+		dev_err(pwm->dev, "setting blinking for this "
+					"device not supported\n");
+		return -EINVAL;
+	}
+	/*
+	 * get the period value that is to be written to
+	 * AB8500_PWM_OUT_BLINK_CTRL1 REGS[0:2]
+	 */
+	value = period_ns & 0x07;
+	/*
+	 * get blink duty value to be written to
+	 * AB8500_PWM_OUT_BLINK_CTRL REGS[7:4]
+	 */
+	value |= ((duty_ns << AB8505_PWM_OUT_BLINK_CTRL_DUTYBIT) &
+					AB8505_PWM_OUT_BLINK_DUTYMASK);
+
+	reg = AB8505_PWM_OUT_BLINK_CTRL1_REG + (pwm->pwm_id - 1);
+
+	ret = abx500_set_register_interruptible(pwm->dev, AB8500_MISC,
+			reg, (u8)value);
+	if (ret < 0)
+		dev_err(pwm->dev, "%s: Failed to config PWM blink,Error %d\n",
+							pwm->label, ret);
+	return ret;
+}
+
+int pwm_blink_ctrl(struct pwm_device *pwm , int enable)
+{
+	int ret;
+
+	if ((!is_ab8505(pwm->parent)) || (!pwm->blink_en)) {
+		dev_err(pwm->dev, "setting blinking for this "
+					"device not supported\n");
+		return -EINVAL;
+	}
+	/*
+	 * Enable/disable blinking feature for corresponding PWMOUT
+	 * channel depending on value of enable.
+	 */
+	ret = abx500_mask_and_set_register_interruptible(pwm->dev,
+			AB8500_MISC, AB8505_PWM_OUT_BLINK_CTRL4_REG,
+			1 << (pwm->pwm_id-1), enable << (pwm->pwm_id-1));
+	if (ret < 0)
+		dev_err(pwm->dev, "%s: Failed to control PWM blink,Error %d\n",
+							pwm->label, ret);
+	return ret;
+}
+
+int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
+{
+	int ret = 0;
+	unsigned int higher_val, lower_val;
+	u8 reg;
+
+	/*
+	 * get the first 8 bits that are be written to
+	 * AB8500_PWM_OUT_CTRL1_REG[0:7]
+	 */
+	lower_val = duty_ns & 0x00FF;
+	/*
+	 * get bits [9:10] that are to be written to
+	 * AB8500_PWM_OUT_CTRL2_REG[0:1]
+	 */
+	higher_val = ((duty_ns & 0x0300) >> 8);
+
+	reg = AB8500_PWM_OUT_CTRL1_REG + ((pwm->pwm_id - 1) * 2);
+
+	ret = abx500_set_register_interruptible(pwm->dev, AB8500_MISC,
+			reg, (u8)lower_val);
+	if (ret < 0)
+		return ret;
+	ret = abx500_set_register_interruptible(pwm->dev, AB8500_MISC,
+			(reg + 1), (u8)higher_val);
+
+	return ret;
+}
+EXPORT_SYMBOL(pwm_config);
+
+int pwm_enable(struct pwm_device *pwm)
+{
+	int ret;
+
+	if (!pwm->clk_enabled) {
+		ret = clk_enable(pwm->clk);
+		if (ret < 0) {
+			dev_err(pwm->dev, "failed to enable clock\n");
+			return ret;
+		}
+		pwm->clk_enabled = true;
+	}
+	ret = abx500_mask_and_set_register_interruptible(pwm->dev,
+				AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
+				1 << (pwm->pwm_id-1), 1 << (pwm->pwm_id-1));
+	if (ret < 0)
+		dev_err(pwm->dev, "%s: Failed to enable PWM, Error %d\n",
+							pwm->label, ret);
+	return ret;
+}
+EXPORT_SYMBOL(pwm_enable);
+
+void pwm_disable(struct pwm_device *pwm)
+{
+	int ret;
+
+	ret = abx500_mask_and_set_register_interruptible(pwm->dev,
+				AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
+				1 << (pwm->pwm_id-1), DISABLE_PWM);
+	/*
+	 * Workaround to set PWM in disable.
+	 * If enable bit is not toggled the PWM might output 50/50 duty cycle
+	 * even though it should be disabled
+	 */
+	ret &= abx500_mask_and_set_register_interruptible(pwm->dev,
+				AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
+				1 << (pwm->pwm_id-1),
+				ENABLE_PWM << (pwm->pwm_id-1));
+	ret &= abx500_mask_and_set_register_interruptible(pwm->dev,
+				AB8500_MISC, AB8500_PWM_OUT_CTRL7_REG,
+				1 << (pwm->pwm_id-1), DISABLE_PWM);
+
+	if (ret < 0)
+		dev_err(pwm->dev, "%s: Failed to disable PWM, Error %d\n",
+							pwm->label, ret);
+	if (pwm->clk_enabled) {
+		clk_disable(pwm->clk);
+		pwm->clk_enabled = false;
+	}
+
+	return;
+}
+EXPORT_SYMBOL(pwm_disable);
+
+struct pwm_device *pwm_request(int pwm_id, const char *label)
+{
+	struct pwm_device *pwm;
+	list_for_each_entry(pwm, &pwm_list, node) {
+		if (pwm->pwm_id == pwm_id) {
+			pwm->label = label;
+			pwm->pwm_id = pwm_id;
+			return pwm;
+		}
+	}
+
+	return ERR_PTR(-ENOENT);
+}
+EXPORT_SYMBOL(pwm_request);
+
+void pwm_free(struct pwm_device *pwm)
+{
+	pwm_disable(pwm);
+}
+EXPORT_SYMBOL(pwm_free);
+
+static int __devinit ab8500_pwm_probe(struct platform_device *pdev)
+{
+	struct ab8500 *parent = dev_get_drvdata(pdev->dev.parent);
+	struct ab8500_platform_data *plat = dev_get_platdata(parent->dev);
+	struct ab8500_pwmled_platform_data *pdata = plat->pwmled;
+	struct pwm_device *pwm;
+	int ret = 0 , i;
+
+	/*
+	 * Nothing to be done in probe, this is required to get the
+	 * device which is required for ab8500 read and write
+	 */
+	pwm = kzalloc(((sizeof(struct pwm_device)) * pdata->num_pwm),
+						 GFP_KERNEL);
+	if (pwm == NULL) {
+		dev_err(&pdev->dev, "failed to allocate memory\n");
+		return -ENOMEM;
+	}
+	for (i = 0; i < pdata->num_pwm; i++) {
+		pwm[i].dev = &pdev->dev;
+		pwm[i].parent = parent;
+		pwm[i].blink_en = pdata->leds[i].blink_en;
+		pwm[i].pwm_id = pdata->leds[i].pwm_id;
+		list_add_tail(&pwm[i].node, &pwm_list);
+	}
+	pwm->clk = clk_get(pwm->dev, NULL);
+	if (IS_ERR(pwm->clk)) {
+		dev_err(pwm->dev, "clock request failed\n");
+		ret = PTR_ERR(pwm->clk);
+		goto fail;
+	}
+	platform_set_drvdata(pdev, pwm);
+	pwm->clk_enabled = false;
+	dev_dbg(pwm->dev, "pwm probe successful\n");
+	return ret;
+
+fail:
+	list_del(&pwm->node);
+	kfree(pwm);
+	return ret;
+}
+
+static int __devexit ab8500_pwm_remove(struct platform_device *pdev)
+{
+	struct pwm_device *pwm = platform_get_drvdata(pdev);
+
+	list_del(&pwm->node);
+	clk_put(pwm->clk);
+	dev_dbg(&pdev->dev, "pwm driver removed\n");
+	kfree(pwm);
+	return 0;
+}
+
+static struct platform_driver ab8500_pwm_driver = {
+	.driver = {
+		.name = "ab8500-pwm",
+		.owner = THIS_MODULE,
+	},
+	.probe = ab8500_pwm_probe,
+	.remove = __devexit_p(ab8500_pwm_remove),
+};
+
+static int __init ab8500_pwm_init(void)
+{
+	return platform_driver_register(&ab8500_pwm_driver);
+}
+
+static void __exit ab8500_pwm_exit(void)
+{
+	platform_driver_unregister(&ab8500_pwm_driver);
+}
+
+subsys_initcall(ab8500_pwm_init);
+module_exit(ab8500_pwm_exit);
+MODULE_AUTHOR("Arun MURTHY <arun.murthy@stericsson.com>");
+MODULE_DESCRIPTION("AB8500 Pulse Width Modulation Driver");
+MODULE_ALIAS("platform:ab8500-pwm");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/ab8500/pwmleds.h b/include/linux/mfd/ab8500/pwmleds.h
new file mode 100644
index 0000000..e316582
--- /dev/null
+++ b/include/linux/mfd/ab8500/pwmleds.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright ST-Ericsson 2012.
+ *
+ * Author: Naga Radhesh <naga.radheshy@stericsson.com>
+ * Licensed under GPLv2.
+ */
+#ifndef _AB8500_PWMLED_H
+#define _AB8500_PWMLED_H
+
+struct ab8500_led_pwm {
+	int	pwm_id;
+	int	blink_en;
+};
+
+struct ab8500_pwmled_platform_data {
+	int	num_pwm;
+	struct	ab8500_led_pwm *leds;
+};
+
+#endif
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 83de910..62cbe65 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -281,6 +281,7 @@ struct ab8500_sysctrl_platform_data;
  * @regulator_reg_init: regulator init registers
  * @num_regulator: number of regulators
  * @regulator: machine-specific constraints for regulators
+ * @pwmled: machine-specific pwmled data
  */
 struct ab8500_platform_data {
 	int irq_base;
@@ -293,6 +294,7 @@ struct ab8500_platform_data {
 	struct ab8500_gpio_platform_data *gpio;
 	struct ab8500_codec_platform_data *codec;
 	struct ab8500_sysctrl_platform_data *sysctrl;
+	struct ab8500_pwmled_platform_data *pwmled;
 };
 
 extern int __devinit ab8500_init(struct ab8500 *ab8500,
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 24/26] mfd: ab8500-debugfs: sizeof() mismatch bugfix
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (22 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-15 12:56 ` [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout Lee Jones
  2013-01-15 12:56 ` [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter Lee Jones
  25 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Ashok G, Lee Jones

From: Ashok G <ashok.g@stericsson.com>

Simple pointer error fix to obtain the expected sizeof() result.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Ashok G <ashok.g@stericsson.com>
Reviewed-by: Mattias WALLIN <mattias.wallin@stericsson.com>
---
 drivers/mfd/ab8500-debugfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 8e405af..4147984 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -1565,7 +1565,7 @@ static int __devinit ab8500_debug_probe(struct platform_device *plf)
 	ab8500 = dev_get_drvdata(plf->dev.parent);
 	num_irqs = ab8500->mask_size;
 
-	irq_count = kzalloc(sizeof(irq_count)*num_irqs, GFP_KERNEL);
+	irq_count = kzalloc(sizeof(*irq_count)*num_irqs, GFP_KERNEL);
 	if (!irq_count)
 		return -ENOMEM;
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (23 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 24/26] mfd: ab8500-debugfs: sizeof() mismatch bugfix Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-27 23:53   ` Samuel Ortiz
  2013-01-15 12:56 ` [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter Lee Jones
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Jonas Aaberg, Lee Jones

From: Jonas Aaberg <jonas.aberg@stericsson.com>

Reduce the conversion timeout from 2s to 0.5s

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Karl KOMIEROWSKI <karl.komierowski@stericsson.com>
---
 drivers/mfd/ab8500-gpadc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/ab8500-gpadc.c b/drivers/mfd/ab8500-gpadc.c
index 1fd8f78..a7a6c77 100644
--- a/drivers/mfd/ab8500-gpadc.c
+++ b/drivers/mfd/ab8500-gpadc.c
@@ -86,6 +86,8 @@
 /* Time in ms before disabling regulator */
 #define GPADC_AUDOSUSPEND_DELAY		1
 
+#define CONVERSION_TIME			500 /* ms */
+
 enum cal_channels {
 	ADC_INPUT_VMAIN = 0,
 	ADC_INPUT_BTEMP,
@@ -372,7 +374,8 @@ int ab8500_gpadc_read_raw(struct ab8500_gpadc *gpadc, u8 channel)
 		goto out;
 	}
 	/* wait for completion of conversion */
-	if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete, 2*HZ)) {
+	if (!wait_for_completion_timeout(&gpadc->ab8500_gpadc_complete,
+					 msecs_to_jiffies(CONVERSION_TIME))) {
 		dev_err(gpadc->dev,
 			"timeout: didn't receive GPADC conversion interrupt\n");
 		ret = -EINVAL;
@@ -598,8 +601,6 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
 
 static int ab8500_gpadc_runtime_idle(struct device *dev)
 {
-	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
-
 	pm_runtime_suspend(dev);
 	return 0;
 }
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter
  2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
                   ` (24 preceding siblings ...)
  2013-01-15 12:56 ` [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout Lee Jones
@ 2013-01-15 12:56 ` Lee Jones
  2013-01-27 23:54   ` Samuel Ortiz
  25 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-15 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel
  Cc: arnd, linus.walleij, sameo, Philippe Langlais, Lee Jones

From: Philippe Langlais <philippe.langlais@linaro.org>

The new format of ab8500_gpadc_get() accepts a device name as a
parameter to specify which device to retrieve. This patch
enforces the use of that new format.

Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
---
 drivers/mfd/ab8500-debugfs.c |   26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c
index 4147984..f7e6d11 100644
--- a/drivers/mfd/ab8500-debugfs.c
+++ b/drivers/mfd/ab8500-debugfs.c
@@ -806,7 +806,7 @@ static int ab8500_gpadc_bat_ctrl_print(struct seq_file *s, void *p)
 	int bat_ctrl_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	bat_ctrl_raw = ab8500_gpadc_read_raw(gpadc, BAT_CTRL);
 	bat_ctrl_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 			BAT_CTRL, bat_ctrl_raw);
@@ -834,7 +834,7 @@ static int ab8500_gpadc_btemp_ball_print(struct seq_file *s, void *p)
 	int btemp_ball_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	btemp_ball_raw = ab8500_gpadc_read_raw(gpadc, BTEMP_BALL);
 	btemp_ball_convert = ab8500_gpadc_ad_to_voltage(gpadc, BTEMP_BALL,
 			btemp_ball_raw);
@@ -863,7 +863,7 @@ static int ab8500_gpadc_main_charger_v_print(struct seq_file *s, void *p)
 	int main_charger_v_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	main_charger_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_V);
 	main_charger_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 			MAIN_CHARGER_V, main_charger_v_raw);
@@ -893,7 +893,7 @@ static int ab8500_gpadc_acc_detect1_print(struct seq_file *s, void *p)
 	int acc_detect1_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	acc_detect1_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT1);
 	acc_detect1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ACC_DETECT1,
 			acc_detect1_raw);
@@ -923,7 +923,7 @@ static int ab8500_gpadc_acc_detect2_print(struct seq_file *s, void *p)
 	int acc_detect2_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	acc_detect2_raw = ab8500_gpadc_read_raw(gpadc, ACC_DETECT2);
 	acc_detect2_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 	    ACC_DETECT2, acc_detect2_raw);
@@ -953,7 +953,7 @@ static int ab8500_gpadc_aux1_print(struct seq_file *s, void *p)
 	int aux1_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	aux1_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX1);
 	aux1_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX1,
 			aux1_raw);
@@ -981,7 +981,7 @@ static int ab8500_gpadc_aux2_print(struct seq_file *s, void *p)
 	int aux2_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	aux2_raw = ab8500_gpadc_read_raw(gpadc, ADC_AUX2);
 	aux2_convert = ab8500_gpadc_ad_to_voltage(gpadc, ADC_AUX2,
 			aux2_raw);
@@ -1009,7 +1009,7 @@ static int ab8500_gpadc_main_bat_v_print(struct seq_file *s, void *p)
 	int main_bat_v_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	main_bat_v_raw = ab8500_gpadc_read_raw(gpadc, MAIN_BAT_V);
 	main_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, MAIN_BAT_V,
 			main_bat_v_raw);
@@ -1038,7 +1038,7 @@ static int ab8500_gpadc_vbus_v_print(struct seq_file *s, void *p)
 	int vbus_v_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	vbus_v_raw = ab8500_gpadc_read_raw(gpadc, VBUS_V);
 	vbus_v_convert = ab8500_gpadc_ad_to_voltage(gpadc, VBUS_V,
 			vbus_v_raw);
@@ -1066,7 +1066,7 @@ static int ab8500_gpadc_main_charger_c_print(struct seq_file *s, void *p)
 	int main_charger_c_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	main_charger_c_raw = ab8500_gpadc_read_raw(gpadc, MAIN_CHARGER_C);
 	main_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 			MAIN_CHARGER_C, main_charger_c_raw);
@@ -1096,7 +1096,7 @@ static int ab8500_gpadc_usb_charger_c_print(struct seq_file *s, void *p)
 	int usb_charger_c_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	usb_charger_c_raw = ab8500_gpadc_read_raw(gpadc, USB_CHARGER_C);
 	usb_charger_c_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 	    USB_CHARGER_C, usb_charger_c_raw);
@@ -1126,7 +1126,7 @@ static int ab8500_gpadc_bk_bat_v_print(struct seq_file *s, void *p)
 	int bk_bat_v_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	bk_bat_v_raw = ab8500_gpadc_read_raw(gpadc, BK_BAT_V);
 	bk_bat_v_convert = ab8500_gpadc_ad_to_voltage(gpadc,
 			BK_BAT_V, bk_bat_v_raw);
@@ -1154,7 +1154,7 @@ static int ab8500_gpadc_die_temp_print(struct seq_file *s, void *p)
 	int die_temp_convert;
 	struct ab8500_gpadc *gpadc;
 
-	gpadc = ab8500_gpadc_get();
+	gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
 	die_temp_raw = ab8500_gpadc_read_raw(gpadc, DIE_TEMP);
 	die_temp_convert = ab8500_gpadc_ad_to_voltage(gpadc, DIE_TEMP,
 			die_temp_raw);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 55+ messages in thread

* Re: [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer
  2013-01-15 12:55 ` [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer Lee Jones
@ 2013-01-15 13:06   ` Mark Brown
  2013-01-15 13:49     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Mark Brown @ 2013-01-15 13:06 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, sameo

On Tue, Jan 15, 2013 at 12:55:52PM +0000, Lee Jones wrote:
> Partly for coding style reasons, but mostly because sparse warns on it.
> 
> This patch is a completion of a previous patch my Mark Brown.

Typo there :)

Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer
  2013-01-15 13:06   ` Mark Brown
@ 2013-01-15 13:49     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-15 13:49 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, sameo

On Tue, 15 Jan 2013, Mark Brown wrote:

> On Tue, Jan 15, 2013 at 12:55:52PM +0000, Lee Jones wrote:
> > Partly for coding style reasons, but mostly because sparse warns on it.
> > 
> > This patch is a completion of a previous patch my Mark Brown.
> 
> Typo there :)

Yes, it should say "patch by my Mark Brown". ;)

> Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Thanks. I'll fixup with the typo.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead
  2013-01-15 12:55 ` [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead Lee Jones
@ 2013-01-27 23:52   ` Samuel Ortiz
  2013-01-28  8:44     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:52 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

Hi Lee,

On Tue, Jan 15, 2013 at 12:55:42PM +0000, Lee Jones wrote:
> From: Jonas Aaberg <jonas.aberg@stericsson.com>
> 
> If a changer is attached on power off, reboot the system
s/changer/charger/

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution
  2013-01-15 12:55 ` [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution Lee Jones
@ 2013-01-27 23:52   ` Samuel Ortiz
  2013-01-28  8:43     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:52 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

Hi Lee, Jonas,

On Tue, Jan 15, 2013 at 12:55:45PM +0000, Lee Jones wrote:
> From: Jonas Aaberg <jonas.aberg@stericsson.com>
> 
> The resolution of msleep is related to HZ, so with HZ set to
> 100 any msleep of less than 10ms will become ~10ms.
usleep_range would be more appropriate, sleeping should be preferred over
spinning.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers
  2013-01-15 12:55 ` [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers Lee Jones
@ 2013-01-27 23:52   ` Samuel Ortiz
  2013-01-28  8:38     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:52 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Kennet Wallden

Hi Lee, Kennet,

On Tue, Jan 15, 2013 at 12:55:46PM +0000, Lee Jones wrote:
> From: Kennet Wallden <kennet.wallden@stericsson.com>
> 
> Add the possibility to pass configuration settings for
> SysCl1kReqRfClkBuf to SysClk8ReqRfClkBuf via platform data.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Kennet Wallden <kennet.wallden@stericsson.com>
> Reviewed-by: Karl-Johan PERNTZ <karl-johan.perntz@stericsson.com>
> Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
> ---
>  drivers/mfd/ab8500-sysctrl.c              |   25 +++++++++++++++++++++++++
>  include/linux/mfd/abx500/ab8500-sysctrl.h |    5 +++++
>  include/linux/mfd/abx500/ab8500.h         |    2 ++
>  3 files changed, 32 insertions(+)
> 
> diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
> index cf58f69..19a024e 100644
> --- a/drivers/mfd/ab8500-sysctrl.c
> +++ b/drivers/mfd/ab8500-sysctrl.c
> @@ -113,11 +113,36 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
>  static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
>  {
>  	struct ab8500_platform_data *plat;
> +	struct ab8500_sysctrl_platform_data *pdata;
>  
>  	sysctrl_dev = &pdev->dev;
>  	plat = dev_get_platdata(pdev->dev.parent);
>  	if (plat->pm_power_off)
>  		pm_power_off = ab8500_power_off;
> +
> +	pdata = plat->sysctrl;
> +
> +	if (pdata) {
> +		int ret;
> +		int i;
> +		int j;
Cosmetic 
int i, j, ret;


> +		for (i = AB8500_SYSCLKREQ1RFCLKBUF;
> +		     i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) {
> +			j = i - AB8500_SYSCLKREQ1RFCLKBUF;
> +			ret = ab8500_sysctrl_write(i, 0xff,
> +						   pdata->initial_req_buf_config[j]);
> +			dev_dbg(&pdev->dev,
> +				"Setting SysClkReq%dRfClkBuf 0x%X\n",
> +				j + 1,
> +				pdata->initial_req_buf_config[j]);
> +			if (ret < 0) {
> +				dev_err(&pdev->dev,
> +					"unable to set sysClkReq%dRfClkBuf: "
> +					"%d\n", j + 1, ret);
> +			}
> +		}
> +	}
> +
>  	return 0;
>  }
>  
> diff --git a/include/linux/mfd/abx500/ab8500-sysctrl.h b/include/linux/mfd/abx500/ab8500-sysctrl.h
> index 10eb509..ebf12e7 100644
> --- a/include/linux/mfd/abx500/ab8500-sysctrl.h
> +++ b/include/linux/mfd/abx500/ab8500-sysctrl.h
> @@ -37,6 +37,11 @@ static inline int ab8500_sysctrl_clear(u16 reg, u8 bits)
>  	return ab8500_sysctrl_write(reg, bits, 0);
>  }
>  
> +/* Configuration data for SysClkReq1RfClkBuf - SysClkReq8RfClkBuf */
> +struct ab8500_sysctrl_platform_data {
> +	u8 initial_req_buf_config[8];
> +};
> +
>  /* Registers */
>  #define AB8500_TURNONSTATUS		0x100
>  #define AB8500_RESETSTATUS		0x101
> diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
> index 96840c4..3f4e6d1 100644
> --- a/include/linux/mfd/abx500/ab8500.h
> +++ b/include/linux/mfd/abx500/ab8500.h
> @@ -270,6 +270,7 @@ struct regulator_reg_init;
>  struct regulator_init_data;
>  struct ab8500_gpio_platform_data;
>  struct ab8500_codec_platform_data;
> +struct ab8500_sysctrl_platform_data;
>  
>  /**
>   * struct ab8500_platform_data - AB8500 platform data
> @@ -291,6 +292,7 @@ struct ab8500_platform_data {
>  	struct regulator_init_data *regulator;
>  	struct ab8500_gpio_platform_data *gpio;
>  	struct ab8500_codec_platform_data *codec;
> +	struct ab8500_sysctrl_platform_data *sysctrl;
>  };
>  
>  extern int __devinit ab8500_init(struct ab8500 *ab8500,
> -- 
> 1.7.9.5
> 

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-15 12:55 ` [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs Lee Jones
@ 2013-01-27 23:52   ` Samuel Ortiz
  2013-01-28  8:25     ` Lee Jones
  2013-01-28 10:22     ` Lee Jones
  0 siblings, 2 replies; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:52 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

Hi Lee,

On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> Allow users to subscribe to and view IRQ events live from debugfs.
I seem to remember that I got a similar patch some time ago for the same
purpose and my answer was: Please use a UIO driver for this. There already is
such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
do is adding a platform device for the specific interrupt number. This would
avoid the irq handler registration and the sysfs entry creation, both things I
believe are not very elegant and open coded. It also gives you an IRQ count
implementation.
Ideally, the UIO framework could be improved to support IRQ ranges (through
IRQ domains) instead of the current single interrupt number.

Have you considered going through that path ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ
  2013-01-15 12:55 ` [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ Lee Jones
@ 2013-01-27 23:53   ` Samuel Ortiz
  2013-01-28  8:49     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:53 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

Hi Lee,

On Tue, Jan 15, 2013 at 12:55:50PM +0000, Lee Jones wrote:
> Ensure the device wakes up if the debugfs IRQ fires if we're
> in suspend mode.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mfd/ab8500-debugfs.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
Please squash this one with the previous one.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry
  2013-01-15 12:55 ` [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry Lee Jones
@ 2013-01-27 23:53   ` Samuel Ortiz
  2013-01-28  8:47     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:53 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, carriere etienne

Hi Lee,

On Tue, Jan 15, 2013 at 12:55:53PM +0000, Lee Jones wrote:
> +static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
> +		struct device *dev)
> +{
> +	uint write, val = 0;
> +	struct hwreg_cfg loc = {
> +		.bank = 0,          /* default: invalid phys addr */
> +		.addr = 0,          /* default: invalid phys addr */
> +		.fmt = 0,           /* default: 32bit access, hex output */
> +		.mask = 0xFFFFFFFF, /* default: no mask */
> +		.shift = 0,         /* default: no bit shift */
> +	};
> +
> +	/* read or write ? */
> +	if (!strncmp(b, "read ", 5)) {
> +		write = 0;
> +		b += 5;
> +	} else if (!strncmp(b, "write ", 6)) {
> +		write = 1;
> +		b += 6;
> +	} else
> +		return -EINVAL;
> +
> +	/* OPTIONS -l|-w|-b -s -m -o */
> +	while ((*b == ' ') || (*b == '-')) {
> +		if (*(b-1) != ' ') {
> +			b++;
> +			continue;
> +		}
> +		if ((!strncmp(b, "-d ", 3)) ||
> +				(!strncmp(b, "-dec ", 5))) {
> +			b += (*(b+2) == ' ') ? 3 : 5;
> +			loc.fmt |= (1<<0);
> +		} else if ((!strncmp(b, "-h ", 3)) ||
> +				(!strncmp(b, "-hex ", 5))) {
> +			b += (*(b+2) == ' ') ? 3 : 5;
> +			loc.fmt &= ~(1<<0);
> +		} else if ((!strncmp(b, "-m ", 3)) ||
> +				(!strncmp(b, "-mask ", 6))) {
> +			b += (*(b+2) == ' ') ? 3 : 6;
> +			if (strval_len(b) == 0)
> +				return -EINVAL;
> +			loc.mask = simple_strtoul(b, &b, 0);
> +		} else if ((!strncmp(b, "-s ", 3)) ||
> +				(!strncmp(b, "-shift ", 7))) {
> +			b += (*(b+2) == ' ') ? 3 : 7;
> +			if (strval_len(b) == 0)
> +				return -EINVAL;
> +			loc.shift = simple_strtol(b, &b, 0);
> +		} else {
> +			return -EINVAL;
> +		}
> +	}
> +	/* get arg BANK and ADDRESS */
> +	if (strval_len(b) == 0)
> +		return -EINVAL;
> +	loc.bank = simple_strtoul(b, &b, 0);
> +	while (*b == ' ')
> +		b++;
> +	if (strval_len(b) == 0)
> +		return -EINVAL;
> +	loc.addr = simple_strtoul(b, &b, 0);
> +
> +	if (write) {
> +		while (*b == ' ')
> +			b++;
> +		if (strval_len(b) == 0)
> +			return -EINVAL;
> +		val = simple_strtoul(b, &b, 0);
> +	}
> +
> +	/* args are ok, update target cfg (mainly for read) */
> +	*cfg = loc;
> +
> +#if ABB_HWREG_DEBUG
> +	pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d
> +			value=0x%X\n", (write) ? "write" : "read",
> +			REG_FMT_DEC(cfg) ? "decimal" : "hexa",
> +			cfg->addr, cfg->mask, cfg->shift, val);
> +#endif
> +
> +	if (write) {
if (!write)
	return 0;

for a more readable code.


> +		u8  regvalue;
> +		int ret = abx500_get_register_interruptible(dev,
> +			(u8)cfg->bank, (u8)cfg->addr, &regvalue);
> +		if (ret < 0) {
> +			dev_err(dev, "abx500_get_reg fail %d, %d\n",
> +				ret, __LINE__);
> +			return -EINVAL;
> +		}
> +
> +		if (cfg->shift >= 0) {
> +			regvalue &= ~(cfg->mask << (cfg->shift));
> +			val = (val & cfg->mask) << (cfg->shift);
> +		} else {
> +			regvalue &= ~(cfg->mask >> (-cfg->shift));
> +			val = (val & cfg->mask) >> (-cfg->shift);
> +		}
> +		val = val | regvalue;
> +
> +		ret = abx500_set_register_interruptible(dev,
> +			(u8)cfg->bank, (u8)cfg->addr, (u8)val);
> +		if (ret < 0) {
> +			pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
> +			return -EINVAL;
> +		}
> +
> +	}
> +	return 0;
> +}
I think this is a pretty big routine, that could be split into a command
parsing part and the actual register write one.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings
  2013-01-15 12:55 ` [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings Lee Jones
@ 2013-01-27 23:53   ` Samuel Ortiz
  2013-01-28  8:45     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:53 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij,
	Philippe Langlais, Philippe Langlais

Hi Lee,

On Tue, Jan 15, 2013 at 12:55:54PM +0000, Lee Jones wrote:
> From: Philippe Langlais <philippe.langlais@stericsson.com>
> 
> Some simple fixes regarding pre-processor usage.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
> ---
>  drivers/mfd/ab8500-debugfs.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
Here again, please squash this one with the previous one.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout
  2013-01-15 12:56 ` [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout Lee Jones
@ 2013-01-27 23:53   ` Samuel Ortiz
  2013-01-28  8:45     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:53 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

Hi Lee,

On Tue, Jan 15, 2013 at 12:56:05PM +0000, Lee Jones wrote:
> @@ -598,8 +601,6 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
>  
>  static int ab8500_gpadc_runtime_idle(struct device *dev)
>  {
> -	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
> -
Unrelated change, please remove that part.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink
  2013-01-15 12:56 ` [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink Lee Jones
@ 2013-01-27 23:53   ` Samuel Ortiz
  2013-01-28  8:13     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:53 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Naga Radhesh

Hi Lee,

On Tue, Jan 15, 2013 at 12:56:03PM +0000, Lee Jones wrote:
> From: Naga Radhesh <naga.radheshy@stericsson.com>
> 
> Enable support for PWM OUT LED blinking for AB8505. Instead of
> having 3 pwm instances from ab8500 core file add it as platform data.
> 
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com>
> Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com>
> Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
> ---
>  drivers/mfd/ab8500-core.c          |   10 --
>  drivers/misc/ab8500-pwm.c          |  282 ++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/ab8500/pwmleds.h |   20 +++
>  include/linux/mfd/abx500/ab8500.h  |    2 +
>  4 files changed, 304 insertions(+), 10 deletions(-)
>  create mode 100644 drivers/misc/ab8500-pwm.c
This pretty much looks like the already existing and PWM API compliant
drivers/pwm/ab8500-pwm.c. What's the point here ?

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter
  2013-01-15 12:56 ` [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter Lee Jones
@ 2013-01-27 23:54   ` Samuel Ortiz
  2013-01-28  8:11     ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-27 23:54 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Philippe Langlais

Hi Lee,

On Tue, Jan 15, 2013 at 12:56:06PM +0000, Lee Jones wrote:
> From: Philippe Langlais <philippe.langlais@linaro.org>
> 
> The new format of ab8500_gpadc_get() accepts a device name as a
> parameter to specify which device to retrieve. This patch
> enforces the use of that new format.
Where is that new API coming from ? I couldn't find it in the previous 25
patches. If it's there, this one should be merged with the patch that changes
this API.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter
  2013-01-27 23:54   ` Samuel Ortiz
@ 2013-01-28  8:11     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:11 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Philippe Langlais

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:56:06PM +0000, Lee Jones wrote:
> > From: Philippe Langlais <philippe.langlais@linaro.org>
> > 
> > The new format of ab8500_gpadc_get() accepts a device name as a
> > parameter to specify which device to retrieve. This patch
> > enforces the use of that new format.
> Where is that new API coming from ? I couldn't find it in the previous 25
> patches. If it's there, this one should be merged with the patch that changes
> this API.

The API is already upstream:

6321992c (Daniel Willerud  2011-03-05 11:46:13 +0100 133) struct
  ab8500_gpadc *ab8500_gpadc_get(char *name)

The branch I'm trying to upstream from used the old one before now.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink
  2013-01-27 23:53   ` Samuel Ortiz
@ 2013-01-28  8:13     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:13 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Naga Radhesh

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:56:03PM +0000, Lee Jones wrote:
> > From: Naga Radhesh <naga.radheshy@stericsson.com>
> > 
> > Enable support for PWM OUT LED blinking for AB8505. Instead of
> > having 3 pwm instances from ab8500 core file add it as platform data.
> > 
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Naga Radhesh <naga.radheshy@stericsson.com>
> > Reviewed-by: Arun MURTHY <arun.murthy@stericsson.com>
> > Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
> > ---
> >  drivers/mfd/ab8500-core.c          |   10 --
> >  drivers/misc/ab8500-pwm.c          |  282 ++++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/ab8500/pwmleds.h |   20 +++
> >  include/linux/mfd/abx500/ab8500.h  |    2 +
> >  4 files changed, 304 insertions(+), 10 deletions(-)
> >  create mode 100644 drivers/misc/ab8500-pwm.c
> This pretty much looks like the already existing and PWM API compliant
> drivers/pwm/ab8500-pwm.c. What's the point here ?

This patch pre-dates the new PWM interface.

It's probably the same thing. I'll look into it.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-27 23:52   ` Samuel Ortiz
@ 2013-01-28  8:25     ` Lee Jones
  2013-01-28 10:22     ` Lee Jones
  1 sibling, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:25 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> > Allow users to subscribe to and view IRQ events live from debugfs.
> I seem to remember that I got a similar patch some time ago for the same
> purpose and my answer was: Please use a UIO driver for this. There already is
> such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
> do is adding a platform device for the specific interrupt number. This would
> avoid the irq handler registration and the sysfs entry creation, both things I
> believe are not very elegant and open coded. It also gives you an IRQ count
> implementation.
> Ideally, the UIO framework could be improved to support IRQ ranges (through
> IRQ domains) instead of the current single interrupt number.
> 
> Have you considered going through that path ?

I haven't looked into re-writing any of the MFD stuff yet. Instead I
have a plan of action:

1. Upstream as many of the 100 patches from the internal kernel up
into Mainline.

2. Mark any patches which are unsuitable for Mainlining and re-work
them after the remainder have been accepted. Not withstanding small
fixups, as these can be done on the fly without too much disruption.

3. Upstream the remainder once re-worked.

If I don't follow this work-flow and fix-up/re-work as I go, not only
will it take forever, but I'm also likely to encounter too many
complications in the way of conflicts in the latter stages.

I'm also following the same work-flow for 'drivers/power' and
'drivers/regulator'.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers
  2013-01-27 23:52   ` Samuel Ortiz
@ 2013-01-28  8:38     ` Lee Jones
  2013-02-03 17:02       ` Samuel Ortiz
  0 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:38 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Kennet Wallden

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee, Kennet,
> 
> On Tue, Jan 15, 2013 at 12:55:46PM +0000, Lee Jones wrote:
> > From: Kennet Wallden <kennet.wallden@stericsson.com>
> > 
> > Add the possibility to pass configuration settings for
> > SysCl1kReqRfClkBuf to SysClk8ReqRfClkBuf via platform data.
> > 
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Kennet Wallden <kennet.wallden@stericsson.com>
> > Reviewed-by: Karl-Johan PERNTZ <karl-johan.perntz@stericsson.com>
> > Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
> > ---
> >  drivers/mfd/ab8500-sysctrl.c              |   25 +++++++++++++++++++++++++
> >  include/linux/mfd/abx500/ab8500-sysctrl.h |    5 +++++
> >  include/linux/mfd/abx500/ab8500.h         |    2 ++
> >  3 files changed, 32 insertions(+)
> > 
> > diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
> > index cf58f69..19a024e 100644
> > --- a/drivers/mfd/ab8500-sysctrl.c
> > +++ b/drivers/mfd/ab8500-sysctrl.c
> > @@ -113,11 +113,36 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
> >  static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
> >  {
> >  	struct ab8500_platform_data *plat;
> > +	struct ab8500_sysctrl_platform_data *pdata;
> >  
> >  	sysctrl_dev = &pdev->dev;
> >  	plat = dev_get_platdata(pdev->dev.parent);
> >  	if (plat->pm_power_off)
> >  		pm_power_off = ab8500_power_off;
> > +
> > +	pdata = plat->sysctrl;
> > +
> > +	if (pdata) {
> > +		int ret;
> > +		int i;
> > +		int j;
> Cosmetic 
> int i, j, ret;

Hmmm... this is how I'd prefer it too, but other maintainers prefer
one-per-line. It would be better if we could standardise it somewhere
to prevent unnecessary fixups.

> > +		for (i = AB8500_SYSCLKREQ1RFCLKBUF;
> > +		     i <= AB8500_SYSCLKREQ8RFCLKBUF; i++) {
> > +			j = i - AB8500_SYSCLKREQ1RFCLKBUF;
> > +			ret = ab8500_sysctrl_write(i, 0xff,
> > +						   pdata->initial_req_buf_config[j]);
> > +			dev_dbg(&pdev->dev,
> > +				"Setting SysClkReq%dRfClkBuf 0x%X\n",
> > +				j + 1,
> > +				pdata->initial_req_buf_config[j]);
> > +			if (ret < 0) {
> > +				dev_err(&pdev->dev,
> > +					"unable to set sysClkReq%dRfClkBuf: "
> > +					"%d\n", j + 1, ret);
> > +			}
> > +		}
> > +	}
> > +
> >  	return 0;
> >  }
> >  
> > diff --git a/include/linux/mfd/abx500/ab8500-sysctrl.h b/include/linux/mfd/abx500/ab8500-sysctrl.h
> > index 10eb509..ebf12e7 100644
> > --- a/include/linux/mfd/abx500/ab8500-sysctrl.h
> > +++ b/include/linux/mfd/abx500/ab8500-sysctrl.h
> > @@ -37,6 +37,11 @@ static inline int ab8500_sysctrl_clear(u16 reg, u8 bits)
> >  	return ab8500_sysctrl_write(reg, bits, 0);
> >  }
> >  
> > +/* Configuration data for SysClkReq1RfClkBuf - SysClkReq8RfClkBuf */
> > +struct ab8500_sysctrl_platform_data {
> > +	u8 initial_req_buf_config[8];
> > +};
> > +
> >  /* Registers */
> >  #define AB8500_TURNONSTATUS		0x100
> >  #define AB8500_RESETSTATUS		0x101
> > diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
> > index 96840c4..3f4e6d1 100644
> > --- a/include/linux/mfd/abx500/ab8500.h
> > +++ b/include/linux/mfd/abx500/ab8500.h
> > @@ -270,6 +270,7 @@ struct regulator_reg_init;
> >  struct regulator_init_data;
> >  struct ab8500_gpio_platform_data;
> >  struct ab8500_codec_platform_data;
> > +struct ab8500_sysctrl_platform_data;
> >  
> >  /**
> >   * struct ab8500_platform_data - AB8500 platform data
> > @@ -291,6 +292,7 @@ struct ab8500_platform_data {
> >  	struct regulator_init_data *regulator;
> >  	struct ab8500_gpio_platform_data *gpio;
> >  	struct ab8500_codec_platform_data *codec;
> > +	struct ab8500_sysctrl_platform_data *sysctrl;
> >  };
> >  
> >  extern int __devinit ab8500_init(struct ab8500 *ab8500,
> 

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution
  2013-01-27 23:52   ` Samuel Ortiz
@ 2013-01-28  8:43     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:43 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee, Jonas,
> 
> On Tue, Jan 15, 2013 at 12:55:45PM +0000, Lee Jones wrote:
> > From: Jonas Aaberg <jonas.aberg@stericsson.com>
> > 
> > The resolution of msleep is related to HZ, so with HZ set to
> > 100 any msleep of less than 10ms will become ~10ms.
> usleep_range would be more appropriate, sleeping should be preferred over
> spinning.

I believe this patch was written before usleep_range() was around. This
is addressed in a latter patch. Please allow this one in for a)
historical reasons (trying to keep the development history) and b) to
prevent any conflicts when we do reach the fixup patch.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead
  2013-01-27 23:52   ` Samuel Ortiz
@ 2013-01-28  8:44     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:44 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:42PM +0000, Lee Jones wrote:
> > From: Jonas Aaberg <jonas.aberg@stericsson.com>
> > 
> > If a changer is attached on power off, reboot the system
> s/changer/charger/

I'll fixup.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout
  2013-01-27 23:53   ` Samuel Ortiz
@ 2013-01-28  8:45     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:45 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Jonas Aaberg

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:56:05PM +0000, Lee Jones wrote:
> > @@ -598,8 +601,6 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
> >  
> >  static int ab8500_gpadc_runtime_idle(struct device *dev)
> >  {
> > -	struct ab8500_gpadc *gpadc = dev_get_drvdata(dev);
> > -
> Unrelated change, please remove that part.

I'll fixup.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings
  2013-01-27 23:53   ` Samuel Ortiz
@ 2013-01-28  8:45     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:45 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij,
	Philippe Langlais, Philippe Langlais

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:54PM +0000, Lee Jones wrote:
> > From: Philippe Langlais <philippe.langlais@stericsson.com>
> > 
> > Some simple fixes regarding pre-processor usage.
> > 
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > Signed-off-by: Philippe Langlais <philippe.langlais@linaro.org>
> > ---
> >  drivers/mfd/ab8500-debugfs.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> Here again, please squash this one with the previous one.

I'll fixup.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry
  2013-01-27 23:53   ` Samuel Ortiz
@ 2013-01-28  8:47     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:47 UTC (permalink / raw)
  To: Samuel Ortiz
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, carriere etienne

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:53PM +0000, Lee Jones wrote:
> > +static ssize_t hwreg_common_write(char *b, struct hwreg_cfg *cfg,
> > +		struct device *dev)
> > +{
> > +	uint write, val = 0;
> > +	struct hwreg_cfg loc = {
> > +		.bank = 0,          /* default: invalid phys addr */
> > +		.addr = 0,          /* default: invalid phys addr */
> > +		.fmt = 0,           /* default: 32bit access, hex output */
> > +		.mask = 0xFFFFFFFF, /* default: no mask */
> > +		.shift = 0,         /* default: no bit shift */
> > +	};
> > +
> > +	/* read or write ? */
> > +	if (!strncmp(b, "read ", 5)) {
> > +		write = 0;
> > +		b += 5;
> > +	} else if (!strncmp(b, "write ", 6)) {
> > +		write = 1;
> > +		b += 6;
> > +	} else
> > +		return -EINVAL;
> > +
> > +	/* OPTIONS -l|-w|-b -s -m -o */
> > +	while ((*b == ' ') || (*b == '-')) {
> > +		if (*(b-1) != ' ') {
> > +			b++;
> > +			continue;
> > +		}
> > +		if ((!strncmp(b, "-d ", 3)) ||
> > +				(!strncmp(b, "-dec ", 5))) {
> > +			b += (*(b+2) == ' ') ? 3 : 5;
> > +			loc.fmt |= (1<<0);
> > +		} else if ((!strncmp(b, "-h ", 3)) ||
> > +				(!strncmp(b, "-hex ", 5))) {
> > +			b += (*(b+2) == ' ') ? 3 : 5;
> > +			loc.fmt &= ~(1<<0);
> > +		} else if ((!strncmp(b, "-m ", 3)) ||
> > +				(!strncmp(b, "-mask ", 6))) {
> > +			b += (*(b+2) == ' ') ? 3 : 6;
> > +			if (strval_len(b) == 0)
> > +				return -EINVAL;
> > +			loc.mask = simple_strtoul(b, &b, 0);
> > +		} else if ((!strncmp(b, "-s ", 3)) ||
> > +				(!strncmp(b, "-shift ", 7))) {
> > +			b += (*(b+2) == ' ') ? 3 : 7;
> > +			if (strval_len(b) == 0)
> > +				return -EINVAL;
> > +			loc.shift = simple_strtol(b, &b, 0);
> > +		} else {
> > +			return -EINVAL;
> > +		}
> > +	}
> > +	/* get arg BANK and ADDRESS */
> > +	if (strval_len(b) == 0)
> > +		return -EINVAL;
> > +	loc.bank = simple_strtoul(b, &b, 0);
> > +	while (*b == ' ')
> > +		b++;
> > +	if (strval_len(b) == 0)
> > +		return -EINVAL;
> > +	loc.addr = simple_strtoul(b, &b, 0);
> > +
> > +	if (write) {
> > +		while (*b == ' ')
> > +			b++;
> > +		if (strval_len(b) == 0)
> > +			return -EINVAL;
> > +		val = simple_strtoul(b, &b, 0);
> > +	}
> > +
> > +	/* args are ok, update target cfg (mainly for read) */
> > +	*cfg = loc;
> > +
> > +#if ABB_HWREG_DEBUG
> > +	pr_warn("HWREG request: %s, %s, addr=0x%08X, mask=0x%X, shift=%d
> > +			value=0x%X\n", (write) ? "write" : "read",
> > +			REG_FMT_DEC(cfg) ? "decimal" : "hexa",
> > +			cfg->addr, cfg->mask, cfg->shift, val);
> > +#endif
> > +
> > +	if (write) {
> if (!write)
> 	return 0;
> 
> for a more readable code.

I'll fixup.

> > +		u8  regvalue;
> > +		int ret = abx500_get_register_interruptible(dev,
> > +			(u8)cfg->bank, (u8)cfg->addr, &regvalue);
> > +		if (ret < 0) {
> > +			dev_err(dev, "abx500_get_reg fail %d, %d\n",
> > +				ret, __LINE__);
> > +			return -EINVAL;
> > +		}
> > +
> > +		if (cfg->shift >= 0) {
> > +			regvalue &= ~(cfg->mask << (cfg->shift));
> > +			val = (val & cfg->mask) << (cfg->shift);
> > +		} else {
> > +			regvalue &= ~(cfg->mask >> (-cfg->shift));
> > +			val = (val & cfg->mask) >> (-cfg->shift);
> > +		}
> > +		val = val | regvalue;
> > +
> > +		ret = abx500_set_register_interruptible(dev,
> > +			(u8)cfg->bank, (u8)cfg->addr, (u8)val);
> > +		if (ret < 0) {
> > +			pr_err("abx500_set_reg failed %d, %d", ret, __LINE__);
> > +			return -EINVAL;
> > +		}
> > +
> > +	}
> > +	return 0;
> > +}
> I think this is a pretty big routine, that could be split into a command
> parsing part and the actual register write one.

I've made a note to address this as the _end_ of the big push. I'd
really like to avoid any unnecessary conflicts.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ
  2013-01-27 23:53   ` Samuel Ortiz
@ 2013-01-28  8:49     ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-01-28  8:49 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:50PM +0000, Lee Jones wrote:
> > Ensure the device wakes up if the debugfs IRQ fires if we're
> > in suspend mode.
> > 
> > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > ---
> >  drivers/mfd/ab8500-debugfs.c |    3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> Please squash this one with the previous one.

I'll fixup.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-27 23:52   ` Samuel Ortiz
  2013-01-28  8:25     ` Lee Jones
@ 2013-01-28 10:22     ` Lee Jones
  2013-01-28 10:49       ` Samuel Ortiz
  1 sibling, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-28 10:22 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> > Allow users to subscribe to and view IRQ events live from debugfs.
> I seem to remember that I got a similar patch some time ago for the same
> purpose and my answer was: Please use a UIO driver for this. There already is
> such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
> do is adding a platform device for the specific interrupt number. This would
> avoid the irq handler registration and the sysfs entry creation, both things I
> believe are not very elegant and open coded. It also gives you an IRQ count
> implementation.
> Ideally, the UIO framework could be improved to support IRQ ranges (through
> IRQ domains) instead of the current single interrupt number.
> 
> Have you considered going through that path ?

I'm going to have to put this patch-set in the bin. Pulling this
patch, causes lots of conflicts to the remaining patches in the
set.

I'll start again from scratch and find another way to sync the ab* MFD
drivers. I might even have to do it manually i.e. throw out all
commit history and upstream it as my own patches pulled in from diffs.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-28 10:22     ` Lee Jones
@ 2013-01-28 10:49       ` Samuel Ortiz
  2013-01-28 11:34         ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-01-28 10:49 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

Hi Lee,

On Mon, Jan 28, 2013 at 10:22:23AM +0000, Lee Jones wrote:
> On Mon, 28 Jan 2013, Samuel Ortiz wrote:
> 
> > Hi Lee,
> > 
> > On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> > > Allow users to subscribe to and view IRQ events live from debugfs.
> > I seem to remember that I got a similar patch some time ago for the same
> > purpose and my answer was: Please use a UIO driver for this. There already is
> > such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
> > do is adding a platform device for the specific interrupt number. This would
> > avoid the irq handler registration and the sysfs entry creation, both things I
> > believe are not very elegant and open coded. It also gives you an IRQ count
> > implementation.
> > Ideally, the UIO framework could be improved to support IRQ ranges (through
> > IRQ domains) instead of the current single interrupt number.
> > 
> > Have you considered going through that path ?
> 
> I'm going to have to put this patch-set in the bin. Pulling this
> patch, causes lots of conflicts to the remaining patches in the
> set.
I bet removing this one causes a lot of conflicts. I'm not saying it should
absolutely be removed, but I'm afraid once it's upstream no one is going to
look at improving it. And to be honest, having an IRQ handler from debugfs
code looks weird to me. I know you can put all sort of crazyness into a
debugfs entry, but still.

 
> I'll start again from scratch and find another way to sync the ab* MFD
> drivers. I might even have to do it manually i.e. throw out all
> commit history and upstream it as my own patches pulled in from diffs.
I don't have any problems with that.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-28 10:49       ` Samuel Ortiz
@ 2013-01-28 11:34         ` Lee Jones
  2013-02-03 17:01           ` Samuel Ortiz
  0 siblings, 1 reply; 55+ messages in thread
From: Lee Jones @ 2013-01-28 11:34 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

On Mon, 28 Jan 2013, Samuel Ortiz wrote:

> Hi Lee,
> 
> On Mon, Jan 28, 2013 at 10:22:23AM +0000, Lee Jones wrote:
> > On Mon, 28 Jan 2013, Samuel Ortiz wrote:
> > 
> > > Hi Lee,
> > > 
> > > On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> > > > Allow users to subscribe to and view IRQ events live from debugfs.
> > > I seem to remember that I got a similar patch some time ago for the same
> > > purpose and my answer was: Please use a UIO driver for this. There already is
> > > such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
> > > do is adding a platform device for the specific interrupt number. This would
> > > avoid the irq handler registration and the sysfs entry creation, both things I
> > > believe are not very elegant and open coded. It also gives you an IRQ count
> > > implementation.
> > > Ideally, the UIO framework could be improved to support IRQ ranges (through
> > > IRQ domains) instead of the current single interrupt number.
> > > 
> > > Have you considered going through that path ?
> > 
> > I'm going to have to put this patch-set in the bin. Pulling this
> > patch, causes lots of conflicts to the remaining patches in the
> > set.
> I bet removing this one causes a lot of conflicts. I'm not saying it should
> absolutely be removed, but I'm afraid once it's upstream no one is going to
> look at improving it.

This is really not the case. I have every intention of fixing each and
every issue which are brought to my attention during the upstreaming
process of 'drivers/regulators', 'drivers/power' and 'drivers/mfd'.

All I'm doing is making a list of all the fixups and re-writes and
I'll address them on the completion of the push. Hence if you're happy
for this to go in with my promise of improvement, it would certainly
make this task a great deal easier for me.

> And to be honest, having an IRQ handler from debugfs
> code looks weird to me. I know you can put all sort of crazyness into a
> debugfs entry, but still.
>  
> > I'll start again from scratch and find another way to sync the ab* MFD
> > drivers. I might even have to do it manually i.e. throw out all
> > commit history and upstream it as my own patches pulled in from diffs.
> I don't have any problems with that.

I'm sure you don't, but it's me that's doing all the hard work. ;)

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-01-28 11:34         ` Lee Jones
@ 2013-02-03 17:01           ` Samuel Ortiz
  2013-02-04  9:27             ` Lee Jones
  0 siblings, 1 reply; 55+ messages in thread
From: Samuel Ortiz @ 2013-02-03 17:01 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

Hi Lee,

On Mon, Jan 28, 2013 at 11:34:43AM +0000, Lee Jones wrote:
> On Mon, 28 Jan 2013, Samuel Ortiz wrote:
> 
> > Hi Lee,
> > 
> > On Mon, Jan 28, 2013 at 10:22:23AM +0000, Lee Jones wrote:
> > > On Mon, 28 Jan 2013, Samuel Ortiz wrote:
> > > 
> > > > Hi Lee,
> > > > 
> > > > On Tue, Jan 15, 2013 at 12:55:49PM +0000, Lee Jones wrote:
> > > > > Allow users to subscribe to and view IRQ events live from debugfs.
> > > > I seem to remember that I got a similar patch some time ago for the same
> > > > purpose and my answer was: Please use a UIO driver for this. There already is
> > > > such driver, it's uio_pdrv_genirq. What your debugfs registration entry could
> > > > do is adding a platform device for the specific interrupt number. This would
> > > > avoid the irq handler registration and the sysfs entry creation, both things I
> > > > believe are not very elegant and open coded. It also gives you an IRQ count
> > > > implementation.
> > > > Ideally, the UIO framework could be improved to support IRQ ranges (through
> > > > IRQ domains) instead of the current single interrupt number.
> > > > 
> > > > Have you considered going through that path ?
> > > 
> > > I'm going to have to put this patch-set in the bin. Pulling this
> > > patch, causes lots of conflicts to the remaining patches in the
> > > set.
> > I bet removing this one causes a lot of conflicts. I'm not saying it should
> > absolutely be removed, but I'm afraid once it's upstream no one is going to
> > look at improving it.
> 
> This is really not the case. 
I trust you here, but usually people get busy with other stuff after their
patchset is upstreamed and never get back to me on the initial issues.

> I have every intention of fixing each and
> every issue which are brought to my attention during the upstreaming
> process of 'drivers/regulators', 'drivers/power' and 'drivers/mfd'.
> 
> All I'm doing is making a list of all the fixups and re-writes and
> I'll address them on the completion of the push. Hence if you're happy
> for this to go in with my promise of improvement, it would certainly
> make this task a great deal easier for me.
I'll take your words here. I'll apply this one once you adressed the other
issues I commented about on this patchset.


> > And to be honest, having an IRQ handler from debugfs
> > code looks weird to me. I know you can put all sort of crazyness into a
> > debugfs entry, but still.
> >  
> > > I'll start again from scratch and find another way to sync the ab* MFD
> > > drivers. I might even have to do it manually i.e. throw out all
> > > commit history and upstream it as my own patches pulled in from diffs.
> > I don't have any problems with that.
> 
> I'm sure you don't, but it's me that's doing all the hard work. ;)
What's wrong with that ? ;)

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers
  2013-01-28  8:38     ` Lee Jones
@ 2013-02-03 17:02       ` Samuel Ortiz
  0 siblings, 0 replies; 55+ messages in thread
From: Samuel Ortiz @ 2013-02-03 17:02 UTC (permalink / raw)
  To: Lee Jones
  Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij, Kennet Wallden

Hi Lee,

On Mon, Jan 28, 2013 at 08:38:16AM +0000, Lee Jones wrote:
> On Mon, 28 Jan 2013, Samuel Ortiz wrote:
> 
> > Hi Lee, Kennet,
> > 
> > On Tue, Jan 15, 2013 at 12:55:46PM +0000, Lee Jones wrote:
> > > From: Kennet Wallden <kennet.wallden@stericsson.com>
> > > 
> > > Add the possibility to pass configuration settings for
> > > SysCl1kReqRfClkBuf to SysClk8ReqRfClkBuf via platform data.
> > > 
> > > Signed-off-by: Lee Jones <lee.jones@linaro.org>
> > > Signed-off-by: Kennet Wallden <kennet.wallden@stericsson.com>
> > > Reviewed-by: Karl-Johan PERNTZ <karl-johan.perntz@stericsson.com>
> > > Reviewed-by: Bengt JONSSON <bengt.g.jonsson@stericsson.com>
> > > ---
> > >  drivers/mfd/ab8500-sysctrl.c              |   25 +++++++++++++++++++++++++
> > >  include/linux/mfd/abx500/ab8500-sysctrl.h |    5 +++++
> > >  include/linux/mfd/abx500/ab8500.h         |    2 ++
> > >  3 files changed, 32 insertions(+)
> > > 
> > > diff --git a/drivers/mfd/ab8500-sysctrl.c b/drivers/mfd/ab8500-sysctrl.c
> > > index cf58f69..19a024e 100644
> > > --- a/drivers/mfd/ab8500-sysctrl.c
> > > +++ b/drivers/mfd/ab8500-sysctrl.c
> > > @@ -113,11 +113,36 @@ int ab8500_sysctrl_write(u16 reg, u8 mask, u8 value)
> > >  static int __devinit ab8500_sysctrl_probe(struct platform_device *pdev)
> > >  {
> > >  	struct ab8500_platform_data *plat;
> > > +	struct ab8500_sysctrl_platform_data *pdata;
> > >  
> > >  	sysctrl_dev = &pdev->dev;
> > >  	plat = dev_get_platdata(pdev->dev.parent);
> > >  	if (plat->pm_power_off)
> > >  		pm_power_off = ab8500_power_off;
> > > +
> > > +	pdata = plat->sysctrl;
> > > +
> > > +	if (pdata) {
> > > +		int ret;
> > > +		int i;
> > > +		int j;
> > Cosmetic 
> > int i, j, ret;
> 
> Hmmm... this is how I'd prefer it too, 
Great, I'm glad we agree :)

> but other maintainers prefer
> one-per-line. It would be better if we could standardise it somewhere
> to prevent unnecessary fixups.
I certainly don't like that coding style and I sincerely believe a vast
majority of the kernel code avoids it as well.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

^ permalink raw reply	[flat|nested] 55+ messages in thread

* Re: [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs
  2013-02-03 17:01           ` Samuel Ortiz
@ 2013-02-04  9:27             ` Lee Jones
  0 siblings, 0 replies; 55+ messages in thread
From: Lee Jones @ 2013-02-04  9:27 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-arm-kernel, linux-kernel, arnd, linus.walleij

> > > > I'm going to have to put this patch-set in the bin. Pulling this
> > > > patch, causes lots of conflicts to the remaining patches in the
> > > > set.
> > > I bet removing this one causes a lot of conflicts. I'm not saying it should
> > > absolutely be removed, but I'm afraid once it's upstream no one is going to
> > > look at improving it.
> > 
> > This is really not the case. 
> I trust you here, but usually people get busy with other stuff after their
> patchset is upstreamed and never get back to me on the initial issues.
> 
> > I have every intention of fixing each and
> > every issue which are brought to my attention during the upstreaming
> > process of 'drivers/regulators', 'drivers/power' and 'drivers/mfd'.
> > 
> > All I'm doing is making a list of all the fixups and re-writes and
> > I'll address them on the completion of the push. Hence if you're happy
> > for this to go in with my promise of improvement, it would certainly
> > make this task a great deal easier for me.
> I'll take your words here. I'll apply this one once you adressed the other
> issues I commented about on this patchset.

Fixups complete, pull-request sent.

> > > And to be honest, having an IRQ handler from debugfs
> > > code looks weird to me. I know you can put all sort of crazyness into a
> > > debugfs entry, but still.
> > >  
> > > > I'll start again from scratch and find another way to sync the ab* MFD
> > > > drivers. I might even have to do it manually i.e. throw out all
> > > > commit history and upstream it as my own patches pulled in from diffs.
> > > I don't have any problems with that.
> > 
> > I'm sure you don't, but it's me that's doing all the hard work. ;)
> What's wrong with that ? ;)

Hmmm... :D

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 55+ messages in thread

end of thread, other threads:[~2013-02-04  9:28 UTC | newest]

Thread overview: 55+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-15 12:55 [PATCH 00/26] AB8500 MFD overhaul Lee Jones
2013-01-15 12:55 ` [PATCH 01/26] mfd: ab8500-sysctrl: Provide a platform specific pm_power_off() call-back Lee Jones
2013-01-15 12:55 ` [PATCH 02/26] mfd: ab8500-sysctrl: If a charger is present, reboot instead Lee Jones
2013-01-27 23:52   ` Samuel Ortiz
2013-01-28  8:44     ` Lee Jones
2013-01-15 12:55 ` [PATCH 03/26] mfd: ab8500-sysctrl: Only reboot into charging mode if battery type is known Lee Jones
2013-01-15 12:55 ` [PATCH 04/26] mfd: ab8500-sysctrl.c: Provide charging as reset reason Lee Jones
2013-01-15 12:55 ` [PATCH 05/26] mfd: ab8500-gpadc: Change to mdelay for greater resolution Lee Jones
2013-01-27 23:52   ` Samuel Ortiz
2013-01-28  8:43     ` Lee Jones
2013-01-15 12:55 ` [PATCH 06/26] mfd: ab8500-sysctrl: Provide configuration for SysClkReqRfClkBuf registers Lee Jones
2013-01-27 23:52   ` Samuel Ortiz
2013-01-28  8:38     ` Lee Jones
2013-02-03 17:02       ` Samuel Ortiz
2013-01-15 12:55 ` [PATCH 07/26] mfd: ab8500-sysctrl: export read/write symbols Lee Jones
2013-01-15 12:55 ` [PATCH 08/26] mfd: abx500-core: Provide an API to dump all ABx500 registers Lee Jones
2013-01-15 12:55 ` [PATCH 09/26] mfd: ab8500-debugfs: Provide a means for a user subscribe to IRQs Lee Jones
2013-01-27 23:52   ` Samuel Ortiz
2013-01-28  8:25     ` Lee Jones
2013-01-28 10:22     ` Lee Jones
2013-01-28 10:49       ` Samuel Ortiz
2013-01-28 11:34         ` Lee Jones
2013-02-03 17:01           ` Samuel Ortiz
2013-02-04  9:27             ` Lee Jones
2013-01-15 12:55 ` [PATCH 10/26] mfd: ab8500-debugfs: Wake-up device on debugfs IRQ Lee Jones
2013-01-27 23:53   ` Samuel Ortiz
2013-01-28  8:49     ` Lee Jones
2013-01-15 12:55 ` [PATCH 11/26] mfd: ab8500-debugfs: Keep count of IRQs in debugfs Lee Jones
2013-01-15 12:55 ` [PATCH 12/26] mfd: ab8500-debugfs: Use NULL to initialise remaining NULL pointer Lee Jones
2013-01-15 13:06   ` Mark Brown
2013-01-15 13:49     ` Lee Jones
2013-01-15 12:55 ` [PATCH 13/26] mfd: ab8500-debugfs: Formated access AB8500 registers from debugfs entry Lee Jones
2013-01-27 23:53   ` Samuel Ortiz
2013-01-28  8:47     ` Lee Jones
2013-01-15 12:55 ` [PATCH 14/26] mfd: ab8500-debugfs: Fix introduced compiler time warnings Lee Jones
2013-01-27 23:53   ` Samuel Ortiz
2013-01-28  8:45     ` Lee Jones
2013-01-15 12:55 ` [PATCH 15/26] mfd: ab8500-debugfs: Export all AB8500 ADCs as debugfs nodes Lee Jones
2013-01-15 12:55 ` [PATCH 16/26] mfd: ab8500-debugfs: Set the USB charging current to 300mA for ABV3 Lee Jones
2013-01-15 12:55 ` [PATCH 17/26] mfd: ab8500-debugfs: add debugfs node to read all registers Lee Jones
2013-01-15 12:55 ` [PATCH 18/26] mfd: ab8500-core: Allow the possibility to dump all AB8500 registers Lee Jones
2013-01-15 12:55 ` [PATCH 19/26] mfd: ab8500-debugfs: Allow number of IRQs to be provided more dynamically Lee Jones
2013-01-15 12:56 ` [PATCH 20/26] mfd ab8500-gpadc: Introduce new AB version detection Lee Jones
2013-01-15 12:56 ` [PATCH 21/26] mfd: ab8500-debugfs: Add interrupt debug Lee Jones
2013-01-15 12:56 ` [PATCH 22/26] mfd: ab8500-gpadc: Add runtime pm support Lee Jones
2013-01-15 12:56 ` [PATCH 23/26] mfd: ab8500-pwm: Enable support for AB8505 PWMLED blink Lee Jones
2013-01-27 23:53   ` Samuel Ortiz
2013-01-28  8:13     ` Lee Jones
2013-01-15 12:56 ` [PATCH 24/26] mfd: ab8500-debugfs: sizeof() mismatch bugfix Lee Jones
2013-01-15 12:56 ` [PATCH 25/26] mfd: ab8500-gpadc: Reduce conversion timeout Lee Jones
2013-01-27 23:53   ` Samuel Ortiz
2013-01-28  8:45     ` Lee Jones
2013-01-15 12:56 ` [PATCH 26/26] mfd: ab8500-gpadc: Use new ab8500_gpadc_get() with name parameter Lee Jones
2013-01-27 23:54   ` Samuel Ortiz
2013-01-28  8:11     ` Lee Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).