From patchwork Fri Aug 28 18:29:54 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 44544 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7SIUQO8010904 for ; Fri, 28 Aug 2009 18:30:26 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id n7SISPai019999; Fri, 28 Aug 2009 13:28:30 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id n7SISOYv004439; Fri, 28 Aug 2009 13:28:25 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C7BD780627; Fri, 28 Aug 2009 13:28:24 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 33BFC80626 for ; Fri, 28 Aug 2009 13:28:22 -0500 (CDT) Received: from neches.ext.ti.com (localhost [127.0.0.1]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id n7SISLPo014516 for ; Fri, 28 Aug 2009 13:28:21 -0500 (CDT) Received: from mail156-va3-R.bigfish.com (mail-va3.bigfish.com [216.32.180.114]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id n7SISGPh014473 for ; Fri, 28 Aug 2009 13:28:21 -0500 Received: from mail156-va3 (localhost.localdomain [127.0.0.1]) by mail156-va3-R.bigfish.com (Postfix) with ESMTP id 858AE1C873E for ; Fri, 28 Aug 2009 18:28:16 +0000 (UTC) X-SpamScore: 0 X-BigFish: vps0(zzzz1202hzzz2dh6bh64h) X-Spam-TCS-SCL: 3:0 X-FB-SS: 5, X-MS-Exchange-Organization-Antispam-Report: OrigIP: 63.81.120.155; Service: EHS Received: by mail156-va3 (MessageSwitch) id 1251484092756902_19094; Fri, 28 Aug 2009 18:28:12 +0000 (UCT) Received: from imap.sh.mvista.com (unknown [63.81.120.155]) by mail156-va3.bigfish.com (Postfix) with ESMTP id 67363BA8054 for ; Fri, 28 Aug 2009 18:28:12 +0000 (UTC) Received: from wasted.dev.rtsoft.ru (unknown [10.150.0.9]) by imap.sh.mvista.com (Postfix) with ESMTP id 8B37D3EC9; Fri, 28 Aug 2009 11:28:10 -0700 (PDT) From: Sergei Shtylyov Organization: MontaVista Software Inc. To: davinci-linux-open-source@linux.davincidsp.com Date: Fri, 28 Aug 2009 22:29:54 +0400 User-Agent: KMail/1.5 MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200908282229.54352.sshtylyov@ru.mvista.com> Cc: linux-usb@vger.kernel.org Subject: [PATCH 1/3] DaVinci: move MUSB platform device to devices.c X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.4 Precedence: list List-Id: davinci-linux-open-source.linux.davincidsp.com List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com There's absolutely no reason why the DaVinci USB platfrom device should be in its own module; moreover, it will stand in the way of DA8xx's USB platfrom device which occupies different region and IRQ -- so, move it into devices.c and get rid of usb.c... While at it, add 'davinci_' prefix to setup_usb(), remove its duplicate declaration in common.h, and rename 'usb_dev' to 'davinci_usb_device' to match the naming pattern established for devices.c... Signed-off-by: Sergei Shtylyov --- The patch is against the recent DaVinci tree... arch/arm/mach-davinci/usb.c | 110 ---------------------------- arch/arm/mach-davinci/Makefile | 2 arch/arm/mach-davinci/board-dm355-evm.c | 2 arch/arm/mach-davinci/board-dm355-leopard.c | 2 arch/arm/mach-davinci/board-dm644x-evm.c | 2 arch/arm/mach-davinci/board-sffsdr.c | 2 arch/arm/mach-davinci/devices.c | 94 +++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/common.h | 5 - 8 files changed, 100 insertions(+), 119 deletions(-) Index: linux-davinci/arch/arm/mach-davinci/Makefile =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/Makefile +++ linux-davinci/arch/arm/mach-davinci/Makefile @@ -5,7 +5,7 @@ # Common objects obj-y := time.o clock.o serial.o io.o psc.o \ - gpio.o dma.o usb.o common.o sram.o + gpio.o dma.o common.o sram.o obj-$(CONFIG_DAVINCI_MUX) += mux.o Index: linux-davinci/arch/arm/mach-davinci/board-dm355-evm.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/board-dm355-evm.c +++ linux-davinci/arch/arm/mach-davinci/board-dm355-evm.c @@ -275,7 +275,7 @@ static __init void dm355_evm_init(void) gpio_request(2, "usb_id_toggle"); gpio_direction_output(2, USB_ID_VALUE); /* irlml6401 switches over 1A in under 8 msec */ - setup_usb(500, 8); + davinci_setup_usb(500, 8); davinci_setup_mmc(0, &dm355evm_mmc_config); davinci_setup_mmc(1, &dm355evm_mmc_config); Index: linux-davinci/arch/arm/mach-davinci/board-dm355-leopard.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/board-dm355-leopard.c +++ linux-davinci/arch/arm/mach-davinci/board-dm355-leopard.c @@ -271,7 +271,7 @@ static __init void dm355_leopard_init(vo gpio_request(2, "usb_id_toggle"); gpio_direction_output(2, USB_ID_VALUE); /* irlml6401 switches over 1A in under 8 msec */ - setup_usb(500, 8); + davinci_setup_usb(500, 8); davinci_setup_mmc(0, &dm355leopard_mmc_config); davinci_setup_mmc(1, &dm355leopard_mmc_config); Index: linux-davinci/arch/arm/mach-davinci/board-dm644x-evm.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/board-dm644x-evm.c +++ linux-davinci/arch/arm/mach-davinci/board-dm644x-evm.c @@ -409,7 +409,7 @@ evm_u35_setup(struct i2c_client *client, /* irlml6401 switches over 1A, in under 8 msec; * now it can be managed by nDRV_VBUS ... */ - setup_usb(500, 8); + davinci_setup_usb(500, 8); return 0; } Index: linux-davinci/arch/arm/mach-davinci/board-sffsdr.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/board-sffsdr.c +++ linux-davinci/arch/arm/mach-davinci/board-sffsdr.c @@ -165,7 +165,7 @@ static __init void davinci_sffsdr_init(v davinci_serial_init(&uart_config); soc_info->emac_pdata->phy_mask = SFFSDR_PHY_MASK; soc_info->emac_pdata->mdio_max_freq = SFFSDR_MDIO_FREQUENCY; - setup_usb(0, 0); /* We support only peripheral mode. */ + davinci_setup_usb(0, 0); /* We support only peripheral mode. */ /* mux VLYNQ pins */ davinci_cfg_reg(DM644X_VLYNQEN); Index: linux-davinci/arch/arm/mach-davinci/devices.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/devices.c +++ linux-davinci/arch/arm/mach-davinci/devices.c @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -28,6 +29,7 @@ #include #define DAVINCI_I2C_BASE 0x01C21000 +#define DAVINCI_USB_OTG_BASE 0x01C64000 #define DAVINCI_MMCSD0_BASE 0x01E10000 #define DM355_MMCSD0_BASE 0x01E11000 #define DM355_MMCSD1_BASE 0x01E00000 @@ -62,6 +64,98 @@ void __init davinci_init_i2c(struct davi (void) platform_device_register(&davinci_i2c_device); } +#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) + +static struct musb_hdrc_eps_bits musb_eps[] = { + { "ep1_tx", 8, }, + { "ep1_rx", 8, }, + { "ep2_tx", 8, }, + { "ep2_rx", 8, }, + { "ep3_tx", 5, }, + { "ep3_rx", 5, }, + { "ep4_tx", 5, }, + { "ep4_rx", 5, }, +}; + +static struct musb_hdrc_config musb_config = { + .multipoint = true, + .dyn_fifo = true, + .soft_con = true, + .dma = true, + + .num_eps = 5, + .dma_channels = 8, + .ram_bits = 10, + .eps_bits = musb_eps, +}; + +static struct musb_hdrc_platform_data usb_data = { +#if defined(CONFIG_USB_MUSB_OTG) + /* OTG requires a Mini-AB connector */ + .mode = MUSB_OTG, +#elif defined(CONFIG_USB_MUSB_PERIPHERAL) + .mode = MUSB_PERIPHERAL, +#elif defined(CONFIG_USB_MUSB_HOST) + .mode = MUSB_HOST, +#endif + .clock = "usb", + .config = &musb_config, +}; + +static struct resource usb_resources[] = { + { + /* physical address */ + .start = DAVINCI_USB_OTG_BASE, + .end = DAVINCI_USB_OTG_BASE + 0x5ff, + .flags = IORESOURCE_MEM, + }, + { + .start = IRQ_USBINT, + .flags = IORESOURCE_IRQ, + }, + { + /* placeholder for the dedicated CPPI IRQ */ + .flags = IORESOURCE_IRQ, + }, +}; + +static u64 usb_dmamask = DMA_BIT_MASK(32); + +static struct platform_device davinci_usb_device = { + .name = "musb_hdrc", + .id = -1, + .dev = { + .platform_data = &usb_data, + .dma_mask = &usb_dmamask, + .coherent_dma_mask = DMA_BIT_MASK(32), + }, + .resource = usb_resources, + .num_resources = ARRAY_SIZE(usb_resources), +}; + +void __init davinci_setup_usb(unsigned mA, unsigned potpgt_msec) +{ + usb_data.power = mA / 2; + usb_data.potpgt = potpgt_msec / 2; + + if (cpu_is_davinci_dm646x()) { + /* Override the defaults as DM6467 uses different IRQs. */ + davinci_usb_device.resource[1].start = IRQ_DM646X_USBINT; + davinci_usb_device.resource[2].start = IRQ_DM646X_USBDMAINT; + } else /* other devices don't have dedicated CPPI IRQ */ + davinci_usb_device.num_resources = 2; + + platform_device_register(&davinci_usb_device); +} + +#else + +void __init davinci_setup_usb(unsigned mA, unsigned potpgt_msec) +{ +} + +#endif /* CONFIG_USB_MUSB_HDRC */ + #if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE) static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32); Index: linux-davinci/arch/arm/mach-davinci/include/mach/common.h =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/include/mach/common.h +++ linux-davinci/arch/arm/mach-davinci/include/mach/common.h @@ -21,10 +21,7 @@ extern void __iomem *davinci_intc_base; extern int davinci_intc_type; /* parameters describe VBUS sourcing for host mode */ -extern void setup_usb(unsigned mA, unsigned potpgt_msec); - -/* parameters describe VBUS sourcing for host mode */ -extern void setup_usb(unsigned mA, unsigned potpgt_msec); +void davinci_setup_usb(unsigned mA, unsigned potpgt_msec); struct davinci_timer_instance { void __iomem *base; Index: linux-davinci/arch/arm/mach-davinci/usb.c =================================================================== --- linux-davinci.orig/arch/arm/mach-davinci/usb.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * USB - */ -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#define DAVINCI_USB_OTG_BASE 0x01C64000 - -#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) -static struct musb_hdrc_eps_bits musb_eps[] = { - { "ep1_tx", 8, }, - { "ep1_rx", 8, }, - { "ep2_tx", 8, }, - { "ep2_rx", 8, }, - { "ep3_tx", 5, }, - { "ep3_rx", 5, }, - { "ep4_tx", 5, }, - { "ep4_rx", 5, }, -}; - -static struct musb_hdrc_config musb_config = { - .multipoint = true, - .dyn_fifo = true, - .soft_con = true, - .dma = true, - - .num_eps = 5, - .dma_channels = 8, - .ram_bits = 10, - .eps_bits = musb_eps, -}; - -static struct musb_hdrc_platform_data usb_data = { -#if defined(CONFIG_USB_MUSB_OTG) - /* OTG requires a Mini-AB connector */ - .mode = MUSB_OTG, -#elif defined(CONFIG_USB_MUSB_PERIPHERAL) - .mode = MUSB_PERIPHERAL, -#elif defined(CONFIG_USB_MUSB_HOST) - .mode = MUSB_HOST, -#endif - .clock = "usb", - .config = &musb_config, -}; - -static struct resource usb_resources[] = { - { - /* physical address */ - .start = DAVINCI_USB_OTG_BASE, - .end = DAVINCI_USB_OTG_BASE + 0x5ff, - .flags = IORESOURCE_MEM, - }, - { - .start = IRQ_USBINT, - .flags = IORESOURCE_IRQ, - }, - { - /* placeholder for the dedicated CPPI IRQ */ - .flags = IORESOURCE_IRQ, - }, -}; - -static u64 usb_dmamask = DMA_BIT_MASK(32); - -static struct platform_device usb_dev = { - .name = "musb_hdrc", - .id = -1, - .dev = { - .platform_data = &usb_data, - .dma_mask = &usb_dmamask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, - .resource = usb_resources, - .num_resources = ARRAY_SIZE(usb_resources), -}; - -void __init setup_usb(unsigned mA, unsigned potpgt_msec) -{ - usb_data.power = mA / 2; - usb_data.potpgt = potpgt_msec / 2; - - if (cpu_is_davinci_dm646x()) { - /* Override the defaults as DM6467 uses different IRQs. */ - usb_dev.resource[1].start = IRQ_DM646X_USBINT; - usb_dev.resource[2].start = IRQ_DM646X_USBDMAINT; - } else /* other devices don't have dedicated CPPI IRQ */ - usb_dev.num_resources = 2; - - platform_device_register(&usb_dev); -} - -#else - -void __init setup_usb(unsigned mA, unsigned potpgt_msec) -{ -} - -#endif /* CONFIG_USB_MUSB_HDRC */ -