Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-16 Thread Caesar Wang


在 2014年11月14日 03:35, Daniel Kurtz 写道:

On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang  wrote:

In order to meet high performance and low power requirements, a power
management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power ot the whole chip.

Signed-off-by: Jack Dai 
Signed-off-by: jinkun.hong 
Signed-off-by: Caesar Wang 

---

Changes in v11:
 - fix pm_genpd_init(>genpd, NULL, false);

Changes in v10:
 - this switches over domain infos to use masks instead of recomputing
   them each time and also gets rid of custom domain translator and
   uses standard onecell on.

Changes in v9:
 - fix v8 changes as follows:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.
 - add rockchip_pm_add_one_domain() to control domains.
 - add pd_start/pd_stop interface to control clocks

Changes in v8:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.

Changes in v7:
 - Delete unused variables

Changes in v6:
 - delete pmu_lock
 - modify dev_lock using mutex
 - pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
 - pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
 - add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
 - delete idle_lock
 - add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
 - use list storage dev

Changes in v3:
 - change use pm_clk_resume() and pm_clk_suspend()

Changes in v2:
 - remove the "pd->pd.of_node = np"

  arch/arm/mach-rockchip/Kconfig|   1 +
  arch/arm/mach-rockchip/Makefile   |   1 +
  arch/arm/mach-rockchip/pm_domains.c   | 471 ++
  include/dt-bindings/power-domain/rk3288.h |  11 +
  4 files changed, 484 insertions(+)
  create mode 100644 arch/arm/mach-rockchip/pm_domains.c
  create mode 100644 include/dt-bindings/power-domain/rk3288.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ac5803c..d033993 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
 select DW_APB_TIMER_OF
 select ARM_GLOBAL_TIMER
 select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+   select PM_GENERIC_DOMAINS if PM
 help
   Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
   containing the RK2928, RK30xx and RK31xx series.
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index b29d8ea..17ea082 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,4 +1,5 @@
  CFLAGS_platsmp.o := -march=armv7-a

  obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
  obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-rockchip/pm_domains.c 
b/arch/arm/mach-rockchip/pm_domains.c
new file mode 100644
index 000..00730eb
--- /dev/null
+++ b/arch/arm/mach-rockchip/pm_domains.c
@@ -0,0 +1,471 @@
+/*
+ * Rockchip Generic power domain support.
+ *
+ * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct rockchip_domain_info {
+   int pwr_mask;
+   int status_mask;
+   int req_mask;
+   int idle_mask;
+   int ack_mask;
+};
+
+struct rockchip_pmu_info {
+   u32 pwr_offset;
+   u32 status_offset;
+   u32 req_offset;
+   u32 idle_offset;
+   u32 ack_offset;
+
+   int num_domains;
+   const struct rockchip_domain_info *domain_info;
+};
+
+struct rockchip_pm_domain {
+   struct generic_pm_domain genpd;
+   const struct rockchip_domain_info *info;
+   struct rockchip_pmu *pmu;
+   int num_clks;
+   struct clk *clks[];
+};
+
+struct rockchip_pmu {
+   struct device *dev;
+   struct regmap *regmap;
+   const struct rockchip_pmu_info *info;
+   struct mutex mutex; /* mutex lock for pmu */
+   struct genpd_onecell_data genpd_data;
+   struct generic_pm_domain *domains[];
+};
+
+#define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd)
+
+#define DOMAIN(pwr, status, req, idle, ack)\

Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-16 Thread Caesar Wang


在 2014年11月14日 03:35, Daniel Kurtz 写道:

On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang caesar.w...@rock-chips.com wrote:

In order to meet high performance and low power requirements, a power
management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power ot the whole chip.

Signed-off-by: Jack Dai jack@rock-chips.com
Signed-off-by: jinkun.hong jinkun.h...@rock-chips.com
Signed-off-by: Caesar Wang caesar.w...@rock-chips.com

---

Changes in v11:
 - fix pm_genpd_init(pd-genpd, NULL, false);

Changes in v10:
 - this switches over domain infos to use masks instead of recomputing
   them each time and also gets rid of custom domain translator and
   uses standard onecell on.

Changes in v9:
 - fix v8 changes as follows:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.
 - add rockchip_pm_add_one_domain() to control domains.
 - add pd_start/pd_stop interface to control clocks

Changes in v8:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.

Changes in v7:
 - Delete unused variables

Changes in v6:
 - delete pmu_lock
 - modify dev_lock using mutex
 - pm_clk_resume(pd-dev) change to pm_clk_resume(ed-dev)
 - pm_clk_suspend(pd-dev) change to pm_clk_suspend(ed-dev)
 - add devm_kfree(pd-dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
 - delete idle_lock
 - add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
 - use list storage dev

Changes in v3:
 - change use pm_clk_resume() and pm_clk_suspend()

Changes in v2:
 - remove the pd-pd.of_node = np

  arch/arm/mach-rockchip/Kconfig|   1 +
  arch/arm/mach-rockchip/Makefile   |   1 +
  arch/arm/mach-rockchip/pm_domains.c   | 471 ++
  include/dt-bindings/power-domain/rk3288.h |  11 +
  4 files changed, 484 insertions(+)
  create mode 100644 arch/arm/mach-rockchip/pm_domains.c
  create mode 100644 include/dt-bindings/power-domain/rk3288.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ac5803c..d033993 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
 select DW_APB_TIMER_OF
 select ARM_GLOBAL_TIMER
 select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+   select PM_GENERIC_DOMAINS if PM
 help
   Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
   containing the RK2928, RK30xx and RK31xx series.
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index b29d8ea..17ea082 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,4 +1,5 @@
  CFLAGS_platsmp.o := -march=armv7-a

  obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
  obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-rockchip/pm_domains.c 
b/arch/arm/mach-rockchip/pm_domains.c
new file mode 100644
index 000..00730eb
--- /dev/null
+++ b/arch/arm/mach-rockchip/pm_domains.c
@@ -0,0 +1,471 @@
+/*
+ * Rockchip Generic power domain support.
+ *
+ * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/io.h
+#include linux/err.h
+#include linux/pm_clock.h
+#include linux/pm_domain.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/clk.h
+#include linux/clk-provider.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
+#include dt-bindings/power-domain/rk3288.h
+
+struct rockchip_domain_info {
+   int pwr_mask;
+   int status_mask;
+   int req_mask;
+   int idle_mask;
+   int ack_mask;
+};
+
+struct rockchip_pmu_info {
+   u32 pwr_offset;
+   u32 status_offset;
+   u32 req_offset;
+   u32 idle_offset;
+   u32 ack_offset;
+
+   int num_domains;
+   const struct rockchip_domain_info *domain_info;
+};
+
+struct rockchip_pm_domain {
+   struct generic_pm_domain genpd;
+   const struct rockchip_domain_info *info;
+   struct rockchip_pmu *pmu;
+   int num_clks;
+   struct clk *clks[];
+};
+
+struct rockchip_pmu {
+   struct device *dev;
+   struct regmap *regmap;
+   const struct 

Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Daniel Kurtz
Caesar,

One more little nit:

The title of this patch has a typo:
  doamin -> domain

Thanks,
-Dan
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Dmitry Torokhov
On Friday, November 14, 2014 03:35:44 AM Daniel Kurtz wrote:
> On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang  
> wrote:
> > +
> > +   error = -ENXIO;
> > +
> > +   for_each_available_child_of_node(np, node) {
> > +   error = rockchip_pm_add_one_domain(pmu, node);
> > +   if (error) {
> > +   dev_err(dev, "failed to handle node %s: %d\n",
> > +   node->name, error);
> > +   goto err_out;
> > +   }
> > +   }
> > +
> > +   if (error) {
> > +   dev_dbg(dev, "no power domains defined\n");
> 
> Perhaps dev_err() or dev_warn(), to ensure this message is seen.
> But, not have defined power domains doesn't seem like a fatal error.
> Perhaps just return 0?

As far as the driver concerned it is a fatal error - the driver can't do
anything when no domain is defined.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Daniel Kurtz
On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang  wrote:
> In order to meet high performance and low power requirements, a power
> management unit is designed or saving power when RK3288 in low power mode.
> The RK3288 PMU is dedicated for managing the power ot the whole chip.
>
> Signed-off-by: Jack Dai 
> Signed-off-by: jinkun.hong 
> Signed-off-by: Caesar Wang 
>
> ---
>
> Changes in v11:
> - fix pm_genpd_init(>genpd, NULL, false);
>
> Changes in v10:
> - this switches over domain infos to use masks instead of recomputing
>   them each time and also gets rid of custom domain translator and
>   uses standard onecell on.
>
> Changes in v9:
> - fix v8 changes as follows:
> - This reconciles the v2 and v7 code so that we power domain have
>   lists of clocks they toggle on and off during power transitions and
>   independently from power domains clocks we attach clocks to devices
>   comprising power domain and prepare them so they are turn on and off
>   by runtime PM.
> - add rockchip_pm_add_one_domain() to control domains.
> - add pd_start/pd_stop interface to control clocks
>
> Changes in v8:
> - This reconciles the v2 and v7 code so that we power domain have
>   lists of clocks they toggle on and off during power transitions and
>   independently from power domains clocks we attach clocks to devices
>   comprising power domain and prepare them so they are turn on and off
>   by runtime PM.
>
> Changes in v7:
> - Delete unused variables
>
> Changes in v6:
> - delete pmu_lock
> - modify dev_lock using mutex
> - pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
> - pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
> - add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev
>
> Changes in v5:
> - delete idle_lock
> - add timeout in rockchip_pmu_set_idle_request()
>
> Changes in v4:
> - use list storage dev
>
> Changes in v3:
> - change use pm_clk_resume() and pm_clk_suspend()
>
> Changes in v2:
> - remove the "pd->pd.of_node = np"
>
>  arch/arm/mach-rockchip/Kconfig|   1 +
>  arch/arm/mach-rockchip/Makefile   |   1 +
>  arch/arm/mach-rockchip/pm_domains.c   | 471 
> ++
>  include/dt-bindings/power-domain/rk3288.h |  11 +
>  4 files changed, 484 insertions(+)
>  create mode 100644 arch/arm/mach-rockchip/pm_domains.c
>  create mode 100644 include/dt-bindings/power-domain/rk3288.h
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index ac5803c..d033993 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
> select DW_APB_TIMER_OF
> select ARM_GLOBAL_TIMER
> select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
> +   select PM_GENERIC_DOMAINS if PM
> help
>   Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
>   containing the RK2928, RK30xx and RK31xx series.
> diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
> index b29d8ea..17ea082 100644
> --- a/arch/arm/mach-rockchip/Makefile
> +++ b/arch/arm/mach-rockchip/Makefile
> @@ -1,4 +1,5 @@
>  CFLAGS_platsmp.o := -march=armv7-a
>
>  obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
> +obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
>  obj-$(CONFIG_SMP) += headsmp.o platsmp.o
> diff --git a/arch/arm/mach-rockchip/pm_domains.c 
> b/arch/arm/mach-rockchip/pm_domains.c
> new file mode 100644
> index 000..00730eb
> --- /dev/null
> +++ b/arch/arm/mach-rockchip/pm_domains.c
> @@ -0,0 +1,471 @@
> +/*
> + * Rockchip Generic power domain support.
> + *
> + * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +struct rockchip_domain_info {
> +   int pwr_mask;
> +   int status_mask;
> +   int req_mask;
> +   int idle_mask;
> +   int ack_mask;
> +};
> +
> +struct rockchip_pmu_info {
> +   u32 pwr_offset;
> +   u32 status_offset;
> +   u32 req_offset;
> +   u32 idle_offset;
> +   u32 ack_offset;
> +
> +   int num_domains;
> +   const struct rockchip_domain_info *domain_info;
> +};
> +
> +struct rockchip_pm_domain {
> +   struct generic_pm_domain genpd;
> +   const struct rockchip_domain_info *info;
> +   struct rockchip_pmu *pmu;
> +   int num_clks;
> +   struct clk *clks[];
> +};
> +
> +struct rockchip_pmu {
> +   struct device *dev;
> +   struct regmap *regmap;
> +   const struct rockchip_pmu_info *info;
> +   struct mutex mutex; /* mutex lock for pmu */
> +   struct 

Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Doug Anderson
Hi,

On Wed, Nov 12, 2014 at 2:01 PM, Caesar Wang  wrote:
> In order to meet high performance and low power requirements, a power
> management unit is designed or saving power when RK3288 in low power mode.
> The RK3288 PMU is dedicated for managing the power ot the whole chip.
>
> Signed-off-by: Jack Dai 
> Signed-off-by: jinkun.hong 
> Signed-off-by: Caesar Wang 
>
> ---
>
> Changes in v11:
> - fix pm_genpd_init(>genpd, NULL, false);
>
> Changes in v10:
> - this switches over domain infos to use masks instead of recomputing
>   them each time and also gets rid of custom domain translator and
>   uses standard onecell on.
>
> Changes in v9:
> - fix v8 changes as follows:
> - This reconciles the v2 and v7 code so that we power domain have
>   lists of clocks they toggle on and off during power transitions and
>   independently from power domains clocks we attach clocks to devices
>   comprising power domain and prepare them so they are turn on and off
>   by runtime PM.
> - add rockchip_pm_add_one_domain() to control domains.
> - add pd_start/pd_stop interface to control clocks
>
> Changes in v8:
> - This reconciles the v2 and v7 code so that we power domain have
>   lists of clocks they toggle on and off during power transitions and
>   independently from power domains clocks we attach clocks to devices
>   comprising power domain and prepare them so they are turn on and off
>   by runtime PM.
>
> Changes in v7:
> - Delete unused variables
>
> Changes in v6:
> - delete pmu_lock
> - modify dev_lock using mutex
> - pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
> - pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
> - add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev
>
> Changes in v5:
> - delete idle_lock
> - add timeout in rockchip_pmu_set_idle_request()
>
> Changes in v4:
> - use list storage dev
>
> Changes in v3:
> - change use pm_clk_resume() and pm_clk_suspend()
>
> Changes in v2:
> - remove the "pd->pd.of_node = np"
>
>  arch/arm/mach-rockchip/Kconfig|   1 +
>  arch/arm/mach-rockchip/Makefile   |   1 +
>  arch/arm/mach-rockchip/pm_domains.c   | 471 
> ++
>  include/dt-bindings/power-domain/rk3288.h |  11 +
>  4 files changed, 484 insertions(+)

This was discussed offlist, but just to make sure it's also included here:

This patch will need to be spun to deal with the fact that (c16561e PM
/ Domains: Change prototype for the attach and detach callbacks) has
landed.

-Doug
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Doug Anderson
Hi,

On Wed, Nov 12, 2014 at 2:01 PM, Caesar Wang caesar.w...@rock-chips.com wrote:
 In order to meet high performance and low power requirements, a power
 management unit is designed or saving power when RK3288 in low power mode.
 The RK3288 PMU is dedicated for managing the power ot the whole chip.

 Signed-off-by: Jack Dai jack@rock-chips.com
 Signed-off-by: jinkun.hong jinkun.h...@rock-chips.com
 Signed-off-by: Caesar Wang caesar.w...@rock-chips.com

 ---

 Changes in v11:
 - fix pm_genpd_init(pd-genpd, NULL, false);

 Changes in v10:
 - this switches over domain infos to use masks instead of recomputing
   them each time and also gets rid of custom domain translator and
   uses standard onecell on.

 Changes in v9:
 - fix v8 changes as follows:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.
 - add rockchip_pm_add_one_domain() to control domains.
 - add pd_start/pd_stop interface to control clocks

 Changes in v8:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.

 Changes in v7:
 - Delete unused variables

 Changes in v6:
 - delete pmu_lock
 - modify dev_lock using mutex
 - pm_clk_resume(pd-dev) change to pm_clk_resume(ed-dev)
 - pm_clk_suspend(pd-dev) change to pm_clk_suspend(ed-dev)
 - add devm_kfree(pd-dev, de) in rockchip_pm_domain_detach_dev

 Changes in v5:
 - delete idle_lock
 - add timeout in rockchip_pmu_set_idle_request()

 Changes in v4:
 - use list storage dev

 Changes in v3:
 - change use pm_clk_resume() and pm_clk_suspend()

 Changes in v2:
 - remove the pd-pd.of_node = np

  arch/arm/mach-rockchip/Kconfig|   1 +
  arch/arm/mach-rockchip/Makefile   |   1 +
  arch/arm/mach-rockchip/pm_domains.c   | 471 
 ++
  include/dt-bindings/power-domain/rk3288.h |  11 +
  4 files changed, 484 insertions(+)

This was discussed offlist, but just to make sure it's also included here:

This patch will need to be spun to deal with the fact that (c16561e PM
/ Domains: Change prototype for the attach and detach callbacks) has
landed.

-Doug
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Daniel Kurtz
On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang caesar.w...@rock-chips.com wrote:
 In order to meet high performance and low power requirements, a power
 management unit is designed or saving power when RK3288 in low power mode.
 The RK3288 PMU is dedicated for managing the power ot the whole chip.

 Signed-off-by: Jack Dai jack@rock-chips.com
 Signed-off-by: jinkun.hong jinkun.h...@rock-chips.com
 Signed-off-by: Caesar Wang caesar.w...@rock-chips.com

 ---

 Changes in v11:
 - fix pm_genpd_init(pd-genpd, NULL, false);

 Changes in v10:
 - this switches over domain infos to use masks instead of recomputing
   them each time and also gets rid of custom domain translator and
   uses standard onecell on.

 Changes in v9:
 - fix v8 changes as follows:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.
 - add rockchip_pm_add_one_domain() to control domains.
 - add pd_start/pd_stop interface to control clocks

 Changes in v8:
 - This reconciles the v2 and v7 code so that we power domain have
   lists of clocks they toggle on and off during power transitions and
   independently from power domains clocks we attach clocks to devices
   comprising power domain and prepare them so they are turn on and off
   by runtime PM.

 Changes in v7:
 - Delete unused variables

 Changes in v6:
 - delete pmu_lock
 - modify dev_lock using mutex
 - pm_clk_resume(pd-dev) change to pm_clk_resume(ed-dev)
 - pm_clk_suspend(pd-dev) change to pm_clk_suspend(ed-dev)
 - add devm_kfree(pd-dev, de) in rockchip_pm_domain_detach_dev

 Changes in v5:
 - delete idle_lock
 - add timeout in rockchip_pmu_set_idle_request()

 Changes in v4:
 - use list storage dev

 Changes in v3:
 - change use pm_clk_resume() and pm_clk_suspend()

 Changes in v2:
 - remove the pd-pd.of_node = np

  arch/arm/mach-rockchip/Kconfig|   1 +
  arch/arm/mach-rockchip/Makefile   |   1 +
  arch/arm/mach-rockchip/pm_domains.c   | 471 
 ++
  include/dt-bindings/power-domain/rk3288.h |  11 +
  4 files changed, 484 insertions(+)
  create mode 100644 arch/arm/mach-rockchip/pm_domains.c
  create mode 100644 include/dt-bindings/power-domain/rk3288.h

 diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
 index ac5803c..d033993 100644
 --- a/arch/arm/mach-rockchip/Kconfig
 +++ b/arch/arm/mach-rockchip/Kconfig
 @@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
 select DW_APB_TIMER_OF
 select ARM_GLOBAL_TIMER
 select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
 +   select PM_GENERIC_DOMAINS if PM
 help
   Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
   containing the RK2928, RK30xx and RK31xx series.
 diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
 index b29d8ea..17ea082 100644
 --- a/arch/arm/mach-rockchip/Makefile
 +++ b/arch/arm/mach-rockchip/Makefile
 @@ -1,4 +1,5 @@
  CFLAGS_platsmp.o := -march=armv7-a

  obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
 +obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
  obj-$(CONFIG_SMP) += headsmp.o platsmp.o
 diff --git a/arch/arm/mach-rockchip/pm_domains.c 
 b/arch/arm/mach-rockchip/pm_domains.c
 new file mode 100644
 index 000..00730eb
 --- /dev/null
 +++ b/arch/arm/mach-rockchip/pm_domains.c
 @@ -0,0 +1,471 @@
 +/*
 + * Rockchip Generic power domain support.
 + *
 + * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License version 2 as
 + * published by the Free Software Foundation.
 + */
 +
 +#include linux/module.h
 +#include linux/io.h
 +#include linux/err.h
 +#include linux/pm_clock.h
 +#include linux/pm_domain.h
 +#include linux/of_address.h
 +#include linux/of_platform.h
 +#include linux/clk.h
 +#include linux/clk-provider.h
 +#include linux/regmap.h
 +#include linux/mfd/syscon.h
 +#include dt-bindings/power-domain/rk3288.h
 +
 +struct rockchip_domain_info {
 +   int pwr_mask;
 +   int status_mask;
 +   int req_mask;
 +   int idle_mask;
 +   int ack_mask;
 +};
 +
 +struct rockchip_pmu_info {
 +   u32 pwr_offset;
 +   u32 status_offset;
 +   u32 req_offset;
 +   u32 idle_offset;
 +   u32 ack_offset;
 +
 +   int num_domains;
 +   const struct rockchip_domain_info *domain_info;
 +};
 +
 +struct rockchip_pm_domain {
 +   struct generic_pm_domain genpd;
 +   const struct rockchip_domain_info *info;
 +   struct rockchip_pmu *pmu;
 +   int num_clks;
 +   struct clk *clks[];
 +};
 +
 +struct rockchip_pmu {
 +   struct device *dev;
 +   struct 

Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Dmitry Torokhov
On Friday, November 14, 2014 03:35:44 AM Daniel Kurtz wrote:
 On Thu, Nov 13, 2014 at 6:01 AM, Caesar Wang caesar.w...@rock-chips.com 
 wrote:
  +
  +   error = -ENXIO;
  +
  +   for_each_available_child_of_node(np, node) {
  +   error = rockchip_pm_add_one_domain(pmu, node);
  +   if (error) {
  +   dev_err(dev, failed to handle node %s: %d\n,
  +   node-name, error);
  +   goto err_out;
  +   }
  +   }
  +
  +   if (error) {
  +   dev_dbg(dev, no power domains defined\n);
 
 Perhaps dev_err() or dev_warn(), to ensure this message is seen.
 But, not have defined power domains doesn't seem like a fatal error.
 Perhaps just return 0?

As far as the driver concerned it is a fatal error - the driver can't do
anything when no domain is defined.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-13 Thread Daniel Kurtz
Caesar,

One more little nit:

The title of this patch has a typo:
  doamin - domain

Thanks,
-Dan
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-12 Thread Caesar Wang
In order to meet high performance and low power requirements, a power
management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power ot the whole chip.

Signed-off-by: Jack Dai 
Signed-off-by: jinkun.hong 
Signed-off-by: Caesar Wang 

---

Changes in v11:
- fix pm_genpd_init(>genpd, NULL, false);

Changes in v10:
- this switches over domain infos to use masks instead of recomputing
  them each time and also gets rid of custom domain translator and
  uses standard onecell on.

Changes in v9:
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks

Changes in v8:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock
- modify dev_lock using mutex
- pm_clk_resume(pd->dev) change to pm_clk_resume(ed->dev)
- pm_clk_suspend(pd->dev) change to pm_clk_suspend(ed->dev)
- add devm_kfree(pd->dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
- delete idle_lock
- add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
- use list storage dev

Changes in v3:
- change use pm_clk_resume() and pm_clk_suspend()

Changes in v2:
- remove the "pd->pd.of_node = np"

 arch/arm/mach-rockchip/Kconfig|   1 +
 arch/arm/mach-rockchip/Makefile   |   1 +
 arch/arm/mach-rockchip/pm_domains.c   | 471 ++
 include/dt-bindings/power-domain/rk3288.h |  11 +
 4 files changed, 484 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ac5803c..d033993 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
select DW_APB_TIMER_OF
select ARM_GLOBAL_TIMER
select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+   select PM_GENERIC_DOMAINS if PM
help
  Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
  containing the RK2928, RK30xx and RK31xx series.
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index b29d8ea..17ea082 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,4 +1,5 @@
 CFLAGS_platsmp.o := -march=armv7-a
 
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-rockchip/pm_domains.c 
b/arch/arm/mach-rockchip/pm_domains.c
new file mode 100644
index 000..00730eb
--- /dev/null
+++ b/arch/arm/mach-rockchip/pm_domains.c
@@ -0,0 +1,471 @@
+/*
+ * Rockchip Generic power domain support.
+ *
+ * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct rockchip_domain_info {
+   int pwr_mask;
+   int status_mask;
+   int req_mask;
+   int idle_mask;
+   int ack_mask;
+};
+
+struct rockchip_pmu_info {
+   u32 pwr_offset;
+   u32 status_offset;
+   u32 req_offset;
+   u32 idle_offset;
+   u32 ack_offset;
+
+   int num_domains;
+   const struct rockchip_domain_info *domain_info;
+};
+
+struct rockchip_pm_domain {
+   struct generic_pm_domain genpd;
+   const struct rockchip_domain_info *info;
+   struct rockchip_pmu *pmu;
+   int num_clks;
+   struct clk *clks[];
+};
+
+struct rockchip_pmu {
+   struct device *dev;
+   struct regmap *regmap;
+   const struct rockchip_pmu_info *info;
+   struct mutex mutex; /* mutex lock for pmu */
+   struct genpd_onecell_data genpd_data;
+   struct generic_pm_domain *domains[];
+};
+
+#define to_rockchip_pd(gpd) container_of(gpd, struct rockchip_pm_domain, genpd)
+
+#define DOMAIN(pwr, status, req, idle, ack)\
+{  \
+   .pwr_mask = BIT(pwr),   \
+   .status_mask = BIT(status), 

[PATCH v11 2/3] power-domain: rockchip: add power doamin driver

2014-11-12 Thread Caesar Wang
In order to meet high performance and low power requirements, a power
management unit is designed or saving power when RK3288 in low power mode.
The RK3288 PMU is dedicated for managing the power ot the whole chip.

Signed-off-by: Jack Dai jack@rock-chips.com
Signed-off-by: jinkun.hong jinkun.h...@rock-chips.com
Signed-off-by: Caesar Wang caesar.w...@rock-chips.com

---

Changes in v11:
- fix pm_genpd_init(pd-genpd, NULL, false);

Changes in v10:
- this switches over domain infos to use masks instead of recomputing
  them each time and also gets rid of custom domain translator and
  uses standard onecell on.

Changes in v9:
- fix v8 changes as follows:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.
- add rockchip_pm_add_one_domain() to control domains.
- add pd_start/pd_stop interface to control clocks

Changes in v8:
- This reconciles the v2 and v7 code so that we power domain have
  lists of clocks they toggle on and off during power transitions and
  independently from power domains clocks we attach clocks to devices
  comprising power domain and prepare them so they are turn on and off
  by runtime PM.

Changes in v7:
- Delete unused variables

Changes in v6:
- delete pmu_lock
- modify dev_lock using mutex
- pm_clk_resume(pd-dev) change to pm_clk_resume(ed-dev)
- pm_clk_suspend(pd-dev) change to pm_clk_suspend(ed-dev)
- add devm_kfree(pd-dev, de) in rockchip_pm_domain_detach_dev

Changes in v5:
- delete idle_lock
- add timeout in rockchip_pmu_set_idle_request()

Changes in v4:
- use list storage dev

Changes in v3:
- change use pm_clk_resume() and pm_clk_suspend()

Changes in v2:
- remove the pd-pd.of_node = np

 arch/arm/mach-rockchip/Kconfig|   1 +
 arch/arm/mach-rockchip/Makefile   |   1 +
 arch/arm/mach-rockchip/pm_domains.c   | 471 ++
 include/dt-bindings/power-domain/rk3288.h |  11 +
 4 files changed, 484 insertions(+)
 create mode 100644 arch/arm/mach-rockchip/pm_domains.c
 create mode 100644 include/dt-bindings/power-domain/rk3288.h

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ac5803c..d033993 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -13,6 +13,7 @@ config ARCH_ROCKCHIP
select DW_APB_TIMER_OF
select ARM_GLOBAL_TIMER
select CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK
+   select PM_GENERIC_DOMAINS if PM
help
  Support for Rockchip's Cortex-A9 Single-to-Quad-Core-SoCs
  containing the RK2928, RK30xx and RK31xx series.
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index b29d8ea..17ea082 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,4 +1,5 @@
 CFLAGS_platsmp.o := -march=armv7-a
 
 obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip.o
+obj-$(CONFIG_PM_GENERIC_DOMAINS) += pm_domains.o
 obj-$(CONFIG_SMP) += headsmp.o platsmp.o
diff --git a/arch/arm/mach-rockchip/pm_domains.c 
b/arch/arm/mach-rockchip/pm_domains.c
new file mode 100644
index 000..00730eb
--- /dev/null
+++ b/arch/arm/mach-rockchip/pm_domains.c
@@ -0,0 +1,471 @@
+/*
+ * Rockchip Generic power domain support.
+ *
+ * Copyright (c) 2014 ROCKCHIP, Co. Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include linux/module.h
+#include linux/io.h
+#include linux/err.h
+#include linux/pm_clock.h
+#include linux/pm_domain.h
+#include linux/of_address.h
+#include linux/of_platform.h
+#include linux/clk.h
+#include linux/clk-provider.h
+#include linux/regmap.h
+#include linux/mfd/syscon.h
+#include dt-bindings/power-domain/rk3288.h
+
+struct rockchip_domain_info {
+   int pwr_mask;
+   int status_mask;
+   int req_mask;
+   int idle_mask;
+   int ack_mask;
+};
+
+struct rockchip_pmu_info {
+   u32 pwr_offset;
+   u32 status_offset;
+   u32 req_offset;
+   u32 idle_offset;
+   u32 ack_offset;
+
+   int num_domains;
+   const struct rockchip_domain_info *domain_info;
+};
+
+struct rockchip_pm_domain {
+   struct generic_pm_domain genpd;
+   const struct rockchip_domain_info *info;
+   struct rockchip_pmu *pmu;
+   int num_clks;
+   struct clk *clks[];
+};
+
+struct rockchip_pmu {
+   struct device *dev;
+   struct regmap *regmap;
+   const struct rockchip_pmu_info *info;
+   struct mutex mutex; /* mutex lock for pmu */
+   struct genpd_onecell_data genpd_data;
+   struct generic_pm_domain *domains[];
+};
+