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>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2009-03-21 20:07:59 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2011-07-26 01:23:39 +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-07-26 01:23:39 +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
|
|
|
|
2009-05-13 19:01:13 +00:00
|
|
|
void at91_serial0_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 8, 1); /* TXD0 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 9, 0); /* RXD0 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART0);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial1_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 12, 1); /* TXD1 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 13, 0); /* RXD1 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART1);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial2_hw_init(void)
|
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 14, 1); /* TXD2 */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTC, 15, 0); /* RXD2 */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_USART2);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
|
2011-07-26 01:23:39 +00:00
|
|
|
void at91_seriald_hw_init(void)
|
2009-05-13 19:01:13 +00:00
|
|
|
{
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_SYS);
|
2009-05-13 19:01:13 +00:00
|
|
|
}
|
|
|
|
|
2017-10-10 18:59:42 +00:00
|
|
|
#ifdef CONFIG_ATMEL_SPI
|
2009-03-21 20:07:59 +00:00
|
|
|
void at91_spi0_hw_init(unsigned long cs_mask)
|
|
|
|
{
|
2011-07-26 01:23:39 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 0, PUP); /* SPI0_MISO */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 1, PUP); /* SPI0_MOSI */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 2, PUP); /* SPI0_SPCK */
|
2009-03-21 20:07:59 +00:00
|
|
|
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_SPI0);
|
2009-03-21 20:07:59 +00:00
|
|
|
|
|
|
|
if (cs_mask & (1 << 0)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 3, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 1)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 4, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 2)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 5, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 3)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 6, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 4)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 3, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 5)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 4, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 6)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 5, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 7)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 6, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void at91_spi1_hw_init(unsigned long cs_mask)
|
|
|
|
{
|
2011-07-26 01:23:39 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTB, 30, PUP); /* SPI1_MISO */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTB, 31, PUP); /* SPI1_MOSI */
|
|
|
|
at91_set_a_periph(AT91_PIO_PORTB, 29, PUP); /* SPI1_SPCK */
|
2009-03-21 20:07:59 +00:00
|
|
|
|
2016-02-03 02:16:49 +00:00
|
|
|
at91_periph_clk_enable(ATMEL_ID_SPI1);
|
2009-03-21 20:07:59 +00:00
|
|
|
|
|
|
|
if (cs_mask & (1 << 0)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTB, 28, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 1)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_b_periph(AT91_PIO_PORTA, 24, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 2)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_b_periph(AT91_PIO_PORTA, 25, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 3)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_a_periph(AT91_PIO_PORTA, 26, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 4)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTB, 28, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 5)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 24, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 6)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 25, 1);
|
2009-03-27 12:14:52 +00:00
|
|
|
}
|
|
|
|
if (cs_mask & (1 << 7)) {
|
2010-02-03 21:46:46 +00:00
|
|
|
at91_set_pio_output(AT91_PIO_PORTA, 26, 1);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-13 19:01:13 +00:00
|
|
|
#endif
|