Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-07-02 Thread Paul Walmsley
Hi,

On Fri, 2 Jul 2010, Paul Walmsley wrote:

> On Tue, 29 Jun 2010, Kevin Hilman wrote:
> 
> > Kevin Hilman  writes:
> > 
> > > Create simple omap_devices for the main processors and busses.
> > 
> > I've reworked this patch so that it is no longer using early devices,
> > updated version below.
> 
> Thanks for these changes, this seems better than the early_platform_device 
> approach.  I've made a few more changes:

Just FYI, after this patch, 2420 platforms (and presumably 2430 platforms 
also) emit this warning on boot:

[0.057067] WARNING: at arch/arm/mach-omap2/pm.c:53 
_init_omap_device+0x80/0xa0()
[0.057098] _init_omap_device: could not find omap_hwmod for iva
[0.057128] Modules linked in:
[0.057189] [] (unwind_backtrace+0x0/0xec) from [] 
(warn_slowpath_common+0x4c/0x64)
[0.057250] [] (warn_slowpath_common+0x4c/0x64) from [] 
(warn_slowpath_fmt+0x2c/0x3)
[0.057342] [] (warn_slowpath_fmt+0x2c/0x3c) from [] 
(_init_omap_device+0x80/0xa0)
[0.057403] [] (_init_omap_device+0x80/0xa0) from [] 
(omap2_common_pm_init+0x20/0x4)
[0.057495] [] (omap2_common_pm_init+0x20/0x48) from [] 
(do_one_initcall+0x5c/0x1b4)
[0.057556] [] (do_one_initcall+0x5c/0x1b4) from [] 
(kernel_init+0x90/0x144)
[0.057647] [] (kernel_init+0x90/0x144) from [] 
(kernel_thread_exit+0x0/0x8)
[0.057708] ---[ end trace dec6997083161631 ]---

This appears to be due to the lack of an IVA hwmod for 2420/2430, so I've 
added one based on Benoît's patch for 3xxx (below).  This fixes the 
warnings.


- Paul


OMAP2: hwmod data: add IVA1 (2420), IVA2 (2430) hwmods

From: Paul Walmsley 

Add IVA1 hwmod data for OMAP2420 and IVA2 hwmod data for 2430.  The data
is based on Benoît Cousson's hwmod data for the OMAP3 IVA blocks.

Signed-off-by: Paul Walmsley 
Cc: Benoît Cousson 
Cc: Kevin Hilman 
---
 arch/arm/mach-omap2/omap_hwmod_2420_data.c |   30 ++
 arch/arm/mach-omap2/omap_hwmod_2430_data.c |   32 ++--
 2 files changed, 60 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod_2420_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
index 8c90b27..3cc768e 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2420_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2420_data.c
@@ -30,6 +30,7 @@
  */
 
 static struct omap_hwmod omap2420_mpu_hwmod;
+static struct omap_hwmod omap2420_iva_hwmod;
 static struct omap_hwmod omap2420_l3_main_hwmod;
 static struct omap_hwmod omap2420_l4_core_hwmod;
 
@@ -136,11 +137,40 @@ static struct omap_hwmod omap2420_mpu_hwmod = {
.omap_chip  = OMAP_CHIP_INIT(CHIP_IS_OMAP2420),
 };
 
+/*
+ * IVA1 interface data
+ */
+
+/* IVA <- L3 interface */
+static struct omap_hwmod_ocp_if omap2420_l3__iva = {
+   .master = &omap2420_l3_main_hwmod,
+   .slave  = &omap2420_iva_hwmod,
+   .clk= "iva1_ifck",
+   .user   = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+static struct omap_hwmod_ocp_if *omap2420_iva_masters[] = {
+   &omap2420_l3__iva,
+};
+
+/*
+ * IVA2 (IVA2)
+ */
+
+static struct omap_hwmod omap2420_iva_hwmod = {
+   .name   = "iva",
+   .class  = &iva_hwmod_class,
+   .masters= omap2420_iva_masters,
+   .masters_cnt= ARRAY_SIZE(omap2420_iva_masters),
+   .omap_chip  = OMAP_CHIP_INIT(CHIP_IS_OMAP2420)
+};
+
 static __initdata struct omap_hwmod *omap2420_hwmods[] = {
&omap2420_l3_main_hwmod,
&omap2420_l4_core_hwmod,
&omap2420_l4_wkup_hwmod,
&omap2420_mpu_hwmod,
+   &omap2420_iva_hwmod,
NULL,
 };
 
diff --git a/arch/arm/mach-omap2/omap_hwmod_2430_data.c 
b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
index c0f3311..4526628 100644
--- a/arch/arm/mach-omap2/omap_hwmod_2430_data.c
+++ b/arch/arm/mach-omap2/omap_hwmod_2430_data.c
@@ -30,6 +30,7 @@
  */
 
 static struct omap_hwmod omap2430_mpu_hwmod;
+static struct omap_hwmod omap2430_iva_hwmod;
 static struct omap_hwmod omap2430_l3_main_hwmod;
 static struct omap_hwmod omap2430_l4_core_hwmod;
 
@@ -70,8 +71,6 @@ static struct omap_hwmod omap2430_l3_main_hwmod = {
 };
 
 static struct omap_hwmod omap2430_l4_wkup_hwmod;
-static struct omap_hwmod omap2430_mmc1_hwmod;
-static struct omap_hwmod omap2430_mmc2_hwmod;
 
 /* L4_CORE -> L4_WKUP interface */
 static struct omap_hwmod_ocp_if omap2430_l4_core__l4_wkup = {
@@ -138,11 +137,40 @@ static struct omap_hwmod omap2430_mpu_hwmod = {
.omap_chip  = OMAP_CHIP_INIT(CHIP_IS_OMAP2430),
 };
 
+/*
+ * IVA2_1 interface data
+ */
+
+/* IVA2 <- L3 interface */
+static struct omap_hwmod_ocp_if omap2430_l3__iva = {
+   .master = &omap2430_l3_main_hwmod,
+   .slave  = &omap2430_iva_hwmod,
+   .clk= "dsp_fck",
+   .user   = OCP_USER_MPU | OCP_USER_SDMA,
+};
+
+static struct omap_hwmod_ocp_if *omap2430_iva_masters[] = {
+   &omap2430_l3__iva,
+};
+
+/*
+ * IVA2 (IVA2)
+ */
+
+static struct omap_hwmod omap2430_iva_hwmod = {
+  

Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-07-02 Thread Paul Walmsley
Hi,

On Tue, 29 Jun 2010, Kevin Hilman wrote:

> Kevin Hilman  writes:
> 
> > Create simple omap_devices for the main processors and busses.
> >
> > This is required to support the forth-coming device-based OPP
> > approach, where OPPs are managed and tracked at the device level.
> >
> > So that these primary devices are available for early PM initialization,
> > they are created as early platform_devices.
> 
> I've reworked this patch so that it is no longer using early devices,
> updated version below.
> 
> This requires delaying some other PM init as well (OMAP PM layer, OPP
> layer etc.) so a common_pm_init() function was created and initialized
> as a device_initcall().
> 
> My pm-hwmods branch has been updated with this version, and the PM
> branch now has corresponding changes to the SR/voltage layers to
> initialize them as device_initcalls as well.

Thanks for these changes, this seems better than the early_platform_device 
approach.  I've made a few more changes:

- the newly-created functions have been moved to a new file, 
  mach-omap2/pm.c.  I'm not convinced that this file is the right place
  for these functions either, but it didn't make sense to me to create 
  these functions in mach-omap2/io.c;

- the functions have been renamed to start with "omap2" to indicate that
  they are OMAP2+-only functions;

- sparse warnings have been resolved.

Revised patch below.


- Paul

OMAP: PM: create omap_devices for MPU, DSP, L3

From: Kevin Hilman 

Create simple omap_devices for the main processors and busses.

This is required to support the forth-coming device-based OPP
approach, where OPPs are managed and tracked at the device level.

Also, move these common PM init functions into a common_pm_init call
that is called as a device_initcall().  The PM init is done at this level
to ensure that the driver core is initialized before initialized.

Signed-off-by: Kevin Hilman 
[p...@pwsan.com: sparse warnings cleaned up; newly-created functions moved
 from mach-omap2/io.c to mach-omap2/pm.c; newly-created functions renamed
 to start with "omap2" rather than "omap"]
Signed-off-by: Paul Walmsley 
---
 arch/arm/mach-omap2/Makefile |2 -
 arch/arm/mach-omap2/io.c |2 -
 arch/arm/mach-omap2/pm.c |   84 ++
 arch/arm/plat-omap/include/plat/common.h |4 +
 4 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-omap2/pm.c

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 2fa3418..213f1df 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -3,7 +3,7 @@
 #
 
 # Common support
-obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o
+obj-y := id.o io.o control.o mux.o devices.o serial.o gpmc.o timer-gp.o pm.o
 
 omap-2-3-common= irq.o sdrc.o
 hwmod-common   = omap_hwmod.o \
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 05c9cdb..2b983ac 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -44,6 +44,7 @@
 
 #include 
 #include "clockdomains.h"
+
 #include 
 
 /*
@@ -346,7 +347,6 @@ void __init omap2_init_common_hw(struct omap_sdrc_params 
*sdrc_cs0,
if (cpu_is_omap24xx() || cpu_is_omap34xx())   /* FIXME: OMAP4 */
omap_hwmod_late_init(skip_setup_idle);
 
-   omap_pm_if_init();
if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
_omap2_init_reprogram_sdrc();
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
new file mode 100644
index 000..68f9f2e
--- /dev/null
+++ b/arch/arm/mach-omap2/pm.c
@@ -0,0 +1,84 @@
+/*
+ * pm.c - Common OMAP2+ power management-related code
+ *
+ * Copyright (C) 2010 Texas Instruments, Inc.
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * 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 
+
+static struct omap_device_pm_latency *pm_lats;
+
+static struct device *mpu_dev;
+static struct device *dsp_dev;
+static struct device *l3_dev;
+
+struct device *omap2_get_mpuss_device(void)
+{
+   WARN_ON_ONCE(!mpu_dev);
+   return mpu_dev;
+}
+
+struct device *omap2_get_dsp_device(void)
+{
+   WARN_ON_ONCE(!dsp_dev);
+   return dsp_dev;
+}
+
+struct device *omap2_get_l3_device(void)
+{
+   WARN_ON_ONCE(!l3_dev);
+   return l3_dev;
+}
+
+/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
+static int _init_omap_device(char *name, struct device **new_dev)
+{
+   struct omap_hwmod *oh;
+   struct omap_device *od;
+
+   oh = omap_hwmod_lookup(name);
+   if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
+__func__, name))

RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-30 Thread Gopinath, Thara


>>-Original Message-
>>From: Shilimkar, Santosh
>>Sent: Thursday, July 01, 2010 9:46 AM
>>To: Gopinath, Thara; Kevin Hilman
>>Cc: linux-omap@vger.kernel.org; p...@pwsan.com
>>Subject: RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
>>
>>> -Original Message-
>>> From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
>>> ow...@vger.kernel.org] On Behalf Of Gopinath, Thara
>>> Sent: Thursday, July 01, 2010 9:35 AM
>>> To: Kevin Hilman
>>> Cc: linux-omap@vger.kernel.org; p...@pwsan.com
>>> Subject: RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
>>>
>>>
>>>
>>> >>-Original Message-
>>> >>From: Kevin Hilman [mailto:khil...@deeprootsystems.com]
>>> >>Sent: Thursday, July 01, 2010 2:09 AM
>>> >>To: Gopinath, Thara
>>> >>Cc: linux-omap@vger.kernel.org; p...@pwsan.com
>>> >>Subject: Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
>>> >>
>>> >>"Gopinath, Thara"  writes:
>>> >>
>>> >>[...]
>>> >>
>>> >>>>>+static int __init omap_common_pm_init(void)
>>> >>>>>+{
>>> >>>>>+  omap_init_processor_devices();
>>> >>>>>+  omap_pm_if_init();
>>> >>>>>+
>>> >>>>>+  return 0;
>>> >>>>>+}
>>> >>>>>+device_initcall(omap_common_pm_init);
>>> >>
>>> >>>
>>> >>> But I guess opp layer is still getting initialized before this. Esp if
>>> >>> the board files are initializing the opp structures. Or do you have a
>>> >>> patch to fix it in some other branch ?
>>> >>>
>>> >>
>>> >>The common OPP init will be done in this function as well (see current
>>> >>PM branch.)  Board files no longer do OPP init (by default) as it is
>>> >>handled by common code.  Only boards that add OPPs need to call the init
>>> >>function, and we'll have to figure out way to handle that late.
>>>
>>> Yes you are correct. The common OPP init is done in this function. One
>>> other thing I am a bit worried about is the order of initializations. The
>>> order should be
>>> Opp layer
>>> Voltage layer
>>> Smartreflex device layer.
>>>
>>> Presently all three layers are device_initcalls. The sequence is
>>> maintained due to the way these drivers are compiled in. We need to make
>>> them work independent of the way the drivers are compiled.
>>> One way is to have the omap_common_pm_init call into the inits of all
>>> these layers sequentially and
>>> remove the separate init calls. Any other suggestion anyone?
>>>
>>Grouping the initcalls is good idea but with this you can never be
>>able to build any of these as loadable modules.
>>This is valid only if any of above you plan to build as loadable module

I do not think we need to build voltage, opp and smartreflex as modules. I 
would consider them as system critical layers and should be part of the basic 
kernel. Do you see a use case where these layers need to be modules? Also all 
these layers are stand alone libraries. Not registered with any bus or 
anything. So we will have to do some work if we need to load them as modules.

Regards
Thara
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-30 Thread Shilimkar, Santosh
> -Original Message-
> From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> ow...@vger.kernel.org] On Behalf Of Gopinath, Thara
> Sent: Thursday, July 01, 2010 9:35 AM
> To: Kevin Hilman
> Cc: linux-omap@vger.kernel.org; p...@pwsan.com
> Subject: RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
> 
> 
> 
> >>-Original Message-
> >>From: Kevin Hilman [mailto:khil...@deeprootsystems.com]
> >>Sent: Thursday, July 01, 2010 2:09 AM
> >>To: Gopinath, Thara
> >>Cc: linux-omap@vger.kernel.org; p...@pwsan.com
> >>Subject: Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
> >>
> >>"Gopinath, Thara"  writes:
> >>
> >>[...]
> >>
> >>>>>+static int __init omap_common_pm_init(void)
> >>>>>+{
> >>>>>+omap_init_processor_devices();
> >>>>>+omap_pm_if_init();
> >>>>>+
> >>>>>+return 0;
> >>>>>+}
> >>>>>+device_initcall(omap_common_pm_init);
> >>
> >>>
> >>> But I guess opp layer is still getting initialized before this. Esp if
> >>> the board files are initializing the opp structures. Or do you have a
> >>> patch to fix it in some other branch ?
> >>>
> >>
> >>The common OPP init will be done in this function as well (see current
> >>PM branch.)  Board files no longer do OPP init (by default) as it is
> >>handled by common code.  Only boards that add OPPs need to call the init
> >>function, and we'll have to figure out way to handle that late.
> 
> Yes you are correct. The common OPP init is done in this function. One
> other thing I am a bit worried about is the order of initializations. The
> order should be
>   Opp layer
>   Voltage layer
>   Smartreflex device layer.
> 
> Presently all three layers are device_initcalls. The sequence is
> maintained due to the way these drivers are compiled in. We need to make
> them work independent of the way the drivers are compiled.
> One way is to have the omap_common_pm_init call into the inits of all
> these layers sequentially and
> remove the separate init calls. Any other suggestion anyone?
> 
Grouping the initcalls is good idea but with this you can never be 
able to build any of these as loadable modules.
This is valid only if any of above you plan to build as loadable module

> Kevin, by the way your latest pm-sr branch with the above changes works. I
> tested it yesterday.
> 
> Regards
> Thara
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-30 Thread Gopinath, Thara


>>-Original Message-
>>From: Kevin Hilman [mailto:khil...@deeprootsystems.com]
>>Sent: Thursday, July 01, 2010 2:09 AM
>>To: Gopinath, Thara
>>Cc: linux-omap@vger.kernel.org; p...@pwsan.com
>>Subject: Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
>>
>>"Gopinath, Thara"  writes:
>>
>>[...]
>>
>>>>>+static int __init omap_common_pm_init(void)
>>>>>+{
>>>>>+  omap_init_processor_devices();
>>>>>+  omap_pm_if_init();
>>>>>+
>>>>>+  return 0;
>>>>>+}
>>>>>+device_initcall(omap_common_pm_init);
>>
>>>
>>> But I guess opp layer is still getting initialized before this. Esp if
>>> the board files are initializing the opp structures. Or do you have a
>>> patch to fix it in some other branch ?
>>>
>>
>>The common OPP init will be done in this function as well (see current
>>PM branch.)  Board files no longer do OPP init (by default) as it is
>>handled by common code.  Only boards that add OPPs need to call the init
>>function, and we'll have to figure out way to handle that late.

Yes you are correct. The common OPP init is done in this function. One other 
thing I am a bit worried about is the order of initializations. The order 
should be
Opp layer
Voltage layer
Smartreflex device layer.

Presently all three layers are device_initcalls. The sequence is maintained due 
to the way these drivers are compiled in. We need to make them work independent 
of the way the drivers are compiled.
One way is to have the omap_common_pm_init call into the inits of all these 
layers sequentially and
remove the separate init calls. Any other suggestion anyone?

Kevin, by the way your latest pm-sr branch with the above changes works. I 
tested it yesterday.

Regards
Thara
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-30 Thread Kevin Hilman
"Gopinath, Thara"  writes:

[...]

>>>+static int __init omap_common_pm_init(void)
>>>+{
>>>+omap_init_processor_devices();
>>>+omap_pm_if_init();
>>>+
>>>+return 0;
>>>+}
>>>+device_initcall(omap_common_pm_init);

>
> But I guess opp layer is still getting initialized before this. Esp if
> the board files are initializing the opp structures. Or do you have a
> patch to fix it in some other branch ?
>

The common OPP init will be done in this function as well (see current
PM branch.)  Board files no longer do OPP init (by default) as it is
handled by common code.  Only boards that add OPPs need to call the init
function, and we'll have to figure out way to handle that late.

Kevin

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


RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-29 Thread Gopinath, Thara


>>-Original Message-
>>From: linux-omap-ow...@vger.kernel.org 
>>[mailto:linux-omap-ow...@vger.kernel.org] On Behalf Of Kevin
>>Hilman
>>Sent: Tuesday, June 29, 2010 11:00 PM
>>To: linux-omap@vger.kernel.org
>>Cc: p...@pwsan.com
>>Subject: Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
>>
>>Kevin Hilman  writes:
>>
>>> Create simple omap_devices for the main processors and busses.
>>>
>>> This is required to support the forth-coming device-based OPP
>>> approach, where OPPs are managed and tracked at the device level.
>>>
>>> So that these primary devices are available for early PM initialization,
>>> they are created as early platform_devices.
>>
>>I've reworked this patch so that it is no longer using early devices,
>>updated version below.
>>
>>This requires delaying some other PM init as well (OMAP PM layer, OPP
>>layer etc.) so a common_pm_init() function was created and initialized
>>as a device_initcall().
>>
>>My pm-hwmods branch has been updated with this version, and the PM
>>branch now has corresponding changes to the SR/voltage layers to
>>initialize them as device_initcalls as well.
>>
>>Kevin
>>
>>From 5180e0c52509fcf30ad92503b817326856231efb Mon Sep 17 00:00:00 2001
>>From: Kevin Hilman 
>>Date: Mon, 21 Jun 2010 10:53:13 -0700
>>Subject: [PATCH] OMAP: create omap_devices for MPU, DSP, L3
>>
>>Create simple omap_devices for the main processors and busses.
>>
>>This is required to support the forth-coming device-based OPP
>>approach, where OPPs are managed and tracked at the device level.
>>
>>Also, move these common PM init functions into a common_pm_init call
>>that is called as a device_initcall().  The PM init is done at this level
>>to ensure that the driver core is initialized before initialized.
>>
>>Cc: Paul Walmsley 
>>Signed-off-by: Kevin Hilman 
>>---
>> arch/arm/mach-omap2/devices.c|2 +
>> arch/arm/mach-omap2/io.c |   67 
>> +-
>> arch/arm/plat-omap/include/plat/common.h |4 ++
>> 3 files changed, 71 insertions(+), 2 deletions(-)
>>
>>diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
>>index 03e6c9e..62920ac 100644
>>--- a/arch/arm/mach-omap2/devices.c
>>+++ b/arch/arm/mach-omap2/devices.c
>>@@ -15,6 +15,7 @@
>> #include 
>> #include 
>> #include 
>>+#include 
>>
>> #include 
>> #include 
>>@@ -29,6 +30,7 @@
>> #include 
>> #include 
>> #include 
>>+#include 
>>
>> #include "mux.h"
>>
>>diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
>>index 3cfb425..f406fac 100644
>>--- a/arch/arm/mach-omap2/io.c
>>+++ b/arch/arm/mach-omap2/io.c
>>@@ -45,7 +45,7 @@
>>
>> #include 
>> #include "clockdomains.h"
>>-#include 
>>+#include 
>>
>> /*
>>  * The machine specific code may provide the extra mapping besides the
>>@@ -313,6 +313,70 @@ static int __init _omap2_init_reprogram_sdrc(void)
>>  return v;
>> }
>>
>>+static struct omap_device_pm_latency *pm_lats;
>>+
>>+static struct device *mpu_dev;
>>+static struct device *dsp_dev;
>>+static struct device *l3_dev;
>>+
>>+struct device *omap_get_mpuss_device(void)
>>+{
>>+ WARN_ON_ONCE(!mpu_dev);
>>+ return mpu_dev;
>>+}
>>+
>>+struct device *omap_get_dsp_device(void)
>>+{
>>+ WARN_ON_ONCE(!dsp_dev);
>>+ return dsp_dev;
>>+}
>>+
>>+struct device *omap_get_l3_device(void)
>>+{
>>+ WARN_ON_ONCE(!l3_dev);
>>+ return l3_dev;
>>+}
>>+
>>+/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
>>+static int _init_omap_device(char *name, struct device **new_dev)
>>+{
>>+ struct omap_hwmod *oh;
>>+ struct omap_device *od;
>>+
>>+ oh = omap_hwmod_lookup(name);
>>+ if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
>>+  __func__, name))
>>+ return -ENODEV;
>>+
>>+ od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
>>+ if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
>>+  __func__, name))
>>+ return -ENODEV;
>>+
>>+ *new_dev = &od->pdev.dev;
>>+
>>+ return 0;
>>+}
>&

Re: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-29 Thread Kevin Hilman
Kevin Hilman  writes:

> Create simple omap_devices for the main processors and busses.
>
> This is required to support the forth-coming device-based OPP
> approach, where OPPs are managed and tracked at the device level.
>
> So that these primary devices are available for early PM initialization,
> they are created as early platform_devices.

I've reworked this patch so that it is no longer using early devices,
updated version below.

This requires delaying some other PM init as well (OMAP PM layer, OPP
layer etc.) so a common_pm_init() function was created and initialized
as a device_initcall().

My pm-hwmods branch has been updated with this version, and the PM
branch now has corresponding changes to the SR/voltage layers to
initialize them as device_initcalls as well.

Kevin

>From 5180e0c52509fcf30ad92503b817326856231efb Mon Sep 17 00:00:00 2001
From: Kevin Hilman 
Date: Mon, 21 Jun 2010 10:53:13 -0700
Subject: [PATCH] OMAP: create omap_devices for MPU, DSP, L3

Create simple omap_devices for the main processors and busses.

This is required to support the forth-coming device-based OPP
approach, where OPPs are managed and tracked at the device level.

Also, move these common PM init functions into a common_pm_init call
that is called as a device_initcall().  The PM init is done at this level
to ensure that the driver core is initialized before initialized.

Cc: Paul Walmsley 
Signed-off-by: Kevin Hilman 
---
 arch/arm/mach-omap2/devices.c|2 +
 arch/arm/mach-omap2/io.c |   67 +-
 arch/arm/plat-omap/include/plat/common.h |4 ++
 3 files changed, 71 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 03e6c9e..62920ac 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -29,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mux.h"
 
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3cfb425..f406fac 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -45,7 +45,7 @@
 
 #include 
 #include "clockdomains.h"
-#include 
+#include 
 
 /*
  * The machine specific code may provide the extra mapping besides the
@@ -313,6 +313,70 @@ static int __init _omap2_init_reprogram_sdrc(void)
return v;
 }
 
+static struct omap_device_pm_latency *pm_lats;
+
+static struct device *mpu_dev;
+static struct device *dsp_dev;
+static struct device *l3_dev;
+
+struct device *omap_get_mpuss_device(void)
+{
+   WARN_ON_ONCE(!mpu_dev);
+   return mpu_dev;
+}
+
+struct device *omap_get_dsp_device(void)
+{
+   WARN_ON_ONCE(!dsp_dev);
+   return dsp_dev;
+}
+
+struct device *omap_get_l3_device(void)
+{
+   WARN_ON_ONCE(!l3_dev);
+   return l3_dev;
+}
+
+/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
+static int _init_omap_device(char *name, struct device **new_dev)
+{
+   struct omap_hwmod *oh;
+   struct omap_device *od;
+
+   oh = omap_hwmod_lookup(name);
+   if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
+__func__, name))
+   return -ENODEV;
+
+   od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, false);
+   if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
+__func__, name))
+   return -ENODEV;
+
+   *new_dev = &od->pdev.dev;
+
+   return 0;
+}
+
+/*
+ * Build omap_devices for processors and bus.
+ */
+static void omap_init_processor_devices(void)
+{
+   _init_omap_device("mpu", &mpu_dev);
+   _init_omap_device("iva", &dsp_dev);
+   _init_omap_device("l3_main", &l3_dev);
+}
+
+static int __init omap_common_pm_init(void)
+{
+   omap_init_processor_devices();
+   omap_pm_if_init();
+
+   return 0;
+}
+device_initcall(omap_common_pm_init);
+
 void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
 struct omap_sdrc_params *sdrc_cs1)
 {
@@ -342,7 +406,6 @@ void __init omap2_init_common_hw(struct omap_sdrc_params 
*sdrc_cs0,
omap_serial_early_init();
if (cpu_is_omap24xx() || cpu_is_omap34xx())   /* FIXME: OMAP4 */
omap_hwmod_late_init();
-   omap_pm_if_init();
if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
_omap2_init_reprogram_sdrc();
diff --git a/arch/arm/plat-omap/include/plat/common.h 
b/arch/arm/plat-omap/include/plat/common.h
index d265018..9cdd9cd 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -87,4 +87,8 @@ void omap2_set_globals_uart(struct omap_globals *);
}   \
 })
 
+struct device *omap_get_mpuss_device(void);
+struct device *omap_get_dsp_device(void);
+struct device *omap_

RE: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-26 Thread DebBarma, Tarun Kanti
> -Original Message-
> From: linux-omap-ow...@vger.kernel.org [mailto:linux-omap-
> ow...@vger.kernel.org] On Behalf Of Kevin Hilman
> Sent: Friday, June 25, 2010 5:15 AM
> To: linux-omap@vger.kernel.org
> Cc: p...@pwsan.com
> Subject: [PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3
> 
> Create simple omap_devices for the main processors and busses.
> 
> This is required to support the forth-coming device-based OPP
> approach, where OPPs are managed and tracked at the device level.
> 
> So that these primary devices are available for early PM initialization,
> they are created as early platform_devices.
> 
> Cc: Paul Walmsley 
> Signed-off-by: Kevin Hilman 
> ---
>  arch/arm/mach-omap2/devices.c|2 +
>  arch/arm/mach-omap2/io.c |   58
> +-
>  arch/arm/plat-omap/include/plat/common.h |4 ++
>  3 files changed, 63 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
> index 03e6c9e..62920ac 100644
> --- a/arch/arm/mach-omap2/devices.c
> +++ b/arch/arm/mach-omap2/devices.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include 
>  #include 
> @@ -29,6 +30,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
> 
>  #include "mux.h"
> 
> diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
> index 3cfb425..407498d 100644
> --- a/arch/arm/mach-omap2/io.c
> +++ b/arch/arm/mach-omap2/io.c
> @@ -45,7 +45,7 @@
> 
>  #include 
>  #include "clockdomains.h"
> -#include 
> +#include 
> 
>  /*
>   * The machine specific code may provide the extra mapping besides the
> @@ -313,6 +313,61 @@ static int __init _omap2_init_reprogram_sdrc(void)
>   return v;
>  }
> 
> +static struct omap_device_pm_latency *pm_lats;
> +
> +static struct device *mpu_dev;
> +static struct device *dsp_dev;
> +static struct device *l3_dev;
> +
> +struct device *omap_get_mpuss_device(void)
> +{
> + WARN_ON_ONCE(!mpu_dev);
> + return mpu_dev;
> +}
> +
> +struct device *omap_get_dsp_device(void)
> +{
> + WARN_ON_ONCE(!dsp_dev);
> + return dsp_dev;
> +}
> +
> +struct device *omap_get_l3_device(void)
> +{
> + WARN_ON_ONCE(!l3_dev);
> + return l3_dev;
> +}
> +
> +/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
> +static int _init_omap_device(char *name, struct device **new_dev)
> +{
> + struct omap_hwmod *oh;
> + struct omap_device *od;
> +
> + oh = omap_hwmod_lookup(name);
> + if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
> +  __func__, name))
> + return -ENODEV;
> +
> + od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, true);

[Tarun Kanti DebBarma] 
I am new to hwmod and just trying to catch up. In omap_device_build(...) we 
anyway pass (oh) and so why also pass (oh->name)? If so we can reduce a 
parameter.


> + if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
> +  __func__, name))
> + return -ENODEV;
> +
> + *new_dev = &od->pdev.dev;
> +
> + return 0;
> +}
> +
> +/*
> + * Build omap_devices for processors and bus.
> + */
> +static void omap_init_processor_devices(void)
> +{
> + _init_omap_device("mpu", &mpu_dev);
> + _init_omap_device("iva", &dsp_dev);
> + _init_omap_device("l3_main", &l3_dev);
> +}
> +
>  void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
>struct omap_sdrc_params *sdrc_cs1)
>  {
> @@ -342,6 +397,7 @@ void __init omap2_init_common_hw(struct
> omap_sdrc_params *sdrc_cs0,
>   omap_serial_early_init();
>   if (cpu_is_omap24xx() || cpu_is_omap34xx())   /* FIXME: OMAP4 */
>   omap_hwmod_late_init();
> + omap_init_processor_devices();
>   omap_pm_if_init();
>   if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
>   omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
> diff --git a/arch/arm/plat-omap/include/plat/common.h b/arch/arm/plat-
> omap/include/plat/common.h
> index d265018..9cdd9cd 100644
> --- a/arch/arm/plat-omap/include/plat/common.h
> +++ b/arch/arm/plat-omap/include/plat/common.h
> @@ -87,4 +87,8 @@ void omap2_set_globals_uart(struct omap_globals *);
>   }   \
>  })
> 
> +struct device *omap_get_mpuss_device(void);
> +struct device *omap_get_dsp_device(void);
> +struct device *omap_get_l3_device(void);
> +
>  #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
> --
> 1.7.0.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 10/13] OMAP: create omap_devices for MPU, DSP, L3

2010-06-24 Thread Kevin Hilman
Create simple omap_devices for the main processors and busses.

This is required to support the forth-coming device-based OPP
approach, where OPPs are managed and tracked at the device level.

So that these primary devices are available for early PM initialization,
they are created as early platform_devices.

Cc: Paul Walmsley 
Signed-off-by: Kevin Hilman 
---
 arch/arm/mach-omap2/devices.c|2 +
 arch/arm/mach-omap2/io.c |   58 +-
 arch/arm/plat-omap/include/plat/common.h |4 ++
 3 files changed, 63 insertions(+), 1 deletions(-)

diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c
index 03e6c9e..62920ac 100644
--- a/arch/arm/mach-omap2/devices.c
+++ b/arch/arm/mach-omap2/devices.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -29,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "mux.h"
 
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3cfb425..407498d 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -45,7 +45,7 @@
 
 #include 
 #include "clockdomains.h"
-#include 
+#include 
 
 /*
  * The machine specific code may provide the extra mapping besides the
@@ -313,6 +313,61 @@ static int __init _omap2_init_reprogram_sdrc(void)
return v;
 }
 
+static struct omap_device_pm_latency *pm_lats;
+
+static struct device *mpu_dev;
+static struct device *dsp_dev;
+static struct device *l3_dev;
+
+struct device *omap_get_mpuss_device(void)
+{
+   WARN_ON_ONCE(!mpu_dev);
+   return mpu_dev;
+}
+
+struct device *omap_get_dsp_device(void)
+{
+   WARN_ON_ONCE(!dsp_dev);
+   return dsp_dev;
+}
+
+struct device *omap_get_l3_device(void)
+{
+   WARN_ON_ONCE(!l3_dev);
+   return l3_dev;
+}
+
+/* static int _init_omap_device(struct omap_hwmod *oh, void *user) */
+static int _init_omap_device(char *name, struct device **new_dev)
+{
+   struct omap_hwmod *oh;
+   struct omap_device *od;
+
+   oh = omap_hwmod_lookup(name);
+   if (WARN(!oh, "%s: could not find omap_hwmod for %s\n",
+__func__, name))
+   return -ENODEV;
+
+   od = omap_device_build(oh->name, 0, oh, NULL, 0, pm_lats, 0, true);
+   if (WARN(IS_ERR(od), "%s: could not build omap_device for %s\n",
+__func__, name))
+   return -ENODEV;
+
+   *new_dev = &od->pdev.dev;
+
+   return 0;
+}
+
+/*
+ * Build omap_devices for processors and bus.
+ */
+static void omap_init_processor_devices(void)
+{
+   _init_omap_device("mpu", &mpu_dev);
+   _init_omap_device("iva", &dsp_dev);
+   _init_omap_device("l3_main", &l3_dev);
+}
+
 void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
 struct omap_sdrc_params *sdrc_cs1)
 {
@@ -342,6 +397,7 @@ void __init omap2_init_common_hw(struct omap_sdrc_params 
*sdrc_cs0,
omap_serial_early_init();
if (cpu_is_omap24xx() || cpu_is_omap34xx())   /* FIXME: OMAP4 */
omap_hwmod_late_init();
+   omap_init_processor_devices();
omap_pm_if_init();
if (cpu_is_omap24xx() || cpu_is_omap34xx()) {
omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
diff --git a/arch/arm/plat-omap/include/plat/common.h 
b/arch/arm/plat-omap/include/plat/common.h
index d265018..9cdd9cd 100644
--- a/arch/arm/plat-omap/include/plat/common.h
+++ b/arch/arm/plat-omap/include/plat/common.h
@@ -87,4 +87,8 @@ void omap2_set_globals_uart(struct omap_globals *);
}   \
 })
 
+struct device *omap_get_mpuss_device(void);
+struct device *omap_get_dsp_device(void);
+struct device *omap_get_l3_device(void);
+
 #endif /* __ARCH_ARM_MACH_OMAP_COMMON_H */
-- 
1.7.0.2

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