]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/eukrea/cpu9260/cpu9260.c
at91: nand: switch atmel_nand to generic GPIO API
[people/ms/u-boot.git] / board / eukrea / cpu9260 / cpu9260.c
CommitLineData
23b80982
TR
1/*
2 * (C) Copyright 2007-2008
c9e798d3 3 * Stelian Pop <stelian@popies.net>
23b80982
TR
4 * Lead Tech Design <www.leadtechdesign.com>
5 * Ilko Iliev <www.ronetix.at>
6 *
95d50e5c 7 * (C) Copyright 2009-2011
23b80982
TR
8 * Eric Benard <eric@eukrea.com>
9 *
1a459660 10 * SPDX-License-Identifier: GPL-2.0+
23b80982
TR
11 */
12
13#include <common.h>
95d50e5c 14#include <asm/io.h>
ac45bb16 15#include <asm/gpio.h>
23b80982 16#include <asm/arch/at91sam9260.h>
23b80982
TR
17#include <asm/arch/at91sam9_smc.h>
18#include <asm/arch/at91_common.h>
95d50e5c 19#include <asm/arch/at91_matrix.h>
23b80982 20#include <asm/arch/at91_pmc.h>
c2b2a07e
EB
21#include <asm/arch/at91_pio.h>
22#include <asm/arch/clk.h>
23b80982
TR
23#include <asm/arch/hardware.h>
24#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
25#include <net.h>
26#endif
27#include <netdev.h>
28
29DECLARE_GLOBAL_DATA_PTR;
30
31/* ------------------------------------------------------------------------- */
32/*
33 * Miscelaneous platform dependent initialisations
34 */
35
36#ifdef CONFIG_CMD_NAND
37static void cpu9260_nand_hw_init(void)
38{
39 unsigned long csa;
95d50e5c
EB
40 at91_smc_t *smc = (at91_smc_t *) ATMEL_BASE_SMC;
41 at91_matrix_t *matrix = (at91_matrix_t *) ATMEL_BASE_MATRIX;
42 at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
23b80982
TR
43
44 /* Enable CS3 */
c2b2a07e
EB
45 csa = readl(&matrix->csa) | AT91_MATRIX_CSA_EBI_CS3A;
46 writel(csa, &matrix->csa);
23b80982
TR
47
48 /* Configure SMC CS3 for NAND/SmartMedia */
49#if defined(CONFIG_CPU9G20)
c2b2a07e
EB
50 writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
51 AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
52 &smc->cs[3].setup);
53 writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(4) |
54 AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(4),
55 &smc->cs[3].pulse);
56 writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
57 &smc->cs[3].cycle);
58 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
59 AT91_SMC_MODE_EXNW_DISABLE |
60 AT91_SMC_MODE_DBW_8 |
61 AT91_SMC_MODE_TDF_CYCLE(3),
62 &smc->cs[3].mode);
23b80982 63#elif defined(CONFIG_CPU9260)
c2b2a07e
EB
64 writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
65 AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
66 &smc->cs[3].setup);
67 writel(AT91_SMC_PULSE_NWE(3) | AT91_SMC_PULSE_NCS_WR(3) |
68 AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(3),
69 &smc->cs[3].pulse);
70 writel(AT91_SMC_CYCLE_NWE(5) | AT91_SMC_CYCLE_NRD(5),
71 &smc->cs[3].cycle);
72 writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
73 AT91_SMC_MODE_EXNW_DISABLE |
74 AT91_SMC_MODE_DBW_8 |
75 AT91_SMC_MODE_TDF_CYCLE(2),
76 &smc->cs[3].mode);
23b80982
TR
77#endif
78
95d50e5c 79 writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
23b80982
TR
80
81 /* Configure RDY/BSY */
ac45bb16 82 gpio_direction_input(CONFIG_SYS_NAND_READY_PIN);
23b80982
TR
83
84 /* Enable NandFlash */
ac45bb16 85 gpio_direction_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
23b80982
TR
86}
87#endif
88
89#ifdef CONFIG_MACB
90static void cpu9260_macb_hw_init(void)
91{
95d50e5c 92 at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
23b80982
TR
93
94 /* Enable clock */
95d50e5c 95 writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
c2b2a07e
EB
96
97 at91_set_pio_pullup(AT91_PIO_PORTA, 17, 1);
98
4535a24c 99 at91_phy_reset();
23b80982
TR
100
101 at91_macb_hw_init();
102}
103#endif
104
c2b2a07e 105int board_early_init_f(void)
23b80982 106{
95d50e5c 107 at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
c2b2a07e 108
95d50e5c
EB
109 writel((1 << ATMEL_ID_PIOA) |
110 (1 << ATMEL_ID_PIOB) |
111 (1 << ATMEL_ID_PIOC),
c2b2a07e
EB
112 &pmc->pcer);
113
95d50e5c 114 at91_seriald_hw_init();
c2b2a07e
EB
115
116 return 0;
117}
23b80982 118
c2b2a07e
EB
119
120int board_init(void)
121{
23b80982
TR
122 /* arch number of the board */
123#if defined(CONFIG_CPU9G20)
94d50c52 124 gd->bd->bi_arch_number = MACH_TYPE_CPUAT9G20;
23b80982
TR
125#elif defined(CONFIG_CPU9260)
126 gd->bd->bi_arch_number = MACH_TYPE_CPUAT9260;
127#endif
128
129 /* adress of boot parameters */
c2b2a07e 130 gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
23b80982 131
23b80982
TR
132#ifdef CONFIG_CMD_NAND
133 cpu9260_nand_hw_init();
134#endif
135#ifdef CONFIG_MACB
136 cpu9260_macb_hw_init();
137#endif
138#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
139 status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
140#endif
141 return 0;
142}
143
144int dram_init(void)
145{
a55d23cc 146 gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
c2b2a07e 147 CONFIG_SYS_SDRAM_SIZE);
23b80982
TR
148 return 0;
149}
150
23b80982
TR
151int board_eth_init(bd_t *bis)
152{
153 int rc = 0;
154#ifdef CONFIG_MACB
95d50e5c 155 rc = macb_eth_initialize(0, (void *)ATMEL_BASE_EMAC0, 0);
23b80982
TR
156#endif
157 return rc;
158}