Re: [RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-10 Thread Pankaj Dubey

Hi Bartlomiej,

Thanks for review.

On 04/03/2014 08:56 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

On Wednesday, April 02, 2014 05:24:44 PM Pankaj Dubey wrote:

From: Younggun Jang 

This driver is mainly used for setting misc bits of register from PMU IP
of Exynos SoC which will be required to configure before Suspend/Resume.
Currently all these settings are done in "arch/arm/mach-exynos/pmu.c" but
moving ahead for ARM64 based SoC support, there is a need of DT based
implementation of PMU driver.

PMU support for ARM32 EXYNOS SoCs is heavily SoC dependent and there
is very little code shared between diffirent SoCs.  Unless PMU setup
for Samsung ARM64 SoCs is similar to some existing ARM32 EXYNOS SoCs
it may be better to just add a separate PMU driver for Samsung ARM64
SoCs. IOW it would be best to show that this patch series is really
useful before merging it.


We think it will be useful, but I will consider your point of making driver
which should have common piece of code to address various EXYNOS SoCs.
We are working on it, once it takes some proper shape I will post details here.



When it comes to the current patches it would be better to do changes
converting PMU support to be a platform driver first for the existing
arch/arm/mach-exynos/pmu.c file and then move+rename this file in
the separate patch.  Currently the code changes are done at the same
time as the code movement which makes them difficult to review/verify.


OK, will do as you suggested in next version.


There are also some minor issues with the new code:

[...]


diff --git a/drivers/mfd/exynos-pmu.c b/drivers/mfd/exynos-pmu.c
new file mode 100644
index 000..24abd9b
--- /dev/null
+++ b/drivers/mfd/exynos-pmu.c
@@ -0,0 +1,534 @@
+/*
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/

2015?


Will fix this.


[...]


+static int __init exynos4210_pmu_init(void)
+{
+   exynos_pmu_config = exynos4210_pmu_config;
+   pmu_data->pmu_id = PMU_EXYNOS4210;
+   pr_info("EXYNOS4210 PMU Initialize\n");
+
+   return 0;
+}
+
+static int __init exynos4212_pmu_init(void)
+{
+   exynos_pmu_config = exynos4x12_pmu_config;
+   pmu_data->pmu_id = PMU_EXYNOS4212;
+   pr_info("EXYNOS4x12 PMU Initialize\n");
+
+   return 0;
+}
+
+static int __init exynos4412_pmu_init(void)
+{
+   exynos_pmu_config = exynos4x12_pmu_config;
+   pmu_data->pmu_id = PMU_EXYNOS4412;
+   pr_info("EXYNOS4412 PMU Initialize\n");
+
+   return 0;
+}
+
+static int __init exynos5250_pmu_init(void)
+{
+   unsigned int value;
+
+   /*
+* When SYS_WDTRESET is set, watchdog timer reset request
+* is ignored by power management unit.
+*/
+   value = __raw_readl(pmu_data->regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
+   value &= ~EXYNOS5_SYS_WDTRESET;
+   __raw_writel(value, pmu_data->regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
+
+   value = __raw_readl(pmu_data->regs + EXYNOS5_MASK_WDTRESET_REQUEST);
+   value &= ~EXYNOS5_SYS_WDTRESET;
+   __raw_writel(value, pmu_data->regs + EXYNOS5_MASK_WDTRESET_REQUEST);
+
+   exynos_pmu_config = exynos5250_pmu_config;
+   pmu_data->pmu_id = PMU_EXYNOS5250;
+   pr_info("EXYNOS5250 PMU Initialize\n");
+
+   return 0;
+}
+
+/*
+ * PMU platform driver and devicetree bindings.
+ */
+static struct of_device_id exynos_pmu_of_device_ids[] = {
+   {
+   .compatible = "samsung,exynos4210-pmu",
+   .data = (void *)exynos4210_pmu_init
+   },
+   {
+   .compatible = "samsung,exynos4212-pmu",
+   .data = (void *)exynos4212_pmu_init
+   },
+   {
+   .compatible = "samsung,exynos4412-pmu",
+   .data = (void *)exynos4412_pmu_init
+   },
+   {
+   .compatible = "samsung,exynos5250-pmu",
+   .data = (void *)exynos5250_pmu_init
+   },
+   {},
+};
+
+static int exynos_pmu_probe(struct platform_device *pdev)
+{
+   const struct of_device_id *match;
+   exynos_pmu_init_t exynos_pmu_init;
+   struct resource *res;
+
+   pmu_data = devm_kzalloc(>dev,
+   sizeof(struct exynos_pmu_data), GFP_KERNEL);
+   if (!pmu_data) {
+   dev_err(>dev, "exynos_pmu driver probe failed\n");
+   return -ENOMEM;
+   }
+
+   pmu_data->dev = >dev;
+
+   match = of_match_node(exynos_pmu_of_device_ids, pdev->dev.of_node);
+   exynos_pmu_init = match->data;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   pmu_data->regs = devm_ioremap_resource(>dev, res);

devm_ioremap_resouce() return value should be checked for errors with

if (IS_ERR(pmu_data->regs))
return PTR_ERR(pmu_data->regs);

Will take care.

+
+   exynos_pmu_init();

exynos*_pmu_init() methods should be void as they always return 0 and
the return value is ignored anyway.

Also they cannot be marked with __init as the driver probe function

Re: [RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-10 Thread Pankaj Dubey

Hi Bartlomiej,

Thanks for review.

On 04/03/2014 08:56 PM, Bartlomiej Zolnierkiewicz wrote:

Hi,

On Wednesday, April 02, 2014 05:24:44 PM Pankaj Dubey wrote:

From: Younggun Jang yg1004.j...@samsung.com

This driver is mainly used for setting misc bits of register from PMU IP
of Exynos SoC which will be required to configure before Suspend/Resume.
Currently all these settings are done in arch/arm/mach-exynos/pmu.c but
moving ahead for ARM64 based SoC support, there is a need of DT based
implementation of PMU driver.

PMU support for ARM32 EXYNOS SoCs is heavily SoC dependent and there
is very little code shared between diffirent SoCs.  Unless PMU setup
for Samsung ARM64 SoCs is similar to some existing ARM32 EXYNOS SoCs
it may be better to just add a separate PMU driver for Samsung ARM64
SoCs. IOW it would be best to show that this patch series is really
useful before merging it.


We think it will be useful, but I will consider your point of making driver
which should have common piece of code to address various EXYNOS SoCs.
We are working on it, once it takes some proper shape I will post details here.



When it comes to the current patches it would be better to do changes
converting PMU support to be a platform driver first for the existing
arch/arm/mach-exynos/pmu.c file and then move+rename this file in
the separate patch.  Currently the code changes are done at the same
time as the code movement which makes them difficult to review/verify.


OK, will do as you suggested in next version.


There are also some minor issues with the new code:

[...]


diff --git a/drivers/mfd/exynos-pmu.c b/drivers/mfd/exynos-pmu.c
new file mode 100644
index 000..24abd9b
--- /dev/null
+++ b/drivers/mfd/exynos-pmu.c
@@ -0,0 +1,534 @@
+/*
+ * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
+ * http://www.samsung.com/

2015?


Will fix this.


[...]


+static int __init exynos4210_pmu_init(void)
+{
+   exynos_pmu_config = exynos4210_pmu_config;
+   pmu_data-pmu_id = PMU_EXYNOS4210;
+   pr_info(EXYNOS4210 PMU Initialize\n);
+
+   return 0;
+}
+
+static int __init exynos4212_pmu_init(void)
+{
+   exynos_pmu_config = exynos4x12_pmu_config;
+   pmu_data-pmu_id = PMU_EXYNOS4212;
+   pr_info(EXYNOS4x12 PMU Initialize\n);
+
+   return 0;
+}
+
+static int __init exynos4412_pmu_init(void)
+{
+   exynos_pmu_config = exynos4x12_pmu_config;
+   pmu_data-pmu_id = PMU_EXYNOS4412;
+   pr_info(EXYNOS4412 PMU Initialize\n);
+
+   return 0;
+}
+
+static int __init exynos5250_pmu_init(void)
+{
+   unsigned int value;
+
+   /*
+* When SYS_WDTRESET is set, watchdog timer reset request
+* is ignored by power management unit.
+*/
+   value = __raw_readl(pmu_data-regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
+   value = ~EXYNOS5_SYS_WDTRESET;
+   __raw_writel(value, pmu_data-regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
+
+   value = __raw_readl(pmu_data-regs + EXYNOS5_MASK_WDTRESET_REQUEST);
+   value = ~EXYNOS5_SYS_WDTRESET;
+   __raw_writel(value, pmu_data-regs + EXYNOS5_MASK_WDTRESET_REQUEST);
+
+   exynos_pmu_config = exynos5250_pmu_config;
+   pmu_data-pmu_id = PMU_EXYNOS5250;
+   pr_info(EXYNOS5250 PMU Initialize\n);
+
+   return 0;
+}
+
+/*
+ * PMU platform driver and devicetree bindings.
+ */
+static struct of_device_id exynos_pmu_of_device_ids[] = {
+   {
+   .compatible = samsung,exynos4210-pmu,
+   .data = (void *)exynos4210_pmu_init
+   },
+   {
+   .compatible = samsung,exynos4212-pmu,
+   .data = (void *)exynos4212_pmu_init
+   },
+   {
+   .compatible = samsung,exynos4412-pmu,
+   .data = (void *)exynos4412_pmu_init
+   },
+   {
+   .compatible = samsung,exynos5250-pmu,
+   .data = (void *)exynos5250_pmu_init
+   },
+   {},
+};
+
+static int exynos_pmu_probe(struct platform_device *pdev)
+{
+   const struct of_device_id *match;
+   exynos_pmu_init_t exynos_pmu_init;
+   struct resource *res;
+
+   pmu_data = devm_kzalloc(pdev-dev,
+   sizeof(struct exynos_pmu_data), GFP_KERNEL);
+   if (!pmu_data) {
+   dev_err(pdev-dev, exynos_pmu driver probe failed\n);
+   return -ENOMEM;
+   }
+
+   pmu_data-dev = pdev-dev;
+
+   match = of_match_node(exynos_pmu_of_device_ids, pdev-dev.of_node);
+   exynos_pmu_init = match-data;
+
+   res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   pmu_data-regs = devm_ioremap_resource(pdev-dev, res);

devm_ioremap_resouce() return value should be checked for errors with

if (IS_ERR(pmu_data-regs))
return PTR_ERR(pmu_data-regs);

Will take care.

+
+   exynos_pmu_init();

exynos*_pmu_init() methods should be void as they always return 0 and
the return value is ignored anyway.

Also they cannot be marked with __init as the driver probe 

Re: [RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-03 Thread Bartlomiej Zolnierkiewicz

Hi,

On Wednesday, April 02, 2014 05:24:44 PM Pankaj Dubey wrote:
> From: Younggun Jang 
> 
> This driver is mainly used for setting misc bits of register from PMU IP
> of Exynos SoC which will be required to configure before Suspend/Resume.
> Currently all these settings are done in "arch/arm/mach-exynos/pmu.c" but
> moving ahead for ARM64 based SoC support, there is a need of DT based
> implementation of PMU driver.

PMU support for ARM32 EXYNOS SoCs is heavily SoC dependent and there
is very little code shared between diffirent SoCs.  Unless PMU setup
for Samsung ARM64 SoCs is similar to some existing ARM32 EXYNOS SoCs
it may be better to just add a separate PMU driver for Samsung ARM64
SoCs. IOW it would be best to show that this patch series is really
useful before merging it.

When it comes to the current patches it would be better to do changes
converting PMU support to be a platform driver first for the existing
arch/arm/mach-exynos/pmu.c file and then move+rename this file in
the separate patch.  Currently the code changes are done at the same
time as the code movement which makes them difficult to review/verify.

There are also some minor issues with the new code:

[...]

> diff --git a/drivers/mfd/exynos-pmu.c b/drivers/mfd/exynos-pmu.c
> new file mode 100644
> index 000..24abd9b
> --- /dev/null
> +++ b/drivers/mfd/exynos-pmu.c
> @@ -0,0 +1,534 @@
> +/*
> + * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
> + *   http://www.samsung.com/

2015?

[...]

> +static int __init exynos4210_pmu_init(void)
> +{
> + exynos_pmu_config = exynos4210_pmu_config;
> + pmu_data->pmu_id = PMU_EXYNOS4210;
> + pr_info("EXYNOS4210 PMU Initialize\n");
> +
> + return 0;
> +}
> +
> +static int __init exynos4212_pmu_init(void)
> +{
> + exynos_pmu_config = exynos4x12_pmu_config;
> + pmu_data->pmu_id = PMU_EXYNOS4212;
> + pr_info("EXYNOS4x12 PMU Initialize\n");
> +
> + return 0;
> +}
> +
> +static int __init exynos4412_pmu_init(void)
> +{
> + exynos_pmu_config = exynos4x12_pmu_config;
> + pmu_data->pmu_id = PMU_EXYNOS4412;
> + pr_info("EXYNOS4412 PMU Initialize\n");
> +
> + return 0;
> +}
> +
> +static int __init exynos5250_pmu_init(void)
> +{
> + unsigned int value;
> +
> + /*
> +  * When SYS_WDTRESET is set, watchdog timer reset request
> +  * is ignored by power management unit.
> +  */
> + value = __raw_readl(pmu_data->regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
> + value &= ~EXYNOS5_SYS_WDTRESET;
> + __raw_writel(value, pmu_data->regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
> +
> + value = __raw_readl(pmu_data->regs + EXYNOS5_MASK_WDTRESET_REQUEST);
> + value &= ~EXYNOS5_SYS_WDTRESET;
> + __raw_writel(value, pmu_data->regs + EXYNOS5_MASK_WDTRESET_REQUEST);
> +
> + exynos_pmu_config = exynos5250_pmu_config;
> + pmu_data->pmu_id = PMU_EXYNOS5250;
> + pr_info("EXYNOS5250 PMU Initialize\n");
> +
> + return 0;
> +}
> +
> +/*
> + * PMU platform driver and devicetree bindings.
> + */
> +static struct of_device_id exynos_pmu_of_device_ids[] = {
> + {
> + .compatible = "samsung,exynos4210-pmu",
> + .data = (void *)exynos4210_pmu_init
> + },
> + {
> + .compatible = "samsung,exynos4212-pmu",
> + .data = (void *)exynos4212_pmu_init
> + },
> + {
> + .compatible = "samsung,exynos4412-pmu",
> + .data = (void *)exynos4412_pmu_init
> + },
> + {
> + .compatible = "samsung,exynos5250-pmu",
> + .data = (void *)exynos5250_pmu_init
> + },
> + {},
> +};
> +
> +static int exynos_pmu_probe(struct platform_device *pdev)
> +{
> + const struct of_device_id *match;
> + exynos_pmu_init_t exynos_pmu_init;
> + struct resource *res;
> +
> + pmu_data = devm_kzalloc(>dev,
> + sizeof(struct exynos_pmu_data), GFP_KERNEL);
> + if (!pmu_data) {
> + dev_err(>dev, "exynos_pmu driver probe failed\n");
> + return -ENOMEM;
> + }
> +
> + pmu_data->dev = >dev;
> +
> + match = of_match_node(exynos_pmu_of_device_ids, pdev->dev.of_node);
> + exynos_pmu_init = match->data;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + pmu_data->regs = devm_ioremap_resource(>dev, res);

devm_ioremap_resouce() return value should be checked for errors with

if (IS_ERR(pmu_data->regs))
return PTR_ERR(pmu_data->regs);

> +
> + exynos_pmu_init();

exynos*_pmu_init() methods should be void as they always return 0 and
the return value is ignored anyway.

Also they cannot be marked with __init as the driver probe function
itself is not marked with __init (it cannot be beacuse of possibility
of doing unbind/bind through sysfs).

> +
> + return 0;
> +};
> +
> +static int exynos_pmu_remove(struct platform_device *pdev)
> +{
> + exynos_pmu_config = NULL;
> +
> + return 0;
> +}
> +
> +static struct platform_driver 

Re: [RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-03 Thread Bartlomiej Zolnierkiewicz

Hi,

On Wednesday, April 02, 2014 05:24:44 PM Pankaj Dubey wrote:
 From: Younggun Jang yg1004.j...@samsung.com
 
 This driver is mainly used for setting misc bits of register from PMU IP
 of Exynos SoC which will be required to configure before Suspend/Resume.
 Currently all these settings are done in arch/arm/mach-exynos/pmu.c but
 moving ahead for ARM64 based SoC support, there is a need of DT based
 implementation of PMU driver.

PMU support for ARM32 EXYNOS SoCs is heavily SoC dependent and there
is very little code shared between diffirent SoCs.  Unless PMU setup
for Samsung ARM64 SoCs is similar to some existing ARM32 EXYNOS SoCs
it may be better to just add a separate PMU driver for Samsung ARM64
SoCs. IOW it would be best to show that this patch series is really
useful before merging it.

When it comes to the current patches it would be better to do changes
converting PMU support to be a platform driver first for the existing
arch/arm/mach-exynos/pmu.c file and then move+rename this file in
the separate patch.  Currently the code changes are done at the same
time as the code movement which makes them difficult to review/verify.

There are also some minor issues with the new code:

[...]

 diff --git a/drivers/mfd/exynos-pmu.c b/drivers/mfd/exynos-pmu.c
 new file mode 100644
 index 000..24abd9b
 --- /dev/null
 +++ b/drivers/mfd/exynos-pmu.c
 @@ -0,0 +1,534 @@
 +/*
 + * Copyright (c) 2014-2015 Samsung Electronics Co., Ltd.
 + *   http://www.samsung.com/

2015?

[...]

 +static int __init exynos4210_pmu_init(void)
 +{
 + exynos_pmu_config = exynos4210_pmu_config;
 + pmu_data-pmu_id = PMU_EXYNOS4210;
 + pr_info(EXYNOS4210 PMU Initialize\n);
 +
 + return 0;
 +}
 +
 +static int __init exynos4212_pmu_init(void)
 +{
 + exynos_pmu_config = exynos4x12_pmu_config;
 + pmu_data-pmu_id = PMU_EXYNOS4212;
 + pr_info(EXYNOS4x12 PMU Initialize\n);
 +
 + return 0;
 +}
 +
 +static int __init exynos4412_pmu_init(void)
 +{
 + exynos_pmu_config = exynos4x12_pmu_config;
 + pmu_data-pmu_id = PMU_EXYNOS4412;
 + pr_info(EXYNOS4412 PMU Initialize\n);
 +
 + return 0;
 +}
 +
 +static int __init exynos5250_pmu_init(void)
 +{
 + unsigned int value;
 +
 + /*
 +  * When SYS_WDTRESET is set, watchdog timer reset request
 +  * is ignored by power management unit.
 +  */
 + value = __raw_readl(pmu_data-regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
 + value = ~EXYNOS5_SYS_WDTRESET;
 + __raw_writel(value, pmu_data-regs + EXYNOS5_AUTO_WDTRESET_DISABLE);
 +
 + value = __raw_readl(pmu_data-regs + EXYNOS5_MASK_WDTRESET_REQUEST);
 + value = ~EXYNOS5_SYS_WDTRESET;
 + __raw_writel(value, pmu_data-regs + EXYNOS5_MASK_WDTRESET_REQUEST);
 +
 + exynos_pmu_config = exynos5250_pmu_config;
 + pmu_data-pmu_id = PMU_EXYNOS5250;
 + pr_info(EXYNOS5250 PMU Initialize\n);
 +
 + return 0;
 +}
 +
 +/*
 + * PMU platform driver and devicetree bindings.
 + */
 +static struct of_device_id exynos_pmu_of_device_ids[] = {
 + {
 + .compatible = samsung,exynos4210-pmu,
 + .data = (void *)exynos4210_pmu_init
 + },
 + {
 + .compatible = samsung,exynos4212-pmu,
 + .data = (void *)exynos4212_pmu_init
 + },
 + {
 + .compatible = samsung,exynos4412-pmu,
 + .data = (void *)exynos4412_pmu_init
 + },
 + {
 + .compatible = samsung,exynos5250-pmu,
 + .data = (void *)exynos5250_pmu_init
 + },
 + {},
 +};
 +
 +static int exynos_pmu_probe(struct platform_device *pdev)
 +{
 + const struct of_device_id *match;
 + exynos_pmu_init_t exynos_pmu_init;
 + struct resource *res;
 +
 + pmu_data = devm_kzalloc(pdev-dev,
 + sizeof(struct exynos_pmu_data), GFP_KERNEL);
 + if (!pmu_data) {
 + dev_err(pdev-dev, exynos_pmu driver probe failed\n);
 + return -ENOMEM;
 + }
 +
 + pmu_data-dev = pdev-dev;
 +
 + match = of_match_node(exynos_pmu_of_device_ids, pdev-dev.of_node);
 + exynos_pmu_init = match-data;
 +
 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 + pmu_data-regs = devm_ioremap_resource(pdev-dev, res);

devm_ioremap_resouce() return value should be checked for errors with

if (IS_ERR(pmu_data-regs))
return PTR_ERR(pmu_data-regs);

 +
 + exynos_pmu_init();

exynos*_pmu_init() methods should be void as they always return 0 and
the return value is ignored anyway.

Also they cannot be marked with __init as the driver probe function
itself is not marked with __init (it cannot be beacuse of possibility
of doing unbind/bind through sysfs).

 +
 + return 0;
 +};
 +
 +static int exynos_pmu_remove(struct platform_device *pdev)
 +{
 + exynos_pmu_config = NULL;
 +
 + return 0;
 +}
 +
 +static struct platform_driver exynos_pmu_driver = {
 + .driver  = {
 + .name   = exynos-pmu,
 + .of_match_table = 

[RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-02 Thread Pankaj Dubey
From: Younggun Jang 

This driver is mainly used for setting misc bits of register from PMU IP
of Exynos SoC which will be required to configure before Suspend/Resume.
Currently all these settings are done in "arch/arm/mach-exynos/pmu.c" but
moving ahead for ARM64 based SoC support, there is a need of DT based
implementation of PMU driver.
This driver uses already existing DT binding information.

CC: Samuel Ortiz 
CC: Lee Jones 
CC: Sangbeom Kim 
CC: Grant Likely 
CC: Rob Herring 
CC: devicet...@vger.kernel.org
Signed-off-by: Younggun Jang 
Signed-off-by: Pankaj Dubey 
---
 arch/arm/mach-exynos/common.h   |   22 +-
 arch/arm/mach-exynos/regs-pmu.h |  310 
 drivers/mfd/Kconfig |9 +
 drivers/mfd/Makefile|2 +
 drivers/mfd/exynos-pmu.c|  534 +++
 include/linux/mfd/samsung/exynos-pmu.h  |   31 ++
 include/linux/mfd/samsung/exynos-regs-pmu.h |  308 +++
 7 files changed, 888 insertions(+), 328 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/regs-pmu.h
 create mode 100644 drivers/mfd/exynos-pmu.c
 create mode 100644 include/linux/mfd/samsung/exynos-pmu.h
 create mode 100644 include/linux/mfd/samsung/exynos-regs-pmu.h

diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 645f4f8..cbe8159 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -12,9 +12,12 @@
 #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
 #define __ARCH_ARM_MACH_EXYNOS_COMMON_H
 
+#include 
+
 #include 
 #include 
-#include "regs-pmu.h"
+#include 
+#include 
 
 void exynos_init_io(void);
 void exynos_restart(enum reboot_mode mode, const char *cmd);
@@ -42,24 +45,7 @@ extern struct smp_operations exynos_smp_ops;
 
 extern void exynos_cpu_die(unsigned int cpu);
 
-/* PMU(Power Management Unit) support */
-
-#define PMU_TABLE_END  0x
-
-enum sys_powerdown {
-   SYS_AFTR,
-   SYS_LPA,
-   SYS_SLEEP,
-   NUM_SYS_POWERDOWN,
-};
-
 extern unsigned long l2x0_regs_phys;
-struct exynos_pmu_conf {
-   unsigned int offset;
-   unsigned int val[NUM_SYS_POWERDOWN];
-};
-
-extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
 
 extern void __iomem *get_exynos_pmubase(void);
 
diff --git a/arch/arm/mach-exynos/regs-pmu.h b/arch/arm/mach-exynos/regs-pmu.h
deleted file mode 100644
index 7f3bf65..000
--- a/arch/arm/mach-exynos/regs-pmu.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
- * http://www.samsung.com
- *
- * EXYNOS - Power management unit definition
- *
- * 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.
-*/
-
-#ifndef __ASM_ARCH_REGS_PMU_H
-#define __ASM_ARCH_REGS_PMU_H __FILE__
-
-#include 
-
-#define S5P_CENTRAL_SEQ_CONFIGURATION  0x0200
-
-#define S5P_CENTRAL_LOWPWR_CFG (1 << 16)
-
-#define S5P_CENTRAL_SEQ_OPTION 0x0208
-
-#define S5P_USE_STANDBY_WFI0   (1 << 16)
-#define S5P_USE_STANDBY_WFE0   (1 << 24)
-
-#define EXYNOS_SWRESET 0x0400
-#define EXYNOS5440_SWRESET 0x00C4
-
-#define S5P_WAKEUP_STAT0x0600
-#define S5P_EINT_WAKEUP_MASK   0x0604
-#define S5P_WAKEUP_MASK0x0608
-
-#define S5P_INFORM00x0800
-#define S5P_INFORM10x0804
-#define S5P_INFORM50x0814
-#define S5P_INFORM60x0818
-#define S5P_INFORM70x081C
-
-#define S5P_ARM_CORE0_LOWPWR   0x1000
-#define S5P_DIS_IRQ_CORE0  0x1004
-#define S5P_DIS_IRQ_CENTRAL0   0x1008
-#define S5P_ARM_CORE1_LOWPWR   0x1010
-#define S5P_DIS_IRQ_CORE1  0x1014
-#define S5P_DIS_IRQ_CENTRAL1   0x1018
-#define S5P_ARM_COMMON_LOWPWR  0x1080
-#define S5P_L2_0_LOWPWR0x10C0
-#define S5P_L2_1_LOWPWR0x10C4
-#define S5P_CMU_ACLKSTOP_LOWPWR0x1100
-#define S5P_CMU_SCLKSTOP_LOWPWR0x1104
-#define S5P_CMU_RESET_LOWPWR   0x110C
-#define S5P_APLL_SYSCLK_LOWPWR 0x1120
-#define S5P_MPLL_SYSCLK_LOWPWR 0x1124
-#define S5P_VPLL_SYSCLK_LOWPWR 0x1128
-#define S5P_EPLL_SYSCLK_LOWPWR 0x112C
-#define S5P_CMU_CLKSTOP_GPS_ALIVE_LOWPWR   0x1138
-#define S5P_CMU_RESET_GPSALIVE_LOWPWR  0x113C
-#define S5P_CMU_CLKSTOP_CAM_LOWPWR 0x1140
-#define S5P_CMU_CLKSTOP_TV_LOWPWR  0x1144
-#define S5P_CMU_CLKSTOP_MFC_LOWPWR 0x1148
-#define 

[RFC PATCH 1/2] drivers: mfd: Add support of exynos-pmu driver

2014-04-02 Thread Pankaj Dubey
From: Younggun Jang yg1004.j...@samsung.com

This driver is mainly used for setting misc bits of register from PMU IP
of Exynos SoC which will be required to configure before Suspend/Resume.
Currently all these settings are done in arch/arm/mach-exynos/pmu.c but
moving ahead for ARM64 based SoC support, there is a need of DT based
implementation of PMU driver.
This driver uses already existing DT binding information.

CC: Samuel Ortiz sa...@linux.intel.com
CC: Lee Jones lee.jo...@linaro.org
CC: Sangbeom Kim sbki...@samsung.com
CC: Grant Likely grant.lik...@linaro.org
CC: Rob Herring robh...@kernel.org
CC: devicet...@vger.kernel.org
Signed-off-by: Younggun Jang yg1004.j...@samsung.com
Signed-off-by: Pankaj Dubey pankaj.du...@samsung.com
---
 arch/arm/mach-exynos/common.h   |   22 +-
 arch/arm/mach-exynos/regs-pmu.h |  310 
 drivers/mfd/Kconfig |9 +
 drivers/mfd/Makefile|2 +
 drivers/mfd/exynos-pmu.c|  534 +++
 include/linux/mfd/samsung/exynos-pmu.h  |   31 ++
 include/linux/mfd/samsung/exynos-regs-pmu.h |  308 +++
 7 files changed, 888 insertions(+), 328 deletions(-)
 delete mode 100644 arch/arm/mach-exynos/regs-pmu.h
 create mode 100644 drivers/mfd/exynos-pmu.c
 create mode 100644 include/linux/mfd/samsung/exynos-pmu.h
 create mode 100644 include/linux/mfd/samsung/exynos-regs-pmu.h

diff --git a/arch/arm/mach-exynos/common.h b/arch/arm/mach-exynos/common.h
index 645f4f8..cbe8159 100644
--- a/arch/arm/mach-exynos/common.h
+++ b/arch/arm/mach-exynos/common.h
@@ -12,9 +12,12 @@
 #ifndef __ARCH_ARM_MACH_EXYNOS_COMMON_H
 #define __ARCH_ARM_MACH_EXYNOS_COMMON_H
 
+#include mach/map.h
+
 #include linux/reboot.h
 #include linux/of.h
-#include regs-pmu.h
+#include linux/mfd/samsung/exynos-pmu.h
+#include linux/mfd/samsung/exynos-regs-pmu.h
 
 void exynos_init_io(void);
 void exynos_restart(enum reboot_mode mode, const char *cmd);
@@ -42,24 +45,7 @@ extern struct smp_operations exynos_smp_ops;
 
 extern void exynos_cpu_die(unsigned int cpu);
 
-/* PMU(Power Management Unit) support */
-
-#define PMU_TABLE_END  0x
-
-enum sys_powerdown {
-   SYS_AFTR,
-   SYS_LPA,
-   SYS_SLEEP,
-   NUM_SYS_POWERDOWN,
-};
-
 extern unsigned long l2x0_regs_phys;
-struct exynos_pmu_conf {
-   unsigned int offset;
-   unsigned int val[NUM_SYS_POWERDOWN];
-};
-
-extern void exynos_sys_powerdown_conf(enum sys_powerdown mode);
 
 extern void __iomem *get_exynos_pmubase(void);
 
diff --git a/arch/arm/mach-exynos/regs-pmu.h b/arch/arm/mach-exynos/regs-pmu.h
deleted file mode 100644
index 7f3bf65..000
--- a/arch/arm/mach-exynos/regs-pmu.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright (c) 2010-2012 Samsung Electronics Co., Ltd.
- * http://www.samsung.com
- *
- * EXYNOS - Power management unit definition
- *
- * 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.
-*/
-
-#ifndef __ASM_ARCH_REGS_PMU_H
-#define __ASM_ARCH_REGS_PMU_H __FILE__
-
-#include mach/map.h
-
-#define S5P_CENTRAL_SEQ_CONFIGURATION  0x0200
-
-#define S5P_CENTRAL_LOWPWR_CFG (1  16)
-
-#define S5P_CENTRAL_SEQ_OPTION 0x0208
-
-#define S5P_USE_STANDBY_WFI0   (1  16)
-#define S5P_USE_STANDBY_WFE0   (1  24)
-
-#define EXYNOS_SWRESET 0x0400
-#define EXYNOS5440_SWRESET 0x00C4
-
-#define S5P_WAKEUP_STAT0x0600
-#define S5P_EINT_WAKEUP_MASK   0x0604
-#define S5P_WAKEUP_MASK0x0608
-
-#define S5P_INFORM00x0800
-#define S5P_INFORM10x0804
-#define S5P_INFORM50x0814
-#define S5P_INFORM60x0818
-#define S5P_INFORM70x081C
-
-#define S5P_ARM_CORE0_LOWPWR   0x1000
-#define S5P_DIS_IRQ_CORE0  0x1004
-#define S5P_DIS_IRQ_CENTRAL0   0x1008
-#define S5P_ARM_CORE1_LOWPWR   0x1010
-#define S5P_DIS_IRQ_CORE1  0x1014
-#define S5P_DIS_IRQ_CENTRAL1   0x1018
-#define S5P_ARM_COMMON_LOWPWR  0x1080
-#define S5P_L2_0_LOWPWR0x10C0
-#define S5P_L2_1_LOWPWR0x10C4
-#define S5P_CMU_ACLKSTOP_LOWPWR0x1100
-#define S5P_CMU_SCLKSTOP_LOWPWR0x1104
-#define S5P_CMU_RESET_LOWPWR   0x110C
-#define S5P_APLL_SYSCLK_LOWPWR 0x1120
-#define S5P_MPLL_SYSCLK_LOWPWR 0x1124
-#define S5P_VPLL_SYSCLK_LOWPWR 0x1128
-#define S5P_EPLL_SYSCLK_LOWPWR 0x112C
-#define