blob: e3d3dd880cad2446e5d11242209095551f2af46f [file] [log] [blame]
Sandeep Sheriker Mallikarjun32f4d7c2019-09-27 13:08:40 +00001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries
4 */
5
6#include <common.h>
7#include <asm/arch/at91_common.h>
8#include <asm/arch/clk.h>
9#include <asm/arch/gpio.h>
10#include <asm/io.h>
11
12unsigned int get_chip_id(void)
13{
14 /* The 0x40 is the offset of cidr in DBGU */
15 return readl(ATMEL_BASE_DBGU + 0x40) & ~ARCH_ID_VERSION_MASK;
16}
17
18unsigned int get_extension_chip_id(void)
19{
20 /* The 0x44 is the offset of exid in DBGU */
21 return readl(ATMEL_BASE_DBGU + 0x44);
22}
23
24unsigned int has_emac1(void)
25{
26 return cpu_is_sam9x60();
27}
28
29unsigned int has_emac0(void)
30{
31 return cpu_is_sam9x60();
32}
33
34unsigned int has_lcdc(void)
35{
36 return cpu_is_sam9x60();
37}
38
39char *get_cpu_name(void)
40{
41 unsigned int extension_id = get_extension_chip_id();
42
43 if (cpu_is_sam9x60()) {
44 switch (extension_id) {
45 case ARCH_EXID_SAM9X60:
46 return "SAM9X60";
Nicolas Ferreb72fa0b2020-10-07 16:53:44 +020047 case ARCH_EXID_SAM9X60_D6K:
48 return "SAM9X60 8MiB SDRAM SiP";
49 case ARCH_EXID_SAM9X60_D5M:
50 return "SAM9X60 64MiB DDR2 SiP";
51 case ARCH_EXID_SAM9X60_D1G:
52 return "SAM9X60 128MiB DDR2 SiP";
Sandeep Sheriker Mallikarjun32f4d7c2019-09-27 13:08:40 +000053 default:
54 return "Unknown CPU type";
55 }
56 } else {
57 return "Unknown CPU type";
58 }
59}
60
61void at91_seriald_hw_init(void)
62{
63 at91_pio3_set_a_periph(AT91_PIO_PORTA, 9, 1); /* DRXD */
64 at91_pio3_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */
65
66 at91_periph_clk_enable(ATMEL_ID_DBGU);
67}
68
69void at91_mci_hw_init(void)
70{
71 /* Initialize the SDMMC0 */
72 at91_pio3_set_a_periph(AT91_PIO_PORTA, 17, 1); /* CLK */
73 at91_pio3_set_a_periph(AT91_PIO_PORTA, 16, 1); /* CMD */
74 at91_pio3_set_a_periph(AT91_PIO_PORTA, 15, 1); /* DAT0 */
75 at91_pio3_set_a_periph(AT91_PIO_PORTA, 18, 1); /* DAT1 */
76 at91_pio3_set_a_periph(AT91_PIO_PORTA, 19, 1); /* DAT2 */
77 at91_pio3_set_a_periph(AT91_PIO_PORTA, 20, 1); /* DAT3 */
78
79 at91_periph_clk_enable(ATMEL_ID_SDMMC0);
80}
81
82#ifdef CONFIG_MACB
83void at91_macb_hw_init(void)
84{
85 if (has_emac0()) {
86 /* Enable EMAC0 clock */
87 at91_periph_clk_enable(ATMEL_ID_EMAC0);
88 /* EMAC0 pins setup */
89 at91_pio3_set_a_periph(AT91_PIO_PORTB, 4, 0); /* ETXCK */
90 at91_pio3_set_a_periph(AT91_PIO_PORTB, 3, 0); /* ERXDV */
91 at91_pio3_set_a_periph(AT91_PIO_PORTB, 0, 0); /* ERX0 */
92 at91_pio3_set_a_periph(AT91_PIO_PORTB, 1, 0); /* ERX1 */
93 at91_pio3_set_a_periph(AT91_PIO_PORTB, 2, 0); /* ERXER */
94 at91_pio3_set_a_periph(AT91_PIO_PORTB, 7, 0); /* ETXEN */
95 at91_pio3_set_a_periph(AT91_PIO_PORTB, 9, 0); /* ETX0 */
96 at91_pio3_set_a_periph(AT91_PIO_PORTB, 10, 0); /* ETX1 */
97 at91_pio3_set_a_periph(AT91_PIO_PORTB, 5, 0); /* EMDIO */
98 at91_pio3_set_a_periph(AT91_PIO_PORTB, 6, 0); /* EMDC */
99 }
100
101 if (has_emac1()) {
102 /* Enable EMAC1 clock */
103 at91_periph_clk_enable(ATMEL_ID_EMAC1);
104 /* EMAC1 pins setup */
105 at91_pio3_set_b_periph(AT91_PIO_PORTC, 29, 0); /* ETXCK */
106 at91_pio3_set_b_periph(AT91_PIO_PORTC, 28, 0); /* ECRSDV */
107 at91_pio3_set_b_periph(AT91_PIO_PORTC, 20, 0); /* ERXO */
108 at91_pio3_set_b_periph(AT91_PIO_PORTC, 21, 0); /* ERX1 */
109 at91_pio3_set_b_periph(AT91_PIO_PORTC, 16, 0); /* ERXER */
110 at91_pio3_set_b_periph(AT91_PIO_PORTC, 27, 0); /* ETXEN */
111 at91_pio3_set_b_periph(AT91_PIO_PORTC, 18, 0); /* ETX0 */
112 at91_pio3_set_b_periph(AT91_PIO_PORTC, 19, 0); /* ETX1 */
113 at91_pio3_set_b_periph(AT91_PIO_PORTC, 31, 0); /* EMDIO */
114 at91_pio3_set_b_periph(AT91_PIO_PORTC, 30, 0); /* EMDC */
115 }
116
117#ifndef CONFIG_RMII
118 /* Only emac0 support MII */
119 if (has_emac0()) {
120 at91_pio3_set_a_periph(AT91_PIO_PORTB, 16, 0); /* ECRS */
121 at91_pio3_set_a_periph(AT91_PIO_PORTB, 17, 0); /* ECOL */
122 at91_pio3_set_a_periph(AT91_PIO_PORTB, 13, 0); /* ERX2 */
123 at91_pio3_set_a_periph(AT91_PIO_PORTB, 14, 0); /* ERX3 */
124 at91_pio3_set_a_periph(AT91_PIO_PORTB, 15, 0); /* ERXCK */
125 at91_pio3_set_a_periph(AT91_PIO_PORTB, 11, 0); /* ETX2 */
126 at91_pio3_set_a_periph(AT91_PIO_PORTB, 12, 0); /* ETX3 */
127 at91_pio3_set_a_periph(AT91_PIO_PORTB, 8, 0); /* ETXER */
128 }
129#endif
130}
131#endif