12
12
#include <linux/cpu.h>
13
13
#include <linux/device.h>
14
14
#include <linux/kernel.h>
15
+ #include <linux/platform_device.h>
15
16
#include <linux/pm_domain.h>
16
17
#include <linux/pm_runtime.h>
17
18
#include <linux/psci.h>
@@ -42,8 +43,8 @@ static int psci_pd_power_off(struct generic_pm_domain *pd)
42
43
return 0 ;
43
44
}
44
45
45
- static int __init psci_pd_parse_state_nodes (struct genpd_power_state * states ,
46
- int state_count )
46
+ static int psci_pd_parse_state_nodes (struct genpd_power_state * states ,
47
+ int state_count )
47
48
{
48
49
int i , ret ;
49
50
u32 psci_state , * psci_state_buf ;
@@ -72,7 +73,7 @@ static int __init psci_pd_parse_state_nodes(struct genpd_power_state *states,
72
73
return ret ;
73
74
}
74
75
75
- static int __init psci_pd_parse_states (struct device_node * np ,
76
+ static int psci_pd_parse_states (struct device_node * np ,
76
77
struct genpd_power_state * * states , int * state_count )
77
78
{
78
79
int ret ;
@@ -100,7 +101,7 @@ static void psci_pd_free_states(struct genpd_power_state *states,
100
101
kfree (states );
101
102
}
102
103
103
- static int __init psci_pd_init (struct device_node * np )
104
+ static int psci_pd_init (struct device_node * np )
104
105
{
105
106
struct generic_pm_domain * pd ;
106
107
struct psci_pd_provider * pd_provider ;
@@ -167,7 +168,7 @@ static int __init psci_pd_init(struct device_node *np)
167
168
return ret ;
168
169
}
169
170
170
- static void __init psci_pd_remove (void )
171
+ static void psci_pd_remove (void )
171
172
{
172
173
struct psci_pd_provider * pd_provider , * it ;
173
174
struct generic_pm_domain * genpd ;
@@ -185,7 +186,7 @@ static void __init psci_pd_remove(void)
185
186
}
186
187
}
187
188
188
- static int __init psci_pd_init_topology (struct device_node * np , bool add )
189
+ static int psci_pd_init_topology (struct device_node * np , bool add )
189
190
{
190
191
struct device_node * node ;
191
192
struct of_phandle_args child , parent ;
@@ -211,24 +212,24 @@ static int __init psci_pd_init_topology(struct device_node *np, bool add)
211
212
return 0 ;
212
213
}
213
214
214
- static int __init psci_pd_add_topology (struct device_node * np )
215
+ static int psci_pd_add_topology (struct device_node * np )
215
216
{
216
217
return psci_pd_init_topology (np , true);
217
218
}
218
219
219
- static void __init psci_pd_remove_topology (struct device_node * np )
220
+ static void psci_pd_remove_topology (struct device_node * np )
220
221
{
221
222
psci_pd_init_topology (np , false);
222
223
}
223
224
224
- static const struct of_device_id psci_of_match [] __initconst = {
225
+ static const struct of_device_id psci_of_match [] = {
225
226
{ .compatible = "arm,psci-1.0" },
226
227
{}
227
228
};
228
229
229
- static int __init psci_idle_init_domains ( void )
230
+ static int psci_cpuidle_domain_probe ( struct platform_device * pdev )
230
231
{
231
- struct device_node * np = of_find_matching_node ( NULL , psci_of_match ) ;
232
+ struct device_node * np = pdev -> dev . of_node ;
232
233
struct device_node * node ;
233
234
int ret = 0 , pd_count = 0 ;
234
235
@@ -237,7 +238,7 @@ static int __init psci_idle_init_domains(void)
237
238
238
239
/* Currently limit the hierarchical topology to be used in OSI mode. */
239
240
if (!psci_has_osi_support ())
240
- goto out ;
241
+ return 0 ;
241
242
242
243
/*
243
244
* Parse child nodes for the "#power-domain-cells" property and
@@ -256,7 +257,7 @@ static int __init psci_idle_init_domains(void)
256
257
257
258
/* Bail out if not using the hierarchical CPU topology. */
258
259
if (!pd_count )
259
- goto out ;
260
+ return 0 ;
260
261
261
262
/* Link genpd masters/subdomains to model the CPU topology. */
262
263
ret = psci_pd_add_topology (np );
@@ -271,20 +272,30 @@ static int __init psci_idle_init_domains(void)
271
272
goto remove_pd ;
272
273
}
273
274
274
- of_node_put (np );
275
275
pr_info ("Initialized CPU PM domain topology\n" );
276
- return pd_count ;
276
+ return 0 ;
277
277
278
278
put_node :
279
279
of_node_put (node );
280
280
remove_pd :
281
281
if (pd_count )
282
282
psci_pd_remove ();
283
283
pr_err ("failed to create CPU PM domains ret=%d\n" , ret );
284
- out :
285
- of_node_put (np );
286
284
return ret ;
287
285
}
286
+
287
+ static struct platform_driver psci_cpuidle_domain_driver = {
288
+ .probe = psci_cpuidle_domain_probe ,
289
+ .driver = {
290
+ .name = "psci-cpuidle-domain" ,
291
+ .of_match_table = psci_of_match ,
292
+ },
293
+ };
294
+
295
+ static int __init psci_idle_init_domains (void )
296
+ {
297
+ return platform_driver_register (& psci_cpuidle_domain_driver );
298
+ }
288
299
subsys_initcall (psci_idle_init_domains );
289
300
290
301
struct device * psci_dt_attach_cpu (int cpu )
0 commit comments