Skip to contentSkip to conversation

bus: imx-weim: support CS GPR configuration

PATCH Superseded Shawn Guo 3 participants 8 messages Feb 16, 2014 – Feb 17, 2014

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Shawn Guo

author
#0 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

Depending on which configuration of the following 4 is chosen for given system, IOMUXC_GPR1[11:0] should be set up as 05, 033, 0113 or 01111 correspondingly.

	CS0(128M) CS1(0M)  CS2(0M)  CS3(0M)
	CS0(64M)  CS1(64M) CS2(0M)  CS3(0M)
	CS0(64M)  CS1(32M) CS2(32M) CS3(0M)
	CS0(32M)  CS1(32M) CS2(32M) CS3(32M)

The patch creates a function for such type of devices, which scans 'ranges' property of WEIM node and build the GPR value incrementally. Thus the WEIM CS GPR can be set up automatically at boot time.

---
Changes since v3:
- Add DT property fsl,weim-cs-gpr back, so that the support can work for more i.MX SoCs than just i.MX6Q.

 Documentation/devicetree/bindings/bus/imx-weim.txt |   27 +++++++++-
 drivers/bus/imx-weim.c                             |   55 ++++++++++++++++++++
 2 files changed, 81 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/bus/imx-weim.txt +26 -1
index 0fd76c4..363c970 100644
@@ -8,7 +8,12 @@ The actual devices are instantiated from the child nodes of a WEIM node.
 
 Required properties:
 
- - compatible:		Should be set to "fsl,<soc>-weim"
+ - compatible:		Should contain one of the following:
+			  "fsl,imx1-weim"
+			  "fsl,imx27-weim"
+			  "fsl,imx51-weim"
+			  "fsl,imx50-weim"
+			  "fsl,imx6q-weim"
  - reg:			A resource specifier for the register space
 			(see the example below)
  - clocks:		the clock, see the example below.
@@ -19,6 +24,26 @@ Required properties:
 
 			   <cs-number> 0 <physical address of mapping> <size>
 
+Optional properties:
+
+ - fsl,weim-cs-gpr:	For "fsl,imx50-weim" and "fsl,imx6q-weim" type of
+			devices, it should be the phandle to the system General
+			Purpose Register controller that contains WEIM CS GPR
+			register, e.g. IOMUXC_GPR1 on i.MX6Q.  IOMUXC_GPR1[11:0]
+			should be set up as one of the following 4 possible
+			values depending on the CS space configuration.
+
+			IOMUXC_GPR1[11:0]    CS0    CS1    CS2    CS3
+			---------------------------------------------
+				05	    128M     0M     0M     0M
+				033          64M    64M     0M     0M
+				0113         64M    32M    32M     0M
+				01111        32M    32M    32M    32M
+
+			In case that the property is absent, the reset value or
+			what bootloader sets up in IOMUXC_GPR1[11:0] will be
+			used.
+
 Timing property for child nodes. It is mandatory, not optional.
 
  - fsl,weim-cs-timing:	The timing array, contains timing values for the
drivers/bus/imx-weim.c +55 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw

???????????, 16 ??????? 2014, 22:03 +08:00 ?? Shawn Guo <[email protected]>:

Quoted 3 lines

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

...

Quoted 11 lines
drivers/bus/imx-weim.c +11 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 82

Quoted 10 lines
drivers/bus/imx-weim.c +10 -0
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;

Only one comment:
You do not use these error codes in the probe(),
so let's declare this function as void.

---

author
#2 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

Quoted 22 lines · Alexander Shiyan

???????????, 16 ??????? 2014, 22:03 +08:00 ?? Shawn Guo <[email protected]>:

Quoted 3 lines

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

...

Quoted 17 lines
drivers/bus/imx-weim.c +17 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
Quoted 8 lines

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 82

Quoted 4 lines
drivers/bus/imx-weim.c +4 -0
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;

Only one comment:
You do not use these error codes in the probe(),
so let's declare this function as void.

Oh, yes. I should check return of imx_weim_gpr_setup() in probe(). Will add in the next version.

Shawn

#3 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

Quoted 32 lines · Shawn Guo
Quoted 22 lines · Alexander Shiyan

???????????, 16 ??????? 2014, 22:03 +08:00 ?? Shawn Guo <[email protected]>:

Quoted 3 lines

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

...

Quoted 17 lines
drivers/bus/imx-weim.c +17 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
Quoted 8 lines

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 82

Quoted 4 lines
drivers/bus/imx-weim.c +4 -0
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;

Only one comment:
You do not use these error codes in the probe(),
so let's declare this function as void.

Quoted 2 lines

Oh, yes. I should check return of imx_weim_gpr_setup() in probe(). Will add in the next version.

Well, as all the error cases are already covered by error messages, there is no added value in testing that again in probe(). As Alexander wrote, you can declare imx_weim_gpr_setup() as 'void'.

Philippe

Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
author
#4 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

Quoted 33 lines · Philippe De Muyter
Quoted 32 lines · Shawn Guo
Quoted 30 lines · Alexander Shiyan

???????????, 16 ??????? 2014, 22:03 +08:00 ?? Shawn Guo <[email protected]>:

Quoted 3 lines

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

...

Quoted 11 lines
drivers/bus/imx-weim.c +11 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 82

Quoted 10 lines
drivers/bus/imx-weim.c +10 -0
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;

Only one comment:
You do not use these error codes in the probe(),
so let's declare this function as void.

Quoted 6 lines
Quoted 2 lines

Oh, yes. I should check return of imx_weim_gpr_setup() in probe(). Will add in the next version.

Well, as all the error cases are already covered by error messages, there is no added value in testing that again in probe(). As Alexander wrote, you can declare imx_weim_gpr_setup() as 'void'.

Hmm, shouldn't we stop probing when running into the error of invalid ranges configuration?

Shawn

#5 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

Quoted 37 lines · Shawn Guo
Quoted 36 lines · Philippe De Muyter
Quoted 34 lines · Shawn Guo
Quoted 22 lines · Alexander Shiyan

???????????, 16 ??????? 2014, 22:03 +08:00 ?? Shawn Guo <[email protected]>:

Quoted 3 lines

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

...

Quoted 17 lines
drivers/bus/imx-weim.c +17 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
Quoted 8 lines

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 82

Quoted 4 lines
drivers/bus/imx-weim.c +4 -0
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;

Only one comment:
You do not use these error codes in the probe(),
so let's declare this function as void.

Oh, yes. I should check return of imx_weim_gpr_setup() in probe(). Will add in the next version.

Quoted 6 lines
Quoted 3 lines

Well, as all the error cases are already covered by error messages, there is no added value in testing that again in probe(). As Alexander wrote, you can declare imx_weim_gpr_setup() as 'void'.

Hmm, shouldn't we stop probing when running into the error of invalid ranges configuration?

I agree, we could do that :)

Philippe

Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
#6 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

In reply to Shawn Guo
Quoted 62 lines · Shawn Guo

For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q.

Depending on which configuration of the following 4 is chosen for given system, IOMUXC_GPR1[11:0] should be set up as 05, 033, 0113 or 01111 correspondingly.

	CS0(128M) CS1(0M)  CS2(0M)  CS3(0M)
	CS0(64M)  CS1(64M) CS2(0M)  CS3(0M)
	CS0(64M)  CS1(32M) CS2(32M) CS3(0M)
	CS0(32M)  CS1(32M) CS2(32M) CS3(32M)

The patch creates a function for such type of devices, which scans 'ranges' property of WEIM node and build the GPR value incrementally. Thus the WEIM CS GPR can be set up automatically at boot time.

---
Changes since v3:
- Add DT property fsl,weim-cs-gpr back, so that the support can work for more i.MX SoCs than just i.MX6Q.

 Documentation/devicetree/bindings/bus/imx-weim.txt |   27 +++++++++-
 drivers/bus/imx-weim.c                             |   55 ++++++++++++++++++++
 2 files changed, 81 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/bus/imx-weim.txt +19 -1
index 0fd76c4..363c970 100644
@@ -8,7 +8,12 @@ The actual devices are instantiated from the child nodes of a WEIM node.
 
 Required properties:
 
- - compatible:		Should be set to "fsl,<soc>-weim"
+ - compatible:		Should contain one of the following:
+			  "fsl,imx1-weim"
+			  "fsl,imx27-weim"
+			  "fsl,imx51-weim"
+			  "fsl,imx50-weim"
+			  "fsl,imx6q-weim"
  - reg:			A resource specifier for the register space
 			(see the example below)
  - clocks:		the clock, see the example below.
@@ -19,6 +24,26 @@ Required properties:
 
 			   <cs-number> 0 <physical address of mapping> <size>
 
+Optional properties:
+
+ - fsl,weim-cs-gpr:	For "fsl,imx50-weim" and "fsl,imx6q-weim" type of
+			devices, it should be the phandle to the system General
+			Purpose Register controller that contains WEIM CS GPR
+			register, e.g. IOMUXC_GPR1 on i.MX6Q.  IOMUXC_GPR1[11:0]
+			should be set up as one of the following 4 possible
+			values depending on the CS space configuration.
+
+			IOMUXC_GPR1[11:0]    CS0    CS1    CS2    CS3
+			---------------------------------------------
+				05	    128M     0M     0M     0M
+				033          64M    64M     0M     0M

Documentation/devicetree/bindings/bus/imx-weim.txt Required properties: · line 49

Quoted 10 lines
Documentation/devicetree/bindings/bus/imx-weim.txt +7 -0
+				0113         64M    32M    32M     0M
+				01111        32M    32M    32M    32M
+
+			In case that the property is absent, the reset value or
+			what bootloader sets up in IOMUXC_GPR1[11:0] will be
+			used.
+
 Timing property for child nodes. It is mandatory, not optional.
 
  - fsl,weim-cs-timing:	The timing array, contains timing values for the

Could you also add the following line to the example in the same file :

		fsl,weim-cs-gpr = <&gpr>;

It took me some time to figure it out :)

Quoted 19 lines
drivers/bus/imx-weim.c +4 -0
index 3ef58c8..35e9529 100644
@@ -11,6 +11,9 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
+#include <linux/regmap.h>
 
 struct imx_weim_devtype {
 	unsigned int	cs_count;
@@ -56,6 +59,55 @@ static const struct of_device_id weim_id_table[] = {
 };
 MODULE_DEVICE_TABLE(of, weim_id_table);
 
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 72

Quoted 10 lines
drivers/bus/imx-weim.c +10 -0
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
			   CS0(32M)			CS3(32M)
Quoted 54 lines
drivers/bus/imx-weim.c +41 -0
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;
+	}
+
+	of_property_for_each_u32(np, "ranges", prop, p, val) {
+		if (i % 4 == 0) {
+			cs = val;
+		} else if (i % 4 == 3 && val) {
+			val = (val / SZ_32M) | 1;
+			gprval |= val << cs * 3;
+		}
+		i++;
+	}
+
+	if (i == 0 || i % 4)
+		goto err;
+
+	for (i = 0; i < ARRAY_SIZE(gprvals); i++) {
+		if (gprval == gprvals[i]) {
+			/* Found it. Set up IOMUXC_GPR1[11:0] with it. */
+			regmap_update_bits(gpr, IOMUXC_GPR1, 0xfff, gprval);
+			return 0;
+		}
+	}
+
+err:
+	dev_err(&pdev->dev, "Invalid 'ranges' configuration\n");
+	return -EINVAL;
+}
+
 /* Parse and set the timing for this device. */
 static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
 				    const struct imx_weim_devtype *devtype)
@@ -92,6 +144,9 @@ static int __init weim_parse_dt(struct platform_device *pdev,
 	struct device_node *child;
 	int ret;
 
+	if (devtype == &imx50_weim_devtype)
+		imx_weim_gpr_setup(pdev);
+
 	for_each_child_of_node(pdev->dev.of_node, child) {
 		if (!child->name)
 			continue;
Signature · 1 line
1.7.9.5
Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles
author
#7 lore raw

PATCH v4 1/1 bus: imx-weim: support CS GPR configuration

Quoted 26 lines · Philippe De Muyter
Quoted 26 lines
Documentation/devicetree/bindings/bus/imx-weim.txt +20 -0
@@ -19,6 +24,26 @@ Required properties:
 
 			   <cs-number> 0 <physical address of mapping> <size>
 
+Optional properties:
+
+ - fsl,weim-cs-gpr:	For "fsl,imx50-weim" and "fsl,imx6q-weim" type of
+			devices, it should be the phandle to the system General
+			Purpose Register controller that contains WEIM CS GPR
+			register, e.g. IOMUXC_GPR1 on i.MX6Q.  IOMUXC_GPR1[11:0]
+			should be set up as one of the following 4 possible
+			values depending on the CS space configuration.
+
+			IOMUXC_GPR1[11:0]    CS0    CS1    CS2    CS3
+			---------------------------------------------
+				05	    128M     0M     0M     0M
+				033          64M    64M     0M     0M
+				0113         64M    32M    32M     0M
+				01111        32M    32M    32M    32M
+
+			In case that the property is absent, the reset value or
+			what bootloader sets up in IOMUXC_GPR1[11:0] will be
+			used.
+
 Timing property for child nodes. It is mandatory, not optional.
 
Quoted 7 lines

Documentation/devicetree/bindings/bus/imx-weim.txt Required properties: · line 49

Quoted 1 line
Documentation/devicetree/bindings/bus/imx-weim.txt +0 -0
  - fsl,weim-cs-timing:	The timing array, contains timing values for the

Could you also add the following line to the example in the same file :

		fsl,weim-cs-gpr = <&gpr>;

It took me some time to figure it out :)

Okay. I will wait comments from DT folks on the binding update for a while, and then send out v5.

Quoted 19 lines
Quoted 19 lines
drivers/bus/imx-weim.c +3 -0
index 3ef58c8..35e9529 100644
@@ -11,6 +11,9 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of_device.h>
+#include <linux/mfd/syscon.h>
+#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
+#include <linux/regmap.h>
 
 struct imx_weim_devtype {
 	unsigned int	cs_count;
@@ -56,6 +59,55 @@ static const struct of_device_id weim_id_table[] = {
 };
 MODULE_DEVICE_TABLE(of, weim_id_table);
 
Quoted 13 lines

drivers/bus/imx-weim.c static const struct of_device_id weim_id_table[] = { · line 72

Quoted 11 lines
drivers/bus/imx-weim.c +11 -0
+static int __init imx_weim_gpr_setup(struct platform_device *pdev)
+{
+	struct device_node *np = pdev->dev.of_node;
+	struct property *prop;
+	const __be32 *p;
+	struct regmap *gpr;
+	u32 gprvals[4] = {
+		05,	/* CS0(128M) CS1(0M)  CS2(0M)  CS3(0M) */
+		033,	/* CS0(64M)  CS1(64M) CS2(0M)  CS3(0M) */
+		0113,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
+		01111,	/* CS0(64M)  CS1(32M) CS2(32M) CS3(0M) */
			   CS0(32M)			CS3(32M)

Sure, thanks.

Shawn

Quoted 58 lines
Quoted 55 lines
drivers/bus/imx-weim.c +41 -0
+	};
+	u32 gprval = 0;
+	u32 val;
+	int cs = 0;
+	int i = 0;
+
+	gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr");
+	if (IS_ERR(gpr)) {
+		dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n");
+		return 0;
+	}
+
+	of_property_for_each_u32(np, "ranges", prop, p, val) {
+		if (i % 4 == 0) {
+			cs = val;
+		} else if (i % 4 == 3 && val) {
+			val = (val / SZ_32M) | 1;
+			gprval |= val << cs * 3;
+		}
+		i++;
+	}
+
+	if (i == 0 || i % 4)
+		goto err;
+
+	for (i = 0; i < ARRAY_SIZE(gprvals); i++) {
+		if (gprval == gprvals[i]) {
+			/* Found it. Set up IOMUXC_GPR1[11:0] with it. */
+			regmap_update_bits(gpr, IOMUXC_GPR1, 0xfff, gprval);
+			return 0;
+		}
+	}
+
+err:
+	dev_err(&pdev->dev, "Invalid 'ranges' configuration\n");
+	return -EINVAL;
+}
+
 /* Parse and set the timing for this device. */
 static int __init weim_timing_setup(struct device_node *np, void __iomem *base,
 				    const struct imx_weim_devtype *devtype)
@@ -92,6 +144,9 @@ static int __init weim_parse_dt(struct platform_device *pdev,
 	struct device_node *child;
 	int ret;
 
+	if (devtype == &imx50_weim_devtype)
+		imx_weim_gpr_setup(pdev);
+
 	for_each_child_of_node(pdev->dev.of_node, child) {
 		if (!child->name)
 			continue;
Signature · 1 line
1.7.9.5
Signature · 1 line
Philippe De Muyter +32 2 6101532 Macq SA rue de l'Aeronef 2 B-1140 Bruxelles