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 | |
| 7 | #include <common.h> |
| 8 | #include <asm/io.h> |
| 9 | #include <asm/arch/at91_common.h> |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 10 | #include <asm/arch/at91_pio.h> |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 11 | #include <asm/arch/clk.h> |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 12 | |
| 13 | unsigned int has_lcdc() |
| 14 | { |
| 15 | return 1; |
| 16 | } |
| 17 | |
| 18 | void at91_serial0_hw_init(void) |
| 19 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 20 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 0, 1); /* TXD0 */ |
| 21 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 1, 0); /* RXD0 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 22 | at91_periph_clk_enable(ATMEL_ID_USART0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | void at91_serial1_hw_init(void) |
| 26 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 27 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 5, 1); /* TXD1 */ |
| 28 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 6, 0); /* RXD1 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 29 | at91_periph_clk_enable(ATMEL_ID_USART1); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | void at91_serial2_hw_init(void) |
| 33 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 34 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 7, 1); /* TXD2 */ |
| 35 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 8, 0); /* RXD2 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 36 | at91_periph_clk_enable(ATMEL_ID_USART2); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | void at91_serial3_hw_init(void) |
| 40 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 41 | at91_pio3_set_b_periph(AT91_PIO_PORTC, 22, 1); /* TXD3 */ |
| 42 | at91_pio3_set_b_periph(AT91_PIO_PORTC, 23, 0); /* RXD3 */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 43 | at91_periph_clk_enable(ATMEL_ID_USART3); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | void at91_seriald_hw_init(void) |
| 47 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 48 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */ |
| 49 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */ |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 50 | at91_periph_clk_enable(ATMEL_ID_SYS); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | #ifdef CONFIG_ATMEL_SPI |
| 54 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 55 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 56 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 11, 0); /* SPI0_MISO */ |
| 57 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 12, 0); /* SPI0_MOSI */ |
| 58 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 13, 0); /* SPI0_SPCK */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 59 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 60 | at91_periph_clk_enable(ATMEL_ID_SPI0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 61 | |
| 62 | if (cs_mask & (1 << 0)) |
| 63 | at91_set_pio_output(AT91_PIO_PORTA, 14, 1); |
| 64 | if (cs_mask & (1 << 1)) |
| 65 | at91_set_pio_output(AT91_PIO_PORTA, 7, 1); |
| 66 | if (cs_mask & (1 << 2)) |
| 67 | at91_set_pio_output(AT91_PIO_PORTA, 1, 1); |
| 68 | if (cs_mask & (1 << 3)) |
| 69 | at91_set_pio_output(AT91_PIO_PORTB, 3, 1); |
| 70 | } |
| 71 | |
| 72 | void at91_spi1_hw_init(unsigned long cs_mask) |
| 73 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 74 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 21, 0); /* SPI1_MISO */ |
| 75 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 22, 0); /* SPI1_MOSI */ |
| 76 | at91_pio3_set_b_periph(AT91_PIO_PORTA, 23, 0); /* SPI1_SPCK */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 77 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 78 | at91_periph_clk_enable(ATMEL_ID_SPI1); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 79 | |
| 80 | if (cs_mask & (1 << 0)) |
| 81 | at91_set_pio_output(AT91_PIO_PORTA, 8, 1); |
| 82 | if (cs_mask & (1 << 1)) |
| 83 | at91_set_pio_output(AT91_PIO_PORTA, 0, 1); |
| 84 | if (cs_mask & (1 << 2)) |
| 85 | at91_set_pio_output(AT91_PIO_PORTA, 31, 1); |
| 86 | if (cs_mask & (1 << 3)) |
| 87 | at91_set_pio_output(AT91_PIO_PORTA, 30, 1); |
| 88 | } |
| 89 | #endif |
| 90 | |
| 91 | void at91_mci_hw_init(void) |
| 92 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 93 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 17, 0); /* MCCK */ |
| 94 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 16, 0); /* MCCDA */ |
| 95 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 15, 0); /* MCDA0 */ |
| 96 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 18, 0); /* MCDA1 */ |
| 97 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 19, 0); /* MCDA2 */ |
| 98 | at91_pio3_set_a_periph(AT91_PIO_PORTA, 20, 0); /* MCDA3 */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 99 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 100 | at91_periph_clk_enable(ATMEL_ID_HSMCI0); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | #ifdef CONFIG_LCD |
| 104 | void at91_lcd_hw_init(void) |
| 105 | { |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 106 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDDPWR */ |
| 107 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDVSYNC */ |
| 108 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDHSYNC */ |
| 109 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 28, 0); /* LCDDOTCK */ |
| 110 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 29, 0); /* LCDDEN */ |
| 111 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 30, 0); /* LCDDOTCK */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 112 | |
Wenyou Yang | 4a92a3e | 2017-03-23 12:44:36 +0800 | [diff] [blame] | 113 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 0, 0); /* LCDD0 */ |
| 114 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDD1 */ |
| 115 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDD2 */ |
| 116 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDD3 */ |
| 117 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 4, 0); /* LCDD4 */ |
| 118 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 5, 0); /* LCDD5 */ |
| 119 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD6 */ |
| 120 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD7 */ |
| 121 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD8 */ |
| 122 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD9 */ |
| 123 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD10 */ |
| 124 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD11 */ |
| 125 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 12, 0); /* LCDD12 */ |
| 126 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 13, 0); /* LCDD13 */ |
| 127 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD14 */ |
| 128 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD15 */ |
| 129 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD16 */ |
| 130 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 17, 0); /* LCDD17 */ |
| 131 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD18 */ |
| 132 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD19 */ |
| 133 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 20, 0); /* LCDD20 */ |
| 134 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 21, 0); /* LCDD21 */ |
| 135 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD22 */ |
| 136 | at91_pio3_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD23 */ |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 137 | |
Wenyou Yang | 57b7f29 | 2016-02-03 10:16:49 +0800 | [diff] [blame] | 138 | at91_periph_clk_enable(ATMEL_ID_LCDC); |
Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 139 | } |
| 140 | #endif |