Wu, Josh | 3f338c1 | 2013-04-16 23:42:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2013 Atmel Corporation |
| 3 | * Josh Wu <josh.wu@atmel.com> |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <asm/io.h> |
| 26 | #include <asm/arch/at91_common.h> |
| 27 | #include <asm/arch/at91_pmc.h> |
| 28 | #include <asm/arch/at91_pio.h> |
| 29 | |
| 30 | unsigned int has_lcdc() |
| 31 | { |
| 32 | return 1; |
| 33 | } |
| 34 | |
| 35 | void at91_serial0_hw_init(void) |
| 36 | { |
| 37 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 38 | |
| 39 | at91_set_a_periph(AT91_PIO_PORTA, 0, 1); /* TXD0 */ |
| 40 | at91_set_a_periph(AT91_PIO_PORTA, 1, 0); /* RXD0 */ |
| 41 | writel(1 << ATMEL_ID_USART0, &pmc->pcer); |
| 42 | } |
| 43 | |
| 44 | void at91_serial1_hw_init(void) |
| 45 | { |
| 46 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 47 | |
| 48 | at91_set_a_periph(AT91_PIO_PORTA, 5, 1); /* TXD1 */ |
| 49 | at91_set_a_periph(AT91_PIO_PORTA, 6, 0); /* RXD1 */ |
| 50 | writel(1 << ATMEL_ID_USART1, &pmc->pcer); |
| 51 | } |
| 52 | |
| 53 | void at91_serial2_hw_init(void) |
| 54 | { |
| 55 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 56 | |
| 57 | at91_set_a_periph(AT91_PIO_PORTA, 7, 1); /* TXD2 */ |
| 58 | at91_set_a_periph(AT91_PIO_PORTA, 8, 0); /* RXD2 */ |
| 59 | writel(1 << ATMEL_ID_USART2, &pmc->pcer); |
| 60 | } |
| 61 | |
| 62 | void at91_serial3_hw_init(void) |
| 63 | { |
| 64 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 65 | |
| 66 | at91_set_b_periph(AT91_PIO_PORTC, 22, 1); /* TXD3 */ |
| 67 | at91_set_b_periph(AT91_PIO_PORTC, 23, 0); /* RXD3 */ |
| 68 | writel(1 << ATMEL_ID_USART3, &pmc->pcer); |
| 69 | } |
| 70 | |
| 71 | void at91_seriald_hw_init(void) |
| 72 | { |
| 73 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 74 | |
| 75 | at91_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */ |
| 76 | at91_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */ |
| 77 | writel(1 << ATMEL_ID_SYS, &pmc->pcer); |
| 78 | } |
| 79 | |
| 80 | #ifdef CONFIG_ATMEL_SPI |
| 81 | void at91_spi0_hw_init(unsigned long cs_mask) |
| 82 | { |
| 83 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 84 | |
| 85 | at91_set_a_periph(AT91_PIO_PORTA, 11, 0); /* SPI0_MISO */ |
| 86 | at91_set_a_periph(AT91_PIO_PORTA, 12, 0); /* SPI0_MOSI */ |
| 87 | at91_set_a_periph(AT91_PIO_PORTA, 13, 0); /* SPI0_SPCK */ |
| 88 | |
| 89 | /* Enable clock */ |
| 90 | writel(1 << ATMEL_ID_SPI0, &pmc->pcer); |
| 91 | |
| 92 | if (cs_mask & (1 << 0)) |
| 93 | at91_set_pio_output(AT91_PIO_PORTA, 14, 1); |
| 94 | if (cs_mask & (1 << 1)) |
| 95 | at91_set_pio_output(AT91_PIO_PORTA, 7, 1); |
| 96 | if (cs_mask & (1 << 2)) |
| 97 | at91_set_pio_output(AT91_PIO_PORTA, 1, 1); |
| 98 | if (cs_mask & (1 << 3)) |
| 99 | at91_set_pio_output(AT91_PIO_PORTB, 3, 1); |
| 100 | } |
| 101 | |
| 102 | void at91_spi1_hw_init(unsigned long cs_mask) |
| 103 | { |
| 104 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 105 | |
| 106 | at91_set_b_periph(AT91_PIO_PORTA, 21, 0); /* SPI1_MISO */ |
| 107 | at91_set_b_periph(AT91_PIO_PORTA, 22, 0); /* SPI1_MOSI */ |
| 108 | at91_set_b_periph(AT91_PIO_PORTA, 23, 0); /* SPI1_SPCK */ |
| 109 | |
| 110 | /* Enable clock */ |
| 111 | writel(1 << ATMEL_ID_SPI1, &pmc->pcer); |
| 112 | |
| 113 | if (cs_mask & (1 << 0)) |
| 114 | at91_set_pio_output(AT91_PIO_PORTA, 8, 1); |
| 115 | if (cs_mask & (1 << 1)) |
| 116 | at91_set_pio_output(AT91_PIO_PORTA, 0, 1); |
| 117 | if (cs_mask & (1 << 2)) |
| 118 | at91_set_pio_output(AT91_PIO_PORTA, 31, 1); |
| 119 | if (cs_mask & (1 << 3)) |
| 120 | at91_set_pio_output(AT91_PIO_PORTA, 30, 1); |
| 121 | } |
| 122 | #endif |
| 123 | |
| 124 | void at91_mci_hw_init(void) |
| 125 | { |
| 126 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 127 | |
| 128 | at91_set_a_periph(AT91_PIO_PORTA, 17, 0); /* MCCK */ |
| 129 | at91_set_a_periph(AT91_PIO_PORTA, 16, 0); /* MCCDA */ |
| 130 | at91_set_a_periph(AT91_PIO_PORTA, 15, 0); /* MCDA0 */ |
| 131 | at91_set_a_periph(AT91_PIO_PORTA, 18, 0); /* MCDA1 */ |
| 132 | at91_set_a_periph(AT91_PIO_PORTA, 19, 0); /* MCDA2 */ |
| 133 | at91_set_a_periph(AT91_PIO_PORTA, 20, 0); /* MCDA3 */ |
| 134 | |
| 135 | writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer); |
| 136 | } |
| 137 | |
| 138 | #ifdef CONFIG_LCD |
| 139 | void at91_lcd_hw_init(void) |
| 140 | { |
| 141 | struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC; |
| 142 | |
| 143 | at91_set_a_periph(AT91_PIO_PORTC, 24, 0); /* LCDDPWR */ |
| 144 | at91_set_a_periph(AT91_PIO_PORTC, 26, 0); /* LCDVSYNC */ |
| 145 | at91_set_a_periph(AT91_PIO_PORTC, 27, 0); /* LCDHSYNC */ |
| 146 | at91_set_a_periph(AT91_PIO_PORTC, 28, 0); /* LCDDOTCK */ |
| 147 | at91_set_a_periph(AT91_PIO_PORTC, 29, 0); /* LCDDEN */ |
| 148 | at91_set_a_periph(AT91_PIO_PORTC, 30, 0); /* LCDDOTCK */ |
| 149 | |
| 150 | at91_set_a_periph(AT91_PIO_PORTC, 0, 0); /* LCDD0 */ |
| 151 | at91_set_a_periph(AT91_PIO_PORTC, 1, 0); /* LCDD1 */ |
| 152 | at91_set_a_periph(AT91_PIO_PORTC, 2, 0); /* LCDD2 */ |
| 153 | at91_set_a_periph(AT91_PIO_PORTC, 3, 0); /* LCDD3 */ |
| 154 | at91_set_a_periph(AT91_PIO_PORTC, 4, 0); /* LCDD4 */ |
| 155 | at91_set_a_periph(AT91_PIO_PORTC, 5, 0); /* LCDD5 */ |
| 156 | at91_set_a_periph(AT91_PIO_PORTC, 6, 0); /* LCDD6 */ |
| 157 | at91_set_a_periph(AT91_PIO_PORTC, 7, 0); /* LCDD7 */ |
| 158 | at91_set_a_periph(AT91_PIO_PORTC, 8, 0); /* LCDD8 */ |
| 159 | at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* LCDD9 */ |
| 160 | at91_set_a_periph(AT91_PIO_PORTC, 10, 0); /* LCDD10 */ |
| 161 | at91_set_a_periph(AT91_PIO_PORTC, 11, 0); /* LCDD11 */ |
| 162 | at91_set_a_periph(AT91_PIO_PORTC, 12, 0); /* LCDD12 */ |
| 163 | at91_set_a_periph(AT91_PIO_PORTC, 13, 0); /* LCDD13 */ |
| 164 | at91_set_a_periph(AT91_PIO_PORTC, 14, 0); /* LCDD14 */ |
| 165 | at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* LCDD15 */ |
| 166 | at91_set_a_periph(AT91_PIO_PORTC, 16, 0); /* LCDD16 */ |
| 167 | at91_set_a_periph(AT91_PIO_PORTC, 17, 0); /* LCDD17 */ |
| 168 | at91_set_a_periph(AT91_PIO_PORTC, 18, 0); /* LCDD18 */ |
| 169 | at91_set_a_periph(AT91_PIO_PORTC, 19, 0); /* LCDD19 */ |
| 170 | at91_set_a_periph(AT91_PIO_PORTC, 20, 0); /* LCDD20 */ |
| 171 | at91_set_a_periph(AT91_PIO_PORTC, 21, 0); /* LCDD21 */ |
| 172 | at91_set_a_periph(AT91_PIO_PORTC, 22, 0); /* LCDD22 */ |
| 173 | at91_set_a_periph(AT91_PIO_PORTC, 23, 0); /* LCDD23 */ |
| 174 | |
| 175 | writel(1 << ATMEL_ID_LCDC, &pmc->pcer); |
| 176 | } |
| 177 | #endif |