Skip to contentSkip to conversation

MFD updates

PATCH In review Mark Brown 2 participants 10 messages Dec 18, 2008

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

cover MFD updates

The following changes since commit d9f27a08919b6ea6e5266b3e32596286766715b2:
Samuel Ortiz (1):
mfd: Fix twl4030-core.c build error

are available in the git repository at:

git://opensource.wolfsonmicro.com/linux-2.6-audioplus for-sameo

Mark Brown (6):
mfd: Pass driver_data onto child devices
mfd: Register WM8400 codec device
mfd: Add WM8352 support
mfd: Handle missing WM8350 platform data
mfd: Support configurable numbers of DCDCs and ISINKs on WM8350
mfd: Add WM8351 support

 drivers/mfd/Kconfig                  |   33 +
 drivers/mfd/mfd-core.c               |    1 +
 drivers/mfd/wm8350-core.c            |  139 ++-
 drivers/mfd/wm8350-i2c.c             |    2 +
 drivers/mfd/wm8350-regmap.c          | 2096 ++++++++++++++++++++++++++++++++++
 drivers/mfd/wm8400-core.c            |   31 +-
 drivers/regulator/wm8350-regulator.c |    7 +
 include/linux/mfd/wm8350/core.h      |    8 +
 include/linux/mfd/wm8350/pmic.h      |    4 +
 9 files changed, 2299 insertions(+), 22 deletions(-)
author
#1 lore raw

PATCH 1/6 mfd: Pass driver_data onto child devices

The MFD cell structure provides a driver_data field but doesn't pass it on to the child devices when instantiating them - do that.

---
 drivers/mfd/mfd-core.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/mfd/mfd-core.c +1 -0
index 6c0d1be..54ddf37 100644
@@ -34,6 +34,7 @@ static int mfd_add_device(struct device *parent, int id,
 		goto fail_device;
 
 	pdev->dev.parent = parent;
+	platform_set_drvdata(pdev, cell->driver_data);
 
 	ret = platform_device_add_data(pdev,
 			cell->platform_data, cell->data_size);
Signature · 1 line
1.5.6.5
author
#2 lore raw

PATCH 2/6 mfd: Register WM8400 codec device

Register a child device for the codec in the WM8400.

Also switch the unregistration of the MFD devices to use the MFD core since the current code is hand rolling the same thing.

---
 drivers/mfd/Kconfig       |    1 +
 drivers/mfd/wm8400-core.c |   31 +++++++++++++++++++++++++------
 2 files changed, 26 insertions(+), 6 deletions(-)
drivers/mfd/Kconfig +1 -0
index 8cd3dd9..ddfb12b 100644
@@ -116,6 +116,7 @@ config PMIC_DA903X
 
 config MFD_WM8400
 	tristate "Support Wolfson Microelectronics WM8400"
+	select MFD_CORE
 	depends on I2C
 	help
 	  Support for the Wolfson Microelecronics WM8400 PMIC and audio
drivers/mfd/wm8400-core.c +25 -6
index 6a0cedb..cf30d06 100644
@@ -15,6 +15,7 @@
 #include <linux/bug.h>
 #include <linux/i2c.h>
 #include <linux/kernel.h>
+#include <linux/mfd/core.h>
 #include <linux/mfd/wm8400-private.h>
 #include <linux/mfd/wm8400-audio.h>
 
@@ -239,6 +240,16 @@ void wm8400_reset_codec_reg_cache(struct wm8400 *wm8400)
 }
 EXPORT_SYMBOL_GPL(wm8400_reset_codec_reg_cache);
 
+static int wm8400_register_codec(struct wm8400 *wm8400)
+{
+	struct mfd_cell cell = {
+		.name = "wm8400-codec",
+		.driver_data = wm8400,
+	};
+
+	return mfd_add_devices(wm8400->dev, -1, &cell, 1, NULL, 0);
+}
+
 /*
  * wm8400_init - Generic initialisation
  *
@@ -296,24 +307,32 @@ static int wm8400_init(struct wm8400 *wm8400,
 	reg = (reg & WM8400_CHIP_REV_MASK) >> WM8400_CHIP_REV_SHIFT;
 	dev_info(wm8400->dev, "WM8400 revision %x\n", reg);
 
+	ret = wm8400_register_codec(wm8400);
+	if (ret != 0) {
+		dev_err(wm8400->dev, "Failed to register codec\n");
+		goto err_children;
+	}
+
 	if (pdata && pdata->platform_init) {
 		ret = pdata->platform_init(wm8400->dev);
-		if (ret != 0)
+		if (ret != 0) {
 			dev_err(wm8400->dev, "Platform init failed: %d\n",
 				ret);
+			goto err_children;
+		}
 	} else
 		dev_warn(wm8400->dev, "No platform initialisation supplied\n");
 
+	return 0;
+
+err_children:
+	mfd_remove_devices(wm8400->dev);
 	return ret;
 }
 
 static void wm8400_release(struct wm8400 *wm8400)
 {
-	int i;
-
-	for (i = 0; i < ARRAY_SIZE(wm8400->regulators); i++)
-		if (wm8400->regulators[i].name)
-			platform_device_unregister(&wm8400->regulators[i]);
+	mfd_remove_devices(wm8400->dev);
 }
 
 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
Signature · 1 line
1.5.6.5
author
#3 lore raw

PATCH 3/6 mfd: Add WM8352 support

The WM8352 is a variant of the WM8350. Aside from the register defaults there are no software visible differences to the WM8350.

---
 drivers/mfd/Kconfig             |   16 +
 drivers/mfd/wm8350-core.c       |   86 +++-
 drivers/mfd/wm8350-i2c.c        |    1 +
 drivers/mfd/wm8350-regmap.c     | 1052 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/wm8350/core.h |    4 +
 5 files changed, 1143 insertions(+), 16 deletions(-)
drivers/mfd/Kconfig +16 -0
index ddfb12b..76a482d 100644
@@ -143,6 +143,22 @@ config MFD_WM8350_CONFIG_MODE_3
 	bool
 	depends on MFD_WM8350
 
+config MFD_WM8352_CONFIG_MODE_0
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8352_CONFIG_MODE_1
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8352_CONFIG_MODE_2
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8352_CONFIG_MODE_3
+	bool
+	depends on MFD_WM8350
+
 config MFD_WM8350_I2C
 	tristate "Support Wolfson Microelectronics WM8350 with I2C"
 	select MFD_WM8350
drivers/mfd/wm8350-core.c +70 -16

118 lines not on this page · raw message

drivers/mfd/wm8350-i2c.c +1 -0
index 876e693..8780512 100644
@@ -97,6 +97,7 @@ static int wm8350_i2c_remove(struct i2c_client *i2c)
 
 static const struct i2c_device_id wm8350_i2c_id[] = {
        { "wm8350", 0 },
+       { "wm8352", 0 },
        { }
 };
 MODULE_DEVICE_TABLE(i2c, wm8350_i2c_id);
drivers/mfd/wm8350-regmap.c +1052 -0

1,058 lines not on this page · raw message

include/linux/mfd/wm8350/core.h +4 -0
index afeff6f..7375790 100644
@@ -589,6 +589,10 @@ extern const u16 wm8350_mode0_defaults[];
 extern const u16 wm8350_mode1_defaults[];
 extern const u16 wm8350_mode2_defaults[];
 extern const u16 wm8350_mode3_defaults[];
+extern const u16 wm8352_mode0_defaults[];
+extern const u16 wm8352_mode1_defaults[];
+extern const u16 wm8352_mode2_defaults[];
+extern const u16 wm8352_mode3_defaults[];
 
 struct wm8350;
 
Signature · 1 line
1.5.6.5
author
#4 lore raw

PATCH 4/6 mfd: Handle missing WM8350 platform data

---
 drivers/mfd/wm8350-core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/wm8350-core.c +1 -1
index fa505ac..03af3b1 100644
@@ -1350,7 +1350,7 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 		return ret;
 	}
 
-	if (pdata->init) {
+	if (pdata && pdata->init) {
 		ret = pdata->init(wm8350);
 		if (ret != 0) {
 			dev_err(wm8350->dev, "Platform init() failed: %d\n",
Signature · 1 line
1.5.6.5
author
#5 lore raw

PATCH 5/6 mfd: Support configurable numbers of DCDCs and ISINKs on WM8350

Some WM8350 variants have fewer DCDCs and ISINKs. Identify these at probe and refuse to use the absent DCDCs when running on these chips.

---
 drivers/mfd/wm8350-core.c            |    6 ++++++
 drivers/regulator/wm8350-regulator.c |    7 +++++++
 include/linux/mfd/wm8350/pmic.h      |    4 ++++
 3 files changed, 17 insertions(+), 0 deletions(-)
drivers/mfd/wm8350-core.c +6 -0
index 03af3b1..56c363c 100644
@@ -1301,6 +1301,9 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 
 	switch (mask_rev) {
 	case 0:
+		wm8350->pmic.max_dcdc = WM8350_DCDC_6;
+		wm8350->pmic.max_isink = WM8350_ISINK_B;
+
 		switch (chip_rev) {
 		case WM8350_REV_E:
 			dev_info(wm8350->dev, "WM8350 Rev E\n");
@@ -1325,6 +1328,9 @@ int wm8350_device_init(struct wm8350 *wm8350, int irq,
 		break;
 
 	case 2:
+		wm8350->pmic.max_dcdc = WM8350_DCDC_6;
+		wm8350->pmic.max_isink = WM8350_ISINK_B;
+
 		switch (chip_rev) {
 		case 0:
 			dev_info(wm8350->dev, "WM8352 Rev A\n");
drivers/regulator/wm8350-regulator.c +7 -0
index 1f44b17..c68c496 100644
@@ -1380,6 +1380,13 @@ int wm8350_register_regulator(struct wm8350 *wm8350, int reg,
 	if (wm8350->pmic.pdev[reg])
 		return -EBUSY;
 
+	if (reg >= WM8350_DCDC_1 && reg <= WM8350_DCDC_6 &&
+	    reg > wm8350->pmic.max_dcdc)
+		return -ENODEV;
+	if (reg >= WM8350_ISINK_A && reg <= WM8350_ISINK_B &&
+	    reg > wm8350->pmic.max_isink)
+		return -ENODEV;
+
 	pdev = platform_device_alloc("wm8350-regulator", reg);
 	if (!pdev)
 		return -ENOMEM;
include/linux/mfd/wm8350/pmic.h +4 -0
index 69b69e0..96acbfc 100644
@@ -701,6 +701,10 @@ struct platform_device;
 struct regulator_init_data;
 
 struct wm8350_pmic {
+	/* Number of regulators of each type on this device */
+	int max_dcdc;
+	int max_isink;
+
 	/* ISINK to DCDC mapping */
 	int isink_A_dcdc;
 	int isink_B_dcdc;
Signature · 1 line
1.5.6.5
author
#6 lore raw

PATCH 6/6 mfd: Add WM8351 support

The WM8351 is a WM8350 variant. As well as register default changes the WM8351 has fewer voltage and current regulators than the WM8350.

---
 drivers/mfd/Kconfig             |   16 +
 drivers/mfd/wm8350-core.c       |   47 ++
 drivers/mfd/wm8350-i2c.c        |    1 +
 drivers/mfd/wm8350-regmap.c     | 1044 +++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/wm8350/core.h |    4 +
 5 files changed, 1112 insertions(+), 0 deletions(-)
drivers/mfd/Kconfig +16 -0
index 76a482d..781a279 100644
@@ -143,6 +143,22 @@ config MFD_WM8350_CONFIG_MODE_3
 	bool
 	depends on MFD_WM8350
 
+config MFD_WM8351_CONFIG_MODE_0
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8351_CONFIG_MODE_1
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8351_CONFIG_MODE_2
+	bool
+	depends on MFD_WM8350
+
+config MFD_WM8351_CONFIG_MODE_3
+	bool
+	depends on MFD_WM8350
+
 config MFD_WM8352_CONFIG_MODE_0
 	bool
 	depends on MFD_WM8350
drivers/mfd/wm8350-core.c +47 -0

59 lines not on this page · raw message

drivers/mfd/wm8350-i2c.c +1 -0
index 8780512..8d8c932 100644
@@ -97,6 +97,7 @@ static int wm8350_i2c_remove(struct i2c_client *i2c)
 
 static const struct i2c_device_id wm8350_i2c_id[] = {
        { "wm8350", 0 },
+       { "wm8351", 0 },
        { "wm8352", 0 },
        { }
 };
drivers/mfd/wm8350-regmap.c +1044 -0

1,050 lines not on this page · raw message

include/linux/mfd/wm8350/core.h +4 -0
index 7375790..980669d 100644
@@ -589,6 +589,10 @@ extern const u16 wm8350_mode0_defaults[];
 extern const u16 wm8350_mode1_defaults[];
 extern const u16 wm8350_mode2_defaults[];
 extern const u16 wm8350_mode3_defaults[];
+extern const u16 wm8351_mode0_defaults[];
+extern const u16 wm8351_mode1_defaults[];
+extern const u16 wm8351_mode2_defaults[];
+extern const u16 wm8351_mode3_defaults[];
 extern const u16 wm8352_mode0_defaults[];
 extern const u16 wm8352_mode1_defaults[];
 extern const u16 wm8352_mode2_defaults[];
Signature · 1 line
1.5.6.5
#7 lore raw
In reply to Mark Brown

Hi Mark,

Quoted 11 lines · Mark Brown

The following changes since commit d9f27a08919b6ea6e5266b3e32596286766715b2:
Samuel Ortiz (1):
mfd: Fix twl4030-core.c build error

are available in the git repository at:

git://opensource.wolfsonmicro.com/linux-2.6-audioplus for-sameo

Mark Brown (6):
mfd: Pass driver_data onto child devices
mfd: Register WM8400 codec device

I just applied those 2 from your last mail.
I'll look at the remaining ones later today.

Thanks for the patches.

Cheers,
Samuel.

Quoted 15 lines

mfd: Add WM8352 support
mfd: Handle missing WM8350 platform data
mfd: Support configurable numbers of DCDCs and ISINKs on WM8350
mfd: Add WM8351 support

 drivers/mfd/Kconfig                  |   33 +
 drivers/mfd/mfd-core.c               |    1 +
 drivers/mfd/wm8350-core.c            |  139 ++-
 drivers/mfd/wm8350-i2c.c             |    2 +
 drivers/mfd/wm8350-regmap.c          | 2096 ++++++++++++++++++++++++++++++++++
 drivers/mfd/wm8400-core.c            |   31 +-
 drivers/regulator/wm8350-regulator.c |    7 +
 include/linux/mfd/wm8350/core.h      |    8 +
 include/linux/mfd/wm8350/pmic.h      |    4 +
 9 files changed, 2299 insertions(+), 22 deletions(-)
Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#8 lore raw
Quoted 2 lines · Samuel Ortiz

I just applied those 2 from your last mail.
I'll look at the remaining ones later today.

Thanks - I rebased my for-sameo branch against your current for-next branch in case that's useful.

#9 lore raw
Quoted 7 lines · Mark Brown
Quoted 2 lines · Samuel Ortiz

I just applied those 2 from your last mail.
I'll look at the remaining ones later today.

Thanks - I rebased my for-sameo branch against your current for-next branch in case that's useful.

Thanks, all 6 patches (plus the missing break one) applied now.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/