From: Jonathan Cameron <[email protected]>
Add support for changing the mode of the da9030 usb charge pump
Signed-off-by: Jonathan Cameron <[email protected]>
--
This simple driver is intended to allow board configs to control
the mode in which the usb charge pump on th da9030 pmic is
running (typically as part of usb enable callbacks).
The 3 options are:
auto - controlled entirely by hardware signals.
100mA charge pump manual enable
10mA current source manual enable
Note this function is completely separate from the usb charging
functionality (which will need a much more sophisticated driver).
As ever, all comments welcomed.
The main question on this is whether it should just be rolled into
the core mfd driver. I'm inclined to keep it separate and decidedly
optional as the fact it isn't already in the driver implies that
it may not be commonly used. (Intel Stargate 2 does need this
functionality though, hence the submission as I'm hoping to get
the relevant board code in soonish.)
I don't have the da9034 data sheet, so not a clue if this is
relevant for that as well?
Signed-off-by: Jonathan Cameron <[email protected]>
drivers/mfd/Kconfig | 7 +++
drivers/mfd/Makefile | 3 +-
drivers/mfd/da9030-usb.c | 79 ++++++++++++++++++++++++++++++++++++++
include/linux/mfd/da9030-usbcp.h | 20 ++++++++++
4 files changed, 108 insertions(+), 1 deletions(-)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2572773..d53e82d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -114,6 +114,13 @@ config PMIC_DA903X
individual components like LCD backlight, voltage regulators,
LEDs and battery-charger under the corresponding menus.
+config PMIC_DA9030_USBCP
+ bool "DA9030 USB charge pump mode control"
+ depends on PMIC_DA903X
+ help
+ Say yes here to support control of the USB charge pump on
+ the DA9030 PMIC.
+
config MFD_WM8400
tristate "Support Wolfson Microelectronics WM8400"
depends on I2C
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 9a5ad8a..eeb86c9 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -31,4 +31,5 @@ obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o
endif
obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
-obj-$(CONFIG_PMIC_DA903X) += da903x.o
\ No newline at end of file
+obj-$(CONFIG_PMIC_DA903X) += da903x.o
+obj-$(CONFIG_PMIC_DA9030_USBCP) += da9030-usb.o
\ No newline at end of file
diff --git a/drivers/mfd/da9030-usb.c b/drivers/mfd/da9030-usb.c
new file mode 100644
index 0000000..f1160c6
--- /dev/null
+++ b/drivers/mfd/da9030-usb.c
@@ -0,0 +1,79 @@
+/* mfd/da9030-usb.c
+ *
+ * Minimal control driver for the da9030 usb charge pump.
+ *
+ * Jonathan Cameron <[email protected]> 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/mfd/da903x.h>
+#include <linux/mfd/da9030-usbcp.h>
+
+/* Single device assumption */
+struct device *da9030_mfd;
+
+int da9030_set_usb_charge_pump_mode(int mode)
+{
+ uint8_t val = 0;
+
+ switch (mode) {
+ case DA9030_USBPUMP_AUTO:
+ val = 0;
+ break;
+ case DA9030_USBPUMP_CHARGE_PUMP:
+ val = 0x40;
+ break;
+ case DA9030_USBPUMP_CURRENT_SOURCE:
+ val = 0x80;
+ break;
+ }
+
+ return da903x_write(da9030_mfd, DA9030_USBPUMP_REG, val);
+}
+EXPORT_SYMBOL_GPL(da9030_set_usb_charge_pump_mode);
+
+static int __devinit da9030_usb_probe(struct platform_device *pdev)
+{
+ da9030_mfd = pdev->dev.parent;
+
+ return 0;
+}
+
+static int __devexit da9030_usb_remove(struct platform_device *pdev)
+{
+ da9030_mfd = NULL;
+ return 0;
+}
+
+static struct platform_driver da9030_usb_driver = {
+ .driver = {
+ .name = "da9030-usb",
+ .owner = THIS_MODULE,
+ },
+ .probe = da9030_usb_probe,
+ .remove = __devexit_p(da9030_usb_remove),
+};
+
+static int __init da9030_usb_init(void)
+{
+ return platform_driver_register(&da9030_usb_driver);
+}
+module_init(da9030_usb_init);
+
+static void __exit da9030_usb_exit(void)
+{
+ platform_driver_unregister(&da9030_usb_driver);
+}
+module_exit(da9030_usb_exit);
+
+MODULE_DESCRIPTION("USB charge pump control driver for Dialog DA9030");
+MODULE_AUTHOR("Jonathan Cameron <[email protected]>");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform::da9030-usb");
diff --git a/include/linux/mfd/da9030-usbcp.h b/include/linux/mfd/da9030-usbcp.h
new file mode 100644
index 0000000..62af5a7
--- /dev/null
+++ b/include/linux/mfd/da9030-usbcp.h
@@ -0,0 +1,20 @@
+/* linux/mfd/da9030-usbcp.h
+ *
+ * Minimal control driver for the da9030 usb charge pump.
+ *
+ * Jonathan Cameron <[email protected]> 2008
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#define DA9030_USBPUMP_AUTO 1
+#define DA9030_USBPUMP_CHARGE_PUMP 2
+#define DA9030_USBPUMP_CURRENT_SOURCE 3
+
+#define DA9030_USBPUMP_REG 0x19
+
+int da9030_set_usb_charge_pump_mode(int mode);
+
+
Jonathan Cameron wrote:
> From: Jonathan Cameron <[email protected]>
>
> Add support for changing the mode of the da9030 usb charge pump
>
> Signed-off-by: Jonathan Cameron <[email protected]>
>
> --
> This simple driver is intended to allow board configs to control
> the mode in which the usb charge pump on th da9030 pmic is
> running (typically as part of usb enable callbacks).
>
> The 3 options are:
>
> auto - controlled entirely by hardware signals.
> 100mA charge pump manual enable
> 10mA current source manual enable
>
> Note this function is completely separate from the usb charging
> functionality (which will need a much more sophisticated driver).
>
> As ever, all comments welcomed.
>
> The main question on this is whether it should just be rolled into
> the core mfd driver. I'm inclined to keep it separate and decidedly
> optional as the fact it isn't already in the driver implies that
> it may not be commonly used. (Intel Stargate 2 does need this
> functionality though, hence the submission as I'm hoping to get
> the relevant board code in soonish.)
I'm for adding "da9030_set_usb_charge_pump_mode" to the core mfd driver.
> I don't have the da9034 data sheet, so not a clue if this is
> relevant for that as well?
>
> Signed-off-by: Jonathan Cameron <[email protected]>
> drivers/mfd/Kconfig | 7 +++
> drivers/mfd/Makefile | 3 +-
> drivers/mfd/da9030-usb.c | 79 ++++++++++++++++++++++++++++++++++++++
> include/linux/mfd/da9030-usbcp.h | 20 ++++++++++
> 4 files changed, 108 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 2572773..d53e82d 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -114,6 +114,13 @@ config PMIC_DA903X
> individual components like LCD backlight, voltage regulators,
> LEDs and battery-charger under the corresponding menus.
>
> +config PMIC_DA9030_USBCP
> + bool "DA9030 USB charge pump mode control"
> + depends on PMIC_DA903X
> + help
> + Say yes here to support control of the USB charge pump on
> + the DA9030 PMIC.
> +
> config MFD_WM8400
> tristate "Support Wolfson Microelectronics WM8400"
> depends on I2C
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 9a5ad8a..eeb86c9 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -31,4 +31,5 @@ obj-$(CONFIG_MCP_UCB1200) += ucb1x00-assabet.o
> endif
> obj-$(CONFIG_UCB1400_CORE) += ucb1400_core.o
>
> -obj-$(CONFIG_PMIC_DA903X) += da903x.o
> \ No newline at end of file
> +obj-$(CONFIG_PMIC_DA903X) += da903x.o
> +obj-$(CONFIG_PMIC_DA9030_USBCP) += da9030-usb.o
> \ No newline at end of file
> diff --git a/drivers/mfd/da9030-usb.c b/drivers/mfd/da9030-usb.c
> new file mode 100644
> index 0000000..f1160c6
> --- /dev/null
> +++ b/drivers/mfd/da9030-usb.c
> @@ -0,0 +1,79 @@
> +/* mfd/da9030-usb.c
> + *
> + * Minimal control driver for the da9030 usb charge pump.
> + *
> + * Jonathan Cameron <[email protected]> 2008
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/kernel.h>
> +#include <linux/module.h>
> +#include <linux/interrupt.h>
> +#include <linux/platform_device.h>
> +#include <linux/mfd/da903x.h>
> +#include <linux/mfd/da9030-usbcp.h>
> +
> +/* Single device assumption */
> +struct device *da9030_mfd;
> +
> +int da9030_set_usb_charge_pump_mode(int mode)
> +{
> + uint8_t val = 0;
> +
> + switch (mode) {
> + case DA9030_USBPUMP_AUTO:
> + val = 0;
> + break;
> + case DA9030_USBPUMP_CHARGE_PUMP:
> + val = 0x40;
> + break;
> + case DA9030_USBPUMP_CURRENT_SOURCE:
> + val = 0x80;
> + break;
> + }
> +
> + return da903x_write(da9030_mfd, DA9030_USBPUMP_REG, val);
> +}
> +EXPORT_SYMBOL_GPL(da9030_set_usb_charge_pump_mode);
> +
> +static int __devinit da9030_usb_probe(struct platform_device *pdev)
> +{
> + da9030_mfd = pdev->dev.parent;
> +
> + return 0;
> +}
> +
> +static int __devexit da9030_usb_remove(struct platform_device *pdev)
> +{
> + da9030_mfd = NULL;
> + return 0;
> +}
> +
> +static struct platform_driver da9030_usb_driver = {
> + .driver = {
> + .name = "da9030-usb",
> + .owner = THIS_MODULE,
> + },
> + .probe = da9030_usb_probe,
> + .remove = __devexit_p(da9030_usb_remove),
> +};
> +
> +static int __init da9030_usb_init(void)
> +{
> + return platform_driver_register(&da9030_usb_driver);
> +}
> +module_init(da9030_usb_init);
> +
> +static void __exit da9030_usb_exit(void)
> +{
> + platform_driver_unregister(&da9030_usb_driver);
> +}
> +module_exit(da9030_usb_exit);
> +
> +MODULE_DESCRIPTION("USB charge pump control driver for Dialog DA9030");
> +MODULE_AUTHOR("Jonathan Cameron <[email protected]>");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform::da9030-usb");
> diff --git a/include/linux/mfd/da9030-usbcp.h b/include/linux/mfd/da9030-usbcp.h
> new file mode 100644
> index 0000000..62af5a7
> --- /dev/null
> +++ b/include/linux/mfd/da9030-usbcp.h
> @@ -0,0 +1,20 @@
> +/* linux/mfd/da9030-usbcp.h
> + *
> + * Minimal control driver for the da9030 usb charge pump.
> + *
> + * Jonathan Cameron <[email protected]> 2008
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#define DA9030_USBPUMP_AUTO 1
> +#define DA9030_USBPUMP_CHARGE_PUMP 2
> +#define DA9030_USBPUMP_CURRENT_SOURCE 3
> +
> +#define DA9030_USBPUMP_REG 0x19
> +
> +int da9030_set_usb_charge_pump_mode(int mode);
> +
> +
>
--
Sincerely yours,
Mike.
On Mon, Dec 15, 2008 at 11:01:47AM +0200, Mike Rapoport wrote:
> Jonathan Cameron wrote:
> > The main question on this is whether it should just be rolled into
> > the core mfd driver. I'm inclined to keep it separate and decidedly
> > optional as the fact it isn't already in the driver implies that
> > it may not be commonly used. (Intel Stargate 2 does need this
> > functionality though, hence the submission as I'm hoping to get
> > the relevant board code in soonish.)
> I'm for adding "da9030_set_usb_charge_pump_mode" to the core mfd driver.
Me too - if there are concerns about kernel size a config option could
be added to allow users to select it. Unless we get an abstraction for
these USB power sources (which might be useful) a separate driver
doesn't seem to buy much.
Mark Brown wrote:
> On Mon, Dec 15, 2008 at 11:01:47AM +0200, Mike Rapoport wrote:
>> Jonathan Cameron wrote:
>
>>> The main question on this is whether it should just be rolled into
>>> the core mfd driver. I'm inclined to keep it separate and decidedly
>>> optional as the fact it isn't already in the driver implies that
>>> it may not be commonly used. (Intel Stargate 2 does need this
>>> functionality though, hence the submission as I'm hoping to get
>>> the relevant board code in soonish.)
>
>> I'm for adding "da9030_set_usb_charge_pump_mode" to the core mfd driver.
>
> Me too - if there are concerns about kernel size a config option could
> be added to allow users to select it. Unless we get an abstraction for
> these USB power sources (which might be useful) a separate driver
> doesn't seem to buy much.
>
Fair enough, I'll admit I thought there would be rather more to it when I
started writing that!
New patch to follow shortly.
Jonathan
From: Jonathan Cameron <[email protected]>
Add support for changing the mode of the da9030 usb charge pump
Signed-off-by: Jonathan Cameron <[email protected]>
--
This version simply adds the functionality to the da903x mfd driver
core. If anyone can suggest a way round simply maintaining a
global pointer to the device it would be good.
To be able to call this from a board config file the driver must be
built in rather than a module but enforcing that is down to the
board Kconfig entry.
diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
index 0b5bd85..600e884 100644
--- a/drivers/mfd/da903x.c
+++ b/drivers/mfd/da903x.c
@@ -472,6 +472,32 @@ failed:
return ret;
}
+/* Single device assumption */
+struct device *da9030_mfd_dev;
+
+int da9030_set_usb_charge_pump_mode(int mode)
+{
+ uint8_t val = 0;
+
+ if (da9030_mfd_dev == NULL)
+ return -EINVAL;
+
+ switch (mode) {
+ case DA9030_USBPUMP_AUTO:
+ val = 0;
+ break;
+ case DA9030_USBPUMP_CHARGE_PUMP:
+ val = 0x40;
+ break;
+ case DA9030_USBPUMP_CURRENT_SOURCE:
+ val = 0x80;
+ break;
+ }
+
+ return da903x_write(da9030_mfd_dev, DA9030_USBPUMP_REG, val);
+}
+EXPORT_SYMBOL_GPL(da9030_set_usb_charge_pump_mode);
+
static int __devinit da903x_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -487,6 +513,7 @@ static int __devinit da903x_probe(struct i2c_client *client,
chip->client = client;
chip->dev = &client->dev;
chip->ops = &da903x_ops[id->driver_data];
+ da9030_mfd_dev = &client->dev;
mutex_init(&chip->lock);
INIT_WORK(&chip->irq_work, da903x_irq_work);
@@ -547,6 +574,7 @@ static struct i2c_driver da903x_driver = {
static int __init da903x_init(void)
{
+ da9030_mfd_dev = NULL;
return i2c_add_driver(&da903x_driver);
}
module_init(da903x_init);
diff --git a/include/linux/mfd/da903x.h b/include/linux/mfd/da903x.h
index cad314c..0f12331 100644
--- a/include/linux/mfd/da903x.h
+++ b/include/linux/mfd/da903x.h
@@ -189,6 +190,13 @@ extern int da903x_unregister_notifier(struct device *dev,
extern int da903x_query_status(struct device *dev, unsigned int status);
+#define DA9030_USBPUMP_AUTO 1
+#define DA9030_USBPUMP_CHARGE_PUMP 2
+#define DA9030_USBPUMP_CURRENT_SOURCE 3
+
+#define DA9030_USBPUMP_REG 0x19
+
+int da9030_set_usb_charge_pump_mode(int mode);
/* NOTE: the two functions below are not intended for use outside
* of the DA9034 sub-device drivers
Dear All,
Anyone had a chance to have a look at this?
I have a board config waiting on this or something with the same
functionality getting merged.
Thanks,
Jonathan
> From: Jonathan Cameron <[email protected]>
>
> Add support for changing the mode of the da9030 usb charge pump
>
> Signed-off-by: Jonathan Cameron <[email protected]>
>
> --
>
> This version simply adds the functionality to the da903x mfd driver
> core. If anyone can suggest a way round simply maintaining a
> global pointer to the device it would be good.
>
> To be able to call this from a board config file the driver must be
> built in rather than a module but enforcing that is down to the
> board Kconfig entry.
>
> diff --git a/drivers/mfd/da903x.c b/drivers/mfd/da903x.c
> index 0b5bd85..600e884 100644
> --- a/drivers/mfd/da903x.c
> +++ b/drivers/mfd/da903x.c
> @@ -472,6 +472,32 @@ failed:
> return ret;
> }
>
> +/* Single device assumption */
> +struct device *da9030_mfd_dev;
> +
> +int da9030_set_usb_charge_pump_mode(int mode)
> +{
> + uint8_t val = 0;
> +
> + if (da9030_mfd_dev == NULL)
> + return -EINVAL;
> +
> + switch (mode) {
> + case DA9030_USBPUMP_AUTO:
> + val = 0;
> + break;
> + case DA9030_USBPUMP_CHARGE_PUMP:
> + val = 0x40;
> + break;
> + case DA9030_USBPUMP_CURRENT_SOURCE:
> + val = 0x80;
> + break;
> + }
> +
> + return da903x_write(da9030_mfd_dev, DA9030_USBPUMP_REG, val);
> +}
> +EXPORT_SYMBOL_GPL(da9030_set_usb_charge_pump_mode);
> +
> static int __devinit da903x_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -487,6 +513,7 @@ static int __devinit da903x_probe(struct i2c_client *client,
> chip->client = client;
> chip->dev = &client->dev;
> chip->ops = &da903x_ops[id->driver_data];
> + da9030_mfd_dev = &client->dev;
>
> mutex_init(&chip->lock);
> INIT_WORK(&chip->irq_work, da903x_irq_work);
> @@ -547,6 +574,7 @@ static struct i2c_driver da903x_driver = {
>
> static int __init da903x_init(void)
> {
> + da9030_mfd_dev = NULL;
> return i2c_add_driver(&da903x_driver);
> }
> module_init(da903x_init);
> diff --git a/include/linux/mfd/da903x.h b/include/linux/mfd/da903x.h
> index cad314c..0f12331 100644
> --- a/include/linux/mfd/da903x.h
> +++ b/include/linux/mfd/da903x.h
> @@ -189,6 +190,13 @@ extern int da903x_unregister_notifier(struct device *dev,
>
> extern int da903x_query_status(struct device *dev, unsigned int status);
>
> +#define DA9030_USBPUMP_AUTO 1
> +#define DA9030_USBPUMP_CHARGE_PUMP 2
> +#define DA9030_USBPUMP_CURRENT_SOURCE 3
> +
> +#define DA9030_USBPUMP_REG 0x19
> +
> +int da9030_set_usb_charge_pump_mode(int mode);
>
> /* NOTE: the two functions below are not intended for use outside
> * of the DA9034 sub-device drivers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
On Wed, Jan 14, 2009 at 05:47:50PM +0000, Jonathan Cameron wrote:
> Anyone had a chance to have a look at this?
> I have a board config waiting on this or something with the same
> functionality getting merged.
You probably want to send it to Eric Maio (who wrote the driver
originally) and Samuel Ortiz (MFD maintainer).