Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread Viresh Kumar
On 8 February 2013 08:56, amit kachhap  wrote:
> +   dvfs_info->dvfs_init = true;

 why do you need this ?
>>> This is added to synchronize the interrupts.
>>
>> How? You are setting it once in init() and not touching it afterwards. :)
>
> Yes but during init also if interrupts starts arriving before complete
> initialization so to protect that case it is there. I suppose there
> are other ways. Will check them

Then clear any pending interrupts from init ()
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread amit kachhap
On Thu, Feb 7, 2013 at 6:42 PM, Viresh Kumar  wrote:
> On 8 February 2013 00:38, amit kachhap  wrote:
>> Hi Viresh,
>>
>> Thanks for the detailed review. Will try to handle them in the next version,
>
> np. I haven't seen reply to few questions, you missed them or accept them.

Many of your comments were apt so I agreed to most of them :)

>
> General tip: Leave a blank line before and after your comment, it makes it 
> more
> readable. :)
>
>> On Thu, Feb 7, 2013 at 3:17 AM, Viresh Kumar  wrote:
>>> On Thu, Feb 7, 2013 at 1:09 AM, Amit Daniel Kachhap
 +Required properties:
 +- interrupts: Interrupt to know the completion of cpu frequency change.
 +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
 into,
>>>
>>> This has to be "operating-points" as in cpufreq-cpu0 driver.
>> Yes I will check if opp table is beneficial. In my case it is just one
>> time parsing of cpufreq table and those values(freq, volt) are not
>> used later so did not use opp libraries.
>
> Its one time parsing for everybody, nobody do it twice :)

By every time I mean like using the opp table and getting voltage from
there and then doing set_voltage. For me if I use opp table it is just
once during initializations so i didn't use it.

>
 +   for (old_index = 0;
 +   freq_table[old_index].frequency != CPUFREQ_TABLE_END;
 +   old_index++)
 +   if (freq_table[old_index].frequency == freqs.old)
 +   break;
 +
 +   if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
>>>
>>> How can this be true?
>> This is error scenario
>
> We have given cpufreq core a valid table and it has to set frequency from
> this table only. How can cpu have any other freq here ? And you have done
> something similar in your init() too, where you check if cpu has freq from the
> table or not.

Yes agreed this is repetition.

>
 +   dvfs_info = kzalloc(sizeof(struct exynos_dvfs_data), GFP_KERNEL);
>>>
>>> sizeof(*dvfs_info) ?? why don't make it static too, as you have other
>>> stuff too.. ?
>>> The better option for single image solution to allocate everything
>>> dynamically, so that
>>> unused drivers don't occupy any space.
>
> ?
>
 +   if ((len == 0) || (len / 2 > CPUFREQ_LEVEL_END)) {
>>>
>>> I really didn't like this limit you have put at the number of dvfs
>>> points. Better
>>> would be to use:
>
 +   dvfs_info->dvfs_init = true;
>>>
>>> why do you need this ?
>> This is added to synchronize the interrupts.
>
> How? You are setting it once in init() and not touching it afterwards. :)

Yes but during init also if interrupts starts arriving before complete
initialization so to protect that case it is there. I suppose there
are other ways. Will check them

Thanks,
Amit Daniel
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread Viresh Kumar
On 8 February 2013 00:38, amit kachhap  wrote:
> Hi Viresh,
>
> Thanks for the detailed review. Will try to handle them in the next version,

np. I haven't seen reply to few questions, you missed them or accept them.

General tip: Leave a blank line before and after your comment, it makes it more
readable. :)

> On Thu, Feb 7, 2013 at 3:17 AM, Viresh Kumar  wrote:
>> On Thu, Feb 7, 2013 at 1:09 AM, Amit Daniel Kachhap
>>> +Required properties:
>>> +- interrupts: Interrupt to know the completion of cpu frequency change.
>>> +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
>>> into,
>>
>> This has to be "operating-points" as in cpufreq-cpu0 driver.
> Yes I will check if opp table is beneficial. In my case it is just one
> time parsing of cpufreq table and those values(freq, volt) are not
> used later so did not use opp libraries.

Its one time parsing for everybody, nobody do it twice :)

>>> +   for (old_index = 0;
>>> +   freq_table[old_index].frequency != CPUFREQ_TABLE_END;
>>> +   old_index++)
>>> +   if (freq_table[old_index].frequency == freqs.old)
>>> +   break;
>>> +
>>> +   if (freq_table[old_index].frequency == CPUFREQ_TABLE_END) {
>>
>> How can this be true?
> This is error scenario

We have given cpufreq core a valid table and it has to set frequency from
this table only. How can cpu have any other freq here ? And you have done
something similar in your init() too, where you check if cpu has freq from the
table or not.

>>> +   dvfs_info = kzalloc(sizeof(struct exynos_dvfs_data), GFP_KERNEL);
>>
>> sizeof(*dvfs_info) ?? why don't make it static too, as you have other
>> stuff too.. ?
>> The better option for single image solution to allocate everything
>> dynamically, so that
>> unused drivers don't occupy any space.

?

>>> +   if ((len == 0) || (len / 2 > CPUFREQ_LEVEL_END)) {
>>
>> I really didn't like this limit you have put at the number of dvfs
>> points. Better
>> would be to use:

>>> +   dvfs_info->dvfs_init = true;
>>
>> why do you need this ?
> This is added to synchronize the interrupts.

How? You are setting it once in init() and not touching it afterwards. :)
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread amit kachhap
Hi Viresh,

Thanks for the detailed review. Will try to handle them in the next version,

On Thu, Feb 7, 2013 at 3:17 AM, Viresh Kumar  wrote:
> On Thu, Feb 7, 2013 at 1:09 AM, Amit Daniel Kachhap
>  wrote:
>> This patch adds dvfs support for exynos5440 SOC. The nature of exynos5440
>> clock controller is different from previous exynos controllers so not using
>> the common exynos cpufreq framework. Also, the device tree parsing is added
>> to get different parameters like frequency, voltage etc.
>
> Some information about platform cpu configuration would be helpful.. cpus, 
> type,
> clock lines for cpus - shared/separate?
Ok.
>
>> Signed-off-by: Amit Daniel Kachhap 
>> ---
>>  .../bindings/cpufreq/cpufreq-exynos5440.txt|   24 ++
>>  drivers/cpufreq/Kconfig.arm|8 +
>>  drivers/cpufreq/Makefile   |1 +
>>  drivers/cpufreq/exynos5440-cpufreq.c   |  448 
>> 
>>  4 files changed, 481 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>>  create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt 
>> b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>> new file mode 100644
>> index 000..96cb0ed
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>> @@ -0,0 +1,24 @@
>> +
>> +Exynos5440 cpufreq driver
>> +---
>> +
>> +Exynos5440 SoC cpufreq driver for CPU frequency scaling.
>> +
>> +Required properties:
>> +- interrupts: Interrupt to know the completion of cpu frequency change.
>> +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
>> into,
>
> This has to be "operating-points" as in cpufreq-cpu0 driver.
Yes I will check if opp table is beneficial. In my case it is just one
time parsing of cpufreq table and those values(freq, volt) are not
used later so did not use opp libraries.
>
>> +   in the decreasing order. Frequency should be in KHZ units and voltage
>> +   should be in microvolts.
>> +
>> +All the required listed above must be defined under node cpufreq.
>> +
>> +Example:
>> +
>> +   cpufreq@16 {
>> +   compatible = "samsung,exynos5440-cpufreq";
>> +   reg = <0x16 0x1000>;
>> +   interrupts = <0 57 0>;
>> +   cpufreq_tbl = < 120 1025000
>> +   100 975000
>> +   80  925000 >;
>> +   };
>
>> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c 
>> b/drivers/cpufreq/exynos5440-cpufreq.c
>> new file mode 100644
>> index 000..41d39e2
>> --- /dev/null
>> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
>> @@ -0,0 +1,448 @@
>> +/*
>> + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
>> + * http://www.samsung.com
>> + *
>> + * Amit Daniel Kachhap 
>> + *
>> + * EXYNOS5440 - CPU frequency scaling support
>> + *
>> + * 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 
>> +
>> +/*Register definations*/
>> +#define XMU_DVFS_CTRL  0x0060
>> +#define XMU_PMU_P0_7   0x0064
>> +#define XMU_C0_3_PSTATE0x0090
>> +#define XMU_P_LIMIT0x00A0
>> +#define XMU_P_STATUS   0x00A4
>> +#define XMU_PMUEVTEN   0x00D0
>> +#define XMU_PMUIRQEN   0x00D4
>> +#define XMU_PMUIRQ 0x00D8
>> +
>> +/*PMU mask and shift definations*/
>> +#define P_VALUE_MASK   0x7
>> +
>> +#define XMU_DVFS_CTRL_EN_SHIFT 0
>> +
>> +#define P0_7_CPUCLKDEV_SHIFT   21
>> +#define P0_7_CPUCLKDEV_MASK0x7
>> +#define P0_7_ATBCLKDEV_SHIFT   18
>> +#define P0_7_ATBCLKDEV_MASK0x7
>> +#define P0_7_CSCLKDEV_SHIFT15
>> +#define P0_7_CSCLKDEV_MASK 0x7
>> +#define P0_7_CPUEMA_SHIFT  28
>> +#define P0_7_CPUEMA_MASK   0xf
>> +#define P0_7_L2EMA_SHIFT   24
>> +#define P0_7_L2EMA_MASK0xf
>> +#define P0_7_VDD_SHIFT 8
>> +#define P0_7_VDD_MASK  0x7f
>> +#define P0_7_FREQ_SHIFT0
>> +#define P0_7_FREQ_MASK 0xff
>> +
>> +#define C0_3_PSTATE_VALID_SHIFT8
>> +#define C0_3_PSTATE_CURR_SHIFT 4
>> +#define C0_3_PSTATE_NEW_SHIFT  0
>> +
>> +#define PSTATE_CHANGED_EVTEN_SHIFT 0
>> +
>> +#define PSTATE_CHANGED_IRQEN_SHIFT 0
>> +
>> +#define PSTATE_CHANGED_SHIFT   0
>> +
>> +/*some constant values for clock divider calculation*/
>> +#define CPU_DIV_FREQ_MAX   500
>> +#define CPU_DBG_FREQ_MAX   375
>> +#define CPU_ATB_FREQ_MAX   500
>> +
>> +#define PMIC_LOW_VOLT  0x30
>> +#define PMIC_HIGH_VOLT 0x28
>> +
>> +#define CPUEMA_HIGH0x2
>>

Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread amit kachhap
Hi Inder,

Thanks for the review,
On Wed, Feb 6, 2013 at 9:09 PM, Inderpal Singh
 wrote:
> On 7 February 2013 01:09, Amit Daniel Kachhap  wrote:
>> This patch adds dvfs support for exynos5440 SOC. The nature of exynos5440
>> clock controller is different from previous exynos controllers so not using
>> the common exynos cpufreq framework. Also, the device tree parsing is added
>> to get different parameters like frequency, voltage etc.
>>
>> Signed-off-by: Amit Daniel Kachhap 
>> ---
>>  .../bindings/cpufreq/cpufreq-exynos5440.txt|   24 ++
>>  drivers/cpufreq/Kconfig.arm|8 +
>>  drivers/cpufreq/Makefile   |1 +
>>  drivers/cpufreq/exynos5440-cpufreq.c   |  448 
>> 
>>  4 files changed, 481 insertions(+)
>>  create mode 100644 
>> Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>>  create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
>>
>> diff --git 
>> a/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt 
>> b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>> new file mode 100644
>> index 000..96cb0ed
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>> @@ -0,0 +1,24 @@
>> +
>> +Exynos5440 cpufreq driver
>> +---
>> +
>> +Exynos5440 SoC cpufreq driver for CPU frequency scaling.
>> +
>> +Required properties:
>> +- interrupts: Interrupt to know the completion of cpu frequency change.
>> +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
>> into,
>> +   in the decreasing order. Frequency should be in KHZ units and voltage
>> +   should be in microvolts.
>> +
>> +All the required listed above must be defined under node cpufreq.
>> +
>> +Example:
>> +
>> +   cpufreq@16 {
>> +   compatible = "samsung,exynos5440-cpufreq";
>> +   reg = <0x16 0x1000>;
>> +   interrupts = <0 57 0>;
>> +   cpufreq_tbl = < 120 1025000
>> +   100 975000
>> +   80  925000 >;
>> +   };
>> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
>> index a0b3661..554756f 100644
>> --- a/drivers/cpufreq/Kconfig.arm
>> +++ b/drivers/cpufreq/Kconfig.arm
>> @@ -77,6 +77,14 @@ config ARM_EXYNOS5250_CPUFREQ
>>   This adds the CPUFreq driver for Samsung EXYNOS5250
>>   SoC.
>>
>> +config ARM_EXYNOS5440_CPUFREQ
>> +   def_bool SOC_EXYNOS5440
>> +   help
>> + This adds the CPUFreq driver for Samsung EXYNOS5440
>> + SoC. The nature of exynos5440 clock controller is
>> + different than previous exynos controllers so not using
>> + the common exynos framework.
>> +
>>  config ARM_SPEAR_CPUFREQ
>> bool "SPEAr CPUFreq support"
>> depends on PLAT_SPEAR
>> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
>> index fadc4d4..5159ba4 100644
>> --- a/drivers/cpufreq/Makefile
>> +++ b/drivers/cpufreq/Makefile
>> @@ -50,6 +50,7 @@ obj-$(CONFIG_ARM_EXYNOS_CPUFREQ)  += exynos-cpufreq.o
>>  obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ)   += exynos4210-cpufreq.o
>>  obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)   += exynos4x12-cpufreq.o
>>  obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)   += exynos5250-cpufreq.o
>> +obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)   += exynos5440-cpufreq.o
>>  obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
>>  obj-$(CONFIG_ARM_SPEAR_CPUFREQ)+= spear-cpufreq.o
>>
>> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c 
>> b/drivers/cpufreq/exynos5440-cpufreq.c
>> new file mode 100644
>> index 000..41d39e2
>> --- /dev/null
>> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
>> @@ -0,0 +1,448 @@
>> +/*
>> + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
>> + * http://www.samsung.com
>> + *
>> + * Amit Daniel Kachhap 
>> + *
>> + * EXYNOS5440 - CPU frequency scaling support
>> + *
>> + * 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 
>> +
>> +/*Register definations*/
>> +#define XMU_DVFS_CTRL  0x0060
>> +#define XMU_PMU_P0_7   0x0064
>> +#define XMU_C0_3_PSTATE0x0090
>> +#define XMU_P_LIMIT0x00A0
>> +#define XMU_P_STATUS   0x00A4
>> +#define XMU_PMUEVTEN   0x00D0
>> +#define XMU_PMUIRQEN   0x00D4
>> +#define XMU_PMUIRQ 0x00D8
>> +
>> +/*PMU mask and shift definations*/
>> +#define P_VALUE_MASK   0x7
>> +
>> +#define XMU_DVFS_CTRL_EN_SHIFT 0
>> +
>> +#define P0_7_CPUCLKDEV_SHIFT   21
>> +#define P0_7_CPUCLKDEV_MASK0x7
>> +#define P0_7_ATBCLKDEV_SHIFT   18
>> +#define P0_7_ATBCLKDEV_MASK0x7
>> +#define P0_7_CSCL

Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread Inderpal Singh
On 7 February 2013 16:49, Viresh Kumar  wrote:
> On Thu, Feb 7, 2013 at 10:39 AM, Inderpal Singh
>  wrote:
>>> +#define DRIVER_NAME"exynos5440_dvfs"
>
>>> +static struct cpufreq_driver exynos_driver = {
>>> +   .name   = DRIVER_NAME,
>>> +};
>>> +
>>
>> Since this driver is only for exynos5440, having the same names as
>> common exynos-cpufreq is misleading.
>
> Where is it same?

I meant hooks names (verify/get/target and init)

Thanks,
Inder
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread Viresh Kumar
On Thu, Feb 7, 2013 at 10:39 AM, Inderpal Singh
 wrote:
>> +#define DRIVER_NAME"exynos5440_dvfs"

>> +static struct cpufreq_driver exynos_driver = {
>> +   .name   = DRIVER_NAME,
>> +};
>> +
>
> Since this driver is only for exynos5440, having the same names as
> common exynos-cpufreq is misleading.

Where is it same?
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-07 Thread Viresh Kumar
On Thu, Feb 7, 2013 at 1:09 AM, Amit Daniel Kachhap
 wrote:
> This patch adds dvfs support for exynos5440 SOC. The nature of exynos5440
> clock controller is different from previous exynos controllers so not using
> the common exynos cpufreq framework. Also, the device tree parsing is added
> to get different parameters like frequency, voltage etc.

Some information about platform cpu configuration would be helpful.. cpus, type,
clock lines for cpus - shared/separate?

> Signed-off-by: Amit Daniel Kachhap 
> ---
>  .../bindings/cpufreq/cpufreq-exynos5440.txt|   24 ++
>  drivers/cpufreq/Kconfig.arm|8 +
>  drivers/cpufreq/Makefile   |1 +
>  drivers/cpufreq/exynos5440-cpufreq.c   |  448 
> 
>  4 files changed, 481 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>  create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
>
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt 
> b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
> new file mode 100644
> index 000..96cb0ed
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
> @@ -0,0 +1,24 @@
> +
> +Exynos5440 cpufreq driver
> +---
> +
> +Exynos5440 SoC cpufreq driver for CPU frequency scaling.
> +
> +Required properties:
> +- interrupts: Interrupt to know the completion of cpu frequency change.
> +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
> into,

This has to be "operating-points" as in cpufreq-cpu0 driver.

> +   in the decreasing order. Frequency should be in KHZ units and voltage
> +   should be in microvolts.
> +
> +All the required listed above must be defined under node cpufreq.
> +
> +Example:
> +
> +   cpufreq@16 {
> +   compatible = "samsung,exynos5440-cpufreq";
> +   reg = <0x16 0x1000>;
> +   interrupts = <0 57 0>;
> +   cpufreq_tbl = < 120 1025000
> +   100 975000
> +   80  925000 >;
> +   };

> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c 
> b/drivers/cpufreq/exynos5440-cpufreq.c
> new file mode 100644
> index 000..41d39e2
> --- /dev/null
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -0,0 +1,448 @@
> +/*
> + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
> + * http://www.samsung.com
> + *
> + * Amit Daniel Kachhap 
> + *
> + * EXYNOS5440 - CPU frequency scaling support
> + *
> + * 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 
> +
> +/*Register definations*/
> +#define XMU_DVFS_CTRL  0x0060
> +#define XMU_PMU_P0_7   0x0064
> +#define XMU_C0_3_PSTATE0x0090
> +#define XMU_P_LIMIT0x00A0
> +#define XMU_P_STATUS   0x00A4
> +#define XMU_PMUEVTEN   0x00D0
> +#define XMU_PMUIRQEN   0x00D4
> +#define XMU_PMUIRQ 0x00D8
> +
> +/*PMU mask and shift definations*/
> +#define P_VALUE_MASK   0x7
> +
> +#define XMU_DVFS_CTRL_EN_SHIFT 0
> +
> +#define P0_7_CPUCLKDEV_SHIFT   21
> +#define P0_7_CPUCLKDEV_MASK0x7
> +#define P0_7_ATBCLKDEV_SHIFT   18
> +#define P0_7_ATBCLKDEV_MASK0x7
> +#define P0_7_CSCLKDEV_SHIFT15
> +#define P0_7_CSCLKDEV_MASK 0x7
> +#define P0_7_CPUEMA_SHIFT  28
> +#define P0_7_CPUEMA_MASK   0xf
> +#define P0_7_L2EMA_SHIFT   24
> +#define P0_7_L2EMA_MASK0xf
> +#define P0_7_VDD_SHIFT 8
> +#define P0_7_VDD_MASK  0x7f
> +#define P0_7_FREQ_SHIFT0
> +#define P0_7_FREQ_MASK 0xff
> +
> +#define C0_3_PSTATE_VALID_SHIFT8
> +#define C0_3_PSTATE_CURR_SHIFT 4
> +#define C0_3_PSTATE_NEW_SHIFT  0
> +
> +#define PSTATE_CHANGED_EVTEN_SHIFT 0
> +
> +#define PSTATE_CHANGED_IRQEN_SHIFT 0
> +
> +#define PSTATE_CHANGED_SHIFT   0
> +
> +/*some constant values for clock divider calculation*/
> +#define CPU_DIV_FREQ_MAX   500
> +#define CPU_DBG_FREQ_MAX   375
> +#define CPU_ATB_FREQ_MAX   500
> +
> +#define PMIC_LOW_VOLT  0x30
> +#define PMIC_HIGH_VOLT 0x28
> +
> +#define CPUEMA_HIGH0x2
> +#define CPUEMA_MID 0x4
> +#define CPUEMA_LOW 0x7
> +
> +#define L2EMA_HIGH 0x1
> +#define L2EMA_MID  0x3
> +#define L2EMA_LOW  0x4
> +
> +#define DIV_TAB_MAX2
> +/*frequency unit is 20MHZ*/
> +#define FREQ_UNIT  20
> +#define MAX_VOLTAGE155 /*In micro volt*/
> +#define VOLTAGE_STEP   12500   /*In micro volt*/
> +
> +#define DRIVER_NAME"exynos5440_dvfs"
> +#define DEF_TRANS_LATENCY  

Re: [PATCH 2/3] cpufreq: exynos: Adding cpufreq driver for exynos5440

2013-02-06 Thread Inderpal Singh
On 7 February 2013 01:09, Amit Daniel Kachhap  wrote:
> This patch adds dvfs support for exynos5440 SOC. The nature of exynos5440
> clock controller is different from previous exynos controllers so not using
> the common exynos cpufreq framework. Also, the device tree parsing is added
> to get different parameters like frequency, voltage etc.
>
> Signed-off-by: Amit Daniel Kachhap 
> ---
>  .../bindings/cpufreq/cpufreq-exynos5440.txt|   24 ++
>  drivers/cpufreq/Kconfig.arm|8 +
>  drivers/cpufreq/Makefile   |1 +
>  drivers/cpufreq/exynos5440-cpufreq.c   |  448 
> 
>  4 files changed, 481 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
>  create mode 100644 drivers/cpufreq/exynos5440-cpufreq.c
>
> diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt 
> b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
> new file mode 100644
> index 000..96cb0ed
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-exynos5440.txt
> @@ -0,0 +1,24 @@
> +
> +Exynos5440 cpufreq driver
> +---
> +
> +Exynos5440 SoC cpufreq driver for CPU frequency scaling.
> +
> +Required properties:
> +- interrupts: Interrupt to know the completion of cpu frequency change.
> +- cpufreq_tbl: Table of frequencies and voltage CPU could be transitioned 
> into,
> +   in the decreasing order. Frequency should be in KHZ units and voltage
> +   should be in microvolts.
> +
> +All the required listed above must be defined under node cpufreq.
> +
> +Example:
> +
> +   cpufreq@16 {
> +   compatible = "samsung,exynos5440-cpufreq";
> +   reg = <0x16 0x1000>;
> +   interrupts = <0 57 0>;
> +   cpufreq_tbl = < 120 1025000
> +   100 975000
> +   80  925000 >;
> +   };
> diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm
> index a0b3661..554756f 100644
> --- a/drivers/cpufreq/Kconfig.arm
> +++ b/drivers/cpufreq/Kconfig.arm
> @@ -77,6 +77,14 @@ config ARM_EXYNOS5250_CPUFREQ
>   This adds the CPUFreq driver for Samsung EXYNOS5250
>   SoC.
>
> +config ARM_EXYNOS5440_CPUFREQ
> +   def_bool SOC_EXYNOS5440
> +   help
> + This adds the CPUFreq driver for Samsung EXYNOS5440
> + SoC. The nature of exynos5440 clock controller is
> + different than previous exynos controllers so not using
> + the common exynos framework.
> +
>  config ARM_SPEAR_CPUFREQ
> bool "SPEAr CPUFreq support"
> depends on PLAT_SPEAR
> diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
> index fadc4d4..5159ba4 100644
> --- a/drivers/cpufreq/Makefile
> +++ b/drivers/cpufreq/Makefile
> @@ -50,6 +50,7 @@ obj-$(CONFIG_ARM_EXYNOS_CPUFREQ)  += exynos-cpufreq.o
>  obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ)   += exynos4210-cpufreq.o
>  obj-$(CONFIG_ARM_EXYNOS4X12_CPUFREQ)   += exynos4x12-cpufreq.o
>  obj-$(CONFIG_ARM_EXYNOS5250_CPUFREQ)   += exynos5250-cpufreq.o
> +obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)   += exynos5440-cpufreq.o
>  obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ) += omap-cpufreq.o
>  obj-$(CONFIG_ARM_SPEAR_CPUFREQ)+= spear-cpufreq.o
>
> diff --git a/drivers/cpufreq/exynos5440-cpufreq.c 
> b/drivers/cpufreq/exynos5440-cpufreq.c
> new file mode 100644
> index 000..41d39e2
> --- /dev/null
> +++ b/drivers/cpufreq/exynos5440-cpufreq.c
> @@ -0,0 +1,448 @@
> +/*
> + * Copyright (c) 2013 Samsung Electronics Co., Ltd.
> + * http://www.samsung.com
> + *
> + * Amit Daniel Kachhap 
> + *
> + * EXYNOS5440 - CPU frequency scaling support
> + *
> + * 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 
> +
> +/*Register definations*/
> +#define XMU_DVFS_CTRL  0x0060
> +#define XMU_PMU_P0_7   0x0064
> +#define XMU_C0_3_PSTATE0x0090
> +#define XMU_P_LIMIT0x00A0
> +#define XMU_P_STATUS   0x00A4
> +#define XMU_PMUEVTEN   0x00D0
> +#define XMU_PMUIRQEN   0x00D4
> +#define XMU_PMUIRQ 0x00D8
> +
> +/*PMU mask and shift definations*/
> +#define P_VALUE_MASK   0x7
> +
> +#define XMU_DVFS_CTRL_EN_SHIFT 0
> +
> +#define P0_7_CPUCLKDEV_SHIFT   21
> +#define P0_7_CPUCLKDEV_MASK0x7
> +#define P0_7_ATBCLKDEV_SHIFT   18
> +#define P0_7_ATBCLKDEV_MASK0x7
> +#define P0_7_CSCLKDEV_SHIFT15
> +#define P0_7_CSCLKDEV_MASK 0x7
> +#define P0_7_CPUEMA_SHIFT  28
> +#define P0_7_CPUEMA_MASK   0xf
> +#define P0_7_L2EMA_SHIFT   24
> +#define P0_7_L2EMA_MASK0xf
> +#define P0_7_VDD