clk: sunxi usb clks support
Subsystems (4)
v4 cover clk: sunxi usb clks support
Hi All,
And here is v4 of my sunxi usb clks support series.
Changes since v2:
-rename the compatibilty strings from foo-usb-gates-clk to foo-usb-clk
Changes since v3:
-rename the compatibilty string for sun4i-usb-clk to sun4i-a10-usb-clk
Note the dts bits (patches 3-5) of this series depends on Chen-Yu Tsai's clk rename series.
Emilio, should Mike pick patches 1-2 up directly, or should they go through your tree?
Maxime, can you please add patches 3-5 to your dts tree ? Assuming that wens clk rename patches are already there.
Thanks & Regards,
Hans
PATCH v4 1/5 clk: sunxi: Add support for USB clock-register reset bits
The usb-clk register is special in that it not only contains clk gate bits, but also has a few reset bits. This commit adds support for this by allowing gates type sunxi clks to also register a reset controller.
--- drivers/clk/sunxi/clk-sunxi.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)
drivers/clk/sunxi/clk-sunxi.c +71 -0
@@ -18,6 +18,7 @@#include <linux/clkdev.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/reset-controller.h> #include "clk-factors.h"
@@ -838,6 +839,59 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,/** +* sunxi_gates_reset... - reset bits in leaf gate clk registers handling +*/ + +struct gates_reset_data { +void __iomem *reg; +spinlock_t *lock; +struct reset_controller_dev rcdev; +}; + +static int sunxi_gates_reset_assert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct gates_reset_data *data =container_of (rcdev, + struct gates_reset_data, + rcdev); +unsigned long flags; +u32 reg; + +spin_lock_irqsave (data->lock, flags); + + reg =readl (data->reg); +writel (reg & ~BIT (id), data->reg); + +spin_unlock_irqrestore (data->lock, flags); + +return 0 ; +} + +static int sunxi_gates_reset_deassert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct gates_reset_data *data =container_of (rcdev, + struct gates_reset_data, + rcdev); +unsigned long flags; +u32 reg; + +spin_lock_irqsave (data->lock, flags); + + reg =readl (data->reg); +writel (reg |BIT (id), data->reg); + +spin_unlock_irqrestore (data->lock, flags); + +return 0 ; +} + +static struct reset_control_ops sunxi_gates_reset_ops = { + .assert = sunxi_gates_reset_assert, + .deassert = sunxi_gates_reset_deassert, +}; + +/** * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks */
@@ -845,6 +899,7 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,struct gates_data { DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE); +u32 reset_mask; };static const struct gates_data sun4i_axi_gates_data__initconst = {
@@ -915,6 +970,7 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, struct gates_data *data) {struct clk_onecell_data *clk_data; +struct gates_reset_data *reset_data;const char *clk_parent;const char *clk_name;void *reg;
@@ -958,6 +1014,21 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, clk_data->clk_num = i;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); + +/* Register a reset controler for gates with reset bits */ +if (data->reset_mask ==0 ) +return ; + + reset_data =kzalloc (sizeof (*reset_data),GFP_KERNEL ); +if (!reset_data) +return ; + + reset_data->reg = reg; + reset_data->lock = &clk_lock; + reset_data->rcdev.nr_resets =__fls (data->reset_mask) +1 ; + reset_data->rcdev.ops = &sunxi_gates_reset_ops; + reset_data->rcdev.of_node = node; +reset_controller_register (&reset_data->rcdev); }
Signature · 1 line
1.8.4.2
PATCH v4 1/5 clk: sunxi: Add support for USB clock-register reset bits
Am Freitag, den 07.02.2014, 16:21 +0100 schrieb Hans de Goede:
Quoted 5 lines
The usb-clk register is special in that it not only contains clk gate bits, but also has a few reset bits. This commit adds support for this by allowing gates type sunxi clks to also register a reset controller.
Signed-off-by Hans de Goede <[email protected]>
Quoted 114 lines
--- drivers/clk/sunxi/clk-sunxi.c | 71 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+)drivers/clk/sunxi/clk-sunxi.c +71
-0@@ -18,6 +18,7 @@#include <linux/clkdev.h> #include <linux/of.h> #include <linux/of_address.h> +#include <linux/reset-controller.h> #include "clk-factors.h" @@ -838,6 +839,59 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,/** +* sunxi_gates_reset... - reset bits in leaf gate clk registers handling +*/ + +struct gates_reset_data { +void __iomem *reg; +spinlock_t *lock; +struct reset_controller_dev rcdev; +}; + +static int sunxi_gates_reset_assert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct gates_reset_data *data =container_of (rcdev, + struct gates_reset_data, + rcdev); +unsigned long flags; +u32 reg; + +spin_lock_irqsave (data->lock, flags); + + reg =readl (data->reg); +writel (reg & ~BIT (id), data->reg); + +spin_unlock_irqrestore (data->lock, flags); + +return 0 ; +} + +static int sunxi_gates_reset_deassert (struct reset_controller_dev *rcdev, +unsigned long id) +{ +struct gates_reset_data *data =container_of (rcdev, + struct gates_reset_data, + rcdev); +unsigned long flags; +u32 reg; + +spin_lock_irqsave (data->lock, flags); + + reg =readl (data->reg); +writel (reg |BIT (id), data->reg); + +spin_unlock_irqrestore (data->lock, flags); + +return 0 ; +} + +static struct reset_control_ops sunxi_gates_reset_ops = { + .assert = sunxi_gates_reset_assert, + .deassert = sunxi_gates_reset_deassert, +}; + +/** * sunxi_gates_clk_setup() - Setup function for leaf gates on clocks */ @@ -845,6 +899,7 @@ static void __init sunxi_divider_clk_setup(struct device_node *node,struct gates_data { DECLARE_BITMAP(mask, SUNXI_GATES_MAX_SIZE); +u32 reset_mask; };static const struct gates_data sun4i_axi_gates_data__initconst = {@@ -915,6 +970,7 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, struct gates_data *data) {struct clk_onecell_data *clk_data; +struct gates_reset_data *reset_data;const char *clk_parent;const char *clk_name;void *reg;@@ -958,6 +1014,21 @@ static void __init sunxi_gates_clk_setup(struct device_node *node, clk_data->clk_num = i;of_clk_add_provider (node, of_clk_src_onecell_get, clk_data); + +/* Register a reset controler for gates with reset bits */ +if (data->reset_mask ==0 ) +return ; + + reset_data =kzalloc (sizeof (*reset_data),GFP_KERNEL ); +if (!reset_data) +return ; + + reset_data->reg = reg; + reset_data->lock = &clk_lock; + reset_data->rcdev.nr_resets =__fls (data->reset_mask) +1 ; + reset_data->rcdev.ops = &sunxi_gates_reset_ops; + reset_data->rcdev.of_node = node; +reset_controller_register (&reset_data->rcdev); }
PATCH v4 1/5 clk: sunxi: Add support for USB clock-register reset bits
In reply to Hans de GoedeQuoted 5 lines · Hans de Goede
The usb-clk register is special in that it not only contains clk gate bits, but also has a few reset bits. This commit adds support for this by allowing gates type sunxi clks to also register a reset controller.
Signed-off-by Hans de Goede <[email protected]>
Thanks!
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140207/eb93acaa/attachment-0001.sig>
PATCH v4 2/5 clk: sunxi: Add USB clock register defintions
In reply to Hans de GoedeFrom: Roman Byshko <[email protected]>
Add register definitions for the usb-clk register found on sun4i, sun5i and sun7i SoCs.
--- Documentation/devicetree/bindings/clock/sunxi.txt | 5 +++++ drivers/clk/sunxi/clk-sunxi.c | 12 ++++++++++++ 2 files changed, 17 insertions(+)
Documentation/devicetree/bindings/clock/sunxi.txt +5 -0
@@ -38,6 +38,8 @@ Required properties: "allwinner,sun4i-mod0-clk" - for the module 0 family of clocks "allwinner,sun7i-a20-out-clk" - for the external output clocks "allwinner,sun7i-a20-gmac-clk" - for the GMAC clock module on A20/A31 + "allwinner,sun4i-a10-usb-clk" - for usb gates + resets on A10 / A20 + "allwinner,sun5i-a13-usb-clk" - for usb gates + resets on A13 Required properties for all clocks: - reg : shall be the control register address for the clock.
@@ -54,6 +56,9 @@ Required properties for all clocks: For "allwinner,sun7i-a20-gmac-clk", the parent clocks shall be fixed rate dummy clocks at 25 MHz and 125 MHz, respectively. See example. +And "allwinner,*-usb-clk" clocks also require: +- reset-cells : shall be set to 1 + Clock consumers should specify the desired clocks they use with a "clocks" phandle cell. Consumers that are using a gated clock should provide an additional ID in their clock property. This ID is the
drivers/clk/sunxi/clk-sunxi.c +12 -0
@@ -910,6 +910,16 @@ static const struct gates_data sun4i_ahb_gates_data __initconst = { .mask = {0x7F77FFF, 0x14FB3F}, }; +static const struct gates_data sun4i_a10_usb_gates_data__initconst = { + .mask = {0x1C0 }, + .reset_mask =0x07 , +}; + +static const struct gates_data sun5i_a13_usb_gates_data__initconst = { + .mask = {0x140 }, + .reset_mask =0x03 , +}; +static const struct gates_data sun5i_a10s_ahb_gates_data__initconst = { .mask = {0x147667e7 ,0x185915 }, };
@@ -1257,6 +1267,8 @@ static const struct of_device_id clk_gates_match[] __initconst = { {.compatible = "allwinner,sun6i-a31-apb1-gates-clk", .data = &sun6i_a31_apb1_gates_data,}, {.compatible = "allwinner,sun7i-a20-apb1-gates-clk", .data = &sun7i_a20_apb1_gates_data,}, {.compatible = "allwinner,sun6i-a31-apb2-gates-clk", .data = &sun6i_a31_apb2_gates_data,}, + {.compatible = "allwinner,sun4i-a10-usb-clk", .data = &sun4i_a10_usb_gates_data,}, + {.compatible = "allwinner,sun5i-a13-usb-clk", .data = &sun5i_a13_usb_gates_data,}, {} };
Signature · 1 line
1.8.4.2
PATCH v4 2/5 clk: sunxi: Add USB clock register defintions
Quoted 7 lines · Hans de Goede
From: Roman Byshko <[email protected]>
Add register definitions for the usb-clk register found on sun4i, sun5i and sun7i SoCs.
Signed-off-by Roman Byshko <[email protected]>Signed-off-by Hans de Goede <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140207/727ba076/attachment.sig>
PATCH v4 3/5 ARM: sun4i: dt: Add bindings for USB clocks
In reply to Hans de GoedeFrom: Roman Byshko <[email protected]>
--- arch/arm/boot/dts/sun4i-a10.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +9 -0
@@ -301,6 +301,15 @@ clock-output-names = "ir1"; }; + usb_clk: clk at 01c200cc { + #clock-cells = <1>; + #reset-cells = <1>; + compatible = "allwinner,sun4i-a10-usb-clk"; + reg = <0x01c200cc 0x4>; + clocks = <&pll6 1>; + clock-output-names = "usb_ohci0", "usb_ohci1", "usb_phy"; + }; + spi3_clk: clk at 01c200d4 { #clock-cells = <0>; compatible = "allwinner,sun4i-mod0-clk";
Signature · 1 line
1.8.4.2
PATCH v4 4/5 ARM: sun5i: dt: Add bindings for USB clocks
In reply to Hans de GoedeFrom: Roman Byshko <[email protected]>
--- arch/arm/boot/dts/sun5i-a10s.dtsi | 9 +++++++++ arch/arm/boot/dts/sun5i-a13.dtsi | 9 +++++++++ 2 files changed, 18 insertions(+)
arch/arm/boot/dts/sun5i-a10s.dtsi +9 -0
@@ -264,6 +264,15 @@ clock-output-names = "ir0"; }; + usb_clk: clk at 01c200cc { + #clock-cells = <1>; + #reset-cells = <1>; + compatible = "allwinner,sun5i-a13-usb-clk"; + reg = <0x01c200cc 0x4>; + clocks = <&pll6 1>; + clock-output-names = "usb_ohci0", "usb_phy"; + }; + mbus_clk: clk at 01c2015c { #clock-cells = <0>; compatible = "allwinner,sun4i-mod0-clk";
arch/arm/boot/dts/sun5i-a13.dtsi +9 -0
@@ -261,6 +261,15 @@ clock-output-names = "ir0"; }; + usb_clk: clk at 01c200cc { + #clock-cells = <1>; + #reset-cells = <1>; + compatible = "allwinner,sun5i-a13-usb-clk"; + reg = <0x01c200cc 0x4>; + clocks = <&pll6 1>; + clock-output-names = "usb_ohci0", "usb_phy"; + }; + mbus_clk: clk at 01c2015c { #clock-cells = <0>; compatible = "allwinner,sun4i-mod0-clk";
Signature · 1 line
1.8.4.2
PATCH v4 5/5 ARM: sun7i: dt: Add bindings for USB clocks
In reply to Hans de GoedeFrom: Roman Byshko <[email protected]>
--- arch/arm/boot/dts/sun7i-a20.dtsi | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/arm/boot/dts/sun7i-a20.dtsi +9 -0
@@ -289,6 +289,15 @@ clock-output-names = "ir1"; }; + usb_clk: clk at 01c200cc { + #clock-cells = <1>; + #reset-cells = <1>; + compatible = "allwinner,sun4i-a10-usb-clk"; + reg = <0x01c200cc 0x4>; + clocks = <&pll6 1>; + clock-output-names = "usb_ohci0", "usb_ohci1", "usb_phy"; + }; + spi3_clk: clk at 01c200d4 { #clock-cells = <0>; compatible = "allwinner,sun4i-mod0-clk";
Signature · 1 line
1.8.4.2
Emilio López
maintainerv4 cover clk: sunxi usb clks support
In reply to Hans de GoedeHi Hans,
El 07/02/14 12:21, Hans de Goede escribi?:
Quoted 7 lines
Hi All,
And here is v4 of my sunxi usb clks support series.
Changes since v2:
-rename the compatibilty strings from foo-usb-gates-clk to foo-usb-clk
Quoted 8 lines
Changes since v3:
-rename the compatibilty string for sun4i-usb-clk to sun4i-a10-usb-clkNote the dts bits (patches 3-5) of this series depends on Chen-Yu Tsai's clk rename series.
Emilio, should Mike pick patches 1-2 up directly, or should they go through your tree?
I have taken 1-2 on sunxi-clk-for-mike with acks from Maxime and Philipp.
Quoted 2 lines
Maxime, can you please add patches 3-5 to your dts tree ? Assuming that wens clk rename patches are already there.
Maxime, please do :)
Cheers, and thanks for working on USB!
Emilio
v4 cover clk: sunxi usb clks support
Hi,
Quoted 4 lines · Emilio L?pez
Quoted 2 lines
Maxime, can you please add patches 3-5 to your dts tree ? Assuming that wens clk rename patches are already there.
Maxime, please do :)
Done. Thanks!
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140218/fd5c1e2c/attachment.sig>