From patchwork Thu Feb 17 11:53:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Balbi X-Patchwork-Id: 569811 X-Patchwork-Delegate: me@felipebalbi.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p1HBril8026165 for ; Thu, 17 Feb 2011 11:53:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755677Ab1BQLxk (ORCPT ); Thu, 17 Feb 2011 06:53:40 -0500 Received: from na3sys009aog112.obsmtp.com ([74.125.149.207]:50335 "EHLO na3sys009aog112.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755445Ab1BQLxj (ORCPT ); Thu, 17 Feb 2011 06:53:39 -0500 Received: from source ([209.85.214.51]) (using TLSv1) by na3sys009aob112.postini.com ([74.125.148.12]) with SMTP ID DSNKTV0MQbVu9YXWUNccpnbwAcvHgUs72dL8@postini.com; Thu, 17 Feb 2011 03:53:38 PST Received: by mail-bw0-f51.google.com with SMTP id 10so2602192bwz.24 for ; Thu, 17 Feb 2011 03:53:37 -0800 (PST) Received: by 10.204.80.161 with SMTP id t33mr1590139bkk.121.1297943617670; Thu, 17 Feb 2011 03:53:37 -0800 (PST) Received: from localhost (cs181221087.pp.htv.fi [82.181.221.87]) by mx.google.com with ESMTPS id rc9sm585311bkb.14.2011.02.17.03.53.35 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 17 Feb 2011 03:53:36 -0800 (PST) Date: Thu, 17 Feb 2011 13:53:33 +0200 From: Felipe Balbi To: Felipe Balbi Cc: Hema HK , linux-usb@vger.kernel.org, linux-omap@vger.kernel.org, Tony Lindgren , Kevin Hilman , "Cousson, Benoit" , Paul Walmsley Subject: Re: [PATCH 5/6 v8] OMAP2+: musb: hwmod adaptation for musb registration Message-ID: <20110217115332.GB22356@legolas.emea.dhcp.ti.com> Reply-To: balbi@ti.com References: <1297924642-3791-1-git-send-email-hemahk@ti.com> <1297924642-3791-6-git-send-email-hemahk@ti.com> <20110217113321.GA22356@legolas.emea.dhcp.ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110217113321.GA22356@legolas.emea.dhcp.ti.com> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Feb 2011 11:53:44 +0000 (UTC) From 76ad3bd54b53b36c908acddc603a4f1aa2ef45ab Mon Sep 17 00:00:00 2001 From: Hema HK Date: Thu, 17 Feb 2011 12:07:21 +0530 Subject: [PATCH] OMAP2+: musb: hwmod adaptation for musb registration Organization: Texas Instruments\n Using omap_device_build API instead of platform_device_register for OMAP2430,OMAP3xxx, OMAP4430 and AM35x musb device registration. The device specific resources defined in centralized database will be used. Signed-off-by: Hema HK Cc: Tony Lindgren Cc: Kevin Hilman Cc: Cousson, Benoit Cc: Paul Walmsley Signed-off-by: Felipe Balbi --- arch/arm/mach-omap2/usb-musb.c | 84 +++++++++++++++++++++------------------- 1 files changed, 44 insertions(+), 40 deletions(-) diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c index 5a82b43..b089ea4 100644 --- a/arch/arm/mach-omap2/usb-musb.c +++ b/arch/arm/mach-omap2/usb-musb.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "control.h" #include "mux.h" @@ -127,22 +128,6 @@ static void am35x_musb_set_mode(u8 musb_mode) omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2); } -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 struct musb_hdrc_config musb_config = { .multipoint = 1, .dyn_fifo = 1, @@ -170,16 +155,12 @@ static struct musb_hdrc_platform_data musb_plat = { static u64 musb_dmamask = DMA_BIT_MASK(32); -static struct platform_device musb_device = { - .name = "musb-omap2430", - .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, }; static void usb_musb_mux_init(struct omap_musb_board_data *board_data) @@ -219,28 +200,24 @@ static void usb_musb_mux_init(struct omap_musb_board_data *board_data) break; } } + 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_omap3517() || cpu_is_omap3505()) { - musb_device.name = "musb-am35x"; - musb_resources[0].start = AM35XX_IPSS_USBOTGSS_BASE; - musb_resources[1].start = INT_35XX_USBOTG_IRQ; + struct omap_hwmod *oh; + struct omap_device *od; + struct platform_device *pdev; + struct device *dev; + int bus_id = -1; + const char *oh_name, *name; + + if (cpu_is_omap3517() || cpu_is_omap3505()) { board_data->set_phy_power = am35x_musb_phy_power; board_data->clear_irq = am35x_musb_clear_irq; board_data->set_mode = am35x_musb_set_mode; board_data->reset = am35x_musb_reset; - } 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; - usb_musb_mux_init(board_data); } - musb_resources[0].end = musb_resources[0].start + SZ_4K - 1; /* * REVISIT: This line can be removed once all the platforms using @@ -252,8 +229,35 @@ void __init usb_musb_init(struct omap_musb_board_data *board_data) 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"); + if (cpu_is_omap3517() || cpu_is_omap3505()) { + oh_name = "am35x_otg_hs"; + name = "musb-am35x"; + } else { + oh_name = "usb_otg_hs"; + name = "musb-omap2430"; + } + + oh = omap_hwmod_lookup(oh_name); + if (!oh) { + pr_err("Could not look up %s\n", oh_name); + return; + } + + od = omap_device_build(name, bus_id, oh, &musb_plat, + sizeof(musb_plat), 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 -- 1.7.4.rc2