1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2010 Pengutronix
4  * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
5  */
6 #include <linux/dma-mapping.h>
7 
8 #include "../hardware.h"
9 #include "devices-common.h"
10 
11 #define imx_mxc_ehci_data_entry_single(soc, _id, hs)			\
12 	{								\
13 		.id = _id,						\
14 		.iobase = soc ## _USB_ ## hs ## _BASE_ADDR,		\
15 		.irq = soc ## _INT_USB_ ## hs,				\
16 	}
17 
18 #ifdef CONFIG_SOC_IMX27
19 const struct imx_mxc_ehci_data imx27_mxc_ehci_otg_data __initconst =
20 	imx_mxc_ehci_data_entry_single(MX27, 0, OTG);
21 const struct imx_mxc_ehci_data imx27_mxc_ehci_hs_data[] __initconst = {
22 	imx_mxc_ehci_data_entry_single(MX27, 1, HS1),
23 	imx_mxc_ehci_data_entry_single(MX27, 2, HS2),
24 };
25 #endif /* ifdef CONFIG_SOC_IMX27 */
26 
27 #ifdef CONFIG_SOC_IMX31
28 const struct imx_mxc_ehci_data imx31_mxc_ehci_otg_data __initconst =
29 	imx_mxc_ehci_data_entry_single(MX31, 0, OTG);
30 const struct imx_mxc_ehci_data imx31_mxc_ehci_hs_data[] __initconst = {
31 	imx_mxc_ehci_data_entry_single(MX31, 1, HS1),
32 	imx_mxc_ehci_data_entry_single(MX31, 2, HS2),
33 };
34 #endif /* ifdef CONFIG_SOC_IMX31 */
35 
36 #ifdef CONFIG_SOC_IMX35
37 const struct imx_mxc_ehci_data imx35_mxc_ehci_otg_data __initconst =
38 	imx_mxc_ehci_data_entry_single(MX35, 0, OTG);
39 const struct imx_mxc_ehci_data imx35_mxc_ehci_hs_data __initconst =
40 	imx_mxc_ehci_data_entry_single(MX35, 1, HS);
41 #endif /* ifdef CONFIG_SOC_IMX35 */
42 
imx_add_mxc_ehci(const struct imx_mxc_ehci_data * data,const struct mxc_usbh_platform_data * pdata)43 struct platform_device *__init imx_add_mxc_ehci(
44 		const struct imx_mxc_ehci_data *data,
45 		const struct mxc_usbh_platform_data *pdata)
46 {
47 	struct resource res[] = {
48 		{
49 			.start = data->iobase,
50 			.end = data->iobase + SZ_512 - 1,
51 			.flags = IORESOURCE_MEM,
52 		}, {
53 			.start = data->irq,
54 			.end = data->irq,
55 			.flags = IORESOURCE_IRQ,
56 		},
57 	};
58 	return imx_add_platform_device_dmamask("mxc-ehci", data->id,
59 			res, ARRAY_SIZE(res),
60 			pdata, sizeof(*pdata), DMA_BIT_MASK(32));
61 }
62