gemini: switch to 3.8
[openwrt.git] / target / linux / gemini / patches-3.3 / 121-arm-gemini-add-ethernet-device.patch
1 --- a/arch/arm/mach-gemini/common.h
2 +++ b/arch/arm/mach-gemini/common.h
3 @@ -13,6 +13,7 @@
4  #define __GEMINI_COMMON_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 @@ -26,5 +27,6 @@ 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  #endif /* __GEMINI_COMMON_H__ */
18 --- a/arch/arm/mach-gemini/devices.c
19 +++ b/arch/arm/mach-gemini/devices.c
20 @@ -17,6 +17,7 @@
21  #include <mach/irqs.h>
22  #include <mach/hardware.h>
23  #include <mach/global_reg.h>
24 +#include <mach/gmac.h>
25  #include "common.h"
26  
27  static struct plat_serial8250_port serial_platform_data[] = {
28 @@ -134,3 +135,53 @@ int __init platform_register_watchdog(vo
29  {
30         return platform_device_register(&wdt_device);
31  }
32 +
33 +static struct resource gmac_resources[] = {
34 +       {
35 +               .start  = 0x60000000,
36 +               .end    = 0x6000ffff,
37 +               .flags  = IORESOURCE_MEM,
38 +       },
39 +       {
40 +               .start  = IRQ_GMAC0,
41 +               .end    = IRQ_GMAC0,
42 +               .flags  = IORESOURCE_IRQ,
43 +       },
44 +       {
45 +               .start  = IRQ_GMAC1,
46 +               .end    = IRQ_GMAC1,
47 +               .flags  = IORESOURCE_IRQ,
48 +       },
49 +};
50 +
51 +static u64 gmac_dmamask = 0xffffffffUL;
52 +
53 +static struct platform_device ethernet_device = {
54 +       .name   = "gemini-gmac",
55 +       .id     = 0,
56 +       .dev    = {
57 +               .dma_mask = &gmac_dmamask,
58 +               .coherent_dma_mask = DMA_BIT_MASK(32),
59 +       },
60 +       .num_resources  = ARRAY_SIZE(gmac_resources),
61 +       .resource       = gmac_resources,
62 +};
63 +
64 +int __init platform_register_ethernet(struct gemini_gmac_platform_data *pdata)
65 +{
66 +       unsigned int reg;
67 +
68 +       reg = __raw_readl(IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
69 +       reg &= ~(GMAC_GMII | GMAC_1_ENABLE);
70 +
71 +       if (pdata->bus_id[1])
72 +               reg |= GMAC_1_ENABLE;
73 +       else if (pdata->interface[0] == PHY_INTERFACE_MODE_GMII)
74 +               reg |= GMAC_GMII;
75 +
76 +       __raw_writel(reg, IO_ADDRESS(GEMINI_GLOBAL_BASE) + GLOBAL_MISC_CTRL);
77 +
78 +       ethernet_device.dev.platform_data = pdata;
79 +
80 +       return platform_device_register(&ethernet_device);
81 +}