* [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support
@ 2014-05-09 11:11 Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 1/7] reset: sunxi: document sunxi's reset controllers bindings Boris BREZILLON
` (6 more replies)
0 siblings, 7 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Hello,
This patch series adds support for some functions provided by the PRCM
(Power/Reset/Clock Management) unit:
- AR100, AHB0 and APB0 clocks
- APB0 reset controller
These functions are needed to get the P2WI driver working, but more
subdevices might be added later.
Best Regards,
Boris
Changes since v2:
- use devm_ioremap_resource instead of devm_request_and_ioremap
- remove unnecessary header inclusions
- remove info trace when the probe succeed
- rename apb0_timer01 clk into apb0_timer
Changes since v1:
- fix prcm and prcm-clks DT documentation
- remove unneeded iounmap and kfree calls from sunxi_reset_remove function
- rework the AR100 clk implementation
Boris BREZILLON (7):
reset: sunxi: document sunxi's reset controllers bindings
reset: sunxi: allow MFD subdevices probe
mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
mfd: sun6i-prcm: document DT bindings
clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
clk: sunxi: document PRCM clock compatible strings
ARM: sunxi: dt: add PRCM clk and reset controller subdevices
Documentation/devicetree/bindings/clock/sunxi.txt | 4 +
.../devicetree/bindings/mfd/sun6i-prcm.txt | 59 ++++
.../bindings/reset/allwinner,sunxi-clock-reset.txt | 21 ++
arch/arm/boot/dts/sun6i-a31.dtsi | 37 +++
drivers/clk/sunxi/Makefile | 2 +
drivers/clk/sunxi/clk-sun6i-prcm.c | 343 +++++++++++++++++++++
drivers/mfd/Kconfig | 8 +
drivers/mfd/Makefile | 1 +
drivers/mfd/sun6i-prcm.c | 134 ++++++++
drivers/reset/reset-sunxi.c | 21 +-
10 files changed, 627 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
create mode 100644 Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
create mode 100644 drivers/clk/sunxi/clk-sun6i-prcm.c
create mode 100644 drivers/mfd/sun6i-prcm.c
--
1.8.3.2
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH v3 1/7] reset: sunxi: document sunxi's reset controllers bindings
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 2/7] reset: sunxi: allow MFD subdevices probe Boris BREZILLON
` (5 subsequent siblings)
6 siblings, 0 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Add DT bindings documentation for sunxi's reset controllers.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
.../bindings/reset/allwinner,sunxi-clock-reset.txt | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
create mode 100644 Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
diff --git a/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt b/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
new file mode 100644
index 0000000..c8f7757
--- /dev/null
+++ b/Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt
@@ -0,0 +1,21 @@
+Allwinner sunxi Peripheral Reset Controller
+===========================================
+
+Please also refer to reset.txt in this directory for common reset
+controller binding usage.
+
+Required properties:
+- compatible: Should be one of the following:
+ "allwinner,sun6i-a31-ahb1-reset"
+ "allwinner,sun6i-a31-clock-reset"
+- reg: should be register base and length as documented in the
+ datasheet
+- #reset-cells: 1, see below
+
+example:
+
+ahb1_rst: reset@01c202c0 {
+ #reset-cells = <1>;
+ compatible = "allwinner,sun6i-a31-ahb1-reset";
+ reg = <0x01c202c0 0xc>;
+};
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 2/7] reset: sunxi: allow MFD subdevices probe
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 1/7] reset: sunxi: document sunxi's reset controllers bindings Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit Boris BREZILLON
` (4 subsequent siblings)
6 siblings, 0 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
The current implementation uses sunxi_reset_init function for both early
init and platform device probe.
The sunxi_reset_init function uses DT to retrieve device resources, which
will be an issue if reset controllers are registered from an MFD device
that define resources from mfd_cell definition.
Moreover, we can make of devm functions when we're in the probe context.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/reset/reset-sunxi.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index 695bd34..a94e7a7 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -145,7 +145,24 @@ MODULE_DEVICE_TABLE(of, sunxi_reset_dt_ids);
static int sunxi_reset_probe(struct platform_device *pdev)
{
- return sunxi_reset_init(pdev->dev.of_node);
+ struct sunxi_reset_data *data;
+ struct resource *res;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ data->membase = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(data->membase))
+ return PTR_ERR(data->membase);
+
+ data->rcdev.owner = THIS_MODULE;
+ data->rcdev.nr_resets = resource_size(res) * 32;
+ data->rcdev.ops = &sunxi_reset_ops;
+ data->rcdev.of_node = pdev->dev.of_node;
+
+ return reset_controller_register(&data->rcdev);
}
static int sunxi_reset_remove(struct platform_device *pdev)
@@ -153,8 +170,6 @@ static int sunxi_reset_remove(struct platform_device *pdev)
struct sunxi_reset_data *data = platform_get_drvdata(pdev);
reset_controller_unregister(&data->rcdev);
- iounmap(data->membase);
- kfree(data);
return 0;
}
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 1/7] reset: sunxi: document sunxi's reset controllers bindings Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 2/7] reset: sunxi: allow MFD subdevices probe Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-09 13:52 ` Lee Jones
2014-05-19 14:29 ` Lee Jones
2014-05-09 11:11 ` [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings Boris BREZILLON
` (3 subsequent siblings)
6 siblings, 2 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
The PRCM (Power/Reset/Clock Management) block exposes several subdevices
in different subsystems (clk, reset ...)
Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
and reset controller subdevices.
Other subdevices might be added later (if needed).
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/mfd/Kconfig | 8 +++
drivers/mfd/Makefile | 1 +
drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+)
create mode 100644 drivers/mfd/sun6i-prcm.c
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 2d347c9..56794fe 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -731,6 +731,14 @@ config MFD_STA2X11
select MFD_CORE
select REGMAP_MMIO
+config MFD_SUN6I_PRCM
+ bool "Allwinner A31 PRCM controller"
+ depends on ARCH_SUNXI
+ select MFD_CORE
+ help
+ Support for the PRCM (Power/Reset/Clock Management) unit available
+ in A31 SoC.
+
config MFD_SYSCON
bool "System Controller Register R/W Based on Regmap"
select REGMAP_MMIO
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 1efecf2..df7823c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_MFD_STA2X11) += sta2x11-mfd.o
obj-$(CONFIG_MFD_STMPE) += stmpe.o
obj-$(CONFIG_STMPE_I2C) += stmpe-i2c.o
obj-$(CONFIG_STMPE_SPI) += stmpe-spi.o
+obj-$(CONFIG_MFD_SUN6I_PRCM) += sun6i-prcm.o
obj-$(CONFIG_MFD_TC3589X) += tc3589x.o
obj-$(CONFIG_MFD_T7L66XB) += t7l66xb.o tmio_core.o
obj-$(CONFIG_MFD_TC6387XB) += tc6387xb.o tmio_core.o
diff --git a/drivers/mfd/sun6i-prcm.c b/drivers/mfd/sun6i-prcm.c
new file mode 100644
index 0000000..718fc4d
--- /dev/null
+++ b/drivers/mfd/sun6i-prcm.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ *
+ * License Terms: GNU General Public License v2
+ * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
+ *
+ * Allwinner PRCM (Power/Reset/Clock Management) driver
+ *
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of.h>
+
+struct prcm_data {
+ int nsubdevs;
+ const struct mfd_cell *subdevs;
+};
+
+static const struct resource sun6i_a31_ar100_clk_res[] = {
+ {
+ .start = 0x0,
+ .end = 0x3,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static const struct resource sun6i_a31_apb0_clk_res[] = {
+ {
+ .start = 0xc,
+ .end = 0xf,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static const struct resource sun6i_a31_apb0_gates_clk_res[] = {
+ {
+ .start = 0x28,
+ .end = 0x2b,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static const struct resource sun6i_a31_apb0_rstc_res[] = {
+ {
+ .start = 0xb0,
+ .end = 0xb3,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static const struct mfd_cell sun6i_a31_prcm_subdevs[] = {
+ {
+ .name = "sun6i-a31-ar100-clk",
+ .of_compatible = "allwinner,sun6i-a31-ar100-clk",
+ .num_resources = ARRAY_SIZE(sun6i_a31_ar100_clk_res),
+ .resources = sun6i_a31_ar100_clk_res,
+ },
+ {
+ .name = "sun6i-a31-apb0-clk",
+ .of_compatible = "allwinner,sun6i-a31-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,sun6i-a31-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 of_device_id sun6i_prcm_dt_ids[] = {
+ {
+ .compatible = "allwinner,sun6i-a31-prcm",
+ .data = &sun6i_a31_prcm_data,
+ },
+ { /* sentinel */ },
+};
+
+static int sun6i_prcm_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ const struct of_device_id *match;
+ const struct prcm_data *data;
+ struct resource *res;
+ int ret;
+
+ match = of_match_node(sun6i_prcm_dt_ids, np);
+ if (!match)
+ return -EINVAL;
+
+ data = match->data;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ if (!res) {
+ dev_err(&pdev->dev, "no prcm memory region provided\n");
+ return -ENOENT;
+ }
+
+ ret = mfd_add_devices(&pdev->dev, 0, data->subdevs, data->nsubdevs,
+ res, -1, NULL);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to add subdevices\n");
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct platform_driver sun6i_prcm_driver = {
+ .driver = {
+ .name = "sun6i-prcm",
+ .owner = THIS_MODULE,
+ .of_match_table = sun6i_prcm_dt_ids,
+ },
+ .probe = sun6i_prcm_probe,
+};
+module_platform_driver(sun6i_prcm_driver);
+
+MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
+MODULE_DESCRIPTION("Allwinner sun6i PRCM driver");
+MODULE_LICENSE("GPL v2");
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
` (2 preceding siblings ...)
2014-05-09 11:11 ` [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-19 14:26 ` Lee Jones
2014-05-09 11:11 ` [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support Boris BREZILLON
` (2 subsequent siblings)
6 siblings, 1 reply; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Document DT bindings of the PRCM (Power/Reset/Clock Management) unit.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
.../devicetree/bindings/mfd/sun6i-prcm.txt | 59 ++++++++++++++++++++++
1 file changed, 59 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
diff --git a/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
new file mode 100644
index 0000000..1f5a31f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
@@ -0,0 +1,59 @@
+* Allwinner PRCM (Power/Reset/Clock Management) Multi-Functional Device
+
+PRCM is an MFD device exposing several Power Management related devices
+(like clks and reset controllers).
+
+Required properties:
+ - compatible: "allwinner,sun6i-a31-prcm"
+ - reg: The PRCM registers range
+
+The prcm node may contain several subdevices definitions:
+ - see Documentation/devicetree/clk/sunxi.txt for clock devices
+ - see Documentation/devicetree/reset/allwinner,sunxi-clock-reset.txt for reset
+ controller devices
+
+
+Example:
+
+ prcm: prcm@01f01400 {
+ compatible = "allwinner,sun6i-a31-prcm";
+ reg = <0x01f01400 0x200>;
+
+ /* Put subdevices here */
+ ar100: ar100_clk {
+ compatible = "allwinner,sun6i-a31-ar100-clk";
+ #clock-cells = <0>;
+ clocks = <&osc32k>, <&osc24M>, <&pll6>, <&pll6>;
+ };
+
+ ahb0: ahb0_clk {
+ compatible = "fixed-factor-clock";
+ #clock-cells = <0>;
+ clock-div = <1>;
+ clock-mult = <1>;
+ clocks = <&ar100_div>;
+ clock-output-names = "ahb0";
+ };
+
+ apb0: apb0_clk {
+ compatible = "allwinner,sun6i-a31-apb0-clk";
+ #clock-cells = <0>;
+ clocks = <&ahb0>;
+ clock-output-names = "apb0";
+ };
+
+ apb0_gates: apb0_gates_clk {
+ compatible = "allwinner,sun6i-a31-apb0-gates-clk";
+ #clock-cells = <1>;
+ clocks = <&apb0>;
+ clock-output-names = "apb0_pio", "apb0_ir",
+ "apb0_timer01", "apb0_p2wi",
+ "apb0_uart", "apb0_1wire",
+ "apb0_i2c";
+ };
+
+ apb0_rst: apb0_rst {
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ #reset-cells = <1>;
+ };
+ };
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
` (3 preceding siblings ...)
2014-05-09 11:11 ` [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-13 15:09 ` Emilio López
2014-05-14 0:51 ` Mike Turquette
2014-05-09 11:11 ` [PATCH v3 6/7] clk: sunxi: document PRCM clock compatible strings Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices Boris BREZILLON
6 siblings, 2 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
The PRCM (Power/Reset/Clock Management) unit provides several clock
devices:
- AR100 clk: used to clock the Power Management co-processor
- AHB0 clk: used to clock the AHB0 bus
- APB0 clk and gates: used to clk peripherals connected to the APB0 bus
Add support for these clks in a separate driver so that they can be probed
as platform devices instead of registered during early init.
This is needed to be able to probe PRCM MFD subdevices.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
drivers/clk/sunxi/Makefile | 2 +
drivers/clk/sunxi/clk-sun6i-prcm.c | 343 +++++++++++++++++++++++++++++++++++++
2 files changed, 345 insertions(+)
create mode 100644 drivers/clk/sunxi/clk-sun6i-prcm.c
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index b5bac91..ef8cdc9 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -3,3 +3,5 @@
#
obj-y += clk-sunxi.o clk-factors.o
+
+obj-$(CONFIG_MFD_SUN6I_PRCM) += clk-sun6i-prcm.o
diff --git a/drivers/clk/sunxi/clk-sun6i-prcm.c b/drivers/clk/sunxi/clk-sun6i-prcm.c
new file mode 100644
index 0000000..3efaf8f
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun6i-prcm.c
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2014 Free Electrons
+ *
+ * License Terms: GNU General Public License v2
+ * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
+ *
+ * Allwinner PRCM (Power/Reset/Clock Management) driver
+ *
+ */
+
+#include <linux/clk-provider.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+
+#define SUN6I_APB0_GATES_MAX_SIZE 32
+#define SUN6I_AR100_MAX_PARENTS 4
+#define SUN6I_AR100_SHIFT_MASK 0x3
+#define SUN6I_AR100_SHIFT_MAX SUN6I_AR100_SHIFT_MASK
+#define SUN6I_AR100_SHIFT_SHIFT 4
+#define SUN6I_AR100_DIV_MASK 0x1f
+#define SUN6I_AR100_DIV_MAX (SUN6I_AR100_DIV_MASK + 1)
+#define SUN6I_AR100_DIV_SHIFT 8
+#define SUN6I_AR100_MUX_MASK 0x3
+#define SUN6I_AR100_MUX_SHIFT 16
+
+struct ar100_clk {
+ struct clk_hw hw;
+ void __iomem *reg;
+};
+
+static inline struct ar100_clk *to_ar100_clk(struct clk_hw *hw)
+{
+ return container_of(hw, struct ar100_clk, hw);
+}
+
+static unsigned long ar100_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct ar100_clk *clk = to_ar100_clk(hw);
+ u32 val = readl(clk->reg);
+ int shift = (val >> SUN6I_AR100_SHIFT_SHIFT) & SUN6I_AR100_SHIFT_MASK;
+ int div = (val >> SUN6I_AR100_DIV_SHIFT) & SUN6I_AR100_DIV_MASK;
+
+ return (parent_rate >> shift) / (div + 1);
+}
+
+static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long *best_parent_rate,
+ struct clk **best_parent_clk)
+{
+ int nparents = __clk_get_num_parents(hw->clk);
+ long best_rate = -EINVAL;
+ int i;
+
+ *best_parent_clk = NULL;
+
+ for (i = 0; i < nparents; i++) {
+ unsigned long parent_rate;
+ unsigned long tmp_rate;
+ struct clk *parent;
+ unsigned long div;
+ int shift;
+
+ parent = clk_get_parent_by_index(hw->clk, i);
+ parent_rate = __clk_get_rate(parent);
+ div = DIV_ROUND_UP(parent_rate, rate);
+
+ shift = ffs(div) - 1;
+ if (shift > SUN6I_AR100_SHIFT_MAX)
+ shift = SUN6I_AR100_SHIFT_MAX;
+
+ div >>= shift;
+
+ while (div > SUN6I_AR100_DIV_MAX) {
+ shift++;
+ div >>= 1;
+ if (shift > SUN6I_AR100_SHIFT_MAX)
+ break;
+ }
+
+ if (shift > SUN6I_AR100_SHIFT_MAX)
+ continue;
+
+ tmp_rate = (parent_rate >> shift) / div;
+ if (!*best_parent_clk || tmp_rate > best_rate) {
+ *best_parent_clk = parent;
+ *best_parent_rate = parent_rate;
+ best_rate = tmp_rate;
+ }
+ }
+
+ return best_rate;
+}
+
+static int ar100_set_parent(struct clk_hw *hw, u8 index)
+{
+ struct ar100_clk *clk = to_ar100_clk(hw);
+ u32 val = readl(clk->reg);
+
+ if (index >= SUN6I_AR100_MAX_PARENTS)
+ return -EINVAL;
+
+ val &= ~(SUN6I_AR100_MUX_MASK << SUN6I_AR100_MUX_SHIFT);
+ val |= (index << SUN6I_AR100_MUX_SHIFT);
+ writel(val, clk->reg);
+
+ return 0;
+}
+
+static u8 ar100_get_parent(struct clk_hw *hw)
+{
+ struct ar100_clk *clk = to_ar100_clk(hw);
+ return (readl(clk->reg) >> SUN6I_AR100_MUX_SHIFT) &
+ SUN6I_AR100_MUX_MASK;
+}
+
+static int ar100_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ unsigned long div = parent_rate / rate;
+ struct ar100_clk *clk = to_ar100_clk(hw);
+ u32 val = readl(clk->reg);
+ int shift;
+
+ if (parent_rate % rate)
+ return -EINVAL;
+
+ shift = ffs(div) - 1;
+ if (shift > SUN6I_AR100_SHIFT_MAX)
+ shift = SUN6I_AR100_SHIFT_MAX;
+
+ div >>= shift;
+
+ if (div > SUN6I_AR100_DIV_MAX)
+ return -EINVAL;
+
+ val &= ~((SUN6I_AR100_SHIFT_MASK << SUN6I_AR100_SHIFT_SHIFT) |
+ (SUN6I_AR100_DIV_MASK << SUN6I_AR100_DIV_SHIFT));
+ val |= (shift << SUN6I_AR100_SHIFT_SHIFT) |
+ (div << SUN6I_AR100_DIV_SHIFT);
+ writel(val, clk->reg);
+
+ return 0;
+}
+
+struct clk_ops ar100_ops = {
+ .recalc_rate = ar100_recalc_rate,
+ .determine_rate = ar100_determine_rate,
+ .set_parent = ar100_set_parent,
+ .get_parent = ar100_get_parent,
+ .set_rate = ar100_set_rate,
+};
+
+static int sun6i_a31_ar100_clk_register(struct platform_device *pdev)
+{
+ const char *parents[SUN6I_AR100_MAX_PARENTS];
+ struct device_node *np = pdev->dev.of_node;
+ const char *clk_name = np->name;
+ struct clk_init_data init;
+ struct ar100_clk *ar100;
+ struct resource *r;
+ struct clk *clk;
+ int nparents;
+ int i;
+
+ ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
+ if (!ar100)
+ return -ENOMEM;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ar100->reg = devm_ioremap_resource(&pdev->dev, r);
+ if (IS_ERR(ar100->reg))
+ return PTR_ERR(ar100->reg);
+
+ nparents = of_clk_get_parent_count(np);
+ 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_property_read_string(np, "clock-output-names", &clk_name);
+
+ init.name = clk_name;
+ init.ops = &ar100_ops;
+ init.parent_names = parents;
+ init.num_parents = nparents;
+ init.flags = 0;
+
+ ar100->hw.init = &init;
+
+ clk = clk_register(&pdev->dev, &ar100->hw);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ return of_clk_add_provider(np, of_clk_src_simple_get, clk);
+}
+
+static const struct clk_div_table sun6i_a31_apb0_divs[] = {
+ { .val = 0, .div = 2, },
+ { .val = 1, .div = 2, },
+ { .val = 2, .div = 4, },
+ { .val = 3, .div = 8, },
+ { /* sentinel */ },
+};
+
+static int sun6i_a31_apb0_clk_register(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);
+
+ clk = clk_register_divider_table(&pdev->dev, clk_name, clk_parent,
+ 0, reg, 0, 2, 0, sun6i_a31_apb0_divs,
+ NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ return of_clk_add_provider(np, of_clk_src_simple_get, clk);
+}
+
+static int sun6i_a31_apb0_gates_clk_register(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct clk_onecell_data *clk_data;
+ const char *clk_parent;
+ const char *clk_name;
+ struct resource *r;
+ void __iomem *reg;
+ int gate_id;
+ int ngates;
+ int i;
+
+ r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ reg = devm_ioremap_resource(&pdev->dev, r);
+ if (!reg)
+ return PTR_ERR(reg);
+
+ clk_parent = of_clk_get_parent_name(np, 0);
+ if (!clk_parent)
+ return -EINVAL;
+
+ ngates = of_property_count_strings(np, "clock-output-names");
+ if (ngates < 0)
+ return ngates;
+
+ if (!ngates || ngates > SUN6I_APB0_GATES_MAX_SIZE)
+ return -EINVAL;
+
+ clk_data = devm_kzalloc(&pdev->dev, sizeof(struct clk_onecell_data),
+ GFP_KERNEL);
+ if (!clk_data)
+ return -ENOMEM;
+
+ clk_data->clks = devm_kzalloc(&pdev->dev,
+ SUN6I_APB0_GATES_MAX_SIZE *
+ sizeof(struct clk *),
+ GFP_KERNEL);
+ if (!clk_data->clks)
+ return -ENOMEM;
+
+ for (i = 0; i < ngates; i++) {
+ of_property_read_string_index(np, "clock-output-names",
+ i, &clk_name);
+
+ gate_id = i;
+ of_property_read_u32_index(np, "clock-indices", i, &gate_id);
+
+ WARN_ON(gate_id >= SUN6I_APB0_GATES_MAX_SIZE);
+ if (gate_id >= SUN6I_APB0_GATES_MAX_SIZE)
+ continue;
+
+ clk_data->clks[gate_id] = clk_register_gate(&pdev->dev,
+ clk_name,
+ clk_parent, 0,
+ reg, gate_id,
+ 0, NULL);
+ WARN_ON(IS_ERR(clk_data->clks[gate_id]));
+ }
+
+ clk_data->clk_num = ngates;
+
+ return of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
+}
+
+const struct of_device_id sun6i_a31_prcm_clk_dt_ids[] = {
+ {
+ .compatible = "allwinner,sun6i-a31-ar100-clk",
+ .data = sun6i_a31_ar100_clk_register,
+ },
+ {
+ .compatible = "allwinner,sun6i-a31-apb0-clk",
+ .data = sun6i_a31_apb0_clk_register,
+ },
+ {
+ .compatible = "allwinner,sun6i-a31-apb0-gates-clk",
+ .data = sun6i_a31_apb0_gates_clk_register,
+ },
+ { /* sentinel */ }
+};
+
+static int sun6i_a31_prcm_clk_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ int (*register_func)(struct platform_device *pdev);
+ const struct of_device_id *match;
+
+ match = of_match_node(sun6i_a31_prcm_clk_dt_ids, np);
+ if (!match)
+ return -EINVAL;
+
+ register_func = match->data;
+ return register_func(pdev);
+}
+
+static struct platform_driver sun6i_a31_prcm_clk_driver = {
+ .driver = {
+ .name = "sun6i-a31-prcm-clk",
+ .owner = THIS_MODULE,
+ .of_match_table = sun6i_a31_prcm_clk_dt_ids,
+ },
+ .probe = sun6i_a31_prcm_clk_probe,
+};
+module_platform_driver(sun6i_a31_prcm_clk_driver);
+
+MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
+MODULE_DESCRIPTION("Allwinner PRCM clock Driver");
+MODULE_LICENSE("GPL v2");
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 6/7] clk: sunxi: document PRCM clock compatible strings
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
` (4 preceding siblings ...)
2014-05-09 11:11 ` [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices Boris BREZILLON
6 siblings, 0 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Document new compatible strings for clock provided by the PRCM
(Power/Reset/Clock Management) unit.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index a5160d8..d154d9d 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -20,12 +20,16 @@ Required properties:
"allwinner,sun5i-a13-ahb-gates-clk" - for the AHB gates on A13
"allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s
"allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
+ "allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
+ "allwinner,sun6i-a31-ahb0-clk" - for the AHB0 multiplexer on A31
"allwinner,sun6i-a31-ahb1-mux-clk" - for the AHB1 multiplexer on A31
"allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
"allwinner,sun4i-a10-apb0-clk" - for the APB0 clock
+ "allwinner,sun6i-a31-apb0-clk" - for the APB0 clock on A31
"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
+ "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,sun4i-a10-apb1-clk" - for the APB1 clock
"allwinner,sun4i-a10-apb1-mux-clk" - for the APB1 clock muxing
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
` (5 preceding siblings ...)
2014-05-09 11:11 ` [PATCH v3 6/7] clk: sunxi: document PRCM clock compatible strings Boris BREZILLON
@ 2014-05-09 11:11 ` Boris BREZILLON
2014-05-13 15:17 ` Emilio López
6 siblings, 1 reply; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 11:11 UTC (permalink / raw)
To: Emilio López, Mike Turquette, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Add DT definitions for PRCM (Power/Reset/Clock Management) clock and reset
controller subdevices.
Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
---
arch/arm/boot/dts/sun6i-a31.dtsi | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
index 9feb3f4..03d5258 100644
--- a/arch/arm/boot/dts/sun6i-a31.dtsi
+++ b/arch/arm/boot/dts/sun6i-a31.dtsi
@@ -496,6 +496,43 @@
prcm@01f01400 {
compatible = "allwinner,sun6i-a31-prcm";
reg = <0x01f01400 0x200>;
+
+ ar100: ar100_clk {
+ compatible = "allwinner,sun6i-a31-ar100-clk";
+ #clock-cells = <0>;
+ clocks = <&osc32k>, <&osc24M>, <&pll6>, <&pll6>;
+ };
+
+ 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,sun6i-a31-apb0-clk";
+ #clock-cells = <0>;
+ clocks = <&ahb0>;
+ clock-output-names = "apb0";
+ };
+
+ apb0_gates: apb0_gates_clk {
+ compatible = "allwinner,sun6i-a31-apb0-gates-clk";
+ #clock-cells = <1>;
+ clocks = <&apb0>;
+ clock-output-names = "apb0_pio", "apb0_ir",
+ "apb0_timer", "apb0_p2wi",
+ "apb0_uart", "apb0_1wire",
+ "apb0_i2c";
+ };
+
+ apb0_rst: apb0_rst {
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ #reset-cells = <1>;
+ };
};
cpucfg@01f01c00 {
--
1.8.3.2
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-09 11:11 ` [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit Boris BREZILLON
@ 2014-05-09 13:52 ` Lee Jones
2014-05-09 14:01 ` Boris BREZILLON
2014-05-15 15:17 ` Maxime Ripard
2014-05-19 14:29 ` Lee Jones
1 sibling, 2 replies; 23+ messages in thread
From: Lee Jones @ 2014-05-09 13:52 UTC (permalink / raw)
To: Boris BREZILLON
Cc: Emilio López, Mike Turquette, Samuel Ortiz, Chen-Yu Tsai,
Maxime Ripard, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> in different subsystems (clk, reset ...)
>
> Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> and reset controller subdevices.
>
> Other subdevices might be added later (if needed).
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/mfd/Kconfig | 8 +++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 143 insertions(+)
> create mode 100644 drivers/mfd/sun6i-prcm.c
[...]
> +/*
> + * Copyright (C) 2014 Free Electrons
> + *
> + * License Terms: GNU General Public License v2
> + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> + *
> + * Allwinner PRCM (Power/Reset/Clock Management) driver
> + *
> + */
> +
> +#include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
Ah, now isn't that better?
Acked-by: Lee Jones <lee.jones@linaro.org>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-09 13:52 ` Lee Jones
@ 2014-05-09 14:01 ` Boris BREZILLON
2014-05-15 15:17 ` Maxime Ripard
1 sibling, 0 replies; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-09 14:01 UTC (permalink / raw)
To: Lee Jones
Cc: Emilio López, Mike Turquette, Samuel Ortiz, Chen-Yu Tsai,
Maxime Ripard, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
On 09/05/2014 15:52, Lee Jones wrote:
>> The PRCM (Power/Reset/Clock Management) block exposes several subdevices
>> in different subsystems (clk, reset ...)
>>
>> Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
>> and reset controller subdevices.
>>
>> Other subdevices might be added later (if needed).
>>
>> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
>> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
>> ---
>> drivers/mfd/Kconfig | 8 +++
>> drivers/mfd/Makefile | 1 +
>> drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 143 insertions(+)
>> create mode 100644 drivers/mfd/sun6i-prcm.c
> [...]
>
>> +/*
>> + * Copyright (C) 2014 Free Electrons
>> + *
>> + * License Terms: GNU General Public License v2
>> + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
>> + *
>> + * Allwinner PRCM (Power/Reset/Clock Management) driver
>> + *
>> + */
>> +
>> +#include <linux/mfd/core.h>
>> +#include <linux/module.h>
>> +#include <linux/of.h>
> Ah, now isn't that better?
Absolutely :-).
> Acked-by: Lee Jones <lee.jones@linaro.org>
>
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
2014-05-09 11:11 ` [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support Boris BREZILLON
@ 2014-05-13 15:09 ` Emilio López
2014-05-14 0:51 ` Mike Turquette
1 sibling, 0 replies; 23+ messages in thread
From: Emilio López @ 2014-05-13 15:09 UTC (permalink / raw)
To: Boris BREZILLON, Mike Turquette, Maxime Ripard
Cc: Samuel Ortiz, Lee Jones, Chen-Yu Tsai, Philipp Zabel, Shuge,
kevin, Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev
Hi Boris,
First of all, thanks for working on this :)
While reading the code below I noticed a complete lack of comments. I
think it would be good to have at least some to aid readability,
considering these clocks are poorly documented on AW's material.
El 09/05/14 08:11, Boris BREZILLON escribió:
> The PRCM (Power/Reset/Clock Management) unit provides several clock
> devices:
> - AR100 clk: used to clock the Power Management co-processor
> - AHB0 clk: used to clock the AHB0 bus
> - APB0 clk and gates: used to clk peripherals connected to the APB0 bus
>
> Add support for these clks in a separate driver so that they can be probed
> as platform devices instead of registered during early init.
> This is needed to be able to probe PRCM MFD subdevices.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/clk/sunxi/Makefile | 2 +
> drivers/clk/sunxi/clk-sun6i-prcm.c | 343 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 345 insertions(+)
> create mode 100644 drivers/clk/sunxi/clk-sun6i-prcm.c
>
> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
> index b5bac91..ef8cdc9 100644
> --- a/drivers/clk/sunxi/Makefile
> +++ b/drivers/clk/sunxi/Makefile
> @@ -3,3 +3,5 @@
> #
>
> obj-y += clk-sunxi.o clk-factors.o
> +
> +obj-$(CONFIG_MFD_SUN6I_PRCM) += clk-sun6i-prcm.o
> diff --git a/drivers/clk/sunxi/clk-sun6i-prcm.c b/drivers/clk/sunxi/clk-sun6i-prcm.c
> new file mode 100644
> index 0000000..3efaf8f
> --- /dev/null
> +++ b/drivers/clk/sunxi/clk-sun6i-prcm.c
> @@ -0,0 +1,343 @@
> +/*
> + * Copyright (C) 2014 Free Electrons
> + *
> + * License Terms: GNU General Public License v2
> + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> + *
> + * Allwinner PRCM (Power/Reset/Clock Management) driver
> + *
> + */
> +
> +#include <linux/clk-provider.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/platform_device.h>
> +
> +#define SUN6I_APB0_GATES_MAX_SIZE 32
> +#define SUN6I_AR100_MAX_PARENTS 4
> +#define SUN6I_AR100_SHIFT_MASK 0x3
> +#define SUN6I_AR100_SHIFT_MAX SUN6I_AR100_SHIFT_MASK
> +#define SUN6I_AR100_SHIFT_SHIFT 4
> +#define SUN6I_AR100_DIV_MASK 0x1f
> +#define SUN6I_AR100_DIV_MAX (SUN6I_AR100_DIV_MASK + 1)
> +#define SUN6I_AR100_DIV_SHIFT 8
> +#define SUN6I_AR100_MUX_MASK 0x3
> +#define SUN6I_AR100_MUX_SHIFT 16
> +
> +struct ar100_clk {
> + struct clk_hw hw;
> + void __iomem *reg;
> +};
> +
> +static inline struct ar100_clk *to_ar100_clk(struct clk_hw *hw)
> +{
> + return container_of(hw, struct ar100_clk, hw);
> +}
> +
> +static unsigned long ar100_recalc_rate(struct clk_hw *hw,
> + unsigned long parent_rate)
> +{
> + struct ar100_clk *clk = to_ar100_clk(hw);
> + u32 val = readl(clk->reg);
> + int shift = (val >> SUN6I_AR100_SHIFT_SHIFT) & SUN6I_AR100_SHIFT_MASK;
> + int div = (val >> SUN6I_AR100_DIV_SHIFT) & SUN6I_AR100_DIV_MASK;
> +
> + return (parent_rate >> shift) / (div + 1);
> +}
> +
> +static long ar100_determine_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long *best_parent_rate,
> + struct clk **best_parent_clk)
> +{
> + int nparents = __clk_get_num_parents(hw->clk);
> + long best_rate = -EINVAL;
> + int i;
> +
> + *best_parent_clk = NULL;
> +
> + for (i = 0; i < nparents; i++) {
> + unsigned long parent_rate;
> + unsigned long tmp_rate;
> + struct clk *parent;
> + unsigned long div;
> + int shift;
> +
> + parent = clk_get_parent_by_index(hw->clk, i);
> + parent_rate = __clk_get_rate(parent);
> + div = DIV_ROUND_UP(parent_rate, rate);
> +
> + shift = ffs(div) - 1;
> + if (shift > SUN6I_AR100_SHIFT_MAX)
> + shift = SUN6I_AR100_SHIFT_MAX;
> +
> + div >>= shift;
> +
> + while (div > SUN6I_AR100_DIV_MAX) {
> + shift++;
> + div >>= 1;
> + if (shift > SUN6I_AR100_SHIFT_MAX)
> + break;
> + }
> +
> + if (shift > SUN6I_AR100_SHIFT_MAX)
> + continue;
> +
> + tmp_rate = (parent_rate >> shift) / div;
> + if (!*best_parent_clk || tmp_rate > best_rate) {
> + *best_parent_clk = parent;
> + *best_parent_rate = parent_rate;
> + best_rate = tmp_rate;
> + }
> + }
> +
> + return best_rate;
> +}
> +
> +static int ar100_set_parent(struct clk_hw *hw, u8 index)
> +{
> + struct ar100_clk *clk = to_ar100_clk(hw);
> + u32 val = readl(clk->reg);
> +
> + if (index >= SUN6I_AR100_MAX_PARENTS)
> + return -EINVAL;
> +
> + val &= ~(SUN6I_AR100_MUX_MASK << SUN6I_AR100_MUX_SHIFT);
> + val |= (index << SUN6I_AR100_MUX_SHIFT);
> + writel(val, clk->reg);
> +
> + return 0;
> +}
> +
> +static u8 ar100_get_parent(struct clk_hw *hw)
> +{
> + struct ar100_clk *clk = to_ar100_clk(hw);
> + return (readl(clk->reg) >> SUN6I_AR100_MUX_SHIFT) &
> + SUN6I_AR100_MUX_MASK;
> +}
> +
> +static int ar100_set_rate(struct clk_hw *hw, unsigned long rate,
> + unsigned long parent_rate)
> +{
> + unsigned long div = parent_rate / rate;
> + struct ar100_clk *clk = to_ar100_clk(hw);
> + u32 val = readl(clk->reg);
> + int shift;
> +
> + if (parent_rate % rate)
> + return -EINVAL;
> +
> + shift = ffs(div) - 1;
> + if (shift > SUN6I_AR100_SHIFT_MAX)
> + shift = SUN6I_AR100_SHIFT_MAX;
> +
> + div >>= shift;
> +
> + if (div > SUN6I_AR100_DIV_MAX)
> + return -EINVAL;
> +
> + val &= ~((SUN6I_AR100_SHIFT_MASK << SUN6I_AR100_SHIFT_SHIFT) |
> + (SUN6I_AR100_DIV_MASK << SUN6I_AR100_DIV_SHIFT));
> + val |= (shift << SUN6I_AR100_SHIFT_SHIFT) |
> + (div << SUN6I_AR100_DIV_SHIFT);
> + writel(val, clk->reg);
> +
> + return 0;
> +}
> +
> +struct clk_ops ar100_ops = {
> + .recalc_rate = ar100_recalc_rate,
> + .determine_rate = ar100_determine_rate,
> + .set_parent = ar100_set_parent,
> + .get_parent = ar100_get_parent,
> + .set_rate = ar100_set_rate,
> +};
> +
> +static int sun6i_a31_ar100_clk_register(struct platform_device *pdev)
> +{
> + const char *parents[SUN6I_AR100_MAX_PARENTS];
> + struct device_node *np = pdev->dev.of_node;
> + const char *clk_name = np->name;
> + struct clk_init_data init;
> + struct ar100_clk *ar100;
> + struct resource *r;
> + struct clk *clk;
> + int nparents;
> + int i;
> +
> + ar100 = devm_kzalloc(&pdev->dev, sizeof(*ar100), GFP_KERNEL);
> + if (!ar100)
> + return -ENOMEM;
> +
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + ar100->reg = devm_ioremap_resource(&pdev->dev, r);
> + if (IS_ERR(ar100->reg))
> + return PTR_ERR(ar100->reg);
> +
> + nparents = of_clk_get_parent_count(np);
> + 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_property_read_string(np, "clock-output-names", &clk_name);
> +
> + init.name = clk_name;
> + init.ops = &ar100_ops;
> + init.parent_names = parents;
> + init.num_parents = nparents;
> + init.flags = 0;
> +
> + ar100->hw.init = &init;
> +
> + clk = clk_register(&pdev->dev, &ar100->hw);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> + return of_clk_add_provider(np, of_clk_src_simple_get, clk);
> +}
> +
> +static const struct clk_div_table sun6i_a31_apb0_divs[] = {
> + { .val = 0, .div = 2, },
> + { .val = 1, .div = 2, },
> + { .val = 2, .div = 4, },
> + { .val = 3, .div = 8, },
> + { /* sentinel */ },
> +};
> +
> +static int sun6i_a31_apb0_clk_register(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;
Indentation seems to be off here.
> +
> + of_property_read_string(np, "clock-output-names", &clk_name);
> +
> + clk = clk_register_divider_table(&pdev->dev, clk_name, clk_parent,
> + 0, reg, 0, 2, 0, sun6i_a31_apb0_divs,
> + NULL);
> + if (IS_ERR(clk))
> + return PTR_ERR(clk);
> +
> + return of_clk_add_provider(np, of_clk_src_simple_get, clk);
> +}
> +
> +static int sun6i_a31_apb0_gates_clk_register(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + struct clk_onecell_data *clk_data;
> + const char *clk_parent;
> + const char *clk_name;
> + struct resource *r;
> + void __iomem *reg;
> + int gate_id;
> + int ngates;
> + int i;
> +
> + r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + reg = devm_ioremap_resource(&pdev->dev, r);
> + if (!reg)
> + return PTR_ERR(reg);
> +
> + clk_parent = of_clk_get_parent_name(np, 0);
> + if (!clk_parent)
> + return -EINVAL;
> +
> + ngates = of_property_count_strings(np, "clock-output-names");
> + if (ngates < 0)
> + return ngates;
> +
> + if (!ngates || ngates > SUN6I_APB0_GATES_MAX_SIZE)
> + return -EINVAL;
> +
> + clk_data = devm_kzalloc(&pdev->dev, sizeof(struct clk_onecell_data),
> + GFP_KERNEL);
> + if (!clk_data)
> + return -ENOMEM;
> +
> + clk_data->clks = devm_kzalloc(&pdev->dev,
> + SUN6I_APB0_GATES_MAX_SIZE *
> + sizeof(struct clk *),
> + GFP_KERNEL);
> + if (!clk_data->clks)
> + return -ENOMEM;
> +
> + for (i = 0; i < ngates; i++) {
> + of_property_read_string_index(np, "clock-output-names",
> + i, &clk_name);
> +
> + gate_id = i;
> + of_property_read_u32_index(np, "clock-indices", i, &gate_id);
> +
> + WARN_ON(gate_id >= SUN6I_APB0_GATES_MAX_SIZE);
> + if (gate_id >= SUN6I_APB0_GATES_MAX_SIZE)
> + continue;
> +
> + clk_data->clks[gate_id] = clk_register_gate(&pdev->dev,
> + clk_name,
> + clk_parent, 0,
> + reg, gate_id,
> + 0, NULL);
> + WARN_ON(IS_ERR(clk_data->clks[gate_id]));
> + }
> +
> + clk_data->clk_num = ngates;
> +
> + return of_clk_add_provider(np, of_clk_src_onecell_get, clk_data);
> +}
> +
> +const struct of_device_id sun6i_a31_prcm_clk_dt_ids[] = {
> + {
> + .compatible = "allwinner,sun6i-a31-ar100-clk",
> + .data = sun6i_a31_ar100_clk_register,
> + },
> + {
> + .compatible = "allwinner,sun6i-a31-apb0-clk",
> + .data = sun6i_a31_apb0_clk_register,
> + },
> + {
> + .compatible = "allwinner,sun6i-a31-apb0-gates-clk",
> + .data = sun6i_a31_apb0_gates_clk_register,
> + },
> + { /* sentinel */ }
> +};
> +
> +static int sun6i_a31_prcm_clk_probe(struct platform_device *pdev)
> +{
> + struct device_node *np = pdev->dev.of_node;
> + int (*register_func)(struct platform_device *pdev);
> + const struct of_device_id *match;
> +
> + match = of_match_node(sun6i_a31_prcm_clk_dt_ids, np);
> + if (!match)
> + return -EINVAL;
> +
> + register_func = match->data;
> + return register_func(pdev);
> +}
> +
> +static struct platform_driver sun6i_a31_prcm_clk_driver = {
> + .driver = {
> + .name = "sun6i-a31-prcm-clk",
> + .owner = THIS_MODULE,
> + .of_match_table = sun6i_a31_prcm_clk_dt_ids,
> + },
> + .probe = sun6i_a31_prcm_clk_probe,
> +};
> +module_platform_driver(sun6i_a31_prcm_clk_driver);
> +
> +MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
> +MODULE_DESCRIPTION("Allwinner PRCM clock Driver");
> +MODULE_LICENSE("GPL v2");
Other than that, the code looks good to me. As we're nearing the merge
window and you need this for other drivers, let me know if you want me
to apply this and fixup the extra tab locally, or if you wish to respin
this patch with some more comments.
@Mike, any comments on this?
Cheers,
Emilio
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices
2014-05-09 11:11 ` [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices Boris BREZILLON
@ 2014-05-13 15:17 ` Emilio López
0 siblings, 0 replies; 23+ messages in thread
From: Emilio López @ 2014-05-13 15:17 UTC (permalink / raw)
To: Boris BREZILLON, Mike Turquette, Lee Jones, Maxime Ripard
Cc: Samuel Ortiz, Chen-Yu Tsai, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev
Hi Boris,
El 09/05/14 08:11, Boris BREZILLON escribió:
> Add DT definitions for PRCM (Power/Reset/Clock Management) clock and reset
> controller subdevices.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
> arch/arm/boot/dts/sun6i-a31.dtsi | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/arch/arm/boot/dts/sun6i-a31.dtsi b/arch/arm/boot/dts/sun6i-a31.dtsi
> index 9feb3f4..03d5258 100644
> --- a/arch/arm/boot/dts/sun6i-a31.dtsi
> +++ b/arch/arm/boot/dts/sun6i-a31.dtsi
> @@ -496,6 +496,43 @@
> prcm@01f01400 {
> compatible = "allwinner,sun6i-a31-prcm";
> reg = <0x01f01400 0x200>;
> +
> + ar100: ar100_clk {
> + compatible = "allwinner,sun6i-a31-ar100-clk";
> + #clock-cells = <0>;
> + clocks = <&osc32k>, <&osc24M>, <&pll6>, <&pll6>;
You could add
clock-output-names = "ar100";
here, so you don't depend on the node name. Your code already checks for
it and uses it when available.
> + };
Cheers,
Emilio
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
2014-05-09 11:11 ` [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support Boris BREZILLON
2014-05-13 15:09 ` Emilio López
@ 2014-05-14 0:51 ` Mike Turquette
2014-05-14 7:30 ` Boris BREZILLON
1 sibling, 1 reply; 23+ messages in thread
From: Mike Turquette @ 2014-05-14 0:51 UTC (permalink / raw)
To: Boris BREZILLON, Emilio López, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev, Boris BREZILLON
Quoting Boris BREZILLON (2014-05-09 04:11:49)
> +struct clk_ops ar100_ops = {
> + .recalc_rate = ar100_recalc_rate,
> + .determine_rate = ar100_determine_rate,
> + .set_parent = ar100_set_parent,
> + .get_parent = ar100_get_parent,
> + .set_rate = ar100_set_rate,
> +};
I might be having a brain fart, but is there a valid case for having
both a .recalc_rate and a .determine_rate? I believe that the former
will never be used and the latter will always be used by the clock
framework core.
Regards,
Mike
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
2014-05-14 0:51 ` Mike Turquette
@ 2014-05-14 7:30 ` Boris BREZILLON
2014-05-14 22:39 ` Mike Turquette
0 siblings, 1 reply; 23+ messages in thread
From: Boris BREZILLON @ 2014-05-14 7:30 UTC (permalink / raw)
To: Mike Turquette, Emilio López, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev
Hello Mike,
On 14/05/2014 02:51, Mike Turquette wrote:
> Quoting Boris BREZILLON (2014-05-09 04:11:49)
>> +struct clk_ops ar100_ops = {
>> + .recalc_rate = ar100_recalc_rate,
>> + .determine_rate = ar100_determine_rate,
>> + .set_parent = ar100_set_parent,
>> + .get_parent = ar100_get_parent,
>> + .set_rate = ar100_set_rate,
>> +};
> I might be having a brain fart, but is there a valid case for having
> both a .recalc_rate and a .determine_rate? I believe that the former
> will never be used and the latter will always be used by the clock
> framework core.
I think you're mistaking recalc_rate for round_rate.
AFAIK, recalc_rate is mandatory for a clk that implement either
round_rate or determine_rate.
Best Regards,
Boris
--
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support
2014-05-14 7:30 ` Boris BREZILLON
@ 2014-05-14 22:39 ` Mike Turquette
0 siblings, 0 replies; 23+ messages in thread
From: Mike Turquette @ 2014-05-14 22:39 UTC (permalink / raw)
To: Boris BREZILLON, Emilio López, Samuel Ortiz, Lee Jones
Cc: Chen-Yu Tsai, Maxime Ripard, Philipp Zabel, Shuge, kevin,
Hans de Goede, Randy Dunlap, devicetree, linux-doc,
linux-arm-kernel, linux-kernel, dev
Quoting Boris BREZILLON (2014-05-14 00:30:59)
> Hello Mike,
>
> On 14/05/2014 02:51, Mike Turquette wrote:
> > Quoting Boris BREZILLON (2014-05-09 04:11:49)
> >> +struct clk_ops ar100_ops = {
> >> + .recalc_rate = ar100_recalc_rate,
> >> + .determine_rate = ar100_determine_rate,
> >> + .set_parent = ar100_set_parent,
> >> + .get_parent = ar100_get_parent,
> >> + .set_rate = ar100_set_rate,
> >> +};
> > I might be having a brain fart, but is there a valid case for having
> > both a .recalc_rate and a .determine_rate? I believe that the former
> > will never be used and the latter will always be used by the clock
> > framework core.
>
> I think you're mistaking recalc_rate for round_rate.
> AFAIK, recalc_rate is mandatory for a clk that implement either
> round_rate or determine_rate.
I *was* having a brain fart. You're right of course. Too many .r*_rate()
callbacks...
Thanks,
Mike
>
>
> Best Regards,
>
> Boris
>
> --
> Boris Brezillon, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-09 13:52 ` Lee Jones
2014-05-09 14:01 ` Boris BREZILLON
@ 2014-05-15 15:17 ` Maxime Ripard
2014-05-19 9:21 ` Lee Jones
1 sibling, 1 reply; 23+ messages in thread
From: Maxime Ripard @ 2014-05-15 15:17 UTC (permalink / raw)
To: Lee Jones
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
[-- Attachment #1: Type: text/plain, Size: 1514 bytes --]
Hi Lee,
On Fri, May 09, 2014 at 02:52:51PM +0100, Lee Jones wrote:
> > The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> > in different subsystems (clk, reset ...)
> >
> > Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> > and reset controller subdevices.
> >
> > Other subdevices might be added later (if needed).
> >
> > Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> > drivers/mfd/Kconfig | 8 +++
> > drivers/mfd/Makefile | 1 +
> > drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 143 insertions(+)
> > create mode 100644 drivers/mfd/sun6i-prcm.c
>
> [...]
>
> > +/*
> > + * Copyright (C) 2014 Free Electrons
> > + *
> > + * License Terms: GNU General Public License v2
> > + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > + *
> > + * Allwinner PRCM (Power/Reset/Clock Management) driver
> > + *
> > + */
> > +
> > +#include <linux/mfd/core.h>
> > +#include <linux/module.h>
> > +#include <linux/of.h>
>
> Ah, now isn't that better?
>
> Acked-by: Lee Jones <lee.jones@linaro.org>
How do you want to merge this? Do you want me to take it through
mach-sunxi tree, or do you want to take it in your tree?
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] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-15 15:17 ` Maxime Ripard
@ 2014-05-19 9:21 ` Lee Jones
2014-05-19 9:27 ` Maxime Ripard
0 siblings, 1 reply; 23+ messages in thread
From: Lee Jones @ 2014-05-19 9:21 UTC (permalink / raw)
To: Maxime Ripard
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> > > The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> > > in different subsystems (clk, reset ...)
> > >
> > > Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> > > and reset controller subdevices.
> > >
> > > Other subdevices might be added later (if needed).
> > >
> > > Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > ---
> > > drivers/mfd/Kconfig | 8 +++
> > > drivers/mfd/Makefile | 1 +
> > > drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> > > 3 files changed, 143 insertions(+)
> > > create mode 100644 drivers/mfd/sun6i-prcm.c
> >
> > [...]
> >
> > > +/*
> > > + * Copyright (C) 2014 Free Electrons
> > > + *
> > > + * License Terms: GNU General Public License v2
> > > + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > + *
> > > + * Allwinner PRCM (Power/Reset/Clock Management) driver
> > > + *
> > > + */
> > > +
> > > +#include <linux/mfd/core.h>
> > > +#include <linux/module.h>
> > > +#include <linux/of.h>
> >
> > Ah, now isn't that better?
> >
> > Acked-by: Lee Jones <lee.jones@linaro.org>
>
> How do you want to merge this? Do you want me to take it through
> mach-sunxi tree, or do you want to take it in your tree?
If Boris can tell me what needs to go in with this patch (or if it
can go in on its own), I will create a(n immutable) branch from which
you can pull into your tree.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-19 9:21 ` Lee Jones
@ 2014-05-19 9:27 ` Maxime Ripard
2014-05-19 13:32 ` Lee Jones
0 siblings, 1 reply; 23+ messages in thread
From: Maxime Ripard @ 2014-05-19 9:27 UTC (permalink / raw)
To: Lee Jones
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
[-- Attachment #1: Type: text/plain, Size: 2020 bytes --]
On Mon, May 19, 2014 at 10:21:59AM +0100, Lee Jones wrote:
> > > > The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> > > > in different subsystems (clk, reset ...)
> > > >
> > > > Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> > > > and reset controller subdevices.
> > > >
> > > > Other subdevices might be added later (if needed).
> > > >
> > > > Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > > ---
> > > > drivers/mfd/Kconfig | 8 +++
> > > > drivers/mfd/Makefile | 1 +
> > > > drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> > > > 3 files changed, 143 insertions(+)
> > > > create mode 100644 drivers/mfd/sun6i-prcm.c
> > >
> > > [...]
> > >
> > > > +/*
> > > > + * Copyright (C) 2014 Free Electrons
> > > > + *
> > > > + * License Terms: GNU General Public License v2
> > > > + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > + *
> > > > + * Allwinner PRCM (Power/Reset/Clock Management) driver
> > > > + *
> > > > + */
> > > > +
> > > > +#include <linux/mfd/core.h>
> > > > +#include <linux/module.h>
> > > > +#include <linux/of.h>
> > >
> > > Ah, now isn't that better?
> > >
> > > Acked-by: Lee Jones <lee.jones@linaro.org>
> >
> > How do you want to merge this? Do you want me to take it through
> > mach-sunxi tree, or do you want to take it in your tree?
>
> If Boris can tell me what needs to go in with this patch (or if it
> can go in on its own), I will create a(n immutable) branch from which
> you can pull into your tree.
We don't have any runtime or compile time dependency on this, so you
can merge it through your tree. Unless something change, I don't have
to pull anything in my tree.
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] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-19 9:27 ` Maxime Ripard
@ 2014-05-19 13:32 ` Lee Jones
2014-05-19 14:05 ` Maxime Ripard
0 siblings, 1 reply; 23+ messages in thread
From: Lee Jones @ 2014-05-19 13:32 UTC (permalink / raw)
To: Maxime Ripard
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> > > > > The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> > > > > in different subsystems (clk, reset ...)
> > > > >
> > > > > Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> > > > > and reset controller subdevices.
> > > > >
> > > > > Other subdevices might be added later (if needed).
> > > > >
> > > > > Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > > > ---
> > > > > drivers/mfd/Kconfig | 8 +++
> > > > > drivers/mfd/Makefile | 1 +
> > > > > drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> > > > > 3 files changed, 143 insertions(+)
> > > > > create mode 100644 drivers/mfd/sun6i-prcm.c
> > > >
> > > > [...]
> > > >
> > > > > +/*
> > > > > + * Copyright (C) 2014 Free Electrons
> > > > > + *
> > > > > + * License Terms: GNU General Public License v2
> > > > > + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > > + *
> > > > > + * Allwinner PRCM (Power/Reset/Clock Management) driver
> > > > > + *
> > > > > + */
> > > > > +
> > > > > +#include <linux/mfd/core.h>
> > > > > +#include <linux/module.h>
> > > > > +#include <linux/of.h>
> > > >
> > > > Ah, now isn't that better?
> > > >
> > > > Acked-by: Lee Jones <lee.jones@linaro.org>
> > >
> > > How do you want to merge this? Do you want me to take it through
> > > mach-sunxi tree, or do you want to take it in your tree?
> >
> > If Boris can tell me what needs to go in with this patch (or if it
> > can go in on its own), I will create a(n immutable) branch from which
> > you can pull into your tree.
>
> We don't have any runtime or compile time dependency on this, so you
> can merge it through your tree. Unless something change, I don't have
> to pull anything in my tree.
When you say 'this', do you mean this patch, or this set? If I can
just apply this patch, that will be ideal?
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-19 13:32 ` Lee Jones
@ 2014-05-19 14:05 ` Maxime Ripard
2014-05-19 14:24 ` Lee Jones
0 siblings, 1 reply; 23+ messages in thread
From: Maxime Ripard @ 2014-05-19 14:05 UTC (permalink / raw)
To: Lee Jones
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
[-- Attachment #1: Type: text/plain, Size: 2547 bytes --]
On Mon, May 19, 2014 at 02:32:53PM +0100, Lee Jones wrote:
>
> > > > > > The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> > > > > > in different subsystems (clk, reset ...)
> > > > > >
> > > > > > Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> > > > > > and reset controller subdevices.
> > > > > >
> > > > > > Other subdevices might be added later (if needed).
> > > > > >
> > > > > > Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > > > Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > > > > ---
> > > > > > drivers/mfd/Kconfig | 8 +++
> > > > > > drivers/mfd/Makefile | 1 +
> > > > > > drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> > > > > > 3 files changed, 143 insertions(+)
> > > > > > create mode 100644 drivers/mfd/sun6i-prcm.c
> > > > >
> > > > > [...]
> > > > >
> > > > > > +/*
> > > > > > + * Copyright (C) 2014 Free Electrons
> > > > > > + *
> > > > > > + * License Terms: GNU General Public License v2
> > > > > > + * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
> > > > > > + *
> > > > > > + * Allwinner PRCM (Power/Reset/Clock Management) driver
> > > > > > + *
> > > > > > + */
> > > > > > +
> > > > > > +#include <linux/mfd/core.h>
> > > > > > +#include <linux/module.h>
> > > > > > +#include <linux/of.h>
> > > > >
> > > > > Ah, now isn't that better?
> > > > >
> > > > > Acked-by: Lee Jones <lee.jones@linaro.org>
> > > >
> > > > How do you want to merge this? Do you want me to take it through
> > > > mach-sunxi tree, or do you want to take it in your tree?
> > >
> > > If Boris can tell me what needs to go in with this patch (or if it
> > > can go in on its own), I will create a(n immutable) branch from which
> > > you can pull into your tree.
> >
> > We don't have any runtime or compile time dependency on this, so you
> > can merge it through your tree. Unless something change, I don't have
> > to pull anything in my tree.
>
> When you say 'this', do you mean this patch, or this set? If I can
> just apply this patch, that will be ideal?
I mean you can apply these two patches:
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/256537.html
http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/256535.html
And it would be ideal :)
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] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-19 14:05 ` Maxime Ripard
@ 2014-05-19 14:24 ` Lee Jones
0 siblings, 0 replies; 23+ messages in thread
From: Lee Jones @ 2014-05-19 14:24 UTC (permalink / raw)
To: Maxime Ripard
Cc: Boris BREZILLON, Emilio López, Mike Turquette, Samuel Ortiz,
Chen-Yu Tsai, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> > When you say 'this', do you mean this patch, or this set? If I can
> > just apply this patch, that will be ideal?
>
> I mean you can apply these two patches:
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/256537.html
> http://lists.infradead.org/pipermail/linux-arm-kernel/2014-May/256535.html
>
> And it would be ideal :)
Perfect!
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings
2014-05-09 11:11 ` [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings Boris BREZILLON
@ 2014-05-19 14:26 ` Lee Jones
0 siblings, 0 replies; 23+ messages in thread
From: Lee Jones @ 2014-05-19 14:26 UTC (permalink / raw)
To: Boris BREZILLON
Cc: Emilio López, Mike Turquette, Samuel Ortiz, Chen-Yu Tsai,
Maxime Ripard, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> Document DT bindings of the PRCM (Power/Reset/Clock Management) unit.
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> ---
> .../devicetree/bindings/mfd/sun6i-prcm.txt | 59 ++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
Been on the list a while now, doesn't seem to have any potentially
controversial bindings and looks mostly fine.
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit
2014-05-09 11:11 ` [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit Boris BREZILLON
2014-05-09 13:52 ` Lee Jones
@ 2014-05-19 14:29 ` Lee Jones
1 sibling, 0 replies; 23+ messages in thread
From: Lee Jones @ 2014-05-19 14:29 UTC (permalink / raw)
To: Boris BREZILLON
Cc: Emilio López, Mike Turquette, Samuel Ortiz, Chen-Yu Tsai,
Maxime Ripard, Philipp Zabel, Shuge, kevin, Hans de Goede,
Randy Dunlap, devicetree, linux-doc, linux-arm-kernel,
linux-kernel, dev
> The PRCM (Power/Reset/Clock Management) block exposes several subdevices
> in different subsystems (clk, reset ...)
>
> Add basic support for the PRCM unit with clk (AR100, AHB0, and APB0 clks)
> and reset controller subdevices.
>
> Other subdevices might be added later (if needed).
>
> Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
> drivers/mfd/Kconfig | 8 +++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/sun6i-prcm.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 143 insertions(+)
> create mode 100644 drivers/mfd/sun6i-prcm.c
Applied, thanks.
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2014-05-19 14:29 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-09 11:11 [PATCH v3 0/7] mfd: add basic sun6i A31 PRCM support Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 1/7] reset: sunxi: document sunxi's reset controllers bindings Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 2/7] reset: sunxi: allow MFD subdevices probe Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 3/7] mfd: add support for sun6i PRCM (Power/Reset/Clock Management) unit Boris BREZILLON
2014-05-09 13:52 ` Lee Jones
2014-05-09 14:01 ` Boris BREZILLON
2014-05-15 15:17 ` Maxime Ripard
2014-05-19 9:21 ` Lee Jones
2014-05-19 9:27 ` Maxime Ripard
2014-05-19 13:32 ` Lee Jones
2014-05-19 14:05 ` Maxime Ripard
2014-05-19 14:24 ` Lee Jones
2014-05-19 14:29 ` Lee Jones
2014-05-09 11:11 ` [PATCH v3 4/7] mfd: sun6i-prcm: document DT bindings Boris BREZILLON
2014-05-19 14:26 ` Lee Jones
2014-05-09 11:11 ` [PATCH v3 5/7] clk: sunxi: add PRCM (Power/Reset/Clock Management) clks support Boris BREZILLON
2014-05-13 15:09 ` Emilio López
2014-05-14 0:51 ` Mike Turquette
2014-05-14 7:30 ` Boris BREZILLON
2014-05-14 22:39 ` Mike Turquette
2014-05-09 11:11 ` [PATCH v3 6/7] clk: sunxi: document PRCM clock compatible strings Boris BREZILLON
2014-05-09 11:11 ` [PATCH v3 7/7] ARM: sunxi: dt: add PRCM clk and reset controller subdevices Boris BREZILLON
2014-05-13 15:17 ` Emilio López
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).