Merge tag 'acpi-5.19-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6-microblaze.git] / drivers / clk / sunxi-ng / ccu-sun50i-h6-r.c
index f30d7eb..29a8c71 100644 (file)
@@ -4,7 +4,8 @@
  */
 
 #include <linux/clk-provider.h>
-#include <linux/of_address.h>
+#include <linux/module.h>
+#include <linux/of_device.h>
 #include <linux/platform_device.h>
 
 #include "ccu_common.h"
@@ -97,6 +98,8 @@ static SUNXI_CCU_GATE(r_apb1_ir_clk,  "r-apb1-ir",    "r-apb1",
                      0x1cc, BIT(0), 0);
 static SUNXI_CCU_GATE(r_apb1_w1_clk,   "r-apb1-w1",    "r-apb1",
                      0x1ec, BIT(0), 0);
+static SUNXI_CCU_GATE(r_apb1_rtc_clk,  "r-apb1-rtc",   "r-apb1",
+                     0x20c, BIT(0), CLK_IGNORE_UNUSED);
 
 /* Information of IR(RX) mod clock is gathered from BSP source code */
 static const char * const r_mod0_default_parents[] = { "osc32k", "osc24M" };
@@ -146,6 +149,7 @@ static struct ccu_common *sun50i_h616_r_ccu_clks[] = {
        &r_apb2_i2c_clk.common,
        &r_apb2_rsb_clk.common,
        &r_apb1_ir_clk.common,
+       &r_apb1_rtc_clk.common,
        &ir_clk.common,
 };
 
@@ -163,6 +167,7 @@ static struct clk_hw_onecell_data sun50i_h6_r_hw_clks = {
                [CLK_R_APB2_RSB]        = &r_apb2_rsb_clk.common.hw,
                [CLK_R_APB1_IR]         = &r_apb1_ir_clk.common.hw,
                [CLK_R_APB1_W1]         = &r_apb1_w1_clk.common.hw,
+               [CLK_R_APB1_RTC]        = &r_apb1_rtc_clk.common.hw,
                [CLK_IR]                = &ir_clk.common.hw,
                [CLK_W1]                = &w1_clk.common.hw,
        },
@@ -178,6 +183,7 @@ static struct clk_hw_onecell_data sun50i_h616_r_hw_clks = {
                [CLK_R_APB2_I2C]        = &r_apb2_i2c_clk.common.hw,
                [CLK_R_APB2_RSB]        = &r_apb2_rsb_clk.common.hw,
                [CLK_R_APB1_IR]         = &r_apb1_ir_clk.common.hw,
+               [CLK_R_APB1_RTC]        = &r_apb1_rtc_clk.common.hw,
                [CLK_IR]                = &ir_clk.common.hw,
        },
        .num    = CLK_NUMBER,
@@ -221,30 +227,43 @@ static const struct sunxi_ccu_desc sun50i_h616_r_ccu_desc = {
        .num_resets     = ARRAY_SIZE(sun50i_h616_r_ccu_resets),
 };
 
-static void __init sunxi_r_ccu_init(struct device_node *node,
-                                   const struct sunxi_ccu_desc *desc)
+static int sun50i_h6_r_ccu_probe(struct platform_device *pdev)
 {
+       const struct sunxi_ccu_desc *desc;
        void __iomem *reg;
 
-       reg = of_io_request_and_map(node, 0, of_node_full_name(node));
-       if (IS_ERR(reg)) {
-               pr_err("%pOF: Could not map the clock registers\n", node);
-               return;
-       }
+       desc = of_device_get_match_data(&pdev->dev);
+       if (!desc)
+               return -EINVAL;
 
-       of_sunxi_ccu_probe(node, reg, desc);
-}
+       reg = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(reg))
+               return PTR_ERR(reg);
 
-static void __init sun50i_h6_r_ccu_setup(struct device_node *node)
-{
-       sunxi_r_ccu_init(node, &sun50i_h6_r_ccu_desc);
+       return devm_sunxi_ccu_probe(&pdev->dev, reg, desc);
 }
-CLK_OF_DECLARE(sun50i_h6_r_ccu, "allwinner,sun50i-h6-r-ccu",
-              sun50i_h6_r_ccu_setup);
 
-static void __init sun50i_h616_r_ccu_setup(struct device_node *node)
-{
-       sunxi_r_ccu_init(node, &sun50i_h616_r_ccu_desc);
-}
-CLK_OF_DECLARE(sun50i_h616_r_ccu, "allwinner,sun50i-h616-r-ccu",
-              sun50i_h616_r_ccu_setup);
+static const struct of_device_id sun50i_h6_r_ccu_ids[] = {
+       {
+               .compatible = "allwinner,sun50i-h6-r-ccu",
+               .data = &sun50i_h6_r_ccu_desc,
+       },
+       {
+               .compatible = "allwinner,sun50i-h616-r-ccu",
+               .data = &sun50i_h616_r_ccu_desc,
+       },
+       { }
+};
+
+static struct platform_driver sun50i_h6_r_ccu_driver = {
+       .probe  = sun50i_h6_r_ccu_probe,
+       .driver = {
+               .name                   = "sun50i-h6-r-ccu",
+               .suppress_bind_attrs    = true,
+               .of_match_table         = sun50i_h6_r_ccu_ids,
+       },
+};
+module_platform_driver(sun50i_h6_r_ccu_driver);
+
+MODULE_IMPORT_NS(SUNXI_CCU);
+MODULE_LICENSE("GPL");