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
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 ***************************************************************************
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).
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)
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)
56 /*-------------------------------------------------------------------------*/
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
= {
83 .release
= usb_release
,
85 .num_resources
= ARRAY_SIZE(ehci_host_resources
),
86 .resource
= ehci_host_resources
,
90 * USB OTG module structures.
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
= {
109 .release
= usb_release
,
111 .num_resources
= ARRAY_SIZE(ehci_otg_resources
),
112 .resource
= ehci_otg_resources
,
116 typedef volatile u8 vuint8
; /* 8 bits */
119 mcf532x_usb_init(void)
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);
137 #error "CONFIG_CLOCK_240MHz or CONFIG_CLOCK_180MHz must be defined for MCF532x."
140 * Register USB Host device:
142 status
= platform_device_register(&ehci_host_device
);
145 ("USB-MCF532x: Can't register MCF532x USB Host device, %d\n",
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
);
160 ("USB-MCF532x: Can't register MCF532x USB OTG device, %d\n",
164 pr_info("USB-MCF532x: MCF532x USB OTG device is registered\n");
170 subsys_initcall(mcf532x_usb_init
);