blob: c849885bc2bb2a8706fef1c32d3cf4362da1bd0a [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +00002/*
3 * [partely copied from arch/arm/cpu/arm926ejs/at91/arm9260_devices.c]
4 *
5 * (C) Copyright 2011
Andreas Bießmann07dafdb2016-05-01 03:46:16 +02006 * Andreas Bießmann <andreas@biessmann.org>
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +00007 *
8 * (C) Copyright 2007-2008
Stelian Pop5ee0c7f2011-11-01 00:00:39 +01009 * Stelian Pop <stelian@popies.net>
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000010 * Lead Tech Design <www.leadtechdesign.com>
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000011 */
12
13#include <common.h>
14#include <asm/io.h>
15#include <asm/arch/at91_common.h>
Wenyou Yang57b7f292016-02-03 10:16:49 +080016#include <asm/arch/clk.h>
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000017#include <asm/arch/gpio.h>
18
19/*
20 * if CONFIG_AT91_GPIO_PULLUP ist set, keep pullups on on all
21 * peripheral pins. Good to have if hardware is soldered optionally
22 * or in case of SPI no slave is selected. Avoid lines to float
23 * needlessly. Use a short local PUP define.
24 *
25 * Due to errata "TXD floats when CTS is inactive" pullups are always
26 * on for TXD pins.
27 */
28#ifdef CONFIG_AT91_GPIO_PULLUP
29# define PUP CONFIG_AT91_GPIO_PULLUP
30#else
31# define PUP 0
32#endif
33
34void at91_serial0_hw_init(void)
35{
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000036 at91_set_a_periph(AT91_PIO_PORTA, 17, 1); /* TXD0 */
37 at91_set_a_periph(AT91_PIO_PORTA, 18, PUP); /* RXD0 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080038 at91_periph_clk_enable(ATMEL_ID_USART0);
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000039}
40
41void at91_serial1_hw_init(void)
42{
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000043 at91_set_a_periph(AT91_PIO_PORTB, 20, PUP); /* RXD1 */
44 at91_set_a_periph(AT91_PIO_PORTB, 21, 1); /* TXD1 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080045 at91_periph_clk_enable(ATMEL_ID_USART1);
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000046}
47
48void at91_serial2_hw_init(void)
49{
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000050 at91_set_a_periph(AT91_PIO_PORTA, 22, PUP); /* RXD2 */
51 at91_set_a_periph(AT91_PIO_PORTA, 23, 1); /* TXD2 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080052 at91_periph_clk_enable(ATMEL_ID_USART2);
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000053}
54
Andreas Bießmann5e1f6c82011-06-12 01:49:13 +000055void at91_seriald_hw_init(void)
56{
57 at91_set_a_periph(AT91_PIO_PORTA, 30, PUP); /* DRXD */
58 at91_set_a_periph(AT91_PIO_PORTA, 31, 1); /* DTXD */
59 /* writing SYS to PCER has no effect on AT91RM9200 */
60}