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-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>
|
|
|
|
#include <asm/arch/at91_pmc.h>
|
|
|
|
#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)
|
|
|
|
{
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
|
2010-02-03 21:46:58 +00:00
|
|
|
|
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 */
|
|
|
|
writel(1 << ATMEL_ID_USART0, &pmc->pcer);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial1_hw_init(void)
|
|
|
|
{
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
|
2010-02-03 21:46:58 +00:00
|
|
|
|
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 */
|
|
|
|
writel(1 << ATMEL_ID_USART1, &pmc->pcer);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void at91_serial2_hw_init(void)
|
|
|
|
{
|
2011-08-01 03:56:32 +00:00
|
|
|
at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
|
2010-02-03 21:46:58 +00:00
|
|
|
|
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 */
|
|
|
|
writel(1 << ATMEL_ID_USART2, &pmc->pcer);
|
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_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
|
2010-02-03 21:46:58 +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 */
|
2011-08-01 03:56:32 +00:00
|
|
|
writel(1 << ATMEL_ID_SYS, &pmc->pcer);
|
2009-03-21 20:07:59 +00:00
|
|
|
}
|
2009-05-13 19:01:13 +00:00
|
|
|
|
2011-08-01 03:56:32 +00:00
|
|
|
#if defined(CONFIG_HAS_DATAFLASH) || defined(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_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
|
2010-02-03 21:46:58 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
/* Enable clock */
|
2011-08-01 03:56:32 +00:00
|
|
|
writel(1 << ATMEL_ID_SPI, &pmc->pcer);
|
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
|