Skip to content

Commit e083000

Browse files
author
Uwe Kleine-König
committed
ARM: imx: dynamically allocate imx_udc device
This is only available for mx1 machines with no in-tree user. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
1 parent 300f86d commit e083000

File tree

7 files changed

+103
-52
lines changed

7 files changed

+103
-52
lines changed

arch/arm/mach-imx/devices.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,49 +70,6 @@ struct platform_device imx1_camera_device = {
7070
.num_resources = ARRAY_SIZE(imx1_camera_resources),
7171
};
7272

73-
static struct resource imx_usb_resources[] = {
74-
{
75-
.start = 0x00212000,
76-
.end = 0x00212148,
77-
.flags = IORESOURCE_MEM,
78-
}, {
79-
.start = MX1_USBD_INT0,
80-
.end = MX1_USBD_INT0,
81-
.flags = IORESOURCE_IRQ,
82-
}, {
83-
.start = MX1_USBD_INT1,
84-
.end = MX1_USBD_INT1,
85-
.flags = IORESOURCE_IRQ,
86-
}, {
87-
.start = MX1_USBD_INT2,
88-
.end = MX1_USBD_INT2,
89-
.flags = IORESOURCE_IRQ,
90-
}, {
91-
.start = MX1_USBD_INT3,
92-
.end = MX1_USBD_INT3,
93-
.flags = IORESOURCE_IRQ,
94-
}, {
95-
.start = MX1_USBD_INT4,
96-
.end = MX1_USBD_INT4,
97-
.flags = IORESOURCE_IRQ,
98-
}, {
99-
.start = MX1_USBD_INT5,
100-
.end = MX1_USBD_INT5,
101-
.flags = IORESOURCE_IRQ,
102-
}, {
103-
.start = MX1_USBD_INT6,
104-
.end = MX1_USBD_INT6,
105-
.flags = IORESOURCE_IRQ,
106-
},
107-
};
108-
109-
struct platform_device imx_usb_device = {
110-
.name = "imx_udc",
111-
.id = 0,
112-
.num_resources = ARRAY_SIZE(imx_usb_resources),
113-
.resource = imx_usb_resources,
114-
};
115-
11673
/* GPIO port description */
11774
static struct mxc_gpio_port imx_gpio_ports[] = {
11875
{

arch/arm/mach-imx/devices.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#ifdef CONFIG_ARCH_MX1
22
extern struct platform_device imx1_camera_device;
3-
extern struct platform_device imx_usb_device;
43
#endif
54

65
#if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)

arch/arm/plat-mxc/devices/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ config IMX_HAVE_PLATFORM_IMX_SSI
2222
config IMX_HAVE_PLATFORM_IMX_UART
2323
bool
2424

25+
config IMX_HAVE_PLATFORM_IMX_UDC
26+
bool
27+
2528
config IMX_HAVE_PLATFORM_MXC_NAND
2629
bool
2730

arch/arm/plat-mxc/devices/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ obj-y += platform-imx-dma.o
66
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_I2C) += platform-imx-i2c.o
77
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_SSI) += platform-imx-ssi.o
88
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UART) += platform-imx-uart.o
9+
obj-$(CONFIG_IMX_HAVE_PLATFORM_IMX_UDC) += platform-imx_udc.o
910
obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_NAND) += platform-mxc_nand.o
1011
obj-$(CONFIG_IMX_HAVE_PLATFORM_MXC_W1) += platform-mxc_w1.o
1112
obj-$(CONFIG_IMX_HAVE_PLATFORM_SPI_IMX) += platform-spi_imx.o
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (C) 2010 Pengutronix
3+
* Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
4+
*
5+
* This program is free software; you can redistribute it and/or modify it under
6+
* the terms of the GNU General Public License version 2 as published by the
7+
* Free Software Foundation.
8+
*/
9+
#include <mach/hardware.h>
10+
#include <mach/devices-common.h>
11+
12+
#define imx_imx_udc_data_entry_single(soc, _size) \
13+
{ \
14+
.iobase = soc ## _USBD_BASE_ADDR, \
15+
.iosize = _size, \
16+
.irq0 = soc ## _INT_USBD0, \
17+
.irq1 = soc ## _INT_USBD1, \
18+
.irq2 = soc ## _INT_USBD2, \
19+
.irq3 = soc ## _INT_USBD3, \
20+
.irq4 = soc ## _INT_USBD4, \
21+
.irq5 = soc ## _INT_USBD5, \
22+
.irq6 = soc ## _INT_USBD6, \
23+
}
24+
25+
#define imx_imx_udc_data_entry(soc, _size) \
26+
[_id] = imx_imx_udc_data_entry_single(soc, _size)
27+
28+
#ifdef CONFIG_SOC_IMX1
29+
const struct imx_imx_udc_data imx1_imx_udc_data __initconst =
30+
imx_imx_udc_data_entry_single(MX1, SZ_4K);
31+
#endif /* ifdef CONFIG_SOC_IMX1 */
32+
33+
struct platform_device *__init imx_add_imx_udc(
34+
const struct imx_imx_udc_data *data,
35+
const struct imxusb_platform_data *pdata)
36+
{
37+
struct resource res[] = {
38+
{
39+
.start = data->iobase,
40+
.end = data->iobase + data->iosize - 1,
41+
.flags = IORESOURCE_MEM,
42+
}, {
43+
.start = data->irq0,
44+
.end = data->irq0,
45+
.flags = IORESOURCE_IRQ,
46+
}, {
47+
.start = data->irq1,
48+
.end = data->irq1,
49+
.flags = IORESOURCE_IRQ,
50+
}, {
51+
.start = data->irq2,
52+
.end = data->irq2,
53+
.flags = IORESOURCE_IRQ,
54+
}, {
55+
.start = data->irq3,
56+
.end = data->irq3,
57+
.flags = IORESOURCE_IRQ,
58+
}, {
59+
.start = data->irq4,
60+
.end = data->irq4,
61+
.flags = IORESOURCE_IRQ,
62+
}, {
63+
.start = data->irq5,
64+
.end = data->irq5,
65+
.flags = IORESOURCE_IRQ,
66+
}, {
67+
.start = data->irq6,
68+
.end = data->irq6,
69+
.flags = IORESOURCE_IRQ,
70+
},
71+
};
72+
73+
return imx_add_platform_device("imx_udc", 0,
74+
res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
75+
}

arch/arm/plat-mxc/include/mach/devices-common.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,22 @@ struct platform_device *__init imx_add_imx_uart_1irq(
8282
const struct imx_imx_uart_1irq_data *data,
8383
const struct imxuart_platform_data *pdata);
8484

85+
#include <mach/usb.h>
86+
struct imx_imx_udc_data {
87+
resource_size_t iobase;
88+
resource_size_t iosize;
89+
resource_size_t irq0;
90+
resource_size_t irq1;
91+
resource_size_t irq2;
92+
resource_size_t irq3;
93+
resource_size_t irq4;
94+
resource_size_t irq5;
95+
resource_size_t irq6;
96+
};
97+
struct platform_device *__init imx_add_imx_udc(
98+
const struct imx_imx_udc_data *data,
99+
const struct imxusb_platform_data *pdata);
100+
85101
#include <mach/mxc_nand.h>
86102
struct imx_mxc_nand_data {
87103
/*

arch/arm/plat-mxc/include/mach/mx1.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,13 @@
114114
#define MX1_SSI_RX_INT 44
115115
#define MX1_SSI_RX_ERR_INT 45
116116
#define MX1_TOUCH_INT 46
117-
#define MX1_USBD_INT0 47
118-
#define MX1_USBD_INT1 48
119-
#define MX1_USBD_INT2 49
120-
#define MX1_USBD_INT3 50
121-
#define MX1_USBD_INT4 51
122-
#define MX1_USBD_INT5 52
123-
#define MX1_USBD_INT6 53
117+
#define MX1_INT_USBD0 47
118+
#define MX1_INT_USBD1 48
119+
#define MX1_INT_USBD2 49
120+
#define MX1_INT_USBD3 50
121+
#define MX1_INT_USBD4 51
122+
#define MX1_INT_USBD5 52
123+
#define MX1_INT_USBD6 53
124124
#define MX1_BTSYS_INT 55
125125
#define MX1_BTTIM_INT 56
126126
#define MX1_BTWUI_INT 57
@@ -163,6 +163,6 @@
163163
* to not break drivers/usb/gadget/imx_udc. Should go
164164
* away after this driver uses the new name.
165165
*/
166-
#define USBD_INT0 MX1_USBD_INT0
166+
#define USBD_INT0 MX1_INT_USBD0
167167

168168
#endif /* ifndef __MACH_MX1_H__ */

0 commit comments

Comments
 (0)