2 * (C) Copyright 2000-2005
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * (C) Copyright 2005-2007
6 * Beijing UD Technology Co., Ltd., taihusupport@amcc.com
8 * See file CREDITS for list of people who contributed to this
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <asm/processor.h>
33 extern int lcd_init(void);
38 int board_early_init_f(void)
42 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
43 mtdcr(uicer, 0x00000000); /* disable all ints */
44 mtdcr(uiccr, 0x00000000);
45 mtdcr(uicpr, 0xFFFF7F00); /* set int polarities */
46 mtdcr(uictr, 0x00000000); /* set int trigger levels */
47 mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */
48 mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */
50 mtebc(pb3ap, CFG_EBC_PB3AP); /* memory bank 3 (CPLD_LCM) initialization */
51 mtebc(pb3cr, CFG_EBC_PB3CR);
54 * Configure CPC0_PCI to enable PerWE as output
55 * and enable the internal PCI arbiter
57 mtdcr(cpc0_pci, CPC0_PCI_SPE | CPC0_PCI_HOST_CFG_EN | CPC0_PCI_ARBIT_EN);
63 * Check Board Identity:
67 char *s = getenv("serial#");
69 puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
80 /*************************************************************************
83 ************************************************************************/
84 long int initdram(int board)
86 return CFG_SDRAM_SIZE_PER_BANK * CFG_SDRAM_BANKS; /* 128Mbytes */
89 static int do_sw_stat(cmd_tbl_t* cmd_tp, int flags, int argc, char *argv[])
94 stat = in_8((u8 *) CPLD_REG0_ADDR);
95 printf("SW2 status: ");
96 for (i=0; i<4; i++) /* 4-position */
97 printf("%d:%s ", i, stat & (0x08 >> i)?"on":"off");
103 sw2_stat, 1, 1, do_sw_stat,
104 "sw2_stat - show status of switch 2\n",
108 static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char *argv[])
113 printf("%s", cmd_tp->usage);
117 led_no = simple_strtoul(argv[1], NULL, 16);
118 if (led_no != 1 && led_no != 2) {
119 printf("%s", cmd_tp->usage);
123 if (strcmp(argv[2],"off") == 0x0) {
125 gpio_write_bit(30, 1);
127 gpio_write_bit(31, 1);
128 } else if (strcmp(argv[2],"on") == 0x0) {
130 gpio_write_bit(30, 0);
132 gpio_write_bit(31, 0);
134 printf("%s", cmd_tp->usage);
142 led_ctl, 3, 1, do_led_ctl,
143 "led_ctl - make led 1 or 2 on or off\n",
144 "<led_no> <on/off> - make led <led_no> on/off,\n"
145 "\tled_no is 1 or 2\t"
148 #define SPI_CS_GPIO0 0
149 #define SPI_SCLK_GPIO14 14
150 #define SPI_DIN_GPIO15 15
151 #define SPI_DOUT_GPIO16 16
153 void spi_scl(int bit)
155 gpio_write_bit(SPI_SCLK_GPIO14, bit);
158 void spi_sda(int bit)
160 gpio_write_bit(SPI_DOUT_GPIO16, bit);
163 unsigned char spi_read(void)
165 return (unsigned char)gpio_read_in_bit(SPI_DIN_GPIO15);
168 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
170 return bus == 0 && cs == 0;
173 void spi_cs_activate(struct spi_slave *slave)
175 gpio_write_bit(SPI_CS_GPIO0, 1);
178 void spi_cs_deactivate(struct spi_slave *slave)
180 gpio_write_bit(SPI_CS_GPIO0, 0);
184 static unsigned char int_lines[32] = {
185 29, 30, 27, 28, 29, 30, 25, 27,
186 29, 30, 27, 28, 29, 30, 27, 28,
187 29, 30, 27, 28, 29, 30, 27, 28,
188 29, 30, 27, 28, 29, 30, 27, 28};
190 static void taihu_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
192 unsigned char int_line = int_lines[PCI_DEV(dev) & 31];
194 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
197 int pci_pre_init(struct pci_controller *hose)
199 hose->fixup_irq = taihu_pci_fixup_irq;
202 #endif /* CONFIG_PCI */