* [PATCH v3 1/9] clk: sunxi: Add A23 APB0 divider clock support
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
@ 2014-07-03 14:55 ` Chen-Yu Tsai
[not found] ` <1404399349-20237-2-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2014-07-03 14:55 ` [PATCH v3 2/9] clk: sunxi: Fix gate indexing for sun6i-a31-apb0-gates Chen-Yu Tsai
` (7 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The A23 has an almost identical PRCM clock tree. The difference in
the APB0 clock is the smallest divisor is 1, instead of 2.
This patch adds a separate sun8i-a23-apb0-clk driver to support it.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
drivers/clk/sunxi/Makefile | 4 +-
drivers/clk/sunxi/clk-sun8i-apb0.c | 68 +++++++++++++++++++++++
3 files changed, 72 insertions(+), 1 deletion(-)
create mode 100644 drivers/clk/sunxi/clk-sun8i-apb0.c
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 18030ce..68dbd3d 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -28,6 +28,7 @@ Required properties:
"allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
"allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
"allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31
+ "allwinner,sun8i-a23-apb0-clk" - for the APB0 clock on A23
"allwinner,sun4i-a10-apb0-gates-clk" - for the APB0 gates on A10
"allwinner,sun5i-a13-apb0-gates-clk" - for the APB0 gates on A13
"allwinner,sun5i-a10s-apb0-gates-clk" - for the APB0 gates on A10s
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 762fd64..6850cba 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -6,4 +6,6 @@ obj-y += clk-sunxi.o clk-factors.o
obj-y += clk-a10-hosc.o
obj-y += clk-a20-gmac.o
-obj-$(CONFIG_MFD_SUN6I_PRCM) += clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o
+obj-$(CONFIG_MFD_SUN6I_PRCM) += \
+ clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
+ clk-sun8i-apb0.o
diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c b/drivers/clk/sunxi/clk-sun8i-apb0.c
new file mode 100644
index 0000000..196a499
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun8i-apb0.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2014 Chen-Yu Tsai
+ * Author: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
+ *
+ * Allwinner A23 APB0 clock driver
+ *
+ * License Terms: GNU General Public License v2
+ *
+ * Based on clk-sun6i-apb0.c
+ * Allwinner A31 APB0 clock driver
+ *
+ * Copyright (C) 2014 Free Electrons
+ * Author: Boris BREZILLON <boris.brezillon-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
+ *
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+static int sun8i_a23_apb0_clk_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const char *clk_name = np->name;
+ const char *clk_parent;
+ struct resource *r;
+ void __iomem *reg;
+ struct clk *clk;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ reg = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(reg))
+ return PTR_ERR(reg);
+
+ clk_parent = of_clk_get_parent_name(np, 0);
+ if (!clk_parent)
+ return -EINVAL;
+
+ of_property_read_string(np, "clock-output-names", &clk_name);
+
+ /* The A23 APB0 clock is a standard 2 bit wide divider clock */
+ clk = clk_register_divider(&pdev->dev, clk_name, clk_parent, 0, reg,
+ 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ return of_clk_add_provider(np, of_clk_src_simple_get, clk);
+}
+
+const struct of_device_id sun8i_a23_apb0_clk_dt_ids[] = {
+ { .compatible = "allwinner,sun8i-a23-apb0-clk" },
+ { /* sentinel */ }
+};
+
+static struct platform_driver sun8i_a23_apb0_clk_driver = {
+ .driver = {
+ .name = "sun8i-a23-apb0-clk",
+ .owner = THIS_MODULE,
+ .of_match_table = sun8i_a23_apb0_clk_dt_ids,
+ },
+ .probe = sun8i_a23_apb0_clk_probe,
+};
+module_platform_driver(sun8i_a23_apb0_clk_driver);
+
+MODULE_AUTHOR("Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>");
+MODULE_DESCRIPTION("Allwinner A23 APB0 clock Driver");
+MODULE_LICENSE("GPL v2");
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 2/9] clk: sunxi: Fix gate indexing for sun6i-a31-apb0-gates
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2014-07-03 14:55 ` [PATCH v3 1/9] clk: sunxi: Add A23 APB0 divider clock support Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
2014-07-07 8:54 ` Maxime Ripard
2014-07-03 14:55 ` [PATCH v3 3/9] clk: sunxi: Add A23 specific compatible to sun6i-a31-apb0-gates-clk Chen-Yu Tsai
` (6 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
sun6i-a31-apb0-gates supports using clock-indices for holes between
individual gates. However, the driver passes the number of gates
registered in clk_data->clk_num, which of_clk_src_onecell_get uses
to recognize the range of valid indices a consumer can use.
This patch makes the driver pass the maximum gate index + 1, so
of_clk_src_onecell_get does not complain about indices greater
than gates registered.
This was tested on the A23 SoC, which has a similar APB0 clock,
but has holes for gates to removed IP blocks.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
drivers/clk/sunxi/clk-sun6i-apb0-gates.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
index 44cd27c..b342f2a 100644
--- a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
+++ b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
@@ -25,6 +25,7 @@ static int sun6i_a31_apb0_gates_clk_probe(struct platform_device *pdev)
void __iomem *reg;
int gate_id;
int ngates;
+ int gate_max = 0;
int i;
r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -72,9 +73,12 @@ static int sun6i_a31_apb0_gates_clk_probe(struct platform_device *pdev)
reg, gate_id,
0, NULL);
WARN_ON(IS_ERR(clk_data->clks[gate_id]));
+
+ if (gate_id > gate_max)
+ gate_max = gate_id;
}
- clk_data->clk_num = ngates;
+ clk_data->clk_num = gate_max + 1;
return of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
}
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 2/9] clk: sunxi: Fix gate indexing for sun6i-a31-apb0-gates
2014-07-03 14:55 ` [PATCH v3 2/9] clk: sunxi: Fix gate indexing for sun6i-a31-apb0-gates Chen-Yu Tsai
@ 2014-07-07 8:54 ` Maxime Ripard
0 siblings, 0 replies; 17+ messages in thread
From: Maxime Ripard @ 2014-07-07 8:54 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Lee Jones, Samuel Ortiz, Rob Herring, Greg Kroah-Hartman,
Emilio Lopez, Mike Turquette, linux-arm-kernel, devicetree,
linux-serial, linux-sunxi
[-- Attachment #1: Type: text/plain, Size: 874 bytes --]
On Thu, Jul 03, 2014 at 10:55:42PM +0800, Chen-Yu Tsai wrote:
> sun6i-a31-apb0-gates supports using clock-indices for holes between
> individual gates. However, the driver passes the number of gates
> registered in clk_data->clk_num, which of_clk_src_onecell_get uses
> to recognize the range of valid indices a consumer can use.
>
> This patch makes the driver pass the maximum gate index + 1, so
> of_clk_src_onecell_get does not complain about indices greater
> than gates registered.
>
> This was tested on the A23 SoC, which has a similar APB0 clock,
> but has holes for gates to removed IP blocks.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Applied, thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 3/9] clk: sunxi: Add A23 specific compatible to sun6i-a31-apb0-gates-clk
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2014-07-03 14:55 ` [PATCH v3 1/9] clk: sunxi: Add A23 APB0 divider clock support Chen-Yu Tsai
2014-07-03 14:55 ` [PATCH v3 2/9] clk: sunxi: Fix gate indexing for sun6i-a31-apb0-gates Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
2014-07-03 14:55 ` [PATCH v3 4/9] mfd: sun6i-prcm: Add support for Allwinner A23 PRCM Chen-Yu Tsai
` (5 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The sun6i-a31-apb0-gates-clk driver is generic in that it supports
the "clock-indicies" DT property with "clock-output-names" to list
the valid clock gate bits.
However this might lead one to assume that the clock in the A23 is
the same as the A31. To make it clear, we add a new compatible for
the A23, "allwinner,sun8i-a23-apb0-gates-clk".
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
drivers/clk/sunxi/clk-sun6i-apb0-gates.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index 68dbd3d..d3a5c3c 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -34,6 +34,7 @@ Required properties:
"allwinner,sun5i-a10s-apb0-gates-clk" - for the APB0 gates on A10s
"allwinner,sun6i-a31-apb0-gates-clk" - for the APB0 gates on A31
"allwinner,sun7i-a20-apb0-gates-clk" - for the APB0 gates on A20
+ "allwinner,sun8i-a23-apb0-gates-clk" - for the APB0 gates on A23
"allwinner,sun4i-a10-apb1-clk" - for the APB1 clock
"allwinner,sun4i-a10-apb1-mux-clk" - for the APB1 clock muxing
"allwinner,sun4i-a10-apb1-gates-clk" - for the APB1 gates on A10
diff --git a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
index b342f2a..f147fee 100644
--- a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
+++ b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c
@@ -85,6 +85,7 @@ static int sun6i_a31_apb0_gates_clk_probe(struct platform_device *pdev)
const struct of_device_id sun6i_a31_apb0_gates_clk_dt_ids[] = {
{ .compatible = "allwinner,sun6i-a31-apb0-gates-clk" },
+ { .compatible = "allwinner,sun8i-a23-apb0-gates-clk" },
{ /* sentinel */ }
};
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 4/9] mfd: sun6i-prcm: Add support for Allwinner A23 PRCM
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (2 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 3/9] clk: sunxi: Add A23 specific compatible to sun6i-a31-apb0-gates-clk Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
[not found] ` <1404399349-20237-5-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2014-07-03 14:55 ` [PATCH v3 5/9] serial: 8250_dw: Add optional reset control support Chen-Yu Tsai
` (4 subsequent siblings)
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The Allwinner A23 SoC has a PRCM unit like the previous A31 SoC.
The differences are the AR100 clock can no longer be modified,
the APB0 clock has different divisors, and some clock gates are
gone.
This patch adds a compatible with a modified subdevice list for
the A23.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
.../devicetree/bindings/mfd/sun6i-prcm.txt | 2 +-
drivers/mfd/sun6i-prcm.c | 30 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
index 1f5a31f..03c5a55 100644
--- a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
+++ b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
@@ -4,7 +4,7 @@ PRCM is an MFD device exposing several Power Management related devices
(like clks and reset controllers).
Required properties:
- - compatible: "allwinner,sun6i-a31-prcm"
+ - compatible: "allwinner,sun6i-a31-prcm" or "allwinner,sun8i-a23-prcm"
- reg: The PRCM registers range
The prcm node may contain several subdevices definitions:
diff --git a/drivers/mfd/sun6i-prcm.c b/drivers/mfd/sun6i-prcm.c
index 718fc4d..283ab8d 100644
--- a/drivers/mfd/sun6i-prcm.c
+++ b/drivers/mfd/sun6i-prcm.c
@@ -76,16 +76,46 @@ static const struct mfd_cell sun6i_a31_prcm_subdevs[] = {
},
};
+static const struct mfd_cell sun8i_a23_prcm_subdevs[] = {
+ {
+ .name = "sun8i-a23-apb0-clk",
+ .of_compatible = "allwinner,sun8i-a23-apb0-clk",
+ .num_resources = ARRAY_SIZE(sun6i_a31_apb0_clk_res),
+ .resources = sun6i_a31_apb0_clk_res,
+ },
+ {
+ .name = "sun6i-a31-apb0-gates-clk",
+ .of_compatible = "allwinner,sun8i-a23-apb0-gates-clk",
+ .num_resources = ARRAY_SIZE(sun6i_a31_apb0_gates_clk_res),
+ .resources = sun6i_a31_apb0_gates_clk_res,
+ },
+ {
+ .name = "sun6i-a31-apb0-clock-reset",
+ .of_compatible = "allwinner,sun6i-a31-clock-reset",
+ .num_resources = ARRAY_SIZE(sun6i_a31_apb0_rstc_res),
+ .resources = sun6i_a31_apb0_rstc_res,
+ },
+};
+
static const struct prcm_data sun6i_a31_prcm_data = {
.nsubdevs = ARRAY_SIZE(sun6i_a31_prcm_subdevs),
.subdevs = sun6i_a31_prcm_subdevs,
};
+static const struct prcm_data sun8i_a23_prcm_data = {
+ .nsubdevs = ARRAY_SIZE(sun8i_a23_prcm_subdevs),
+ .subdevs = sun8i_a23_prcm_subdevs,
+};
+
static const struct of_device_id sun6i_prcm_dt_ids[] = {
{
.compatible = "allwinner,sun6i-a31-prcm",
.data = &sun6i_a31_prcm_data,
},
+ {
+ .compatible = "allwinner,sun8i-a23-prcm",
+ .data = &sun8i_a23_prcm_data,
+ },
{ /* sentinel */ },
};
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 5/9] serial: 8250_dw: Add optional reset control support
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (3 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 4/9] mfd: sun6i-prcm: Add support for Allwinner A23 PRCM Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
2014-07-03 14:55 ` [PATCH v3 6/9] serial: 8250_dw: Add support for deferred probing Chen-Yu Tsai
` (3 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The Allwinner A31 and A23 SoCs have a reset controller
maintaining the UART in reset by default.
This patch adds optional reset support to the driver.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
Acked-by: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt | 1 +
drivers/tty/serial/8250/8250_dw.c | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt
index f13f1c5..cb9af84 100644
--- a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt
+++ b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.txt
@@ -7,6 +7,7 @@ Required properties:
- clock-frequency : the input clock frequency for the UART.
Optional properties:
+- resets : phandle to the parent reset controller.
- reg-shift : quantity to shift the register offsets by. If this property is
not present then the register offsets are not shifted.
- reg-io-width : the size (in bytes) of the IO accesses that should be
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 51b307a..cb1b3dc 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -26,6 +26,7 @@
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/clk.h>
+#include <linux/reset.h>
#include <linux/pm_runtime.h>
#include <asm/byteorder.h>
@@ -59,6 +60,7 @@ struct dw8250_data {
int last_mcr;
int line;
struct clk *clk;
+ struct reset_control *rst;
struct uart_8250_dma dma;
};
@@ -408,6 +410,10 @@ static int dw8250_probe(struct platform_device *pdev)
uart.port.uartclk = clk_get_rate(data->clk);
}
+ data->rst = devm_reset_control_get_optional(&pdev->dev, NULL);
+ if (!IS_ERR(data->rst))
+ reset_control_deassert(data->rst);
+
data->dma.rx_chan_id = -1;
data->dma.tx_chan_id = -1;
data->dma.rx_param = data;
@@ -451,6 +457,9 @@ static int dw8250_remove(struct platform_device *pdev)
serial8250_unregister_port(data->line);
+ if (!IS_ERR(data->rst))
+ reset_control_assert(data->rst);
+
if (!IS_ERR(data->clk))
clk_disable_unprepare(data->clk);
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 6/9] serial: 8250_dw: Add support for deferred probing
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (4 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 5/9] serial: 8250_dw: Add optional reset control support Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
2014-07-03 14:55 ` [PATCH v3 7/9] ARM: sunxi: select MFD_SUN6I_PRCM when sun8i arch support is enabled Chen-Yu Tsai
` (2 subsequent siblings)
8 siblings, 0 replies; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The 8250_dw driver fails to probe if the specified clock isn't
registered at probe time. Even if a clock frequency is given,
the required clock might be gated because it wasn't properly
enabled.
This happened to me when the device is registered through DT,
and the clock was part of an MFD, the PRCM found on A31 and A23
SoCs. Unlike core clocks that are registered with OF_CLK_DECLARE,
which happen almost immediately after the kernel starts, the
clocks are registered as sub-devices of the PRCM MFD platform
device. Even though devices are registered in the order they are
found in the DT, the drivers are registered in a different,
arbitrary order. It is possible that the 8250_dw driver is
registered, and thus associated with the device and probed, before
the clock driver is registered and probed.
8250_dw then reports unable to get the clock, and fails. Without
a working console, the kernel panics.
This patch adds support for deferred probe handling for the clock
and reset controller.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
drivers/tty/serial/8250/8250_dw.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index cb1b3dc..d9eeed7 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -405,12 +405,16 @@ static int dw8250_probe(struct platform_device *pdev)
data->usr_reg = DW_UART_USR;
data->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
if (!IS_ERR(data->clk)) {
clk_prepare_enable(data->clk);
uart.port.uartclk = clk_get_rate(data->clk);
}
data->rst = devm_reset_control_get_optional(&pdev->dev, NULL);
+ if (IS_ERR(data->rst) && PTR_ERR(data->rst) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
if (!IS_ERR(data->rst))
reset_control_deassert(data->rst);
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 7/9] ARM: sunxi: select MFD_SUN6I_PRCM when sun8i arch support is enabled
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (5 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 6/9] serial: 8250_dw: Add support for deferred probing Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
2014-07-07 9:00 ` Maxime Ripard
2014-07-03 14:55 ` [PATCH v3 8/9] ARM: sun8i: Add PRCM clock and reset controller nodes to the DTSI Chen-Yu Tsai
2014-07-03 14:55 ` [PATCH v3 9/9] ARM: sun8i: Add " Chen-Yu Tsai
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
Select the MFD_SUN6I_PRCM option when sun8i arch is enabled in order to
get the PRCM (Power/Reset/Clock Management) related drivers compiled.
Also select ARCH_HAS_RESET_CONTROLLER and RESET_CONTROLLER to make sure
the reset controller drivers are compiled.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
arch/arm/mach-sunxi/Kconfig | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/arm/mach-sunxi/Kconfig b/arch/arm/mach-sunxi/Kconfig
index f776c5f..6434e3b 100644
--- a/arch/arm/mach-sunxi/Kconfig
+++ b/arch/arm/mach-sunxi/Kconfig
@@ -38,6 +38,9 @@ config MACH_SUN7I
config MACH_SUN8I
bool "Allwinner A23 (sun8i) SoCs support"
default ARCH_SUNXI
+ select ARCH_HAS_RESET_CONTROLLER
select ARM_GIC
+ select MFD_SUN6I_PRCM
+ select RESET_CONTROLLER
endif
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH v3 7/9] ARM: sunxi: select MFD_SUN6I_PRCM when sun8i arch support is enabled
2014-07-03 14:55 ` [PATCH v3 7/9] ARM: sunxi: select MFD_SUN6I_PRCM when sun8i arch support is enabled Chen-Yu Tsai
@ 2014-07-07 9:00 ` Maxime Ripard
0 siblings, 0 replies; 17+ messages in thread
From: Maxime Ripard @ 2014-07-07 9:00 UTC (permalink / raw)
To: Chen-Yu Tsai
Cc: Lee Jones, Samuel Ortiz, Rob Herring, Greg Kroah-Hartman,
Emilio Lopez, Mike Turquette, linux-arm-kernel, devicetree,
linux-serial, linux-sunxi
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
On Thu, Jul 03, 2014 at 10:55:47PM +0800, Chen-Yu Tsai wrote:
> Select the MFD_SUN6I_PRCM option when sun8i arch is enabled in order to
> get the PRCM (Power/Reset/Clock Management) related drivers compiled.
>
> Also select ARCH_HAS_RESET_CONTROLLER and RESET_CONTROLLER to make sure
> the reset controller drivers are compiled.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
Applied, thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v3 8/9] ARM: sun8i: Add PRCM clock and reset controller nodes to the DTSI
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (6 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 7/9] ARM: sunxi: select MFD_SUN6I_PRCM when sun8i arch support is enabled Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
[not found] ` <1404399349-20237-9-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2014-07-03 14:55 ` [PATCH v3 9/9] ARM: sun8i: Add " Chen-Yu Tsai
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
With sun8i PRCM support available, we can add the PRCM clock and
reset controller nodes to the DTSI. Also update R_UART's clock
phandle and add it's reset control phandle.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
arch/arm/boot/dts/sun8i-a23.dtsi | 48 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/sun8i-a23.dtsi b/arch/arm/boot/dts/sun8i-a23.dtsi
index 79c4083..e10c708 100644
--- a/arch/arm/boot/dts/sun8i-a23.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23.dtsi
@@ -262,13 +262,59 @@
interrupts = <1 9 0xf04>;
};
+ prcm@01f01400 {
+ compatible = "allwinner,sun8i-a23-prcm";
+ reg = <0x01f01400 0x200>;
+
+ ar100: ar100_clk {
+ compatible = "fixed-factor-clock";
+ #clock-cells = <0>;
+ clock-div = <1>;
+ clock-mult = <1>;
+ clocks = <&osc24M>;
+ clock-output-names = "ar100";
+ };
+
+ ahb0: ahb0_clk {
+ compatible = "fixed-factor-clock";
+ #clock-cells = <0>;
+ clock-div = <1>;
+ clock-mult = <1>;
+ clocks = <&ar100>;
+ clock-output-names = "ahb0";
+ };
+
+ apb0: apb0_clk {
+ compatible = "allwinner,sun8i-a23-apb0-clk";
+ #clock-cells = <0>;
+ clocks = <&ahb0>;
+ clock-output-names = "apb0";
+ };
+
+ apb0_gates: apb0_gates_clk {
+ compatible = "allwinner,sun8i-a23-apb0-gates-clk";
+ #clock-cells = <1>;
+ clocks = <&apb0>;
+ clock-indices = <0>, <2>, <3>, <4>, <6>;
+ clock-output-names = "apb0_pio", "apb0_timer",
+ "apb0_rsb", "apb0_uart",
+ "apb0_i2c";
+ };
+
+ apb0_rst: apb0_rst {
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ #reset-cells = <1>;
+ };
+ };
+
r_uart: serial@01f02800 {
compatible = "snps,dw-apb-uart";
reg = <0x01f02800 0x400>;
interrupts = <0 38 4>;
reg-shift = <2>;
reg-io-width = <4>;
- clocks = <&osc24M>;
+ clocks = <&apb0_gates 4>;
+ resets = <&apb0_rst 4>;
status = "disabled";
};
};
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH v3 9/9] ARM: sun8i: Add reset controller nodes to the DTSI
[not found] ` <1404399349-20237-1-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
` (7 preceding siblings ...)
2014-07-03 14:55 ` [PATCH v3 8/9] ARM: sun8i: Add PRCM clock and reset controller nodes to the DTSI Chen-Yu Tsai
@ 2014-07-03 14:55 ` Chen-Yu Tsai
[not found] ` <1404399349-20237-10-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
8 siblings, 1 reply; 17+ messages in thread
From: Chen-Yu Tsai @ 2014-07-03 14:55 UTC (permalink / raw)
To: Maxime Ripard, Lee Jones, Samuel Ortiz, Rob Herring,
Greg Kroah-Hartman, Emilio Lopez, Mike Turquette
Cc: Chen-Yu Tsai, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-sunxi-/JYPxA39Uh5TLH3MbocFFw
The A23 has the same MMIO reset controllers matching the clocks gates,
just like in the A31. This patch adds the reset controller nodes and
the reset control phandles for the peripherals needing them to the
DTSI.
Unlike the sun6i DTSI, this patch uses sun6i-a31-clock-reset for
ahb1_rst. sun6i-a31-ahb-reset is for early init, and requires some
additions to the machine code. It is used to support the hstimer.
However the hstimer on sun8i only has 1 timer, which is somewhat
useless. Support for it will probably not be added. Hence the
decision to use sun6i-a31-clock-reset here to avoid the changes to
sun8i machine code.
Signed-off-by: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>
---
arch/arm/boot/dts/sun8i-a23.dtsi | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/arch/arm/boot/dts/sun8i-a23.dtsi b/arch/arm/boot/dts/sun8i-a23.dtsi
index e10c708..7d47933 100644
--- a/arch/arm/boot/dts/sun8i-a23.dtsi
+++ b/arch/arm/boot/dts/sun8i-a23.dtsi
@@ -187,6 +187,24 @@
#size-cells = <1>;
ranges;
+ ahb1_rst: reset@01c202c0 {
+ #reset-cells = <1>;
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ reg = <0x01c202c0 0xc>;
+ };
+
+ apb1_rst: reset@01c202d0 {
+ #reset-cells = <1>;
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ reg = <0x01c202d0 0x4>;
+ };
+
+ apb2_rst: reset@01c202d8 {
+ #reset-cells = <1>;
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ reg = <0x01c202d8 0x4>;
+ };
+
timer@01c20c00 {
compatible = "allwinner,sun4i-a10-timer";
reg = <0x01c20c00 0xa0>;
@@ -208,6 +226,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&apb2_gates 16>;
+ resets = <&apb2_rst 16>;
status = "disabled";
};
@@ -218,6 +237,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&apb2_gates 17>;
+ resets = <&apb2_rst 17>;
status = "disabled";
};
@@ -228,6 +248,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&apb2_gates 18>;
+ resets = <&apb2_rst 18>;
status = "disabled";
};
@@ -238,6 +259,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&apb2_gates 19>;
+ resets = <&apb2_rst 19>;
status = "disabled";
};
@@ -248,6 +270,7 @@
reg-shift = <2>;
reg-io-width = <4>;
clocks = <&apb2_gates 20>;
+ resets = <&apb2_rst 20>;
status = "disabled";
};
--
2.0.1
^ permalink raw reply related [flat|nested] 17+ messages in thread