mfd: arizona: Updates for v3.11
cover mfd: arizona: Updates for v3.11
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:
Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git tags/mfd-arizona-v3.10-rc2
for you to fetch changes up to f773fc6dca4619bdf8da767eaba101a83b766059:
mfd: arizona: Change fast_start pdata name to better reflect functionality (2013-05-21 12:41:54 -0500)
----------------------------------------------------------------
mfd: arizona: Updates for v3.10
A bunch of enhancements and fixes for the arizona devices, adding a few new features (the main one being device tree) and improving robustness.
----------------------------------------------------------------
There's going to be some changes following on from this which overlap with ASoC, it might be simplest to merge all this stuff in via ASoC if that's OK?
Charles Keepax (2):
mfd: wm5102: Manually apply register patch
mfd: arizona: Change fast_start pdata name to better reflect functionality
Mark Brown (5):
mfd: arizona: Read the device identification information after boot
mfd: arizona: Add missing cleanup on remove
mfd: arizona: Disable interrupts during suspend
mfd: Add device tree bindings for Arizona class devices
mfd: arizona: Support use of external DCVDD
Documentation/devicetree/bindings/mfd/arizona.txt | 62 ++++++ drivers/mfd/arizona-core.c | 234 ++++++++++++++++++--- drivers/mfd/arizona-i2c.c | 10 +- drivers/mfd/arizona-spi.c | 10 +- drivers/mfd/arizona.h | 12 ++ include/linux/mfd/arizona/core.h | 2 + include/linux/mfd/arizona/pdata.h | 2 +- 7 files changed, 294 insertions(+), 38 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/arizona.txt
PATCH 1/7 mfd: arizona: Read the device identification information after boot
Future devices may not fully report the device identification information until their boot sequence is complete so defer acting on these until that has finished.
--- drivers/mfd/arizona-core.c | 80 +++++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 31 deletions(-)
drivers/mfd/arizona-core.c +49 -31
@@ -536,51 +536,22 @@ int arizona_dev_init(struct arizona *arizona)regcache_cache_only (arizona->regmap, false); +/* Verify that this is a chip we know about */ ret =regmap_read (arizona->regmap,ARIZONA_SOFTWARE_RESET , ®);if (ret !=0 ) {dev_err (dev,"Failed to read ID register: %d\n" , ret); goto err_reset; } - ret =regmap_read (arizona->regmap,ARIZONA_DEVICE_REVISION , - &arizona->rev); -if (ret !=0 ) { -dev_err (dev,"Failed to read revision register: %d\n" , ret); - goto err_reset; - } - arizona->rev &=ARIZONA_DEVICE_REVISION_MASK ; -switch (reg) { -#ifdef CONFIG_MFD_WM5102 case 0x5102 : - type_name ="WM5102" ; -if (arizona->type !=WM5102 ) { -dev_err (arizona->dev,"WM5102 registered as %d\n" , - arizona->type); - arizona->type =WM5102 ; - } - apply_patch = wm5102_patch; - arizona->rev &=0x7 ; -break ; -#endif -#ifdef CONFIG_MFD_WM5110 case 0x5110 : - type_name ="WM5110" ; -if (arizona->type !=WM5110 ) { -dev_err (arizona->dev,"WM5110 registered as %d\n" , - arizona->type); - arizona->type =WM5110 ; - } - apply_patch = wm5110_patch;break ; -#endif default : -dev_err (arizona->dev,"Unknown device ID %x\n" , reg); +dev_err (arizona->dev,"Unknown device ID: %x\n" , reg); goto err_reset; } -dev_info (dev,"%s revision %c\n" , type_name, arizona->rev +'A' ); -/* If we have a /RESET GPIO we'll already be reset */ if (!arizona->pdata.reset) {regcache_mark_dirty (arizona->regmap);
@@ -600,6 +571,7 @@ int arizona_dev_init(struct arizona *arizona) } } +/* Ensure device startup is complete */ switch (arizona->type) {case WM5102 : ret =regmap_read (arizona->regmap,0x19 , &val);
@@ -620,6 +592,52 @@ int arizona_dev_init(struct arizona *arizona)break ; } +/* Read the device ID information & do device specific stuff */ + ret =regmap_read (arizona->regmap,ARIZONA_SOFTWARE_RESET , ®); +if (ret !=0 ) { +dev_err (dev,"Failed to read ID register: %d\n" , ret); + goto err_reset; + } + + ret =regmap_read (arizona->regmap,ARIZONA_DEVICE_REVISION , + &arizona->rev); +if (ret !=0 ) { +dev_err (dev,"Failed to read revision register: %d\n" , ret); + goto err_reset; + } + arizona->rev &=ARIZONA_DEVICE_REVISION_MASK ; + +switch (reg) { +#ifdef CONFIG_MFD_WM5102 +case 0x5102 : + type_name ="WM5102" ; +if (arizona->type !=WM5102 ) { +dev_err (arizona->dev,"WM5102 registered as %d\n" , + arizona->type); + arizona->type =WM5102 ; + } + apply_patch = wm5102_patch; + arizona->rev &=0x7 ; +break ; +#endif +#ifdef CONFIG_MFD_WM5110 +case 0x5110 : + type_name ="WM5110" ; +if (arizona->type !=WM5110 ) { +dev_err (arizona->dev,"WM5110 registered as %d\n" , + arizona->type); + arizona->type =WM5110 ; + } + apply_patch = wm5110_patch; +break ; +#endif +default : +dev_err (arizona->dev,"Unknown device ID %x\n" , reg); + goto err_reset; + } + +dev_info (dev,"%s revision %c\n" , type_name, arizona->rev +'A' ); +if (apply_patch) { ret =apply_patch (arizona);if (ret !=0 ) {
Signature · 1 line
1.7.10.4
PATCH 2/7 mfd: wm5102: Manually apply register patch
From: Charles Keepax <[email protected]>
Future updates will require us to manually apply the register patch for wm5102.
--- drivers/mfd/arizona-core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/mfd/arizona-core.c +12 -0
@@ -368,6 +368,18 @@ static int arizona_runtime_resume(struct device *dev)break ; } +switch (arizona->type) { +case WM5102 : + ret =wm5102_patch (arizona); +if (ret !=0 ) { +dev_err (arizona->dev,"Failed to apply patch: %d\n" , + ret); + goto err; + } +default : +break ; + } + ret =regcache_sync (arizona->regmap);if (ret !=0 ) {dev_err (arizona->dev,"Failed to restore register cache\n" );
Signature · 1 line
1.7.10.4
PATCH 3/7 mfd: arizona: Add missing cleanup on remove
In reply to Mark BrownWe'd forgotten to disable /RESET or the regulators. Practically speaking this code is unlikely to ever be run.
--- drivers/mfd/arizona-core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/mfd/arizona-core.c +5 -0
@@ -839,6 +839,11 @@ int arizona_dev_exit(struct arizona *arizona)arizona_free_irq (arizona,ARIZONA_IRQ_CLKGEN_ERR , arizona);pm_runtime_disable (arizona->dev);arizona_irq_exit (arizona); +if (arizona->pdata.reset) +gpio_set_value_cansleep (arizona->pdata.reset,0 ); +regulator_disable (arizona->dcvdd); +regulator_bulk_disable (ARRAY_SIZE (arizona->core_supplies), + arizona->core_supplies);return 0 ; }EXPORT_SYMBOL_GPL (arizona_dev_exit);
Signature · 1 line
1.7.10.4
PATCH 4/7 mfd: arizona: Disable interrupts during suspend
In reply to Mark BrownWe aren't able to handle interrupts after the device has suspended since we need to runtime resume it in order to do so but the controller may not be available any more. Handle this in the same way as we handle a similar issue on resume.
--- drivers/mfd/arizona-core.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/mfd/arizona-core.c +22 -1
@@ -409,6 +409,26 @@ static int arizona_runtime_suspend(struct device *dev)#endif #ifdef CONFIG_PM_SLEEP +static int arizona_suspend (struct device *dev) +{ +struct arizona *arizona =dev_get_drvdata (dev); + +dev_dbg (arizona->dev,"Suspend, disabling IRQ\n" ); +disable_irq (arizona->irq); + +return 0 ; +} + +static int arizona_suspend_late (struct device *dev) +{ +struct arizona *arizona =dev_get_drvdata (dev); + +dev_dbg (arizona->dev,"Late suspend, reenabling IRQ\n" ); +enable_irq (arizona->irq); + +return 0 ; +} +static int arizona_resume_noirq (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev);
@@ -434,8 +454,9 @@ const struct dev_pm_ops arizona_pm_ops = {SET_RUNTIME_PM_OPS (arizona_runtime_suspend, arizona_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(NULL, arizona_resume) + SET_SYSTEM_SLEEP_PM_OPS(arizona_suspend, arizona_resume) #ifdef CONFIG_PM_SLEEP + .suspend_late = arizona_suspend_late, .resume_noirq = arizona_resume_noirq,#endif };
Signature · 1 line
1.7.10.4
PATCH 5/7 mfd: Add device tree bindings for Arizona class devices
In reply to Mark Brown--- Documentation/devicetree/bindings/mfd/arizona.txt | 62 ++++++++++++++++++ drivers/mfd/arizona-core.c | 69 +++++++++++++++++++++ drivers/mfd/arizona-i2c.c | 10 ++- drivers/mfd/arizona-spi.c | 10 ++- drivers/mfd/arizona.h | 12 ++++ 5 files changed, 159 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/arizona.txt
Documentation/devicetree/bindings/mfd/arizona.txt new file +62 -0
@@ -0,0 +1,62 @@ +Wolfson Arizona class audio SoCs + +These devices are audio SoCs with extensive digital capabilites and a range +of analogue I/O. + +Required properties: + + - compatible : one of the following chip-specific strings: + "wlf,wm5102" + "wlf,wm5110" + - reg : I2C slave address when connected using I2C, chip select number when + using SPI. + + - interrupts : The interrupt line the /IRQ signal for the device is + connected to. + - interrupt-controller : Arizona class devices contain interrupt controllers + and may provide interrupt services to other devices. + - interrupt-parent : The parent interrupt controller. + - #interrupt-cells: the number of cells to describe an IRQ, this should be 2. + The first cell is the IRQ number. + The second cell is the flags, encoded as the trigger masks from + Documentation/devicetree/bindings/interrupts.txt + + - gpio-controller : Indicates this device is a GPIO controller. + - #gpio-cells : Must be 2. The first cell is the pin number and the + second cell is used to specify optional parameters (currently unused). + + - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, + SPKVDDL-supply, SPKVDDR-supply : power supplies for the device, as covered + in Documentation/devicetree/bindings/regulator/regulator.txt + +Optional properties: + + - wlf,reset : GPIO specifier for the GPIO controlling /RESET + - wlf,ldoena : GPIO specifier for the GPIO controlling LDOENA + + - wlf,gpio-defaults : A list of GPIO configuration register values. If + absent, no configuration of these registers is performed. If any + entry has a value that is out of range for a 16 bit register then + the chip default will be used. If present exactly five values must + be specified. + +Example: + +codec: wm5102@1a { + compatible = "wlf,wm5102"; + reg = <0x1a>; + interrupts = <347>; + #interrupt-cells = <2>; + interrupt-parent = <&gic>; + + gpio-controller; + #gpio-cells = <2>; + + wlf,gpio-defaults = < + 0x00000000, /* AIF1TXLRCLK */ + 0xffffffff, + 0xffffffff, + 0xffffffff, + 0xffffffff, + >; +};
drivers/mfd/arizona-core.c +69 -0
87 lines not on this page · raw message
drivers/mfd/arizona-i2c.c +8 -2
@@ -27,9 +27,14 @@ static int arizona_i2c_probe(struct i2c_client *i2c, {struct arizona *arizona;const struct regmap_config *regmap_config; -int ret; +int ret, type; -switch (id->driver_data) { +if (i2c->dev.of_node) + type =arizona_of_get_type (&i2c->dev); +else + type = id->driver_data; + +switch (type) {#ifdef CONFIG_MFD_WM5102 case WM5102 : regmap_config = &wm5102_i2c_regmap;
@@ -84,6 +89,7 @@ static struct i2c_driver arizona_i2c_driver = { .name = "arizona", .owner = THIS_MODULE, .pm = &arizona_pm_ops, + .of_match_table = of_match_ptr(arizona_of_match), }, .probe = arizona_i2c_probe, .remove = arizona_i2c_remove,
drivers/mfd/arizona-spi.c +8 -2
@@ -27,9 +27,14 @@ static int arizona_spi_probe(struct spi_device *spi)const struct spi_device_id *id =spi_get_device_id (spi);struct arizona *arizona;const struct regmap_config *regmap_config; -int ret; +int ret, type; -switch (id->driver_data) { +if (spi->dev.of_node) + type =arizona_of_get_type (&spi->dev); +else + type = id->driver_data; + +switch (type) {#ifdef CONFIG_MFD_WM5102 case WM5102 : regmap_config = &wm5102_spi_regmap;
@@ -84,6 +89,7 @@ static struct spi_driver arizona_spi_driver = { .name = "arizona", .owner = THIS_MODULE, .pm = &arizona_pm_ops, + .of_match_table = of_match_ptr(arizona_of_match), }, .probe = arizona_spi_probe, .remove = arizona_spi_remove,
drivers/mfd/arizona.h +12 -0
@@ -13,6 +13,7 @@#ifndef _WM5102_H#define _WM5102_H +#include <linux/of.h> #include <linux/regmap.h> #include <linux/pm.h>
@@ -26,6 +27,8 @@ extern const struct regmap_config wm5110_spi_regmap;extern const struct dev_pm_ops arizona_pm_ops; +extern const struct of_device_id arizona_of_match[]; +extern const struct regmap_irq_chip wm5102_aod;extern const struct regmap_irq_chip wm5102_irq;
@@ -37,4 +40,13 @@ int arizona_dev_exit(struct arizona *arizona);int arizona_irq_init (struct arizona *arizona);int arizona_irq_exit (struct arizona *arizona); +#ifdef CONFIG_OF +int arizona_of_get_type (struct device *dev); +#else +static inline int arizona_of_get_type (struct device *dev) +{ +return 0 ; +} +#endif +#endif
Signature · 1 line
1.7.10.4
PATCH 6/7 mfd: arizona: Support use of external DCVDD
In reply to Mark BrownWhen the device is used with an external DCVDD supply instead of the internal LDO1 then an extra step is required when suspending and resuming the device.
--- drivers/mfd/arizona-core.c | 43 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/arizona/core.h | 2 ++ 2 files changed, 45 insertions(+)
drivers/mfd/arizona-core.c +43 -0
@@ -22,6 +22,7 @@#include <linux/pm_runtime.h> #include <linux/regmap.h> #include <linux/regulator/consumer.h> +#include <linux/regulator/machine.h> #include <linux/slab.h> #include <linux/mfd/arizona/core.h>
@@ -347,6 +348,17 @@ static int arizona_runtime_resume(struct device *dev)switch (arizona->type) {case WM5102 : +if (arizona->external_dcvdd) { + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 ,0 ); +if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to connect DCVDD: %d\n" , ret); + goto err; + } + } + ret =wm5102_patch (arizona);if (ret !=0 ) { dev_err(arizona->dev, "Failed to apply patch: %d\n",
@@ -368,6 +380,16 @@ static int arizona_runtime_resume(struct device *dev) goto err; } +if (arizona->external_dcvdd) { + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 ,0 ); +if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to connect DCVDD: %d\n" , ret); + goto err; + } + }break ; }
@@ -400,9 +422,22 @@ err:static int arizona_runtime_suspend (struct device *dev) {struct arizona *arizona =dev_get_drvdata (dev); +int ret;dev_dbg (arizona->dev,"Entering AoD mode\n" ); +if (arizona->external_dcvdd) { + ret =regmap_update_bits (arizona->regmap, +ARIZONA_ISOLATION_CONTROL , +ARIZONA_ISOLATE_DCVDD1 , +ARIZONA_ISOLATE_DCVDD1 ); +if (ret !=0 ) { +dev_err (arizona->dev,"Failed to isolate DCVDD: %d\n" , + ret); +return ret; + } + } +regulator_disable (arizona->dcvdd);regcache_cache_only (arizona->regmap, true);regcache_mark_dirty (arizona->regmap);
@@ -771,6 +806,14 @@ int arizona_dev_init(struct arizona *arizona) arizona->pdata.gpio_defaults[i]); } +/* +* LDO1 can only be used to supply DCVDD so if it has no +* consumers then DCVDD is supplied externally. +*/ +if (arizona->pdata.ldo1 && + arizona->pdata.ldo1->num_consumer_supplies ==0 ) + arizona->external_dcvdd = true; +pm_runtime_set_autosuspend_delay (arizona->dev,100 );pm_runtime_use_autosuspend (arizona->dev);pm_runtime_enable (arizona->dev);
include/linux/mfd/arizona/core.h +2 -0
@@ -95,6 +95,8 @@ struct arizona {struct arizona_pdata pdata; + unsigned int external_dcvdd:1; +int irq;struct irq_domain *virq;struct regmap_irq_chip_data *aod_irq_chip;
Signature · 1 line
1.7.10.4
PATCH 7/7 mfd: arizona: Change fast_start pdata name to better reflect functionality
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
The bit in the register enables MICBIAS fast startup when clear not when set. This patch changes the name of this pdata option to soft_start to better match the functionality. We rename rather than invert the handling to keep the same default functionality, which is fast start active.
--- drivers/mfd/arizona-core.c | 2 +- include/linux/mfd/arizona/pdata.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/arizona-core.c +1 -1
@@ -860,7 +860,7 @@ int arizona_dev_init(struct arizona *arizona)if (arizona->pdata.micbias[i].discharge) val |=ARIZONA_MICB1_DISCH ; -if (arizona->pdata.micbias[i].fast_start) +if (arizona->pdata.micbias[i].soft_start) val |=ARIZONA_MICB1_RATE ;if (arizona->pdata.micbias[i].bypass)
include/linux/mfd/arizona/pdata.h +1 -1
@@ -77,7 +77,7 @@ struct arizona_micbias {int mV;/** Regulated voltage */ unsigned int ext_cap:1; /** External capacitor fitted */ unsigned int discharge:1; /** Actively discharge */ - unsigned int fast_start:1; /** Enable aggressive startup ramp rate */ + unsigned int soft_start:1; /** Disable aggressive startup ramp rate */ unsigned int bypass:1; /** Use bypass mode */ };
Signature · 1 line
1.7.10.4
Hi Mark,
Quoted 15 lines · Mark Brown
The following changes since commit
f722406faae2d073cc1d01063d1123c35425939e:Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.gittags/mfd-arizona-v3.10-rc2for you to fetch changes up to
f773fc6dca4619bdf8da767eaba101a83b766059:mfd: arizona: Change
fast_startpdata name to better reflect functionality (2013-05-21 12:41:54 -0500)----------------------------------------------------------------
mfd: arizona: Updates for v3.10
Quoted 8 lines
A bunch of enhancements and fixes for the arizona devices, adding a few new features (the main one being device tree) and improving robustness.
----------------------------------------------------------------
There's going to be some changes following on from this which overlap with ASoC, it might be simplest to merge all this stuff in via ASoC if that's OK?
That's fine with me. I pulled it anyway to keep mfd-next in sync with the ASoC tree as far as MFD is concerned, and avoid potential merge conflicts.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/