add support for titan variant (WRTP54G) (#6185)
[openwrt/openwrt.git] / target / linux / ar7 / patches-2.6.30 / 930-titan-platform.patch
1 --- a/arch/mips/ar7/platform.c 2009-11-18 14:57:44.000000000 +0800
2 +++ b/arch/mips/ar7/platform.c 2009-11-18 15:43:04.000000000 +0800
3 @@ -128,6 +128,36 @@
4 },
5 };
6
7 +static struct resource cpmac_low_res_titan[] = {
8 + {
9 + .name = "regs",
10 + .flags = IORESOURCE_MEM,
11 + .start = TITAN_REGS_MAC0,
12 + .end = TITAN_REGS_MAC0 + 0x7ff,
13 + },
14 + {
15 + .name = "irq",
16 + .flags = IORESOURCE_IRQ,
17 + .start = 27,
18 + .end = 27,
19 + },
20 +};
21 +
22 +static struct resource cpmac_high_res_titan[] = {
23 + {
24 + .name = "regs",
25 + .flags = IORESOURCE_MEM,
26 + .start = TITAN_REGS_MAC1,
27 + .end = TITAN_REGS_MAC1 + 0x7ff,
28 + },
29 + {
30 + .name = "irq",
31 + .flags = IORESOURCE_IRQ,
32 + .start = 41,
33 + .end = 41,
34 + },
35 +};
36 +
37 static struct resource vlynq_low_res[] = {
38 {
39 .name = "regs",
40 @@ -182,6 +212,60 @@
41 },
42 };
43
44 +static struct resource vlynq_low_res_titan[] = {
45 + {
46 + .name = "regs",
47 + .flags = IORESOURCE_MEM,
48 + .start = TITAN_REGS_VLYNQ0,
49 + .end = TITAN_REGS_VLYNQ0 + 0xff,
50 + },
51 + {
52 + .name = "irq",
53 + .flags = IORESOURCE_IRQ,
54 + .start = 33,
55 + .end = 33,
56 + },
57 + {
58 + .name = "mem",
59 + .flags = IORESOURCE_MEM,
60 + .start = 0x0c000000,
61 + .end = 0x0fffffff,
62 + },
63 + {
64 + .name = "devirq",
65 + .flags = IORESOURCE_IRQ,
66 + .start = 80,
67 + .end = 111,
68 + },
69 +};
70 +
71 +static struct resource vlynq_high_res_titan[] = {
72 + {
73 + .name = "regs",
74 + .flags = IORESOURCE_MEM,
75 + .start = TITAN_REGS_VLYNQ1,
76 + .end = TITAN_REGS_VLYNQ1 + 0xff,
77 + },
78 + {
79 + .name = "irq",
80 + .flags = IORESOURCE_IRQ,
81 + .start = 34,
82 + .end = 34,
83 + },
84 + {
85 + .name = "mem",
86 + .flags = IORESOURCE_MEM,
87 + .start = 0x40000000,
88 + .end = 0x43ffffff,
89 + },
90 + {
91 + .name = "devirq",
92 + .flags = IORESOURCE_IRQ,
93 + .start = 112,
94 + .end = 143,
95 + },
96 +};
97 +
98 static struct resource usb_res[] = {
99 {
100 .name = "regs",
101 @@ -226,6 +310,18 @@
102 .phy_mask = 0x7fffffff,
103 };
104
105 +static struct plat_cpmac_data cpmac_low_data_titan = {
106 + .reset_bit = 17,
107 + .power_bit = 20,
108 + .phy_mask = 0x40000000,
109 +};
110 +
111 +static struct plat_cpmac_data cpmac_high_data_titan = {
112 + .reset_bit = 21,
113 + .power_bit = 22,
114 + .phy_mask = 0x80000000,
115 +};
116 +
117 static struct plat_vlynq_data vlynq_low_data = {
118 .ops.on = vlynq_on,
119 .ops.off = vlynq_off,
120 @@ -240,6 +336,20 @@
121 .gpio_bit = 19,
122 };
123
124 +static struct plat_vlynq_data vlynq_low_data_titan = {
125 + .ops.on = vlynq_on,
126 + .ops.off = vlynq_off,
127 + .reset_bit = 15,
128 + .gpio_bit = 14,
129 +};
130 +
131 +static struct plat_vlynq_data vlynq_high_data_titan = {
132 + .ops.on = vlynq_on,
133 + .ops.off = vlynq_off,
134 + .reset_bit = 16,
135 + .gpio_bit = 7,
136 +};
137 +
138 static struct platform_device physmap_flash = {
139 .id = 0,
140 .name = "physmap-flash",
141 @@ -273,6 +383,30 @@
142 .num_resources = ARRAY_SIZE(cpmac_high_res),
143 };
144
145 +static struct platform_device cpmac_low_titan = {
146 + .id = 0,
147 + .name = "cpmac",
148 + .dev = {
149 + .dma_mask = &cpmac_dma_mask,
150 + .coherent_dma_mask = DMA_32BIT_MASK,
151 + .platform_data = &cpmac_low_data_titan,
152 + },
153 + .resource = cpmac_low_res_titan,
154 + .num_resources = ARRAY_SIZE(cpmac_low_res_titan),
155 +};
156 +
157 +static struct platform_device cpmac_high_titan = {
158 + .id = 1,
159 + .name = "cpmac",
160 + .dev = {
161 + .dma_mask = &cpmac_dma_mask,
162 + .coherent_dma_mask = DMA_32BIT_MASK,
163 + .platform_data = &cpmac_high_data_titan,
164 + },
165 + .resource = cpmac_high_res_titan,
166 + .num_resources = ARRAY_SIZE(cpmac_high_res_titan),
167 +};
168 +
169 static struct platform_device vlynq_low = {
170 .id = 0,
171 .name = "vlynq",
172 @@ -289,6 +423,22 @@
173 .num_resources = ARRAY_SIZE(vlynq_high_res),
174 };
175
176 +static struct platform_device vlynq_low_titan = {
177 + .id = 0,
178 + .name = "vlynq",
179 + .dev.platform_data = &vlynq_low_data_titan,
180 + .resource = vlynq_low_res_titan,
181 + .num_resources = ARRAY_SIZE(vlynq_low_res_titan),
182 +};
183 +
184 +static struct platform_device vlynq_high_titan = {
185 + .id = 1,
186 + .name = "vlynq",
187 + .dev.platform_data = &vlynq_high_data_titan,
188 + .resource = vlynq_high_res_titan,
189 + .num_resources = ARRAY_SIZE(vlynq_high_res_titan),
190 +};
191 +
192
193 /* This is proper way to define uart ports, but they are then detected
194 * as xscale and, obviously, don't work...
195 @@ -333,6 +483,11 @@
196 { .name = "status", .gpio = 8, .active_low = 1, },
197 };
198
199 +static struct gpio_led titan_leds[] = {
200 + { .name = "status", .gpio = 8, .active_low = 1, },
201 + { .name = "wifi", .gpio = 13, .active_low = 1, },
202 +};
203 +
204 static struct gpio_led dsl502t_leds[] = {
205 { .name = "status", .gpio = 9, .active_low = 1, },
206 { .name = "ethernet", .gpio = 7, .active_low = 1, },
207 @@ -425,7 +580,7 @@
208 /* FIXME: the whole thing is unreliable */
209 prId = prom_getenv("ProductID");
210 usb_prod = prom_getenv("usb_prod");
211 -
212 +
213 /* If we can't get the product id from PROM, use the default LEDs */
214 if (!prId)
215 return;
216 @@ -442,6 +597,9 @@
217 } else if (strstr(prId, "DG834")) {
218 ar7_led_data.num_leds = ARRAY_SIZE(dg834g_leds);
219 ar7_led_data.leds = dg834g_leds;
220 + } else if (strstr(prId, "CYWM")) {
221 + ar7_led_data.num_leds = ARRAY_SIZE(titan_leds);
222 + ar7_led_data.leds = titan_leds;
223 }
224 }
225
226 @@ -502,14 +660,18 @@
227 if (res)
228 return res;
229
230 - ar7_device_disable(vlynq_low_data.reset_bit);
231 - res = platform_device_register(&vlynq_low);
232 + ar7_device_disable(ar7_is_titan() ? vlynq_low_data_titan.reset_bit :
233 + vlynq_low_data.reset_bit);
234 + res = platform_device_register(ar7_is_titan() ? &vlynq_low_titan :
235 + &vlynq_low);
236 if (res)
237 return res;
238
239 if (ar7_has_high_vlynq()) {
240 - ar7_device_disable(vlynq_high_data.reset_bit);
241 - res = platform_device_register(&vlynq_high);
242 + ar7_device_disable(ar7_is_titan() ? vlynq_high_data_titan.reset_bit :
243 + vlynq_high_data.reset_bit);
244 + res = platform_device_register(ar7_is_titan() ? &vlynq_high_titan :
245 + &vlynq_high);
246 if (res)
247 return res;
248 }