2 * (C) Copyright 2013 Atmel Corporation
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
26 #include <asm/arch/at91_common.h>
27 #include <asm/arch/at91_pmc.h>
28 #include <asm/arch/at91_pio.h>
30 unsigned int has_lcdc()
35 void at91_serial0_hw_init(void)
37 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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);
44 void at91_serial1_hw_init(void)
46 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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);
53 void at91_serial2_hw_init(void)
55 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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);
62 void at91_serial3_hw_init(void)
64 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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);
71 void at91_seriald_hw_init(void)
73 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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);
80 #ifdef CONFIG_ATMEL_SPI
81 void at91_spi0_hw_init(unsigned long cs_mask)
83 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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 */
90 writel(1 << ATMEL_ID_SPI0, &pmc->pcer);
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);
102 void at91_spi1_hw_init(unsigned long cs_mask)
104 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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 */
111 writel(1 << ATMEL_ID_SPI1, &pmc->pcer);
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);
124 void at91_mci_hw_init(void)
126 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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 */
135 writel(1 << ATMEL_ID_HSMCI0, &pmc->pcer);
139 void at91_lcd_hw_init(void)
141 struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
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 */
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 */
175 writel(1 << ATMEL_ID_LCDC, &pmc->pcer);