MOXA linux-2.6.x / linux-2.6.19-uc1 from UC-7110-LX-BOOTLOADER-1.9_VERSION-4.2.tgz
[linux-2.6.19-moxart.git] / arch / m68knommu / platform / 532x / usb-mcf532x.c
blobc2a13b5c89a7a738d56c25dbdc8d12addd3e1265
1 /***************************************************************************
2 * usb-mcf532x.c - Platform level (mcf532x) USB initialization.
4 * Andrey Butok Andrey.Butok@freescale.com.
5 * Copyright Freescale Semiconductor, Inc 2006
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software Foundation,
19 * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 ***************************************************************************
22 * Changes:
23 * v0.01 31 March 2006 Andrey Butok
24 * Initial Release - developed on uClinux with 2.6.15.6 kernel
26 * WARNING: The MCF532x USB functionality was tested
27 * only with low-speed USB devices (cause of HW bugs).
30 #undef DEBUG
32 #include <linux/module.h>
33 #include <linux/kernel.h>
34 #include <linux/types.h>
35 #include <linux/errno.h>
36 #include <linux/init.h>
37 #include <linux/device.h>
38 #include <linux/platform_device.h>
40 /* Start address of HC registers.*/
41 #define MCF532x_USB_HOST_REG_START (0xfc0b4000)
42 /* End address of HC registers */
43 #define MCF532x_USB_HOST_REG_END (MCF532x_USB_HOST_REG_START+0x200)
44 /* USB Host Interrupt number */
45 #define MCF532x_USB_HOST_INT_NUMBER (128+48)
47 #ifdef CONFIG_USB_OTG
48 /* Start address of OTG module registers.*/
49 #define MCF532x_USB_OTG_REG_START (0xfc0b0000)
50 /* End address of OTG module registers */
51 #define MCF532x_USB_OTG_REG_END (MCF532x_USB_OTG_REG_START+0x200)
52 /* USB OTG Interrupt number */
53 #define MCF532x_USB_OTG_INT_NUMBER (128+47)
54 #endif
56 /*-------------------------------------------------------------------------*/
58 static void
59 usb_release(struct device *dev)
61 /* normally not freed */
65 * USB Host module structures
67 static struct resource ehci_host_resources[] = {
69 .start = MCF532x_USB_HOST_REG_START,
70 .end = MCF532x_USB_HOST_REG_END,
71 .flags = IORESOURCE_MEM,
74 .start = MCF532x_USB_HOST_INT_NUMBER,
75 .flags = IORESOURCE_IRQ,
79 static struct platform_device ehci_host_device = {
80 .name = "ehci",
81 .id = 1,
82 .dev = {
83 .release = usb_release,
84 .dma_mask = 0x0},
85 .num_resources = ARRAY_SIZE(ehci_host_resources),
86 .resource = ehci_host_resources,
90 * USB OTG module structures.
92 #ifdef CONFIG_USB_OTG
93 static struct resource ehci_otg_resources[] = {
95 .start = MCF532x_USB_OTG_REG_START,
96 .end = MCF532x_USB_OTG_REG_END,
97 .flags = IORESOURCE_MEM,
100 .start = MCF532x_USB_OTG_INT_NUMBER,
101 .flags = IORESOURCE_IRQ,
105 static struct platform_device ehci_otg_device = {
106 .name = "ehci",
107 .id = 0,
108 .dev = {
109 .release = usb_release,
110 .dma_mask = 0x0},
111 .num_resources = ARRAY_SIZE(ehci_otg_resources),
112 .resource = ehci_otg_resources,
114 #endif
116 typedef volatile u8 vuint8; /* 8 bits */
118 static int __init
119 mcf532x_usb_init(void)
121 int status;
124 * Initialize the clock divider for the USB:
126 #ifdef CONFIG_CLOCK_240MHz
128 * CPU oerating on 240Mhz (MISCCR[USBDIV]=1)
130 (*(volatile u16 *) (0xFC0A0010)) |= (0x0002);
131 #elif defined(CONFIG_CLOCK_180MHz)
133 * CPU oerating on 180Mhz (MISCCR[USBDIV]=0)
135 (*(volatile u16 *) (0xFC0A0010)) |= ~(0x0002);
136 #else
137 #error "CONFIG_CLOCK_240MHz or CONFIG_CLOCK_180MHz must be defined for MCF532x."
138 #endif
140 * Register USB Host device:
142 status = platform_device_register(&ehci_host_device);
143 if (status) {
144 pr_info
145 ("USB-MCF532x: Can't register MCF532x USB Host device, %d\n",
146 status);
147 return -ENODEV;
149 pr_info("USB-MCF532x: MCF532x USB Host device is registered\n");
151 #ifdef CONFIG_USB_OTG
153 * Register USB OTG device:
154 * Done only USB Host.
155 * TODO: Device and OTG functinality.
157 status = platform_device_register(&ehci_otg_device);
158 if (status) {
159 pr_info
160 ("USB-MCF532x: Can't register MCF532x USB OTG device, %d\n",
161 status);
162 return -ENODEV;
164 pr_info("USB-MCF532x: MCF532x USB OTG device is registered\n");
165 #endif
167 return 0;
170 subsys_initcall(mcf532x_usb_init);