1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries
7 #include <asm/arch/at91_common.h>
8 #include <asm/arch/clk.h>
9 #include <asm/arch/gpio.h>
12 unsigned int get_chip_id(void)
14 /* The 0x40 is the offset of cidr in DBGU */
15 return readl(ATMEL_BASE_DBGU + 0x40) & ~ARCH_ID_VERSION_MASK;
18 unsigned int get_extension_chip_id(void)
20 /* The 0x44 is the offset of exid in DBGU */
21 return readl(ATMEL_BASE_DBGU + 0x44);
24 unsigned int has_emac1(void)
26 return cpu_is_sam9x60();
29 unsigned int has_emac0(void)
31 return cpu_is_sam9x60();
34 unsigned int has_lcdc(void)
36 return cpu_is_sam9x60();
39 char *get_cpu_name(void)
41 unsigned int extension_id = get_extension_chip_id();
43 if (cpu_is_sam9x60()) {
44 switch (extension_id) {
45 case ARCH_EXID_SAM9X60:
47 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";
54 return "Unknown CPU type";
57 return "Unknown CPU type";
61 void at91_seriald_hw_init(void)
63 at91_pio3_set_a_periph(AT91_PIO_PORTA, 9, 1); /* DRXD */
64 at91_pio3_set_a_periph(AT91_PIO_PORTA, 10, 1); /* DTXD */
66 at91_periph_clk_enable(ATMEL_ID_DBGU);
69 void at91_mci_hw_init(void)
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 */
79 at91_periph_clk_enable(ATMEL_ID_SDMMC0);
83 void at91_macb_hw_init(void)
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 */
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 */
118 /* Only emac0 support MII */
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 */