[RESEND PATCH] usb: dwc2: Add reset control to dwc2

2016-06-21 Thread dinguyen
From: Dinh Nguyen 

Allow for platforms that have a reset controller driver in place to bring
the USB IP out of reset.

Signed-off-by: Dinh Nguyen 
Acked-by: John Youn 
Tested-by: Stefan Wahren 
Acked-by: Felipe Balbi 
---
v7: Use devm_reset_control_get_optional()
v6: fix 80 line checkpatch warning in dev_err print
v5: updated error conditions for not finding the reset property
v4: use dev_dbg() if not a -EPROBE_DEFER
v3: fix compile error
v2: move to lowlevel_hw_init()
---
 drivers/usb/dwc2/core.h |1 +
 drivers/usb/dwc2/platform.c |   22 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 3c58d63..f748132 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -837,6 +837,7 @@ struct dwc2_hsotg {
void *priv;
int irq;
struct clk *clk;
+   struct reset_control *reset;
 
unsigned int queuing_high_bandwidth:1;
unsigned int srp_success:1;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 88629be..d34f169 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -337,6 +338,24 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
int i, ret;
 
+   hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
+   if (IS_ERR(hsotg->reset)) {
+   ret = PTR_ERR(hsotg->reset);
+   switch (ret) {
+   case -ENOENT:
+   case -ENOTSUPP:
+   hsotg->reset = NULL;
+   break;
+   default:
+   dev_err(hsotg->dev, "error getting reset control %d\n",
+   ret);
+   return ret;
+   }
+   }
+
+   if (hsotg->reset)
+   reset_control_deassert(hsotg->reset);
+
/* Set default UTMI width */
hsotg->phyif = GUSBCFG_PHYIF16;
 
@@ -434,6 +453,9 @@ static int dwc2_driver_remove(struct platform_device *dev)
if (hsotg->ll_hw_enabled)
dwc2_lowlevel_hw_disable(hsotg);
 
+   if (hsotg->reset)
+   reset_control_assert(hsotg->reset);
+
return 0;
 }
 
-- 
1.7.9.5



[RESEND PATCH] usb: dwc2: Add reset control to dwc2

2016-06-21 Thread dinguyen
From: Dinh Nguyen 

Allow for platforms that have a reset controller driver in place to bring
the USB IP out of reset.

Signed-off-by: Dinh Nguyen 
Acked-by: John Youn 
Tested-by: Stefan Wahren 
Acked-by: Felipe Balbi 
---
v7: Use devm_reset_control_get_optional()
v6: fix 80 line checkpatch warning in dev_err print
v5: updated error conditions for not finding the reset property
v4: use dev_dbg() if not a -EPROBE_DEFER
v3: fix compile error
v2: move to lowlevel_hw_init()
---
 drivers/usb/dwc2/core.h |1 +
 drivers/usb/dwc2/platform.c |   22 ++
 2 files changed, 23 insertions(+)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 3c58d63..f748132 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -837,6 +837,7 @@ struct dwc2_hsotg {
void *priv;
int irq;
struct clk *clk;
+   struct reset_control *reset;
 
unsigned int queuing_high_bandwidth:1;
unsigned int srp_success:1;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 88629be..d34f169 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -337,6 +338,24 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 {
int i, ret;
 
+   hsotg->reset = devm_reset_control_get_optional(hsotg->dev, "dwc2");
+   if (IS_ERR(hsotg->reset)) {
+   ret = PTR_ERR(hsotg->reset);
+   switch (ret) {
+   case -ENOENT:
+   case -ENOTSUPP:
+   hsotg->reset = NULL;
+   break;
+   default:
+   dev_err(hsotg->dev, "error getting reset control %d\n",
+   ret);
+   return ret;
+   }
+   }
+
+   if (hsotg->reset)
+   reset_control_deassert(hsotg->reset);
+
/* Set default UTMI width */
hsotg->phyif = GUSBCFG_PHYIF16;
 
@@ -434,6 +453,9 @@ static int dwc2_driver_remove(struct platform_device *dev)
if (hsotg->ll_hw_enabled)
dwc2_lowlevel_hw_disable(hsotg);
 
+   if (hsotg->reset)
+   reset_control_assert(hsotg->reset);
+
return 0;
 }
 
-- 
1.7.9.5



[PATCHv2] clk: socfpga: allow for multiple parents on Arria10 periph clocks

2016-02-22 Thread dinguyen
From: Dinh Nguyen 

There are some Arria10 clocks of type "altr,socfpga-a10-perip-clk" that can
have multiple parents. Fix up the __socfpga_periph_init() to call
of_clk_parent_fill() that will return the appropriate number of parents.

Also, update __socfpga_gate_init() to call of_clk_parent_fill() helper
function.

Signed-off-by: Dinh Nguyen 
---
v2: fix compile warnings
---
 drivers/clk/socfpga/clk-gate-a10.c   | 6 +-
 drivers/clk/socfpga/clk-periph-a10.c | 7 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate-a10.c 
b/drivers/clk/socfpga/clk-gate-a10.c
index 1cebf25..c2d5727 100644
--- a/drivers/clk/socfpga/clk-gate-a10.c
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -115,7 +115,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -167,12 +166,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-periph-a10.c 
b/drivers/clk/socfpga/clk-periph-a10.c
index 1f397cb..70993f1 100644
--- a/drivers/clk/socfpga/clk-periph-a10.c
+++ b/drivers/clk/socfpga/clk-periph-a10.c
@@ -74,7 +74,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -109,9 +109,8 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.ops = ops;
init.flags = 0;
 
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.num_parents = 1;
-   init.parent_names = _name;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk->hw.hw.init = 
 
-- 
2.6.2



[PATCHv2] clk: socfpga: allow for multiple parents on Arria10 periph clocks

2016-02-22 Thread dinguyen
From: Dinh Nguyen 

There are some Arria10 clocks of type "altr,socfpga-a10-perip-clk" that can
have multiple parents. Fix up the __socfpga_periph_init() to call
of_clk_parent_fill() that will return the appropriate number of parents.

Also, update __socfpga_gate_init() to call of_clk_parent_fill() helper
function.

Signed-off-by: Dinh Nguyen 
---
v2: fix compile warnings
---
 drivers/clk/socfpga/clk-gate-a10.c   | 6 +-
 drivers/clk/socfpga/clk-periph-a10.c | 7 +++
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate-a10.c 
b/drivers/clk/socfpga/clk-gate-a10.c
index 1cebf25..c2d5727 100644
--- a/drivers/clk/socfpga/clk-gate-a10.c
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -115,7 +115,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -167,12 +166,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-periph-a10.c 
b/drivers/clk/socfpga/clk-periph-a10.c
index 1f397cb..70993f1 100644
--- a/drivers/clk/socfpga/clk-periph-a10.c
+++ b/drivers/clk/socfpga/clk-periph-a10.c
@@ -74,7 +74,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -109,9 +109,8 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.ops = ops;
init.flags = 0;
 
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.num_parents = 1;
-   init.parent_names = _name;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk->hw.hw.init = 
 
-- 
2.6.2



[PATCH] clk: socfpga: allow for multiple parents on Arria10 periph clocks

2016-02-22 Thread dinguyen
From: Dinh Nguyen 

There are some Arria10 clocks of type "altr,socfpga-a10-perip-clk" that can
have multiple parents. Fix up the __socfpga_periph_init() to call
of_clk_parent_fill() that will return the appropriate number of parents.

Also, update __socfpga_gate_init() to call of_clk_parent_fill() helper
function.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/socfpga/clk-gate-a10.c   | 5 +
 drivers/clk/socfpga/clk-periph-a10.c | 5 ++---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate-a10.c 
b/drivers/clk/socfpga/clk-gate-a10.c
index 1cebf25..0b6ee7b 100644
--- a/drivers/clk/socfpga/clk-gate-a10.c
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -167,12 +167,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-periph-a10.c 
b/drivers/clk/socfpga/clk-periph-a10.c
index 1f397cb..2b7e215 100644
--- a/drivers/clk/socfpga/clk-periph-a10.c
+++ b/drivers/clk/socfpga/clk-periph-a10.c
@@ -74,7 +74,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -109,8 +109,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.ops = ops;
init.flags = 0;
 
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.num_parents = 1;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = _name;
 
periph_clk->hw.hw.init = 
-- 
2.6.2



[PATCH] clk: socfpga: allow for multiple parents on Arria10 periph clocks

2016-02-22 Thread dinguyen
From: Dinh Nguyen 

There are some Arria10 clocks of type "altr,socfpga-a10-perip-clk" that can
have multiple parents. Fix up the __socfpga_periph_init() to call
of_clk_parent_fill() that will return the appropriate number of parents.

Also, update __socfpga_gate_init() to call of_clk_parent_fill() helper
function.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/socfpga/clk-gate-a10.c   | 5 +
 drivers/clk/socfpga/clk-periph-a10.c | 5 ++---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate-a10.c 
b/drivers/clk/socfpga/clk-gate-a10.c
index 1cebf25..0b6ee7b 100644
--- a/drivers/clk/socfpga/clk-gate-a10.c
+++ b/drivers/clk/socfpga/clk-gate-a10.c
@@ -167,12 +167,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-periph-a10.c 
b/drivers/clk/socfpga/clk-periph-a10.c
index 1f397cb..2b7e215 100644
--- a/drivers/clk/socfpga/clk-periph-a10.c
+++ b/drivers/clk/socfpga/clk-periph-a10.c
@@ -74,7 +74,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -109,8 +109,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.ops = ops;
init.flags = 0;
 
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.num_parents = 1;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = _name;
 
periph_clk->hw.hw.init = 
-- 
2.6.2



[PATCH] Doc: Micrel-ksz90x1.txt: Update the Micrel phy documentation for ksz9031

2016-01-28 Thread dinguyen
From: Dinh Nguyen 

Update the Micrel phy documentation for the KSZ9031 PHY to represent how
the actual values are calculated from the code.

Signed-off-by: Dinh Nguyen 
---
 .../devicetree/bindings/net/micrel-ksz90x1.txt | 73 ++
 1 file changed, 73 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt 
b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
index f9c32ad..9535b2b 100644
--- a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
+++ b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
@@ -36,6 +36,71 @@ KSZ9031:
   value is 0, and the maximum is property-dependent. The increment
   step is 60ps.
 
+  The KSZ9031 hardware supports a range of skew values from negative to
+  positive, where the specific range is property dependent. All values
+  specified in the devicetree are offset by the minimum value so they
+  can be represented as positive integers in the devicetree since it's
+  difficult to represent a negative number in the devictree.
+
+  The following 5-bit values table apply to rxc-skew-ps and txc-skew-ps.
+
+  Pad Skew Value   Delay (ps)  Devicetree Value
+  --
+  0_   -900ps  0
+  0_0001   -840ps  60
+  0_0010   -780ps  120
+  0_0011   -720ps  180
+  0_0100   -660ps  240
+  0_0101   -600ps  300
+  0_0110   -540ps  360
+  0_0111   -480ps  420
+  0_1000   -420ps  480
+  0_1001   -360ps  540
+  0_1010   -300ps  600
+  0_1011   -240ps  660
+  0_1100   -180ps  720
+  0_1101   -120ps  780
+  0_1110   -60ps   840
+  0_   0ps 900
+  1_   60ps960
+  1_0001   120ps   1020
+  1_0010   180ps   1080
+  1_0011   240ps   1140
+  1_0100   300ps   1200
+  1_0101   360ps   1260
+  1_0110   420ps   1320
+  1_0111   480ps   1380
+  1_1000   540ps   1440
+  1_1001   600ps   1500
+  1_1010   660ps   1560
+  1_1011   720ps   1620
+  1_1100   780ps   1680
+  1_1101   840ps   1740
+  1_1110   900ps   1800
+  1_   960ps   1860
+
+  The following 4-bit values table apply to the txdX-skew-ps, rxdX-skew-ps
+  data pads, and the rxdv-skew-ps, txen-skew-ps control pads.
+
+  Pad Skew Value   Delay (ps)  Devicetree Value
+  --
+   -420ps  0
+  0001 -360ps  60
+  0010 -300ps  120
+  0011 -240ps  180
+  0100 -180ps  240
+  0101 -120ps  300
+  0110 -60ps   360
+  0111 0ps 420
+  1000 60ps480
+  1001 120ps   540
+  1010 180ps   600
+  1011 240ps   660
+  1100 300ps   720
+  1101 360ps   780
+  1110 420ps   840
+   480ps   900
+
   Optional properties:
 
 Maximum value of 1860:
@@ -72,3 +137,11 @@ Examples:
phy = <>;
phy-mode = "rgmii-id";
};
+
+References
+
+  Micrel ksz9021rl/rn Data Sheet, Revision 1.2. Dated 2/13/2014.
+  http://www.micrel.com/_PDF/Ethernet/datasheets/ksz9021rl-rn_ds.pdf
+
+  Micrel ksz9031rnx Data Sheet, Revision 2.1. Dated 11/20/2014.
+  http://www.micrel.com/_PDF/Ethernet/datasheets/KSZ9031RNX.pdf
-- 
2.6.2



[PATCH] Doc: Micrel-ksz90x1.txt: Update the Micrel phy documentation for ksz9031

2016-01-28 Thread dinguyen
From: Dinh Nguyen 

Update the Micrel phy documentation for the KSZ9031 PHY to represent how
the actual values are calculated from the code.

Signed-off-by: Dinh Nguyen 
---
 .../devicetree/bindings/net/micrel-ksz90x1.txt | 73 ++
 1 file changed, 73 insertions(+)

diff --git a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt 
b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
index f9c32ad..9535b2b 100644
--- a/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
+++ b/Documentation/devicetree/bindings/net/micrel-ksz90x1.txt
@@ -36,6 +36,71 @@ KSZ9031:
   value is 0, and the maximum is property-dependent. The increment
   step is 60ps.
 
+  The KSZ9031 hardware supports a range of skew values from negative to
+  positive, where the specific range is property dependent. All values
+  specified in the devicetree are offset by the minimum value so they
+  can be represented as positive integers in the devicetree since it's
+  difficult to represent a negative number in the devictree.
+
+  The following 5-bit values table apply to rxc-skew-ps and txc-skew-ps.
+
+  Pad Skew Value   Delay (ps)  Devicetree Value
+  --
+  0_   -900ps  0
+  0_0001   -840ps  60
+  0_0010   -780ps  120
+  0_0011   -720ps  180
+  0_0100   -660ps  240
+  0_0101   -600ps  300
+  0_0110   -540ps  360
+  0_0111   -480ps  420
+  0_1000   -420ps  480
+  0_1001   -360ps  540
+  0_1010   -300ps  600
+  0_1011   -240ps  660
+  0_1100   -180ps  720
+  0_1101   -120ps  780
+  0_1110   -60ps   840
+  0_   0ps 900
+  1_   60ps960
+  1_0001   120ps   1020
+  1_0010   180ps   1080
+  1_0011   240ps   1140
+  1_0100   300ps   1200
+  1_0101   360ps   1260
+  1_0110   420ps   1320
+  1_0111   480ps   1380
+  1_1000   540ps   1440
+  1_1001   600ps   1500
+  1_1010   660ps   1560
+  1_1011   720ps   1620
+  1_1100   780ps   1680
+  1_1101   840ps   1740
+  1_1110   900ps   1800
+  1_   960ps   1860
+
+  The following 4-bit values table apply to the txdX-skew-ps, rxdX-skew-ps
+  data pads, and the rxdv-skew-ps, txen-skew-ps control pads.
+
+  Pad Skew Value   Delay (ps)  Devicetree Value
+  --
+   -420ps  0
+  0001 -360ps  60
+  0010 -300ps  120
+  0011 -240ps  180
+  0100 -180ps  240
+  0101 -120ps  300
+  0110 -60ps   360
+  0111 0ps 420
+  1000 60ps480
+  1001 120ps   540
+  1010 180ps   600
+  1011 240ps   660
+  1100 300ps   720
+  1101 360ps   780
+  1110 420ps   840
+   480ps   900
+
   Optional properties:
 
 Maximum value of 1860:
@@ -72,3 +137,11 @@ Examples:
phy = <>;
phy-mode = "rgmii-id";
};
+
+References
+
+  Micrel ksz9021rl/rn Data Sheet, Revision 1.2. Dated 2/13/2014.
+  http://www.micrel.com/_PDF/Ethernet/datasheets/ksz9021rl-rn_ds.pdf
+
+  Micrel ksz9031rnx Data Sheet, Revision 2.1. Dated 11/20/2014.
+  http://www.micrel.com/_PDF/Ethernet/datasheets/KSZ9031RNX.pdf
-- 
2.6.2



[PATCH] arm: socfpga_defconfig: enable USB dual-role and cleanup

2015-12-03 Thread dinguyen
From: Dinh Nguyen 

Enable USB OTG dual-role and a bit of clean up by using make savedefconfig.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/configs/socfpga_defconfig | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/configs/socfpga_defconfig 
b/arch/arm/configs/socfpga_defconfig
index 8128b93e..f7f4e2e 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -36,7 +36,6 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_IP_PNP_RARP=y
-CONFIG_IPV6=y
 CONFIG_NETWORK_PHY_TIMESTAMPING=y
 CONFIG_VLAN_8021Q=y
 CONFIG_VLAN_8021Q_GVRP=y
@@ -57,7 +56,6 @@ CONFIG_BLK_DEV_SD=y
 # CONFIG_SCSI_LOWLEVEL is not set
 CONFIG_NETDEVICES=y
 CONFIG_STMMAC_ETH=y
-CONFIG_DWMAC_SOCFPGA=y
 CONFIG_MICREL_PHY=y
 CONFIG_INPUT_EVDEV=y
 # CONFIG_SERIO_SERPORT is not set
@@ -83,7 +81,8 @@ CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_USB=y
 CONFIG_USB_DWC2=y
-CONFIG_USB_DWC2_HOST=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_FPGA=y
@@ -92,7 +91,6 @@ CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT2_FS_POSIX_ACL=y
 CONFIG_EXT3_FS=y
-CONFIG_EXT4_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_NTFS_FS=y
 CONFIG_NTFS_RW=y
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] arm: socfpga_defconfig: enable USB dual-role and cleanup

2015-12-03 Thread dinguyen
From: Dinh Nguyen 

Enable USB OTG dual-role and a bit of clean up by using make savedefconfig.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/configs/socfpga_defconfig | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/arm/configs/socfpga_defconfig 
b/arch/arm/configs/socfpga_defconfig
index 8128b93e..f7f4e2e 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -36,7 +36,6 @@ CONFIG_IP_PNP=y
 CONFIG_IP_PNP_DHCP=y
 CONFIG_IP_PNP_BOOTP=y
 CONFIG_IP_PNP_RARP=y
-CONFIG_IPV6=y
 CONFIG_NETWORK_PHY_TIMESTAMPING=y
 CONFIG_VLAN_8021Q=y
 CONFIG_VLAN_8021Q_GVRP=y
@@ -57,7 +56,6 @@ CONFIG_BLK_DEV_SD=y
 # CONFIG_SCSI_LOWLEVEL is not set
 CONFIG_NETDEVICES=y
 CONFIG_STMMAC_ETH=y
-CONFIG_DWMAC_SOCFPGA=y
 CONFIG_MICREL_PHY=y
 CONFIG_INPUT_EVDEV=y
 # CONFIG_SERIO_SERPORT is not set
@@ -83,7 +81,8 @@ CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
 CONFIG_USB=y
 CONFIG_USB_DWC2=y
-CONFIG_USB_DWC2_HOST=y
+CONFIG_NOP_USB_XCEIV=y
+CONFIG_USB_GADGET=y
 CONFIG_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_FPGA=y
@@ -92,7 +91,6 @@ CONFIG_EXT2_FS=y
 CONFIG_EXT2_FS_XATTR=y
 CONFIG_EXT2_FS_POSIX_ACL=y
 CONFIG_EXT3_FS=y
-CONFIG_EXT4_FS=y
 CONFIG_VFAT_FS=y
 CONFIG_NTFS_FS=y
 CONFIG_NTFS_RW=y
-- 
2.6.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv7] EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support

2015-10-27 Thread dinguyen
From: Thor Thayer 

Adding L2 Cache and On-Chip RAM EDAC support for the
Altera SoCs using the EDAC device  model. The SDRAM
controller is using the Memory Controller model.

Each type of ECC is individually configurable.

The SDRAM ECC is a separate Kconfig option because:
1) the SDRAM preparation can take almost 2 seconds on boot and some
customers need a faster boot time.
2) the SDRAM has an ECC initialization dependency on the preloader
which is outside the kernel. It is desirable to be able to turn the
SDRAM on & off separately.

Signed-off-by: Thor Thayer 
Signed-off-by: Dinh Nguyen 
---
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef for EDAC_DEBUG
Use -ENODEV instead of EPROBE_DEFER

v6: Convert to nested EDAC in device tree. Force L2 cache
on for L2Cache ECC & remove L2 cache syscon for checking
enable bit. Update year in header.

v5: No Change

v4: Change mask defines to use BIT().
Fix comment style to agree with kernel coding style.
Better printk description for read != write in trigger.
Remove SysFS debugging message.
Better dci->mod_name
Move gen_pool pointer assignment to end of function.
Invert logic to reduce indent in ocram depenency check.
Change from dev_err() to edac_printk()
Replace magic numbers with defines & comments.
Improve error injection test.
Change Makefile intermediary name to altr (from alt)

v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
instead of separate files.

v2: Fix L2 dependency comments.
---
 drivers/edac/Kconfig   |  16 ++
 drivers/edac/Makefile  |   5 +-
 drivers/edac/altera_edac.c | 488 -
 3 files changed, 507 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index ef25000..b80b4ad 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -376,6 +376,22 @@ config EDAC_ALTERA_MC
  preloader must initialize the SDRAM before loading
  the kernel.
 
+config EDAC_ALTERA_L2C
+   bool "Altera L2 Cache EDAC"
+   depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA
+   select CACHE_L2X0
+   help
+ Support for error detection and correction on the
+ Altera L2 cache Memory for Altera SoCs. This option
+  requires L2 cache so it will force that selection.
+
+config EDAC_ALTERA_OCRAM
+   bool "Altera On-Chip RAM EDAC"
+   depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA && SRAM && GENERIC_ALLOCATOR
+   help
+ Support for error detection and correction on the
+ Altera On-Chip RAM Memory for Altera SoCs.
+
 config EDAC_SYNOPSYS
tristate "Synopsys DDR Memory Controller"
depends on EDAC_MM_EDAC && ARCH_ZYNQ
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index dbf53e0..8f1c6fc 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -67,6 +67,9 @@ obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o
 obj-$(CONFIG_EDAC_OCTEON_LMC)  += octeon_edac-lmc.o
 obj-$(CONFIG_EDAC_OCTEON_PCI)  += octeon_edac-pci.o
 
-obj-$(CONFIG_EDAC_ALTERA_MC)   += altera_edac.o
+altr_edac-y:= altera_edac.o
+obj-$(CONFIG_EDAC_ALTERA_MC)   += altr_edac.o
+obj-$(CONFIG_EDAC_ALTERA_L2C)  += altr_edac.o
+obj-$(CONFIG_EDAC_ALTERA_OCRAM)+= altr_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 9296409..154ac8c 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -17,8 +17,10 @@
  * Adapted from the highbank_mc_edac driver.
  */
 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,6 +36,7 @@
 
 #define EDAC_MOD_STR   "altera_edac"
 #define EDAC_VERSION   "1"
+#define EDAC_DEVICE"ALTR_MEM"
 
 static const struct altr_sdram_prv_data c5_data = {
.ecc_ctrl_offset= CV_CTLCFG_OFST,
@@ -75,6 +78,33 @@ static const struct altr_sdram_prv_data a10_data = {
.ue_set_mask= A10_DIAGINT_TDERRA_MASK,
 };
 
+/** EDAC Device Defines **/
+
+/* OCRAM ECC Management Group Defines */
+#define ALTR_MAN_GRP_OCRAM_ECC_OFFSET   0x04
+#define ALTR_OCR_ECC_EN_MASKBIT(0)
+#define ALTR_OCR_ECC_INJS_MASK  BIT(1)
+#define ALTR_OCR_ECC_INJD_MASK  BIT(2)
+#define ALTR_OCR_ECC_SERR_MASK  BIT(3)
+#define ALTR_OCR_ECC_DERR_MASK  BIT(4)
+
+/* L2 ECC Management Group Defines */
+#define ALTR_MAN_GRP_L2_ECC_OFFSET  0x00
+#define ALTR_L2_ECC_EN_MASK BIT(0)
+#define ALTR_L2_ECC_INJS_MASK   BIT(1)
+#define ALTR_L2_ECC_INJD_MASK   BIT(2)
+
+#define ALTR_UE_TRIGGER_CHAR'U'   /* Trigger for UE */
+#define ALTR_TRIGGER_READ_WRD_CNT   32/* Line size x 4 */
+#define ALTR_TRIG_OCRAM_BYTE_SIZE   

[PATCHv7] EDAC, altera: Add Altera L2 Cache and OCRAM EDAC Support

2015-10-27 Thread dinguyen
From: Thor Thayer 

Adding L2 Cache and On-Chip RAM EDAC support for the
Altera SoCs using the EDAC device  model. The SDRAM
controller is using the Memory Controller model.

Each type of ECC is individually configurable.

The SDRAM ECC is a separate Kconfig option because:
1) the SDRAM preparation can take almost 2 seconds on boot and some
customers need a faster boot time.
2) the SDRAM has an ECC initialization dependency on the preloader
which is outside the kernel. It is desirable to be able to turn the
SDRAM on & off separately.

Signed-off-by: Thor Thayer 
Signed-off-by: Dinh Nguyen 
---
v7: s/of_get_named_gen_pool/of_gen_pool_get
Remove #ifdef for EDAC_DEBUG
Use -ENODEV instead of EPROBE_DEFER

v6: Convert to nested EDAC in device tree. Force L2 cache
on for L2Cache ECC & remove L2 cache syscon for checking
enable bit. Update year in header.

v5: No Change

v4: Change mask defines to use BIT().
Fix comment style to agree with kernel coding style.
Better printk description for read != write in trigger.
Remove SysFS debugging message.
Better dci->mod_name
Move gen_pool pointer assignment to end of function.
Invert logic to reduce indent in ocram depenency check.
Change from dev_err() to edac_printk()
Replace magic numbers with defines & comments.
Improve error injection test.
Change Makefile intermediary name to altr (from alt)

v3: Move OCRAM and L2 cache EDAC functions into altera_edac.c
instead of separate files.

v2: Fix L2 dependency comments.
---
 drivers/edac/Kconfig   |  16 ++
 drivers/edac/Makefile  |   5 +-
 drivers/edac/altera_edac.c | 488 -
 3 files changed, 507 insertions(+), 2 deletions(-)

diff --git a/drivers/edac/Kconfig b/drivers/edac/Kconfig
index ef25000..b80b4ad 100644
--- a/drivers/edac/Kconfig
+++ b/drivers/edac/Kconfig
@@ -376,6 +376,22 @@ config EDAC_ALTERA_MC
  preloader must initialize the SDRAM before loading
  the kernel.
 
+config EDAC_ALTERA_L2C
+   bool "Altera L2 Cache EDAC"
+   depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA
+   select CACHE_L2X0
+   help
+ Support for error detection and correction on the
+ Altera L2 cache Memory for Altera SoCs. This option
+  requires L2 cache so it will force that selection.
+
+config EDAC_ALTERA_OCRAM
+   bool "Altera On-Chip RAM EDAC"
+   depends on EDAC_MM_EDAC=y && ARCH_SOCFPGA && SRAM && GENERIC_ALLOCATOR
+   help
+ Support for error detection and correction on the
+ Altera On-Chip RAM Memory for Altera SoCs.
+
 config EDAC_SYNOPSYS
tristate "Synopsys DDR Memory Controller"
depends on EDAC_MM_EDAC && ARCH_ZYNQ
diff --git a/drivers/edac/Makefile b/drivers/edac/Makefile
index dbf53e0..8f1c6fc 100644
--- a/drivers/edac/Makefile
+++ b/drivers/edac/Makefile
@@ -67,6 +67,9 @@ obj-$(CONFIG_EDAC_OCTEON_L2C) += octeon_edac-l2c.o
 obj-$(CONFIG_EDAC_OCTEON_LMC)  += octeon_edac-lmc.o
 obj-$(CONFIG_EDAC_OCTEON_PCI)  += octeon_edac-pci.o
 
-obj-$(CONFIG_EDAC_ALTERA_MC)   += altera_edac.o
+altr_edac-y:= altera_edac.o
+obj-$(CONFIG_EDAC_ALTERA_MC)   += altr_edac.o
+obj-$(CONFIG_EDAC_ALTERA_L2C)  += altr_edac.o
+obj-$(CONFIG_EDAC_ALTERA_OCRAM)+= altr_edac.o
 obj-$(CONFIG_EDAC_SYNOPSYS)+= synopsys_edac.o
 obj-$(CONFIG_EDAC_XGENE)   += xgene_edac.o
diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 9296409..154ac8c 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -17,8 +17,10 @@
  * Adapted from the highbank_mc_edac driver.
  */
 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -34,6 +36,7 @@
 
 #define EDAC_MOD_STR   "altera_edac"
 #define EDAC_VERSION   "1"
+#define EDAC_DEVICE"ALTR_MEM"
 
 static const struct altr_sdram_prv_data c5_data = {
.ecc_ctrl_offset= CV_CTLCFG_OFST,
@@ -75,6 +78,33 @@ static const struct altr_sdram_prv_data a10_data = {
.ue_set_mask= A10_DIAGINT_TDERRA_MASK,
 };
 
+/** EDAC Device Defines **/
+
+/* OCRAM ECC Management Group Defines */
+#define ALTR_MAN_GRP_OCRAM_ECC_OFFSET   0x04
+#define ALTR_OCR_ECC_EN_MASKBIT(0)
+#define ALTR_OCR_ECC_INJS_MASK  BIT(1)
+#define ALTR_OCR_ECC_INJD_MASK  BIT(2)
+#define ALTR_OCR_ECC_SERR_MASK  BIT(3)
+#define ALTR_OCR_ECC_DERR_MASK  BIT(4)
+
+/* L2 ECC Management Group Defines */
+#define ALTR_MAN_GRP_L2_ECC_OFFSET  0x00
+#define ALTR_L2_ECC_EN_MASK BIT(0)
+#define ALTR_L2_ECC_INJS_MASK   BIT(1)
+#define ALTR_L2_ECC_INJD_MASK   BIT(2)
+
+#define ALTR_UE_TRIGGER_CHAR'U'   /* Trigger for UE */
+#define 

[PATCH] EDAC, altera: SoCFPGA EDAC should not look for ECC_CORR_EN

2015-10-14 Thread dinguyen
From: Dinh Nguyen 

The bootloader may or may not enable the ECC_CORR_EN bit. By not enabling
ECC_CORR_EN, when error happens, it is the user's responsibility to perform
a full SDRAM scrub.

Remove the check for ECC_CORR_EN.

Signed-off-by: Dinh Nguyen 
---
 drivers/edac/altera_edac.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.h b/drivers/edac/altera_edac.h
index 7b64dc7..7a52585 100644
--- a/drivers/edac/altera_edac.h
+++ b/drivers/edac/altera_edac.h
@@ -30,8 +30,7 @@
 #define CV_CTLCFG_GEN_SB_ERR   0x2000
 #define CV_CTLCFG_GEN_DB_ERR   0x4000
 
-#define CV_CTLCFG_ECC_AUTO_EN (CV_CTLCFG_ECC_EN | \
-  CV_CTLCFG_ECC_CORR_EN)
+#define CV_CTLCFG_ECC_AUTO_EN (CV_CTLCFG_ECC_EN)
 
 /* SDRAM Controller Address Width Register */
 #define CV_DRAMADDRW_OFST  0x2C
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] EDAC, altera: SoCFPGA EDAC should not look for ECC_CORR_EN

2015-10-14 Thread dinguyen
From: Dinh Nguyen 

The bootloader may or may not enable the ECC_CORR_EN bit. By not enabling
ECC_CORR_EN, when error happens, it is the user's responsibility to perform
a full SDRAM scrub.

Remove the check for ECC_CORR_EN.

Signed-off-by: Dinh Nguyen 
---
 drivers/edac/altera_edac.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/edac/altera_edac.h b/drivers/edac/altera_edac.h
index 7b64dc7..7a52585 100644
--- a/drivers/edac/altera_edac.h
+++ b/drivers/edac/altera_edac.h
@@ -30,8 +30,7 @@
 #define CV_CTLCFG_GEN_SB_ERR   0x2000
 #define CV_CTLCFG_GEN_DB_ERR   0x4000
 
-#define CV_CTLCFG_ECC_AUTO_EN (CV_CTLCFG_ECC_EN | \
-  CV_CTLCFG_ECC_CORR_EN)
+#define CV_CTLCFG_ECC_AUTO_EN (CV_CTLCFG_ECC_EN)
 
 /* SDRAM Controller Address Width Register */
 #define CV_DRAMADDRW_OFST  0x2C
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv4] arm64: dts: Add base stratix 10 dtsi

2015-09-23 Thread dinguyen
From: Dinh Nguyen 

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen 
---
v4: Add a non-zero ranges property for /soc node
v3: change #address-cells and #size-cells to <2>
change the GIC address to 0xfffc1000
update the GIC virtual CPU reg length to 0x2000
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig.platforms   |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  39 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 409 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 23800a1..36303c8 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -66,6 +66,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool "Altera's Stratix 10 SoCFPGA Family"
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family.
+
 config ARCH_TEGRA
bool "NVIDIA Tegra SoC Family"
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index d9f8833..f585606 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..445aa67
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = "altr,socfpga-stratix10";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x0>;
+   };
+
+   cpu1: cpu@1 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x1>;
+   };
+
+   cpu2: cpu@2 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x2>;
+   };
+
+   cpu3: cpu@3 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x3>;
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = <0 120 8>,
+<0 121 8>,
+<0 122 8>,
+<0 123 8>;
+   interrupt-affinity = <>,
+<>,
+<>,
+<>;
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   intc: intc@fffc1000 {
+   compatible = "arm,gic-400", "arm,cortex-a15-gic";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x0 0xfffc1000 0x1000>,

[PATCHv4] arm64: dts: Add base stratix 10 dtsi

2015-09-23 Thread dinguyen
From: Dinh Nguyen 

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen 
---
v4: Add a non-zero ranges property for /soc node
v3: change #address-cells and #size-cells to <2>
change the GIC address to 0xfffc1000
update the GIC virtual CPU reg length to 0x2000
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig.platforms   |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  39 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 409 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 23800a1..36303c8 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -66,6 +66,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool "Altera's Stratix 10 SoCFPGA Family"
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family.
+
 config ARCH_TEGRA
bool "NVIDIA Tegra SoC Family"
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index d9f8833..f585606 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..445aa67
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = "altr,socfpga-stratix10";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x0>;
+   };
+
+   cpu1: cpu@1 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x1>;
+   };
+
+   cpu2: cpu@2 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x2>;
+   };
+
+   cpu3: cpu@3 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x3>;
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = <0 120 8>,
+<0 121 8>,
+<0 122 8>,
+<0 123 8>;
+   interrupt-affinity = <>,
+<>,
+<>,
+<>;
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   intc: intc@fffc1000 {
+   compatible = "arm,gic-400", "arm,cortex-a15-gic";
+   #interrupt-cells = <3>;
+   

[PATCv3] arm64: dts: Add base stratix 10 dtsi

2015-08-21 Thread dinguyen
From: Dinh Nguyen 

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen 
---
v3: change #address-cells and #size-cells to <2>
change the GIC address to 0xfffc1000
update the GIC virtual CPU reg length to 0x2000
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 408 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool "Altera's Stratix 10 SoCFPGA Family"
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool "NVIDIA Tegra SoC Family"
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..d5f51a5
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = "altr,socfpga-stratix10";
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x0>;
+   };
+
+   cpu1: cpu@1 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x1>;
+   };
+
+   cpu2: cpu@2 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x2>;
+   };
+
+   cpu3: cpu@3 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x3>;
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = <0 120 8>,
+<0 121 8>,
+<0 122 8>,
+<0 123 8>;
+   interrupt-affinity = <>,
+<>,
+<>,
+<>;
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   intc: intc@fffc1000 {
+   compatible = "arm,gic-400", "arm,cortex-a15-gic";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x0 0xfffc1000 0x1000>,
+ <0x0 0xfffc2000 0x2000>,
+ <0x0 0xfffc4000 

[PATCv3] arm64: dts: Add base stratix 10 dtsi

2015-08-21 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v3: change #address-cells and #size-cells to 2
change the GIC address to 0xfffc1000
update the GIC virtual CPU reg length to 0x2000
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 408 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool Altera's Stratix 10 SoCFPGA Family
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool NVIDIA Tegra SoC Family
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..d5f51a5
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = altr,socfpga-stratix10;
+   #address-cells = 2;
+   #size-cells = 2;
+
+   cpus {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   cpu0: cpu@0 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x0;
+   };
+
+   cpu1: cpu@1 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x1;
+   };
+
+   cpu2: cpu@2 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x2;
+   };
+
+   cpu3: cpu@3 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x3;
+   };
+   };
+
+   pmu {
+   compatible = arm,armv8-pmuv3;
+   interrupts = 0 120 8,
+0 121 8,
+0 122 8,
+0 123 8;
+   interrupt-affinity = cpu0,
+cpu1,
+cpu2,
+cpu3;
+   };
+
+   psci {
+   compatible = arm,psci-0.2;
+   method = smc;
+   };
+
+   intc: intc@fffc1000 {
+   compatible = arm,gic-400, arm,cortex-a15-gic;
+   #interrupt-cells = 3;
+   interrupt-controller;
+   reg = 0x0 0xfffc1000 0x1000,
+ 0x0 0xfffc2000 0x2000,
+ 0x0 0xfffc4000 0x2000,
+  

[PATCHv2] arm64: dts: Add base stratix 10 dtsi

2015-08-11 Thread dinguyen
From: Dinh Nguyen 

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen 
---
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 408 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool "Altera's Stratix 10 SoCFPGA Family"
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool "NVIDIA Tegra SoC Family"
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..d67de22
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = "altr,socfpga-stratix10";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x0>;
+   };
+
+   cpu1: cpu@1 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x1>;
+   };
+
+   cpu2: cpu@2 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x2>;
+   };
+
+   cpu3: cpu@3 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x3>;
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = <0 120 8>,
+<0 121 8>,
+<0 122 8>,
+<0 123 8>;
+   interrupt-affinity = <>,
+<>,
+<>,
+<>;
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   intc: intc@8000 {
+   compatible = "arm,gic-400", "arm,cortex-a15-gic";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x0 0x9000 0x1000>,
+ <0x0 0xa000 0x2000>,
+ <0x0 0xc000 0x1000>,
+ <0x0 0xd000 0x1000>;
+   };
+
+   soc {
+   #address-cells = <1>;
+   

[PATCHv2] arm64: dts: Add base stratix 10 dtsi

2015-08-11 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v2: use interrupt-affinity for pmu node
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 358 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 408 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool Altera's Stratix 10 SoCFPGA Family
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool NVIDIA Tegra SoC Family
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..d67de22
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,358 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = altr,socfpga-stratix10;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   cpus {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   cpu0: cpu@0 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x0;
+   };
+
+   cpu1: cpu@1 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x1;
+   };
+
+   cpu2: cpu@2 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x2;
+   };
+
+   cpu3: cpu@3 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x3;
+   };
+   };
+
+   pmu {
+   compatible = arm,armv8-pmuv3;
+   interrupts = 0 120 8,
+0 121 8,
+0 122 8,
+0 123 8;
+   interrupt-affinity = cpu0,
+cpu1,
+cpu2,
+cpu3;
+   };
+
+   psci {
+   compatible = arm,psci-0.2;
+   method = smc;
+   };
+
+   intc: intc@8000 {
+   compatible = arm,gic-400, arm,cortex-a15-gic;
+   #interrupt-cells = 3;
+   interrupt-controller;
+   reg = 0x0 0x9000 0x1000,
+ 0x0 0xa000 0x2000,
+ 0x0 0xc000 0x1000,
+ 0x0 0xd000 0x1000;
+   };
+
+   soc {
+   #address-cells = 1;
+   #size-cells = 1;
+ 

[PATCH] arm64: dts: Add base stratix 10 dtsi

2015-08-10 Thread dinguyen
From: Dinh Nguyen 

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen 
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 354 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 404 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool "Altera's Stratix 10 SoCFPGA Family"
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool "NVIDIA Tegra SoC Family"
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..34f6dc3
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,354 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = "altr,socfpga-stratix10";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x0>;
+   };
+
+   cpu@1 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x1>;
+   };
+
+   cpu@2 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x2>;
+   };
+
+   cpu@3 {
+   compatible = "arm,cortex-a53", "arm,armv8";
+   device_type = "cpu";
+   enable-method = "psci";
+   reg = <0x3>;
+   };
+   };
+
+   pmu {
+   compatible = "arm,armv8-pmuv3";
+   interrupts = <0 120 8>,
+<0 121 8>,
+<0 122 8>,
+<0 123 8>;
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   intc: intc@8000 {
+   compatible = "arm,gic-400", "arm,cortex-a15-gic";
+   #interrupt-cells = <3>;
+   interrupt-controller;
+   reg = <0x0 0x9000 0x1000>,
+ <0x0 0xa000 0x2000>,
+ <0x0 0xc000 0x1000>,
+ <0x0 0xd000 0x1000>;
+   };
+
+   soc {
+   #address-cells = <1>;
+   #size-cells = <1>;
+   compatible = "simple-bus";
+   device_type = "soc";
+   interrupt-parent = <>;
+   ranges;
+
+   clkmgr@ffd1000 {
+   compatible = 

[PATCH] arm64: dts: Add base stratix 10 dtsi

2015-08-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Add the base DTS for Altera's SoCFPGA Stratix 10 platform.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 arch/arm64/Kconfig |   5 +
 arch/arm64/boot/dts/Makefile   |   1 +
 arch/arm64/boot/dts/altera/Makefile|   5 +
 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi  | 354 +
 .../boot/dts/altera/socfpga_stratix10_socdk.dts|  38 +++
 arch/arm64/configs/defconfig   |   1 +
 6 files changed, 404 insertions(+)
 create mode 100644 arch/arm64/boot/dts/altera/Makefile
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
 create mode 100644 arch/arm64/boot/dts/altera/socfpga_stratix10_socdk.dts

diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index 318175f..0f8ab2b 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -207,6 +207,11 @@ config ARCH_SEATTLE
help
  This enables support for AMD Seattle SOC Family
 
+config ARCH_STRATIX10
+   bool Altera's Stratix 10 SoCFPGA Family
+   help
+ This enables support for Altera's Stratix 10 SoCFPGA Family
+
 config ARCH_TEGRA
bool NVIDIA Tegra SoC Family
select ARCH_HAS_RESET_CONTROLLER
diff --git a/arch/arm64/boot/dts/Makefile b/arch/arm64/boot/dts/Makefile
index 38913be..7fb421a 100644
--- a/arch/arm64/boot/dts/Makefile
+++ b/arch/arm64/boot/dts/Makefile
@@ -1,3 +1,4 @@
+dts-dirs += altera
 dts-dirs += amd
 dts-dirs += apm
 dts-dirs += arm
diff --git a/arch/arm64/boot/dts/altera/Makefile 
b/arch/arm64/boot/dts/altera/Makefile
new file mode 100644
index 000..d7a6416
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/Makefile
@@ -0,0 +1,5 @@
+dtb-$(CONFIG_ARCH_STRATIX10) += socfpga_stratix10_socdk.dtb
+
+always := $(dtb-y)
+subdir-y   := $(dts-dirs)
+clean-files:= *.dtb
diff --git a/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi 
b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
new file mode 100644
index 000..34f6dc3
--- /dev/null
+++ b/arch/arm64/boot/dts/altera/socfpga_stratix10.dtsi
@@ -0,0 +1,354 @@
+/*
+ * Copyright Altera Corporation (C) 2015. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see http://www.gnu.org/licenses/.
+ */
+
+/dts-v1/;
+
+/ {
+   compatible = altr,socfpga-stratix10;
+   #address-cells = 1;
+   #size-cells = 1;
+
+   cpus {
+   #address-cells = 1;
+   #size-cells = 0;
+
+   cpu@0 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x0;
+   };
+
+   cpu@1 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x1;
+   };
+
+   cpu@2 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x2;
+   };
+
+   cpu@3 {
+   compatible = arm,cortex-a53, arm,armv8;
+   device_type = cpu;
+   enable-method = psci;
+   reg = 0x3;
+   };
+   };
+
+   pmu {
+   compatible = arm,armv8-pmuv3;
+   interrupts = 0 120 8,
+0 121 8,
+0 122 8,
+0 123 8;
+   };
+
+   psci {
+   compatible = arm,psci-0.2;
+   method = smc;
+   };
+
+   intc: intc@8000 {
+   compatible = arm,gic-400, arm,cortex-a15-gic;
+   #interrupt-cells = 3;
+   interrupt-controller;
+   reg = 0x0 0x9000 0x1000,
+ 0x0 0xa000 0x2000,
+ 0x0 0xc000 0x1000,
+ 0x0 0xd000 0x1000;
+   };
+
+   soc {
+   #address-cells = 1;
+   #size-cells = 1;
+   compatible = simple-bus;
+   device_type = soc;
+   interrupt-parent = intc;
+   ranges;
+
+   clkmgr@ffd1000 {
+   compatible = altr,clk-mgr;
+  

[PATCHv2 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property

2015-07-31 Thread dinguyen
From: Dinh Nguyen 

In order for the Arria10 to be able to re-use the reset driver for SoCFPGA
Cyclone5/Arria5, we need to read the 'altr,modrst-offset' property from the
device tree entry. The 'altr,modrst-offset' property is the first register
into the reset manager that is used for bringing peripherals out of reset.

The driver assumes a modrst-offset of 0x10 in order to support legacy
Cyclone5/Arria5 hardware.

Signed-off-by: Dinh Nguyen 
---
v2: assume a modrst-offset of 0x10 if the property is not specified in order
to support legacy boards that do not have the property.
---
 drivers/reset/reset-socfpga.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 0a8def3..1a6c5d6 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -24,11 +24,11 @@
 #include 
 
 #define NR_BANKS   4
-#define OFFSET_MODRST  0x10
 
 struct socfpga_reset_data {
spinlock_t  lock;
void __iomem*membase;
+   u32 modrst_offset;
struct reset_controller_dev rcdev;
 };
 
@@ -45,8 +45,8 @@ static int socfpga_reset_assert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(>lock, flags);
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg | BIT(offset), data->membase + OFFSET_MODRST +
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+   writel(reg | BIT(offset), data->membase + data->modrst_offset +
 (bank * NR_BANKS));
spin_unlock_irqrestore(>lock, flags);
 
@@ -67,8 +67,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(>lock, flags);
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg & ~BIT(offset), data->membase + OFFSET_MODRST +
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+   writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
  (bank * NR_BANKS));
 
spin_unlock_irqrestore(>lock, flags);
@@ -85,7 +85,7 @@ static int socfpga_reset_status(struct reset_controller_dev 
*rcdev,
int offset = id % BITS_PER_LONG;
u32 reg;
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
 
return !(reg & BIT(offset));
 }
@@ -100,6 +100,8 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 {
struct socfpga_reset_data *data;
struct resource *res;
+   struct device *dev = >dev;
+   struct device_node *np = dev->of_node;
 
/*
 * The binding was mainlined without the required property.
@@ -120,6 +122,11 @@ static int socfpga_reset_probe(struct platform_device 
*pdev)
if (IS_ERR(data->membase))
return PTR_ERR(data->membase);
 
+   if (of_property_read_u32(np, "altr,modrst-offset", 
>modrst_offset)) {
+   dev_warn(dev, "missing altr,modrst-offset property, assuming 
0x10!\n");
+   data->modrst_offset = 0x10;
+   }
+
spin_lock_init(>lock);
 
data->rcdev.owner = THIS_MODULE;
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/4] reset: socfpga: Add reset driver support for Arria10 platform

2015-07-31 Thread dinguyen
From: Dinh Nguyen 

v2: For the reset driver, assume a modrst-offset of 0x10 in order to support
legacy boards that do have the property..

v1:
This patch series adds reset driver support for the SoCFPGA Arria10 SOC. The
reset manager on the Arria10 is very similar to the one on Cyclone5/Arria5,
thus I think it's best to try to re-use the same reset driver.

The biggest difference between the reset manager on Arria10 and Cyclone is
the addition of security features. Since the driver does not support these
security features, it winds down to just a driver that will release IPs from
reset.

The other difference between Arria10 and Cyclone5 are register offsets, and
register bits for different IPs. For the register offset, the main register
offset is the very first register that is needed by the driver for releasing
IPs from reset. To handle this difference, I've introduced a new DTS property,
"altr,modrst-offset", that will represent this register.

The register bits for all the resets are in a new file:

include/dt-bindings/reset/altr,rst-mgr-a10.h

Thanks,

Dinh Nguyen (4):
  dt-bindings: Add reset manager offsets for Arria10
  ARM: socfpga: dts: add "altr,modrst-offset" property
  reset: socfpga: Update reset-socfpga to read the altr,modrst-offset
property
  ARM: socfpga: dts: Add resets for EMACs on Arria10

 .../devicetree/bindings/reset/socfpga-reset.txt|   2 +
 arch/arm/boot/dts/socfpga.dtsi |   1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi |   6 ++
 drivers/reset/reset-socfpga.c  |  19 ++--
 include/dt-bindings/reset/altr,rst-mgr-a10.h   | 110 +
 5 files changed, 132 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/4] dt-bindings: Add reset manager offsets for Arria10

2015-07-31 Thread dinguyen
From: Dinh Nguyen 

The reset manager for is pretty similar to the one for SoCFPGA
cyclone5/arria5 except for a few offsets. This patch adds those offsets.

Signed-off-by: Dinh Nguyen 
---
 include/dt-bindings/reset/altr,rst-mgr-a10.h | 110 +++
 1 file changed, 110 insertions(+)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

diff --git a/include/dt-bindings/reset/altr,rst-mgr-a10.h 
b/include/dt-bindings/reset/altr,rst-mgr-a10.h
new file mode 100644
index 000..acb0bbf
--- /dev/null
+++ b/include/dt-bindings/reset/altr,rst-mgr-a10.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014, Steffen Trumtrar 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+#define _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+
+/* MPUMODRST */
+#define CPU0_RESET 0
+#define CPU1_RESET 1
+#define WDS_RESET  2
+#define SCUPER_RESET   3
+
+/* PER0MODRST */
+#define EMAC0_RESET32
+#define EMAC1_RESET33
+#define EMAC2_RESET34
+#define USB0_RESET 35
+#define USB1_RESET 36
+#define NAND_RESET 37
+#define QSPI_RESET 38
+#define SDMMC_RESET39
+#define EMAC0_OCP_RESET40
+#define EMAC1_OCP_RESET41
+#define EMAC2_OCP_RESET42
+#define USB0_OCP_RESET 43
+#define USB1_OCP_RESET 44
+#define NAND_OCP_RESET 45
+#define QSPI_OCP_RESET 46
+#define SDMMC_OCP_RESET47
+#define DMA_RESET  48
+#define SPIM0_RESET49
+#define SPIM1_RESET50
+#define SPIS0_RESET51
+#define SPIS1_RESET52
+#define DMA_OCP_RESET  53
+#define EMAC_PTP_RESET 54
+/* 55 is empty*/
+#define DMAIF0_RESET   56
+#define DMAIF1_RESET   57
+#define DMAIF2_RESET   58
+#define DMAIF3_RESET   59
+#define DMAIF4_RESET   60
+#define DMAIF5_RESET   61
+#define DMAIF6_RESET   62
+#define DMAIF7_RESET   63
+
+/* PER1MODRST */
+#define L4WD0_RESET64
+#define L4WD1_RESET65
+#define L4SYSTIMER0_RESET  66
+#define L4SYSTIMER1_RESET  67
+#define SPTIMER0_RESET 68
+#define SPTIMER1_RESET 69
+/* 70-71 is reserved */
+#define I2C0_RESET 72
+#define I2C1_RESET 73
+#define I2C2_RESET 74
+#define I2C3_RESET 75
+#define I2C4_RESET 76
+/* 77-79 is reserved */
+#define UART0_RESET80
+#define UART1_RESET81
+/* 82-87 is reserved */
+#define GPIO0_RESET88
+#define GPIO1_RESET89
+#define GPIO2_RESET90
+
+/* BRGMODRST */
+#define HPS2FPGA_RESET 96
+#define LWHPS2FPGA_RESET   97
+#define FPGA2HPS_RESET 98
+#define F2SSDRAM0_RESET99
+#define F2SSDRAM1_RESET100
+#define F2SSDRAM2_RESET101
+#define DDRSCH_RESET   102
+
+/* SYSMODRST*/
+#define ROM_RESET  128
+#define OCRAM_RESET129
+/* 130 is reserved */
+#define FPGAMGR_RESET  131
+#define S2F_RESET  132
+#define SYSDBG_RESET   133
+#define OCRAM_OCP_RESET134
+
+/* COLDMODRST */
+#define CLKMGRCOLD_RESET   160
+/* 161-162 is reserved */
+#define S2FCOLD_RESET  163
+#define TIMESTAMPCOLD_RESET164
+#define TAPCOLD_RESET  165
+#define HMCCOLD_RESET  166
+#define IOMGRCOLD_RESET167
+
+/* NRSTMODRST */
+#define NRSTPINOE_RESET192
+
+/* DBGMODRST */
+#define DBG_RESET  224
+#endif
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/4] ARM: socfpga: dts: add "altr,modrst-offset" property

2015-07-31 Thread dinguyen
From: Dinh Nguyen 

The "altr,modrst-offset" property represents the offset into the reset manager
that is the first register to be used by the driver to bring peripherals out
of reset.

Signed-off-by: Dinh Nguyen 
---
 Documentation/devicetree/bindings/reset/socfpga-reset.txt | 2 ++
 arch/arm/boot/dts/socfpga.dtsi| 1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi| 1 +
 3 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/reset/socfpga-reset.txt 
b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
index 32c1c8b..98c9f56 100644
--- a/Documentation/devicetree/bindings/reset/socfpga-reset.txt
+++ b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
@@ -3,6 +3,7 @@ Altera SOCFPGA Reset Manager
 Required properties:
 - compatible : "altr,rst-mgr"
 - reg : Should contain 1 register ranges(address and length)
+- altr,modrst-offset : Should contain the offset of the first modrst register.
 - #reset-cells: 1
 
 Example:
@@ -10,4 +11,5 @@ Example:
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x1000>;
+   altr,modrst-offset = <0x10>;
};
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 86e0fb6..0bda96a 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -783,6 +783,7 @@
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x1000>;
+   altr,modrst-offset = <0x10>;
};
 
usbphy0: usbphy@0 {
diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index a252905..22e7d82 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -593,6 +593,7 @@
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x100>;
+   altr,modrst-offset = <0x20>;
};
 
scu: snoop-control-unit@c000 {
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 4/4] ARM: socfpga: dts: Add resets for EMACs on Arria10

2015-07-31 Thread dinguyen
From: Dinh Nguyen 

Add the reset property for the EMAC controllers on Arria10.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 22e7d82..2340fcb 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -16,6 +16,7 @@
 
 #include "skeleton.dtsi"
 #include 
+#include 
 
 / {
#address-cells = <1>;
@@ -414,6 +415,8 @@
rx-fifo-depth = <16384>;
clocks = <_mp_clk>;
clock-names = "stmmaceth";
+   resets = < EMAC0_RESET>;
+   reset-names = "stmmaceth";
status = "disabled";
};
 
@@ -431,6 +434,8 @@
rx-fifo-depth = <16384>;
clocks = <_mp_clk>;
clock-names = "stmmaceth";
+   resets = < EMAC1_RESET>;
+   reset-names = "stmmaceth";
status = "disabled";
};
 
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/4] dt-bindings: Add reset manager offsets for Arria10

2015-07-31 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The reset manager for is pretty similar to the one for SoCFPGA
cyclone5/arria5 except for a few offsets. This patch adds those offsets.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 include/dt-bindings/reset/altr,rst-mgr-a10.h | 110 +++
 1 file changed, 110 insertions(+)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

diff --git a/include/dt-bindings/reset/altr,rst-mgr-a10.h 
b/include/dt-bindings/reset/altr,rst-mgr-a10.h
new file mode 100644
index 000..acb0bbf
--- /dev/null
+++ b/include/dt-bindings/reset/altr,rst-mgr-a10.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014, Steffen Trumtrar s.trumt...@pengutronix.de
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+#define _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+
+/* MPUMODRST */
+#define CPU0_RESET 0
+#define CPU1_RESET 1
+#define WDS_RESET  2
+#define SCUPER_RESET   3
+
+/* PER0MODRST */
+#define EMAC0_RESET32
+#define EMAC1_RESET33
+#define EMAC2_RESET34
+#define USB0_RESET 35
+#define USB1_RESET 36
+#define NAND_RESET 37
+#define QSPI_RESET 38
+#define SDMMC_RESET39
+#define EMAC0_OCP_RESET40
+#define EMAC1_OCP_RESET41
+#define EMAC2_OCP_RESET42
+#define USB0_OCP_RESET 43
+#define USB1_OCP_RESET 44
+#define NAND_OCP_RESET 45
+#define QSPI_OCP_RESET 46
+#define SDMMC_OCP_RESET47
+#define DMA_RESET  48
+#define SPIM0_RESET49
+#define SPIM1_RESET50
+#define SPIS0_RESET51
+#define SPIS1_RESET52
+#define DMA_OCP_RESET  53
+#define EMAC_PTP_RESET 54
+/* 55 is empty*/
+#define DMAIF0_RESET   56
+#define DMAIF1_RESET   57
+#define DMAIF2_RESET   58
+#define DMAIF3_RESET   59
+#define DMAIF4_RESET   60
+#define DMAIF5_RESET   61
+#define DMAIF6_RESET   62
+#define DMAIF7_RESET   63
+
+/* PER1MODRST */
+#define L4WD0_RESET64
+#define L4WD1_RESET65
+#define L4SYSTIMER0_RESET  66
+#define L4SYSTIMER1_RESET  67
+#define SPTIMER0_RESET 68
+#define SPTIMER1_RESET 69
+/* 70-71 is reserved */
+#define I2C0_RESET 72
+#define I2C1_RESET 73
+#define I2C2_RESET 74
+#define I2C3_RESET 75
+#define I2C4_RESET 76
+/* 77-79 is reserved */
+#define UART0_RESET80
+#define UART1_RESET81
+/* 82-87 is reserved */
+#define GPIO0_RESET88
+#define GPIO1_RESET89
+#define GPIO2_RESET90
+
+/* BRGMODRST */
+#define HPS2FPGA_RESET 96
+#define LWHPS2FPGA_RESET   97
+#define FPGA2HPS_RESET 98
+#define F2SSDRAM0_RESET99
+#define F2SSDRAM1_RESET100
+#define F2SSDRAM2_RESET101
+#define DDRSCH_RESET   102
+
+/* SYSMODRST*/
+#define ROM_RESET  128
+#define OCRAM_RESET129
+/* 130 is reserved */
+#define FPGAMGR_RESET  131
+#define S2F_RESET  132
+#define SYSDBG_RESET   133
+#define OCRAM_OCP_RESET134
+
+/* COLDMODRST */
+#define CLKMGRCOLD_RESET   160
+/* 161-162 is reserved */
+#define S2FCOLD_RESET  163
+#define TIMESTAMPCOLD_RESET164
+#define TAPCOLD_RESET  165
+#define HMCCOLD_RESET  166
+#define IOMGRCOLD_RESET167
+
+/* NRSTMODRST */
+#define NRSTPINOE_RESET192
+
+/* DBGMODRST */
+#define DBG_RESET  224
+#endif
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/4] ARM: socfpga: dts: add altr,modrst-offset property

2015-07-31 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The altr,modrst-offset property represents the offset into the reset manager
that is the first register to be used by the driver to bring peripherals out
of reset.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 Documentation/devicetree/bindings/reset/socfpga-reset.txt | 2 ++
 arch/arm/boot/dts/socfpga.dtsi| 1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi| 1 +
 3 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/reset/socfpga-reset.txt 
b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
index 32c1c8b..98c9f56 100644
--- a/Documentation/devicetree/bindings/reset/socfpga-reset.txt
+++ b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
@@ -3,6 +3,7 @@ Altera SOCFPGA Reset Manager
 Required properties:
 - compatible : altr,rst-mgr
 - reg : Should contain 1 register ranges(address and length)
+- altr,modrst-offset : Should contain the offset of the first modrst register.
 - #reset-cells: 1
 
 Example:
@@ -10,4 +11,5 @@ Example:
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x1000;
+   altr,modrst-offset = 0x10;
};
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 86e0fb6..0bda96a 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -783,6 +783,7 @@
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x1000;
+   altr,modrst-offset = 0x10;
};
 
usbphy0: usbphy@0 {
diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index a252905..22e7d82 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -593,6 +593,7 @@
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x100;
+   altr,modrst-offset = 0x20;
};
 
scu: snoop-control-unit@c000 {
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property

2015-07-31 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

In order for the Arria10 to be able to re-use the reset driver for SoCFPGA
Cyclone5/Arria5, we need to read the 'altr,modrst-offset' property from the
device tree entry. The 'altr,modrst-offset' property is the first register
into the reset manager that is used for bringing peripherals out of reset.

The driver assumes a modrst-offset of 0x10 in order to support legacy
Cyclone5/Arria5 hardware.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v2: assume a modrst-offset of 0x10 if the property is not specified in order
to support legacy boards that do not have the property.
---
 drivers/reset/reset-socfpga.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 0a8def3..1a6c5d6 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -24,11 +24,11 @@
 #include linux/types.h
 
 #define NR_BANKS   4
-#define OFFSET_MODRST  0x10
 
 struct socfpga_reset_data {
spinlock_t  lock;
void __iomem*membase;
+   u32 modrst_offset;
struct reset_controller_dev rcdev;
 };
 
@@ -45,8 +45,8 @@ static int socfpga_reset_assert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(data-lock, flags);
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg | BIT(offset), data-membase + OFFSET_MODRST +
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
+   writel(reg | BIT(offset), data-membase + data-modrst_offset +
 (bank * NR_BANKS));
spin_unlock_irqrestore(data-lock, flags);
 
@@ -67,8 +67,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(data-lock, flags);
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg  ~BIT(offset), data-membase + OFFSET_MODRST +
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
+   writel(reg  ~BIT(offset), data-membase + data-modrst_offset +
  (bank * NR_BANKS));
 
spin_unlock_irqrestore(data-lock, flags);
@@ -85,7 +85,7 @@ static int socfpga_reset_status(struct reset_controller_dev 
*rcdev,
int offset = id % BITS_PER_LONG;
u32 reg;
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
 
return !(reg  BIT(offset));
 }
@@ -100,6 +100,8 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 {
struct socfpga_reset_data *data;
struct resource *res;
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
 
/*
 * The binding was mainlined without the required property.
@@ -120,6 +122,11 @@ static int socfpga_reset_probe(struct platform_device 
*pdev)
if (IS_ERR(data-membase))
return PTR_ERR(data-membase);
 
+   if (of_property_read_u32(np, altr,modrst-offset, 
data-modrst_offset)) {
+   dev_warn(dev, missing altr,modrst-offset property, assuming 
0x10!\n);
+   data-modrst_offset = 0x10;
+   }
+
spin_lock_init(data-lock);
 
data-rcdev.owner = THIS_MODULE;
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 4/4] ARM: socfpga: dts: Add resets for EMACs on Arria10

2015-07-31 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Add the reset property for the EMAC controllers on Arria10.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 22e7d82..2340fcb 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -16,6 +16,7 @@
 
 #include skeleton.dtsi
 #include dt-bindings/interrupt-controller/arm-gic.h
+#include dt-bindings/reset/altr,rst-mgr-a10.h
 
 / {
#address-cells = 1;
@@ -414,6 +415,8 @@
rx-fifo-depth = 16384;
clocks = l4_mp_clk;
clock-names = stmmaceth;
+   resets = rst EMAC0_RESET;
+   reset-names = stmmaceth;
status = disabled;
};
 
@@ -431,6 +434,8 @@
rx-fifo-depth = 16384;
clocks = l4_mp_clk;
clock-names = stmmaceth;
+   resets = rst EMAC1_RESET;
+   reset-names = stmmaceth;
status = disabled;
};
 
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/4] reset: socfpga: Add reset driver support for Arria10 platform

2015-07-31 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

v2: For the reset driver, assume a modrst-offset of 0x10 in order to support
legacy boards that do have the property..

v1:
This patch series adds reset driver support for the SoCFPGA Arria10 SOC. The
reset manager on the Arria10 is very similar to the one on Cyclone5/Arria5,
thus I think it's best to try to re-use the same reset driver.

The biggest difference between the reset manager on Arria10 and Cyclone is
the addition of security features. Since the driver does not support these
security features, it winds down to just a driver that will release IPs from
reset.

The other difference between Arria10 and Cyclone5 are register offsets, and
register bits for different IPs. For the register offset, the main register
offset is the very first register that is needed by the driver for releasing
IPs from reset. To handle this difference, I've introduced a new DTS property,
altr,modrst-offset, that will represent this register.

The register bits for all the resets are in a new file:

include/dt-bindings/reset/altr,rst-mgr-a10.h

Thanks,

Dinh Nguyen (4):
  dt-bindings: Add reset manager offsets for Arria10
  ARM: socfpga: dts: add altr,modrst-offset property
  reset: socfpga: Update reset-socfpga to read the altr,modrst-offset
property
  ARM: socfpga: dts: Add resets for EMACs on Arria10

 .../devicetree/bindings/reset/socfpga-reset.txt|   2 +
 arch/arm/boot/dts/socfpga.dtsi |   1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi |   6 ++
 drivers/reset/reset-socfpga.c  |  19 ++--
 include/dt-bindings/reset/altr,rst-mgr-a10.h   | 110 +
 5 files changed, 132 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property

2015-07-27 Thread dinguyen
From: Dinh Nguyen 

In order for the Arria10 to be able to re-use the reset driver for SoCFPGA
Cyclone5/Arria5, we need to read the 'altr,modrst-offset' property from the
device tree entry. The 'altr,modrst-offset' property is the first register
into the reset manager that is used for bringing peripherals out of reset.

Signed-off-by: Dinh Nguyen 
---
 drivers/reset/reset-socfpga.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 0a8def3..9074d41 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -24,11 +24,11 @@
 #include 
 
 #define NR_BANKS   4
-#define OFFSET_MODRST  0x10
 
 struct socfpga_reset_data {
spinlock_t  lock;
void __iomem*membase;
+   u32 modrst_offset;
struct reset_controller_dev rcdev;
 };
 
@@ -45,8 +45,8 @@ static int socfpga_reset_assert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(>lock, flags);
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg | BIT(offset), data->membase + OFFSET_MODRST +
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+   writel(reg | BIT(offset), data->membase + data->modrst_offset +
 (bank * NR_BANKS));
spin_unlock_irqrestore(>lock, flags);
 
@@ -67,8 +67,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(>lock, flags);
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg & ~BIT(offset), data->membase + OFFSET_MODRST +
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
+   writel(reg & ~BIT(offset), data->membase + data->modrst_offset +
  (bank * NR_BANKS));
 
spin_unlock_irqrestore(>lock, flags);
@@ -85,7 +85,7 @@ static int socfpga_reset_status(struct reset_controller_dev 
*rcdev,
int offset = id % BITS_PER_LONG;
u32 reg;
 
-   reg = readl(data->membase + OFFSET_MODRST + (bank * NR_BANKS));
+   reg = readl(data->membase + data->modrst_offset + (bank * NR_BANKS));
 
return !(reg & BIT(offset));
 }
@@ -100,6 +100,8 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 {
struct socfpga_reset_data *data;
struct resource *res;
+   struct device *dev = >dev;
+   struct device_node *np = dev->of_node;
 
/*
 * The binding was mainlined without the required property.
@@ -120,6 +122,11 @@ static int socfpga_reset_probe(struct platform_device 
*pdev)
if (IS_ERR(data->membase))
return PTR_ERR(data->membase);
 
+   if (of_property_read_u32(np, "altr,modrst-offset", 
>modrst_offset)) {
+   dev_err(dev, "no altr,modrst-offset specified in device 
tree\n");
+   return -ENODEV;
+   }
+
spin_lock_init(>lock);
 
data->rcdev.owner = THIS_MODULE;
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] ARM: socfpga: dts: add "altr,modrst-offset" property

2015-07-27 Thread dinguyen
From: Dinh Nguyen 

The "altr,modrst-offset" property represents the offset into the reset manager
that is the first register to be used by the driver to bring peripherals out
of reset.

Signed-off-by: Dinh Nguyen 
---
 Documentation/devicetree/bindings/reset/socfpga-reset.txt | 2 ++
 arch/arm/boot/dts/socfpga.dtsi| 1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi| 1 +
 3 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/reset/socfpga-reset.txt 
b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
index 32c1c8b..98c9f56 100644
--- a/Documentation/devicetree/bindings/reset/socfpga-reset.txt
+++ b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
@@ -3,6 +3,7 @@ Altera SOCFPGA Reset Manager
 Required properties:
 - compatible : "altr,rst-mgr"
 - reg : Should contain 1 register ranges(address and length)
+- altr,modrst-offset : Should contain the offset of the first modrst register.
 - #reset-cells: 1
 
 Example:
@@ -10,4 +11,5 @@ Example:
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x1000>;
+   altr,modrst-offset = <0x10>;
};
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 86e0fb6..0bda96a 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -783,6 +783,7 @@
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x1000>;
+   altr,modrst-offset = <0x10>;
};
 
usbphy0: usbphy@0 {
diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index a252905..22e7d82 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -593,6 +593,7 @@
#reset-cells = <1>;
compatible = "altr,rst-mgr";
reg = <0xffd05000 0x100>;
+   altr,modrst-offset = <0x20>;
};
 
scu: snoop-control-unit@c000 {
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] ARM: socfpga: dts: Add resets for EMACs on Arria10

2015-07-27 Thread dinguyen
From: Dinh Nguyen 

Add the reset property for the EMAC controllers on Arria10.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 22e7d82..2340fcb 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -16,6 +16,7 @@
 
 #include "skeleton.dtsi"
 #include 
+#include 
 
 / {
#address-cells = <1>;
@@ -414,6 +415,8 @@
rx-fifo-depth = <16384>;
clocks = <_mp_clk>;
clock-names = "stmmaceth";
+   resets = < EMAC0_RESET>;
+   reset-names = "stmmaceth";
status = "disabled";
};
 
@@ -431,6 +434,8 @@
rx-fifo-depth = <16384>;
clocks = <_mp_clk>;
clock-names = "stmmaceth";
+   resets = < EMAC1_RESET>;
+   reset-names = "stmmaceth";
status = "disabled";
};
 
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] reset: socfpga: Add reset driver support for Arria10 platform

2015-07-27 Thread dinguyen
From: Dinh Nguyen 

Hi,

This patch series adds reset driver support for the SoCFPGA Arria10 SOC. The
reset manager on the Arria10 is very similar to the one on Cyclone5/Arria5,
thus I think it's best to try to re-use the same reset driver.

The biggest difference between the reset manager on Arria10 and Cyclone is
the addition of security features. Since the driver does not support these
security features, it winds down to just a driver that will release IPs from
reset.

The other difference between Arria10 and Cyclone5 are register offsets, and
register bits for different IPs. For the register offset, the main register
offset is the very first register that is needed by the driver for releasing
IPs from reset. To handle this difference, I've introduced a new DTS property,
"altr,modrst-offset", that will represent this register.

The register bits for all the resets are in a new file:

include/dt-bindings/reset/altr,rst-mgr-a10.h

Thanks,

Dinh Nguyen (4):
  dt-bindings: Add reset manager offsets for Arria10
  ARM: socfpga: dts: add "altr,modrst-offset" property
  reset: socfpga: Update reset-socfpga to read the altr,modrst-offset
property
  ARM: socfpga: dts: Add resets for EMACs on Arria10

 .../devicetree/bindings/reset/socfpga-reset.txt|   2 +
 arch/arm/boot/dts/socfpga.dtsi |   1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi |   6 ++
 drivers/reset/reset-socfpga.c  |  19 ++--
 include/dt-bindings/reset/altr,rst-mgr-a10.h   | 110 +
 5 files changed, 132 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] dt-bindings: Add reset manager offsets for Arria10

2015-07-27 Thread dinguyen
From: Dinh Nguyen 

The reset manager for is pretty similar to the one for SoCFPGA
cyclone5/arria5 except for a few offsets. This patch adds those offsets.

Signed-off-by: Dinh Nguyen 
---
 include/dt-bindings/reset/altr,rst-mgr-a10.h | 110 +++
 1 file changed, 110 insertions(+)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

diff --git a/include/dt-bindings/reset/altr,rst-mgr-a10.h 
b/include/dt-bindings/reset/altr,rst-mgr-a10.h
new file mode 100644
index 000..acb0bbf
--- /dev/null
+++ b/include/dt-bindings/reset/altr,rst-mgr-a10.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014, Steffen Trumtrar 
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+#define _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+
+/* MPUMODRST */
+#define CPU0_RESET 0
+#define CPU1_RESET 1
+#define WDS_RESET  2
+#define SCUPER_RESET   3
+
+/* PER0MODRST */
+#define EMAC0_RESET32
+#define EMAC1_RESET33
+#define EMAC2_RESET34
+#define USB0_RESET 35
+#define USB1_RESET 36
+#define NAND_RESET 37
+#define QSPI_RESET 38
+#define SDMMC_RESET39
+#define EMAC0_OCP_RESET40
+#define EMAC1_OCP_RESET41
+#define EMAC2_OCP_RESET42
+#define USB0_OCP_RESET 43
+#define USB1_OCP_RESET 44
+#define NAND_OCP_RESET 45
+#define QSPI_OCP_RESET 46
+#define SDMMC_OCP_RESET47
+#define DMA_RESET  48
+#define SPIM0_RESET49
+#define SPIM1_RESET50
+#define SPIS0_RESET51
+#define SPIS1_RESET52
+#define DMA_OCP_RESET  53
+#define EMAC_PTP_RESET 54
+/* 55 is empty*/
+#define DMAIF0_RESET   56
+#define DMAIF1_RESET   57
+#define DMAIF2_RESET   58
+#define DMAIF3_RESET   59
+#define DMAIF4_RESET   60
+#define DMAIF5_RESET   61
+#define DMAIF6_RESET   62
+#define DMAIF7_RESET   63
+
+/* PER1MODRST */
+#define L4WD0_RESET64
+#define L4WD1_RESET65
+#define L4SYSTIMER0_RESET  66
+#define L4SYSTIMER1_RESET  67
+#define SPTIMER0_RESET 68
+#define SPTIMER1_RESET 69
+/* 70-71 is reserved */
+#define I2C0_RESET 72
+#define I2C1_RESET 73
+#define I2C2_RESET 74
+#define I2C3_RESET 75
+#define I2C4_RESET 76
+/* 77-79 is reserved */
+#define UART0_RESET80
+#define UART1_RESET81
+/* 82-87 is reserved */
+#define GPIO0_RESET88
+#define GPIO1_RESET89
+#define GPIO2_RESET90
+
+/* BRGMODRST */
+#define HPS2FPGA_RESET 96
+#define LWHPS2FPGA_RESET   97
+#define FPGA2HPS_RESET 98
+#define F2SSDRAM0_RESET99
+#define F2SSDRAM1_RESET100
+#define F2SSDRAM2_RESET101
+#define DDRSCH_RESET   102
+
+/* SYSMODRST*/
+#define ROM_RESET  128
+#define OCRAM_RESET129
+/* 130 is reserved */
+#define FPGAMGR_RESET  131
+#define S2F_RESET  132
+#define SYSDBG_RESET   133
+#define OCRAM_OCP_RESET134
+
+/* COLDMODRST */
+#define CLKMGRCOLD_RESET   160
+/* 161-162 is reserved */
+#define S2FCOLD_RESET  163
+#define TIMESTAMPCOLD_RESET164
+#define TAPCOLD_RESET  165
+#define HMCCOLD_RESET  166
+#define IOMGRCOLD_RESET167
+
+/* NRSTMODRST */
+#define NRSTPINOE_RESET192
+
+/* DBGMODRST */
+#define DBG_RESET  224
+#endif
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] reset: socfpga: Update reset-socfpga to read the altr,modrst-offset property

2015-07-27 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

In order for the Arria10 to be able to re-use the reset driver for SoCFPGA
Cyclone5/Arria5, we need to read the 'altr,modrst-offset' property from the
device tree entry. The 'altr,modrst-offset' property is the first register
into the reset manager that is used for bringing peripherals out of reset.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/reset/reset-socfpga.c | 19 +--
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 0a8def3..9074d41 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -24,11 +24,11 @@
 #include linux/types.h
 
 #define NR_BANKS   4
-#define OFFSET_MODRST  0x10
 
 struct socfpga_reset_data {
spinlock_t  lock;
void __iomem*membase;
+   u32 modrst_offset;
struct reset_controller_dev rcdev;
 };
 
@@ -45,8 +45,8 @@ static int socfpga_reset_assert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(data-lock, flags);
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg | BIT(offset), data-membase + OFFSET_MODRST +
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
+   writel(reg | BIT(offset), data-membase + data-modrst_offset +
 (bank * NR_BANKS));
spin_unlock_irqrestore(data-lock, flags);
 
@@ -67,8 +67,8 @@ static int socfpga_reset_deassert(struct reset_controller_dev 
*rcdev,
 
spin_lock_irqsave(data-lock, flags);
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
-   writel(reg  ~BIT(offset), data-membase + OFFSET_MODRST +
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
+   writel(reg  ~BIT(offset), data-membase + data-modrst_offset +
  (bank * NR_BANKS));
 
spin_unlock_irqrestore(data-lock, flags);
@@ -85,7 +85,7 @@ static int socfpga_reset_status(struct reset_controller_dev 
*rcdev,
int offset = id % BITS_PER_LONG;
u32 reg;
 
-   reg = readl(data-membase + OFFSET_MODRST + (bank * NR_BANKS));
+   reg = readl(data-membase + data-modrst_offset + (bank * NR_BANKS));
 
return !(reg  BIT(offset));
 }
@@ -100,6 +100,8 @@ static int socfpga_reset_probe(struct platform_device *pdev)
 {
struct socfpga_reset_data *data;
struct resource *res;
+   struct device *dev = pdev-dev;
+   struct device_node *np = dev-of_node;
 
/*
 * The binding was mainlined without the required property.
@@ -120,6 +122,11 @@ static int socfpga_reset_probe(struct platform_device 
*pdev)
if (IS_ERR(data-membase))
return PTR_ERR(data-membase);
 
+   if (of_property_read_u32(np, altr,modrst-offset, 
data-modrst_offset)) {
+   dev_err(dev, no altr,modrst-offset specified in device 
tree\n);
+   return -ENODEV;
+   }
+
spin_lock_init(data-lock);
 
data-rcdev.owner = THIS_MODULE;
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] dt-bindings: Add reset manager offsets for Arria10

2015-07-27 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The reset manager for is pretty similar to the one for SoCFPGA
cyclone5/arria5 except for a few offsets. This patch adds those offsets.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 include/dt-bindings/reset/altr,rst-mgr-a10.h | 110 +++
 1 file changed, 110 insertions(+)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

diff --git a/include/dt-bindings/reset/altr,rst-mgr-a10.h 
b/include/dt-bindings/reset/altr,rst-mgr-a10.h
new file mode 100644
index 000..acb0bbf
--- /dev/null
+++ b/include/dt-bindings/reset/altr,rst-mgr-a10.h
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2014, Steffen Trumtrar s.trumt...@pengutronix.de
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+#define _DT_BINDINGS_RESET_ALTR_RST_MGR_A10_H
+
+/* MPUMODRST */
+#define CPU0_RESET 0
+#define CPU1_RESET 1
+#define WDS_RESET  2
+#define SCUPER_RESET   3
+
+/* PER0MODRST */
+#define EMAC0_RESET32
+#define EMAC1_RESET33
+#define EMAC2_RESET34
+#define USB0_RESET 35
+#define USB1_RESET 36
+#define NAND_RESET 37
+#define QSPI_RESET 38
+#define SDMMC_RESET39
+#define EMAC0_OCP_RESET40
+#define EMAC1_OCP_RESET41
+#define EMAC2_OCP_RESET42
+#define USB0_OCP_RESET 43
+#define USB1_OCP_RESET 44
+#define NAND_OCP_RESET 45
+#define QSPI_OCP_RESET 46
+#define SDMMC_OCP_RESET47
+#define DMA_RESET  48
+#define SPIM0_RESET49
+#define SPIM1_RESET50
+#define SPIS0_RESET51
+#define SPIS1_RESET52
+#define DMA_OCP_RESET  53
+#define EMAC_PTP_RESET 54
+/* 55 is empty*/
+#define DMAIF0_RESET   56
+#define DMAIF1_RESET   57
+#define DMAIF2_RESET   58
+#define DMAIF3_RESET   59
+#define DMAIF4_RESET   60
+#define DMAIF5_RESET   61
+#define DMAIF6_RESET   62
+#define DMAIF7_RESET   63
+
+/* PER1MODRST */
+#define L4WD0_RESET64
+#define L4WD1_RESET65
+#define L4SYSTIMER0_RESET  66
+#define L4SYSTIMER1_RESET  67
+#define SPTIMER0_RESET 68
+#define SPTIMER1_RESET 69
+/* 70-71 is reserved */
+#define I2C0_RESET 72
+#define I2C1_RESET 73
+#define I2C2_RESET 74
+#define I2C3_RESET 75
+#define I2C4_RESET 76
+/* 77-79 is reserved */
+#define UART0_RESET80
+#define UART1_RESET81
+/* 82-87 is reserved */
+#define GPIO0_RESET88
+#define GPIO1_RESET89
+#define GPIO2_RESET90
+
+/* BRGMODRST */
+#define HPS2FPGA_RESET 96
+#define LWHPS2FPGA_RESET   97
+#define FPGA2HPS_RESET 98
+#define F2SSDRAM0_RESET99
+#define F2SSDRAM1_RESET100
+#define F2SSDRAM2_RESET101
+#define DDRSCH_RESET   102
+
+/* SYSMODRST*/
+#define ROM_RESET  128
+#define OCRAM_RESET129
+/* 130 is reserved */
+#define FPGAMGR_RESET  131
+#define S2F_RESET  132
+#define SYSDBG_RESET   133
+#define OCRAM_OCP_RESET134
+
+/* COLDMODRST */
+#define CLKMGRCOLD_RESET   160
+/* 161-162 is reserved */
+#define S2FCOLD_RESET  163
+#define TIMESTAMPCOLD_RESET164
+#define TAPCOLD_RESET  165
+#define HMCCOLD_RESET  166
+#define IOMGRCOLD_RESET167
+
+/* NRSTMODRST */
+#define NRSTPINOE_RESET192
+
+/* DBGMODRST */
+#define DBG_RESET  224
+#endif
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] ARM: socfpga: dts: add altr,modrst-offset property

2015-07-27 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The altr,modrst-offset property represents the offset into the reset manager
that is the first register to be used by the driver to bring peripherals out
of reset.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 Documentation/devicetree/bindings/reset/socfpga-reset.txt | 2 ++
 arch/arm/boot/dts/socfpga.dtsi| 1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi| 1 +
 3 files changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/reset/socfpga-reset.txt 
b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
index 32c1c8b..98c9f56 100644
--- a/Documentation/devicetree/bindings/reset/socfpga-reset.txt
+++ b/Documentation/devicetree/bindings/reset/socfpga-reset.txt
@@ -3,6 +3,7 @@ Altera SOCFPGA Reset Manager
 Required properties:
 - compatible : altr,rst-mgr
 - reg : Should contain 1 register ranges(address and length)
+- altr,modrst-offset : Should contain the offset of the first modrst register.
 - #reset-cells: 1
 
 Example:
@@ -10,4 +11,5 @@ Example:
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x1000;
+   altr,modrst-offset = 0x10;
};
diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 86e0fb6..0bda96a 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -783,6 +783,7 @@
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x1000;
+   altr,modrst-offset = 0x10;
};
 
usbphy0: usbphy@0 {
diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index a252905..22e7d82 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -593,6 +593,7 @@
#reset-cells = 1;
compatible = altr,rst-mgr;
reg = 0xffd05000 0x100;
+   altr,modrst-offset = 0x20;
};
 
scu: snoop-control-unit@c000 {
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] reset: socfpga: Add reset driver support for Arria10 platform

2015-07-27 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hi,

This patch series adds reset driver support for the SoCFPGA Arria10 SOC. The
reset manager on the Arria10 is very similar to the one on Cyclone5/Arria5,
thus I think it's best to try to re-use the same reset driver.

The biggest difference between the reset manager on Arria10 and Cyclone is
the addition of security features. Since the driver does not support these
security features, it winds down to just a driver that will release IPs from
reset.

The other difference between Arria10 and Cyclone5 are register offsets, and
register bits for different IPs. For the register offset, the main register
offset is the very first register that is needed by the driver for releasing
IPs from reset. To handle this difference, I've introduced a new DTS property,
altr,modrst-offset, that will represent this register.

The register bits for all the resets are in a new file:

include/dt-bindings/reset/altr,rst-mgr-a10.h

Thanks,

Dinh Nguyen (4):
  dt-bindings: Add reset manager offsets for Arria10
  ARM: socfpga: dts: add altr,modrst-offset property
  reset: socfpga: Update reset-socfpga to read the altr,modrst-offset
property
  ARM: socfpga: dts: Add resets for EMACs on Arria10

 .../devicetree/bindings/reset/socfpga-reset.txt|   2 +
 arch/arm/boot/dts/socfpga.dtsi |   1 +
 arch/arm/boot/dts/socfpga_arria10.dtsi |   6 ++
 drivers/reset/reset-socfpga.c  |  19 ++--
 include/dt-bindings/reset/altr,rst-mgr-a10.h   | 110 +
 5 files changed, 132 insertions(+), 6 deletions(-)
 create mode 100644 include/dt-bindings/reset/altr,rst-mgr-a10.h

-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] ARM: socfpga: dts: Add resets for EMACs on Arria10

2015-07-27 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Add the reset property for the EMAC controllers on Arria10.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 arch/arm/boot/dts/socfpga_arria10.dtsi | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/boot/dts/socfpga_arria10.dtsi 
b/arch/arm/boot/dts/socfpga_arria10.dtsi
index 22e7d82..2340fcb 100644
--- a/arch/arm/boot/dts/socfpga_arria10.dtsi
+++ b/arch/arm/boot/dts/socfpga_arria10.dtsi
@@ -16,6 +16,7 @@
 
 #include skeleton.dtsi
 #include dt-bindings/interrupt-controller/arm-gic.h
+#include dt-bindings/reset/altr,rst-mgr-a10.h
 
 / {
#address-cells = 1;
@@ -414,6 +415,8 @@
rx-fifo-depth = 16384;
clocks = l4_mp_clk;
clock-names = stmmaceth;
+   resets = rst EMAC0_RESET;
+   reset-names = stmmaceth;
status = disabled;
};
 
@@ -431,6 +434,8 @@
rx-fifo-depth = 16384;
clocks = l4_mp_clk;
clock-names = stmmaceth;
+   resets = rst EMAC1_RESET;
+   reset-names = stmmaceth;
status = disabled;
};
 
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] clk: socfpga: Add a second parent option for the dbg_base_clk

2015-07-24 Thread dinguyen
From: Dinh Nguyen 

The debug base clock can be bypassed from the main PLL to the OSC1 clock.
The bypass register is the staysoc1(0x10) register that is in the clock
manager.

This patch adds the option to get the correct parent for the debug base
clock.

Signed-off-by: Dinh Nguyen 
---
v2: remove changes to socfpga.dtsi
---
 drivers/clk/socfpga/clk-periph.c | 18 ++
 drivers/clk/socfpga/clk.h|  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c
index 0c66863..52c883e 100644
--- a/drivers/clk/socfpga/clk-periph.c
+++ b/drivers/clk/socfpga/clk-periph.c
@@ -44,8 +44,17 @@ static unsigned long clk_periclk_recalc_rate(struct clk_hw 
*hwclk,
return parent_rate / div;
 }
 
+static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
+{
+   u32 clk_src;
+
+   clk_src = readl(clk_mgr_base_addr + CLKMGR_DBCTRL);
+   return clk_src & 0x1;
+}
+
 static const struct clk_ops periclk_ops = {
.recalc_rate = clk_periclk_recalc_rate,
+   .get_parent = clk_periclk_get_parent,
 };
 
 static __init void __socfpga_periph_init(struct device_node *node,
@@ -55,7 +64,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -89,9 +98,10 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.parent_names = _name;
-   init.num_parents = 1;
+
+   init.num_parents = of_clk_parent_fill(node, parent_name,
+ SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk->hw.hw.init = 
 
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index aa2741d..814c724 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -22,6 +22,7 @@
 /* Clock Manager offsets */
 #define CLKMGR_CTRL0x0
 #define CLKMGR_BYPASS  0x4
+#define CLKMGR_DBCTRL  0x10
 #define CLKMGR_L4SRC   0x70
 #define CLKMGR_PERPLL_SRC  0xAC
 
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2] clk: socfpga: Add a second parent option for the dbg_base_clk

2015-07-24 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The debug base clock can be bypassed from the main PLL to the OSC1 clock.
The bypass register is the staysoc1(0x10) register that is in the clock
manager.

This patch adds the option to get the correct parent for the debug base
clock.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v2: remove changes to socfpga.dtsi
---
 drivers/clk/socfpga/clk-periph.c | 18 ++
 drivers/clk/socfpga/clk.h|  1 +
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c
index 0c66863..52c883e 100644
--- a/drivers/clk/socfpga/clk-periph.c
+++ b/drivers/clk/socfpga/clk-periph.c
@@ -44,8 +44,17 @@ static unsigned long clk_periclk_recalc_rate(struct clk_hw 
*hwclk,
return parent_rate / div;
 }
 
+static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
+{
+   u32 clk_src;
+
+   clk_src = readl(clk_mgr_base_addr + CLKMGR_DBCTRL);
+   return clk_src  0x1;
+}
+
 static const struct clk_ops periclk_ops = {
.recalc_rate = clk_periclk_recalc_rate,
+   .get_parent = clk_periclk_get_parent,
 };
 
 static __init void __socfpga_periph_init(struct device_node *node,
@@ -55,7 +64,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node-name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -89,9 +98,10 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.parent_names = parent_name;
-   init.num_parents = 1;
+
+   init.num_parents = of_clk_parent_fill(node, parent_name,
+ SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk-hw.hw.init = init;
 
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index aa2741d..814c724 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -22,6 +22,7 @@
 /* Clock Manager offsets */
 #define CLKMGR_CTRL0x0
 #define CLKMGR_BYPASS  0x4
+#define CLKMGR_DBCTRL  0x10
 #define CLKMGR_L4SRC   0x70
 #define CLKMGR_PERPLL_SRC  0xAC
 
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk

2015-07-22 Thread dinguyen
From: Dinh Nguyen 

The debug base clock can be bypassed from the main PLL to the OSC1 clock.
The bypass register is the staysoc1(0x10) register that is in the clock
manager.

This patch adds the option to get the correct parent for the debug base
clock.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/boot/dts/socfpga.dtsi   |  2 +-
 drivers/clk/socfpga/clk-periph.c | 18 ++
 drivers/clk/socfpga/clk.h|  1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 80f924d..7d5db54 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -164,7 +164,7 @@
dbg_base_clk: dbg_base_clk {
#clock-cells = <0>;
compatible = 
"altr,socfpga-perip-clk";
-   clocks = <_pll>;
+   clocks = <_pll>, 
<>;
div-reg = <0xe8 0 9>;
reg = <0x50>;
};
diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c
index 0c66863..52c883e 100644
--- a/drivers/clk/socfpga/clk-periph.c
+++ b/drivers/clk/socfpga/clk-periph.c
@@ -44,8 +44,17 @@ static unsigned long clk_periclk_recalc_rate(struct clk_hw 
*hwclk,
return parent_rate / div;
 }
 
+static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
+{
+   u32 clk_src;
+
+   clk_src = readl(clk_mgr_base_addr + CLKMGR_DBCTRL);
+   return clk_src & 0x1;
+}
+
 static const struct clk_ops periclk_ops = {
.recalc_rate = clk_periclk_recalc_rate,
+   .get_parent = clk_periclk_get_parent,
 };
 
 static __init void __socfpga_periph_init(struct device_node *node,
@@ -55,7 +64,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node->name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -89,9 +98,10 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.parent_names = _name;
-   init.num_parents = 1;
+
+   init.num_parents = of_clk_parent_fill(node, parent_name,
+ SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk->hw.hw.init = 
 
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index aa2741d..814c724 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -22,6 +22,7 @@
 /* Clock Manager offsets */
 #define CLKMGR_CTRL0x0
 #define CLKMGR_BYPASS  0x4
+#define CLKMGR_DBCTRL  0x10
 #define CLKMGR_L4SRC   0x70
 #define CLKMGR_PERPLL_SRC  0xAC
 
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] clk: socfpga: Add a second parent option for the dbg_base_clk

2015-07-22 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

The debug base clock can be bypassed from the main PLL to the OSC1 clock.
The bypass register is the staysoc1(0x10) register that is in the clock
manager.

This patch adds the option to get the correct parent for the debug base
clock.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 arch/arm/boot/dts/socfpga.dtsi   |  2 +-
 drivers/clk/socfpga/clk-periph.c | 18 ++
 drivers/clk/socfpga/clk.h|  1 +
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/arch/arm/boot/dts/socfpga.dtsi b/arch/arm/boot/dts/socfpga.dtsi
index 80f924d..7d5db54 100644
--- a/arch/arm/boot/dts/socfpga.dtsi
+++ b/arch/arm/boot/dts/socfpga.dtsi
@@ -164,7 +164,7 @@
dbg_base_clk: dbg_base_clk {
#clock-cells = 0;
compatible = 
altr,socfpga-perip-clk;
-   clocks = main_pll;
+   clocks = main_pll, 
osc1;
div-reg = 0xe8 0 9;
reg = 0x50;
};
diff --git a/drivers/clk/socfpga/clk-periph.c b/drivers/clk/socfpga/clk-periph.c
index 0c66863..52c883e 100644
--- a/drivers/clk/socfpga/clk-periph.c
+++ b/drivers/clk/socfpga/clk-periph.c
@@ -44,8 +44,17 @@ static unsigned long clk_periclk_recalc_rate(struct clk_hw 
*hwclk,
return parent_rate / div;
 }
 
+static u8 clk_periclk_get_parent(struct clk_hw *hwclk)
+{
+   u32 clk_src;
+
+   clk_src = readl(clk_mgr_base_addr + CLKMGR_DBCTRL);
+   return clk_src  0x1;
+}
+
 static const struct clk_ops periclk_ops = {
.recalc_rate = clk_periclk_recalc_rate,
+   .get_parent = clk_periclk_get_parent,
 };
 
 static __init void __socfpga_periph_init(struct device_node *node,
@@ -55,7 +64,7 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
struct clk *clk;
struct socfpga_periph_clk *periph_clk;
const char *clk_name = node-name;
-   const char *parent_name;
+   const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
u32 fixed_div;
@@ -89,9 +98,10 @@ static __init void __socfpga_periph_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   parent_name = of_clk_get_parent_name(node, 0);
-   init.parent_names = parent_name;
-   init.num_parents = 1;
+
+   init.num_parents = of_clk_parent_fill(node, parent_name,
+ SOCFPGA_MAX_PARENTS);
+   init.parent_names = parent_name;
 
periph_clk-hw.hw.init = init;
 
diff --git a/drivers/clk/socfpga/clk.h b/drivers/clk/socfpga/clk.h
index aa2741d..814c724 100644
--- a/drivers/clk/socfpga/clk.h
+++ b/drivers/clk/socfpga/clk.h
@@ -22,6 +22,7 @@
 /* Clock Manager offsets */
 #define CLKMGR_CTRL0x0
 #define CLKMGR_BYPASS  0x4
+#define CLKMGR_DBCTRL  0x10
 #define CLKMGR_L4SRC   0x70
 #define CLKMGR_PERPLL_SRC  0xAC
 
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: socfpga: add reset for the Arria 10 platform

2015-07-20 Thread dinguyen
From: Dinh Nguyen 

Since the Arria10's reset register offset is different from the Cyclone/Arria 5,
it's best to add a new DT_MACHINE_START() for the Arria10.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/mach-socfpga/core.h|  1 +
 arch/arm/mach-socfpga/socfpga.c | 26 ++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
index 7259c37..5bc6ea8 100644
--- a/arch/arm/mach-socfpga/core.h
+++ b/arch/arm/mach-socfpga/core.h
@@ -25,6 +25,7 @@
 #define SOCFPGA_RSTMGR_MODPERRST   0x14
 #define SOCFPGA_RSTMGR_BRGMODRST   0x1c
 
+#define SOCFPGA_A10_RSTMGR_CTRL0xC
 #define SOCFPGA_A10_RSTMGR_MODMPURST   0x20
 
 /* System Manager bits */
diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index 19643a7..48c82af 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -74,6 +74,19 @@ static void socfpga_cyclone5_restart(enum reboot_mode mode, 
const char *cmd)
writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
 }
 
+static void socfpga_arria10_restart(enum reboot_mode mode, const char *cmd)
+{
+   u32 temp;
+
+   temp = readl(rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
+
+   if (mode == REBOOT_HARD)
+   temp |= RSTMGR_CTRL_SWCOLDRSTREQ;
+   else
+   temp |= RSTMGR_CTRL_SWWARMRSTREQ;
+   writel(temp, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
+}
+
 static const char *altera_dt_match[] = {
"altr,socfpga",
NULL
@@ -86,3 +99,16 @@ DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
.restart= socfpga_cyclone5_restart,
.dt_compat  = altera_dt_match,
 MACHINE_END
+
+static const char *altera_a10_dt_match[] = {
+   "altr,socfpga-arria10",
+   NULL
+};
+
+DT_MACHINE_START(SOCFPGA_A10, "Altera SOCFPGA Arria10")
+   .l2c_aux_val= 0,
+   .l2c_aux_mask   = ~0,
+   .init_irq   = socfpga_init_irq,
+   .restart= socfpga_arria10_restart,
+   .dt_compat  = altera_dt_match,
+MACHINE_END
-- 
2.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] ARM: socfpga: add reset for the Arria 10 platform

2015-07-20 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Since the Arria10's reset register offset is different from the Cyclone/Arria 5,
it's best to add a new DT_MACHINE_START() for the Arria10.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 arch/arm/mach-socfpga/core.h|  1 +
 arch/arm/mach-socfpga/socfpga.c | 26 ++
 2 files changed, 27 insertions(+)

diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
index 7259c37..5bc6ea8 100644
--- a/arch/arm/mach-socfpga/core.h
+++ b/arch/arm/mach-socfpga/core.h
@@ -25,6 +25,7 @@
 #define SOCFPGA_RSTMGR_MODPERRST   0x14
 #define SOCFPGA_RSTMGR_BRGMODRST   0x1c
 
+#define SOCFPGA_A10_RSTMGR_CTRL0xC
 #define SOCFPGA_A10_RSTMGR_MODMPURST   0x20
 
 /* System Manager bits */
diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index 19643a7..48c82af 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -74,6 +74,19 @@ static void socfpga_cyclone5_restart(enum reboot_mode mode, 
const char *cmd)
writel(temp, rst_manager_base_addr + SOCFPGA_RSTMGR_CTRL);
 }
 
+static void socfpga_arria10_restart(enum reboot_mode mode, const char *cmd)
+{
+   u32 temp;
+
+   temp = readl(rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
+
+   if (mode == REBOOT_HARD)
+   temp |= RSTMGR_CTRL_SWCOLDRSTREQ;
+   else
+   temp |= RSTMGR_CTRL_SWWARMRSTREQ;
+   writel(temp, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_CTRL);
+}
+
 static const char *altera_dt_match[] = {
altr,socfpga,
NULL
@@ -86,3 +99,16 @@ DT_MACHINE_START(SOCFPGA, Altera SOCFPGA)
.restart= socfpga_cyclone5_restart,
.dt_compat  = altera_dt_match,
 MACHINE_END
+
+static const char *altera_a10_dt_match[] = {
+   altr,socfpga-arria10,
+   NULL
+};
+
+DT_MACHINE_START(SOCFPGA_A10, Altera SOCFPGA Arria10)
+   .l2c_aux_val= 0,
+   .l2c_aux_mask   = ~0,
+   .init_irq   = socfpga_init_irq,
+   .restart= socfpga_arria10_restart,
+   .dt_compat  = altera_dt_match,
+MACHINE_END
-- 
2.4.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 6/6] clk: ti: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Tero Kristo 
---
 drivers/clk/ti/apll.c  |4 +---
 drivers/clk/ti/composite.c |4 +---
 drivers/clk/ti/dpll.c  |4 +---
 drivers/clk/ti/fapll.c |3 +--
 drivers/clk/ti/mux.c   |4 +---
 5 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 49baf38..523880e 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -170,7 +170,6 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
struct clk_hw_omap *clk_hw = NULL;
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
-   int i;
 
ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
@@ -195,8 +194,7 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < init->num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init->num_parents);
 
init->parent_names = parent_names;
 
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 96f83ce..dbef218 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -276,7 +276,6 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
int num_parents;
const char **parent_names;
struct component_clk *clk;
-   int i;
 
num_parents = of_clk_get_parent_count(node);
 
@@ -289,8 +288,7 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
if (!parent_names)
return -ENOMEM;
 
-   for (i = 0; i < num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk) {
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index 2aacf7a..49acdf2 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -341,7 +341,6 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
struct dpll_data *dd = NULL;
-   int i;
u8 dpll_mode = 0;
 
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
@@ -370,8 +369,7 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < init->num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init->num_parents);
 
init->parent_names = parent_names;
 
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 730aa62..b1c741b 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -558,8 +558,7 @@ static void __init ti_fapll_setup(struct device_node *node)
goto free;
}
 
-   parent_name[0] = of_clk_get_parent_name(node, 0);
-   parent_name[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parent_name, 2);
init->parent_names = parent_name;
 
fd->clk_ref = of_clk_get(node, 0);
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 5cdeed5..99fe27e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -190,7 +190,6 @@ static void of_mux_clk_setup(struct device_node *node)
void __iomem *reg;
int num_parents;
const char **parent_names;
-   int i;
u8 clk_mux_flags = 0;
u32 mask = 0;
u32 shift = 0;
@@ -205,8 +204,7 @@ static void of_mux_clk_setup(struct device_node *node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
reg = ti_clk_get_reg_addr(node, 0);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/6] clk: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Hello,

This is v2 of the patchset that makes use of of_clk_parent_fill helper function
on various platforms.

Thanks,

Dinh Nguyen (6):
  clk: at91: make use of of_clk_parent_fill helper function
  clk: qoriq: make use of of_clk_parent_fill helper function
  clk: keystone: make use of of_clk_parent_fill helper function
  clk: st: make use of of_clk_parent_fill helper function
  clk: sunxi: make use of of_clk_parent_fill helper function
  clk: ti: make use of of_clk_parent_fill helper function

 drivers/clk/at91/clk-main.c |7 +--
 drivers/clk/at91/clk-master.c   |7 +--
 drivers/clk/at91/clk-programmable.c |7 +--
 drivers/clk/at91/clk-slow.c |   14 ++
 drivers/clk/at91/clk-smd.c  |7 +--
 drivers/clk/at91/clk-usb.c  |7 +--
 drivers/clk/clk-qoriq.c |5 ++---
 drivers/clk/keystone/pll.c  |3 +--
 drivers/clk/st/clk-flexgen.c|6 ++
 drivers/clk/st/clkgen-mux.c |7 ++-
 drivers/clk/sunxi/clk-a20-gmac.c|4 +---
 drivers/clk/sunxi/clk-factors.c |4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |3 +--
 drivers/clk/sunxi/clk-sunxi.c   |   10 ++
 drivers/clk/ti/apll.c   |4 +---
 drivers/clk/ti/composite.c  |4 +---
 drivers/clk/ti/dpll.c   |4 +---
 drivers/clk/ti/fapll.c  |3 +--
 drivers/clk/ti/mux.c|4 +---
 19 files changed, 24 insertions(+), 86 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/6] clk: at91: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Boris Brezillon 
---
 drivers/clk/at91/clk-main.c |7 +--
 drivers/clk/at91/clk-master.c   |7 +--
 drivers/clk/at91/clk-programmable.c |7 +--
 drivers/clk/at91/clk-slow.c |   14 ++
 drivers/clk/at91/clk-smd.c  |7 +--
 drivers/clk/at91/clk-usb.c  |7 +--
 6 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index c240045..13f481b 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -612,17 +612,12 @@ void __init of_at91sam9x5_clk_main_setup(struct 
device_node *np,
int num_parents;
unsigned int irq;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents <= 0 || num_parents > 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index f98eafe..38f646d 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -218,7 +218,6 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
struct clk *clk;
int num_parents;
-   int i;
unsigned int irq;
const char *parent_names[MASTER_SOURCE_MAX];
const char *name = np->name;
@@ -228,11 +227,7 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents <= 0 || num_parents > MASTER_SOURCE_MAX)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 8c86c0f..21492ac 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -230,7 +230,6 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
int num;
u32 id;
-   int i;
struct clk *clk;
int num_parents;
const char *parent_names[PROG_SOURCE_MAX];
@@ -241,11 +240,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents <= 0 || num_parents > PROG_SOURCE_MAX)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
num = of_get_child_count(np);
if (!num || num > (PROG_ID_MAX + 1))
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 98a84a8..84c19d7 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -371,17 +371,12 @@ void __init of_at91sam9x5_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents <= 0 || num_parents > 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
@@ -449,17 +444,12 @@ void __init of_at91sam9260_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents != 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
index 3817ea8..a7f8501 100644
--- a/drivers/clk/at91/clk-smd.c
+++ b/drivers/clk/at91/clk-smd.c
@@ -145,7 +145,6 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node 
*np,
struct at91_pmc *pmc)
 {
struct clk *clk;
-   

[PATCHv2 4/6] clk: st: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Tested-by Gabriel Fernandez 
Cc: Peter Griffin 
---
 drivers/clk/st/clk-flexgen.c |6 ++
 drivers/clk/st/clkgen-mux.c  |7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 657ca14..ed0696c 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -243,7 +243,7 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents <= 0))
@@ -253,10 +253,8 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
if (!parents)
return NULL;
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
 
-   *num_parents = nparents;
return parents;
 }
 
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 4fbe6e0..b83654a 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -24,7 +24,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents <= 0))
@@ -34,10 +34,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
if (!parents)
return ERR_PTR(-ENOMEM);
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
-
-   *num_parents = nparents;
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
return parents;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 5/6] clk: sunxi: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Maxime Ripard 
Cc: "Emilio López" 
---
v2: Add if (of_clk_parent_fill(node, parents, 2) != 2) to clk-a20-gmac.c
---
 drivers/clk/sunxi/clk-a20-gmac.c|4 +---
 drivers/clk/sunxi/clk-factors.c |4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |3 +--
 drivers/clk/sunxi/clk-sunxi.c   |   10 ++
 4 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c
index 0dcf4f2..1611b03 100644
--- a/drivers/clk/sunxi/clk-a20-gmac.c
+++ b/drivers/clk/sunxi/clk-a20-gmac.c
@@ -80,9 +80,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct 
device_node *node)
goto free_mux;
 
/* gmac clock requires exactly 2 parents */
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
-   if (!parents[0] || !parents[1])
+   if (of_clk_parent_fill(node, parents, 2) != 2)
goto free_gate;
 
reg = of_iomap(node, 0);
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 8c20190..2589457 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -174,9 +174,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
int i = 0;
 
/* if we have a mux, we will have >1 parents */
-   while (i < FACTORS_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
+   i = of_clk_parent_fill(node, parents, FACTORS_MAX_PARENTS);
 
/*
 * some factor clocks, such as pll5 and pll6, may have multiple
diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c 
b/drivers/clk/sunxi/clk-sun6i-ar100.c
index 63cf149..6f229ff 100644
--- a/drivers/clk/sunxi/clk-sun6i-ar100.c
+++ b/drivers/clk/sunxi/clk-sun6i-ar100.c
@@ -195,8 +195,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device 
*pdev)
if (nparents > SUN6I_AR100_MAX_PARENTS)
nparents = SUN6I_AR100_MAX_PARENTS;
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parents, nparents);
 
of_property_read_string(np, "clock-output-names", _name);
 
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 9a82f17..eed66f8 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -202,10 +202,7 @@ static void __init sun6i_ahb1_clk_setup(struct device_node 
*node)
return;
 
/* we have a mux, we will have >1 parents */
-   while (i < SUN6I_AHB1_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUN6I_AHB1_MAX_PARENTS);
of_property_read_string(node, "clock-output-names", _name);
 
ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
@@ -790,10 +787,7 @@ static void __init sunxi_mux_clk_setup(struct device_node 
*node,
 
reg = of_iomap(node, 0);
 
-   while (i < SUNXI_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
of_property_read_string(node, "clock-output-names", _name);
 
clk = clk_register_mux(NULL, clk_name, parents, i,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 3/6] clk: keystone: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Acked-by: Santosh Shilimkar 
---
 drivers/clk/keystone/pll.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index 4a375ea..d6ef063 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -309,8 +309,7 @@ static void __init of_pll_mux_clk_init(struct device_node 
*node)
return;
}
 
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1]) {
pr_err("%s: missing parent clocks\n", __func__);
return;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/6] clk: qoriq: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/clk-qoriq.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index cda90a9..d3f4570 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -70,7 +70,7 @@ static void __init core_mux_init(struct device_node *np)
struct clk_init_data init;
struct cmux_clk *cmux_clk;
struct device_node *node;
-   int rc, count, i;
+   int rc, count;
u32 offset;
const char *clk_name;
const char **parent_names;
@@ -92,8 +92,7 @@ static void __init core_mux_init(struct device_node *np)
if (!parent_names)
return;
 
-   for (i = 0; i < count; i++)
-   parent_names[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parent_names, count);
 
cmux_clk = kzalloc(sizeof(*cmux_clk), GFP_KERNEL);
if (!cmux_clk)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 6/6] clk: ti: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Tero Kristo t-kri...@ti.com
---
 drivers/clk/ti/apll.c  |4 +---
 drivers/clk/ti/composite.c |4 +---
 drivers/clk/ti/dpll.c  |4 +---
 drivers/clk/ti/fapll.c |3 +--
 drivers/clk/ti/mux.c   |4 +---
 5 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 49baf38..523880e 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -170,7 +170,6 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
struct clk_hw_omap *clk_hw = NULL;
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
-   int i;
 
ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
@@ -195,8 +194,7 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  init-num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init-num_parents);
 
init-parent_names = parent_names;
 
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 96f83ce..dbef218 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -276,7 +276,6 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
int num_parents;
const char **parent_names;
struct component_clk *clk;
-   int i;
 
num_parents = of_clk_get_parent_count(node);
 
@@ -289,8 +288,7 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
if (!parent_names)
return -ENOMEM;
 
-   for (i = 0; i  num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk) {
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index 2aacf7a..49acdf2 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -341,7 +341,6 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
struct dpll_data *dd = NULL;
-   int i;
u8 dpll_mode = 0;
 
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
@@ -370,8 +369,7 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  init-num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init-num_parents);
 
init-parent_names = parent_names;
 
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 730aa62..b1c741b 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -558,8 +558,7 @@ static void __init ti_fapll_setup(struct device_node *node)
goto free;
}
 
-   parent_name[0] = of_clk_get_parent_name(node, 0);
-   parent_name[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parent_name, 2);
init-parent_names = parent_name;
 
fd-clk_ref = of_clk_get(node, 0);
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 5cdeed5..99fe27e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -190,7 +190,6 @@ static void of_mux_clk_setup(struct device_node *node)
void __iomem *reg;
int num_parents;
const char **parent_names;
-   int i;
u8 clk_mux_flags = 0;
u32 mask = 0;
u32 shift = 0;
@@ -205,8 +204,7 @@ static void of_mux_clk_setup(struct device_node *node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
reg = ti_clk_get_reg_addr(node, 0);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 0/6] clk: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hello,

This is v2 of the patchset that makes use of of_clk_parent_fill helper function
on various platforms.

Thanks,

Dinh Nguyen (6):
  clk: at91: make use of of_clk_parent_fill helper function
  clk: qoriq: make use of of_clk_parent_fill helper function
  clk: keystone: make use of of_clk_parent_fill helper function
  clk: st: make use of of_clk_parent_fill helper function
  clk: sunxi: make use of of_clk_parent_fill helper function
  clk: ti: make use of of_clk_parent_fill helper function

 drivers/clk/at91/clk-main.c |7 +--
 drivers/clk/at91/clk-master.c   |7 +--
 drivers/clk/at91/clk-programmable.c |7 +--
 drivers/clk/at91/clk-slow.c |   14 ++
 drivers/clk/at91/clk-smd.c  |7 +--
 drivers/clk/at91/clk-usb.c  |7 +--
 drivers/clk/clk-qoriq.c |5 ++---
 drivers/clk/keystone/pll.c  |3 +--
 drivers/clk/st/clk-flexgen.c|6 ++
 drivers/clk/st/clkgen-mux.c |7 ++-
 drivers/clk/sunxi/clk-a20-gmac.c|4 +---
 drivers/clk/sunxi/clk-factors.c |4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |3 +--
 drivers/clk/sunxi/clk-sunxi.c   |   10 ++
 drivers/clk/ti/apll.c   |4 +---
 drivers/clk/ti/composite.c  |4 +---
 drivers/clk/ti/dpll.c   |4 +---
 drivers/clk/ti/fapll.c  |3 +--
 drivers/clk/ti/mux.c|4 +---
 19 files changed, 24 insertions(+), 86 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 5/6] clk: sunxi: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Maxime Ripard maxime.rip...@free-electrons.com
Cc: Emilio López emi...@elopez.com.ar
---
v2: Add if (of_clk_parent_fill(node, parents, 2) != 2) to clk-a20-gmac.c
---
 drivers/clk/sunxi/clk-a20-gmac.c|4 +---
 drivers/clk/sunxi/clk-factors.c |4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |3 +--
 drivers/clk/sunxi/clk-sunxi.c   |   10 ++
 4 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c
index 0dcf4f2..1611b03 100644
--- a/drivers/clk/sunxi/clk-a20-gmac.c
+++ b/drivers/clk/sunxi/clk-a20-gmac.c
@@ -80,9 +80,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct 
device_node *node)
goto free_mux;
 
/* gmac clock requires exactly 2 parents */
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
-   if (!parents[0] || !parents[1])
+   if (of_clk_parent_fill(node, parents, 2) != 2)
goto free_gate;
 
reg = of_iomap(node, 0);
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 8c20190..2589457 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -174,9 +174,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
int i = 0;
 
/* if we have a mux, we will have 1 parents */
-   while (i  FACTORS_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
+   i = of_clk_parent_fill(node, parents, FACTORS_MAX_PARENTS);
 
/*
 * some factor clocks, such as pll5 and pll6, may have multiple
diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c 
b/drivers/clk/sunxi/clk-sun6i-ar100.c
index 63cf149..6f229ff 100644
--- a/drivers/clk/sunxi/clk-sun6i-ar100.c
+++ b/drivers/clk/sunxi/clk-sun6i-ar100.c
@@ -195,8 +195,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device 
*pdev)
if (nparents  SUN6I_AR100_MAX_PARENTS)
nparents = SUN6I_AR100_MAX_PARENTS;
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parents, nparents);
 
of_property_read_string(np, clock-output-names, clk_name);
 
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 9a82f17..eed66f8 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -202,10 +202,7 @@ static void __init sun6i_ahb1_clk_setup(struct device_node 
*node)
return;
 
/* we have a mux, we will have 1 parents */
-   while (i  SUN6I_AHB1_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUN6I_AHB1_MAX_PARENTS);
of_property_read_string(node, clock-output-names, clk_name);
 
ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
@@ -790,10 +787,7 @@ static void __init sunxi_mux_clk_setup(struct device_node 
*node,
 
reg = of_iomap(node, 0);
 
-   while (i  SUNXI_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
of_property_read_string(node, clock-output-names, clk_name);
 
clk = clk_register_mux(NULL, clk_name, parents, i,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 1/6] clk: at91: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/clk/at91/clk-main.c |7 +--
 drivers/clk/at91/clk-master.c   |7 +--
 drivers/clk/at91/clk-programmable.c |7 +--
 drivers/clk/at91/clk-slow.c |   14 ++
 drivers/clk/at91/clk-smd.c  |7 +--
 drivers/clk/at91/clk-usb.c  |7 +--
 6 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index c240045..13f481b 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -612,17 +612,12 @@ void __init of_at91sam9x5_clk_main_setup(struct 
device_node *np,
int num_parents;
unsigned int irq;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents = 0 || num_parents  2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index f98eafe..38f646d 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -218,7 +218,6 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
struct clk *clk;
int num_parents;
-   int i;
unsigned int irq;
const char *parent_names[MASTER_SOURCE_MAX];
const char *name = np-name;
@@ -228,11 +227,7 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents = 0 || num_parents  MASTER_SOURCE_MAX)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 8c86c0f..21492ac 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -230,7 +230,6 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
int num;
u32 id;
-   int i;
struct clk *clk;
int num_parents;
const char *parent_names[PROG_SOURCE_MAX];
@@ -241,11 +240,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents = 0 || num_parents  PROG_SOURCE_MAX)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
num = of_get_child_count(np);
if (!num || num  (PROG_ID_MAX + 1))
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 98a84a8..84c19d7 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -371,17 +371,12 @@ void __init of_at91sam9x5_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents = 0 || num_parents  2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
@@ -449,17 +444,12 @@ void __init of_at91sam9260_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents != 2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
index 3817ea8..a7f8501 100644
--- a/drivers/clk/at91/clk-smd.c
+++ b/drivers/clk/at91/clk-smd.c
@@ -145,7 +145,6 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node 
*np,
  

[PATCHv2 3/6] clk: keystone: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Acked-by: Santosh Shilimkar ssant...@kernel.org
---
 drivers/clk/keystone/pll.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index 4a375ea..d6ef063 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -309,8 +309,7 @@ static void __init of_pll_mux_clk_init(struct device_node 
*node)
return;
}
 
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1]) {
pr_err(%s: missing parent clocks\n, __func__);
return;
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 4/6] clk: st: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Tested-by Gabriel Fernandez gabriel.fernan...@st.com
Cc: Peter Griffin peter.grif...@linaro.org
---
 drivers/clk/st/clk-flexgen.c |6 ++
 drivers/clk/st/clkgen-mux.c  |7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 657ca14..ed0696c 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -243,7 +243,7 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents = 0))
@@ -253,10 +253,8 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
if (!parents)
return NULL;
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
 
-   *num_parents = nparents;
return parents;
 }
 
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 4fbe6e0..b83654a 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -24,7 +24,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents = 0))
@@ -34,10 +34,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
if (!parents)
return ERR_PTR(-ENOMEM);
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
-
-   *num_parents = nparents;
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
return parents;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv2 2/6] clk: qoriq: make use of of_clk_parent_fill helper function

2015-07-06 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/clk/clk-qoriq.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index cda90a9..d3f4570 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -70,7 +70,7 @@ static void __init core_mux_init(struct device_node *np)
struct clk_init_data init;
struct cmux_clk *cmux_clk;
struct device_node *node;
-   int rc, count, i;
+   int rc, count;
u32 offset;
const char *clk_name;
const char **parent_names;
@@ -92,8 +92,7 @@ static void __init core_mux_init(struct device_node *np)
if (!parent_names)
return;
 
-   for (i = 0; i  count; i++)
-   parent_names[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parent_names, count);
 
cmux_clk = kzalloc(sizeof(*cmux_clk), GFP_KERNEL);
if (!cmux_clk)
-- 
1.7.9.5

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] clk: keystone: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Santosh Shilimkar 
---
 drivers/clk/keystone/pll.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index 0dd8a4b..d885372 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -293,8 +293,7 @@ static void __init of_pll_mux_clk_init(struct device_node 
*node)
return;
}
 
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1]) {
pr_err("%s: missing parent clocks\n", __func__);
return;
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] clk: st: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Peter Griffin 
Cc: Gabriel FERNANDEZ 
---
 drivers/clk/st/clk-flexgen.c | 6 ++
 drivers/clk/st/clkgen-mux.c  | 7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 657ca14..ed0696c 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -243,7 +243,7 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents <= 0))
@@ -253,10 +253,8 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
if (!parents)
return NULL;
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
 
-   *num_parents = nparents;
return parents;
 }
 
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 4fbe6e0..b83654a 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -24,7 +24,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents <= 0))
@@ -34,10 +34,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
if (!parents)
return ERR_PTR(-ENOMEM);
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
-
-   *num_parents = nparents;
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
return parents;
 }
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] clk: ti: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Tero Kristo 
---
 drivers/clk/ti/apll.c  | 4 +---
 drivers/clk/ti/composite.c | 4 +---
 drivers/clk/ti/dpll.c  | 4 +---
 drivers/clk/ti/fapll.c | 3 +--
 drivers/clk/ti/mux.c   | 4 +---
 5 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 49baf38..523880e 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -170,7 +170,6 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
struct clk_hw_omap *clk_hw = NULL;
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
-   int i;
 
ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
@@ -195,8 +194,7 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < init->num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init->num_parents);
 
init->parent_names = parent_names;
 
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 96f83ce..dbef218 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -276,7 +276,6 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
int num_parents;
const char **parent_names;
struct component_clk *clk;
-   int i;
 
num_parents = of_clk_get_parent_count(node);
 
@@ -289,8 +288,7 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
if (!parent_names)
return -ENOMEM;
 
-   for (i = 0; i < num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk) {
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index 2aacf7a..49acdf2 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -341,7 +341,6 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
struct dpll_data *dd = NULL;
-   int i;
u8 dpll_mode = 0;
 
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
@@ -370,8 +369,7 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < init->num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init->num_parents);
 
init->parent_names = parent_names;
 
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 730aa62..b1c741b 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -558,8 +558,7 @@ static void __init ti_fapll_setup(struct device_node *node)
goto free;
}
 
-   parent_name[0] = of_clk_get_parent_name(node, 0);
-   parent_name[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parent_name, 2);
init->parent_names = parent_name;
 
fd->clk_ref = of_clk_get(node, 0);
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 5cdeed5..99fe27e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -190,7 +190,6 @@ static void of_mux_clk_setup(struct device_node *node)
void __iomem *reg;
int num_parents;
const char **parent_names;
-   int i;
u8 clk_mux_flags = 0;
u32 mask = 0;
u32 shift = 0;
@@ -205,8 +204,7 @@ static void of_mux_clk_setup(struct device_node *node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i < num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
reg = ti_clk_get_reg_addr(node, 0);
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] clk: at91: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Boris Brezillon 
---
 drivers/clk/at91/clk-main.c |  7 +--
 drivers/clk/at91/clk-master.c   |  7 +--
 drivers/clk/at91/clk-programmable.c |  7 +--
 drivers/clk/at91/clk-slow.c | 14 ++
 drivers/clk/at91/clk-smd.c  |  7 +--
 drivers/clk/at91/clk-usb.c  |  7 +--
 6 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index c240045..13f481b 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -612,17 +612,12 @@ void __init of_at91sam9x5_clk_main_setup(struct 
device_node *np,
int num_parents;
unsigned int irq;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents <= 0 || num_parents > 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index f98eafe..38f646d 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -218,7 +218,6 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
struct clk *clk;
int num_parents;
-   int i;
unsigned int irq;
const char *parent_names[MASTER_SOURCE_MAX];
const char *name = np->name;
@@ -228,11 +227,7 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents <= 0 || num_parents > MASTER_SOURCE_MAX)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 8c86c0f..21492ac 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -230,7 +230,6 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
int num;
u32 id;
-   int i;
struct clk *clk;
int num_parents;
const char *parent_names[PROG_SOURCE_MAX];
@@ -241,11 +240,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents <= 0 || num_parents > PROG_SOURCE_MAX)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
num = of_get_child_count(np);
if (!num || num > (PROG_ID_MAX + 1))
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 98a84a8..84c19d7 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -371,17 +371,12 @@ void __init of_at91sam9x5_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents <= 0 || num_parents > 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
@@ -449,17 +444,12 @@ void __init of_at91sam9260_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np->name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents != 2)
return;
 
-   for (i = 0; i < num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, "clock-output-names", );
 
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
index 3817ea8..a7f8501 100644
--- a/drivers/clk/at91/clk-smd.c
+++ b/drivers/clk/at91/clk-smd.c
@@ -145,7 +145,6 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node 
*np,
struct at91_pmc *pmc)
 {
struct clk *clk;
-   int i;
 

[PATCH 5/6] clk: sunxi: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
Cc: Maxime Ripard 
Cc: "Emilio López" 
---
 drivers/clk/sunxi/clk-a20-gmac.c|  3 +--
 drivers/clk/sunxi/clk-factors.c |  4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |  3 +--
 drivers/clk/sunxi/clk-sunxi.c   | 10 ++
 4 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c
index 0dcf4f2..a432edd 100644
--- a/drivers/clk/sunxi/clk-a20-gmac.c
+++ b/drivers/clk/sunxi/clk-a20-gmac.c
@@ -80,8 +80,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct 
device_node *node)
goto free_mux;
 
/* gmac clock requires exactly 2 parents */
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1])
goto free_gate;
 
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 8c20190..2589457 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -174,9 +174,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
int i = 0;
 
/* if we have a mux, we will have >1 parents */
-   while (i < FACTORS_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
+   i = of_clk_parent_fill(node, parents, FACTORS_MAX_PARENTS);
 
/*
 * some factor clocks, such as pll5 and pll6, may have multiple
diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c 
b/drivers/clk/sunxi/clk-sun6i-ar100.c
index 63cf149..6f229ff 100644
--- a/drivers/clk/sunxi/clk-sun6i-ar100.c
+++ b/drivers/clk/sunxi/clk-sun6i-ar100.c
@@ -195,8 +195,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device 
*pdev)
if (nparents > SUN6I_AR100_MAX_PARENTS)
nparents = SUN6I_AR100_MAX_PARENTS;
 
-   for (i = 0; i < nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parents, nparents);
 
of_property_read_string(np, "clock-output-names", _name);
 
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 7e1e2bd..ebea294 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -200,10 +200,7 @@ static void __init sun6i_ahb1_clk_setup(struct device_node 
*node)
reg = of_io_request_and_map(node, 0, of_node_full_name(node));
 
/* we have a mux, we will have >1 parents */
-   while (i < SUN6I_AHB1_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUN6I_AHB1_MAX_PARENTS);
of_property_read_string(node, "clock-output-names", _name);
 
ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
@@ -788,10 +785,7 @@ static void __init sunxi_mux_clk_setup(struct device_node 
*node,
 
reg = of_iomap(node, 0);
 
-   while (i < SUNXI_MAX_PARENTS &&
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
of_property_read_string(node, "clock-output-names", _name);
 
clk = clk_register_mux(NULL, clk_name, parents, i,
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] clk: qoriq: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/clk-qoriq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index cda90a9..d3f4570 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -70,7 +70,7 @@ static void __init core_mux_init(struct device_node *np)
struct clk_init_data init;
struct cmux_clk *cmux_clk;
struct device_node *node;
-   int rc, count, i;
+   int rc, count;
u32 offset;
const char *clk_name;
const char **parent_names;
@@ -92,8 +92,7 @@ static void __init core_mux_init(struct device_node *np)
if (!parent_names)
return;
 
-   for (i = 0; i < count; i++)
-   parent_names[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parent_names, count);
 
cmux_clk = kzalloc(sizeof(*cmux_clk), GFP_KERNEL);
if (!cmux_clk)
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/6] clk: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen 

Hello,

This patch series makes use of the new of_clk_parent_fill() helper function.
This patch series is not intended for v4.2, as I think it's a bit late, but
I just wanted to make sure people have time to test it. The series is based
on git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git#clk-next.

Thank,

Dinh Nguyen (6):
  clk: at91: make use of of_clk_parent_fill helper function
  clk: qoriq: make use of of_clk_parent_fill helper function
  clk: keystone: make use of of_clk_parent_fill helper function
  clk: st: make use of of_clk_parent_fill helper function
  clk: sunxi: make use of of_clk_parent_fill helper function
  clk: ti: make use of of_clk_parent_fill helper function

 drivers/clk/at91/clk-main.c |  7 +--
 drivers/clk/at91/clk-master.c   |  7 +--
 drivers/clk/at91/clk-programmable.c |  7 +--
 drivers/clk/at91/clk-slow.c | 14 ++
 drivers/clk/at91/clk-smd.c  |  7 +--
 drivers/clk/at91/clk-usb.c  |  7 +--
 drivers/clk/clk-qoriq.c |  5 ++---
 drivers/clk/keystone/pll.c  |  3 +--
 drivers/clk/st/clk-flexgen.c|  6 ++
 drivers/clk/st/clkgen-mux.c |  7 ++-
 drivers/clk/sunxi/clk-a20-gmac.c|  3 +--
 drivers/clk/sunxi/clk-factors.c |  4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |  3 +--
 drivers/clk/sunxi/clk-sunxi.c   | 10 ++
 drivers/clk/ti/apll.c   |  4 +---
 drivers/clk/ti/composite.c  |  4 +---
 drivers/clk/ti/dpll.c   |  4 +---
 drivers/clk/ti/fapll.c  |  3 +--
 drivers/clk/ti/mux.c|  4 +---
 19 files changed, 24 insertions(+), 85 deletions(-)
---
Cc: Tero Kristo 
Cc: Maxime Ripard 
Cc: "Emilio López" 
Cc: Peter Griffin 
Cc: Gabriel FERNANDEZ 
Cc: Santosh Shilimkar 
Cc: Boris Brezillon 

-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/6] clk: at91: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Boris Brezillon boris.brezil...@free-electrons.com
---
 drivers/clk/at91/clk-main.c |  7 +--
 drivers/clk/at91/clk-master.c   |  7 +--
 drivers/clk/at91/clk-programmable.c |  7 +--
 drivers/clk/at91/clk-slow.c | 14 ++
 drivers/clk/at91/clk-smd.c  |  7 +--
 drivers/clk/at91/clk-usb.c  |  7 +--
 6 files changed, 7 insertions(+), 42 deletions(-)

diff --git a/drivers/clk/at91/clk-main.c b/drivers/clk/at91/clk-main.c
index c240045..13f481b 100644
--- a/drivers/clk/at91/clk-main.c
+++ b/drivers/clk/at91/clk-main.c
@@ -612,17 +612,12 @@ void __init of_at91sam9x5_clk_main_setup(struct 
device_node *np,
int num_parents;
unsigned int irq;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents = 0 || num_parents  2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-master.c b/drivers/clk/at91/clk-master.c
index f98eafe..38f646d 100644
--- a/drivers/clk/at91/clk-master.c
+++ b/drivers/clk/at91/clk-master.c
@@ -218,7 +218,6 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
struct clk *clk;
int num_parents;
-   int i;
unsigned int irq;
const char *parent_names[MASTER_SOURCE_MAX];
const char *name = np-name;
@@ -228,11 +227,7 @@ of_at91_clk_master_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents = 0 || num_parents  MASTER_SOURCE_MAX)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-programmable.c 
b/drivers/clk/at91/clk-programmable.c
index 8c86c0f..21492ac 100644
--- a/drivers/clk/at91/clk-programmable.c
+++ b/drivers/clk/at91/clk-programmable.c
@@ -230,7 +230,6 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
 {
int num;
u32 id;
-   int i;
struct clk *clk;
int num_parents;
const char *parent_names[PROG_SOURCE_MAX];
@@ -241,11 +240,7 @@ of_at91_clk_prog_setup(struct device_node *np, struct 
at91_pmc *pmc,
if (num_parents = 0 || num_parents  PROG_SOURCE_MAX)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
num = of_get_child_count(np);
if (!num || num  (PROG_ID_MAX + 1))
diff --git a/drivers/clk/at91/clk-slow.c b/drivers/clk/at91/clk-slow.c
index 98a84a8..84c19d7 100644
--- a/drivers/clk/at91/clk-slow.c
+++ b/drivers/clk/at91/clk-slow.c
@@ -371,17 +371,12 @@ void __init of_at91sam9x5_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents = 0 || num_parents  2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
@@ -449,17 +444,12 @@ void __init of_at91sam9260_clk_slow_setup(struct 
device_node *np,
const char *parent_names[2];
int num_parents;
const char *name = np-name;
-   int i;
 
num_parents = of_clk_get_parent_count(np);
if (num_parents != 2)
return;
 
-   for (i = 0; i  num_parents; ++i) {
-   parent_names[i] = of_clk_get_parent_name(np, i);
-   if (!parent_names[i])
-   return;
-   }
+   of_clk_parent_fill(np, parent_names, num_parents);
 
of_property_read_string(np, clock-output-names, name);
 
diff --git a/drivers/clk/at91/clk-smd.c b/drivers/clk/at91/clk-smd.c
index 3817ea8..a7f8501 100644
--- a/drivers/clk/at91/clk-smd.c
+++ b/drivers/clk/at91/clk-smd.c
@@ -145,7 +145,6 @@ void __init of_at91sam9x5_clk_smd_setup(struct device_node 
*np,
  

[PATCH 0/6] clk: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hello,

This patch series makes use of the new of_clk_parent_fill() helper function.
This patch series is not intended for v4.2, as I think it's a bit late, but
I just wanted to make sure people have time to test it. The series is based
on git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git#clk-next.

Thank,

Dinh Nguyen (6):
  clk: at91: make use of of_clk_parent_fill helper function
  clk: qoriq: make use of of_clk_parent_fill helper function
  clk: keystone: make use of of_clk_parent_fill helper function
  clk: st: make use of of_clk_parent_fill helper function
  clk: sunxi: make use of of_clk_parent_fill helper function
  clk: ti: make use of of_clk_parent_fill helper function

 drivers/clk/at91/clk-main.c |  7 +--
 drivers/clk/at91/clk-master.c   |  7 +--
 drivers/clk/at91/clk-programmable.c |  7 +--
 drivers/clk/at91/clk-slow.c | 14 ++
 drivers/clk/at91/clk-smd.c  |  7 +--
 drivers/clk/at91/clk-usb.c  |  7 +--
 drivers/clk/clk-qoriq.c |  5 ++---
 drivers/clk/keystone/pll.c  |  3 +--
 drivers/clk/st/clk-flexgen.c|  6 ++
 drivers/clk/st/clkgen-mux.c |  7 ++-
 drivers/clk/sunxi/clk-a20-gmac.c|  3 +--
 drivers/clk/sunxi/clk-factors.c |  4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |  3 +--
 drivers/clk/sunxi/clk-sunxi.c   | 10 ++
 drivers/clk/ti/apll.c   |  4 +---
 drivers/clk/ti/composite.c  |  4 +---
 drivers/clk/ti/dpll.c   |  4 +---
 drivers/clk/ti/fapll.c  |  3 +--
 drivers/clk/ti/mux.c|  4 +---
 19 files changed, 24 insertions(+), 85 deletions(-)
---
Cc: Tero Kristo t-kri...@ti.com
Cc: Maxime Ripard maxime.rip...@free-electrons.com
Cc: Emilio López emi...@elopez.com.ar
Cc: Peter Griffin peter.grif...@linaro.org
Cc: Gabriel FERNANDEZ gabriel.fernan...@st.com
Cc: Santosh Shilimkar ssant...@kernel.org
Cc: Boris Brezillon boris.brezil...@free-electrons.com

-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] clk: sunxi: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Maxime Ripard maxime.rip...@free-electrons.com
Cc: Emilio López emi...@elopez.com.ar
---
 drivers/clk/sunxi/clk-a20-gmac.c|  3 +--
 drivers/clk/sunxi/clk-factors.c |  4 +---
 drivers/clk/sunxi/clk-sun6i-ar100.c |  3 +--
 drivers/clk/sunxi/clk-sunxi.c   | 10 ++
 4 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/clk/sunxi/clk-a20-gmac.c b/drivers/clk/sunxi/clk-a20-gmac.c
index 0dcf4f2..a432edd 100644
--- a/drivers/clk/sunxi/clk-a20-gmac.c
+++ b/drivers/clk/sunxi/clk-a20-gmac.c
@@ -80,8 +80,7 @@ static void __init sun7i_a20_gmac_clk_setup(struct 
device_node *node)
goto free_mux;
 
/* gmac clock requires exactly 2 parents */
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1])
goto free_gate;
 
diff --git a/drivers/clk/sunxi/clk-factors.c b/drivers/clk/sunxi/clk-factors.c
index 8c20190..2589457 100644
--- a/drivers/clk/sunxi/clk-factors.c
+++ b/drivers/clk/sunxi/clk-factors.c
@@ -174,9 +174,7 @@ struct clk *sunxi_factors_register(struct device_node *node,
int i = 0;
 
/* if we have a mux, we will have 1 parents */
-   while (i  FACTORS_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
+   i = of_clk_parent_fill(node, parents, FACTORS_MAX_PARENTS);
 
/*
 * some factor clocks, such as pll5 and pll6, may have multiple
diff --git a/drivers/clk/sunxi/clk-sun6i-ar100.c 
b/drivers/clk/sunxi/clk-sun6i-ar100.c
index 63cf149..6f229ff 100644
--- a/drivers/clk/sunxi/clk-sun6i-ar100.c
+++ b/drivers/clk/sunxi/clk-sun6i-ar100.c
@@ -195,8 +195,7 @@ static int sun6i_a31_ar100_clk_probe(struct platform_device 
*pdev)
if (nparents  SUN6I_AR100_MAX_PARENTS)
nparents = SUN6I_AR100_MAX_PARENTS;
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parents, nparents);
 
of_property_read_string(np, clock-output-names, clk_name);
 
diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c
index 7e1e2bd..ebea294 100644
--- a/drivers/clk/sunxi/clk-sunxi.c
+++ b/drivers/clk/sunxi/clk-sunxi.c
@@ -200,10 +200,7 @@ static void __init sun6i_ahb1_clk_setup(struct device_node 
*node)
reg = of_io_request_and_map(node, 0, of_node_full_name(node));
 
/* we have a mux, we will have 1 parents */
-   while (i  SUN6I_AHB1_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUN6I_AHB1_MAX_PARENTS);
of_property_read_string(node, clock-output-names, clk_name);
 
ahb1 = kzalloc(sizeof(struct sun6i_ahb1_clk), GFP_KERNEL);
@@ -788,10 +785,7 @@ static void __init sunxi_mux_clk_setup(struct device_node 
*node,
 
reg = of_iomap(node, 0);
 
-   while (i  SUNXI_MAX_PARENTS 
-  (parents[i] = of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
+   of_clk_parent_fill(node, parents, SUNXI_MAX_PARENTS);
of_property_read_string(node, clock-output-names, clk_name);
 
clk = clk_register_mux(NULL, clk_name, parents, i,
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/6] clk: qoriq: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/clk/clk-qoriq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/clk-qoriq.c b/drivers/clk/clk-qoriq.c
index cda90a9..d3f4570 100644
--- a/drivers/clk/clk-qoriq.c
+++ b/drivers/clk/clk-qoriq.c
@@ -70,7 +70,7 @@ static void __init core_mux_init(struct device_node *np)
struct clk_init_data init;
struct cmux_clk *cmux_clk;
struct device_node *node;
-   int rc, count, i;
+   int rc, count;
u32 offset;
const char *clk_name;
const char **parent_names;
@@ -92,8 +92,7 @@ static void __init core_mux_init(struct device_node *np)
if (!parent_names)
return;
 
-   for (i = 0; i  count; i++)
-   parent_names[i] = of_clk_get_parent_name(np, i);
+   of_clk_parent_fill(np, parent_names, count);
 
cmux_clk = kzalloc(sizeof(*cmux_clk), GFP_KERNEL);
if (!cmux_clk)
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/6] clk: keystone: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Santosh Shilimkar ssant...@kernel.org
---
 drivers/clk/keystone/pll.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/clk/keystone/pll.c b/drivers/clk/keystone/pll.c
index 0dd8a4b..d885372 100644
--- a/drivers/clk/keystone/pll.c
+++ b/drivers/clk/keystone/pll.c
@@ -293,8 +293,7 @@ static void __init of_pll_mux_clk_init(struct device_node 
*node)
return;
}
 
-   parents[0] = of_clk_get_parent_name(node, 0);
-   parents[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parents, 2);
if (!parents[0] || !parents[1]) {
pr_err(%s: missing parent clocks\n, __func__);
return;
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/6] clk: st: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Peter Griffin peter.grif...@linaro.org
Cc: Gabriel FERNANDEZ gabriel.fernan...@st.com
---
 drivers/clk/st/clk-flexgen.c | 6 ++
 drivers/clk/st/clkgen-mux.c  | 7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/st/clk-flexgen.c b/drivers/clk/st/clk-flexgen.c
index 657ca14..ed0696c 100644
--- a/drivers/clk/st/clk-flexgen.c
+++ b/drivers/clk/st/clk-flexgen.c
@@ -243,7 +243,7 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents = 0))
@@ -253,10 +253,8 @@ static const char ** __init flexgen_get_parents(struct 
device_node *np,
if (!parents)
return NULL;
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
 
-   *num_parents = nparents;
return parents;
 }
 
diff --git a/drivers/clk/st/clkgen-mux.c b/drivers/clk/st/clkgen-mux.c
index 4fbe6e0..b83654a 100644
--- a/drivers/clk/st/clkgen-mux.c
+++ b/drivers/clk/st/clkgen-mux.c
@@ -24,7 +24,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
   int *num_parents)
 {
const char **parents;
-   int nparents, i;
+   int nparents;
 
nparents = of_clk_get_parent_count(np);
if (WARN_ON(nparents = 0))
@@ -34,10 +34,7 @@ static const char ** __init clkgen_mux_get_parents(struct 
device_node *np,
if (!parents)
return ERR_PTR(-ENOMEM);
 
-   for (i = 0; i  nparents; i++)
-   parents[i] = of_clk_get_parent_name(np, i);
-
-   *num_parents = nparents;
+   *num_parents = of_clk_parent_fill(np, parents, nparents);
return parents;
 }
 
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/6] clk: ti: make use of of_clk_parent_fill helper function

2015-06-10 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock names' array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Tero Kristo t-kri...@ti.com
---
 drivers/clk/ti/apll.c  | 4 +---
 drivers/clk/ti/composite.c | 4 +---
 drivers/clk/ti/dpll.c  | 4 +---
 drivers/clk/ti/fapll.c | 3 +--
 drivers/clk/ti/mux.c   | 4 +---
 5 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c
index 49baf38..523880e 100644
--- a/drivers/clk/ti/apll.c
+++ b/drivers/clk/ti/apll.c
@@ -170,7 +170,6 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
struct clk_hw_omap *clk_hw = NULL;
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
-   int i;
 
ad = kzalloc(sizeof(*ad), GFP_KERNEL);
clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL);
@@ -195,8 +194,7 @@ static void __init of_dra7_apll_setup(struct device_node 
*node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  init-num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init-num_parents);
 
init-parent_names = parent_names;
 
diff --git a/drivers/clk/ti/composite.c b/drivers/clk/ti/composite.c
index 96f83ce..dbef218 100644
--- a/drivers/clk/ti/composite.c
+++ b/drivers/clk/ti/composite.c
@@ -276,7 +276,6 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
int num_parents;
const char **parent_names;
struct component_clk *clk;
-   int i;
 
num_parents = of_clk_get_parent_count(node);
 
@@ -289,8 +288,7 @@ int __init ti_clk_add_component(struct device_node *node, 
struct clk_hw *hw,
if (!parent_names)
return -ENOMEM;
 
-   for (i = 0; i  num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
clk = kzalloc(sizeof(*clk), GFP_KERNEL);
if (!clk) {
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c
index 2aacf7a..49acdf2 100644
--- a/drivers/clk/ti/dpll.c
+++ b/drivers/clk/ti/dpll.c
@@ -341,7 +341,6 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
struct clk_init_data *init = NULL;
const char **parent_names = NULL;
struct dpll_data *dd = NULL;
-   int i;
u8 dpll_mode = 0;
 
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
@@ -370,8 +369,7 @@ static void __init of_ti_dpll_setup(struct device_node 
*node,
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  init-num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, init-num_parents);
 
init-parent_names = parent_names;
 
diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c
index 730aa62..b1c741b 100644
--- a/drivers/clk/ti/fapll.c
+++ b/drivers/clk/ti/fapll.c
@@ -558,8 +558,7 @@ static void __init ti_fapll_setup(struct device_node *node)
goto free;
}
 
-   parent_name[0] = of_clk_get_parent_name(node, 0);
-   parent_name[1] = of_clk_get_parent_name(node, 1);
+   of_clk_parent_fill(node, parent_name, 2);
init-parent_names = parent_name;
 
fd-clk_ref = of_clk_get(node, 0);
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c
index 5cdeed5..99fe27e 100644
--- a/drivers/clk/ti/mux.c
+++ b/drivers/clk/ti/mux.c
@@ -190,7 +190,6 @@ static void of_mux_clk_setup(struct device_node *node)
void __iomem *reg;
int num_parents;
const char **parent_names;
-   int i;
u8 clk_mux_flags = 0;
u32 mask = 0;
u32 shift = 0;
@@ -205,8 +204,7 @@ static void of_mux_clk_setup(struct device_node *node)
if (!parent_names)
goto cleanup;
 
-   for (i = 0; i  num_parents; i++)
-   parent_names[i] = of_clk_get_parent_name(node, i);
+   of_clk_parent_fill(node, parent_names, num_parents);
 
reg = ti_clk_get_reg_addr(node, 0);
 
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-05 Thread dinguyen
From: Dinh Nguyen 

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen 
---
v3: shorten and clean up function comment, use EXPORT_SYMBOL_GPL
v2: use unsigned int for size
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..5130622 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/**
+ * of_clk_parent_fill(): Fill @parents with names of @np's parents and return
+ * number of parents.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parents' name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size)
+{
+   unsigned int i = 0;
+
+   while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL_GPL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..3ab66d3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-05 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen 
---
v3: none
v2: none
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, "reg", );
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk->hw.hw.init = 
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 0/2] clk: of: add helper function to fill parent clock array

2015-06-05 Thread dinguyen
From: Dinh Nguyen 

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since the following code is sprinkled all over the platform clock drivers:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

v3: shorten and clean up function comment, use EXPORT_SYMBOL_GPL
v2: use unsigned int for size

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] EDAC, altera: wrap edac pm with a CONFIG_PM

2015-06-05 Thread dinguyen
From: Alan Tull 

Suspend-to-RAM and EDAC support are mutually exclusive on
SOCFPGA.  If the EDAC is enabled, it will prevent the
platform from going into suspend.

Signed-off-by: Alan Tull 
Signed-off-by: Dinh Nguyen 
Acked-by: Borislav Petkov 
---
Hi Boris,

Please apply this patch to your for-next? This was part of Alan Tull's
suspend-to-ram patch that I was going to take through arm-soc. But if
I left the patch as it was, it would have caused a merge conflict for
v4.2.

Thanks,
Dinh
---
 drivers/edac/altera_edac.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 182c741..23ef091 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -477,11 +477,31 @@ static int altr_sdram_remove(struct platform_device *pdev)
return 0;
 }
 
+/*
+ * If you want to suspend, need to disable EDAC by removing it
+ * from the device tree or defconfig.
+ */
+#ifdef CONFIG_PM
+static int altr_sdram_prepare(struct device *dev)
+{
+   pr_err("Suspend not allowed when EDAC is enabled.\n");
+
+   return -EPERM;
+}
+
+static const struct dev_pm_ops altr_sdram_pm_ops = {
+   .prepare = altr_sdram_prepare,
+};
+#endif
+
 static struct platform_driver altr_sdram_edac_driver = {
.probe = altr_sdram_probe,
.remove = altr_sdram_remove,
.driver = {
.name = "altr_sdram_edac",
+#ifdef CONFIG_PM
+   .pm = _sdram_pm_ops,
+#endif
.of_match_table = altr_sdram_ctrl_of_match,
},
 };
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] EDAC, altera: wrap edac pm with a CONFIG_PM

2015-06-05 Thread dinguyen
From: Alan Tull at...@opensource.altera.com

Suspend-to-RAM and EDAC support are mutually exclusive on
SOCFPGA.  If the EDAC is enabled, it will prevent the
platform from going into suspend.

Signed-off-by: Alan Tull at...@opensource.altera.com
Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Acked-by: Borislav Petkov b...@suse.de
---
Hi Boris,

Please apply this patch to your for-next? This was part of Alan Tull's
suspend-to-ram patch that I was going to take through arm-soc. But if
I left the patch as it was, it would have caused a merge conflict for
v4.2.

Thanks,
Dinh
---
 drivers/edac/altera_edac.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/edac/altera_edac.c b/drivers/edac/altera_edac.c
index 182c741..23ef091 100644
--- a/drivers/edac/altera_edac.c
+++ b/drivers/edac/altera_edac.c
@@ -477,11 +477,31 @@ static int altr_sdram_remove(struct platform_device *pdev)
return 0;
 }
 
+/*
+ * If you want to suspend, need to disable EDAC by removing it
+ * from the device tree or defconfig.
+ */
+#ifdef CONFIG_PM
+static int altr_sdram_prepare(struct device *dev)
+{
+   pr_err(Suspend not allowed when EDAC is enabled.\n);
+
+   return -EPERM;
+}
+
+static const struct dev_pm_ops altr_sdram_pm_ops = {
+   .prepare = altr_sdram_prepare,
+};
+#endif
+
 static struct platform_driver altr_sdram_edac_driver = {
.probe = altr_sdram_probe,
.remove = altr_sdram_remove,
.driver = {
.name = altr_sdram_edac,
+#ifdef CONFIG_PM
+   .pm = altr_sdram_pm_ops,
+#endif
.of_match_table = altr_sdram_ctrl_of_match,
},
 };
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-05 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v3: none
v2: none
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk-hw.hw.init = init;
 
clk = clk_register(NULL, socfpga_clk-hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, reg, reg);
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk-hw.hw.init = init;
 
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-05 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v3: shorten and clean up function comment, use EXPORT_SYMBOL_GPL
v2: use unsigned int for size
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..5130622 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/**
+ * of_clk_parent_fill(): Fill @parents with names of @np's parents and return
+ * number of parents.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parents' name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size)
+{
+   unsigned int i = 0;
+
+   while (i  size  (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL_GPL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..3ab66d3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHv3 0/2] clk: of: add helper function to fill parent clock array

2015-06-05 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since the following code is sprinkled all over the platform clock drivers:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

v3: shorten and clean up function comment, use EXPORT_SYMBOL_GPL
v2: use unsigned int for size

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-04 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen 
---
v2: none
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, "reg", );
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk->hw.hw.init = 
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 0/2] clk: of: add helper function to fill parent clock array

2015-06-04 Thread dinguyen
From: Dinh Nguyen 

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since the following code is sprinkled all over the platform clock drivers:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

v2: use unsigned int for 'size'

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-04 Thread dinguyen
From: Dinh Nguyen 

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen 
---
v2: use unsigned int for size
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..778bebd 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/*
+ * of_clk_parent_fill(): Helper clock function that will fill the parent
+ * clock's array and return the number of parents it found.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parent's name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size)
+{
+   unsigned int i = 0;
+
+   while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..3ab66d3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-04 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v2: use unsigned int for size
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..778bebd 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/*
+ * of_clk_parent_fill(): Helper clock function that will fill the parent
+ * clock's array and return the number of parents it found.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parent's name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size)
+{
+   unsigned int i = 0;
+
+   while (i  size  (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..3ab66d3 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, unsigned 
int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 0/2] clk: of: add helper function to fill parent clock array

2015-06-04 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since the following code is sprinkled all over the platform clock drivers:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

v2: use unsigned int for 'size'

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv2 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-04 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
v2: none
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk-hw.hw.init = init;
 
clk = clk_register(NULL, socfpga_clk-hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, reg, reg);
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk-hw.hw.init = init;
 
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-01 Thread dinguyen
From: Dinh Nguyen 

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..b75616f 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/*
+ * of_clk_parent_fill(): Helper clock function that will fill the parent
+ * clock's array and return the number of parents it found.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parent's name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, int size)
+{
+   int i = 0;
+
+   while (i < size && (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..36e56c4 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-01 Thread dinguyen
From: Dinh Nguyen 

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen 
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk->hw.hw.init = 
 
clk = clk_register(NULL, _clk->hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, "reg", );
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i < SOCFPGA_MAX_PARENTS && (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk->hw.hw.init = 
 
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 0/2] clk: of: add helper function to fill parent clock array

2015-06-01 Thread dinguyen
From: Dinh Nguyen 

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since this kind of code is sprinkled all over the platform clock drivers:

for (i = 0; i < num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 0/2] clk: of: add helper function to fill parent clock array

2015-06-01 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Hi,

As suggested by Stephen Boyd, this patch adds a helper function that will fill
the parent clock array.

Since this kind of code is sprinkled all over the platform clock drivers:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The above code can be replace by of_clk_parent_fill(). And since the logic
of the of_clk_parent_fill is to walk the clock node to find the parent, it is
easy to just return the number of parents as well.

The second patch makes use of the new helper function in the SoCFPGA platform.
If this patch is accepted, I can go through and replace the other platforms
after that.

Thanks,

Dinh Nguyen (2):
  clk: of: helper for filling parent clock array and return num of
parents
  clk: socfpga: make use of of_clk_parent_fill helper function

 drivers/clk/clk.c  | 20 
 drivers/clk/socfpga/clk-gate.c |  6 +-
 drivers/clk/socfpga/clk-pll.c  |  7 +--
 include/linux/clk-provider.h   |  1 +
 4 files changed, 23 insertions(+), 11 deletions(-)

-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 1/2] clk: of: helper for filling parent clock array and return num of parents

2015-06-01 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Sprinkled all through the platform clock drivers are code like this to
fill the clock parent array:

for (i = 0; i  num_parents; ++i)
parent_names[i] = of_clk_get_parent_name(np, i);

The of_clk_parent_fill() will do the same as the code above, and while
at it, return the number of parents as well since the logic of the
function is to the walk the clock node to look for the parent.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/clk/clk.c| 20 
 include/linux/clk-provider.h |  1 +
 2 files changed, 21 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 459ce9d..b75616f 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3060,6 +3060,26 @@ const char *of_clk_get_parent_name(struct device_node 
*np, int index)
 }
 EXPORT_SYMBOL_GPL(of_clk_get_parent_name);
 
+/*
+ * of_clk_parent_fill(): Helper clock function that will fill the parent
+ * clock's array and return the number of parents it found.
+ * @np: Device node pointer associated with clock provider
+ * @parents: pointer to char array that hold the parent's name
+ * @size: size of the parents array
+ *
+ * Returns number of parents for the clock node.
+ */
+int of_clk_parent_fill(struct device_node *np, const char **parents, int size)
+{
+   int i = 0;
+
+   while (i  size  (parents[i] = of_clk_get_parent_name(np, i)) != NULL)
+   i++;
+
+   return i;
+}
+EXPORT_SYMBOL(of_clk_parent_fill);
+
 struct clock_provider {
of_clk_init_cb_t clk_init_cb;
struct device_node *np;
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index df69531..36e56c4 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -624,6 +624,7 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args 
*clkspec,
  void *data);
 struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void 
*data);
 int of_clk_get_parent_count(struct device_node *np);
+int of_clk_parent_fill(struct device_node *np, const char **parents, int size);
 const char *of_clk_get_parent_name(struct device_node *np, int index);
 
 void of_clk_init(const struct of_device_id *matches);
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC/PATCHv1 2/2] clk: socfpga: make use of of_clk_parent_fill helper function

2015-06-01 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

Use of_clk_parent_fill to fill in the parent clock's array.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
---
 drivers/clk/socfpga/clk-gate.c | 6 +-
 drivers/clk/socfpga/clk-pll.c  | 7 +--
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/clk/socfpga/clk-gate.c b/drivers/clk/socfpga/clk-gate.c
index dd3a78c..fb5a5d7 100644
--- a/drivers/clk/socfpga/clk-gate.c
+++ b/drivers/clk/socfpga/clk-gate.c
@@ -194,7 +194,6 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
const char *parent_name[SOCFPGA_MAX_PARENTS];
struct clk_init_data init;
int rc;
-   int i = 0;
 
socfpga_clk = kzalloc(sizeof(*socfpga_clk), GFP_KERNEL);
if (WARN_ON(!socfpga_clk))
@@ -238,12 +237,9 @@ static void __init __socfpga_gate_init(struct device_node 
*node,
init.name = clk_name;
init.ops = ops;
init.flags = 0;
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
 
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
-   init.num_parents = i;
socfpga_clk-hw.hw.init = init;
 
clk = clk_register(NULL, socfpga_clk-hw.hw);
diff --git a/drivers/clk/socfpga/clk-pll.c b/drivers/clk/socfpga/clk-pll.c
index de6da95..8f26b52 100644
--- a/drivers/clk/socfpga/clk-pll.c
+++ b/drivers/clk/socfpga/clk-pll.c
@@ -92,7 +92,6 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
struct clk_init_data init;
struct device_node *clkmgr_np;
int rc;
-   int i = 0;
 
of_property_read_u32(node, reg, reg);
 
@@ -111,11 +110,7 @@ static __init struct clk *__socfpga_pll_init(struct 
device_node *node,
init.ops = ops;
init.flags = 0;
 
-   while (i  SOCFPGA_MAX_PARENTS  (parent_name[i] =
-   of_clk_get_parent_name(node, i)) != NULL)
-   i++;
-
-   init.num_parents = i;
+   init.num_parents = of_clk_parent_fill(node, parent_name, 
SOCFPGA_MAX_PARENTS);
init.parent_names = parent_name;
pll_clk-hw.hw.init = init;
 
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] usb: dwc2: fix unnecessary USB overcurrent condition

2015-05-26 Thread dinguyen
From: Dinh Nguyen 

For platforms that use a ULPI phy, we should enable the external VbusValid
signal instead.

Signed-off-by: Dinh Nguyen 
Cc: Gregory Herrero 
Cc: Mian Yousaf Kaukab 
Cc: Felipe Balbi 
---
 drivers/usb/dwc2/core.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index e5b546f..08ffdc6 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -807,6 +807,11 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy, int irq)
if (hsotg->core_params->ts_dline > 0)
usbcfg |= GUSBCFG_TERMSELDLPULSE;
 
+   /* Set external VBUS indicator as needed. */
+   if (hsotg->core_params->phy_type == DWC2_PHY_TYPE_PARAM_ULPI)
+   usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
+  GUSBCFG_INDICATORPASSTHROUGH);
+
writel(usbcfg, hsotg->regs + GUSBCFG);
 
/* Reset the Controller */
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] usb: dwc2: fix unnecessary USB overcurrent condition

2015-05-26 Thread dinguyen
From: Dinh Nguyen dingu...@opensource.altera.com

For platforms that use a ULPI phy, we should enable the external VbusValid
signal instead.

Signed-off-by: Dinh Nguyen dingu...@opensource.altera.com
Cc: Gregory Herrero gregory.herr...@intel.com
Cc: Mian Yousaf Kaukab yousaf.kau...@intel.com
Cc: Felipe Balbi ba...@ti.com
---
 drivers/usb/dwc2/core.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index e5b546f..08ffdc6 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -807,6 +807,11 @@ int dwc2_core_init(struct dwc2_hsotg *hsotg, bool 
select_phy, int irq)
if (hsotg-core_params-ts_dline  0)
usbcfg |= GUSBCFG_TERMSELDLPULSE;
 
+   /* Set external VBUS indicator as needed. */
+   if (hsotg-core_params-phy_type == DWC2_PHY_TYPE_PARAM_ULPI)
+   usbcfg |= (GUSBCFG_ULPI_INT_VBUS_IND |
+  GUSBCFG_INDICATORPASSTHROUGH);
+
writel(usbcfg, hsotg-regs + GUSBCFG);
 
/* Reset the Controller */
-- 
2.2.1

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] ARM: socfpga: use CPU_METHOD_OF_DECLARE for socfpga_cyclone5

2015-05-22 Thread dinguyen
From: Dinh Nguyen 

Convert cyclone5/arria5 to use CPU_METHOD_OF_DECLARE for smp operations.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/mach-socfpga/platsmp.c | 2 ++
 arch/arm/mach-socfpga/socfpga.c | 1 -
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
index 7886eae..08250c8 100644
--- a/arch/arm/mach-socfpga/platsmp.c
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -90,3 +90,5 @@ struct smp_operations socfpga_smp_ops __initdata = {
.cpu_die= socfpga_cpu_die,
 #endif
 };
+
+CPU_METHOD_OF_DECLARE(socfpga_smp, "altr,socfpga-smp", _smp_ops);
diff --git a/arch/arm/mach-socfpga/socfpga.c b/arch/arm/mach-socfpga/socfpga.c
index b63dec6..a154920 100644
--- a/arch/arm/mach-socfpga/socfpga.c
+++ b/arch/arm/mach-socfpga/socfpga.c
@@ -78,7 +78,6 @@ static const char *altera_dt_match[] = {
 DT_MACHINE_START(SOCFPGA, "Altera SOCFPGA")
.l2c_aux_val= 0,
.l2c_aux_mask   = ~0,
-   .smp= smp_ops(socfpga_smp_ops),
.init_irq   = socfpga_init_irq,
.restart= socfpga_cyclone5_restart,
.dt_compat  = altera_dt_match,
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] ARM: socfpga: add CPU_METHOD_OF_DECLARE for Arria 10

2015-05-22 Thread dinguyen
From: Dinh Nguyen 

Add boot_secondary implementation for the Arria10 platform. Bringing up
the secondary core on the Arria 10 platform is pretty similar to the
Cyclone/Arria 5 platform, with the exception of the following differences:

- Register offset to bringup CPU1 out of reset is different.
- The cpu1-start-addr for Arria10 contains an additional nibble.

Signed-off-by: Dinh Nguyen 
---
 arch/arm/mach-socfpga/core.h|  2 ++
 arch/arm/mach-socfpga/platsmp.c | 30 ++
 2 files changed, 32 insertions(+)

diff --git a/arch/arm/mach-socfpga/core.h b/arch/arm/mach-socfpga/core.h
index 5913bbb..7637b7f 100644
--- a/arch/arm/mach-socfpga/core.h
+++ b/arch/arm/mach-socfpga/core.h
@@ -25,6 +25,8 @@
 #define SOCFPGA_RSTMGR_MODPERRST   0x14
 #define SOCFPGA_RSTMGR_BRGMODRST   0x1c
 
+#define SOCFPGA_A10_RSTMGR_MODMPURST   0x20
+
 /* System Manager bits */
 #define RSTMGR_CTRL_SWCOLDRSTREQ   0x1 /* Cold Reset */
 #define RSTMGR_CTRL_SWWARMRSTREQ   0x2 /* Warm Reset */
diff --git a/arch/arm/mach-socfpga/platsmp.c b/arch/arm/mach-socfpga/platsmp.c
index 08250c8..bcc7ce8 100644
--- a/arch/arm/mach-socfpga/platsmp.c
+++ b/arch/arm/mach-socfpga/platsmp.c
@@ -54,6 +54,27 @@ static int socfpga_boot_secondary(unsigned int cpu, struct 
task_struct *idle)
return 0;
 }
 
+static int socfpga_a10_boot_secondary(unsigned int cpu, struct task_struct 
*idle)
+{
+   int trampoline_size = _trampoline_end - _trampoline;
+
+   if (socfpga_cpu1start_addr) {
+   memcpy(phys_to_virt(0), _trampoline, trampoline_size);
+
+   writel(virt_to_phys(socfpga_secondary_startup),
+  sys_manager_base_addr + (socfpga_cpu1start_addr & 
0x0fff));
+
+   flush_cache_all();
+   smp_wmb();
+   outer_clean_range(0, trampoline_size);
+
+   /* This will release CPU #1 out of reset. */
+   writel(0, rst_manager_base_addr + SOCFPGA_A10_RSTMGR_MODMPURST);
+   }
+
+   return 0;
+}
+
 static void __init socfpga_smp_prepare_cpus(unsigned int max_cpus)
 {
struct device_node *np;
@@ -91,4 +112,13 @@ struct smp_operations socfpga_smp_ops __initdata = {
 #endif
 };
 
+struct smp_operations socfpga_a10_smp_ops __initdata = {
+   .smp_prepare_cpus   = socfpga_smp_prepare_cpus,
+   .smp_boot_secondary = socfpga_a10_boot_secondary,
+#ifdef CONFIG_HOTPLUG_CPU
+   .cpu_die= socfpga_cpu_die,
+#endif
+};
+
 CPU_METHOD_OF_DECLARE(socfpga_smp, "altr,socfpga-smp", _smp_ops);
+CPU_METHOD_OF_DECLARE(socfpga_a10_smp, "altr,socfpga-a10-smp", 
_a10_smp_ops);
-- 
2.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >