* [PATCH 1/5] mfd: arizona: Add device tree helper functions
@ 2013-09-23 18:30 ` Charles Keepax
0 siblings, 0 replies; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones
Cc: sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel,
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 12 +-
drivers/mfd/arizona-core.c | 121 +++++++++++++++------
2 files changed, 95 insertions(+), 38 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 0e295c9..e2cecfc 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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
>;
};
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 5ac3aa4..986abc5 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -512,42 +512,99 @@ int arizona_of_get_type(struct device *dev)
}
EXPORT_SYMBOL_GPL(arizona_of_get_type);
-static int arizona_of_get_core_pdata(struct arizona *arizona)
+static int arizona_of_get_named_gpio(struct arizona *arizona,
+ const char *prop, bool mandatory,
+ int *gpio)
{
- int ret, i;
+ int ret;
- arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
- "wlf,reset", 0);
- if (arizona->pdata.reset < 0)
- arizona->pdata.reset = 0;
-
- arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
- "wlf,ldoena", 0);
- if (arizona->pdata.ldoena < 0)
- arizona->pdata.ldoena = 0;
-
- ret = of_property_read_u32_array(arizona->dev->of_node,
- "wlf,gpio-defaults",
- arizona->pdata.gpio_defaults,
- ARRAY_SIZE(arizona->pdata.gpio_defaults));
- if (ret >= 0) {
- /*
- * All values are literal except out of range values
- * which are chip default, translate into platform
- * data which uses 0 as chip default and out of range
- * as zero.
- */
- for (i = 0; i < ARRAY_SIZE(arizona->pdata.gpio_defaults); i++) {
- if (arizona->pdata.gpio_defaults[i] > 0xffff)
- arizona->pdata.gpio_defaults[i] = 0;
- if (arizona->pdata.gpio_defaults[i] == 0)
- arizona->pdata.gpio_defaults[i] = 0x10000;
- }
- } else {
- dev_err(arizona->dev, "Failed to parse GPIO defaults: %d\n",
- ret);
+ ret = of_get_named_gpio(arizona->dev->of_node, prop, 0);
+ *gpio = ret;
+ if (ret >= 0)
+ return ret;
+
+ *gpio = 0;
+
+ if (mandatory)
+ dev_err(arizona->dev,
+ "Mandatory DT gpio %s missing/malformed: %d\n",
+ prop, ret);
+
+ return ret;
+}
+
+static int arizona_of_read_u32_array(struct arizona *arizona,
+ const char *prop, bool mandatory,
+ u32 *data, size_t num)
+{
+ int ret;
+
+ ret = of_property_read_u32_array(arizona->dev->of_node, prop,
+ data, num);
+
+ if (ret >= 0)
+ return 0;
+
+ switch (ret) {
+ case -EINVAL:
+ if (mandatory)
+ dev_err(arizona->dev,
+ "Mandatory DT property %s is missing\n",
+ prop);
+ break;
+ default:
+ dev_err(arizona->dev,
+ "DT property %s is malformed: %d\n",
+ prop, ret);
}
+ return ret;
+}
+
+static int arizona_of_read_u32(struct arizona *arizona,
+ const char* prop, bool mandatory,
+ u32 *data)
+{
+ return arizona_of_read_u32_array(arizona, prop, mandatory, data, 1);
+}
+
+static int arizona_of_get_gpio_defaults(struct arizona *arizona,
+ const char *prop)
+{
+ struct arizona_pdata *pdata = &arizona->pdata;
+ int i, ret;
+
+ ret = arizona_of_read_u32_array(arizona, prop, false,
+ pdata->gpio_defaults,
+ ARRAY_SIZE(pdata->gpio_defaults));
+ if (ret < 0)
+ return ret;
+
+ /*
+ * All values are literal except out of range values
+ * which are chip default, translate into platform
+ * data which uses 0 as chip default and out of range
+ * as zero.
+ */
+ for (i = 0; i < ARRAY_SIZE(pdata->gpio_defaults); i++) {
+ if (pdata->gpio_defaults[i] > 0xffff)
+ pdata->gpio_defaults[i] = 0;
+ if (pdata->gpio_defaults[i] == 0)
+ pdata->gpio_defaults[i] = 0x10000;
+ }
+
+ return ret;
+}
+
+static int arizona_of_get_core_pdata(struct arizona *arizona)
+{
+ struct arizona_pdata *pdata = &arizona->pdata;
+
+ arizona_of_get_named_gpio(arizona, "wlf,reset", true, &pdata->reset);
+ arizona_of_get_named_gpio(arizona, "wlf,ldoena", true, &pdata->ldoena);
+
+ arizona_of_get_gpio_defaults(arizona, "wlf,gpio-defaults");
+
return 0;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 25+ messages in thread* [PATCH 2/5] mfd: arizona: Add device tree binding for max_channels_clocked
2013-09-23 18:30 ` Charles Keepax
(?)
@ 2013-09-23 18:30 ` Charles Keepax
[not found] ` <1379961043-23762-2-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
-1 siblings, 1 reply; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones
Cc: sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel,
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.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 7 +++++++
drivers/mfd/arizona-core.c | 5 +++++
2 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index e2cecfc..9eeef62 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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>;
};
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 986abc5..b3337ee 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -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;
}
--
1.7.2.5
^ permalink raw reply related [flat|nested] 25+ messages in thread[parent not found: <1379961043-23762-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* [PATCH 3/5] mfd: arizona: Add simple microphone detection device tree bindings
2013-09-23 18:30 ` Charles Keepax
@ 2013-09-23 18:30 ` Charles Keepax
-1 siblings, 0 replies; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones-QSEj5FYQhm4dnm+yROfE0A
Cc: sameo-VuQAYsv1563Yd54FQh9/CA, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
pawel.moll-5wv7dgnIgG8, mark.rutland-5wv7dgnIgG8,
swarren-3lzwWm7+Weoh9ZMKESR00Q,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, rob-VoJi6FS/r0vR7s880joybQ,
broonie-DgEjT+Ai2ygdnm+yROfE0A,
patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Charles Keepax
Add device tree bindings for several of simpler microphone detection
pdata fields.
Signed-off-by: Charles Keepax <ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 23 +++++++++++++++++++++
drivers/mfd/arizona-core.c | 22 ++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 9eeef62..3ee659d 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index b3337ee..1cc6aa0 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -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",
--
1.7.2.5
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 25+ messages in thread* [PATCH 3/5] mfd: arizona: Add simple microphone detection device tree bindings
@ 2013-09-23 18:30 ` Charles Keepax
0 siblings, 0 replies; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones
Cc: sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel,
Charles Keepax
Add device tree bindings for several of simpler microphone detection
pdata fields.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 23 +++++++++++++++++++++
drivers/mfd/arizona-core.c | 22 ++++++++++++++++++++
2 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 9eeef62..3ee659d 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index b3337ee..1cc6aa0 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -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",
--
1.7.2.5
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH 4/5] mfd: arizona: Add micdet ranges and polarity device tree bindings
2013-09-23 18:30 ` Charles Keepax
` (2 preceding siblings ...)
(?)
@ 2013-09-23 18:30 ` Charles Keepax
[not found] ` <1379961043-23762-4-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
-1 siblings, 1 reply; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones
Cc: sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel,
Charles Keepax
Add device tree bindings for the pdata that configures the microphone
button detection and microphone detection polarity configurations.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 26 +++++
drivers/mfd/arizona-core.c | 116 +++++++++++++++++++++
2 files changed, 142 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 3ee659d..09e384c 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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 */
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 1cc6aa0..c8f30c4 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -596,6 +596,119 @@ static int arizona_of_get_gpio_defaults(struct arizona *arizona,
return ret;
}
+static int arizona_of_get_u32_num_groups(struct arizona *arizona,
+ const char *prop,
+ int group_size)
+{
+ int len_prop;
+ int num_groups;
+
+ if (!of_get_property(arizona->dev->of_node, prop, &len_prop))
+ return -EINVAL;
+
+ num_groups = len_prop / (group_size * sizeof(u32));
+
+ if (num_groups * group_size * sizeof(u32) != len_prop) {
+ dev_err(arizona->dev,
+ "DT property %s is malformed: %d\n",
+ prop, -EOVERFLOW);
+ return -EOVERFLOW;
+ }
+
+ return num_groups;
+}
+
+static int arizona_of_get_micd_ranges(struct arizona *arizona,
+ const char *prop)
+{
+ int nranges;
+ int i, j;
+ int ret = 0;
+ u32 value;
+ struct arizona_micd_range *micd_ranges;
+
+ nranges = arizona_of_get_u32_num_groups(arizona, prop, 2);
+ if (nranges < 0)
+ return nranges;
+
+ micd_ranges = devm_kzalloc(arizona->dev,
+ nranges * sizeof(struct arizona_micd_range),
+ GFP_KERNEL);
+
+ for (i = 0, j = 0; i < nranges; ++i) {
+ ret = of_property_read_u32_index(arizona->dev->of_node,
+ prop, j++, &value);
+ if (ret < 0)
+ goto error;
+ micd_ranges[i].max = value;
+
+ ret = of_property_read_u32_index(arizona->dev->of_node,
+ prop, j++, &value);
+ if (ret < 0)
+ goto error;
+ micd_ranges[i].key = value;
+ }
+
+ arizona->pdata.micd_ranges = micd_ranges;
+ arizona->pdata.num_micd_ranges = nranges;
+
+ return ret;
+
+error:
+ devm_kfree(arizona->dev, micd_ranges);
+ dev_err(arizona->dev, "DT property %s is malformed: %d\n", prop, ret);
+ return ret;
+}
+
+static int arizona_of_get_micd_configs(struct arizona *arizona,
+ const char *prop)
+{
+ int nconfigs;
+ int i, j;
+ int ret = 0;
+ u32 value;
+ struct arizona_micd_config *micd_configs;
+
+ nconfigs = arizona_of_get_u32_num_groups(arizona, prop, 3);
+ if (nconfigs < 0)
+ return nconfigs;
+
+ micd_configs = devm_kzalloc(arizona->dev,
+ nconfigs *
+ sizeof(struct arizona_micd_config),
+ GFP_KERNEL);
+
+ for (i = 0, j = 0; i < nconfigs; ++i) {
+ ret = of_property_read_u32_index(arizona->dev->of_node,
+ prop, j++, &value);
+ if (ret < 0)
+ goto error;
+ micd_configs[i].src = value;
+
+ ret = of_property_read_u32_index(arizona->dev->of_node,
+ prop, j++, &value);
+ if (ret < 0)
+ goto error;
+ micd_configs[i].bias = value;
+
+ ret = of_property_read_u32_index(arizona->dev->of_node,
+ prop, j++, &value);
+ if (ret < 0)
+ goto error;
+ micd_configs[i].gpio = value;
+ }
+
+ arizona->pdata.micd_configs = micd_configs;
+ arizona->pdata.num_micd_configs = nconfigs;
+
+ return ret;
+
+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_core_pdata(struct arizona *arizona)
{
struct arizona_pdata *pdata = &arizona->pdata;
@@ -625,6 +738,9 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
of_property_read_bool(arizona->dev->of_node,
"wlf,micd-force-micbias");
+ arizona_of_get_micd_ranges(arizona, "wlf,micd-ranges");
+ arizona_of_get_micd_configs(arizona, "wlf,micd-configs");
+
arizona_of_get_gpio_defaults(arizona, "wlf,gpio-defaults");
arizona_of_read_u32_array(arizona, "wlf,max-channels-clocked",
--
1.7.2.5
^ permalink raw reply related [flat|nested] 25+ messages in thread* [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
2013-09-23 18:30 ` Charles Keepax
` (3 preceding siblings ...)
(?)
@ 2013-09-23 18:30 ` Charles Keepax
2013-09-23 21:43 ` Stephen Warren
[not found] ` <1379961043-23762-5-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
-1 siblings, 2 replies; 25+ messages in thread
From: Charles Keepax @ 2013-09-23 18:30 UTC (permalink / raw)
To: lee.jones
Cc: sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel,
Charles Keepax
Add device tree bindings for the pdata needed to configure the MICBIAS
generators.
Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
Documentation/devicetree/bindings/mfd/arizona.txt | 15 ++++++++++++
drivers/mfd/arizona-core.c | 25 +++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
index 09e384c..20730dd 100644
--- a/Documentation/devicetree/bindings/mfd/arizona.txt
+++ b/Documentation/devicetree/bindings/mfd/arizona.txt
@@ -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
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index c8f30c4..6236e16 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -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",
--
1.7.2.5
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
2013-09-23 18:30 ` [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators Charles Keepax
@ 2013-09-23 21:43 ` Stephen Warren
[not found] ` <1379961043-23762-5-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
1 sibling, 0 replies; 25+ messages in thread
From: Stephen Warren @ 2013-09-23 21:43 UTC (permalink / raw)
To: Charles Keepax
Cc: lee.jones, sameo, rob.herring, pawel.moll, mark.rutland,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel
On 09/23/2013 12:30 PM, Charles Keepax wrote:
> Add device tree bindings for the pdata needed to configure the MICBIAS
> generators.
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> + - 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.
> + 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.
^ permalink raw reply [flat|nested] 25+ messages in thread[parent not found: <1379961043-23762-5-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>]
* Re: [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
2013-09-23 18:30 ` [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators Charles Keepax
@ 2013-09-23 22:27 ` Mark Brown
[not found] ` <1379961043-23762-5-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
1 sibling, 0 replies; 25+ messages in thread
From: Mark Brown @ 2013-09-23 22:27 UTC (permalink / raw)
To: Charles Keepax
Cc: lee.jones-QSEj5FYQhm4dnm+yROfE0A, sameo-VuQAYsv1563Yd54FQh9/CA,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ, pawel.moll-5wv7dgnIgG8,
mark.rutland-5wv7dgnIgG8, swarren-3lzwWm7+Weoh9ZMKESR00Q,
ijc+devicetree-KcIKpvwj1kUDXYZnReoRVg, rob-VoJi6FS/r0vR7s880joybQ,
patches-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 971 bytes --]
On Mon, Sep 23, 2013 at 07:30:43PM +0100, Charles Keepax wrote:
> + - 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.
> + 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.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [PATCH 5/5] mfd: arizona: Add device tree bindings for MICBIAS generators
@ 2013-09-23 22:27 ` Mark Brown
0 siblings, 0 replies; 25+ messages in thread
From: Mark Brown @ 2013-09-23 22:27 UTC (permalink / raw)
To: Charles Keepax
Cc: lee.jones, sameo, rob.herring, pawel.moll, mark.rutland, swarren,
ijc+devicetree, rob, patches, devicetree, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 971 bytes --]
On Mon, Sep 23, 2013 at 07:30:43PM +0100, Charles Keepax wrote:
> + - 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.
> + 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.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH 1/5] mfd: arizona: Add device tree helper functions
2013-09-23 18:30 ` Charles Keepax
` (4 preceding siblings ...)
(?)
@ 2013-09-23 21:36 ` Stephen Warren
[not found] ` <5240B464.2010903-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
-1 siblings, 1 reply; 25+ messages in thread
From: Stephen Warren @ 2013-09-23 21:36 UTC (permalink / raw)
To: Charles Keepax
Cc: lee.jones, sameo, rob.herring, pawel.moll, mark.rutland,
ijc+devicetree, rob, broonie, patches, devicetree, linux-kernel
On 09/23/2013 12:30 PM, Charles Keepax wrote:
> 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.
> diff --git a/Documentation/devicetree/bindings/mfd/arizona.txt b/Documentation/devicetree/bindings/mfd/arizona.txt
> - - 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.
^ permalink raw reply [flat|nested] 25+ messages in thread