]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/cpu/arm926ejs/at91/at91cap9_devices.c
2 * (C) Copyright 2007-2008
3 * Stelian Pop <stelian@popies.net>
4 * Lead Tech Design <www.leadtechdesign.com>
7 * Daniel Gorsulowski <daniel.gorsulowski@esd.eu>
8 * esd electronic system design gmbh <www.esd.eu>
10 * SPDX-License-Identifier: GPL-2.0+
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>
19 void at91_serial0_hw_init(void)
21 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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
);
28 void at91_serial1_hw_init(void)
30 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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
);
37 void at91_serial2_hw_init(void)
39 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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
);
46 void at91_serial3_hw_init(void)
48 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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
);
55 void at91_serial_hw_init(void)
58 at91_serial0_hw_init();
62 at91_serial1_hw_init();
66 at91_serial2_hw_init();
69 #ifdef CONFIG_USART3 /* DBGU */
70 at91_serial3_hw_init();
74 #ifdef CONFIG_HAS_DATAFLASH
75 void at91_spi0_hw_init(unsigned long cs_mask
)
77 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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 */
84 writel(1 << AT91CAP9_ID_SPI0
, &pmc
->pcer
);
86 if (cs_mask
& (1 << 0)) {
87 at91_set_b_periph(AT91_PIO_PORTA
, 5, 1);
89 if (cs_mask
& (1 << 1)) {
90 at91_set_b_periph(AT91_PIO_PORTA
, 3, 1);
92 if (cs_mask
& (1 << 2)) {
93 at91_set_b_periph(AT91_PIO_PORTD
, 0, 1);
95 if (cs_mask
& (1 << 3)) {
96 at91_set_b_periph(AT91_PIO_PORTD
, 1, 1);
98 if (cs_mask
& (1 << 4)) {
99 at91_set_pio_output(AT91_PIO_PORTA
, 5, 1);
101 if (cs_mask
& (1 << 5)) {
102 at91_set_pio_output(AT91_PIO_PORTA
, 3, 1);
104 if (cs_mask
& (1 << 6)) {
105 at91_set_pio_output(AT91_PIO_PORTD
, 0, 1);
107 if (cs_mask
& (1 << 7)) {
108 at91_set_pio_output(AT91_PIO_PORTD
, 1, 1);
112 void at91_spi1_hw_init(unsigned long cs_mask
)
114 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
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 */
121 writel(1 << AT91CAP9_ID_SPI1
, &pmc
->pcer
);
123 if (cs_mask
& (1 << 0)) {
124 at91_set_a_periph(AT91_PIO_PORTB
, 15, 1);
126 if (cs_mask
& (1 << 1)) {
127 at91_set_a_periph(AT91_PIO_PORTB
, 16, 1);
129 if (cs_mask
& (1 << 2)) {
130 at91_set_a_periph(AT91_PIO_PORTB
, 17, 1);
132 if (cs_mask
& (1 << 3)) {
133 at91_set_a_periph(AT91_PIO_PORTB
, 18, 1);
135 if (cs_mask
& (1 << 4)) {
136 at91_set_pio_output(AT91_PIO_PORTB
, 15, 1);
138 if (cs_mask
& (1 << 5)) {
139 at91_set_pio_output(AT91_PIO_PORTB
, 16, 1);
141 if (cs_mask
& (1 << 6)) {
142 at91_set_pio_output(AT91_PIO_PORTB
, 17, 1);
144 if (cs_mask
& (1 << 7)) {
145 at91_set_pio_output(AT91_PIO_PORTB
, 18, 1);
152 void at91_macb_hw_init(void)
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 */
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 */
178 #ifdef CONFIG_AT91_CAN
179 void at91_can_hw_init(void)
181 at91_pmc_t
*pmc
= (at91_pmc_t
*) AT91_PMC_BASE
;
183 at91_set_a_periph(AT91_PIO_PORTA
, 12, 0); /* CAN_TX */
184 at91_set_a_periph(AT91_PIO_PORTA
, 13, 1); /* CAN_RX */
187 writel(1 << AT91CAP9_ID_CAN
, &pmc
->pcer
);