usb: musb: Using omap_device_build for musb device registration
Subsystems (4)
PATCH v3 5/9 usb: musb: Using omap_device_build for musb device registration
Using omap_device_build api instead of platform_device_register for musb device registration.The device specific resources defined in centralized database will be used. So removed the resource definitions from the musb platform file.
--- arch/arm/mach-omap2/usb-musb.c | 75 ++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 37 deletions(-)
arch/arm/mach-omap2/usb-musb.c +38 -37
@@ -29,24 +29,11 @@#include <mach/hardware.h> #include <mach/irqs.h> #include <plat/usb.h> +#include <plat/omap_device.h> #ifdef CONFIG_USB_MUSB_SOC - -static struct resource musb_resources[] = { - [0 ] = {/* start and end set dynamically */ - .flags =IORESOURCE_MEM , - }, - [1 ] = {/* general IRQ */ - .start =INT_243X_HS_USB_MC , - .flags =IORESOURCE_IRQ , - .name ="mc" , - }, - [2 ] = {/* DMA IRQ */ - .start =INT_243X_HS_USB_DMA , - .flags =IORESOURCE_IRQ , - .name ="dma" , - }, -}; +static const char name[] ="musb_hdrc" ; +#define MAX_OMAP_MUSB_HWMOD_NAME_LEN 16static struct musb_hdrc_config musb_config = { .multipoint = 1,
@@ -75,31 +62,30 @@ static struct musb_hdrc_platform_data mustatic u64 musb_dmamask =DMA_BIT_MASK (32 ); -static struct platform_device musb_device = { - .name ="musb_hdrc" , - .id =-1 , - .dev = { - .dma_mask = &musb_dmamask, - .coherent_dma_mask =DMA_BIT_MASK (32 ), - .platform_data = &musb_plat, +static struct omap_device_pm_latency omap_musb_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , }, - .num_resources =ARRAY_SIZE (musb_resources), - .resource = musb_resources, };void __init usb_musb_init (struct omap_musb_board_data *board_data) { -if (cpu_is_omap243x ()) { - musb_resources[0 ].start =OMAP243X_HS_BASE ; - }else if (cpu_is_omap34xx ()) { - musb_resources[0 ].start =OMAP34XX_HSUSB_OTG_BASE ; - }else if (cpu_is_omap44xx ()) { - musb_resources[0 ].start =OMAP44XX_HSUSB_OTG_BASE ; - musb_resources[1 ].start =OMAP44XX_IRQ_HS_USB_MC_N ; - musb_resources[2 ].start =OMAP44XX_IRQ_HS_USB_DMA_N ; +struct omap_hwmod *oh; +struct omap_device *od; +struct platform_device *pdev; +struct device *dev; +int bus_id =-1 ; +const char *oh_name ="usb_otg_hs" ; +struct musb_hdrc_platform_data *pdata; + + oh =omap_hwmod_lookup (oh_name); + +if (!oh) { +pr_err ("Could not look up %s\n" , oh_name); +return ; } - musb_resources[0 ].end = musb_resources[0 ].start +SZ_4K -1 ; -/* * REVISIT: This line can be removed once all the platforms using * musb_core.c have been converted to use use clkdev.
@@ -110,8 +96,23 @@ void __init usb_musb_init(struct omap_mu musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (platform_device_register (&musb_device) <0 ) - printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n"); + pdata = &musb_plat; + + od =omap_device_build (name, bus_id, oh, pdata, +sizeof (struct musb_hdrc_platform_data ), + omap_musb_latency, +ARRAY_SIZE (omap_musb_latency), false); +if (IS_ERR (od)) { +pr_err ("Could not build omap_device for %s %s\n" , + name, oh_name); +return ; + } + pdev = &od->pdev; + dev = &pdev->dev; +get_device (dev); + dev->dma_mask = &musb_dmamask; + dev->coherent_dma_mask = musb_dmamask; + put_device(dev); }#else
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): 1285201750-26438-1-git-send-email-hemahk-l0cyMroinI0@public.gmane.org
Hi,
Quoted 1 line · Hema
+#define
MAX_OMAP_MUSB_HWMOD_NAME_LEN16
this isn't used anywhere.
Quoted 35 lines
arch/arm/mach-omap2/usb-musb.c +9
-17@@ -75,31 +62,30 @@ static struct musb_hdrc_platform_data mustatic u64 musb_dmamask =DMA_BIT_MASK (32 ); -static struct platform_device musb_device = { - .name ="musb_hdrc" , - .id =-1 , - .dev = { - .dma_mask = &musb_dmamask, - .coherent_dma_mask =DMA_BIT_MASK (32 ), - .platform_data = &musb_plat, +static struct omap_device_pm_latency omap_musb_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , }, - .num_resources =ARRAY_SIZE (musb_resources), - .resource = musb_resources, };void __init usb_musb_init (struct omap_musb_board_data *board_data) { -if (cpu_is_omap243x ()) { - musb_resources[0 ].start =OMAP243X_HS_BASE ; - }else if (cpu_is_omap34xx ()) { - musb_resources[0 ].start =OMAP34XX_HSUSB_OTG_BASE ; - }else if (cpu_is_omap44xx ()) { - musb_resources[0 ].start =OMAP44XX_HSUSB_OTG_BASE ; - musb_resources[1 ].start =OMAP44XX_IRQ_HS_USB_MC_N ; - musb_resources[2 ].start =OMAP44XX_IRQ_HS_USB_DMA_N ; +struct omap_hwmod *oh; +struct omap_device *od; +struct platform_device *pdev; +struct device *dev;
arch/arm/mach-omap2/usb-musb.c static struct musb_hdrc_platform_data mu · line 88
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +9
-0+int bus_id =-1 ; +const char *oh_name ="usb_otg_hs" ; +struct musb_hdrc_platform_data *pdata; + + oh =omap_hwmod_lookup (oh_name); + +if (!oh) { +pr_err ("Could not look up %s\n" , oh_name); +return ; }
Paul, Kevin, to me it looks like a duplication that all devices will have to:
oh = omap_hwmod_lookup("my_hwmod_name"); omap_device_build("my_device_name", bus_id, oh, pdata, sizeof(*pdata));
could the omap_hwmod_lookup() part be moved to omap_device_build ? Or maybe create a omap_hwmod_lookup_and_build(oh_name, dev_name, bus_id, pdata, sizeof(*pdata)) ??
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 102
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +4
-2@@ -110,8 +96,23 @@ void __init usb_musb_init(struct omap_mu musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (platform_device_register (&musb_device) <0 ) -printk (KERN_ERR "Unable to register HS-USB (MUSB) device\n" ); + pdata = &musb_plat; + + od = omap_device_build(name, bus_id, oh, pdata, + sizeof(struct musb_hdrc_platform_data),
use sizeof(*pdata), if we change the name of that structure (very unlikely, but still) it'll avoid unwanted compile breakage.
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 115
Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6
-0+ pdev = &od->pdev; + dev = &pdev->dev; +get_device (dev); + dev->dma_mask = &musb_dmamask; + dev->coherent_dma_mask = musb_dmamask; +put_device (dev);
I think this is also a duplication, it's gonna on all hwmod device registration, no ?
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 80 lines
-----Original Message-----
From: Balbi, Felipe
Sent: Thursday, September 23, 2010 11:51 AM
To: Kalliguddi, Hema
Cc: [email protected]; [email protected]; Balbi, Felipe; Tony Lindgren; Kevin Hilman; Cousson, Benoit; Paul Walmsley
Subject: Re: [PATCH 5/9 v3] usb: musb: Usingomap_device_buildfor musb device registrationHi,
Quoted 1 line · Hema
+#define
MAX_OMAP_MUSB_HWMOD_NAME_LEN16this isn't used anywhere.
Quoted 35 lines
arch/arm/mach-omap2/usb-musb.c +9
-17@@ -75,31 +62,30 @@ static struct musb_hdrc_platform_data mustatic u64 musb_dmamask =DMA_BIT_MASK (32 ); -static struct platform_device musb_device = { - .name ="musb_hdrc" , - .id =-1 , - .dev = { - .dma_mask = &musb_dmamask, - .coherent_dma_mask =DMA_BIT_MASK (32 ), - .platform_data = &musb_plat, +static struct omap_device_pm_latency omap_musb_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , }, - .num_resources =ARRAY_SIZE (musb_resources), - .resource = musb_resources, };void __init usb_musb_init (struct omap_musb_board_data *board_data) { -if (cpu_is_omap243x ()) { - musb_resources[0 ].start =OMAP243X_HS_BASE ; - }else if (cpu_is_omap34xx ()) { - musb_resources[0 ].start =OMAP34XX_HSUSB_OTG_BASE ; - }else if (cpu_is_omap44xx ()) { - musb_resources[0 ].start =OMAP44XX_HSUSB_OTG_BASE ; - musb_resources[1 ].start =OMAP44XX_IRQ_HS_USB_MC_N ; - musb_resources[2 ].start =OMAP44XX_IRQ_HS_USB_DMA_N ; +struct omap_hwmod *oh; +struct omap_device *od; +struct platform_device *pdev; +struct device *dev;arch/arm/mach-omap2/usb-musb.c static struct musb_hdrc_platform_data mu · line 88
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +9
-0+int bus_id =-1 ; +const char *oh_name ="usb_otg_hs" ; +struct musb_hdrc_platform_data *pdata; + + oh =omap_hwmod_lookup (oh_name); + +if (!oh) { +pr_err ("Could not look up %s\n" , oh_name); +return ; }Paul, Kevin, to me it looks like a duplication that all devices will have to:
oh =
omap_hwmod_lookup("my_hwmod_name");omap_device_build("my_device_name", bus_id, oh, pdata, sizeof(*pdata));could the
omap_hwmod_lookup()part be moved toomap_device_build? Or maybe create aomap_hwmod_lookup_and_build(oh_name, dev_name, bus_id, pdata, sizeof(*pdata))??arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 114
Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +0
-2@@ -110,8 +96,23 @@ void __init usb_musb_init(struct omap_mu musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (platform_device_register (&musb_device) <0 ) - printk(KERN_ERR "Unable to register HS-USB(MUSB) device\n");
Quoted 8 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 102
Quoted 4 lines
arch/arm/mach-omap2/usb-musb.c +4
-0+ pdata = &musb_plat; + + od = omap_device_build(name, bus_id, oh, pdata, + sizeof(struct musb_hdrc_platform_data),use
sizeof(*pdata), if we change the name of that structure (very unlikely, but still) it'll avoid unwanted compile breakage.
Ok. Make sense.
Quoted 9 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 115
Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6
-0+ pdev = &od->pdev; + dev = &pdev->dev; +get_device (dev); + dev->dma_mask = &musb_dmamask; + dev->coherent_dma_mask = musb_dmamask; +put_device (dev);I think this is also a duplication, it's gonna on all hwmod device registration, no ?
Any driver which uses the device->dma_mask will have to it after the device build. ~Hema
Quoted 4 lines
Signature · 2 lines
-- balbi
Hi,
Quoted 2 lines · Hema
Any driver which uses the
device->dma_maskwill have to it after the device build.
yeah, let's see what Kevin, Paul and Tony say about it.
Signature · 1 line
balbi
Quoted 56 lines · Felipe Balbi
Hi,
Quoted 1 line · Hema
+#define
MAX_OMAP_MUSB_HWMOD_NAME_LEN16this isn't used anywhere.
Quoted 35 lines
arch/arm/mach-omap2/usb-musb.c +9
-17@@ -75,31 +62,30 @@ static struct musb_hdrc_platform_data mustatic u64 musb_dmamask =DMA_BIT_MASK (32 ); -static struct platform_device musb_device = { - .name ="musb_hdrc" , - .id =-1 , - .dev = { - .dma_mask = &musb_dmamask, - .coherent_dma_mask =DMA_BIT_MASK (32 ), - .platform_data = &musb_plat, +static struct omap_device_pm_latency omap_musb_latency[] = { + { + .deactivate_func = omap_device_idle_hwmods, + .activate_func = omap_device_enable_hwmods, + .flags =OMAP_DEVICE_LATENCY_AUTO_ADJUST , }, - .num_resources =ARRAY_SIZE (musb_resources), - .resource = musb_resources, };void __init usb_musb_init (struct omap_musb_board_data *board_data) { -if (cpu_is_omap243x ()) { - musb_resources[0 ].start =OMAP243X_HS_BASE ; - }else if (cpu_is_omap34xx ()) { - musb_resources[0 ].start =OMAP34XX_HSUSB_OTG_BASE ; - }else if (cpu_is_omap44xx ()) { - musb_resources[0 ].start =OMAP44XX_HSUSB_OTG_BASE ; - musb_resources[1 ].start =OMAP44XX_IRQ_HS_USB_MC_N ; - musb_resources[2 ].start =OMAP44XX_IRQ_HS_USB_DMA_N ; +struct omap_hwmod *oh; +struct omap_device *od; +struct platform_device *pdev; +struct device *dev;arch/arm/mach-omap2/usb-musb.c static struct musb_hdrc_platform_data mu · line 88
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +9
-0+int bus_id =-1 ; +const char *oh_name ="usb_otg_hs" ; +struct musb_hdrc_platform_data *pdata; + + oh =omap_hwmod_lookup (oh_name); + +if (!oh) { +pr_err ("Could not look up %s\n" , oh_name); +return ; }Paul, Kevin, to me it looks like a duplication that all devices will have to:
Quoted 6 lines
oh =
omap_hwmod_lookup("my_hwmod_name");omap_device_build("my_device_name", bus_id, oh, pdata, sizeof(*pdata));could the
omap_hwmod_lookup()part be moved toomap_device_build? Or maybe create aomap_hwmod_lookup_and_build(oh_name, dev_name, bus_id, pdata, sizeof(*pdata))??
I don't think that this is too much extra work.
Also, many drivers are not doing a single hwmod lookup, they are using an iterator to iterate over a bunch of hwmods in a given class (c.f. omap_hwmod_for_each_by_class)
So, IMO, keeping the lookup and build separate is better.
Quoted 14 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 102
Quoted 10 lines
arch/arm/mach-omap2/usb-musb.c +4
-2@@ -110,8 +96,23 @@ void __init usb_musb_init(struct omap_mu musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; -if (platform_device_register (&musb_device) <0 ) -printk (KERN_ERR "Unable to register HS-USB (MUSB) device\n" ); + pdata = &musb_plat; + + od = omap_device_build(name, bus_id, oh, pdata, + sizeof(struct musb_hdrc_platform_data),use
sizeof(*pdata), if we change the name of that structure (very unlikely, but still) it'll avoid unwanted compile breakage.
Quoted 9 lines
arch/arm/mach-omap2/usb-musb.c void __init usb_musb_init(struct omap_mu · line 115
Quoted 6 lines
arch/arm/mach-omap2/usb-musb.c +6
-0+ pdev = &od->pdev; + dev = &pdev->dev; +get_device (dev); + dev->dma_mask = &musb_dmamask; + dev->coherent_dma_mask = musb_dmamask; +put_device (dev);I think this is also a duplication, it's gonna on all hwmod device registration, no ?
Only for devices setting DMA masks.
This is no more duplication than we have today for all platform_devices.
Kevin
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi,
Quoted 10 lines · Kevin Hilman
Quoted 3 lines
could the
omap_hwmod_lookup()part be moved toomap_device_build? Or maybe create aomap_hwmod_lookup_and_build(oh_name, dev_name, bus_id, pdata, sizeof(*pdata))??I don't think that this is too much extra work.
Also, many drivers are not doing a single hwmod lookup, they are using an iterator to iterate over a bunch of hwmods in a given class (c.f.
omap_hwmod_for_each_by_class)
Quoted 8 lines
So, IMO, keeping the lookup and build separate is better.
Quoted 2 lines
I think this is also a duplication, it's gonna on all hwmod device registration, no ?
Only for devices setting DMA masks.
This is no more duplication than we have today for all
platform_devices.
ok, agreed.
Signature · 5 lines
balbi -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Felipe,
Quoted 9 lines · Felipe Balbi
Paul, Kevin, to me it looks like a duplication that all devices will have to:
oh =
omap_hwmod_lookup("my_hwmod_name");omap_device_build("my_device_name", bus_id, oh, pdata, sizeof(*pdata));could the
omap_hwmod_lookup()part be moved toomap_device_build? Or maybe create aomap_hwmod_lookup_and_build(oh_name, dev_name, bus_id, pdata, sizeof(*pdata))??
... (re dma mask) ...
Quoted 2 lines
I think this is also a duplication, it's gonna on all hwmod device registration, no ?
Probably at some point in the future, once a larger set of hwmod conversions are done, we can look at the way that most of the integration code initializes. Ideally, we can combine as much common code together as possible into some data-driven approach. But right now I think it's a little early to do that, since I personally am not sure what most drivers/devices will need to do in their integration code. On the other hand, it's not too early to start thinking about it :-)
- Paul