]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / arch / arm / cpu / arm926ejs / at91 / at91cap9_devices.c
1 /*
2 * (C) Copyright 2007-2008
3 * Stelian Pop <stelian@popies.net>
4 * Lead Tech Design <www.leadtechdesign.com>
5 *
6 * (C) Copyright 2009
7 * Daniel Gorsulowski <daniel.gorsulowski@esd.eu>
8 * esd electronic system design gmbh <www.esd.eu>
9 *
10 * SPDX-License-Identifier: GPL-2.0+
11 */
12
13 #include <common.h>
14 #include <asm/arch/at91_common.h>
15 #include <asm/arch/at91_pmc.h>
16 #include <asm/arch/gpio.h>
17 #include <asm/arch/io.h>
18
19 void at91_serial0_hw_init(void)
20 {
21 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
22
23 at91_set_a_periph(AT91_PIO_PORTA, 22, 1); /* TXD0 */
24 at91_set_a_periph(AT91_PIO_PORTA, 23, 0); /* RXD0 */
25 writel(1 << AT91CAP9_ID_US0, &pmc->pcer);
26 }
27
28 void at91_serial1_hw_init(void)
29 {
30 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
31
32 at91_set_a_periph(AT91_PIO_PORTD, 0, 1); /* TXD1 */
33 at91_set_a_periph(AT91_PIO_PORTD, 1, 0); /* RXD1 */
34 writel(1 << AT91CAP9_ID_US1, &pmc->pcer);
35 }
36
37 void at91_serial2_hw_init(void)
38 {
39 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
40
41 at91_set_a_periph(AT91_PIO_PORTD, 2, 1); /* TXD2 */
42 at91_set_a_periph(AT91_PIO_PORTD, 3, 0); /* RXD2 */
43 writel(1 << AT91CAP9_ID_US2, &pmc->pcer);
44 }
45
46 void at91_serial3_hw_init(void)
47 {
48 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
49
50 at91_set_a_periph(AT91_PIO_PORTC, 30, 0); /* DRXD */
51 at91_set_a_periph(AT91_PIO_PORTC, 31, 1); /* DTXD */
52 writel(1 << AT91_ID_SYS, &pmc->pcer);
53 }
54
55 void at91_serial_hw_init(void)
56 {
57 #ifdef CONFIG_USART0
58 at91_serial0_hw_init();
59 #endif
60
61 #ifdef CONFIG_USART1
62 at91_serial1_hw_init();
63 #endif
64
65 #ifdef CONFIG_USART2
66 at91_serial2_hw_init();
67 #endif
68
69 #ifdef CONFIG_USART3 /* DBGU */
70 at91_serial3_hw_init();
71 #endif
72 }
73
74 #ifdef CONFIG_HAS_DATAFLASH
75 void at91_spi0_hw_init(unsigned long cs_mask)
76 {
77 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
78
79 at91_set_b_periph(AT91_PIO_PORTA, 0, 0); /* SPI0_MISO */
80 at91_set_b_periph(AT91_PIO_PORTA, 1, 0); /* SPI0_MOSI */
81 at91_set_b_periph(AT91_PIO_PORTA, 2, 0); /* SPI0_SPCK */
82
83 /* Enable clock */
84 writel(1 << AT91CAP9_ID_SPI0, &pmc->pcer);
85
86 if (cs_mask & (1 << 0)) {
87 at91_set_b_periph(AT91_PIO_PORTA, 5, 1);
88 }
89 if (cs_mask & (1 << 1)) {
90 at91_set_b_periph(AT91_PIO_PORTA, 3, 1);
91 }
92 if (cs_mask & (1 << 2)) {
93 at91_set_b_periph(AT91_PIO_PORTD, 0, 1);
94 }
95 if (cs_mask & (1 << 3)) {
96 at91_set_b_periph(AT91_PIO_PORTD, 1, 1);
97 }
98 if (cs_mask & (1 << 4)) {
99 at91_set_pio_output(AT91_PIO_PORTA, 5, 1);
100 }
101 if (cs_mask & (1 << 5)) {
102 at91_set_pio_output(AT91_PIO_PORTA, 3, 1);
103 }
104 if (cs_mask & (1 << 6)) {
105 at91_set_pio_output(AT91_PIO_PORTD, 0, 1);
106 }
107 if (cs_mask & (1 << 7)) {
108 at91_set_pio_output(AT91_PIO_PORTD, 1, 1);
109 }
110 }
111
112 void at91_spi1_hw_init(unsigned long cs_mask)
113 {
114 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
115
116 at91_set_a_periph(AT91_PIO_PORTB, 12, 0); /* SPI1_MISO */
117 at91_set_a_periph(AT91_PIO_PORTB, 13, 0); /* SPI1_MOSI */
118 at91_set_a_periph(AT91_PIO_PORTB, 14, 0); /* SPI1_SPCK */
119
120 /* Enable clock */
121 writel(1 << AT91CAP9_ID_SPI1, &pmc->pcer);
122
123 if (cs_mask & (1 << 0)) {
124 at91_set_a_periph(AT91_PIO_PORTB, 15, 1);
125 }
126 if (cs_mask & (1 << 1)) {
127 at91_set_a_periph(AT91_PIO_PORTB, 16, 1);
128 }
129 if (cs_mask & (1 << 2)) {
130 at91_set_a_periph(AT91_PIO_PORTB, 17, 1);
131 }
132 if (cs_mask & (1 << 3)) {
133 at91_set_a_periph(AT91_PIO_PORTB, 18, 1);
134 }
135 if (cs_mask & (1 << 4)) {
136 at91_set_pio_output(AT91_PIO_PORTB, 15, 1);
137 }
138 if (cs_mask & (1 << 5)) {
139 at91_set_pio_output(AT91_PIO_PORTB, 16, 1);
140 }
141 if (cs_mask & (1 << 6)) {
142 at91_set_pio_output(AT91_PIO_PORTB, 17, 1);
143 }
144 if (cs_mask & (1 << 7)) {
145 at91_set_pio_output(AT91_PIO_PORTB, 18, 1);
146 }
147
148 }
149 #endif
150
151 #ifdef CONFIG_MACB
152 void at91_macb_hw_init(void)
153 {
154 at91_set_a_periph(AT91_PIO_PORTB, 21, 0); /* ETXCK_EREFCK */
155 at91_set_a_periph(AT91_PIO_PORTB, 22, 0); /* ERXDV */
156 at91_set_a_periph(AT91_PIO_PORTB, 25, 0); /* ERX0 */
157 at91_set_a_periph(AT91_PIO_PORTB, 26, 0); /* ERX1 */
158 at91_set_a_periph(AT91_PIO_PORTB, 27, 0); /* ERXER */
159 at91_set_a_periph(AT91_PIO_PORTB, 28, 0); /* ETXEN */
160 at91_set_a_periph(AT91_PIO_PORTB, 23, 0); /* ETX0 */
161 at91_set_a_periph(AT91_PIO_PORTB, 24, 0); /* ETX1 */
162 at91_set_a_periph(AT91_PIO_PORTB, 30, 0); /* EMDIO */
163 at91_set_a_periph(AT91_PIO_PORTB, 29, 0); /* EMDC */
164
165 #ifndef CONFIG_RMII
166 at91_set_b_periph(AT91_PIO_PORTC, 25, 0); /* ECRS */
167 at91_set_b_periph(AT91_PIO_PORTC, 26, 0); /* ECOL */
168 at91_set_b_periph(AT91_PIO_PORTC, 22, 0); /* ERX2 */
169 at91_set_b_periph(AT91_PIO_PORTC, 23, 0); /* ERX3 */
170 at91_set_b_periph(AT91_PIO_PORTC, 27, 0); /* ERXCK */
171 at91_set_b_periph(AT91_PIO_PORTC, 20, 0); /* ETX2 */
172 at91_set_b_periph(AT91_PIO_PORTC, 21, 0); /* ETX3 */
173 at91_set_b_periph(AT91_PIO_PORTC, 24, 0); /* ETXER */
174 #endif
175 }
176 #endif
177
178 #ifdef CONFIG_AT91_CAN
179 void at91_can_hw_init(void)
180 {
181 at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
182
183 at91_set_a_periph(AT91_PIO_PORTA, 12, 0); /* CAN_TX */
184 at91_set_a_periph(AT91_PIO_PORTA, 13, 1); /* CAN_RX */
185
186 /* Enable clock */
187 writel(1 << AT91CAP9_ID_CAN, &pmc->pcer);
188 }
189 #endif