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 #include <linux/sizes.h>
8
9 #include "../hardware.h"
10 #include "devices-common.h"
11
12 #define imx_fec_data_entry_single(soc, _devid) \
13 { \
14 .devid = _devid, \
15 .iobase = soc ## _FEC_BASE_ADDR, \
16 .irq = soc ## _INT_FEC, \
17 }
18
19 #ifdef CONFIG_SOC_IMX27
20 const struct imx_fec_data imx27_fec_data __initconst =
21 imx_fec_data_entry_single(MX27, "imx27-fec");
22 #endif /* ifdef CONFIG_SOC_IMX27 */
23
24 #ifdef CONFIG_SOC_IMX35
25 /* i.mx35 has the i.mx27 type fec */
26 const struct imx_fec_data imx35_fec_data __initconst =
27 imx_fec_data_entry_single(MX35, "imx27-fec");
28 #endif
29
imx_add_fec(const struct imx_fec_data * data,const struct fec_platform_data * pdata)30 struct platform_device *__init imx_add_fec(
31 const struct imx_fec_data *data,
32 const struct fec_platform_data *pdata)
33 {
34 struct resource res[] = {
35 {
36 .start = data->iobase,
37 .end = data->iobase + SZ_4K - 1,
38 .flags = IORESOURCE_MEM,
39 }, {
40 .start = data->irq,
41 .end = data->irq,
42 .flags = IORESOURCE_IRQ,
43 },
44 };
45
46 return imx_add_platform_device_dmamask(data->devid, 0,
47 res, ARRAY_SIZE(res),
48 pdata, sizeof(*pdata), DMA_BIT_MASK(32));
49 }
50