diff options
author | Haavard Skinnemoen <hskinnemoen@atmel.com> | 2006-10-04 10:02:08 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-04 13:25:05 -0400 |
commit | 75d35213777e2b278db57a420efbce2bdb61da93 (patch) | |
tree | 2731fc81e13bdca84e6db26a6278c3c9dedca642 | |
parent | 71f2e2b8783f7b270b673e31e2322572057b286a (diff) |
[PATCH] atmel_serial: Pass fixed register mappings through platform_data
In order to initialize the serial console early, the atmel_serial
driver had to do a hack where it compared the physical address of the
port with an address known to be permanently mapped, and used it as a
virtual address. This got around the limitation that ioremap() isn't
always available when the console is being initalized.
This patch removes that hack and replaces it with a new "regs" field
in struct atmel_uart_data that the board-specific code can initialize
to a fixed virtual mapping for platform devices where this is possible.
It also initializes the DBGU's regs field with the address the driver
used to check against.
On AVR32, the "regs" field is initialized from the physical base
address when this it can be accessed through a permanently 1:1 mapped
segment, i.e. the P4 segment.
If regs is NULL, the console initialization is delayed until the "real"
driver is up and running and ioremap() can be used.
Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Acked-by: Andrew Victor <andrew@sanpeople.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/arm/mach-at91rm9200/devices.c | 1 | ||||
-rw-r--r-- | arch/avr32/mach-at32ap/at32ap7000.c | 33 | ||||
-rw-r--r-- | drivers/serial/atmel_serial.c | 5 | ||||
-rw-r--r-- | include/asm-arm/arch-at91rm9200/board.h | 1 | ||||
-rw-r--r-- | include/asm-avr32/arch-at32ap/board.h | 5 |
5 files changed, 37 insertions, 8 deletions
diff --git a/arch/arm/mach-at91rm9200/devices.c b/arch/arm/mach-at91rm9200/devices.c index 5a3919f09d4d..059824376629 100644 --- a/arch/arm/mach-at91rm9200/devices.c +++ b/arch/arm/mach-at91rm9200/devices.c | |||
@@ -561,6 +561,7 @@ static struct resource dbgu_resources[] = { | |||
561 | static struct atmel_uart_data dbgu_data = { | 561 | static struct atmel_uart_data dbgu_data = { |
562 | .use_dma_tx = 0, | 562 | .use_dma_tx = 0, |
563 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ | 563 | .use_dma_rx = 0, /* DBGU not capable of receive DMA */ |
564 | .regs = (void __iomem *)(AT91_VA_BASE_SYS + AT91_DBGU), | ||
564 | }; | 565 | }; |
565 | 566 | ||
566 | static struct platform_device at91rm9200_dbgu_device = { | 567 | static struct platform_device at91rm9200_dbgu_device = { |
diff --git a/arch/avr32/mach-at32ap/at32ap7000.c b/arch/avr32/mach-at32ap/at32ap7000.c index 05d1296bd7b2..3dd305875087 100644 --- a/arch/avr32/mach-at32ap/at32ap7000.c +++ b/arch/avr32/mach-at32ap/at32ap7000.c | |||
@@ -523,32 +523,48 @@ void __init at32_add_system_devices(void) | |||
523 | * USART | 523 | * USART |
524 | * -------------------------------------------------------------------- */ | 524 | * -------------------------------------------------------------------- */ |
525 | 525 | ||
526 | static struct atmel_uart_data atmel_usart0_data = { | ||
527 | .use_dma_tx = 1, | ||
528 | .use_dma_rx = 1, | ||
529 | }; | ||
526 | static struct resource atmel_usart0_resource[] = { | 530 | static struct resource atmel_usart0_resource[] = { |
527 | PBMEM(0xffe00c00), | 531 | PBMEM(0xffe00c00), |
528 | IRQ(7), | 532 | IRQ(7), |
529 | }; | 533 | }; |
530 | DEFINE_DEV(atmel_usart, 0); | 534 | DEFINE_DEV_DATA(atmel_usart, 0); |
531 | DEV_CLK(usart, atmel_usart0, pba, 4); | 535 | DEV_CLK(usart, atmel_usart0, pba, 4); |
532 | 536 | ||
537 | static struct atmel_uart_data atmel_usart1_data = { | ||
538 | .use_dma_tx = 1, | ||
539 | .use_dma_rx = 1, | ||
540 | }; | ||
533 | static struct resource atmel_usart1_resource[] = { | 541 | static struct resource atmel_usart1_resource[] = { |
534 | PBMEM(0xffe01000), | 542 | PBMEM(0xffe01000), |
535 | IRQ(7), | 543 | IRQ(7), |
536 | }; | 544 | }; |
537 | DEFINE_DEV(atmel_usart, 1); | 545 | DEFINE_DEV_DATA(atmel_usart, 1); |
538 | DEV_CLK(usart, atmel_usart1, pba, 4); | 546 | DEV_CLK(usart, atmel_usart1, pba, 4); |
539 | 547 | ||
548 | static struct atmel_uart_data atmel_usart2_data = { | ||
549 | .use_dma_tx = 1, | ||
550 | .use_dma_rx = 1, | ||
551 | }; | ||
540 | static struct resource atmel_usart2_resource[] = { | 552 | static struct resource atmel_usart2_resource[] = { |
541 | PBMEM(0xffe01400), | 553 | PBMEM(0xffe01400), |
542 | IRQ(8), | 554 | IRQ(8), |
543 | }; | 555 | }; |
544 | DEFINE_DEV(atmel_usart, 2); | 556 | DEFINE_DEV_DATA(atmel_usart, 2); |
545 | DEV_CLK(usart, atmel_usart2, pba, 5); | 557 | DEV_CLK(usart, atmel_usart2, pba, 5); |
546 | 558 | ||
559 | static struct atmel_uart_data atmel_usart3_data = { | ||
560 | .use_dma_tx = 1, | ||
561 | .use_dma_rx = 1, | ||
562 | }; | ||
547 | static struct resource atmel_usart3_resource[] = { | 563 | static struct resource atmel_usart3_resource[] = { |
548 | PBMEM(0xffe01800), | 564 | PBMEM(0xffe01800), |
549 | IRQ(9), | 565 | IRQ(9), |
550 | }; | 566 | }; |
551 | DEFINE_DEV(atmel_usart, 3); | 567 | DEFINE_DEV_DATA(atmel_usart, 3); |
552 | DEV_CLK(usart, atmel_usart3, pba, 6); | 568 | DEV_CLK(usart, atmel_usart3, pba, 6); |
553 | 569 | ||
554 | static inline void configure_usart0_pins(void) | 570 | static inline void configure_usart0_pins(void) |
@@ -597,8 +613,13 @@ static struct platform_device *setup_usart(unsigned int id) | |||
597 | configure_usart3_pins(); | 613 | configure_usart3_pins(); |
598 | break; | 614 | break; |
599 | default: | 615 | default: |
600 | pdev = NULL; | 616 | return NULL; |
601 | break; | 617 | } |
618 | |||
619 | if (PXSEG(pdev->resource[0].start) == P4SEG) { | ||
620 | /* Addresses in the P4 segment are permanently mapped 1:1 */ | ||
621 | struct atmel_uart_data *data = pdev->dev.platform_data; | ||
622 | data->regs = (void __iomem *)pdev->resource[0].start; | ||
602 | } | 623 | } |
603 | 624 | ||
604 | return pdev; | 625 | return pdev; |
diff --git a/drivers/serial/atmel_serial.c b/drivers/serial/atmel_serial.c index 2f9d99bb9587..34212df39800 100644 --- a/drivers/serial/atmel_serial.c +++ b/drivers/serial/atmel_serial.c | |||
@@ -694,8 +694,9 @@ static void __devinit atmel_init_port(struct atmel_uart_port *atmel_port, struct | |||
694 | port->mapbase = pdev->resource[0].start; | 694 | port->mapbase = pdev->resource[0].start; |
695 | port->irq = pdev->resource[1].start; | 695 | port->irq = pdev->resource[1].start; |
696 | 696 | ||
697 | if (port->mapbase == AT91_VA_BASE_SYS + AT91_DBGU) /* Part of system perpherals - already mapped */ | 697 | if (data->regs) |
698 | port->membase = (void __iomem *) port->mapbase; | 698 | /* Already mapped by setup code */ |
699 | port->membase = data->regs; | ||
699 | else { | 700 | else { |
700 | port->flags |= UPF_IOREMAP; | 701 | port->flags |= UPF_IOREMAP; |
701 | port->membase = NULL; | 702 | port->membase = NULL; |
diff --git a/include/asm-arm/arch-at91rm9200/board.h b/include/asm-arm/arch-at91rm9200/board.h index d56527055c9d..3cc9aec80f9d 100644 --- a/include/asm-arm/arch-at91rm9200/board.h +++ b/include/asm-arm/arch-at91rm9200/board.h | |||
@@ -103,6 +103,7 @@ extern void __init at91_init_serial(struct at91_uart_config *config); | |||
103 | struct atmel_uart_data { | 103 | struct atmel_uart_data { |
104 | short use_dma_tx; /* use transmit DMA? */ | 104 | short use_dma_tx; /* use transmit DMA? */ |
105 | short use_dma_rx; /* use receive DMA? */ | 105 | short use_dma_rx; /* use receive DMA? */ |
106 | void __iomem *regs; /* virtual base address, if any */ | ||
106 | }; | 107 | }; |
107 | extern void __init at91_add_device_serial(void); | 108 | extern void __init at91_add_device_serial(void); |
108 | 109 | ||
diff --git a/include/asm-avr32/arch-at32ap/board.h b/include/asm-avr32/arch-at32ap/board.h index 82e5404d2f48..435507281f89 100644 --- a/include/asm-avr32/arch-at32ap/board.h +++ b/include/asm-avr32/arch-at32ap/board.h | |||
@@ -12,6 +12,11 @@ void at32_add_system_devices(void); | |||
12 | #define ATMEL_MAX_UART 4 | 12 | #define ATMEL_MAX_UART 4 |
13 | extern struct platform_device *atmel_default_console_device; | 13 | extern struct platform_device *atmel_default_console_device; |
14 | 14 | ||
15 | struct atmel_uart_data { | ||
16 | short use_dma_tx; /* use transmit DMA? */ | ||
17 | short use_dma_rx; /* use receive DMA? */ | ||
18 | void __iomem *regs; /* virtual base address, if any */ | ||
19 | }; | ||
15 | struct platform_device *at32_add_device_usart(unsigned int id); | 20 | struct platform_device *at32_add_device_usart(unsigned int id); |
16 | 21 | ||
17 | struct eth_platform_data { | 22 | struct eth_platform_data { |