[PATCH] AVR32: Allow renumbering of serial devices

Allow the board to remap actual USART peripheral devices to serial
devices by calling at32_map_usart(hw_id, serial_line). This ensures
that even though ATSTK1002 uses USART1 as the first serial port, it
will still have a ttyS0 device.

This also adds a board-specific early setup hook and moves the
at32_setup_serial_console() call there from the platform code.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Haavard Skinnemoen and committed by Linus Torvalds c194588d acca9b83

+26 -18
+13 -3
arch/avr32/boards/atstk1000/atstk1002.c
··· 10 10 #include <linux/init.h> 11 11 12 12 #include <asm/arch/board.h> 13 + #include <asm/arch/init.h> 13 14 14 15 struct eth_platform_data __initdata eth0_data = { 15 16 .valid = 1, ··· 21 20 22 21 extern struct lcdc_platform_data atstk1000_fb0_data; 23 22 23 + void __init setup_board(void) 24 + { 25 + at32_map_usart(1, 0); /* /dev/ttyS0 */ 26 + at32_map_usart(2, 1); /* /dev/ttyS1 */ 27 + at32_map_usart(3, 2); /* /dev/ttyS2 */ 28 + 29 + at32_setup_serial_console(0); 30 + } 31 + 24 32 static int __init atstk1002_init(void) 25 33 { 26 34 at32_add_system_devices(); 27 35 28 - at32_add_device_usart(1); /* /dev/ttyS0 */ 29 - at32_add_device_usart(2); /* /dev/ttyS1 */ 30 - at32_add_device_usart(3); /* /dev/ttyS2 */ 36 + at32_add_device_usart(0); 37 + at32_add_device_usart(1); 38 + at32_add_device_usart(2); 31 39 32 40 at32_add_device_eth(0, &eth0_data); 33 41 at32_add_device_spi(0);
+1
arch/avr32/kernel/setup.c
··· 292 292 293 293 setup_processor(); 294 294 setup_platform(); 295 + setup_board(); 295 296 296 297 cpu_clk = clk_get(NULL, "cpu"); 297 298 if (IS_ERR(cpu_clk)) {
-3
arch/avr32/mach-at32ap/at32ap.c
··· 48 48 at32_sm_init(); 49 49 at32_clock_init(); 50 50 at32_portmux_init(); 51 - 52 - /* FIXME: This doesn't belong here */ 53 - at32_setup_serial_console(1); 54 51 } 55 52 56 53 static int __init pdc_probe(struct platform_device *pdev)
+10 -12
arch/avr32/mach-at32ap/at32ap7000.c
··· 591 591 portmux_set_func(PIOB, 17, FUNC_B); /* TXD */ 592 592 } 593 593 594 - static struct platform_device *setup_usart(unsigned int id) 594 + static struct platform_device *at32_usarts[4]; 595 + 596 + void __init at32_map_usart(unsigned int hw_id, unsigned int line) 595 597 { 596 598 struct platform_device *pdev; 597 599 598 - switch (id) { 600 + switch (hw_id) { 599 601 case 0: 600 602 pdev = &atmel_usart0_device; 601 603 configure_usart0_pins(); ··· 615 613 configure_usart3_pins(); 616 614 break; 617 615 default: 618 - return NULL; 616 + return; 619 617 } 620 618 621 619 if (PXSEG(pdev->resource[0].start) == P4SEG) { ··· 624 622 data->regs = (void __iomem *)pdev->resource[0].start; 625 623 } 626 624 627 - return pdev; 625 + pdev->id = line; 626 + at32_usarts[line] = pdev; 628 627 } 629 628 630 629 struct platform_device *__init at32_add_device_usart(unsigned int id) 631 630 { 632 - struct platform_device *pdev; 633 - 634 - pdev = setup_usart(id); 635 - if (pdev) 636 - platform_device_register(pdev); 637 - 638 - return pdev; 631 + platform_device_register(at32_usarts[id]); 632 + return at32_usarts[id]; 639 633 } 640 634 641 635 struct platform_device *atmel_default_console_device; 642 636 643 637 void __init at32_setup_serial_console(unsigned int usart_id) 644 638 { 645 - atmel_default_console_device = setup_usart(usart_id); 639 + atmel_default_console_device = at32_usarts[usart_id]; 646 640 } 647 641 648 642 /* --------------------------------------------------------------------
+1
include/asm-avr32/arch-at32ap/board.h
··· 17 17 short use_dma_rx; /* use receive DMA? */ 18 18 void __iomem *regs; /* virtual base address, if any */ 19 19 }; 20 + void at32_map_usart(unsigned int hw_id, unsigned int line); 20 21 struct platform_device *at32_add_device_usart(unsigned int id); 21 22 22 23 struct eth_platform_data {
+1
include/asm-avr32/arch-at32ap/init.h
··· 11 11 #define __ASM_AVR32_AT32AP_INIT_H__ 12 12 13 13 void setup_platform(void); 14 + void setup_board(void); 14 15 15 16 /* Called by setup_platform */ 16 17 void at32_clock_init(void);