All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 0/3] regmap: add LE and DT binding for endianness
@ 2014-04-02 10:09 Xiubo Li
  2014-04-02 10:09 ` [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values Xiubo Li
                   ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Xiubo Li @ 2014-04-02 10:09 UTC (permalink / raw)
  To: broonie; +Cc: linux-doc, linux-kernel, Xiubo Li


For this patch series has dependency, so resend them together.


Change in v2:
- resend 'regmap: implement LE formatting/parsing for 16/32-bit values.'
- resend 'regmap: Add the DT binding documentation for endianness'
- fix the commit message of 'regmap: add DT endianness binding support.'




Xiubo Li (3):
  regmap: implement LE formatting/parsing for 16/32-bit values.
  regmap: Add the DT binding documentation for endianness
  regmap: add DT endianness binding support.

 .../bindings/regmap/regmap-endianness.txt          |  49 +++++++
 drivers/base/regmap/regmap.c                       | 141 +++++++++++++++++++--
 2 files changed, 180 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/regmap/regmap-endianness.txt

-- 
1.8.4



^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values.
  2014-04-02 10:09 [PATCHv2 0/3] regmap: add LE and DT binding for endianness Xiubo Li
@ 2014-04-02 10:09 ` Xiubo Li
  2014-04-02 19:42   ` Mark Brown
  2014-04-02 10:09 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 16+ messages in thread
From: Xiubo Li @ 2014-04-02 10:09 UTC (permalink / raw)
  To: broonie; +Cc: linux-doc, linux-kernel, Xiubo Li

Allow busses to request little endianness formatting and
parsing for 16- and 32-bit values. This will be useful to
support regmap-mmio.

For the following the scenarios using the regmap-mmio,
for example:

Index    CPU       Device     Endianess flag for values
----------------------------------------------------------
1        LE        LE         REGMAP_ENDIAN_DEFAULT/NATIVE
2        LE        BE         REGMAP_ENDIAN_BIG
3        BE        BE         REGMAP_ENDIAN_DEFAULT/NATIVE
4        BE        LE         REGMAP_ENDIAN_LITTLE

For one device driver, which will support all the cases above,
needs two boolean properties in DT node like: 'big-endian'
for case 2 and 'little-endian' for case 4, and for cases 1
and 3 they all will be absent.

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/base/regmap/regmap.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6a19515..8e8cea1 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -192,6 +192,13 @@ static void regmap_format_16_be(void *buf, unsigned int val, unsigned int shift)
 	b[0] = cpu_to_be16(val << shift);
 }
 
+static void regmap_format_16_le(void *buf, unsigned int val, unsigned int shift)
+{
+	__le16 *b = buf;
+
+	b[0] = cpu_to_le16(val << shift);
+}
+
 static void regmap_format_16_native(void *buf, unsigned int val,
 				    unsigned int shift)
 {
@@ -216,6 +223,13 @@ static void regmap_format_32_be(void *buf, unsigned int val, unsigned int shift)
 	b[0] = cpu_to_be32(val << shift);
 }
 
+static void regmap_format_32_le(void *buf, unsigned int val, unsigned int shift)
+{
+	__le32 *b = buf;
+
+	b[0] = cpu_to_le32(val << shift);
+}
+
 static void regmap_format_32_native(void *buf, unsigned int val,
 				    unsigned int shift)
 {
@@ -240,6 +254,13 @@ static unsigned int regmap_parse_16_be(const void *buf)
 	return be16_to_cpu(b[0]);
 }
 
+static unsigned int regmap_parse_16_le(const void *buf)
+{
+	const __le16 *b = buf;
+
+	return le16_to_cpu(b[0]);
+}
+
 static void regmap_parse_16_be_inplace(void *buf)
 {
 	__be16 *b = buf;
@@ -247,6 +268,13 @@ static void regmap_parse_16_be_inplace(void *buf)
 	b[0] = be16_to_cpu(b[0]);
 }
 
+static void regmap_parse_16_le_inplace(void *buf)
+{
+	__le16 *b = buf;
+
+	b[0] = le16_to_cpu(b[0]);
+}
+
 static unsigned int regmap_parse_16_native(const void *buf)
 {
 	return *(u16 *)buf;
@@ -269,6 +297,13 @@ static unsigned int regmap_parse_32_be(const void *buf)
 	return be32_to_cpu(b[0]);
 }
 
+static unsigned int regmap_parse_32_le(const void *buf)
+{
+	const __le32 *b = buf;
+
+	return le32_to_cpu(b[0]);
+}
+
 static void regmap_parse_32_be_inplace(void *buf)
 {
 	__be32 *b = buf;
@@ -276,6 +311,13 @@ static void regmap_parse_32_be_inplace(void *buf)
 	b[0] = be32_to_cpu(b[0]);
 }
 
+static void regmap_parse_32_le_inplace(void *buf)
+{
+	__le32 *b = buf;
+
+	b[0] = le32_to_cpu(b[0]);
+}
+
 static unsigned int regmap_parse_32_native(const void *buf)
 {
 	return *(u32 *)buf;
@@ -585,6 +627,11 @@ struct regmap *regmap_init(struct device *dev,
 			map->format.parse_val = regmap_parse_16_be;
 			map->format.parse_inplace = regmap_parse_16_be_inplace;
 			break;
+		case REGMAP_ENDIAN_LITTLE:
+			map->format.format_val = regmap_format_16_le;
+			map->format.parse_val = regmap_parse_16_le;
+			map->format.parse_inplace = regmap_parse_16_le_inplace;
+			break;
 		case REGMAP_ENDIAN_NATIVE:
 			map->format.format_val = regmap_format_16_native;
 			map->format.parse_val = regmap_parse_16_native;
@@ -606,6 +653,11 @@ struct regmap *regmap_init(struct device *dev,
 			map->format.parse_val = regmap_parse_32_be;
 			map->format.parse_inplace = regmap_parse_32_be_inplace;
 			break;
+		case REGMAP_ENDIAN_LITTLE:
+			map->format.format_val = regmap_format_32_le;
+			map->format.parse_val = regmap_parse_32_le;
+			map->format.parse_inplace = regmap_parse_32_le_inplace;
+			break;
 		case REGMAP_ENDIAN_NATIVE:
 			map->format.format_val = regmap_format_32_native;
 			map->format.parse_val = regmap_parse_32_native;
-- 
1.8.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-02 10:09 [PATCHv2 0/3] regmap: add LE and DT binding for endianness Xiubo Li
  2014-04-02 10:09 ` [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values Xiubo Li
@ 2014-04-02 10:09 ` Xiubo Li
  2014-04-02 19:48   ` Mark Brown
  2014-04-02 10:09 ` [PATCHv2 3/3] regmap: add DT endianness binding support Xiubo Li
  2014-04-02 11:14 ` [PATCHv2 0/3] regmap: add LE and DT binding for endianness Haijun.Zhang
  3 siblings, 1 reply; 16+ messages in thread
From: Xiubo Li @ 2014-04-02 10:09 UTC (permalink / raw)
  To: broonie; +Cc: linux-doc, linux-kernel, Xiubo Li

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 .../bindings/regmap/regmap-endianness.txt          | 49 ++++++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regmap/regmap-endianness.txt

diff --git a/Documentation/devicetree/bindings/regmap/regmap-endianness.txt b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
new file mode 100644
index 0000000..045d347
--- /dev/null
+++ b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
@@ -0,0 +1,49 @@
+Device-Tree bindings for regmap endianness
+
+Required properties:
+- reg-endian: Register endianness, this string property could be absent
+  as default endianness, or must be one of 'BE', 'LE' and 'NT'.
+- val-endian: Value endianness, this string property could be absent as
+  default endianness, or must be one of 'BE', 'LE' and 'NT'.
+
+The Endianness flags supported by regmap:
+
+DT properties           Macros
+----------------------------------------
+    'LE'          REGMAP_ENDIAN_LITTLE
+    'BE'          REGMAP_ENDIAN_BIG
+    'NT'          REGMAP_ENDIAN_NATIVE
+    Absent        REGMAP_ENDIAN_DEFAULT
+
+Examples:
+Case 1 : CPU in LE mode & SAI device in BE mode, using mmio.
+sai2: sai@40031000 {
+	      compatible = "fsl,vf610-sai";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      val-endian = 'BE';
+};
+
+Case 2 : CPU in BE mode & SAI device in LE mode, using mmio.
+sai2: sai@40031000 {
+	      compatible = "fsl,vf610-sai";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      val-endian = 'LE';
+};
+
+Case 3 : CPU in LE mode & SAI device in LE mode, using mmio.
+sai2: sai@40031000 {
+	      compatible = "fsl,vf610-sai";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      val-endian = 'NT'; or just absent.
+};
+
+Case 4 : CPU in BE mode & SAI device in BE mode, using mmio.
+sai2: sai@40031000 {
+	      compatible = "fsl,vf610-sai";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      val-endian = 'NT'; or just absent.
+};
-- 
1.8.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCHv2 3/3] regmap: add DT endianness binding support.
  2014-04-02 10:09 [PATCHv2 0/3] regmap: add LE and DT binding for endianness Xiubo Li
  2014-04-02 10:09 ` [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values Xiubo Li
  2014-04-02 10:09 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
@ 2014-04-02 10:09 ` Xiubo Li
  2014-04-02 19:50   ` Mark Brown
  2014-04-02 11:14 ` [PATCHv2 0/3] regmap: add LE and DT binding for endianness Haijun.Zhang
  3 siblings, 1 reply; 16+ messages in thread
From: Xiubo Li @ 2014-04-02 10:09 UTC (permalink / raw)
  To: broonie; +Cc: linux-doc, linux-kernel, Xiubo Li

For many drivers which will support rich endianness of CPU<-->Dev
need define DT properties by itself without the binding support.

The value endianness using regmap-mmio, for example:
Index    CPU       Device     Endianess flag for DT property
------------------------------------------------------------
1        LE        LE         -
2        LE        BE         'big-endian'
3        BE        BE         -
4        BE        LE         'little-endian'

============

Here add DT endianness binding support will define two string
properties of the register and value endiannesses:

'reg-endian' and 'val-endian'.

And the value of them will be:
'LE' : REGMAP_ENDIAN_LITTLE
'BE' : REGMAP_ENDIAN_BIG
'NT' : REGMAP_ENDIAN_NATIVE
Absent : REGMAP_ENDIAN_DEFAULT

The value endianness using regmap-mmio, for example:
Index    CPU       Device     Endianess flag for DT property
------------------------------------------------------------
1        LE        LE         'NT' or absent
2        LE        BE         'BE'
3        BE        BE         'NT' or absent
4        BE        LE         'LE'

Please see the following documetation for detail usage:
    Documentation/devicetree/bindings/regmap/regmap-endianness.txt

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 drivers/base/regmap/regmap.c | 91 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 80 insertions(+), 11 deletions(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 8e8cea1..36a96cc 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -15,6 +15,7 @@
 #include <linux/export.h>
 #include <linux/mutex.h>
 #include <linux/err.h>
+#include <linux/of.h>
 #include <linux/rbtree.h>
 #include <linux/sched.h>
 
@@ -423,6 +424,78 @@ static void regmap_range_exit(struct regmap *map)
 }
 
 /**
+ * of_regmap_endian_get_by_name() - Parse and lookup the endianness referenced
+ * by a device node
+ * @np: pointer to clock consumer node
+ * @name: name of consumer's endianness input
+ *
+ * This function parses the device endianness property, and uses them to
+ * determine the endianness of the registers and values.
+ */
+static int of_regmap_endian_get_by_name(struct device_node *np,
+					const char *endian_name,
+					enum regmap_endian *out_endian)
+{
+	const char *endianness;
+	int ret;
+
+	if (!out_endian)
+		return -EINVAL;
+
+	/* Set the default endianness */
+	*out_endian = REGMAP_ENDIAN_DEFAULT;
+
+	/* Absent or being to use the flag from config of the drivers */
+	if (!of_find_property(np, endian_name, NULL))
+		return 0;
+
+	ret = of_property_read_string(np, endian_name, &endianness);
+	if (ret)
+		return ret;
+
+	if (!strcmp("LE", endianness))
+		*out_endian = REGMAP_ENDIAN_LITTLE;
+	else if (!strcmp("BE", endianness))
+		*out_endian = REGMAP_ENDIAN_BIG;
+	else if (!strcmp("NT", endianness))
+		*out_endian = REGMAP_ENDIAN_NATIVE;
+
+	return 0;
+}
+
+static int of_regmap_get_endian(struct device *dev,
+				const struct regmap_bus *bus,
+				const struct regmap_config *config,
+				const char *endian_name,
+				enum regmap_endian *out_endian)
+{
+	int ret;
+
+	if (!out_endian)
+		return -EINVAL;
+
+	if (dev) {
+		ret = of_regmap_endian_get_by_name(dev->of_node, endian_name,
+						   out_endian);
+		if (ret)
+			return ret;
+	}
+
+	/* To be compatible with the none DT or the old drivers */
+	if (*out_endian != REGMAP_ENDIAN_DEFAULT)
+		return 0;
+
+	/* Parsing the endianness from driver's config or bus */
+	*out_endian = config->reg_format_endian;
+	if (*out_endian == REGMAP_ENDIAN_DEFAULT)
+		*out_endian = bus->reg_format_endian_default;
+	if (*out_endian == REGMAP_ENDIAN_DEFAULT)
+		*out_endian = REGMAP_ENDIAN_BIG;
+
+	return 0;
+}
+
+/**
  * regmap_init(): Initialise register map
  *
  * @dev: Device that will be interacted with
@@ -518,17 +591,13 @@ struct regmap *regmap_init(struct device *dev,
 		map->reg_read  = _regmap_bus_read;
 	}
 
-	reg_endian = config->reg_format_endian;
-	if (reg_endian == REGMAP_ENDIAN_DEFAULT)
-		reg_endian = bus->reg_format_endian_default;
-	if (reg_endian == REGMAP_ENDIAN_DEFAULT)
-		reg_endian = REGMAP_ENDIAN_BIG;
-
-	val_endian = config->val_format_endian;
-	if (val_endian == REGMAP_ENDIAN_DEFAULT)
-		val_endian = bus->val_format_endian_default;
-	if (val_endian == REGMAP_ENDIAN_DEFAULT)
-		val_endian = REGMAP_ENDIAN_BIG;
+	ret = of_regmap_get_endian(dev, bus, config, "reg_endian", &reg_endian);
+	if (ret)
+		return ERR_PTR(ret);
+
+	ret = of_regmap_get_endian(dev, bus, config, "val_endian", &val_endian);
+	if (ret)
+		return ERR_PTR(ret);
 
 	switch (config->reg_bits + map->reg_shift) {
 	case 2:
-- 
1.8.4



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* RE: [PATCHv2 0/3] regmap: add LE and DT binding for endianness
  2014-04-02 10:09 [PATCHv2 0/3] regmap: add LE and DT binding for endianness Xiubo Li
                   ` (2 preceding siblings ...)
  2014-04-02 10:09 ` [PATCHv2 3/3] regmap: add DT endianness binding support Xiubo Li
@ 2014-04-02 11:14 ` Haijun.Zhang
  3 siblings, 0 replies; 16+ messages in thread
From: Haijun.Zhang @ 2014-04-02 11:14 UTC (permalink / raw)
  To: Li.Xiubo, broonie; +Cc: linux-doc, linux-kernel, Li.Xiubo


> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Xiubo Li
> Sent: Wednesday, April 02, 2014 6:09 PM
> To: broonie@kernel.org
> Cc: linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org; Xiubo Li-
> B47053
> Subject: [PATCHv2 0/3] regmap: add LE and DT binding for endianness
>


This patch set is very useful for eSDHC driver, which will support
different endiannesses on both powerpc and arm platforms at the
same time.

And this patch set looks good to me.

> 
> For this patch series has dependency, so resend them together.
> 
> 
> Change in v2:
> - resend 'regmap: implement LE formatting/parsing for 16/32-bit values.'
> - resend 'regmap: Add the DT binding documentation for endianness'
> - fix the commit message of 'regmap: add DT endianness binding support.'
> 
> 
> 
> 
> Xiubo Li (3):
>   regmap: implement LE formatting/parsing for 16/32-bit values.
>   regmap: Add the DT binding documentation for endianness
>   regmap: add DT endianness binding support.
> 
>  .../bindings/regmap/regmap-endianness.txt          |  49 +++++++
>  drivers/base/regmap/regmap.c                       | 141
> +++++++++++++++++++--
>  2 files changed, 180 insertions(+), 10 deletions(-)  create mode 100644
> Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> 
> --
> 1.8.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel"
> in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values.
  2014-04-02 10:09 ` [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values Xiubo Li
@ 2014-04-02 19:42   ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-04-02 19:42 UTC (permalink / raw)
  To: Xiubo Li; +Cc: linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 218 bytes --]

On Wed, Apr 02, 2014 at 06:09:07PM +0800, Xiubo Li wrote:
> Allow busses to request little endianness formatting and
> parsing for 16- and 32-bit values. This will be useful to
> support regmap-mmio.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-02 10:09 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
@ 2014-04-02 19:48   ` Mark Brown
  2014-04-03  7:04     ` Li.Xiubo
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2014-04-02 19:48 UTC (permalink / raw)
  To: Xiubo Li; +Cc: linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

On Wed, Apr 02, 2014 at 06:09:08PM +0800, Xiubo Li wrote:

> +sai2: sai@40031000 {
> +	      compatible = "fsl,vf610-sai";
> +	      reg = <0x40031000 0x1000>;
> +	      ...
> +	      val-endian = 'LE';
> +};

This is mostly OK as a binding (though it should be CCed to the DT list
and maintiners as all DT bindings should) except using upper case
doesn't really seem idiomatic for DT - lower case is more normal - and I
don't think we can make these properties mandatory in themselves.
Individual bindings would need to make them mandatory.  It's also odd to
have a mandatory property which may be absent!

It'd probably be better if the binding defined what the default
endianess was too, or just didn't say what happens in cases where
nothing is specified, the latter seems better.  Generally just not
mentioning regmap is better for a binding definition, the binding should
be usable by all OSs and not just Linux.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 3/3] regmap: add DT endianness binding support.
  2014-04-02 10:09 ` [PATCHv2 3/3] regmap: add DT endianness binding support Xiubo Li
@ 2014-04-02 19:50   ` Mark Brown
  2014-04-03  5:26     ` Li.Xiubo
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2014-04-02 19:50 UTC (permalink / raw)
  To: Xiubo Li; +Cc: linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 474 bytes --]

On Wed, Apr 02, 2014 at 06:09:09PM +0800, Xiubo Li wrote:

> +	ret = of_regmap_get_endian(dev, bus, config, "reg_endian", &reg_endian);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	ret = of_regmap_get_endian(dev, bus, config, "val_endian", &val_endian);
> +	if (ret)
> +		return ERR_PTR(ret);

Actually, if we're going to be doing this for all devices then we
probably need to namespace the properties too.  Not sure what to do for
a prefix though.  One for the DT folks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCHv2 3/3] regmap: add DT endianness binding support.
  2014-04-02 19:50   ` Mark Brown
@ 2014-04-03  5:26     ` Li.Xiubo
  2014-04-14 21:07       ` Mark Brown
  0 siblings, 1 reply; 16+ messages in thread
From: Li.Xiubo @ 2014-04-03  5:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-doc, linux-kernel


> Subject: Re: [PATCHv2 3/3] regmap: add DT endianness binding support.
> 
> On Wed, Apr 02, 2014 at 06:09:09PM +0800, Xiubo Li wrote:
> 
> > +	ret = of_regmap_get_endian(dev, bus, config, "reg_endian", &reg_endian);
> > +	if (ret)
> > +		return ERR_PTR(ret);
> > +
> > +	ret = of_regmap_get_endian(dev, bus, config, "val_endian", &val_endian);
> > +	if (ret)
> > +		return ERR_PTR(ret);
> 
> Actually, if we're going to be doing this for all devices then we
> probably need to namespace the properties too.  Not sure what to do for
> a prefix though.  One for the DT folks.

How about using one prefix string of each regmap bus?
Such as:
Prefix 'regmap-mmio' for regmap-mmio,
Prefix 'regmap-i2c' for regmap-i2c,
Precix 'regmap-spi' for regmap-spi
...

Or just using the same prefix 'regmap' for all of them ?

Thanks,

BRs
Xiubo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-02 19:48   ` Mark Brown
@ 2014-04-03  7:04     ` Li.Xiubo
  2014-04-14 21:09       ` Mark Brown
  0 siblings, 1 reply; 16+ messages in thread
From: Li.Xiubo @ 2014-04-03  7:04 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-doc, linux-kernel

> Subject: Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for
> endianness
> 
> On Wed, Apr 02, 2014 at 06:09:08PM +0800, Xiubo Li wrote:
> 
> > +sai2: sai@40031000 {
> > +	      compatible = "fsl,vf610-sai";
> > +	      reg = <0x40031000 0x1000>;
> > +	      ...
> > +	      val-endian = 'LE';
> > +};
> 
> This is mostly OK as a binding (though it should be CCed to the DT list
> and maintiners as all DT bindings should) except using upper case
> doesn't really seem idiomatic for DT - lower case is more normal - 

I will your advices.


> and I
> don't think we can make these properties mandatory in themselves.
> Individual bindings would need to make them mandatory.  It's also odd to
> have a mandatory property which may be absent!

Well, yes, It is.

The absent one is just to compatible with the old drivers.



> 
> It'd probably be better if the binding defined what the default
> endianess was too, or just didn't say what happens in cases where
> nothing is specified, the latter seems better.  

I will think it over carefully.


> Generally just not
> mentioning regmap is better for a binding definition, the binding should
> be usable by all OSs and not just Linux.

How about move the endianness OF parsing to the driver/of/ ?
Is this will be better ?

Thanks,

BRs
Xiubo




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 3/3] regmap: add DT endianness binding support.
  2014-04-03  5:26     ` Li.Xiubo
@ 2014-04-14 21:07       ` Mark Brown
  0 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2014-04-14 21:07 UTC (permalink / raw)
  To: Li.Xiubo; +Cc: linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 595 bytes --]

On Thu, Apr 03, 2014 at 05:26:57AM +0000, Li.Xiubo@freescale.com wrote:

> > Actually, if we're going to be doing this for all devices then we
> > probably need to namespace the properties too.  Not sure what to do for
> > a prefix though.  One for the DT folks.

> How about using one prefix string of each regmap bus?
> Such as:
> Prefix 'regmap-mmio' for regmap-mmio,
> Prefix 'regmap-i2c' for regmap-i2c,
> Precix 'regmap-spi' for regmap-spi
> ...

> Or just using the same prefix 'regmap' for all of them ?

I don't see any point in defining separate per bus properties so just
one prefix.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-03  7:04     ` Li.Xiubo
@ 2014-04-14 21:09       ` Mark Brown
  2014-04-23  5:08         ` Li.Xiubo
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Brown @ 2014-04-14 21:09 UTC (permalink / raw)
  To: Li.Xiubo; +Cc: linux-doc, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 438 bytes --]

On Thu, Apr 03, 2014 at 07:04:00AM +0000, Li.Xiubo@freescale.com wrote:

> > Generally just not
> > mentioning regmap is better for a binding definition, the binding should
> > be usable by all OSs and not just Linux.

> How about move the endianness OF parsing to the driver/of/ ?
> Is this will be better ?

Where the code is is sensible enough, it's an issue about how the
binding documentation was written rather than about the code.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-14 21:09       ` Mark Brown
@ 2014-04-23  5:08         ` Li.Xiubo
  0 siblings, 0 replies; 16+ messages in thread
From: Li.Xiubo @ 2014-04-23  5:08 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-doc, linux-kernel





> -----Original Message-----
> From: Mark Brown [mailto:broonie@kernel.org]
> Sent: Tuesday, April 15, 2014 5:10 AM
> To: Xiubo Li-B47053
> Cc: linux-doc@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for
> endianness
> 
> On Thu, Apr 03, 2014 at 07:04:00AM +0000, Li.Xiubo@freescale.com wrote:
> 
> > > Generally just not
> > > mentioning regmap is better for a binding definition, the binding should
> > > be usable by all OSs and not just Linux.
> 
> > How about move the endianness OF parsing to the driver/of/ ?
> > Is this will be better ?
> 
> Where the code is is sensible enough, it's an issue about how the
> binding documentation was written rather than about the code.

Sorry for late.

Well, I will try to enhance this.

Thanks,

BRs
Xiubo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* RE: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-23  8:40   ` Mark Rutland
@ 2014-04-28  8:52     ` Li.Xiubo
  0 siblings, 0 replies; 16+ messages in thread
From: Li.Xiubo @ 2014-04-28  8:52 UTC (permalink / raw)
  To: Mark Rutland
  Cc: broonie, rob, robh+dt, Pawel Moll, ijc+devicetree, galak,
	linux-doc, linux-kernel

> Subject: Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for
> endianness
> 
> On Wed, Apr 23, 2014 at 07:46:34AM +0100, Xiubo Li wrote:
> > Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> > ---
> >  .../bindings/regmap/regmap-endianness.txt          | 48
> ++++++++++++++++++++++
> >  1 file changed, 48 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/regmap/regmap-
> endianness.txt
> >
> > diff --git a/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> > new file mode 100644
> > index 0000000..1d838c5
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> > @@ -0,0 +1,48 @@
> > +Device-Tree bindings for regmap endianness
> 
> As regmap is a Linux internal detail, I don't see why it needs to leak
> into bindings.
> 
> > +Required properties:
> > +- regmap-reg-endian: register endianness, see ../endianness/endianness.txt
> > +  for detail.
> > +- regmap-val-endian: value endianness, see ../endianness/endianness.txt for
> 
> I'm not familiar with regmap. What is the difference between register
> and value endianness?
>

Sorry for late, I'm very busy these days.

The register endianness here is used for the I2C and SPI protocol, which will
Send the register address(which maybe 8-bit or 16-bit) before its values.
 
BRs
Xiubo

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-23  6:46 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
@ 2014-04-23  8:40   ` Mark Rutland
  2014-04-28  8:52     ` Li.Xiubo
  0 siblings, 1 reply; 16+ messages in thread
From: Mark Rutland @ 2014-04-23  8:40 UTC (permalink / raw)
  To: Xiubo Li
  Cc: broonie, rob, robh+dt, Pawel Moll, ijc+devicetree, galak,
	linux-doc, linux-kernel

On Wed, Apr 23, 2014 at 07:46:34AM +0100, Xiubo Li wrote:
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---
>  .../bindings/regmap/regmap-endianness.txt          | 48 ++++++++++++++++++++++
>  1 file changed, 48 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> 
> diff --git a/Documentation/devicetree/bindings/regmap/regmap-endianness.txt b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> new file mode 100644
> index 0000000..1d838c5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
> @@ -0,0 +1,48 @@
> +Device-Tree bindings for regmap endianness

As regmap is a Linux internal detail, I don't see why it needs to leak
into bindings.

> +Required properties:
> +- regmap-reg-endian: register endianness, see ../endianness/endianness.txt
> +  for detail.
> +- regmap-val-endian: value endianness, see ../endianness/endianness.txt for

I'm not familiar with regmap. What is the difference between register
and value endianness?

> +  detail.
> +
> +The Endianness flags supported by regmap:
> +DT properties           Macros
> +----------------------------------------
> +    'le'          REGMAP_ENDIAN_LITTLE
> +    'be'          REGMAP_ENDIAN_BIG
> +    'native'      REGMAP_ENDIAN_NATIVE
> +    Absent        REGMAP_ENDIAN_DEFAULT

As mentinoned earlier, I think we should stick to the common convention
of device-specific {big,little}-endian{,-*} boolean properties. The
common case might just be a simple big-endian property, with LE assumed
(or the inverse with a little-endian property).

Cheers,
Mark.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness
  2014-04-23  6:46 [PATCHv2 0/3] add DT endianness binding support Xiubo Li
@ 2014-04-23  6:46 ` Xiubo Li
  2014-04-23  8:40   ` Mark Rutland
  0 siblings, 1 reply; 16+ messages in thread
From: Xiubo Li @ 2014-04-23  6:46 UTC (permalink / raw)
  To: broonie, rob
  Cc: robh+dt, pawel.moll, mark.rutland, ijc+devicetree, galak,
	linux-doc, linux-kernel, Xiubo Li

Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
---
 .../bindings/regmap/regmap-endianness.txt          | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/regmap/regmap-endianness.txt

diff --git a/Documentation/devicetree/bindings/regmap/regmap-endianness.txt b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
new file mode 100644
index 0000000..1d838c5
--- /dev/null
+++ b/Documentation/devicetree/bindings/regmap/regmap-endianness.txt
@@ -0,0 +1,48 @@
+Device-Tree bindings for regmap endianness
+
+Required properties:
+- regmap-reg-endian: register endianness, see ../endianness/endianness.txt
+  for detail.
+- regmap-val-endian: value endianness, see ../endianness/endianness.txt for
+  detail.
+
+The Endianness flags supported by regmap:
+DT properties           Macros
+----------------------------------------
+    'le'          REGMAP_ENDIAN_LITTLE
+    'be'          REGMAP_ENDIAN_BIG
+    'native'      REGMAP_ENDIAN_NATIVE
+    Absent        REGMAP_ENDIAN_DEFAULT
+
+Examples for using the regmap-mmio:
+Scenario 1 : CPU in LE mode & device in LE mode.
+dev: dev@40031000 {
+	      compatible = "name";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      regmap-val-endian = 'native'; or just absent.
+};
+
+Scenario 2 : CPU in LE mode & device in BE mode.
+dev: dev@40031000 {
+	      compatible = "name";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      regmap-val-endian = 'be';
+};
+
+Scenario 3 : CPU in BE mode & device in BE mode.
+dev: dev@40031000 {
+	      compatible = "name";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      regmap-val-endian = 'native'; or just absent.
+};
+
+Scenario 4 : CPU in BE mode & device in LE mode.
+dev: dev@40031000 {
+	      compatible = "name";
+	      reg = <0x40031000 0x1000>;
+	      ...
+	      regmap-val-endian = 'le';
+};
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2014-04-28  8:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-02 10:09 [PATCHv2 0/3] regmap: add LE and DT binding for endianness Xiubo Li
2014-04-02 10:09 ` [PATCHv2 1/3] regmap: implement LE formatting/parsing for 16/32-bit values Xiubo Li
2014-04-02 19:42   ` Mark Brown
2014-04-02 10:09 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
2014-04-02 19:48   ` Mark Brown
2014-04-03  7:04     ` Li.Xiubo
2014-04-14 21:09       ` Mark Brown
2014-04-23  5:08         ` Li.Xiubo
2014-04-02 10:09 ` [PATCHv2 3/3] regmap: add DT endianness binding support Xiubo Li
2014-04-02 19:50   ` Mark Brown
2014-04-03  5:26     ` Li.Xiubo
2014-04-14 21:07       ` Mark Brown
2014-04-02 11:14 ` [PATCHv2 0/3] regmap: add LE and DT binding for endianness Haijun.Zhang
2014-04-23  6:46 [PATCHv2 0/3] add DT endianness binding support Xiubo Li
2014-04-23  6:46 ` [PATCHv2 2/3] regmap: Add the DT binding documentation for endianness Xiubo Li
2014-04-23  8:40   ` Mark Rutland
2014-04-28  8:52     ` Li.Xiubo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.