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