xref: /openbmc/u-boot/board/spear/spear310/spear310.c (revision 9afc1af0)
1080cfee7SVipin KUMAR /*
2080cfee7SVipin KUMAR  * (C) Copyright 2009
3080cfee7SVipin KUMAR  * Ryan Chen, ST Micoelectronics, ryan.chen@st.com.
4080cfee7SVipin KUMAR  * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
5080cfee7SVipin KUMAR  *
6080cfee7SVipin KUMAR  * See file CREDITS for list of people who contributed to this
7080cfee7SVipin KUMAR  * project.
8080cfee7SVipin KUMAR  *
9080cfee7SVipin KUMAR  * This program is free software; you can redistribute it and/or
10080cfee7SVipin KUMAR  * modify it under the terms of the GNU General Public License as
11080cfee7SVipin KUMAR  * published by the Free Software Foundation; either version 2 of
12080cfee7SVipin KUMAR  * the License, or (at your option) any later version.
13080cfee7SVipin KUMAR  *
14080cfee7SVipin KUMAR  * This program is distributed in the hope that it will be useful,
15080cfee7SVipin KUMAR  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16080cfee7SVipin KUMAR  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17080cfee7SVipin KUMAR  * GNU General Public License for more details.
18080cfee7SVipin KUMAR  *
19080cfee7SVipin KUMAR  * You should have received a copy of the GNU General Public License
20080cfee7SVipin KUMAR  * along with this program; if not, write to the Free Software
21080cfee7SVipin KUMAR  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22080cfee7SVipin KUMAR  * MA 02111-1307 USA
23080cfee7SVipin KUMAR  */
24080cfee7SVipin KUMAR 
25080cfee7SVipin KUMAR #include <common.h>
26*9afc1af0SVipin Kumar #include <miiphy.h>
27deb00562SVipin KUMAR #include <netdev.h>
28080cfee7SVipin KUMAR #include <nand.h>
29080cfee7SVipin KUMAR #include <asm/io.h>
301fa943b9SVipin KUMAR #include <linux/mtd/fsmc_nand.h>
31080cfee7SVipin KUMAR #include <asm/arch/hardware.h>
32080cfee7SVipin KUMAR #include <asm/arch/spr_defs.h>
33080cfee7SVipin KUMAR #include <asm/arch/spr_misc.h>
341fa943b9SVipin KUMAR 
351fa943b9SVipin KUMAR static struct nand_chip nand_chip[CONFIG_SYS_MAX_NAND_DEVICE];
36080cfee7SVipin KUMAR 
37080cfee7SVipin KUMAR int board_init(void)
38080cfee7SVipin KUMAR {
399d69e33dSVipin Kumar 	return spear_board_init(MACH_TYPE_SPEAR310);
40080cfee7SVipin KUMAR }
41080cfee7SVipin KUMAR 
42080cfee7SVipin KUMAR /*
43080cfee7SVipin KUMAR  * board_nand_init - Board specific NAND initialization
44080cfee7SVipin KUMAR  * @nand:	mtd private chip structure
45080cfee7SVipin KUMAR  *
46080cfee7SVipin KUMAR  * Called by nand_init_chip to initialize the board specific functions
47080cfee7SVipin KUMAR  */
48080cfee7SVipin KUMAR 
491fa943b9SVipin KUMAR void board_nand_init()
50080cfee7SVipin KUMAR {
51080cfee7SVipin KUMAR 	struct misc_regs *const misc_regs_p =
52080cfee7SVipin KUMAR 	    (struct misc_regs *)CONFIG_SPEAR_MISCBASE;
531fa943b9SVipin KUMAR 	struct nand_chip *nand = &nand_chip[0];
54080cfee7SVipin KUMAR 
551fa943b9SVipin KUMAR #if defined(CONFIG_NAND_FSMC)
56080cfee7SVipin KUMAR 	if (((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
57080cfee7SVipin KUMAR 	     MISC_SOCCFG30) ||
58080cfee7SVipin KUMAR 	    ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
59080cfee7SVipin KUMAR 	     MISC_SOCCFG31)) {
60080cfee7SVipin KUMAR 
611fa943b9SVipin KUMAR 		fsmc_nand_init(nand);
62080cfee7SVipin KUMAR 	}
631fa943b9SVipin KUMAR #endif
641fa943b9SVipin KUMAR 	return;
65080cfee7SVipin KUMAR }
66deb00562SVipin KUMAR 
67deb00562SVipin KUMAR int board_eth_init(bd_t *bis)
68deb00562SVipin KUMAR {
698eb0ee6aSVipin KUMAR 	int ret = 0;
708eb0ee6aSVipin KUMAR 
71deb00562SVipin KUMAR #if defined(CONFIG_DESIGNWARE_ETH)
72*9afc1af0SVipin Kumar 	u32 interface = PHY_INTERFACE_MODE_MII;
73*9afc1af0SVipin Kumar 	if (designware_initialize(0, CONFIG_SPEAR_ETHBASE, CONFIG_DW0_PHY,
74*9afc1af0SVipin Kumar 				interface) >= 0)
75*9afc1af0SVipin Kumar 		ret++;
76deb00562SVipin KUMAR #endif
778eb0ee6aSVipin KUMAR #if defined(CONFIG_MACB)
788eb0ee6aSVipin KUMAR 	if (macb_eth_initialize(0, (void *)CONFIG_SYS_MACB0_BASE,
79*9afc1af0SVipin Kumar 				CONFIG_MACB0_PHY) >= 0)
80*9afc1af0SVipin Kumar 		ret++;
818eb0ee6aSVipin KUMAR 
828eb0ee6aSVipin KUMAR 	if (macb_eth_initialize(1, (void *)CONFIG_SYS_MACB1_BASE,
83*9afc1af0SVipin Kumar 				CONFIG_MACB1_PHY) >= 0)
84*9afc1af0SVipin Kumar 		ret++;
858eb0ee6aSVipin KUMAR 
868eb0ee6aSVipin KUMAR 	if (macb_eth_initialize(2, (void *)CONFIG_SYS_MACB2_BASE,
87*9afc1af0SVipin Kumar 				CONFIG_MACB2_PHY) >= 0)
88*9afc1af0SVipin Kumar 		ret++;
898eb0ee6aSVipin KUMAR 
908eb0ee6aSVipin KUMAR 	if (macb_eth_initialize(3, (void *)CONFIG_SYS_MACB3_BASE,
91*9afc1af0SVipin Kumar 				CONFIG_MACB3_PHY) >= 0)
92*9afc1af0SVipin Kumar 		ret++;
938eb0ee6aSVipin KUMAR #endif
948eb0ee6aSVipin KUMAR 	return ret;
95deb00562SVipin KUMAR }
96