Re: [PATCH v4 1/3] omap: opp: add OMAP3 OPP table data and common init

2010-11-22 Thread Kevin Hilman
Nishanth Menon  writes:

> Add OPP data for OMAP34xx and OMAP36xx and initialization functions
> to populate OPP tables based on current SoC.
> introduce an OMAP generic opp initialization routine which OMAP3
> and OMAP4+ SoCs can use to register their OPP definitions.
>
> Cc: Thomas Petazzoni 
> Signed-off-by: Kevin Hilman 
> Signed-off-by: Nishanth Menon 

Some minor comments below...

> ---
> Warning: http://lkml.org/lkml/2010/11/9/389
> Introduces ARCH_HAS_OPP which needs to be enabled as well
> for OMAP3 in the Kconfig
> v4:
>   Comments from Thomas addressed:
>   * Data switched to .c file and the c file included in opp.c
>   * init_table will fail with -EEXIST if already called
>   * minor comment improvements
>   Not addressed:
>   * request for board files to explicitly call init table
> as discussed http://marc.info/?l=linux-omap&m=128992417530385&w=2
>
> v3: http://marc.info/?t=12898493916&r=1&w=2
>   * added documentation for custom opp modification
> by board files
>   * switched to using device_initcall to autoinitialize the
> opp tables
> v2: https://patchwork.kernel.org/patch/266911/
>
>  Documentation/arm/OMAP/omap_pm |   26 +++
>  arch/arm/mach-omap2/Kconfig|1 +
>  arch/arm/mach-omap2/Makefile   |2 +
>  arch/arm/mach-omap2/opp.c  |  134 
> 
>  arch/arm/mach-omap2/opp3xxx_data.c |   98 ++
>  arch/arm/mach-omap2/pm.h   |9 +++
>  6 files changed, 270 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/opp.c
>  create mode 100644 arch/arm/mach-omap2/opp3xxx_data.c
>
> diff --git a/Documentation/arm/OMAP/omap_pm b/Documentation/arm/OMAP/omap_pm
> index 5389440..88341f0 100644
> --- a/Documentation/arm/OMAP/omap_pm
> +++ b/Documentation/arm/OMAP/omap_pm
> @@ -127,3 +127,29 @@ implementation needs:
>  10. (*pdata->cpu_set_freq)(unsigned long f)
>  
>  11. (*pdata->cpu_get_freq)(void)
> +
> +Customizing OPP for platform
> +
> +Defining CONFIG_PM should enable OPP layer for the silicon
> +and the registration of OPP table should take place automatically.
> +However, in special cases, the default OPP table may need to be
> +tweaked, for e.g.:
> + * enable default OPPs which are disabled by default, but which
> +   could be enabled on a platform
> + * Disable an unsupported OPP on the platform
> + * Define and add a custom opp table entry
> +in these cases, the board file needs to do additional steps as follows:
> +arch/arm/mach-omapx/board-xyz.c
> + #include "pm.h"
> + 
> + static void __init omap_xyz_init_irq(void)
> + {
> + 
> + /* Initialize the default table */
> + omapx_opp_init();
> + /* Do customization to the defaults */
> + 
> + }
> +NOTE: omapx_opp_init will be omap3_opp_init or as required
> +based on the omap family.
> +

new blank line at EOF (reported by git-apply)

> diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
> index ab784bf..93a91ff 100644
> --- a/arch/arm/mach-omap2/Kconfig
> +++ b/arch/arm/mach-omap2/Kconfig
> @@ -35,6 +35,7 @@ config ARCH_OMAP3
>   select CPU_V7
>   select USB_ARCH_HAS_EHCI
>   select ARM_L1_CACHE_SHIFT_6 if !ARCH_OMAP4
> + select PM_OPP if PM

spaces before tab here (reported by git-apply)

>  
>  config ARCH_OMAP4
>   bool "TI OMAP4"
> diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
> index 60e51bc..1650a62 100644
> --- a/arch/arm/mach-omap2/Makefile
> +++ b/arch/arm/mach-omap2/Makefile
> @@ -64,6 +64,8 @@ endif
>  
>  endif
>  
> +obj-$(CONFIG_PM_OPP) += opp.o
> +
>  # PRCM
>  obj-$(CONFIG_ARCH_OMAP2) += cm.o
>  obj-$(CONFIG_ARCH_OMAP3) += cm.o
> diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c
> new file mode 100644
> index 000..66e12be
> --- /dev/null
> +++ b/arch/arm/mach-omap2/opp.c
> @@ -0,0 +1,134 @@
> +/*
> + *  OMAP SoC specific OPP wrapper function
> + *
> + * Copyright (C) 2009 - 2010 Texas Instruments Incorporated.
> + *   Nishanth Menon
> + * Copyright (C) 2009 - 2010 Deep Root Systems, LLC.
> + *   Kevin Hilman
> + * Copyright (C) 2010 Nokia Corporation.
> + *  Eduardo Valentin
> + *
> + * 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 "pm.h"
> +
> +/**
> + * struct omap_opp_def - OMAP OPP Definition
> + * @hwmod_name:  Name of the hwmod for this domain
> + * @freq:Frequency in hertz corresponding to this OPP
> + * @u_volt:  Nominal voltage in microvolts corresponding to this OPP
> + * @enabled: True/false - is this OPP enabled/disabled by default
> + *
> + * OMAP SOCs have 

[PATCH v4 1/3] omap: opp: add OMAP3 OPP table data and common init

2010-11-16 Thread Nishanth Menon
Add OPP data for OMAP34xx and OMAP36xx and initialization functions
to populate OPP tables based on current SoC.
introduce an OMAP generic opp initialization routine which OMAP3
and OMAP4+ SoCs can use to register their OPP definitions.

Cc: Thomas Petazzoni 
Signed-off-by: Kevin Hilman 
Signed-off-by: Nishanth Menon 
---
Warning: http://lkml.org/lkml/2010/11/9/389
Introduces ARCH_HAS_OPP which needs to be enabled as well
for OMAP3 in the Kconfig
v4:
Comments from Thomas addressed:
* Data switched to .c file and the c file included in opp.c
* init_table will fail with -EEXIST if already called
* minor comment improvements
Not addressed:
* request for board files to explicitly call init table
  as discussed http://marc.info/?l=linux-omap&m=128992417530385&w=2

v3: http://marc.info/?t=12898493916&r=1&w=2
* added documentation for custom opp modification
  by board files
* switched to using device_initcall to autoinitialize the
  opp tables
v2: https://patchwork.kernel.org/patch/266911/

 Documentation/arm/OMAP/omap_pm |   26 +++
 arch/arm/mach-omap2/Kconfig|1 +
 arch/arm/mach-omap2/Makefile   |2 +
 arch/arm/mach-omap2/opp.c  |  134 
 arch/arm/mach-omap2/opp3xxx_data.c |   98 ++
 arch/arm/mach-omap2/pm.h   |9 +++
 6 files changed, 270 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/opp.c
 create mode 100644 arch/arm/mach-omap2/opp3xxx_data.c

diff --git a/Documentation/arm/OMAP/omap_pm b/Documentation/arm/OMAP/omap_pm
index 5389440..88341f0 100644
--- a/Documentation/arm/OMAP/omap_pm
+++ b/Documentation/arm/OMAP/omap_pm
@@ -127,3 +127,29 @@ implementation needs:
 10. (*pdata->cpu_set_freq)(unsigned long f)
 
 11. (*pdata->cpu_get_freq)(void)
+
+Customizing OPP for platform
+
+Defining CONFIG_PM should enable OPP layer for the silicon
+and the registration of OPP table should take place automatically.
+However, in special cases, the default OPP table may need to be
+tweaked, for e.g.:
+ * enable default OPPs which are disabled by default, but which
+   could be enabled on a platform
+ * Disable an unsupported OPP on the platform
+ * Define and add a custom opp table entry
+in these cases, the board file needs to do additional steps as follows:
+arch/arm/mach-omapx/board-xyz.c
+   #include "pm.h"
+   
+   static void __init omap_xyz_init_irq(void)
+   {
+   
+   /* Initialize the default table */
+   omapx_opp_init();
+   /* Do customization to the defaults */
+   
+   }
+NOTE: omapx_opp_init will be omap3_opp_init or as required
+based on the omap family.
+
diff --git a/arch/arm/mach-omap2/Kconfig b/arch/arm/mach-omap2/Kconfig
index ab784bf..93a91ff 100644
--- a/arch/arm/mach-omap2/Kconfig
+++ b/arch/arm/mach-omap2/Kconfig
@@ -35,6 +35,7 @@ config ARCH_OMAP3
select CPU_V7
select USB_ARCH_HAS_EHCI
select ARM_L1_CACHE_SHIFT_6 if !ARCH_OMAP4
+   select PM_OPP if PM
 
 config ARCH_OMAP4
bool "TI OMAP4"
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 60e51bc..1650a62 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -64,6 +64,8 @@ endif
 
 endif
 
+obj-$(CONFIG_PM_OPP)   += opp.o
+
 # PRCM
 obj-$(CONFIG_ARCH_OMAP2)   += cm.o
 obj-$(CONFIG_ARCH_OMAP3)   += cm.o
diff --git a/arch/arm/mach-omap2/opp.c b/arch/arm/mach-omap2/opp.c
new file mode 100644
index 000..66e12be
--- /dev/null
+++ b/arch/arm/mach-omap2/opp.c
@@ -0,0 +1,134 @@
+/*
+ *  OMAP SoC specific OPP wrapper function
+ *
+ * Copyright (C) 2009 - 2010 Texas Instruments Incorporated.
+ * Nishanth Menon
+ * Copyright (C) 2009 - 2010 Deep Root Systems, LLC.
+ * Kevin Hilman
+ * Copyright (C) 2010 Nokia Corporation.
+ *  Eduardo Valentin
+ *
+ * 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 "pm.h"
+
+/**
+ * struct omap_opp_def - OMAP OPP Definition
+ * @hwmod_name:Name of the hwmod for this domain
+ * @freq:  Frequency in hertz corresponding to this OPP
+ * @u_volt:Nominal voltage in microvolts corresponding to this OPP
+ * @enabled:   True/false - is this OPP enabled/disabled by default
+ *
+ * OMAP SOCs have a standard set of tuples consisting of frequency and voltage
+ * pairs that the device will support per voltage domain. This is called
+ * Operating Points or OPP. The actual definitions of OMAP Operating Points
+ * varies over silicon within the same family of devices. For a specific
+ * domain, you can have a set of {frequency, voltage} pairs and t