Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 342324
b: refs/heads/master
c: 8a65d23
h: refs/heads/master
v: v3
  • Loading branch information
Tomasz Figa authored and Kukjin Kim committed Nov 21, 2012
1 parent bebf5cf commit 2ca1342
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7add0ec0fef19d5b7a3ae38c5deb80819a065a17
refs/heads/master: 8a65d2365df0635da13ae30c01e217c477c9ce3e
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@ Exynos processors include support for multiple power domains which are used
to gate power to one or more peripherals on the processor.

Required Properties:
- compatiable: should be one of the following.
- compatible: should be one of the following.
* samsung,exynos4210-pd - for exynos4210 type power domain.
- reg: physical base address of the controller and length of memory mapped
region.

Node of a device using power domains must have a samsung,power-domain property
defined with a phandle to respective power domain.

Example:

lcd0: power-domain-lcd0 {
compatible = "samsung,exynos4210-pd";
reg = <0x10023C00 0x10>;
};

Example of the node using power domain:

node {
/* ... */
samsung,power-domain = <&lcd0>;
/* ... */
};
82 changes: 82 additions & 0 deletions trunk/arch/arm/mach-exynos/pm_domains.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <linux/pm_domain.h>
#include <linux/delay.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
#include <linux/sched.h>

#include <mach/regs-pmu.h>
#include <plat/devs.h>
Expand Down Expand Up @@ -83,14 +85,89 @@ static struct exynos_pm_domain PD = { \
}

#ifdef CONFIG_OF
static void exynos_add_device_to_domain(struct exynos_pm_domain *pd,
struct device *dev)
{
int ret;

dev_dbg(dev, "adding to power domain %s\n", pd->pd.name);

while (1) {
ret = pm_genpd_add_device(&pd->pd, dev);
if (ret != -EAGAIN)
break;
cond_resched();
}

pm_genpd_dev_need_restore(dev, true);
}

static void exynos_remove_device_from_domain(struct device *dev)
{
struct generic_pm_domain *genpd = dev_to_genpd(dev);
int ret;

dev_dbg(dev, "removing from power domain %s\n", genpd->name);

while (1) {
ret = pm_genpd_remove_device(genpd, dev);
if (ret != -EAGAIN)
break;
cond_resched();
}
}

static void exynos_read_domain_from_dt(struct device *dev)
{
struct platform_device *pd_pdev;
struct exynos_pm_domain *pd;
struct device_node *node;

node = of_parse_phandle(dev->of_node, "samsung,power-domain", 0);
if (!node)
return;
pd_pdev = of_find_device_by_node(node);
if (!pd_pdev)
return;
pd = platform_get_drvdata(pd_pdev);
exynos_add_device_to_domain(pd, dev);
}

static int exynos_pm_notifier_call(struct notifier_block *nb,
unsigned long event, void *data)
{
struct device *dev = data;

switch (event) {
case BUS_NOTIFY_BIND_DRIVER:
if (dev->of_node)
exynos_read_domain_from_dt(dev);

break;

case BUS_NOTIFY_UNBOUND_DRIVER:
exynos_remove_device_from_domain(dev);

break;
}
return NOTIFY_DONE;
}

static struct notifier_block platform_nb = {
.notifier_call = exynos_pm_notifier_call,
};

static __init int exynos_pm_dt_parse_domains(void)
{
struct platform_device *pdev;
struct device_node *np;

for_each_compatible_node(np, NULL, "samsung,exynos4210-pd") {
struct exynos_pm_domain *pd;
int on;

pdev = of_find_device_by_node(np);

pd = kzalloc(sizeof(*pd), GFP_KERNEL);
if (!pd) {
pr_err("%s: failed to allocate memory for domain\n",
Expand All @@ -105,10 +182,15 @@ static __init int exynos_pm_dt_parse_domains(void)
pd->pd.power_on = exynos_pd_power_on;
pd->pd.of_node = np;

platform_set_drvdata(pdev, pd);

on = __raw_readl(pd->base + 0x4) & S5P_INT_LOCAL_PWR_EN;

pm_genpd_init(&pd->pd, NULL, !on);
}

bus_register_notifier(&platform_bus_type, &platform_nb);

return 0;
}
#else
Expand Down

0 comments on commit 2ca1342

Please sign in to comment.