xref: /rk3399_rockchip-uboot/arch/arm/mach-at91/arm926ejs/at91sam9rl_devices.c (revision b0ec94428e54da320f890e293bacdedd40ef45e0)
162011840SMasahiro Yamada /*
262011840SMasahiro Yamada  * (C) Copyright 2007-2008
362011840SMasahiro Yamada  * Stelian Pop <stelian@popies.net>
462011840SMasahiro Yamada  * Lead Tech Design <www.leadtechdesign.com>
562011840SMasahiro Yamada  *
662011840SMasahiro Yamada  * SPDX-License-Identifier:	GPL-2.0+
762011840SMasahiro Yamada  */
862011840SMasahiro Yamada 
962011840SMasahiro Yamada #include <common.h>
1062011840SMasahiro Yamada #include <asm/io.h>
1162011840SMasahiro Yamada #include <asm/arch/at91_common.h>
12eced5a7eSWenyou Yang #include <asm/arch/clk.h>
1362011840SMasahiro Yamada #include <asm/arch/gpio.h>
1462011840SMasahiro Yamada 
1562011840SMasahiro Yamada /*
1662011840SMasahiro Yamada  * if CONFIG_AT91_GPIO_PULLUP ist set, keep pullups on on all
1762011840SMasahiro Yamada  * peripheral pins. Good to have if hardware is soldered optionally
1862011840SMasahiro Yamada  * or in case of SPI no slave is selected. Avoid lines to float
1962011840SMasahiro Yamada  * needlessly. Use a short local PUP define.
2062011840SMasahiro Yamada  *
2162011840SMasahiro Yamada  * Due to errata "TXD floats when CTS is inactive" pullups are always
2262011840SMasahiro Yamada  * on for TXD pins.
2362011840SMasahiro Yamada  */
2462011840SMasahiro Yamada #ifdef CONFIG_AT91_GPIO_PULLUP
2562011840SMasahiro Yamada # define PUP CONFIG_AT91_GPIO_PULLUP
2662011840SMasahiro Yamada #else
2762011840SMasahiro Yamada # define PUP 0
2862011840SMasahiro Yamada #endif
2962011840SMasahiro Yamada 
at91_serial0_hw_init(void)3062011840SMasahiro Yamada void at91_serial0_hw_init(void)
3162011840SMasahiro Yamada {
3262011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 6, 1);		/* TXD0 */
3362011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 7, PUP);		/* RXD0 */
34eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_USART0);
3562011840SMasahiro Yamada }
3662011840SMasahiro Yamada 
at91_serial1_hw_init(void)3762011840SMasahiro Yamada void at91_serial1_hw_init(void)
3862011840SMasahiro Yamada {
3962011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 11, 1);		/* TXD1 */
4062011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 12, PUP);		/* RXD1 */
41eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_USART1);
4262011840SMasahiro Yamada }
4362011840SMasahiro Yamada 
at91_serial2_hw_init(void)4462011840SMasahiro Yamada void at91_serial2_hw_init(void)
4562011840SMasahiro Yamada {
4662011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 13, 1);		/* TXD2 */
4762011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 14, PUP);		/* RXD2 */
48eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_USART2);
4962011840SMasahiro Yamada }
5062011840SMasahiro Yamada 
at91_seriald_hw_init(void)5162011840SMasahiro Yamada void at91_seriald_hw_init(void)
5262011840SMasahiro Yamada {
5362011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 21, PUP);		/* DRXD */
5462011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 22, 1);		/* DTXD */
55eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_SYS);
5662011840SMasahiro Yamada }
5762011840SMasahiro Yamada 
58*b0ec9442STuomas Tynkkynen #ifdef CONFIG_ATMEL_SPI
at91_spi0_hw_init(unsigned long cs_mask)5962011840SMasahiro Yamada void at91_spi0_hw_init(unsigned long cs_mask)
6062011840SMasahiro Yamada {
6162011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 25, PUP);	/* SPI0_MISO */
6262011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 26, PUP);	/* SPI0_MOSI */
6362011840SMasahiro Yamada 	at91_set_a_periph(AT91_PIO_PORTA, 27, PUP);	/* SPI0_SPCK */
6462011840SMasahiro Yamada 
65eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_SPI);
6662011840SMasahiro Yamada 
6762011840SMasahiro Yamada 	if (cs_mask & (1 << 0)) {
6862011840SMasahiro Yamada 		at91_set_a_periph(AT91_PIO_PORTA, 28, 1);
6962011840SMasahiro Yamada 	}
7062011840SMasahiro Yamada 	if (cs_mask & (1 << 1)) {
7162011840SMasahiro Yamada 		at91_set_b_periph(AT91_PIO_PORTB, 7, 1);
7262011840SMasahiro Yamada 	}
7362011840SMasahiro Yamada 	if (cs_mask & (1 << 2)) {
7462011840SMasahiro Yamada 		at91_set_a_periph(AT91_PIO_PORTD, 8, 1);
7562011840SMasahiro Yamada 	}
7662011840SMasahiro Yamada 	if (cs_mask & (1 << 3)) {
7762011840SMasahiro Yamada 		at91_set_b_periph(AT91_PIO_PORTD, 9, 1);
7862011840SMasahiro Yamada 	}
7962011840SMasahiro Yamada 	if (cs_mask & (1 << 4)) {
8062011840SMasahiro Yamada 		at91_set_pio_output(AT91_PIO_PORTA, 28, 1);
8162011840SMasahiro Yamada 	}
8262011840SMasahiro Yamada 	if (cs_mask & (1 << 5)) {
8362011840SMasahiro Yamada 		at91_set_pio_output(AT91_PIO_PORTB, 7, 1);
8462011840SMasahiro Yamada 	}
8562011840SMasahiro Yamada 	if (cs_mask & (1 << 6)) {
8662011840SMasahiro Yamada 		at91_set_pio_output(AT91_PIO_PORTD, 8, 1);
8762011840SMasahiro Yamada 	}
8862011840SMasahiro Yamada 	if (cs_mask & (1 << 7)) {
8962011840SMasahiro Yamada 		at91_set_pio_output(AT91_PIO_PORTD, 9, 1);
9062011840SMasahiro Yamada 	}
9162011840SMasahiro Yamada }
9262011840SMasahiro Yamada #endif
93111ec4c6SWu, Josh 
94111ec4c6SWu, Josh #ifdef CONFIG_GENERIC_ATMEL_MCI
at91_mci_hw_init(void)95111ec4c6SWu, Josh void at91_mci_hw_init(void)
96111ec4c6SWu, Josh {
97111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 2, 0);        /* MCI CLK */
98111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 1, 0);        /* MCI CDA */
99111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 0, 0);        /* MCI DA0 */
100111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 3, 0);        /* MCI DA1 */
101111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 4, 0);        /* MCI DA2 */
102111ec4c6SWu, Josh 	at91_set_a_periph(AT91_PIO_PORTA, 5, 0);        /* MCI DA3 */
103111ec4c6SWu, Josh 
104eced5a7eSWenyou Yang 	at91_periph_clk_enable(ATMEL_ID_MCI);
105111ec4c6SWu, Josh }
106111ec4c6SWu, Josh #endif
107