diff options
Diffstat (limited to 'arch/arm/mach-orion5x/ts209-setup.c')
-rw-r--r-- | arch/arm/mach-orion5x/ts209-setup.c | 299 |
1 files changed, 93 insertions, 206 deletions
diff --git a/arch/arm/mach-orion5x/ts209-setup.c b/arch/arm/mach-orion5x/ts209-setup.c index 9afb41ee6e07..a9cef9703d5b 100644 --- a/arch/arm/mach-orion5x/ts209-setup.c +++ b/arch/arm/mach-orion5x/ts209-setup.c | |||
@@ -28,6 +28,8 @@ | |||
28 | #include <asm/mach/pci.h> | 28 | #include <asm/mach/pci.h> |
29 | #include <asm/arch/orion5x.h> | 29 | #include <asm/arch/orion5x.h> |
30 | #include "common.h" | 30 | #include "common.h" |
31 | #include "mpp.h" | ||
32 | #include "tsx09-common.h" | ||
31 | 33 | ||
32 | #define QNAP_TS209_NOR_BOOT_BASE 0xf4000000 | 34 | #define QNAP_TS209_NOR_BOOT_BASE 0xf4000000 |
33 | #define QNAP_TS209_NOR_BOOT_SIZE SZ_8M | 35 | #define QNAP_TS209_NOR_BOOT_SIZE SZ_8M |
@@ -47,52 +49,54 @@ | |||
47 | ***************************************************************************/ | 49 | ***************************************************************************/ |
48 | static struct mtd_partition qnap_ts209_partitions[] = { | 50 | static struct mtd_partition qnap_ts209_partitions[] = { |
49 | { | 51 | { |
50 | .name = "U-Boot", | 52 | .name = "U-Boot", |
51 | .size = 0x00080000, | 53 | .size = 0x00080000, |
52 | .offset = 0x00780000, | 54 | .offset = 0x00780000, |
53 | .mask_flags = MTD_WRITEABLE, | 55 | .mask_flags = MTD_WRITEABLE, |
54 | }, { | 56 | }, { |
55 | .name = "Kernel", | 57 | .name = "Kernel", |
56 | .size = 0x00200000, | 58 | .size = 0x00200000, |
57 | .offset = 0, | 59 | .offset = 0, |
58 | }, { | 60 | }, { |
59 | .name = "RootFS1", | 61 | .name = "RootFS1", |
60 | .size = 0x00400000, | 62 | .size = 0x00400000, |
61 | .offset = 0x00200000, | 63 | .offset = 0x00200000, |
62 | }, { | 64 | }, { |
63 | .name = "RootFS2", | 65 | .name = "RootFS2", |
64 | .size = 0x00100000, | 66 | .size = 0x00100000, |
65 | .offset = 0x00600000, | 67 | .offset = 0x00600000, |
66 | }, { | 68 | }, { |
67 | .name = "U-Boot Config", | 69 | .name = "U-Boot Config", |
68 | .size = 0x00020000, | 70 | .size = 0x00020000, |
69 | .offset = 0x00760000, | 71 | .offset = 0x00760000, |
70 | }, { | 72 | }, { |
71 | .name = "NAS Config", | 73 | .name = "NAS Config", |
72 | .size = 0x00060000, | 74 | .size = 0x00060000, |
73 | .offset = 0x00700000, | 75 | .offset = 0x00700000, |
74 | .mask_flags = MTD_WRITEABLE, | 76 | .mask_flags = MTD_WRITEABLE, |
75 | } | 77 | }, |
76 | }; | 78 | }; |
77 | 79 | ||
78 | static struct physmap_flash_data qnap_ts209_nor_flash_data = { | 80 | static struct physmap_flash_data qnap_ts209_nor_flash_data = { |
79 | .width = 1, | 81 | .width = 1, |
80 | .parts = qnap_ts209_partitions, | 82 | .parts = qnap_ts209_partitions, |
81 | .nr_parts = ARRAY_SIZE(qnap_ts209_partitions) | 83 | .nr_parts = ARRAY_SIZE(qnap_ts209_partitions) |
82 | }; | 84 | }; |
83 | 85 | ||
84 | static struct resource qnap_ts209_nor_flash_resource = { | 86 | static struct resource qnap_ts209_nor_flash_resource = { |
85 | .flags = IORESOURCE_MEM, | 87 | .flags = IORESOURCE_MEM, |
86 | .start = QNAP_TS209_NOR_BOOT_BASE, | 88 | .start = QNAP_TS209_NOR_BOOT_BASE, |
87 | .end = QNAP_TS209_NOR_BOOT_BASE + QNAP_TS209_NOR_BOOT_SIZE - 1, | 89 | .end = QNAP_TS209_NOR_BOOT_BASE + QNAP_TS209_NOR_BOOT_SIZE - 1, |
88 | }; | 90 | }; |
89 | 91 | ||
90 | static struct platform_device qnap_ts209_nor_flash = { | 92 | static struct platform_device qnap_ts209_nor_flash = { |
91 | .name = "physmap-flash", | 93 | .name = "physmap-flash", |
92 | .id = 0, | 94 | .id = 0, |
93 | .dev = { .platform_data = &qnap_ts209_nor_flash_data, }, | 95 | .dev = { |
94 | .resource = &qnap_ts209_nor_flash_resource, | 96 | .platform_data = &qnap_ts209_nor_flash_data, |
95 | .num_resources = 1, | 97 | }, |
98 | .resource = &qnap_ts209_nor_flash_resource, | ||
99 | .num_resources = 1, | ||
96 | }; | 100 | }; |
97 | 101 | ||
98 | /***************************************************************************** | 102 | /***************************************************************************** |
@@ -164,12 +168,12 @@ static int __init qnap_ts209_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin) | |||
164 | } | 168 | } |
165 | 169 | ||
166 | static struct hw_pci qnap_ts209_pci __initdata = { | 170 | static struct hw_pci qnap_ts209_pci __initdata = { |
167 | .nr_controllers = 2, | 171 | .nr_controllers = 2, |
168 | .preinit = qnap_ts209_pci_preinit, | 172 | .preinit = qnap_ts209_pci_preinit, |
169 | .swizzle = pci_std_swizzle, | 173 | .swizzle = pci_std_swizzle, |
170 | .setup = orion5x_pci_sys_setup, | 174 | .setup = orion5x_pci_sys_setup, |
171 | .scan = orion5x_pci_sys_scan_bus, | 175 | .scan = orion5x_pci_sys_scan_bus, |
172 | .map_irq = qnap_ts209_pci_map_irq, | 176 | .map_irq = qnap_ts209_pci_map_irq, |
173 | }; | 177 | }; |
174 | 178 | ||
175 | static int __init qnap_ts209_pci_init(void) | 179 | static int __init qnap_ts209_pci_init(void) |
@@ -183,96 +187,6 @@ static int __init qnap_ts209_pci_init(void) | |||
183 | subsys_initcall(qnap_ts209_pci_init); | 187 | subsys_initcall(qnap_ts209_pci_init); |
184 | 188 | ||
185 | /***************************************************************************** | 189 | /***************************************************************************** |
186 | * Ethernet | ||
187 | ****************************************************************************/ | ||
188 | |||
189 | static struct mv643xx_eth_platform_data qnap_ts209_eth_data = { | ||
190 | .phy_addr = 8, | ||
191 | .force_phy_addr = 1, | ||
192 | }; | ||
193 | |||
194 | static int __init parse_hex_nibble(char n) | ||
195 | { | ||
196 | if (n >= '0' && n <= '9') | ||
197 | return n - '0'; | ||
198 | |||
199 | if (n >= 'A' && n <= 'F') | ||
200 | return n - 'A' + 10; | ||
201 | |||
202 | if (n >= 'a' && n <= 'f') | ||
203 | return n - 'a' + 10; | ||
204 | |||
205 | return -1; | ||
206 | } | ||
207 | |||
208 | static int __init parse_hex_byte(const char *b) | ||
209 | { | ||
210 | int hi; | ||
211 | int lo; | ||
212 | |||
213 | hi = parse_hex_nibble(b[0]); | ||
214 | lo = parse_hex_nibble(b[1]); | ||
215 | |||
216 | if (hi < 0 || lo < 0) | ||
217 | return -1; | ||
218 | |||
219 | return (hi << 4) | lo; | ||
220 | } | ||
221 | |||
222 | static int __init check_mac_addr(const char *addr_str) | ||
223 | { | ||
224 | u_int8_t addr[6]; | ||
225 | int i; | ||
226 | |||
227 | for (i = 0; i < 6; i++) { | ||
228 | int byte; | ||
229 | |||
230 | /* | ||
231 | * Enforce "xx:xx:xx:xx:xx:xx\n" format. | ||
232 | */ | ||
233 | if (addr_str[(i * 3) + 2] != ((i < 5) ? ':' : '\n')) | ||
234 | return -1; | ||
235 | |||
236 | byte = parse_hex_byte(addr_str + (i * 3)); | ||
237 | if (byte < 0) | ||
238 | return -1; | ||
239 | addr[i] = byte; | ||
240 | } | ||
241 | |||
242 | printk(KERN_INFO "ts209: found ethernet mac address "); | ||
243 | for (i = 0; i < 6; i++) | ||
244 | printk("%.2x%s", addr[i], (i < 5) ? ":" : ".\n"); | ||
245 | |||
246 | memcpy(qnap_ts209_eth_data.mac_addr, addr, 6); | ||
247 | |||
248 | return 0; | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * The 'NAS Config' flash partition has an ext2 filesystem which | ||
253 | * contains a file that has the ethernet MAC address in plain text | ||
254 | * (format "xx:xx:xx:xx:xx:xx\n".) | ||
255 | */ | ||
256 | static void __init ts209_find_mac_addr(void) | ||
257 | { | ||
258 | unsigned long addr; | ||
259 | |||
260 | for (addr = 0x00700000; addr < 0x00760000; addr += 1024) { | ||
261 | char *nor_page; | ||
262 | int ret = 0; | ||
263 | |||
264 | nor_page = ioremap(QNAP_TS209_NOR_BOOT_BASE + addr, 1024); | ||
265 | if (nor_page != NULL) { | ||
266 | ret = check_mac_addr(nor_page); | ||
267 | iounmap(nor_page); | ||
268 | } | ||
269 | |||
270 | if (ret == 0) | ||
271 | break; | ||
272 | } | ||
273 | } | ||
274 | |||
275 | /***************************************************************************** | ||
276 | * RTC S35390A on I2C bus | 190 | * RTC S35390A on I2C bus |
277 | ****************************************************************************/ | 191 | ****************************************************************************/ |
278 | 192 | ||
@@ -280,7 +194,7 @@ static void __init ts209_find_mac_addr(void) | |||
280 | 194 | ||
281 | static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = { | 195 | static struct i2c_board_info __initdata qnap_ts209_i2c_rtc = { |
282 | I2C_BOARD_INFO("s35390a", 0x30), | 196 | I2C_BOARD_INFO("s35390a", 0x30), |
283 | .irq = 0, | 197 | .irq = 0, |
284 | }; | 198 | }; |
285 | 199 | ||
286 | /**************************************************************************** | 200 | /**************************************************************************** |
@@ -297,70 +211,63 @@ static struct gpio_keys_button qnap_ts209_buttons[] = { | |||
297 | .gpio = QNAP_TS209_GPIO_KEY_MEDIA, | 211 | .gpio = QNAP_TS209_GPIO_KEY_MEDIA, |
298 | .desc = "USB Copy Button", | 212 | .desc = "USB Copy Button", |
299 | .active_low = 1, | 213 | .active_low = 1, |
300 | }, | 214 | }, { |
301 | { | ||
302 | .code = KEY_POWER, | 215 | .code = KEY_POWER, |
303 | .gpio = QNAP_TS209_GPIO_KEY_RESET, | 216 | .gpio = QNAP_TS209_GPIO_KEY_RESET, |
304 | .desc = "Reset Button", | 217 | .desc = "Reset Button", |
305 | .active_low = 1, | 218 | .active_low = 1, |
306 | } | 219 | }, |
307 | }; | 220 | }; |
308 | 221 | ||
309 | static struct gpio_keys_platform_data qnap_ts209_button_data = { | 222 | static struct gpio_keys_platform_data qnap_ts209_button_data = { |
310 | .buttons = qnap_ts209_buttons, | 223 | .buttons = qnap_ts209_buttons, |
311 | .nbuttons = ARRAY_SIZE(qnap_ts209_buttons), | 224 | .nbuttons = ARRAY_SIZE(qnap_ts209_buttons), |
312 | }; | 225 | }; |
313 | 226 | ||
314 | static struct platform_device qnap_ts209_button_device = { | 227 | static struct platform_device qnap_ts209_button_device = { |
315 | .name = "gpio-keys", | 228 | .name = "gpio-keys", |
316 | .id = -1, | 229 | .id = -1, |
317 | .num_resources = 0, | 230 | .num_resources = 0, |
318 | .dev = { .platform_data = &qnap_ts209_button_data, }, | 231 | .dev = { |
232 | .platform_data = &qnap_ts209_button_data, | ||
233 | }, | ||
319 | }; | 234 | }; |
320 | 235 | ||
321 | /***************************************************************************** | 236 | /***************************************************************************** |
322 | * SATA | 237 | * SATA |
323 | ****************************************************************************/ | 238 | ****************************************************************************/ |
324 | static struct mv_sata_platform_data qnap_ts209_sata_data = { | 239 | static struct mv_sata_platform_data qnap_ts209_sata_data = { |
325 | .n_ports = 2, | 240 | .n_ports = 2, |
326 | }; | 241 | }; |
327 | 242 | ||
328 | /***************************************************************************** | 243 | /***************************************************************************** |
329 | 244 | ||
330 | * General Setup | 245 | * General Setup |
331 | ****************************************************************************/ | 246 | ****************************************************************************/ |
332 | 247 | static struct orion5x_mpp_mode ts209_mpp_modes[] __initdata = { | |
333 | static struct platform_device *qnap_ts209_devices[] __initdata = { | 248 | { 0, MPP_UNUSED }, |
334 | &qnap_ts209_nor_flash, | 249 | { 1, MPP_GPIO }, /* USB copy button */ |
335 | &qnap_ts209_button_device, | 250 | { 2, MPP_GPIO }, /* Load defaults button */ |
251 | { 3, MPP_GPIO }, /* GPIO RTC */ | ||
252 | { 4, MPP_UNUSED }, | ||
253 | { 5, MPP_UNUSED }, | ||
254 | { 6, MPP_GPIO }, /* PCI Int A */ | ||
255 | { 7, MPP_GPIO }, /* PCI Int B */ | ||
256 | { 8, MPP_UNUSED }, | ||
257 | { 9, MPP_UNUSED }, | ||
258 | { 10, MPP_UNUSED }, | ||
259 | { 11, MPP_UNUSED }, | ||
260 | { 12, MPP_SATA_LED }, /* SATA 0 presence */ | ||
261 | { 13, MPP_SATA_LED }, /* SATA 1 presence */ | ||
262 | { 14, MPP_SATA_LED }, /* SATA 0 active */ | ||
263 | { 15, MPP_SATA_LED }, /* SATA 1 active */ | ||
264 | { 16, MPP_UART }, /* UART1 RXD */ | ||
265 | { 17, MPP_UART }, /* UART1 TXD */ | ||
266 | { 18, MPP_GPIO }, /* SW_RST */ | ||
267 | { 19, MPP_UNUSED }, | ||
268 | { -1 }, | ||
336 | }; | 269 | }; |
337 | 270 | ||
338 | /* | ||
339 | * QNAP TS-[12]09 specific power off method via UART1-attached PIC | ||
340 | */ | ||
341 | |||
342 | #define UART1_REG(x) (UART1_VIRT_BASE + ((UART_##x) << 2)) | ||
343 | |||
344 | static void qnap_ts209_power_off(void) | ||
345 | { | ||
346 | /* 19200 baud divisor */ | ||
347 | const unsigned divisor = ((ORION5X_TCLK + (8 * 19200)) / (16 * 19200)); | ||
348 | |||
349 | pr_info("%s: triggering power-off...\n", __func__); | ||
350 | |||
351 | /* hijack uart1 and reset into sane state (19200,8n1) */ | ||
352 | orion5x_write(UART1_REG(LCR), 0x83); | ||
353 | orion5x_write(UART1_REG(DLL), divisor & 0xff); | ||
354 | orion5x_write(UART1_REG(DLM), (divisor >> 8) & 0xff); | ||
355 | orion5x_write(UART1_REG(LCR), 0x03); | ||
356 | orion5x_write(UART1_REG(IER), 0x00); | ||
357 | orion5x_write(UART1_REG(FCR), 0x00); | ||
358 | orion5x_write(UART1_REG(MCR), 0x00); | ||
359 | |||
360 | /* send the power-off command 'A' to PIC */ | ||
361 | orion5x_write(UART1_REG(TX), 'A'); | ||
362 | } | ||
363 | |||
364 | static void __init qnap_ts209_init(void) | 271 | static void __init qnap_ts209_init(void) |
365 | { | 272 | { |
366 | /* | 273 | /* |
@@ -368,51 +275,33 @@ static void __init qnap_ts209_init(void) | |||
368 | */ | 275 | */ |
369 | orion5x_init(); | 276 | orion5x_init(); |
370 | 277 | ||
371 | /* | 278 | orion5x_mpp_conf(ts209_mpp_modes); |
372 | * Setup flash mapping | ||
373 | */ | ||
374 | orion5x_setup_dev_boot_win(QNAP_TS209_NOR_BOOT_BASE, | ||
375 | QNAP_TS209_NOR_BOOT_SIZE); | ||
376 | |||
377 | /* | ||
378 | * Open a special address decode windows for the PCIe WA. | ||
379 | */ | ||
380 | orion5x_setup_pcie_wa_win(ORION5X_PCIE_WA_PHYS_BASE, | ||
381 | ORION5X_PCIE_WA_SIZE); | ||
382 | 279 | ||
383 | /* | 280 | /* |
384 | * Setup Multiplexing Pins -- | ||
385 | * MPP[0] Reserved | ||
386 | * MPP[1] USB copy button (0 active) | ||
387 | * MPP[2] Load defaults button (0 active) | ||
388 | * MPP[3] GPIO RTC | ||
389 | * MPP[4-5] Reserved | ||
390 | * MPP[6] PCI Int A | ||
391 | * MPP[7] PCI Int B | ||
392 | * MPP[8-11] Reserved | ||
393 | * MPP[12] SATA 0 presence | ||
394 | * MPP[13] SATA 1 presence | ||
395 | * MPP[14] SATA 0 active | ||
396 | * MPP[15] SATA 1 active | ||
397 | * MPP[16] UART1 RXD | ||
398 | * MPP[17] UART1 TXD | ||
399 | * MPP[18] SW_RST (0 active) | ||
400 | * MPP[19] Reserved | ||
401 | * MPP[20] PCI clock 0 | 281 | * MPP[20] PCI clock 0 |
402 | * MPP[21] PCI clock 1 | 282 | * MPP[21] PCI clock 1 |
403 | * MPP[22] USB 0 over current | 283 | * MPP[22] USB 0 over current |
404 | * MPP[23-25] Reserved | 284 | * MPP[23-25] Reserved |
405 | */ | 285 | */ |
406 | orion5x_write(MPP_0_7_CTRL, 0x3); | ||
407 | orion5x_write(MPP_8_15_CTRL, 0x55550000); | ||
408 | orion5x_write(MPP_16_19_CTRL, 0x5500); | ||
409 | orion5x_gpio_set_valid_pins(0x3cc0fff); | ||
410 | 286 | ||
411 | /* register ts209 specific power-off method */ | 287 | /* |
412 | pm_power_off = qnap_ts209_power_off; | 288 | * Configure peripherals. |
289 | */ | ||
290 | orion5x_ehci0_init(); | ||
291 | orion5x_ehci1_init(); | ||
292 | qnap_tsx09_find_mac_addr(QNAP_TS209_NOR_BOOT_BASE + | ||
293 | qnap_ts209_partitions[5].offset, | ||
294 | qnap_ts209_partitions[5].size); | ||
295 | orion5x_eth_init(&qnap_tsx09_eth_data); | ||
296 | orion5x_i2c_init(); | ||
297 | orion5x_sata_init(&qnap_ts209_sata_data); | ||
298 | orion5x_uart0_init(); | ||
299 | |||
300 | orion5x_setup_dev_boot_win(QNAP_TS209_NOR_BOOT_BASE, | ||
301 | QNAP_TS209_NOR_BOOT_SIZE); | ||
302 | platform_device_register(&qnap_ts209_nor_flash); | ||
413 | 303 | ||
414 | platform_add_devices(qnap_ts209_devices, | 304 | platform_device_register(&qnap_ts209_button_device); |
415 | ARRAY_SIZE(qnap_ts209_devices)); | ||
416 | 305 | ||
417 | /* Get RTC IRQ and register the chip */ | 306 | /* Get RTC IRQ and register the chip */ |
418 | if (gpio_request(TS209_RTC_GPIO, "rtc") == 0) { | 307 | if (gpio_request(TS209_RTC_GPIO, "rtc") == 0) { |
@@ -425,14 +314,12 @@ static void __init qnap_ts209_init(void) | |||
425 | pr_warning("qnap_ts209_init: failed to get RTC IRQ\n"); | 314 | pr_warning("qnap_ts209_init: failed to get RTC IRQ\n"); |
426 | i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1); | 315 | i2c_register_board_info(0, &qnap_ts209_i2c_rtc, 1); |
427 | 316 | ||
428 | ts209_find_mac_addr(); | 317 | /* register tsx09 specific power-off method */ |
429 | orion5x_eth_init(&qnap_ts209_eth_data); | 318 | pm_power_off = qnap_tsx09_power_off; |
430 | |||
431 | orion5x_sata_init(&qnap_ts209_sata_data); | ||
432 | } | 319 | } |
433 | 320 | ||
434 | MACHINE_START(TS209, "QNAP TS-109/TS-209") | 321 | MACHINE_START(TS209, "QNAP TS-109/TS-209") |
435 | /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */ | 322 | /* Maintainer: Byron Bradley <byron.bbradley@gmail.com> */ |
436 | .phys_io = ORION5X_REGS_PHYS_BASE, | 323 | .phys_io = ORION5X_REGS_PHYS_BASE, |
437 | .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC, | 324 | .io_pg_offst = ((ORION5X_REGS_VIRT_BASE) >> 18) & 0xFFFC, |
438 | .boot_params = 0x00000100, | 325 | .boot_params = 0x00000100, |