arizona updates for v3.10
Subsystems (5)
cover arizona updates for v3.10
The following changes since commit 07961ac7c0ee8b546658717034fe692fd12eefa9:
Linux 3.9-rc5 (2013-03-31 15:12:43 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git tags/mfd-arizona-3.10
for you to fetch changes up to b66b1364683c6710e110196b6bf4123675a380bf:
mfd: wm5102: Update defaults to match patch (2013-04-01 18:09:47 +0100)
----------------------------------------------------------------
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixes
----------------------------------------------------------------
Charles Keepax (5):
mfd: wm5102: Manually apply register patch
mfd: arizona: Factor out register polling
mfd: arizona: Add a hardware patch mechanism
mfd: wm5102: Deactivate standard boot sequence
mfd: wm5102: Update defaults to match patch
Mark Brown (10):
mfd: arizona: Disable all wake sources by default
mfd: arizona: Clarify error message for failed primary IRQ request
mfd: arizona: Basic support for edge triggered IRQs
mfd: arizona: Allow GPIO to be specified for IRQ line
mfd: arizona: Try to use interrupt flags from interrupt controller
mfd: arizona: Support configuring MICBIASes into bypass mode
mfd: wm5102: Update patch for latest evaluation
mfd: arizona: Fully support the use of MCLK1 as the 32kHz clock source
mfd: arizona: Unconditionally enable 32kHz clock
mfd: wm5102: Only use the lowest three bits of device revision
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 4 +- drivers/mfd/arizona-core.c | 205 ++++++++++++++++++++++---- drivers/mfd/arizona-irq.c | 106 ++++++++++--- drivers/mfd/wm5102-tables.c | 56 +++++-- include/linux/mfd/arizona/pdata.h | 7 +- 5 files changed, 312 insertions(+), 66 deletions(-)
PATCH 1/15 mfd: arizona: Disable all wake sources by default
--- drivers/mfd/arizona-irq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/arizona-irq.c +3 -0
@@ -192,6 +192,9 @@ int arizona_irq_init(struct arizona *arizona)return -EINVAL ; } +/* Disable all wake sources by default */ +regmap_write (arizona->regmap,ARIZONA_WAKE_CONTROL ,0 ); +if (arizona->pdata.irq_active_high) { ret =regmap_update_bits (arizona->regmap,ARIZONA_IRQ_CTRL_1 ,ARIZONA_IRQ_POL ,0 );
Signature · 1 line
1.7.10.4
PATCH 2/15 mfd: arizona: Clarify error message for failed primary IRQ request
regmap has a very similar looking error, help identify where the error comes from by changing the error message.
--- drivers/mfd/arizona-irq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/arizona-irq.c +1 -1
@@ -264,7 +264,7 @@ int arizona_irq_init(struct arizona *arizona) flags, "arizona", arizona);if (ret !=0 ) { -dev_err (arizona->dev,"Failed to request IRQ %d: %d\n" , +dev_err (arizona->dev,"Failed to request primary IRQ %d: %d\n" , arizona->irq, ret); goto err_main_irq; }
Signature · 1 line
1.7.10.4
PATCH 3/15 mfd: arizona: Basic support for edge triggered IRQs
In reply to Mark BrownAllow the user to configure edge triggered IRQs, though we do not yet fully handle new interrupts occurring while an interrupt is being handled.
--- arch/arm/mach-s3c64xx/mach-crag6410-module.c | 4 ++-- drivers/mfd/arizona-irq.c | 12 +++++++----- include/linux/mfd/arizona/pdata.h | 3 ++- 3 files changed, 11 insertions(+), 8 deletions(-)
arch/arm/mach-s3c64xx/mach-crag6410-module.c +2 -2
@@ -208,7 +208,7 @@ static const struct i2c_board_info wm1277_devs[] = {static struct arizona_pdata wm5102_reva_pdata = { .ldoena =S3C64XX_GPN (7 ), .gpio_base =CODEC_GPIO_BASE , - .irq_active_high = true, + .irq_flags =IRQF_TRIGGER_HIGH , .micd_pol_gpio =CODEC_GPIO_BASE +4 , .gpio_defaults = { [2 ] =0x10000 ,/* AIF3TXLRCLK */
@@ -237,7 +237,7 @@ static struct spi_board_info wm5102_reva_spi_devs[] = {static struct arizona_pdata wm5102_pdata = { .ldoena =S3C64XX_GPN (7 ), .gpio_base =CODEC_GPIO_BASE , - .irq_active_high = true, + .irq_flags =IRQF_TRIGGER_HIGH , .micd_pol_gpio =CODEC_GPIO_BASE +2 , .gpio_defaults = { [2 ] =0x10000 ,/* AIF3TXLRCLK */
drivers/mfd/arizona-irq.c +7 -5
@@ -195,7 +195,11 @@ int arizona_irq_init(struct arizona *arizona)/* Disable all wake sources by default */ regmap_write (arizona->regmap,ARIZONA_WAKE_CONTROL ,0 ); -if (arizona->pdata.irq_active_high) { +if (!arizona->pdata.irq_flags) + arizona->pdata.irq_flags =IRQF_TRIGGER_LOW ; + +if (arizona->pdata.irq_flags & (IRQF_TRIGGER_HIGH | +IRQF_TRIGGER_RISING )) { ret =regmap_update_bits (arizona->regmap,ARIZONA_IRQ_CTRL_1 ,ARIZONA_IRQ_POL ,0 );if (ret !=0 ) {
@@ -203,12 +207,10 @@ int arizona_irq_init(struct arizona *arizona) ret); goto err; } - - flags |=IRQF_TRIGGER_HIGH ; - }else { - flags |=IRQF_TRIGGER_LOW ; } + flags |= arizona->pdata.irq_flags; +/* Allocate a virtual IRQ domain to distribute to the regmap domains */ arizona->virq =irq_domain_add_linear (NULL ,2 , &arizona_domain_ops, arizona);
include/linux/mfd/arizona/pdata.h +2 -1
@@ -99,7 +99,8 @@ struct arizona_pdata {/** If a direct 32kHz clock is provided on an MCLK specify it here */ int clk32k_src; -bool irq_active_high;/** IRQ polarity */ +/** Mode for primary IRQ (defaults to active low) */ +unsigned int irq_flags;/* Base GPIO */ int gpio_base;
Signature · 1 line
1.7.10.4
PATCH 4/15 mfd: arizona: Allow GPIO to be specified for IRQ line
In reply to Mark BrownIf a GPIO is specified for the chip IRQ line then request it. This improves support for systems that do not put pins into input mode when used as interrupts.
Also use this GPIO when the primary IRQ is in edge triggered mode to detect if we have handled pending interrupts in order to improve robustness.
--- drivers/mfd/arizona-irq.c | 66 +++++++++++++++++++++++++++++-------- include/linux/mfd/arizona/pdata.h | 3 ++ 2 files changed, 56 insertions(+), 13 deletions(-)
drivers/mfd/arizona-irq.c +53 -13
@@ -94,6 +94,7 @@ static irqreturn_t arizona_ctrlif_err(int irq, void *data)static irqreturn_t arizona_irq_thread (int irq,void *data) {struct arizona *arizona = data; +bool poll;unsigned int val;int ret;
@@ -103,20 +104,39 @@ static irqreturn_t arizona_irq_thread(int irq, void *data)return IRQ_NONE ; } -/* Always handle the AoD domain */ -handle_nested_irq (irq_find_mapping (arizona->virq,0 )); +do { + poll = false; + +/* Always handle the AoD domain */ +handle_nested_irq (irq_find_mapping (arizona->virq,0 )); + +/* +* Check if one of the main interrupts is asserted and only +* check that domain if it is. +*/ + ret =regmap_read (arizona->regmap,ARIZONA_IRQ_PIN_STATUS , + &val); +if (ret ==0 && val &ARIZONA_IRQ1_STS ) { +handle_nested_irq (irq_find_mapping (arizona->virq,1 )); + }else if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to read main IRQ status: %d\n" , ret); + } -/* -* Check if one of the main interrupts is asserted and only -* check that domain if it is. -*/ - ret =regmap_read (arizona->regmap,ARIZONA_IRQ_PIN_STATUS , &val); -if (ret ==0 && val &ARIZONA_IRQ1_STS ) { -handle_nested_irq (irq_find_mapping (arizona->virq,1 )); - }else if (ret !=0 ) { -dev_err (arizona->dev,"Failed to read main IRQ status: %d\n" , - ret); - } +/* +* Poll the IRQ pin status to see if we're really done +* if the interrupt controller can't do it for us. +*/ +if (!arizona->pdata.irq_gpio) { +break ; + }else if (arizona->pdata.irq_flags &IRQF_TRIGGER_RISING && +gpio_get_value_cansleep (arizona->pdata.irq_gpio)) { + poll = true; + }else if (arizona->pdata.irq_flags &IRQF_TRIGGER_FALLING && + !gpio_get_value_cansleep (arizona->pdata.irq_gpio)) { + poll = true; + } + }while (poll);pm_runtime_mark_last_busy (arizona->dev);pm_runtime_put_autosuspend (arizona->dev);
@@ -262,6 +282,26 @@ int arizona_irq_init(struct arizona *arizona) } } +/* Used to emulate edge trigger and to work around broken pinmux */ +if (arizona->pdata.irq_gpio) { +if (gpio_to_irq (arizona->pdata.irq_gpio) != arizona->irq) { +dev_warn (arizona->dev,"IRQ %d is not GPIO %d (%d)\n" , + arizona->irq, arizona->pdata.irq_gpio, +gpio_to_irq (arizona->pdata.irq_gpio)); + arizona->irq =gpio_to_irq (arizona->pdata.irq_gpio); + } + + ret =devm_gpio_request_one (arizona->dev, + arizona->pdata.irq_gpio, +GPIOF_IN ,"arizona IRQ" ); +if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to request IRQ GPIO %d:: %d\n" , + arizona->pdata.irq_gpio, ret); + arizona->pdata.irq_gpio =0 ; + } + } + ret =request_threaded_irq (arizona->irq,NULL , arizona_irq_thread, flags,"arizona" , arizona);
include/linux/mfd/arizona/pdata.h +3 -0
@@ -163,6 +163,9 @@ struct arizona_pdata {/** Haptic actuator type */ unsigned int hap_act; + +/** GPIO for primary IRQ (used for edge triggered emulation) */ + int irq_gpio; };#endif
Signature · 1 line
1.7.10.4
PATCH 5/15 mfd: arizona: Try to use interrupt flags from interrupt controller
In reply to Mark BrownIf no irq_flags are passed in platform data then query the interrupt controller for the trigger type and try to use that. This provides default operation with a wider range of hardware and will be needed for device tree support where the interrupt flags are configured on the interrupt controller.
--- drivers/mfd/arizona-irq.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
drivers/mfd/arizona-irq.c +25 -2
@@ -189,6 +189,7 @@ int arizona_irq_init(struct arizona *arizona)int ret, i;const struct regmap_irq_chip *aod, *irq;bool ctrlif_error = true; +struct irq_data *irq_data;switch (arizona->type) {#ifdef CONFIG_MFD_WM5102
@@ -215,8 +216,30 @@ int arizona_irq_init(struct arizona *arizona)/* Disable all wake sources by default */ regmap_write (arizona->regmap,ARIZONA_WAKE_CONTROL ,0 ); -if (!arizona->pdata.irq_flags) - arizona->pdata.irq_flags =IRQF_TRIGGER_LOW ; +/* Read the flags from the interrupt controller if not specified */ +if (!arizona->pdata.irq_flags) { + irq_data =irq_get_irq_data (arizona->irq); +if (!irq_data) { +dev_err (arizona->dev,"Invalid IRQ: %d\n" , + arizona->irq); +return -EINVAL ; + } + + arizona->pdata.irq_flags =irqd_get_trigger_type (irq_data); +switch (arizona->pdata.irq_flags) { +case IRQF_TRIGGER_LOW : +case IRQF_TRIGGER_HIGH : +case IRQF_TRIGGER_RISING : +case IRQF_TRIGGER_FALLING : +break ; + +case IRQ_TYPE_NONE : +default : +/* Device default */ + arizona->pdata.irq_flags =IRQF_TRIGGER_LOW ; +break ; + } + }if (arizona->pdata.irq_flags & (IRQF_TRIGGER_HIGH |IRQF_TRIGGER_RISING )) {
Signature · 1 line
1.7.10.4
PATCH 6/15 mfd: arizona: Support configuring MICBIASes into bypass mode
In reply to Mark Brown--- drivers/mfd/arizona-core.c | 12 +++++++++++- include/linux/mfd/arizona/pdata.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/mfd/arizona-core.c +11 -1
@@ -511,10 +511,16 @@ int arizona_dev_init(struct arizona *arizona) }for (i =0 ; i <ARIZONA_MAX_MICBIAS ; i++) { -if (!arizona->pdata.micbias[i].mV) +if (!arizona->pdata.micbias[i].mV && + !arizona->pdata.micbias[i].bypass)continue ; +/* Apply default for bypass mode */ +if (!arizona->pdata.micbias[i].mV) + arizona->pdata.micbias[i].mV =2800 ; + val = (arizona->pdata.micbias[i].mV -1500 ) /100 ; + val <<=ARIZONA_MICB1_LVL_SHIFT ;if (arizona->pdata.micbias[i].ext_cap)
@@ -526,10 +532,14 @@ int arizona_dev_init(struct arizona *arizona)if (arizona->pdata.micbias[i].fast_start) val |=ARIZONA_MICB1_RATE ; +if (arizona->pdata.micbias[i].bypass) + val |=ARIZONA_MICB1_BYPASS ; +regmap_update_bits (arizona->regmap,ARIZONA_MIC_BIAS_CTRL_1 + i,ARIZONA_MICB1_LVL_MASK |ARIZONA_MICB1_DISCH | +ARIZONA_MICB1_BYPASS |ARIZONA_MICB1_RATE , val); }
include/linux/mfd/arizona/pdata.h +1 -0
@@ -78,6 +78,7 @@ struct arizona_micbias { 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 bypass:1; /** Use bypass mode */ };struct arizona_micd_config {
Signature · 1 line
1.7.10.4
PATCH 7/15 mfd: wm5102: Update patch for latest evaluation
In reply to Mark Brown--- drivers/mfd/wm5102-tables.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/mfd/wm5102-tables.c +10 -5
@@ -57,15 +57,20 @@ static const struct reg_default wm5102_reva_patch[] = { };static const struct reg_default wm5102_revb_patch[] = { + {0x19 ,0x0001 }, {0x80 ,0x0003 }, {0x081 ,0xE022 }, - {0x410 ,0x4080 }, - {0x418 ,0x4080 }, - {0x420 ,0x4080 }, - {0x428 ,0xC000 }, + {0x410 ,0x6080 }, + {0x418 ,0xa080 }, + {0x420 ,0xa080 }, + {0x428 ,0xe000 }, + {0x443 ,0xDC1A }, {0x4B0 ,0x0066 }, {0x458 ,0x000b }, {0x212 ,0x0000 }, + {0x171 ,0x0000 }, + {0x35E ,0x000C }, + {0x2D4 ,0x0000 }, {0x80 ,0x0000 }, };
@@ -282,7 +287,7 @@ static const struct reg_default wm5102_reg_default[] = { { 0x00000155, 0x0000 }, /* R341 - Rate Estimator 4 */ { 0x00000156, 0x0000 }, /* R342 - Rate Estimator 5 */ { 0x00000161, 0x0000 }, /* R353 - Dynamic Frequency Scaling 1 */ - { 0x00000171, 0x0002 }, /* R369 - FLL1 Control 1 */ + { 0x00000171, 0x0000 }, /* R369 - FLL1 Control 1 */ { 0x00000172, 0x0008 }, /* R370 - FLL1 Control 2 */ { 0x00000173, 0x0018 }, /* R371 - FLL1 Control 3 */ { 0x00000174, 0x007D }, /* R372 - FLL1 Control 4 */
Signature · 1 line
1.7.10.4
PATCH 8/15 mfd: arizona: Fully support the use of MCLK1 as the 32kHz clock source
In reply to Mark BrownMCLK1 is not in the AoD power domain so if it is used as the 32kHz clock source we need to hold a runtime PM reference to keep the device from going into low power mode.
--- drivers/mfd/arizona-core.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-)
drivers/mfd/arizona-core.c +19 -2
@@ -39,11 +39,21 @@ int arizona_clk32k_enable(struct arizona *arizona) arizona->clk32k_ref++; -if (arizona->clk32k_ref ==1 ) +if (arizona->clk32k_ref ==1 ) { +switch (arizona->pdata.clk32k_src) { +case ARIZONA_32KZ_MCLK1 : + ret =pm_runtime_get_sync (arizona->dev); +if (ret !=0 ) + goto out; +break ; + } + ret =regmap_update_bits (arizona->regmap,ARIZONA_CLOCK_32K_1 ,ARIZONA_CLK_32K_ENA ,ARIZONA_CLK_32K_ENA ); + } +out:if (ret !=0 ) arizona->clk32k_ref--;
@@ -63,10 +73,17 @@ int arizona_clk32k_disable(struct arizona *arizona) arizona->clk32k_ref--; -if (arizona->clk32k_ref ==0 ) +if (arizona->clk32k_ref ==0 ) {regmap_update_bits (arizona->regmap,ARIZONA_CLOCK_32K_1 ,ARIZONA_CLK_32K_ENA ,0 ); +switch (arizona->pdata.clk32k_src) { +case ARIZONA_32KZ_MCLK1 : +pm_runtime_put_sync (arizona->dev); +break ; + } + } +mutex_unlock (&arizona->clk_lock);return ret;
Signature · 1 line
1.7.10.4
PATCH 9/15 mfd: arizona: Unconditionally enable 32kHz clock
In reply to Mark BrownIf we have a directly provided 32kHz clock unconditionally enable it, substantial chip functionality relies on it so dynamic management is not worthwhile.
--- drivers/mfd/arizona-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/arizona-core.c +1 -0
@@ -515,6 +515,7 @@ int arizona_dev_init(struct arizona *arizona)regmap_update_bits (arizona->regmap,ARIZONA_CLOCK_32K_1 ,ARIZONA_CLK_32K_SRC_MASK , arizona->pdata.clk32k_src -1 ); +arizona_clk32k_enable (arizona);break ;case ARIZONA_32KZ_NONE : regmap_update_bits(arizona->regmap, ARIZONA_CLOCK_32K_1,
Signature · 1 line
1.7.10.4
PATCH 10/15 mfd: wm5102: Only use the lowest three bits of device revision
In reply to Mark BrownOnly the lowest three bits contain device revision for WM5102, the high bits have been repurposed.
--- drivers/mfd/arizona-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/arizona-core.c +1 -0
@@ -441,6 +441,7 @@ int arizona_dev_init(struct arizona *arizona) arizona->type = WM5102; } apply_patch = wm5102_patch; + arizona->rev &=0x7 ;break ;#endif #ifdef CONFIG_MFD_WM5110
Signature · 1 line
1.7.10.4
PATCH 11/15 mfd: wm5102: Manually apply register patch
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
Future updates will require us to manually apply the register patch for wm5102.
--- drivers/mfd/arizona-core.c | 10 ++++++++++ drivers/mfd/wm5102-tables.c | 31 +++++++++++++++++++++++++------ 2 files changed, 35 insertions(+), 6 deletions(-)
drivers/mfd/arizona-core.c +10 -0
@@ -256,6 +256,16 @@ static int arizona_runtime_resume(struct device *dev)return ret; } +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; + } + } + ret =regcache_sync (arizona->regmap);if (ret !=0 ) {dev_err (arizona->dev,"Failed to restore register cache\n" );
drivers/mfd/wm5102-tables.c +25 -6
@@ -10,6 +10,7 @@* published by the Free Software Foundation. */ +#include <linux/device.h> #include <linux/module.h> #include <linux/mfd/arizona/core.h>
@@ -77,16 +78,34 @@ static const struct reg_default wm5102_revb_patch[] = {/* We use a function so we can use ARRAY_SIZE() */ int wm5102_patch (struct arizona *arizona) { +const struct reg_default *wm5102_patch; +int ret =0 ; +int i, patch_size; +switch (arizona->rev) {case 0 : -return regmap_register_patch (arizona->regmap, - wm5102_reva_patch, -ARRAY_SIZE (wm5102_reva_patch)); + wm5102_patch = wm5102_reva_patch; + patch_size =ARRAY_SIZE (wm5102_reva_patch);default : -return regmap_register_patch (arizona->regmap, - wm5102_revb_patch, -ARRAY_SIZE (wm5102_revb_patch)); + wm5102_patch = wm5102_revb_patch; + patch_size =ARRAY_SIZE (wm5102_revb_patch); } + +regcache_cache_bypass (arizona->regmap, true); + +for (i =0 ; i < patch_size; i++) { + ret =regmap_write (arizona->regmap, wm5102_patch[i].reg, + wm5102_patch[i].def); +if (ret !=0 ) { +dev_err (arizona->dev,"Failed to write %x = %x: %d\n" , + wm5102_patch[i].reg, wm5102_patch[i].def, ret); + goto out; + } + } + +out: +regcache_cache_bypass (arizona->regmap, false); +return ret; }static const struct regmap_irq wm5102_aod_irqs[ARIZONA_NUM_IRQ ] = {
Signature · 1 line
1.7.10.4
PATCH 12/15 mfd: arizona: Factor out register polling
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
Factor out the polling of the interrupt status register whilst we wait for boot done to allow the polling to be reused in other situations.
--- drivers/mfd/arizona-core.c | 52 +++++++++++++++++++++++++------------------- 1 file changed, 30 insertions(+), 22 deletions(-)
drivers/mfd/arizona-core.c +30 -22
@@ -196,42 +196,50 @@ static irqreturn_t arizona_overclocked(int irq, void *data)return IRQ_HANDLED ; } -static int arizona_wait_for_boot (struct arizona *arizona) +static int arizona_poll_reg (struct arizona *arizona, +int timeout,unsigned int reg, +unsigned int mask,unsigned int target) { -unsigned int reg; +unsigned int val =0 ;int ret, i; -/* -* We can't use an interrupt as we need to runtime resume to do so, -* we won't race with the interrupt handler as it'll be blocked on -* runtime resume. -*/ -for (i =0 ; i <5 ; i++) { -msleep (1 ); - - ret =regmap_read (arizona->regmap, -ARIZONA_INTERRUPT_RAW_STATUS_5 , ®); +for (i =0 ; i < timeout; i++) { + ret =regmap_read (arizona->regmap, reg, &val);if (ret !=0 ) { -dev_err (arizona->dev,"Failed to read boot state: %d\n" , - ret); +dev_err (arizona->dev,"Failed to read reg %u: %d\n" , + reg, ret);continue ; } -if (reg &ARIZONA_BOOT_DONE_STS ) -break ; +if ((val & mask) == target) +return 0 ; + +msleep (1 ); } -if (reg &ARIZONA_BOOT_DONE_STS ) { +dev_err (arizona->dev,"Polling reg %u timed out: %x\n" , reg, val); +return -ETIMEDOUT ; +} + +static int arizona_wait_for_boot (struct arizona *arizona) +{ +int ret; + +/* +* We can't use an interrupt as we need to runtime resume to do so, +* we won't race with the interrupt handler as it'll be blocked on +* runtime resume. +*/ + ret =arizona_poll_reg (arizona,5 ,ARIZONA_INTERRUPT_RAW_STATUS_5 , +ARIZONA_BOOT_DONE_STS ,ARIZONA_BOOT_DONE_STS ); + +if (!ret)regmap_write (arizona->regmap,ARIZONA_INTERRUPT_STATUS_5 ,ARIZONA_BOOT_DONE_STS ); - }else { -dev_err (arizona->dev,"Device boot timed out: %x\n" , reg); -return -ETIMEDOUT ; - }pm_runtime_mark_last_busy (arizona->dev); -return 0 ; +return ret; }#ifdef CONFIG_PM_RUNTIME
Signature · 1 line
1.7.10.4
PATCH 13/15 mfd: arizona: Add a hardware patch mechanism
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
This patch adds facilities for apply a register patch contained within the chip using the write sequencer.
--- drivers/mfd/arizona-core.c | 103 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+)
drivers/mfd/arizona-core.c +103 -0
@@ -242,6 +242,84 @@ static int arizona_wait_for_boot(struct arizona *arizona)return ret; } +static int arizona_apply_hardware_patch (struct arizona * arizona) +{ +unsigned int fll, sysclk; +int ret; + +regcache_cache_bypass (arizona->regmap, true); + +/* Cache existing FLL and SYSCLK settings */ + ret =regmap_read (arizona->regmap,ARIZONA_FLL1_CONTROL_1 , &fll); +if (ret <0 ) { +dev_err (arizona->dev,"Failed to cache FLL settings: %d\n" , + ret); +return ret; + } + ret =regmap_read (arizona->regmap,ARIZONA_SYSTEM_CLOCK_1 , &sysclk); +if (ret <0 ) { +dev_err (arizona->dev,"Failed to cache SYSCLK settings: %d\n" , + ret); +return ret; + } + +/* Start up SYSCLK using the FLL in free running mode */ + ret =regmap_write (arizona->regmap,ARIZONA_FLL1_CONTROL_1 , +ARIZONA_FLL1_ENA |ARIZONA_FLL1_FREERUN ); +if (ret <0 ) { +dev_err (arizona->dev, +"Failed to start FLL in freerunning mode: %d\n" , + ret); +return ret; + } + ret =arizona_poll_reg (arizona,25 ,ARIZONA_INTERRUPT_RAW_STATUS_5 , +ARIZONA_FLL1_CLOCK_OK_STS , +ARIZONA_FLL1_CLOCK_OK_STS ); +if (ret <0 ) { + ret = -ETIMEDOUT ; + goto err_fll; + } + + ret =regmap_write (arizona->regmap,ARIZONA_SYSTEM_CLOCK_1 ,0x0144 ); +if (ret <0 ) { +dev_err (arizona->dev,"Failed to start SYSCLK: %d\n" , ret); + goto err_fll; + } + +/* Start the write sequencer and wait for it to finish */ + ret =regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_0 , +ARIZONA_WSEQ_ENA |ARIZONA_WSEQ_START |160 ); +if (ret <0 ) { +dev_err (arizona->dev,"Failed to start write sequencer: %d\n" , + ret); + goto err_sysclk; + } + ret =arizona_poll_reg (arizona,5 ,ARIZONA_WRITE_SEQUENCER_CTRL_1 , +ARIZONA_WSEQ_BUSY ,0 ); +if (ret <0 ) { +regmap_write (arizona->regmap,ARIZONA_WRITE_SEQUENCER_CTRL_0 , +ARIZONA_WSEQ_ABORT ); + ret = -ETIMEDOUT ; + } + +err_sysclk: + ret =regmap_write (arizona->regmap,ARIZONA_SYSTEM_CLOCK_1 , sysclk); +if (ret <0 ) +dev_err (arizona->dev, +"Failed to re-apply old SYSCLK settings: %d\n" , + ret); + +err_fll: + ret =regmap_write (arizona->regmap,ARIZONA_FLL1_CONTROL_1 , fll); +if (ret <0 ) +dev_err (arizona->dev, +"Failed to re-apply old FLL settings: %d\n" , + ret); + +regcache_cache_bypass (arizona->regmap, false); +return ret; +} +#ifdef CONFIG_PM_RUNTIME static int arizona_runtime_resume (struct device *dev) {
@@ -272,6 +350,17 @@ static int arizona_runtime_resume(struct device *dev) ret); goto err; } + + ret =arizona_apply_hardware_patch (arizona); +if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to apply hardware patch: %d\n" , + ret); + goto err; + } +break ; +default : +break ; } ret =regcache_sync (arizona->regmap);
@@ -510,6 +599,20 @@ int arizona_dev_init(struct arizona *arizona) ret); goto err_reset; } + +switch (arizona->type) { +case WM5102 : + ret =arizona_apply_hardware_patch (arizona); +if (ret !=0 ) { +dev_err (arizona->dev, +"Failed to apply hardware patch: %d\n" , + ret); + goto err_reset; + } +break ; +default : +break ; + } }for (i =0 ; i <ARRAY_SIZE (arizona->pdata.gpio_defaults); i++) {
Signature · 1 line
1.7.10.4
PATCH 14/15 mfd: wm5102: Deactivate standard boot sequence
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
This patch deactivates the standard, currently noop, boot sequence because we now have facilities in place for running a custom boot sequence.
--- drivers/mfd/arizona-core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/mfd/arizona-core.c +5 -6
@@ -336,12 +336,6 @@ static int arizona_runtime_resume(struct device *dev)regcache_cache_only (arizona->regmap, false); - ret =arizona_wait_for_boot (arizona); -if (ret !=0 ) { -regulator_disable (arizona->dcvdd); -return ret; - } -switch (arizona->type) {case WM5102 : ret =wm5102_patch (arizona);
@@ -360,6 +354,11 @@ static int arizona_runtime_resume(struct device *dev) }break ;default : + ret =arizona_wait_for_boot (arizona); +if (ret !=0 ) { + goto err; + } +break ; }
Signature · 1 line
1.7.10.4
PATCH 15/15 mfd: wm5102: Update defaults to match patch
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
Registers which have defaults and are updated by the patch file should have their defaults updated to match the value set by the patch file, otherwise incorrect values will be read from the cache.
--- drivers/mfd/wm5102-tables.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/mfd/wm5102-tables.c +5 -5
@@ -382,7 +382,7 @@ static const struct reg_default wm5102_reg_default[] = { { 0x00000400, 0x0000 }, /* R1024 - Output Enables 1 */ { 0x00000408, 0x0000 }, /* R1032 - Output Rate 1 */ { 0x00000409, 0x0022 }, /* R1033 - Output Volume Ramp */ - { 0x00000410, 0x4080 }, /* R1040 - Output Path Config 1L */ + { 0x00000410, 0x6080 }, /* R1040 - Output Path Config 1L */ { 0x00000411, 0x0180 }, /* R1041 - DAC Digital Volume 1L */ { 0x00000412, 0x0081 }, /* R1042 - DAC Volume Limit 1L */ { 0x00000413, 0x0001 }, /* R1043 - Noise Gate Select 1L */
@@ -390,7 +390,7 @@ static const struct reg_default wm5102_reg_default[] = { { 0x00000415, 0x0180 }, /* R1045 - DAC Digital Volume 1R */ { 0x00000416, 0x0081 }, /* R1046 - DAC Volume Limit 1R */ { 0x00000417, 0x0002 }, /* R1047 - Noise Gate Select 1R */ - { 0x00000418, 0x4080 }, /* R1048 - Output Path Config 2L */ + { 0x00000418, 0xA080 }, /* R1048 - Output Path Config 2L */ { 0x00000419, 0x0180 }, /* R1049 - DAC Digital Volume 2L */ { 0x0000041A, 0x0081 }, /* R1050 - DAC Volume Limit 2L */ { 0x0000041B, 0x0004 }, /* R1051 - Noise Gate Select 2L */
@@ -398,11 +398,11 @@ static const struct reg_default wm5102_reg_default[] = { { 0x0000041D, 0x0180 }, /* R1053 - DAC Digital Volume 2R */ { 0x0000041E, 0x0081 }, /* R1054 - DAC Volume Limit 2R */ { 0x0000041F, 0x0008 }, /* R1055 - Noise Gate Select 2R */ - { 0x00000420, 0x4080 }, /* R1056 - Output Path Config 3L */ + { 0x00000420, 0xA080 }, /* R1056 - Output Path Config 3L */ { 0x00000421, 0x0180 }, /* R1057 - DAC Digital Volume 3L */ { 0x00000422, 0x0081 }, /* R1058 - DAC Volume Limit 3L */ { 0x00000423, 0x0010 }, /* R1059 - Noise Gate Select 3L */ - { 0x00000428, 0xC000 }, /* R1064 - Output Path Config 4L */ + { 0x00000428, 0xE000 }, /* R1064 - Output Path Config 4L */ { 0x00000429, 0x0180 }, /* R1065 - DAC Digital Volume 4L */ { 0x0000042A, 0x0081 }, /* R1066 - Out Volume 4L */ { 0x0000042B, 0x0040 }, /* R1067 - Noise Gate Select 4L */
@@ -417,7 +417,7 @@ static const struct reg_default wm5102_reg_default[] = { { 0x00000436, 0x0081 }, /* R1078 - DAC Volume Limit 5R */ { 0x00000437, 0x0200 }, /* R1079 - Noise Gate Select 5R */ { 0x00000450, 0x0000 }, /* R1104 - DAC AEC Control 1 */ - { 0x00000458, 0x0001 }, /* R1112 - Noise Gate Control */ + { 0x00000458, 0x000B }, /* R1112 - Noise Gate Control */ { 0x00000490, 0x0069 }, /* R1168 - PDM SPK1 CTRL 1 */ { 0x00000491, 0x0000 }, /* R1169 - PDM SPK1 CTRL 2 */ { 0x00000500, 0x000C }, /* R1280 - AIF1 BCLK Ctrl */
Signature · 1 line
1.7.10.4
Quoted 10 lines · Mark Brown
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixes
A few more updates for this which I'll post just now, I've updated the tag and branch:
The following changes since commit 07961ac7c0ee8b546658717034fe692fd12eefa9:
Linux 3.9-rc5 (2013-03-31 15:12:43 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git tags/mfd-arizona-3.10
for you to fetch changes up to 241979cb90eb0ed5814a5b207298518a25b3f032:
mfd: wm5102: Don't wait for boot when boot sequencer is disabled (2013-04-03 14:19:22 +0100)
----------------------------------------------------------------
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixes
----------------------------------------------------------------
Charles Keepax (7):
mfd: wm5102: Manually apply register patch
mfd: arizona: Factor out register polling
mfd: arizona: Add a hardware patch mechanism
mfd: wm5102: Deactivate standard boot sequence
mfd: wm5102: Update defaults to match patch
mfd: arizona: Wait for internal clocks to startup after reset
mfd: wm5102: Don't wait for boot when boot sequencer is disabled
Mark Brown (11):
mfd: arizona: Disable all wake sources by default
mfd: arizona: Clarify error message for failed primary IRQ request
mfd: arizona: Basic support for edge triggered IRQs
mfd: arizona: Allow GPIO to be specified for IRQ line
mfd: arizona: Try to use interrupt flags from interrupt controller
mfd: arizona: Support configuring MICBIASes into bypass mode
mfd: wm5102: Update patch for latest evaluation
mfd: arizona: Fully support the use of MCLK1 as the 32kHz clock source
mfd: arizona: Unconditionally enable 32kHz clock
mfd: wm5102: Only use the lowest three bits of device revision
mfd: arizona: Hold device in reset while ramping supplies
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 4 +- drivers/mfd/arizona-core.c | 253 +++++++++++++++++++++----- drivers/mfd/arizona-irq.c | 106 +++++++++-- drivers/mfd/wm5102-tables.c | 56 ++++-- include/linux/mfd/arizona/pdata.h | 7 +- 5 files changed, 345 insertions(+), 81 deletions(-)
PATCH 1/3 mfd: arizona: Hold device in reset while ramping supplies
Acquire the /RESET GPIO before we enable regulators and hold the device in reset while the regulators power up in order to improve robustness during the initial power up.
Also fix the error path so that the device is left in reset while we're at it.
--- drivers/mfd/arizona-core.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/mfd/arizona-core.c +13 -13
@@ -494,6 +494,17 @@ int arizona_dev_init(struct arizona *arizona) goto err_early; } +if (arizona->pdata.reset) { +/* Start out with /RESET low to put the chip into reset */ + ret =gpio_request_one (arizona->pdata.reset, +GPIOF_DIR_OUT |GPIOF_INIT_LOW , +"arizona /RESET" ); +if (ret !=0 ) { +dev_err (dev,"Failed to request /RESET: %d\n" , ret); + goto err_early; + } + } + ret =regulator_bulk_enable (arizona->num_core_supplies, arizona->core_supplies);if (ret !=0 ) {
@@ -508,18 +519,8 @@ int arizona_dev_init(struct arizona *arizona) goto err_enable; } -if (arizona->pdata.reset) { -/* Start out with /RESET low to put the chip into reset */ - ret =gpio_request_one (arizona->pdata.reset, -GPIOF_DIR_OUT |GPIOF_INIT_LOW , -"arizona /RESET" ); -if (ret !=0 ) { -dev_err (dev,"Failed to request /RESET: %d\n" , ret); - goto err_dcvdd; - } - +if (arizona->pdata.reset)gpio_set_value_cansleep (arizona->pdata.reset,1 ); - }regcache_cache_only (arizona->regmap, false);
@@ -759,10 +760,9 @@ err_irq:arizona_irq_exit (arizona); err_reset:if (arizona->pdata.reset) { -gpio_set_value_cansleep (arizona->pdata.reset,1 ); +gpio_set_value_cansleep (arizona->pdata.reset,0 );gpio_free (arizona->pdata.reset); } -err_dcvdd:regulator_disable (arizona->dcvdd); err_enable: regulator_bulk_disable(arizona->num_core_supplies,
Signature · 1 line
1.7.10.4
PATCH 2/3 mfd: arizona: Wait for internal clocks to startup after reset
From: Charles Keepax <[email protected]>
--- drivers/mfd/arizona-core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mfd/arizona-core.c +5 -1
@@ -519,8 +519,10 @@ int arizona_dev_init(struct arizona *arizona) goto err_enable; } -if (arizona->pdata.reset) +if (arizona->pdata.reset) {gpio_set_value_cansleep (arizona->pdata.reset,1 ); +msleep (1 ); + }regcache_cache_only (arizona->regmap, false);
@@ -579,6 +581,8 @@ int arizona_dev_init(struct arizona *arizona) goto err_reset; } +msleep (1 ); + ret =regcache_sync (arizona->regmap);if (ret !=0 ) {dev_err (dev,"Failed to sync device: %d\n" , ret);
Signature · 1 line
1.7.10.4
PATCH 3/3 mfd: wm5102: Don't wait for boot when boot sequencer is disabled
In reply to Mark BrownFrom: Charles Keepax <[email protected]>
As we are using a custom boot sequence we don't need to wait for the standard boot sequence in device init when the normal write sequence is disabled.
--- drivers/mfd/arizona-core.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/mfd/arizona-core.c +18 -4
@@ -590,10 +590,24 @@ int arizona_dev_init(struct arizona *arizona) } } - ret =arizona_wait_for_boot (arizona); -if (ret !=0 ) { -dev_err (arizona->dev,"Device failed initial boot: %d\n" , ret); - goto err_reset; +switch (arizona->type) { +case WM5102 : + ret =regmap_read (arizona->regmap,0x19 , &val); +if (ret !=0 ) +dev_err (dev, +"Failed to check write sequencer state: %d\n" , + ret); +else if (val &0x01 ) +break ; +/* Fall through */ +default : + ret =arizona_wait_for_boot (arizona); +if (ret !=0 ) { +dev_err (arizona->dev, +"Device failed initial boot: %d\n" , ret); + goto err_reset; + } +break ; }if (apply_patch) {
Signature · 1 line
1.7.10.4
Hi Mark,
Quoted 16 lines · Mark Brown
Quoted 10 lines · Mark Brown
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixesA few more updates for this which I'll post just now, I've updated the tag and branch:
Quoted 7 lines
The following changes since commit
07961ac7c0ee8b546658717034fe692fd12eefa9:Linux 3.9-rc5 (2013-03-31 15:12:43 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.gittags/mfd-arizona-3.10
Thanks, I pulled this one into mfd-next now.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Quoted 17 lines · Samuel Ortiz
Quoted 16 lines · Mark Brown
Quoted 10 lines · Mark Brown
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixesA few more updates for this which I'll post just now, I've updated the tag and branch:
Quoted 8 lines
Quoted 7 lines
The following changes since commit
07961ac7c0ee8b546658717034fe692fd12eefa9:Linux 3.9-rc5 (2013-03-31 15:12:43 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.gittags/mfd-arizona-3.10Thanks, I pulled this one into mfd-next now.
Actually, this branch fails to build for 2 reasons:
- arizona_runtime_resume() tries to goto err; while there is no err label.
- arizona_of_get_core_pdata() is not defiined when !CONFIG_OF.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/
Quoted 10 lines · Samuel Ortiz
Quoted 3 lines · Samuel Ortiz
Quoted 1 line
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.gittags/mfd-arizona-3.10Thanks, I pulled this one into mfd-next now.
Actually, this branch fails to build for 2 reasons:
-
arizona_runtime_resume()tries to goto err; while there is no err label.
-arizona_of_get_core_pdata()is not defiined when !CONFIG_OF.
Can you be more specific about what you pulled? I'm looking at the mfd-arizona-3.10 tag just now and there's no reference I can see to of_get_core_pdata() which is what I'd expect as this was a separate patch series... I'm just re-tagging and re-pushing but were you testing both serieses together?
Quoted 2 lines · Mark Brown
patch series... I'm just re-tagging and re-pushing but were you testing both serieses together?
OK, the mirrors seem to have the rebase now. New pull request:
The following changes since commit 31880c37c11e28cb81c70757e38392b42e695dc6:
Linux 3.9-rc6 (2013-04-07 20:49:54 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git tags/mfd-arizona-3.10
for you to fetch changes up to 031eb8d52ecbe417cf778fba2d49bee90a078648:
mfd: wm5102: Don't wait for boot when boot sequencer is disabled (2013-04-08 11:12:04 +0100)
----------------------------------------------------------------
mfd: arizona: Updates for v3.10
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixes
----------------------------------------------------------------
Charles Keepax (7):
mfd: wm5102: Manually apply register patch
mfd: arizona: Factor out register polling
mfd: arizona: Add a hardware patch mechanism
mfd: wm5102: Deactivate standard boot sequence
mfd: wm5102: Update defaults to match patch
mfd: arizona: Wait for internal clocks to startup after reset
mfd: wm5102: Don't wait for boot when boot sequencer is disabled
Mark Brown (12):
mfd: arizona: Disable all wake sources by default
mfd: arizona: Clean up on failed runtime resume
mfd: arizona: Clarify error message for failed primary IRQ request
mfd: arizona: Basic support for edge triggered IRQs
mfd: arizona: Allow GPIO to be specified for IRQ line
mfd: arizona: Try to use interrupt flags from interrupt controller
mfd: arizona: Support configuring MICBIASes into bypass mode
mfd: wm5102: Update patch for latest evaluation
mfd: arizona: Fully support the use of MCLK1 as the 32kHz clock source
mfd: arizona: Unconditionally enable 32kHz clock
mfd: wm5102: Only use the lowest three bits of device revision
mfd: arizona: Hold device in reset while ramping supplies
arch/arm/mach-s3c64xx/mach-crag6410-module.c | 4 +- drivers/mfd/arizona-core.c | 267 +++++++++++++++++++++----- drivers/mfd/arizona-irq.c | 106 ++++++++-- drivers/mfd/wm5102-tables.c | 56 ++++-- include/linux/mfd/arizona/pdata.h | 7 +- 5 files changed, 357 insertions(+), 83 deletions(-)
Hi Mark,
Quoted 22 lines · Mark Brown
Quoted 2 lines · Mark Brown
patch series... I'm just re-tagging and re-pushing but were you testing both serieses together?
OK, the mirrors seem to have the rebase now. New pull request:
The following changes since commit
31880c37c11e28cb81c70757e38392b42e695dc6:Linux 3.9-rc6 (2013-04-07 20:49:54 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.gittags/mfd-arizona-3.10for you to fetch changes up to
031eb8d52ecbe417cf778fba2d49bee90a078648:mfd: wm5102: Don't wait for boot when boot sequencer is disabled (2013-04-08 11:12:04 +0100)
----------------------------------------------------------------
mfd: arizona: Updates for v3.10
Quoted 7 lines
This is really a few separate topics which I can split out if required:
- WM5102 updates to improve robustness
- Improved support for interoperation with edge triggered interrupt controllers
- Support for some unusual clocking configurations
- A couple small single patch updates and fixes
Thanks, all 19 patches applied now. Everything builds fine on my side. The culprit for the missing arizona_of_get_core_pdata was "mfd: Add device tree bindings for Arizona class devices", not the above branch.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/