blob: 4dc6e51aba831bf568bd3d091970211ed38fc3fa [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Wu, Josh3f338c12013-04-16 23:42:44 +00002/*
3 * (C) Copyright 2013 Atmel Corporation
4 * Josh Wu <josh.wu@atmel.com>
Wu, Josh3f338c12013-04-16 23:42:44 +00005 */
6
Wu, Josh3f338c12013-04-16 23:42:44 +00007#include <asm/io.h>
8#include <asm/arch/at91_common.h>
Wu, Josh3f338c12013-04-16 23:42:44 +00009#include <asm/arch/at91_pio.h>
Wenyou Yang57b7f292016-02-03 10:16:49 +080010#include <asm/arch/clk.h>
Wu, Josh3f338c12013-04-16 23:42:44 +000011
12unsigned int has_lcdc()
13{
14 return 1;
15}
16
17void at91_serial0_hw_init(void)
18{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080019 at91_pio3_set_a_periph(AT91_PIO_PORTA, 0, 1); /* TXD0 */
20 at91_pio3_set_a_periph(AT91_PIO_PORTA, 1, 0); /* RXD0 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080021 at91_periph_clk_enable(ATMEL_ID_USART0);
Wu, Josh3f338c12013-04-16 23:42:44 +000022}
23
24void at91_serial1_hw_init(void)
25{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080026 at91_pio3_set_a_periph(AT91_PIO_PORTA, 5, 1); /* TXD1 */
27 at91_pio3_set_a_periph(AT91_PIO_PORTA, 6, 0); /* RXD1 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080028 at91_periph_clk_enable(ATMEL_ID_USART1);
Wu, Josh3f338c12013-04-16 23:42:44 +000029}
30
31void at91_serial2_hw_init(void)
32{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080033 at91_pio3_set_a_periph(AT91_PIO_PORTA, 7, 1); /* TXD2 */
34 at91_pio3_set_a_periph(AT91_PIO_PORTA, 8, 0); /* RXD2 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080035 at91_periph_clk_enable(ATMEL_ID_USART2);
Wu, Josh3f338c12013-04-16 23:42:44 +000036}
37
38void at91_serial3_hw_init(void)
39{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080040 at91_pio3_set_b_periph(AT91_PIO_PORTC, 22, 1); /* TXD3 */
41 at91_pio3_set_b_periph(AT91_PIO_PORTC, 23, 0); /* RXD3 */
Wenyou Yang57b7f292016-02-03 10:16:49 +080042 at91_periph_clk_enable(ATMEL_ID_USART3);
Wu, Josh3f338c12013-04-16 23:42:44 +000043}
44
45void at91_seriald_hw_init(void)
46{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080047 at91_pio3_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */
48 at91_pio3_set_a_periph(AT91_PIO_PORTA, 9, 0); /* DRXD */
Wenyou Yang57b7f292016-02-03 10:16:49 +080049 at91_periph_clk_enable(ATMEL_ID_SYS);
Wu, Josh3f338c12013-04-16 23:42:44 +000050}
51
52#ifdef CONFIG_ATMEL_SPI
53void at91_spi0_hw_init(unsigned long cs_mask)
54{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080055 at91_pio3_set_a_periph(AT91_PIO_PORTA, 11, 0); /* SPI0_MISO */
56 at91_pio3_set_a_periph(AT91_PIO_PORTA, 12, 0); /* SPI0_MOSI */
57 at91_pio3_set_a_periph(AT91_PIO_PORTA, 13, 0); /* SPI0_SPCK */
Wu, Josh3f338c12013-04-16 23:42:44 +000058
Wenyou Yang57b7f292016-02-03 10:16:49 +080059 at91_periph_clk_enable(ATMEL_ID_SPI0);
Wu, Josh3f338c12013-04-16 23:42:44 +000060
61 if (cs_mask & (1 << 0))
62 at91_set_pio_output(AT91_PIO_PORTA, 14, 1);
63 if (cs_mask & (1 << 1))
64 at91_set_pio_output(AT91_PIO_PORTA, 7, 1);
65 if (cs_mask & (1 << 2))
66 at91_set_pio_output(AT91_PIO_PORTA, 1, 1);
67 if (cs_mask & (1 << 3))
68 at91_set_pio_output(AT91_PIO_PORTB, 3, 1);
69}
70
71void at91_spi1_hw_init(unsigned long cs_mask)
72{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080073 at91_pio3_set_b_periph(AT91_PIO_PORTA, 21, 0); /* SPI1_MISO */
74 at91_pio3_set_b_periph(AT91_PIO_PORTA, 22, 0); /* SPI1_MOSI */
75 at91_pio3_set_b_periph(AT91_PIO_PORTA, 23, 0); /* SPI1_SPCK */
Wu, Josh3f338c12013-04-16 23:42:44 +000076
Wenyou Yang57b7f292016-02-03 10:16:49 +080077 at91_periph_clk_enable(ATMEL_ID_SPI1);
Wu, Josh3f338c12013-04-16 23:42:44 +000078
79 if (cs_mask & (1 << 0))
80 at91_set_pio_output(AT91_PIO_PORTA, 8, 1);
81 if (cs_mask & (1 << 1))
82 at91_set_pio_output(AT91_PIO_PORTA, 0, 1);
83 if (cs_mask & (1 << 2))
84 at91_set_pio_output(AT91_PIO_PORTA, 31, 1);
85 if (cs_mask & (1 << 3))
86 at91_set_pio_output(AT91_PIO_PORTA, 30, 1);
87}
88#endif
89
90void at91_mci_hw_init(void)
91{
Wenyou Yang4a92a3e2017-03-23 12:44:36 +080092 at91_pio3_set_a_periph(AT91_PIO_PORTA, 17, 0); /* MCCK */
93 at91_pio3_set_a_periph(AT91_PIO_PORTA, 16, 0); /* MCCDA */
94 at91_pio3_set_a_periph(AT91_PIO_PORTA, 15, 0); /* MCDA0 */
95 at91_pio3_set_a_periph(AT91_PIO_PORTA, 18, 0); /* MCDA1 */
96 at91_pio3_set_a_periph(AT91_PIO_PORTA, 19, 0); /* MCDA2 */
97 at91_pio3_set_a_periph(AT91_PIO_PORTA, 20, 0); /* MCDA3 */
Wu, Josh3f338c12013-04-16 23:42:44 +000098
Wenyou Yang57b7f292016-02-03 10:16:49 +080099 at91_periph_clk_enable(ATMEL_ID_HSMCI0);
Wu, Josh3f338c12013-04-16 23:42:44 +0000100}