aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/power/domain.c49
-rw-r--r--include/linux/pm_domain.h42
2 files changed, 51 insertions, 40 deletions
diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
index d8c1eabc7117..c93aa3a64839 100644
--- a/drivers/base/power/domain.c
+++ b/drivers/base/power/domain.c
@@ -1329,6 +1329,10 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
1329EXPORT_SYMBOL_GPL(pm_genpd_init); 1329EXPORT_SYMBOL_GPL(pm_genpd_init);
1330 1330
1331#ifdef CONFIG_PM_GENERIC_DOMAINS_OF 1331#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
1332
1333typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
1334 void *data);
1335
1332/* 1336/*
1333 * Device Tree based PM domain providers. 1337 * Device Tree based PM domain providers.
1334 * 1338 *
@@ -1340,8 +1344,8 @@ EXPORT_SYMBOL_GPL(pm_genpd_init);
1340 * maps a PM domain specifier retrieved from the device tree to a PM domain. 1344 * maps a PM domain specifier retrieved from the device tree to a PM domain.
1341 * 1345 *
1342 * Two simple mapping functions have been provided for convenience: 1346 * Two simple mapping functions have been provided for convenience:
1343 * - __of_genpd_xlate_simple() for 1:1 device tree node to PM domain mapping. 1347 * - genpd_xlate_simple() for 1:1 device tree node to PM domain mapping.
1344 * - __of_genpd_xlate_onecell() for mapping of multiple PM domains per node by 1348 * - genpd_xlate_onecell() for mapping of multiple PM domains per node by
1345 * index. 1349 * index.
1346 */ 1350 */
1347 1351
@@ -1366,7 +1370,7 @@ static LIST_HEAD(of_genpd_providers);
1366static DEFINE_MUTEX(of_genpd_mutex); 1370static DEFINE_MUTEX(of_genpd_mutex);
1367 1371
1368/** 1372/**
1369 * __of_genpd_xlate_simple() - Xlate function for direct node-domain mapping 1373 * genpd_xlate_simple() - Xlate function for direct node-domain mapping
1370 * @genpdspec: OF phandle args to map into a PM domain 1374 * @genpdspec: OF phandle args to map into a PM domain
1371 * @data: xlate function private data - pointer to struct generic_pm_domain 1375 * @data: xlate function private data - pointer to struct generic_pm_domain
1372 * 1376 *
@@ -1374,7 +1378,7 @@ static DEFINE_MUTEX(of_genpd_mutex);
1374 * have their own device tree nodes. The private data of xlate function needs 1378 * have their own device tree nodes. The private data of xlate function needs
1375 * to be a valid pointer to struct generic_pm_domain. 1379 * to be a valid pointer to struct generic_pm_domain.
1376 */ 1380 */
1377struct generic_pm_domain *__of_genpd_xlate_simple( 1381static struct generic_pm_domain *genpd_xlate_simple(
1378 struct of_phandle_args *genpdspec, 1382 struct of_phandle_args *genpdspec,
1379 void *data) 1383 void *data)
1380{ 1384{
@@ -1382,10 +1386,9 @@ struct generic_pm_domain *__of_genpd_xlate_simple(
1382 return ERR_PTR(-EINVAL); 1386 return ERR_PTR(-EINVAL);
1383 return data; 1387 return data;
1384} 1388}
1385EXPORT_SYMBOL_GPL(__of_genpd_xlate_simple);
1386 1389
1387/** 1390/**
1388 * __of_genpd_xlate_onecell() - Xlate function using a single index. 1391 * genpd_xlate_onecell() - Xlate function using a single index.
1389 * @genpdspec: OF phandle args to map into a PM domain 1392 * @genpdspec: OF phandle args to map into a PM domain
1390 * @data: xlate function private data - pointer to struct genpd_onecell_data 1393 * @data: xlate function private data - pointer to struct genpd_onecell_data
1391 * 1394 *
@@ -1394,7 +1397,7 @@ EXPORT_SYMBOL_GPL(__of_genpd_xlate_simple);
1394 * A single cell is used as an index into an array of PM domains specified in 1397 * A single cell is used as an index into an array of PM domains specified in
1395 * the genpd_onecell_data struct when registering the provider. 1398 * the genpd_onecell_data struct when registering the provider.
1396 */ 1399 */
1397struct generic_pm_domain *__of_genpd_xlate_onecell( 1400static struct generic_pm_domain *genpd_xlate_onecell(
1398 struct of_phandle_args *genpdspec, 1401 struct of_phandle_args *genpdspec,
1399 void *data) 1402 void *data)
1400{ 1403{
@@ -1414,16 +1417,15 @@ struct generic_pm_domain *__of_genpd_xlate_onecell(
1414 1417
1415 return genpd_data->domains[idx]; 1418 return genpd_data->domains[idx];
1416} 1419}
1417EXPORT_SYMBOL_GPL(__of_genpd_xlate_onecell);
1418 1420
1419/** 1421/**
1420 * __of_genpd_add_provider() - Register a PM domain provider for a node 1422 * genpd_add_provider() - Register a PM domain provider for a node
1421 * @np: Device node pointer associated with the PM domain provider. 1423 * @np: Device node pointer associated with the PM domain provider.
1422 * @xlate: Callback for decoding PM domain from phandle arguments. 1424 * @xlate: Callback for decoding PM domain from phandle arguments.
1423 * @data: Context pointer for @xlate callback. 1425 * @data: Context pointer for @xlate callback.
1424 */ 1426 */
1425int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, 1427static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
1426 void *data) 1428 void *data)
1427{ 1429{
1428 struct of_genpd_provider *cp; 1430 struct of_genpd_provider *cp;
1429 1431
@@ -1442,7 +1444,30 @@ int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate,
1442 1444
1443 return 0; 1445 return 0;
1444} 1446}
1445EXPORT_SYMBOL_GPL(__of_genpd_add_provider); 1447
1448/**
1449 * of_genpd_add_provider_simple() - Register a simple PM domain provider
1450 * @np: Device node pointer associated with the PM domain provider.
1451 * @genpd: Pointer to PM domain associated with the PM domain provider.
1452 */
1453int of_genpd_add_provider_simple(struct device_node *np,
1454 struct generic_pm_domain *genpd)
1455{
1456 return genpd_add_provider(np, genpd_xlate_simple, genpd);
1457}
1458EXPORT_SYMBOL_GPL(of_genpd_add_provider_simple);
1459
1460/**
1461 * of_genpd_add_provider_onecell() - Register a onecell PM domain provider
1462 * @np: Device node pointer associated with the PM domain provider.
1463 * @data: Pointer to the data associated with the PM domain provider.
1464 */
1465int of_genpd_add_provider_onecell(struct device_node *np,
1466 struct genpd_onecell_data *data)
1467{
1468 return genpd_add_provider(np, genpd_xlate_onecell, data);
1469}
1470EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);
1446 1471
1447/** 1472/**
1448 * of_genpd_del_provider() - Remove a previously registered PM domain provider 1473 * of_genpd_del_provider() - Remove a previously registered PM domain provider
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index bd411e754f4a..f103869db443 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -187,19 +187,12 @@ struct genpd_onecell_data {
187 unsigned int num_domains; 187 unsigned int num_domains;
188}; 188};
189 189
190typedef struct generic_pm_domain *(*genpd_xlate_t)(struct of_phandle_args *args,
191 void *data);
192
193#ifdef CONFIG_PM_GENERIC_DOMAINS_OF 190#ifdef CONFIG_PM_GENERIC_DOMAINS_OF
194int __of_genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, 191int of_genpd_add_provider_simple(struct device_node *np,
195 void *data); 192 struct generic_pm_domain *genpd);
193int of_genpd_add_provider_onecell(struct device_node *np,
194 struct genpd_onecell_data *data);
196void of_genpd_del_provider(struct device_node *np); 195void of_genpd_del_provider(struct device_node *np);
197struct generic_pm_domain *__of_genpd_xlate_simple(
198 struct of_phandle_args *genpdspec,
199 void *data);
200struct generic_pm_domain *__of_genpd_xlate_onecell(
201 struct of_phandle_args *genpdspec,
202 void *data);
203extern int of_genpd_add_device(struct of_phandle_args *args, 196extern int of_genpd_add_device(struct of_phandle_args *args,
204 struct device *dev); 197 struct device *dev);
205extern int of_genpd_add_subdomain(struct of_phandle_args *parent, 198extern int of_genpd_add_subdomain(struct of_phandle_args *parent,
@@ -207,15 +200,19 @@ extern int of_genpd_add_subdomain(struct of_phandle_args *parent,
207 200
208int genpd_dev_pm_attach(struct device *dev); 201int genpd_dev_pm_attach(struct device *dev);
209#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */ 202#else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
210static inline int __of_genpd_add_provider(struct device_node *np, 203static inline int of_genpd_add_provider_simple(struct device_node *np,
211 genpd_xlate_t xlate, void *data) 204 struct generic_pm_domain *genpd)
212{ 205{
213 return 0; 206 return -ENOTSUPP;
207}
208
209static inline int of_genpd_add_provider_onecell(struct device_node *np,
210 struct genpd_onecell_data *data)
211{
212 return -ENOTSUPP;
214} 213}
215static inline void of_genpd_del_provider(struct device_node *np) {}
216 214
217#define __of_genpd_xlate_simple NULL 215static inline void of_genpd_del_provider(struct device_node *np) {}
218#define __of_genpd_xlate_onecell NULL
219 216
220static inline int of_genpd_add_device(struct of_phandle_args *args, 217static inline int of_genpd_add_device(struct of_phandle_args *args,
221 struct device *dev) 218 struct device *dev)
@@ -235,17 +232,6 @@ static inline int genpd_dev_pm_attach(struct device *dev)
235} 232}
236#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */ 233#endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
237 234
238static inline int of_genpd_add_provider_simple(struct device_node *np,
239 struct generic_pm_domain *genpd)
240{
241 return __of_genpd_add_provider(np, __of_genpd_xlate_simple, genpd);
242}
243static inline int of_genpd_add_provider_onecell(struct device_node *np,
244 struct genpd_onecell_data *data)
245{
246 return __of_genpd_add_provider(np, __of_genpd_xlate_onecell, data);
247}
248
249#ifdef CONFIG_PM 235#ifdef CONFIG_PM
250extern int dev_pm_domain_attach(struct device *dev, bool power_on); 236extern int dev_pm_domain_attach(struct device *dev, bool power_on);
251extern void dev_pm_domain_detach(struct device *dev, bool power_off); 237extern void dev_pm_domain_detach(struct device *dev, bool power_off);