mfd: arizona: Add device tree helper functions
PATCH 1/5 mfd: arizona: Add device tree helper functions
Factor out reading of specific device tree bindings into seperate functions in preperation for adding more of them. Whilst we are at is fixup a couple of small issues in the existing binding documentation.
--- Documentation/devicetree/bindings/mfd/arizona.txt | 12 +- drivers/mfd/arizona-core.c | 121 +++++++++++++++------ 2 files changed, 95 insertions(+), 38 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +6 -6
@@ -25,7 +25,7 @@ Required properties: - #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, + - AVDD-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
@@ -53,10 +53,10 @@ codec: wm5102@1a { #gpio-cells = <2>; wlf,gpio-defaults = < - 0x00000000, /* AIF1TXLRCLK */ - 0xffffffff, - 0xffffffff, - 0xffffffff, - 0xffffffff, + 0x00000000 /* AIF1TXLRCLK */ + 0xffffffff + 0xffffffff + 0xffffffff + 0xffffffff >; };
drivers/mfd/arizona-core.c +89 -32
131 lines not on this page · raw message
Signature · 6 lines
1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/5 mfd: arizona: Add device tree binding for max_channels_clocked
Add device tree bindings for the pdata max_channels_clocked, that allows the user to limit the number of channels clocked on a single AIF.
--- Documentation/devicetree/bindings/mfd/arizona.txt | 7 +++++++ drivers/mfd/arizona-core.c | 5 +++++ 2 files changed, 12 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +7 -0
@@ -40,6 +40,11 @@ Optional properties: the chip default will be used. If present exactly five values must be specified. + - wlf,max-channels-clocked : The maximum number of channels to be clocked on + each AIF, useful for I2S systems with multiple data lines being mastered. + If specified three cells must supplied one for each AIF, specify zero for + AIFs that should be handled normally. + Example: codec: wm5102@1a {
@@ -59,4 +64,6 @@ codec: wm5102@1a { 0xffffffff 0xffffffff >; + + wlf,max-channels-clocked = <2 0 0>; };
drivers/mfd/arizona-core.c +5 -0
@@ -605,6 +605,11 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)arizona_of_get_gpio_defaults (arizona,"wlf,gpio-defaults" ); +arizona_of_read_u32_array (arizona,"wlf,max-channels-clocked" , + false, + pdata->max_channels_clocked, +ARRAY_SIZE (pdata->max_channels_clocked)); +return 0 ; }
Signature · 1 line
1.7.2.5
PATCH 3/5 mfd: arizona: Add simple microphone detection device tree bindings
In reply to Charles KeepaxAdd device tree bindings for several of simpler microphone detection pdata fields.
--- Documentation/devicetree/bindings/mfd/arizona.txt | 23 +++++++++++++++++++++ drivers/mfd/arizona-core.c | 22 ++++++++++++++++++++ 2 files changed, 45 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +23 -0
@@ -34,6 +34,22 @@ Optional properties: - wlf,reset : GPIO specifier for the GPIO controlling /RESET - wlf,ldoena : GPIO specifier for the GPIO controlling LDOENA + - wlf,micd-detect-debounce : Additional software microphone detection + debounce specified in milliseconds + - wlf,micd-pol-gpio : GPIO specifier for the GPIO controlling the headset + polarity if one exists + - wlf,micd-bias-start-time : Time allowed for MICBIAS to startup prior to + performing microphone detection, specified as per the MICD_BIAS_STARTTIME + bits in the register MIC_DETECT_1 + - wlf,micd-rate : Delay between successive microphone detection measurements, + specified as per the MICD_RATE bits in the register MIC_DETECT_1 + - wlf,micd-dbtime : Microphone detection hardware debounce level, specified + as per the MICD_DBTIME bits in the register MIC_DETECT_1 + - wlf,micd-timeout : Timeout for microphone detection, specified in + milliseconds + - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone + detection + - 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
@@ -57,6 +73,13 @@ codec: wm5102@1a { gpio-controller; #gpio-cells = <2>; + wlf,micd-detect-debounce = <10>; + wlf,micd-bias-start-time = <0x1>; + wlf,micd-rate = <0x1>; + wlf,micd-dbtime = <0x1>; + wlf,micd-timeout = <10>; + wlf,micd-force-micbias; + wlf,gpio-defaults = < 0x00000000 /* AIF1TXLRCLK */ 0xffffffff
drivers/mfd/arizona-core.c +22 -0
@@ -603,6 +603,28 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)arizona_of_get_named_gpio (arizona,"wlf,reset" , true, &pdata->reset);arizona_of_get_named_gpio (arizona,"wlf,ldoena" , true, &pdata->ldoena); +arizona_of_read_u32 (arizona,"wlf,micd-detect-debounce" , false, + &pdata->micd_detect_debounce); + +arizona_of_get_named_gpio (arizona,"wlf,micd-pol-gpio" , false, + &pdata->micd_pol_gpio); + +arizona_of_read_u32 (arizona,"wlf,micd-bias-start-time" , false, + &pdata->micd_bias_start_time); + +arizona_of_read_u32 (arizona,"wlf,micd-rate" , false, + &pdata->micd_rate); + +arizona_of_read_u32 (arizona,"wlf,micd-dbtime" , false, + &pdata->micd_dbtime); + +arizona_of_read_u32 (arizona,"wlf,micd-timeout" , false, + &pdata->micd_timeout); + + pdata->micd_force_micbias = +of_property_read_bool (arizona->dev->of_node, +"wlf,micd-force-micbias" ); +arizona_of_get_gpio_defaults (arizona,"wlf,gpio-defaults" ); arizona_of_read_u32_array(arizona, "wlf,max-channels-clocked",
Signature · 6 lines
1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/5 mfd: arizona: Add micdet ranges and polarity device tree bindings
In reply to Charles KeepaxAdd device tree bindings for the pdata that configures the microphone button detection and microphone detection polarity configurations.
--- Documentation/devicetree/bindings/mfd/arizona.txt | 26 +++++ drivers/mfd/arizona-core.c | 116 +++++++++++++++++++++ 2 files changed, 142 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +26 -0
@@ -49,6 +49,20 @@ Optional properties: milliseconds - wlf,micd-force-micbias : Force MICBIAS continuously on during microphone detection + - wlf,micd-ranges : Microphone detection level and key configuration, this + field can be of variable length but should always be a multiple of 2 cells + long, each two cell group represents one button configuration + The first cell is the maximum impedance for this button in ohms + The second cell the key that should be reported to the input layer + - wlf,micd-configs : Headset polarity configurations, the field can be of + variable length but should always be a multiple of 3 cells long, each two + cell group represents one polarity configration + The first cell is the accessory detection source as per the ACCDET_SRC bits + in the ACCESSORY_DETECT_MODE_1 register + The second cell represents the MICBIAS to be used as per the MICD_BIAS_SRC + bits in the MIC_DETECT_1 register + The third cell represents the value of the micd-pol-gpio pin, a non-zero + value indicates this should be on - wlf,gpio-defaults : A list of GPIO configuration register values. If absent, no configuration of these registers is performed. If any
@@ -79,6 +93,18 @@ codec: wm5102@1a { wlf,micd-dbtime = <0x1>; wlf,micd-timeout = <10>; wlf,micd-force-micbias; + wlf,micd-ranges = < + 11 0x100 + 28 0x101 + 54 0x102 + 100 0x103 + 186 0x104 + 430 0x105 + >; + wlf,micd-configs = < + 0x1 1 0 + 0x0 2 1 + >; wlf,gpio-defaults = < 0x00000000 /* AIF1TXLRCLK */
drivers/mfd/arizona-core.c +116 -0
128 lines not on this page · raw message
Signature · 1 line
1.7.2.5
PATCH 5/5 mfd: arizona: Add device tree bindings for MICBIAS generators
In reply to Charles KeepaxAdd device tree bindings for the pdata needed to configure the MICBIAS generators.
--- Documentation/devicetree/bindings/mfd/arizona.txt | 15 ++++++++++++ drivers/mfd/arizona-core.c | 25 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/mfd/arizona.txt +15 -0
@@ -64,6 +64,19 @@ Optional properties: The third cell represents the value of the micd-pol-gpio pin, a non-zero value indicates this should be on + - wlf,micbias1 : Configuration for the micbias regulator, should include 5 + cells. + The first cell is the output voltage in millivolts + The second cell a non-zero value indicates an external capacitor is fitted + The third cell a non-zero value indicates the micbias should be actively + discharged + The four cell a non-zero value indicates that the micbias should be + brought up slowly to reduce pops + The fifth cell a non-zero value indicates the micbias should be bypassed + and simply output MICVDD + - wlf,micbias2 : See wlf,micbias1 + - wlf,micbias3 : See wlf,micbias1 + - 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
@@ -106,6 +119,8 @@ codec: wm5102@1a { 0x0 2 1 >; + wlf,micbias2 = <2600 0 1 1 0>; + wlf,gpio-defaults = < 0x00000000 /* AIF1TXLRCLK */ 0xffffffff
drivers/mfd/arizona-core.c +25 -0
@@ -706,6 +706,27 @@ static int arizona_of_get_micd_configs(struct arizona *arizona, error:devm_kfree (arizona->dev, micd_configs);dev_err (arizona->dev,"DT property %s is malformed: %d\n" , prop, ret); + +return ret; +} + +static int arizona_of_get_micbias (struct arizona *arizona, +const char *prop,int index) +{ +int ret; +u32 micbias_config[5 ]; + + ret =arizona_of_read_u32_array (arizona, prop, false, + micbias_config, +ARRAY_SIZE (micbias_config)); +if (ret >=0 ) { + arizona->pdata.micbias[index].mV = micbias_config[0 ]; + arizona->pdata.micbias[index].ext_cap = micbias_config[1 ]; + arizona->pdata.micbias[index].discharge = micbias_config[2 ]; + arizona->pdata.micbias[index].soft_start = micbias_config[3 ]; + arizona->pdata.micbias[index].bypass = micbias_config[4 ]; + } +return ret; }
@@ -741,6 +762,10 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)arizona_of_get_micd_ranges (arizona,"wlf,micd-ranges" );arizona_of_get_micd_configs (arizona,"wlf,micd-configs" ); +arizona_of_get_micbias (arizona,"wlf,micbias1" ,0 ); +arizona_of_get_micbias (arizona,"wlf,micbias2" ,1 ); +arizona_of_get_micbias (arizona,"wlf,micbias3" ,2 ); +arizona_of_get_gpio_defaults (arizona,"wlf,gpio-defaults" ); arizona_of_read_u32_array(arizona, "wlf,max-channels-clocked",
Signature · 1 line
1.7.2.5
Documentation/devicetree/bindings/mfd/arizona.txt Required properties: · line 28
Quoted 8 lines · Charles Keepax
Factor out reading of specific device tree bindings into seperate functions in preperation for adding more of them. Whilst we are at is fixup a couple of small issues in the existing binding documentation.
Documentation/devicetree/bindings/mfd/arizona.txt +1
-1- - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, + - AVDD-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,
That looks like an incompatible change to the DT ABI.
Re: [PATCH 2/5] mfd: arizona: Add device tree binding for max_channels_clocked
In reply to Charles KeepaxDocumentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 46
Quoted 9 lines · Charles Keepax
Add device tree bindings for the pdata
max_channels_clocked, that allows the user to limit the number of channels clocked on a single AIF.Documentation/devicetree/bindings/mfd/arizona.txt +4
-0+ - wlf,max-channels-clocked : The maximum number of channels to be clocked on + each AIF, useful for I2S systems with multiple data lines being mastered. + If specified three cells must supplied one for each AIF, specify zero for + AIFs that should be handled normally.
What determines the value of this property? Is it really a definition of HW, or some kind of run-time configuration/limit? What goes into each of the 3 cells?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/5] mfd: arizona: Add micdet ranges and polarity device tree bindings
In reply to Charles KeepaxDocumentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 56
Quoted 10 lines · Charles Keepax
Add device tree bindings for the pdata that configures the microphone button detection and microphone detection polarity configurations.
Documentation/devicetree/bindings/mfd/arizona.txt +5
-0+ - wlf,micd-ranges : Microphone detection level and key configuration, this + field can be of variable length but should always be a multiple of 2 cells + long, each two cell group represents one button configuration + The first cell is the maximum impedance for this button in ohms + The second cell the key that should be reported to the input layer
Is there a limit on how many ranges can be specified? Are the impedance values arbitrary, or limited to some pre-determined set of values supported by HW?
Documentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 58
Quoted 2 lines
Documentation/devicetree/bindings/mfd/arizona.txt +2
-0+ - wlf,micd-configs : Headset polarity configurations, the field can be of + variable length but should always be a multiple of 3 cells long, each two
s/two/three/
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
In reply to Charles KeepaxDocumentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 70
Quoted 9 lines · Charles Keepax
Add device tree bindings for the pdata needed to configure the MICBIAS generators.
Documentation/devicetree/bindings/mfd/arizona.txt +4
-0+ - wlf,micbias1 : Configuration for the micbias regulator, should include 5 + cells. + The first cell is the output voltage in millivolts + The second cell a non-zero value indicates an external capacitor is fitted
I think you need some kind of delimiter (e.g. a colon) after "cell" there, to separate the line's label and description.
Quoted 1 line
+ The four cell a non-zero value indicates that the micbias should be
s/four/fourth/
There are lots of cells here with a single-bit flag in them. Can the flags be combined into a single cell to reduce the DT size? cpp-based named constants should keep the *.dts file readable.
Re: [PATCH 4/5] mfd: arizona: Add micdet ranges and polarity device tree bindings
In reply to Charles KeepaxQuoted 2 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt | 26 +++++ drivers/mfd/arizona-core.c | 116 +++++++++++++++++++++
It's probably more idomatic to put the parsing for these in the driver that uses them.
Documentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 56
Quoted 5 lines
Documentation/devicetree/bindings/mfd/arizona.txt +5
-0+ - wlf,micd-ranges : Microphone detection level and key configuration, this + field can be of variable length but should always be a multiple of 2 cells + long, each two cell group represents one button configuration + The first cell is the maximum impedance for this button in ohms + The second cell the key that should be reported to the input layer
This isn't good - the device tree is supposed to be an OS independant description of the hardware that can be used by any OS but this binding embeds Linux-specific numbers. There are a few Linux specific bindings where people have just given up due to the complexity of developing a generic description but this doesn't seem like it shuld be such a case. This is going to be used for buttons on headsets and essentially all real headsets can be covered by just defining the ability to set hook switch, fast forward and rewind.
Re: [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
In reply to Charles KeepaxDocumentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 74
Quoted 8 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt +8
-0+ - wlf,micbias1 : Configuration for the micbias regulator, should include 5 + cells. + The first cell is the output voltage in millivolts + The second cell a non-zero value indicates an external capacitor is fitted + The third cell a non-zero value indicates the micbias should be actively + discharged + The four cell a non-zero value indicates that the micbias should be + brought up slowly to reduce pops
I would suggest defining a subnode with boolean properties for these, it's not massively legible to have this many random numbers. Consider using the regulator binding, microphone biases are after all regulators.
Documentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 76
Quoted 2 lines
Documentation/devicetree/bindings/mfd/arizona.txt +2
-0+ The fifth cell a non-zero value indicates the micbias should be bypassed + and simply output MICVDD
This is something that should be being varied at runtime in detection scenarios, the meaning ought to be being tightened up here.
Re: [PATCH 2/5] mfd: arizona: Add device tree binding for max_channels_clocked
In reply to Stephen WarrenQuoted 10 lines · Stephen Warren
Documentation/devicetree/bindings/mfd/arizona.txt Optional properties: · line 46
Quoted 4 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt +4
-0+ - wlf,max-channels-clocked : The maximum number of channels to be clocked on + each AIF, useful for I2S systems with multiple data lines being mastered. + If specified three cells must supplied one for each AIF, specify zero for + AIFs that should be handled normally.What determines the value of this property? Is it really a definition of HW, or some kind of run-time configuration/limit? What goes into each of the 3 cells?
It's hardware, it's other devices wired in parallel on the bus that use the CODEC as a clock master. Personally I'd have this be set by the ASoC machine driver so it's invisible from a DT point of view, that's what it's really a property of.
Quoted 5 lines · Stephen Warren
Documentation/devicetree/bindings/mfd/arizona.txt Required properties: · line 28
Quoted 2 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt +1
-1- - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, + - AVDD-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,That looks like an incompatible change to the DT ABI.
The supply name in the driver is AVDD as is the name for the pin on the datasheet, if you specify it as AVDD1 in device tree the current driver will not load.
This appears to have been a copy and paste error from the wm8994 which has 2 AVDD supplies and I believe these docs were based on. I would prefer to update the documentation to match what the driver already expects rather than the other way around.
Thanks,
Charles
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 2/5] mfd: arizona: Add device tree binding for max_channels_clocked
In reply to Mark BrownQuoted 8 lines · Mark Brown
Quoted 6 lines · Stephen Warren
Quoted 4 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt +4
-0+ - wlf,max-channels-clocked : The maximum number of channels to be clocked on + each AIF, useful for I2S systems with multiple data lines being mastered. + If specified three cells must supplied one for each AIF, specify zero for + AIFs that should be handled normally.
Quoted 8 lines
Quoted 3 lines
What determines the value of this property? Is it really a definition of HW, or some kind of run-time configuration/limit? What goes into each of the 3 cells?
It's hardware, it's other devices wired in parallel on the bus that use the CODEC as a clock master. Personally I'd have this be set by the ASoC machine driver so it's invisible from a DT point of view, that's what it's really a property of.
I don't have any really problem with setting this from the machine driver, I will have a look at doing that.
I think based on the comments here I would suggest that we put the first patch in but I need to rethink the other patches and decide what is actually OS independant here.
Thanks,
Charles
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Charles Keepax
The supply name in the driver is AVDD as is the name for the pin on the datasheet, if you specify it as AVDD1 in device tree the current driver will not load.
This appears to have been a copy and paste error from the wm8994 which has 2 AVDD supplies and I believe these docs were based on. I would prefer to update the documentation to match what the driver already expects rather than the other way around.
I suspect it's due to an error in an old version of one of the datasheets.
Quoted 7 lines · Charles Keepax
Quoted 5 lines · Stephen Warren
Documentation/devicetree/bindings/mfd/arizona.txt Required properties: · line 28
Quoted 2 lines · Charles Keepax
Documentation/devicetree/bindings/mfd/arizona.txt +1
-1- - AVDD1-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply, + - AVDD-supply, DBVDD1-supply, DBVDD2-supply, DBVDD3-supply, CPVDD-supply,That looks like an incompatible change to the DT ABI.
Quoted 8 lines
The supply name in the driver is AVDD as is the name for the pin on the datasheet, if you specify it as AVDD1 in device tree the current driver will not load.
This appears to have been a copy and paste error from the wm8994 which has 2 AVDD supplies and I believe these docs were based on. I would prefer to update the documentation to match what the driver already expects rather than the other way around.
OK, if there's no driver anywhere that can possibly work with the binding as written, it's likely fine to change the binding.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html