Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / arch / arm / mach-mxs / devices / platform-fec.c
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 <asm/sizes.h>
10 #include <mach/mx28.h>
11 #include <mach/devices-common.h>
12
13 #define mxs_fec_data_entry_single(soc, _id)                             \
14         {                                                               \
15                 .id = _id,                                              \
16                 .iobase = soc ## _ENET_MAC ## _id ## _BASE_ADDR,        \
17                 .irq = soc ## _INT_ENET_MAC ## _id,                     \
18         }
19
20 #define mxs_fec_data_entry(soc, _id)                                    \
21         [_id] = mxs_fec_data_entry_single(soc, _id)
22
23 #ifdef CONFIG_SOC_IMX28
24 const struct mxs_fec_data mx28_fec_data[] __initconst = {
25 #define mx28_fec_data_entry(_id)                                        \
26         mxs_fec_data_entry(MX28, _id)
27         mx28_fec_data_entry(0),
28         mx28_fec_data_entry(1),
29 };
30 #endif
31
32 struct platform_device *__init mxs_add_fec(
33                 const struct mxs_fec_data *data,
34                 const struct fec_platform_data *pdata)
35 {
36         struct resource res[] = {
37                 {
38                         .start = data->iobase,
39                         .end = data->iobase + SZ_16K - 1,
40                         .flags = IORESOURCE_MEM,
41                 }, {
42                         .start = data->irq,
43                         .end = data->irq,
44                         .flags = IORESOURCE_IRQ,
45                 },
46         };
47
48         return mxs_add_platform_device("imx28-fec", data->id,
49                         res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
50 }