2 * Copyright (C) 2014 Free Electrons
4 * License Terms: GNU General Public License v2
5 * Author: Boris BREZILLON <boris.brezillon@free-electrons.com>
7 * Allwinner PRCM (Power/Reset/Clock Management) driver
11 #include <linux/mfd/core.h>
12 #include <linux/module.h>
17 const struct mfd_cell
*subdevs
;
20 static const struct resource sun6i_a31_ar100_clk_res
[] = {
24 .flags
= IORESOURCE_MEM
,
28 static const struct resource sun6i_a31_apb0_clk_res
[] = {
32 .flags
= IORESOURCE_MEM
,
36 static const struct resource sun6i_a31_apb0_gates_clk_res
[] = {
40 .flags
= IORESOURCE_MEM
,
44 static const struct resource sun6i_a31_apb0_rstc_res
[] = {
48 .flags
= IORESOURCE_MEM
,
52 static const struct mfd_cell sun6i_a31_prcm_subdevs
[] = {
54 .name
= "sun6i-a31-ar100-clk",
55 .of_compatible
= "allwinner,sun6i-a31-ar100-clk",
56 .num_resources
= ARRAY_SIZE(sun6i_a31_ar100_clk_res
),
57 .resources
= sun6i_a31_ar100_clk_res
,
60 .name
= "sun6i-a31-apb0-clk",
61 .of_compatible
= "allwinner,sun6i-a31-apb0-clk",
62 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_clk_res
),
63 .resources
= sun6i_a31_apb0_clk_res
,
66 .name
= "sun6i-a31-apb0-gates-clk",
67 .of_compatible
= "allwinner,sun6i-a31-apb0-gates-clk",
68 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_gates_clk_res
),
69 .resources
= sun6i_a31_apb0_gates_clk_res
,
72 .name
= "sun6i-a31-apb0-clock-reset",
73 .of_compatible
= "allwinner,sun6i-a31-clock-reset",
74 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_rstc_res
),
75 .resources
= sun6i_a31_apb0_rstc_res
,
79 static const struct mfd_cell sun8i_a23_prcm_subdevs
[] = {
81 .name
= "sun8i-a23-apb0-clk",
82 .of_compatible
= "allwinner,sun8i-a23-apb0-clk",
83 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_clk_res
),
84 .resources
= sun6i_a31_apb0_clk_res
,
87 .name
= "sun6i-a31-apb0-gates-clk",
88 .of_compatible
= "allwinner,sun8i-a23-apb0-gates-clk",
89 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_gates_clk_res
),
90 .resources
= sun6i_a31_apb0_gates_clk_res
,
93 .name
= "sun6i-a31-apb0-clock-reset",
94 .of_compatible
= "allwinner,sun6i-a31-clock-reset",
95 .num_resources
= ARRAY_SIZE(sun6i_a31_apb0_rstc_res
),
96 .resources
= sun6i_a31_apb0_rstc_res
,
100 static const struct prcm_data sun6i_a31_prcm_data
= {
101 .nsubdevs
= ARRAY_SIZE(sun6i_a31_prcm_subdevs
),
102 .subdevs
= sun6i_a31_prcm_subdevs
,
105 static const struct prcm_data sun8i_a23_prcm_data
= {
106 .nsubdevs
= ARRAY_SIZE(sun8i_a23_prcm_subdevs
),
107 .subdevs
= sun8i_a23_prcm_subdevs
,
110 static const struct of_device_id sun6i_prcm_dt_ids
[] = {
112 .compatible
= "allwinner,sun6i-a31-prcm",
113 .data
= &sun6i_a31_prcm_data
,
116 .compatible
= "allwinner,sun8i-a23-prcm",
117 .data
= &sun8i_a23_prcm_data
,
122 static int sun6i_prcm_probe(struct platform_device
*pdev
)
124 struct device_node
*np
= pdev
->dev
.of_node
;
125 const struct of_device_id
*match
;
126 const struct prcm_data
*data
;
127 struct resource
*res
;
130 match
= of_match_node(sun6i_prcm_dt_ids
, np
);
136 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
138 dev_err(&pdev
->dev
, "no prcm memory region provided\n");
142 ret
= mfd_add_devices(&pdev
->dev
, 0, data
->subdevs
, data
->nsubdevs
,
145 dev_err(&pdev
->dev
, "failed to add subdevices\n");
152 static struct platform_driver sun6i_prcm_driver
= {
154 .name
= "sun6i-prcm",
155 .of_match_table
= sun6i_prcm_dt_ids
,
157 .probe
= sun6i_prcm_probe
,
159 module_platform_driver(sun6i_prcm_driver
);
161 MODULE_AUTHOR("Boris BREZILLON <boris.brezillon@free-electrons.com>");
162 MODULE_DESCRIPTION("Allwinner sun6i PRCM driver");
163 MODULE_LICENSE("GPL v2");