| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301 | 
							- /*
 
-  * Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
 
-  *
 
-  * Copyright (C) 2004 Texas Instruments, Inc.
 
-  *
 
-  * 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
 
-  */
 
- #include <linux/module.h>
 
- #include <linux/kernel.h>
 
- #include <linux/init.h>
 
- #include <linux/platform_device.h>
 
- #include <linux/io.h>
 
- #include <asm/irq.h>
 
- #include <mach/mux.h>
 
- #include <mach/usb.h>
 
- #include "common.h"
 
- /* These routines should handle the standard chip-specific modes
 
-  * for usb0/1/2 ports, covering basic mux and transceiver setup.
 
-  *
 
-  * Some board-*.c files will need to set up additional mux options,
 
-  * like for suspend handling, vbus sensing, GPIOs, and the D+ pullup.
 
-  */
 
- /* TESTED ON:
 
-  *  - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
 
-  *  - 5912 OSK OHCI (with usb0 standard-A), standard A-to-B cables
 
-  *  - 5912 OSK UDC, with *nonstandard* A-to-A cable
 
-  *  - 1510 Innovator UDC with bundled usb0 cable
 
-  *  - 1510 Innovator OHCI with bundled usb1/usb2 cable
 
-  *  - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
 
-  *  - 1710 custom development board using alternate pin group
 
-  *  - 1710 H3 (with usb1 mini-AB) using standard Mini-B or OTG cables
 
-  */
 
- #define INT_USB_IRQ_GEN		IH2_BASE + 20
 
- #define INT_USB_IRQ_NISO	IH2_BASE + 30
 
- #define INT_USB_IRQ_ISO		IH2_BASE + 29
 
- #define INT_USB_IRQ_HGEN	INT_USB_HHC_1
 
- #define INT_USB_IRQ_OTG		IH2_BASE + 8
 
- #ifdef	CONFIG_ARCH_OMAP_OTG
 
- void __init
 
- omap_otg_init(struct omap_usb_config *config)
 
- {
 
- 	u32		syscon;
 
- 	int		alt_pingroup = 0;
 
- 	/* NOTE:  no bus or clock setup (yet?) */
 
- 	syscon = omap_readl(OTG_SYSCON_1) & 0xffff;
 
- 	if (!(syscon & OTG_RESET_DONE))
 
- 		pr_debug("USB resets not complete?\n");
 
- 	//omap_writew(0, OTG_IRQ_EN);
 
- 	/* pin muxing and transceiver pinouts */
 
- 	if (config->pins[0] > 2)	/* alt pingroup 2 */
 
- 		alt_pingroup = 1;
 
- 	syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
 
- 	syscon |= config->usb1_init(config->pins[1]);
 
- 	syscon |= config->usb2_init(config->pins[2], alt_pingroup);
 
- 	pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
 
- 	omap_writel(syscon, OTG_SYSCON_1);
 
- 	syscon = config->hmc_mode;
 
- 	syscon |= USBX_SYNCHRO | (4 << 16) /* B_ASE0_BRST */;
 
- #ifdef	CONFIG_USB_OTG
 
- 	if (config->otg)
 
- 		syscon |= OTG_EN;
 
- #endif
 
- 	if (cpu_class_is_omap1())
 
- 		pr_debug("USB_TRANSCEIVER_CTRL = %03x\n",
 
- 			 omap_readl(USB_TRANSCEIVER_CTRL));
 
- 	pr_debug("OTG_SYSCON_2 = %08x\n", omap_readl(OTG_SYSCON_2));
 
- 	omap_writel(syscon, OTG_SYSCON_2);
 
- 	printk("USB: hmc %d", config->hmc_mode);
 
- 	if (!alt_pingroup)
 
- 		printk(", usb2 alt %d wires", config->pins[2]);
 
- 	else if (config->pins[0])
 
- 		printk(", usb0 %d wires%s", config->pins[0],
 
- 			is_usb0_device(config) ? " (dev)" : "");
 
- 	if (config->pins[1])
 
- 		printk(", usb1 %d wires", config->pins[1]);
 
- 	if (!alt_pingroup && config->pins[2])
 
- 		printk(", usb2 %d wires", config->pins[2]);
 
- 	if (config->otg)
 
- 		printk(", Mini-AB on usb%d", config->otg - 1);
 
- 	printk("\n");
 
- 	if (cpu_class_is_omap1()) {
 
- 		u16 w;
 
- 		/* leave USB clocks/controllers off until needed */
 
- 		w = omap_readw(ULPD_SOFT_REQ);
 
- 		w &= ~SOFT_USB_CLK_REQ;
 
- 		omap_writew(w, ULPD_SOFT_REQ);
 
- 		w = omap_readw(ULPD_CLOCK_CTRL);
 
- 		w &= ~USB_MCLK_EN;
 
- 		w |= DIS_USB_PVCI_CLK;
 
- 		omap_writew(w, ULPD_CLOCK_CTRL);
 
- 	}
 
- 	syscon = omap_readl(OTG_SYSCON_1);
 
- 	syscon |= HST_IDLE_EN|DEV_IDLE_EN|OTG_IDLE_EN;
 
- #ifdef	CONFIG_USB_GADGET_OMAP
 
- 	if (config->otg || config->register_dev) {
 
- 		struct platform_device *udc_device = config->udc_device;
 
- 		int status;
 
- 		syscon &= ~DEV_IDLE_EN;
 
- 		udc_device->dev.platform_data = config;
 
- 		status = platform_device_register(udc_device);
 
- 		if (status)
 
- 			pr_debug("can't register UDC device, %d\n", status);
 
- 	}
 
- #endif
 
- #if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 
- 	if (config->otg || config->register_host) {
 
- 		struct platform_device *ohci_device = config->ohci_device;
 
- 		int status;
 
- 		syscon &= ~HST_IDLE_EN;
 
- 		ohci_device->dev.platform_data = config;
 
- 		status = platform_device_register(ohci_device);
 
- 		if (status)
 
- 			pr_debug("can't register OHCI device, %d\n", status);
 
- 	}
 
- #endif
 
- #ifdef	CONFIG_USB_OTG
 
- 	if (config->otg) {
 
- 		struct platform_device *otg_device = config->otg_device;
 
- 		int status;
 
- 		syscon &= ~OTG_IDLE_EN;
 
- 		otg_device->dev.platform_data = config;
 
- 		status = platform_device_register(otg_device);
 
- 		if (status)
 
- 			pr_debug("can't register OTG device, %d\n", status);
 
- 	}
 
- #endif
 
- 	pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
 
- 	omap_writel(syscon, OTG_SYSCON_1);
 
- }
 
- #else
 
- void omap_otg_init(struct omap_usb_config *config) {}
 
- #endif
 
- #ifdef	CONFIG_USB_GADGET_OMAP
 
- static struct resource udc_resources[] = {
 
- 	/* order is significant! */
 
- 	{		/* registers */
 
- 		.start		= UDC_BASE,
 
- 		.end		= UDC_BASE + 0xff,
 
- 		.flags		= IORESOURCE_MEM,
 
- 	}, {		/* general IRQ */
 
- 		.start		= INT_USB_IRQ_GEN,
 
- 		.flags		= IORESOURCE_IRQ,
 
- 	}, {		/* PIO IRQ */
 
- 		.start		= INT_USB_IRQ_NISO,
 
- 		.flags		= IORESOURCE_IRQ,
 
- 	}, {		/* SOF IRQ */
 
- 		.start		= INT_USB_IRQ_ISO,
 
- 		.flags		= IORESOURCE_IRQ,
 
- 	},
 
- };
 
- static u64 udc_dmamask = ~(u32)0;
 
- static struct platform_device udc_device = {
 
- 	.name		= "omap_udc",
 
- 	.id		= -1,
 
- 	.dev = {
 
- 		.dma_mask		= &udc_dmamask,
 
- 		.coherent_dma_mask	= 0xffffffff,
 
- 	},
 
- 	.num_resources	= ARRAY_SIZE(udc_resources),
 
- 	.resource	= udc_resources,
 
- };
 
- static inline void udc_device_init(struct omap_usb_config *pdata)
 
- {
 
- 	/* IRQ numbers for omap7xx */
 
- 	if(cpu_is_omap7xx()) {
 
- 		udc_resources[1].start = INT_7XX_USB_GENI;
 
- 		udc_resources[2].start = INT_7XX_USB_NON_ISO;
 
- 		udc_resources[3].start = INT_7XX_USB_ISO;
 
- 	}
 
- 	pdata->udc_device = &udc_device;
 
- }
 
- #else
 
- static inline void udc_device_init(struct omap_usb_config *pdata)
 
- {
 
- }
 
- #endif
 
- #if	defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
 
- /* The dmamask must be set for OHCI to work */
 
- static u64 ohci_dmamask = ~(u32)0;
 
- static struct resource ohci_resources[] = {
 
- 	{
 
- 		.start	= OMAP_OHCI_BASE,
 
- 		.end	= OMAP_OHCI_BASE + 0xff,
 
- 		.flags	= IORESOURCE_MEM,
 
- 	},
 
- 	{
 
- 		.start	= INT_USB_IRQ_HGEN,
 
- 		.flags	= IORESOURCE_IRQ,
 
- 	},
 
- };
 
- static struct platform_device ohci_device = {
 
- 	.name			= "ohci",
 
- 	.id			= -1,
 
- 	.dev = {
 
- 		.dma_mask		= &ohci_dmamask,
 
- 		.coherent_dma_mask	= 0xffffffff,
 
- 	},
 
- 	.num_resources	= ARRAY_SIZE(ohci_resources),
 
- 	.resource		= ohci_resources,
 
- };
 
- static inline void ohci_device_init(struct omap_usb_config *pdata)
 
- {
 
- 	if (cpu_is_omap7xx())
 
- 		ohci_resources[1].start = INT_7XX_USB_HHC_1;
 
- 	pdata->ohci_device = &ohci_device;
 
- 	pdata->ocpi_enable = &ocpi_enable;
 
- }
 
- #else
 
- static inline void ohci_device_init(struct omap_usb_config *pdata)
 
- {
 
- }
 
- #endif
 
- #if	defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
 
- static struct resource otg_resources[] = {
 
- 	/* order is significant! */
 
- 	{
 
- 		.start		= OTG_BASE,
 
- 		.end		= OTG_BASE + 0xff,
 
- 		.flags		= IORESOURCE_MEM,
 
- 	}, {
 
- 		.start		= INT_USB_IRQ_OTG,
 
- 		.flags		= IORESOURCE_IRQ,
 
- 	},
 
- };
 
- static struct platform_device otg_device = {
 
- 	.name		= "omap_otg",
 
- 	.id		= -1,
 
- 	.num_resources	= ARRAY_SIZE(otg_resources),
 
- 	.resource	= otg_resources,
 
- };
 
- static inline void otg_device_init(struct omap_usb_config *pdata)
 
- {
 
- 	if (cpu_is_omap7xx())
 
- 		otg_resources[1].start = INT_7XX_USB_OTG;
 
- 	pdata->otg_device = &otg_device;
 
- }
 
- #else
 
- static inline void otg_device_init(struct omap_usb_config *pdata)
 
- {
 
- }
 
 
  |