gemini: rename patches directory to patches-4.4
[openwrt/openwrt.git] / target / linux / gemini / patches-4.4 / 121-arm-gemini-add-gmac-device.patch
1 --- a/arch/arm/mach-gemini/common.h
2 +++ b/arch/arm/mach-gemini/common.h
3 @@ -15,6 +15,7 @@
4 #include <linux/reboot.h>
5
6 struct mtd_partition;
7 +struct gemini_gmac_platform_data;
8
9 extern void gemini_map_io(void);
10 extern void gemini_init_irq(void);
11 @@ -28,6 +29,7 @@ extern int platform_register_pflash(unsi
12 struct mtd_partition *parts,
13 unsigned int nr_parts);
14 extern int platform_register_watchdog(void);
15 +extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
16
17 extern void gemini_restart(enum reboot_mode mode, const char *cmd);
18
19 --- a/arch/arm/mach-gemini/devices.c
20 +++ b/arch/arm/mach-gemini/devices.c
21 @@ -17,6 +17,7 @@
22 #include <mach/irqs.h>
23 #include <mach/hardware.h>
24 #include <mach/global_reg.h>
25 +#include <mach/gmac.h>
26
27 static struct plat_serial8250_port serial_platform_data[] = {
28 {
29 @@ -133,3 +134,56 @@ int __init platform_register_watchdog(vo
30 {
31 return platform_device_register(&wdt_device);
32 }
33 +
34 +static struct resource gmac_resources[] = {
35 + {
36 + .start = GEMINI_TOE_BASE,
37 + .end = GEMINI_TOE_BASE + 0xffff,
38 + .flags = IORESOURCE_MEM,
39 + },
40 + {
41 + .start = IRQ_GMAC0,
42 + .end = IRQ_GMAC0,
43 + .flags = IORESOURCE_IRQ,
44 + },
45 + {
46 + .start = IRQ_GMAC1,
47 + .end = IRQ_GMAC1,
48 + .flags = IORESOURCE_IRQ,
49 + },
50 +};
51 +
52 +static u64 gmac_dmamask = 0xffffffffUL;
53 +
54 +static struct platform_device ethernet_device = {
55 + .name = "gmac-gemini",
56 + .id = 0,
57 + .dev = {
58 + .dma_mask = &gmac_dmamask,
59 + .coherent_dma_mask = 0xffffffff,
60 + },
61 + .num_resources = ARRAY_SIZE(gmac_resources),
62 + .resource = gmac_resources,
63 +};
64 +
65 +int platform_register_ethernet(struct gemini_gmac_platform_data *pdata)
66 +{
67 + unsigned int reg;
68 +
69 + reg = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
70 + GLOBAL_MISC_CTRL));
71 +
72 + reg &= ~(GMAC_GMII | GMAC_1_ENABLE);
73 +
74 + if (pdata->bus_id[1])
75 + reg |= GMAC_1_ENABLE;
76 + else if (pdata->interface[0] == PHY_INTERFACE_MODE_GMII)
77 + reg |= GMAC_GMII;
78 +
79 + writel(reg, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
80 + GLOBAL_MISC_CTRL));
81 +
82 + ethernet_device.dev.platform_data = pdata;
83 +
84 + return platform_device_register(&ethernet_device);
85 +}