diff options
author | Shawn Guo <shawn.guo@freescale.com> | 2010-12-09 10:12:47 -0500 |
---|---|---|
committer | Uwe Kleine-König <u.kleine-koenig@pengutronix.de> | 2010-12-20 11:30:24 -0500 |
commit | b9a2ada8ff2ace20b1518a18872319d8619fe1ab (patch) | |
tree | c48add1ef989823e1ebfe20230e7758862d32dd1 /arch/arm/mach-mxs | |
parent | dc38ad4052a50b9e73fdcc970ecdd4f69ee9d97a (diff) |
ARM: mxs: Dynamically allocate fec devices
Dynamically allocate fec devices for MX28, which gets dual
fec interface.
Signed-off-by: Shawn Guo <shawn.guo@freescale.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mxs')
-rw-r--r-- | arch/arm/mach-mxs/devices-mx28.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-mxs/devices/platform-fec.c | 50 | ||||
-rw-r--r-- | arch/arm/mach-mxs/include/mach/devices-common.h | 12 |
3 files changed, 66 insertions, 0 deletions
diff --git a/arch/arm/mach-mxs/devices-mx28.h b/arch/arm/mach-mxs/devices-mx28.h index 47c2f0408ec3..00b736c434ba 100644 --- a/arch/arm/mach-mxs/devices-mx28.h +++ b/arch/arm/mach-mxs/devices-mx28.h | |||
@@ -14,3 +14,7 @@ | |||
14 | extern const struct mxs_duart_data mx28_duart_data __initconst; | 14 | extern const struct mxs_duart_data mx28_duart_data __initconst; |
15 | #define mx28_add_duart() \ | 15 | #define mx28_add_duart() \ |
16 | mxs_add_duart(&mx28_duart_data) | 16 | mxs_add_duart(&mx28_duart_data) |
17 | |||
18 | extern const struct mxs_fec_data mx28_fec_data[] __initconst; | ||
19 | #define mx28_add_fec(id, pdata) \ | ||
20 | mxs_add_fec(&mx28_fec_data[id], pdata) | ||
diff --git a/arch/arm/mach-mxs/devices/platform-fec.c b/arch/arm/mach-mxs/devices/platform-fec.c new file mode 100644 index 000000000000..c08168cf3dec --- /dev/null +++ b/arch/arm/mach-mxs/devices/platform-fec.c | |||
@@ -0,0 +1,50 @@ | |||
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("fec", data->id, | ||
49 | res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); | ||
50 | } | ||
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h index 07b44392cfd3..3da48d4d3273 100644 --- a/arch/arm/mach-mxs/include/mach/devices-common.h +++ b/arch/arm/mach-mxs/include/mach/devices-common.h | |||
@@ -32,3 +32,15 @@ struct mxs_duart_data { | |||
32 | }; | 32 | }; |
33 | struct platform_device *__init mxs_add_duart( | 33 | struct platform_device *__init mxs_add_duart( |
34 | const struct mxs_duart_data *data); | 34 | const struct mxs_duart_data *data); |
35 | |||
36 | /* fec */ | ||
37 | #include <linux/fec.h> | ||
38 | struct mxs_fec_data { | ||
39 | int id; | ||
40 | resource_size_t iobase; | ||
41 | resource_size_t iosize; | ||
42 | resource_size_t irq; | ||
43 | }; | ||
44 | struct platform_device *__init mxs_add_fec( | ||
45 | const struct mxs_fec_data *data, | ||
46 | const struct fec_platform_data *pdata); | ||