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