Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2013 Atmel Corporation |
| 4 | * Josh Wu <josh.wu@atmel.com> |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 7 | #include <asm/io.h> |
| 8 | #include <asm/arch/at91_common.h> |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 9 | #include <asm/arch/at91_pio.h> |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 10 | #include <asm/arch/clk.h> |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 11 | |
| 12 | unsigned int has_lcdc() |
| 13 | { |
| 14 | return 1; |
| 15 | } |
| 16 | |
| 17 | void at91_serial0_hw_init(void) |
| 18 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 19 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 0, 1); /* TXD0 */ |
| 20 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 1, 0); /* RXD0 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 21 | at91_periph_clk_enable(ATMEL_ID_USART0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | void at91_serial1_hw_init(void) |
| 25 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 26 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 5, 1); /* TXD1 */ |
| 27 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 6, 0); /* RXD1 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 28 | at91_periph_clk_enable(ATMEL_ID_USART1); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | void at91_serial2_hw_init(void) |
| 32 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 33 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 7, 1); /* TXD2 */ |
| 34 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 8, 0); /* RXD2 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 35 | at91_periph_clk_enable(ATMEL_ID_USART2); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void at91_serial3_hw_init(void) |
| 39 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 40 | at91_pio3_set_b_periph(AT91_PIO_PORTC, 22, 1); /* TXD3 */ |
| 41 | at91_pio3_set_b_periph(AT91_PIO_PORTC, 23, 0); /* RXD3 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 42 | at91_periph_clk_enable(ATMEL_ID_USART3); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | void at91_seriald_hw_init(void) |
| 46 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 47 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */ |
| 48 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 49 | at91_periph_clk_enable(ATMEL_ID_SYS); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | #ifdef CONFIG_ATMEL_SPI |
| 53 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 54 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 55 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 11, 0); /* SPI0_MISO */ |
| 56 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 12, 0); /* SPI0_MOSI */ |
| 57 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 13, 0); /* SPI0_SPCK */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 58 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 59 | at91_periph_clk_enable(ATMEL_ID_SPI0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 60 | |
| 61 | if (cs_mask & (1 << 0)) |
| 62 | at91_set_pio_output(AT91_PIO_PORTA, 14, 1); |
| 63 | if (cs_mask & (1 << 1)) |
| 64 | at91_set_pio_output(AT91_PIO_PORTA, 7, 1); |
| 65 | if (cs_mask & (1 << 2)) |
| 66 | at91_set_pio_output(AT91_PIO_PORTA, 1, 1); |
| 67 | if (cs_mask & (1 << 3)) |
| 68 | at91_set_pio_output(AT91_PIO_PORTB, 3, 1); |
| 69 | } |
| 70 | |
| 71 | void at91_spi1_hw_init(unsigned long cs_mask) |
| 72 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 73 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 21, 0); /* SPI1_MISO */ |
| 74 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 22, 0); /* SPI1_MOSI */ |
| 75 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 23, 0); /* SPI1_SPCK */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 76 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 77 | at91_periph_clk_enable(ATMEL_ID_SPI1); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 78 | |
| 79 | if (cs_mask & (1 << 0)) |
| 80 | at91_set_pio_output(AT91_PIO_PORTA, 8, 1); |
| 81 | if (cs_mask & (1 << 1)) |
| 82 | at91_set_pio_output(AT91_PIO_PORTA, 0, 1); |
| 83 | if (cs_mask & (1 << 2)) |
| 84 | at91_set_pio_output(AT91_PIO_PORTA, 31, 1); |
| 85 | if (cs_mask & (1 << 3)) |
| 86 | at91_set_pio_output(AT91_PIO_PORTA, 30, 1); |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | void at91_mci_hw_init(void) |
| 91 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 92 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 17, 0); /* MCCK */ |
| 93 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 16, 0); /* MCCDA */ |
| 94 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 15, 0); /* MCDA0 */ |
| 95 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 18, 0); /* MCDA1 */ |
| 96 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 19, 0); /* MCDA2 */ |
| 97 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 20, 0); /* MCDA3 */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 98 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 99 | at91_periph_clk_enable(ATMEL_ID_HSMCI0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 100 | } |