1 // SPDX-License-Identifier: GPL-2.0+
4 * Ilko Iliev <iliev@ronetix.at>
5 * Asen Dimov <dimov@ronetix.at>
6 * Ronetix GmbH <www.ronetix.at>
8 * (C) Copyright 2007-2008
9 * Stelian Pop <stelian@popies.net>
10 * Lead Tech Design <www.leadtechdesign.com>
15 #include <asm/global_data.h>
16 #include <linux/sizes.h>
19 #include <asm/arch/at91sam9_smc.h>
20 #include <asm/arch/at91_common.h>
21 #include <asm/arch/at91_rstc.h>
22 #include <asm/arch/at91_matrix.h>
23 #include <asm/arch/gpio.h>
24 #include <asm/arch/clk.h>
25 #if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
29 #include <asm/mach-types.h>
31 DECLARE_GLOBAL_DATA_PTR;
34 * Miscelaneous platform dependent initialisations
37 #ifdef CONFIG_CMD_NAND
38 static void pm9g45_nand_hw_init(void)
41 struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
42 struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
45 csa = readl(&matrix->ccr[6]) | AT91_MATRIX_CSA_EBI_CS3A;
46 writel(csa, &matrix->ccr[6]);
48 /* Configure SMC CS3 for NAND/SmartMedia */
49 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
50 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
53 writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
54 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(2),
57 writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(4),
60 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
61 AT91_SMC_MODE_EXNW_DISABLE |
63 AT91_SMC_MODE_TDF_CYCLE(3),
66 at91_periph_clk_enable(ATMEL_ID_PIOC);
68 #ifdef CFG_SYS_NAND_READY_PIN
69 /* Configure RDY/BSY */
70 gpio_request(CFG_SYS_NAND_READY_PIN, "NAND RDY/BSY");
71 gpio_direction_input(CFG_SYS_NAND_READY_PIN);
74 /* Enable NandFlash */
75 gpio_request(CFG_SYS_NAND_ENABLE_PIN, "NAND enable");
76 gpio_direction_output(CFG_SYS_NAND_ENABLE_PIN, 1);
81 static void pm9g45_macb_hw_init(void)
84 * PD2 enables the 50MHz oscillator for Ethernet PHY
88 at91_set_pio_output(AT91_PIO_PORTD, 2, 1);
89 at91_set_pio_value(AT91_PIO_PORTD, 2, 1); /* 1- enable, 0 - disable */
91 at91_periph_clk_enable(ATMEL_ID_EMAC);
95 * RXDV (PA15) => PHY normal mode (not Test mode)
96 * ERX0 (PA12) => PHY ADDR0
97 * ERX1 (PA13) => PHY ADDR1 => PHYADDR = 0x0
99 * PHY has internal pull-down
101 at91_set_pio_pullup(AT91_PIO_PORTA, 15, 0);
102 at91_set_pio_pullup(AT91_PIO_PORTA, 12, 0);
103 at91_set_pio_pullup(AT91_PIO_PORTA, 13, 0);
105 /* Re-enable pull-up */
106 at91_set_pio_pullup(AT91_PIO_PORTA, 15, 1);
107 at91_set_pio_pullup(AT91_PIO_PORTA, 12, 1);
108 at91_set_pio_pullup(AT91_PIO_PORTA, 13, 1);
114 int board_early_init_f(void)
116 at91_periph_clk_enable(ATMEL_ID_PIOA);
117 at91_periph_clk_enable(ATMEL_ID_PIOB);
118 at91_periph_clk_enable(ATMEL_ID_PIOC);
119 at91_periph_clk_enable(ATMEL_ID_PIODE);
121 at91_seriald_hw_init();
128 /* arch number of AT91SAM9M10G45EK-Board */
129 gd->bd->bi_arch_number = MACH_TYPE_PM9G45;
130 /* adress of boot parameters */
131 gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
133 #ifdef CONFIG_CMD_NAND
134 pm9g45_nand_hw_init();
138 pm9g45_macb_hw_init();
145 /* dram_init must store complete ramsize in gd->ram_size */
146 gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE,
151 int dram_init_banksize(void)
153 gd->bd->bi_dram[0].start = CFG_SYS_SDRAM_BASE;
154 gd->bd->bi_dram[0].size = CFG_SYS_SDRAM_SIZE;
159 #ifdef CONFIG_RESET_PHY_R
164 * Initialize ethernet HW addr prior to starting Linux,
172 int board_eth_init(struct bd_info *bis)
176 rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC, 0x01);