ARM: meson: Add reset controller
cover ARM: meson: Add reset controller
Apparently several IPs found in the MesonX SoCs can be reset by programming a specific bit in a register in the so called AO (Always-On) domain. From the documentation released by Amlogic under NDA it is not clear which devices can be reset acting on this register. So far from the sources release by Amlogic it seems that at least two IPs use this register for reset: RTC and UART. Since I need it to reset the RTC, I wrote this small driver.
Carlo Caione (3):
ARM: meson: reset: Add reset controller for MesonX SoCs
ARM: meson: DTSI: Enable reset controller
ARM: meson: docs: Add docs for MesonX reset controller
.../bindings/reset/amlogic,meson6-rst-mgr-ao.txt | 14 ++ arch/arm/boot/dts/meson.dtsi | 6 + drivers/reset/Makefile | 1 + drivers/reset/reset-meson.c | 152 +++++++++++++++++++++ 4 files changed, 173 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/amlogic,meson6-rst-mgr-ao.txt create mode 100644 drivers/reset/reset-meson.c
Signature · 1 line
1.9.1
PATCH 1/3 ARM: meson: reset: Add reset controller for MesonX SoCs
This patch adds support for the reset controller found on the Amlogic MesonX SoCs. For several devices in the AO (Always-On) power domain, it is possible to reset them by programming a specific bit in a register.
--- drivers/reset/Makefile | 1 + drivers/reset/reset-meson.c | 152 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 153 insertions(+) create mode 100644 drivers/reset/reset-meson.c
drivers/reset/Makefile +1 -0
@@ -1,4 +1,5 @@ obj-$(CONFIG_RESET_CONTROLLER) += core.o obj-$(CONFIG_ARCH_SOCFPGA) += reset-socfpga.o obj-$(CONFIG_ARCH_SUNXI) += reset-sunxi.o +obj-$(CONFIG_ARCH_MESON) += reset-meson.o obj-$(CONFIG_ARCH_STI) += sti/
drivers/reset/reset-meson.c new file +152 -0
152 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 1/3 ARM: meson: reset: Add reset controller for MesonX SoCs
Quoted 3 lines · Carlo Caione
This patch adds support for the reset controller found on the Amlogic MesonX SoCs. For several devices in the AO (Always-On) power domain, it is possible to reset them by programming a specific bit in a register.
Hi Carlo,
Quoted 6 lines
[...]
drivers/reset/reset-meson.c new file +5
-0+ +static int meson_reset_probe (struct platform_device *pdev) +{ +struct meson_reset_data *data; +struct resource *res;
drivers/reset/reset-meson.c line 103
Quoted 10 lines
drivers/reset/reset-meson.c new file +10
-0+ +/* +* The binding was mainlined without the required property. +* Do not continue, when we encounter an old DT. +*/ +if (!of_find_property (pdev->dev.of_node,"#reset-cells" ,NULL )) { +dev_err (&pdev->dev,"%s missing #reset-cells property\n" , + pdev->dev.of_node->full_name); +return -EINVAL ; + }
Probably the above comment was taken from another driver but is not relevant here.
Quoted 14 lines
drivers/reset/reset-meson.c new file +14
-0+ + 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); + +spin_lock_init (&data->lock); + + data->rcdev.owner =THIS_MODULE ; + data->rcdev.nr_resets =BITS_PER_LONG ;
drivers/reset/reset-meson.c line 127
Quoted 10 lines
drivers/reset/reset-meson.c new file +10
-0+ data->rcdev.ops = &meson_reset_ops; + data->rcdev.of_node = pdev->dev.of_node; +reset_controller_register (&data->rcdev); + +return 0 ; +} + +static int meson_reset_remove (struct platform_device *pdev) +{ +struct meson_reset_data *data =platform_get_drvdata (pdev);
Don't you need to call platform_set_drvdata() in the probe() function for this to be valid?
Quoted 7 lines
drivers/reset/reset-meson.c new file +7
-0+ +reset_controller_unregister (&data->rcdev); + +return 0 ; +} + +static const struct of_device_id meson_reset_dt_ids[] = {
drivers/reset/reset-meson.c line 144
Quoted 10 lines
drivers/reset/reset-meson.c new file +10
-0+ { .compatible = "amlogic,meson6-rst-mgr-ao", }, + { /* sentinel */ }, +}; + +static struct platform_driver meson_reset_driver = { + .probe = meson_reset_probe, + .remove = meson_reset_remove, + .driver = { + .name ="meson-reset" , + .owner =THIS_MODULE ,
I believe you can drop the owner field.
Beniamino
PATCH 1/3 ARM: meson: reset: Add reset controller for MesonX SoCs
Quoted 1 line · Beniamino Galvani
Hi Carlo,
Hi Beniamino,
Quoted 11 lines
Quoted 11 lines
[...]
drivers/reset/reset-meson.c new file +10
-0+ +static int meson_reset_probe (struct platform_device *pdev) +{ +struct meson_reset_data *data; +struct resource *res; + +/* +* The binding was mainlined without the required property. +* Do not continue, when we encounter an old DT. +*/
Quoted 8 lines
drivers/reset/reset-meson.c line 103
Quoted 5 lines
drivers/reset/reset-meson.c new file +5
-0+if (!of_find_property (pdev->dev.of_node,"#reset-cells" ,NULL )) { +dev_err (&pdev->dev,"%s missing #reset-cells property\n" , + pdev->dev.of_node->full_name); +return -EINVAL ; + }Probably the above comment was taken from another driver but is not relevant here.
Right. Lazy copy and paste with brain off
Quoted 7 lines
drivers/reset/reset-meson.c line 127
Quoted 4 lines
drivers/reset/reset-meson.c new file +4
-0+ +static int meson_reset_remove (struct platform_device *pdev) +{ +struct meson_reset_data *data =platform_get_drvdata (pdev);Don't you need to call
platform_set_drvdata()in theprobe()function for this to be valid?
Yes. Even though I believe the remove can never happen.
Quoted 11 lines
Quoted 11 lines
drivers/reset/reset-meson.c new file +11
-0+ +reset_controller_unregister (&data->rcdev); + +return 0 ; +} + +static const struct of_device_id meson_reset_dt_ids[] = { + { .compatible ="amlogic,meson6-rst-mgr-ao" , }, + {/* sentinel */ }, +}; +
Quoted 8 lines
drivers/reset/reset-meson.c line 144
Quoted 6 lines
drivers/reset/reset-meson.c new file +6
-0+static struct platform_driver meson_reset_driver = { + .probe = meson_reset_probe, + .remove = meson_reset_remove, + .driver = { + .name ="meson-reset" , + .owner =THIS_MODULE ,I believe you can drop the owner field.
I will.
Thank you for your review,
Signature · 1 line
Carlo Caione
PATCH 2/3 ARM: meson: DTSI: Enable reset controller
In reply to Carlo CaioneAdd the node for the reset controller in the DTSI.
--- arch/arm/boot/dts/meson.dtsi | 6 ++++++ 1 file changed, 6 insertions(+)
arch/arm/boot/dts/meson.dtsi +6 -0
@@ -75,6 +75,12 @@ reg = <0xc1109900 0x8>; }; + reset_AO: reset at c8100040 { + #reset-cells = <1>; + compatible = "amlogic,meson6-rst-mgr-ao"; + reg = <0xc8100040 0x4>; + }; + uart_AO: serial at c81004c0 { compatible = "amlogic,meson-uart"; reg = <0xc81004c0 0x14>;
Signature · 1 line
1.9.1
PATCH 3/3 ARM: meson: docs: Add docs for MesonX reset controller
In reply to Carlo Caione--- .../bindings/reset/amlogic,meson6-rst-mgr-ao.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Documentation/devicetree/bindings/reset/amlogic,meson6-rst-mgr-ao.txt
Documentation/devicetree/bindings/reset/amlogic,meson6-rst-mgr-ao.txt new file +14 -0
@@ -0,0 +1,14 @@ +Amlogic MesonX Reset Manager (AO domain) + +Required properties: +- compatible : "amlogic,meson6-rst-mgr-ao" +- reg : Should contain 1 register ranges(address and length) +- #reset-cells: 1 + +Example: + + reset: reset at c8100040 { + #reset-cells = <1>; + compatible = "amlogic,meson6-rst-mgr-ao"; + reg = <0xc8100040 0x4>; + };
Signature · 1 line
1.9.1