2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2009-03-21 20:07:59 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2007-2008
|
2011-10-31 23:00:39 +00:00
|
|
|
* Stelian Pop <stelian@popies.net>
|
2009-03-21 20:07:59 +00:00
|
|
|
* Lead Tech Design <www.leadtechdesign.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2011-08-01 03:56:32 +00:00
|
|
|
#include <asm/io.h>
|
2009-03-21 20:07:59 +00:00
|
|
|
#include <asm/arch/at91_common.h>
|
2016-02-03 02:16:49 +00:00
|
|
|
#include <asm/arch/clk.h>
|
2009-03-21 20:07:59 +00:00
|
|
|
#include <asm/arch/gpio.h>
|
2011-08-01 03:56:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* if CONFIG_AT91_GPIO_PULLUP ist set, keep pullups on on all
|
|
|
|
* peripheral pins. Good to have if hardware is soldered optionally
|
|
|
|
* or in case of SPI no slave is selected. Avoid lines to float
|
|
|
|
* needlessly. Use a short local PUP define.
|
|
|
|
*
|
|
|
|
* Due to errata "TXD floats when CTS is inactive" pullups are always
|
|
|
|
* on for TXD pins.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_AT91_GPIO_PULLUP
|
|
|
|
# define PUP CONFIG_AT91_GPIO_PULLUP
|
|
|
|
#else
|
|
|
|
# define PUP 0
|
|
|
|
#endif
|
2009-03-21 20:07:59 +00:00
|
|
|
|
|
|
|
void at91_serial0_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 6, 1); /* TXD0 */
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 7, PUP); /* RXD0 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART0);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial1_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 11, 1); /* TXD1 */
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 12, PUP); /* RXD1 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial2_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 13, 1); /* TXD2 */
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 14, PUP); /* RXD2 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART2);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-01 03:56:32 +00:00
|
|
|
void at91_seriald_hw_init(void)
|
2009-03-21 20:07:59 +00:00
|
|
|
{
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 21, PUP); /* DRXD */
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 22, 1); /* DTXD */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_SYS);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
2009-05-13 19:01:13 +00:00
|
|
|
|
2017-10-10 18:59:42 +00:00
|
|
|
#ifdef CONFIG_ATMEL_SPI
|
2009-05-13 19:01:13 +00:00
|
|
|
void at91_spi0_hw_init(unsigned long cs_mask)
|
|
|
|
{
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 25, PUP); /* SPI0_MISO */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 26, PUP); /* SPI0_MOSI */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 27, PUP); /* SPI0_SPCK */
|
2009-05-13 19:01:13 +00:00
|
|
|
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_SPI);
|
2009-05-13 19:01:13 +00:00
|
|
|
|
|
|
|
if (cs_mask & (1 << 0)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 28, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 1)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_b_periph(AT91_PIO_PORTB, 7, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 2)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTD, 8, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 3)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_b_periph(AT91_PIO_PORTD, 9, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 4)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 28, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 5)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTB, 7, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 6)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTD, 8, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 7)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTD, 9, 1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-02-02 09:51:00 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_GENERIC_ATMEL_MCI
|
|
|
|
void at91_mci_hw_init(void)
|
|
|
|
{
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 2, 0); /* MCI CLK */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 1, 0); /* MCI CDA */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 0, 0); /* MCI DA0 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 3, 0); /* MCI DA1 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 4, 0); /* MCI DA2 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 5, 0); /* MCI DA3 */
|
|
|
|
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_MCI);
|
2015-02-02 09:51:00 +00:00
|
|
|
}
|
|
|
|
#endif
|