2 * Copyright (C) 2012 - 2013 Atmel Corporation
3 * Bo Shen <voice.shen@atmel.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 #include <asm/arch/sama5d3_smc.h>
12 #include <asm/arch/at91_common.h>
13 #include <asm/arch/at91_pmc.h>
14 #include <asm/arch/at91_rstc.h>
15 #include <asm/arch/gpio.h>
16 #include <asm/arch/clk.h>
18 #include <atmel_lcdc.h>
19 #include <atmel_mci.h>
23 DECLARE_GLOBAL_DATA_PTR;
25 /* ------------------------------------------------------------------------- */
27 * Miscelaneous platform dependent initialisations
30 #ifdef CONFIG_NAND_ATMEL
31 void sama5d3xek_nand_hw_init(void)
33 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
35 at91_periph_clk_enable(ATMEL_ID_SMC);
37 /* Configure SMC CS3 for NAND/SmartMedia */
38 writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(1) |
39 AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(1),
41 writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(5) |
42 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(5),
44 writel(AT91_SMC_CYCLE_NWE(8) | AT91_SMC_CYCLE_NRD(8),
46 writel(AT91_SMC_TIMINGS_TCLR(3) | AT91_SMC_TIMINGS_TADL(10) |
47 AT91_SMC_TIMINGS_TAR(3) | AT91_SMC_TIMINGS_TRR(4) |
48 AT91_SMC_TIMINGS_TWB(5) | AT91_SMC_TIMINGS_RBNSEL(3)|
49 AT91_SMC_TIMINGS_NFSEL(1), &smc->cs[3].timings);
50 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
51 AT91_SMC_MODE_EXNW_DISABLE |
52 #ifdef CONFIG_SYS_NAND_DBW_16
53 AT91_SMC_MODE_DBW_16 |
54 #else /* CONFIG_SYS_NAND_DBW_8 */
57 AT91_SMC_MODE_TDF_CYCLE(3),
63 static void sama5d3xek_usb_hw_init(void)
65 at91_set_pio_output(AT91_PIO_PORTD, 25, 0);
66 at91_set_pio_output(AT91_PIO_PORTD, 26, 0);
67 at91_set_pio_output(AT91_PIO_PORTD, 27, 0);
71 #ifdef CONFIG_GENERIC_ATMEL_MCI
72 static void sama5d3xek_mci_hw_init(void)
76 at91_set_pio_output(AT91_PIO_PORTB, 10, 0); /* MCI0 Power */
81 vidinfo_t panel_info = {
85 .vl_sync = ATMEL_LCDC_INVLINE_NORMAL | ATMEL_LCDC_INVFRAME_NORMAL,
90 .vl_right_margin = 64,
92 .vl_upper_margin = 22,
93 .vl_lower_margin = 21,
94 .mmio = ATMEL_BASE_LCDC,
101 void lcd_disable(void)
105 static void sama5d3xek_lcd_hw_init(void)
107 gd->fb_base = CONFIG_SAMA5D3_LCD_BASE;
109 /* The higher 8 bit of LCD is board related */
110 at91_set_c_periph(AT91_PIO_PORTC, 14, 0); /* LCDD16 */
111 at91_set_c_periph(AT91_PIO_PORTC, 13, 0); /* LCDD17 */
112 at91_set_c_periph(AT91_PIO_PORTC, 12, 0); /* LCDD18 */
113 at91_set_c_periph(AT91_PIO_PORTC, 11, 0); /* LCDD19 */
114 at91_set_c_periph(AT91_PIO_PORTC, 10, 0); /* LCDD20 */
115 at91_set_c_periph(AT91_PIO_PORTC, 15, 0); /* LCDD21 */
116 at91_set_c_periph(AT91_PIO_PORTE, 27, 0); /* LCDD22 */
117 at91_set_c_periph(AT91_PIO_PORTE, 28, 0); /* LCDD23 */
119 /* Configure lower 16 bit of LCD and enable clock */
123 #ifdef CONFIG_LCD_INFO
127 void lcd_show_board_info(void)
129 ulong dram_size, nand_size;
133 lcd_printf("%s\n", U_BOOT_VERSION);
134 lcd_printf("(C) 2013 ATMEL Corp\n");
135 lcd_printf("at91@atmel.com\n");
136 lcd_printf("%s CPU at %s MHz\n", get_cpu_name(),
137 strmhz(temp, get_cpu_clk_rate()));
140 for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
141 dram_size += gd->bd->bi_dram[i].size;
144 #ifdef CONFIG_NAND_ATMEL
145 for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)
146 nand_size += nand_info[i].size;
148 lcd_printf("%ld MB SDRAM, %ld MB NAND\n",
149 dram_size >> 20, nand_size >> 20);
151 #endif /* CONFIG_LCD_INFO */
152 #endif /* CONFIG_LCD */
154 int board_early_init_f(void)
156 at91_seriald_hw_init();
163 /* adress of boot parameters */
164 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
166 #ifdef CONFIG_NAND_ATMEL
167 sama5d3xek_nand_hw_init();
169 #ifdef CONFIG_CMD_USB
170 sama5d3xek_usb_hw_init();
172 #ifdef CONFIG_GENERIC_ATMEL_MCI
173 sama5d3xek_mci_hw_init();
175 #ifdef CONFIG_ATMEL_SPI
176 at91_spi0_hw_init(1 << 0);
184 sama5d3xek_lcd_hw_init();
191 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
192 CONFIG_SYS_SDRAM_SIZE);
196 int board_eth_init(bd_t *bis)
202 rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x00);
208 #ifdef CONFIG_GENERIC_ATMEL_MCI
209 int board_mmc_init(bd_t *bis)
213 rc = atmel_mci_init((void *)ATMEL_BASE_MCI0);
219 /* SPI chip select control */
220 #ifdef CONFIG_ATMEL_SPI
223 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
225 return bus == 0 && cs < 4;
228 void spi_cs_activate(struct spi_slave *slave)
232 at91_set_pio_output(AT91_PIO_PORTD, 13, 0);
234 at91_set_pio_output(AT91_PIO_PORTD, 14, 0);
236 at91_set_pio_output(AT91_PIO_PORTD, 15, 0);
238 at91_set_pio_output(AT91_PIO_PORTD, 16, 0);
244 void spi_cs_deactivate(struct spi_slave *slave)
248 at91_set_pio_output(AT91_PIO_PORTD, 13, 1);
250 at91_set_pio_output(AT91_PIO_PORTD, 14, 1);
252 at91_set_pio_output(AT91_PIO_PORTD, 15, 1);
254 at91_set_pio_output(AT91_PIO_PORTD, 16, 1);
259 #endif /* CONFIG_ATMEL_SPI */