From patchwork Wed Oct 7 17:53:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Subbrathnam, Swaminathan" X-Patchwork-Id: 52308 Received: from devils.ext.ti.com (devils.ext.ti.com [198.47.26.153]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n97HNmI4009877 for ; Wed, 7 Oct 2009 17:23:48 GMT Received: from dlep34.itg.ti.com ([157.170.170.115]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id n97HLZ1Z031534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Oct 2009 12:21:35 -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 n97HLWHg029899; Wed, 7 Oct 2009 12:21:32 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 721C48063D; Wed, 7 Oct 2009 12:21:09 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dbdp31.itg.ti.com (dbdp31.itg.ti.com [172.24.170.98]) by linux.omap.com (Postfix) with ESMTP id 82CAE80627 for ; Wed, 7 Oct 2009 12:20:39 -0500 (CDT) Received: from localhost.localdomain (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id n97HKatm009706; Wed, 7 Oct 2009 22:50:37 +0530 (IST) From: Swaminathan S To: davinci-linux-open-source@linux.davincidsp.com Date: Wed, 7 Oct 2009 23:23:06 +0530 Message-Id: <1254937992-2291-2-git-send-email-swami.iyer@ti.com> X-Mailer: git-send-email 1.6.0.rc1.64.g61192 In-Reply-To: <1254937992-2291-1-git-send-email-swami.iyer@ti.com> References: <1254937992-2291-1-git-send-email-swami.iyer@ti.com> Cc: linux-usb@vger.kernel.org Subject: [PATCH 1/7] Re-structure of Davinci USB platform implementation. 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 diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h index 1fd3917..8fbbb7b 100644 --- a/arch/arm/mach-davinci/include/mach/common.h +++ b/arch/arm/mach-davinci/include/mach/common.h @@ -20,12 +20,6 @@ extern void davinci_irq_init(void); 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); - struct davinci_timer_instance { void __iomem *base; u32 bottom_irq; @@ -77,5 +71,6 @@ extern void davinci_common_init(struct davinci_soc_info *soc_info); /* standard place to map on-chip SRAMs; they *may* support DMA */ #define SRAM_VIRT 0xfffe0000 #define SRAM_SIZE SZ_128K +#define DAVINCI_USB_OTG_BASE 0x01C64000 #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ diff --git a/arch/arm/mach-davinci/include/mach/usb_musb.h b/arch/arm/mach-davinci/include/mach/usb_musb.h new file mode 100644 index 0000000..e9b35c9 --- /dev/null +++ b/arch/arm/mach-davinci/include/mach/usb_musb.h @@ -0,0 +1,41 @@ +/* + * This file contains the architecture specific USB definitions + * of the TI DaVinci platforms. + * + * Copyright (C) 2009 Texas Instruments. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +#ifndef USB_MUSB_H_ +#define USB_MUSB_H_ + +#include +#include + +struct plat_res_data { + struct musb_hdrc_platform_data *plat_data; + struct resource *res_data; + u8 num_res; +}; + +struct usb_plat_data { + struct plat_res_data *prdata; + u8 num_inst; +}; + +/* VBUS control fuction */ +extern void setup_usb(struct usb_plat_data *pdata); +#endif diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c index 2fff9a6..2c25c55 100644 --- a/arch/arm/mach-davinci/usb.c +++ b/arch/arm/mach-davinci/usb.c @@ -6,20 +6,12 @@ #include #include #include +#include #include #include +#include -#include -#include -#include -#include -#include - -#define DAVINCI_USB_OTG_BASE 0x01c64000 -#define DA8XX_USB1_BASE 0x01e25000 - -#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, }, @@ -43,103 +35,43 @@ static struct musb_hdrc_config musb_config = { .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 */ - -#ifdef CONFIG_ARCH_DAVINCI_DA8XX -static struct resource da8xx_usb11_resources[] = { - [0] = { - .start = DA8XX_USB1_BASE, - .end = DA8XX_USB1_BASE + SZ_4K - 1, - .flags = IORESOURCE_MEM, - }, - [1] = { - .start = IRQ_DA8XX_IRQN, - .end = IRQ_DA8XX_IRQN, - .flags = IORESOURCE_IRQ, - }, -}; - -static u64 da8xx_usb11_dma_mask = DMA_BIT_MASK(32); - -static struct platform_device da8xx_usb11_device = { - .name = "ohci", - .id = 0, - .dev = { - .dma_mask = &da8xx_usb11_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, - .num_resources = ARRAY_SIZE(da8xx_usb11_resources), - .resource = da8xx_usb11_resources, -}; - -int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) +void __init setup_usb(struct usb_plat_data *pdata) { - da8xx_usb11_device.dev.platform_data = pdata; - return platform_device_register(&da8xx_usb11_device); + u8 ninst = pdata->num_inst; + u8 inst, i = 0; + char name[20] = "musb_hdrc"; + struct platform_device *pdev; + struct plat_res_data *plat_res_data; + + do { + plat_res_data = &pdata->prdata[i++]; + inst = plat_res_data->plat_data->inst; + if (pdata->num_inst > 1) + sprintf(name, "musb_hdrc%d", inst); + + pdev = platform_device_alloc(name, -1); + + if (!pdev) { + pr_warning("WARNING: USB platform Alloc Failed\n"); + break; + } + + /* Verify whether the clock information has already been + * specified if so do not override it with generic definition. + */ + if (!plat_res_data->plat_data->clock) + plat_res_data->plat_data->clock = "usb"; + pdev->dev.platform_data = plat_res_data->plat_data; + pdev->dev.dma_mask = &usb_dmamask, + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + pdev->resource = plat_res_data->res_data; + pdev->num_resources = plat_res_data->num_res; + + /* Associate the default configuration if not specified */ + if (!plat_res_data->plat_data->config) + plat_res_data->plat_data->config = &musb_config; + platform_device_add(pdev); + } while (--ninst); } -#endif /* CONFIG_DAVINCI_DA8XX */ diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index d437556..8fa115c 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -58,6 +58,10 @@ struct musb_hdrc_config { }; struct musb_hdrc_platform_data { + + /* MUSB instance */ + u8 inst; + /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */ u8 mode; @@ -82,6 +86,9 @@ struct musb_hdrc_platform_data { /* Turn device clock on or off */ int (*set_clock)(struct clk *clock, int is_on); + /* Configure the USB Phy */ + int (*phy_config)(struct device *dev, u8 mode, int is_on); + /* MUSB configuration-specific details */ struct musb_hdrc_config *config; };