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>
32 #include <asm/ppc4xx-gpio.h>
34 extern int lcd_init(void);
39 int board_early_init_f(void)
43 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
44 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
45 mtdcr(UIC0CR, 0x00000000);
46 mtdcr(UIC0PR, 0xFFFF7F00); /* set int polarities */
47 mtdcr(UIC0TR, 0x00000000); /* set int trigger levels */
48 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
49 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority */
51 mtebc(PB3AP, CONFIG_SYS_EBC_PB3AP); /* memory bank 3 (CPLD_LCM) initialization */
52 mtebc(PB3CR, CONFIG_SYS_EBC_PB3CR);
55 * Configure CPC0_PCI to enable PerWE as output
56 * and enable the internal PCI arbiter
58 mtdcr(CPC0_PCI, CPC0_PCI_SPE | CPC0_PCI_HOST_CFG_EN | CPC0_PCI_ARBIT_EN);
64 * Check Board Identity:
69 int i = getenv_f("serial#", buf, sizeof(buf));
71 puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
82 static int do_sw_stat(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
87 stat = in_8((u8 *) CPLD_REG0_ADDR);
88 printf("SW2 status: ");
89 for (i=0; i<4; i++) /* 4-position */
90 printf("%d:%s ", i, stat & (0x08 >> i)?"on":"off");
96 sw2_stat, 1, 1, do_sw_stat,
97 "show status of switch 2",
101 static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
106 return cmd_usage(cmd_tp);
108 led_no = simple_strtoul(argv[1], NULL, 16);
109 if (led_no != 1 && led_no != 2)
110 return cmd_usage(cmd_tp);
112 if (strcmp(argv[2],"off") == 0x0) {
114 gpio_write_bit(30, 1);
116 gpio_write_bit(31, 1);
117 } else if (strcmp(argv[2],"on") == 0x0) {
119 gpio_write_bit(30, 0);
121 gpio_write_bit(31, 0);
123 return cmd_usage(cmd_tp);
130 led_ctl, 3, 1, do_led_ctl,
131 "make led 1 or 2 on or off",
132 "<led_no> <on/off> - make led <led_no> on/off,\n"
136 #define SPI_CS_GPIO0 0
137 #define SPI_SCLK_GPIO14 14
138 #define SPI_DIN_GPIO15 15
139 #define SPI_DOUT_GPIO16 16
141 void spi_scl(int bit)
143 gpio_write_bit(SPI_SCLK_GPIO14, bit);
146 void spi_sda(int bit)
148 gpio_write_bit(SPI_DOUT_GPIO16, bit);
151 unsigned char spi_read(void)
153 return (unsigned char)gpio_read_in_bit(SPI_DIN_GPIO15);
156 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
158 return bus == 0 && cs == 0;
161 void spi_cs_activate(struct spi_slave *slave)
163 gpio_write_bit(SPI_CS_GPIO0, 1);
166 void spi_cs_deactivate(struct spi_slave *slave)
168 gpio_write_bit(SPI_CS_GPIO0, 0);
172 static unsigned char int_lines[32] = {
173 29, 30, 27, 28, 29, 30, 25, 27,
174 29, 30, 27, 28, 29, 30, 27, 28,
175 29, 30, 27, 28, 29, 30, 27, 28,
176 29, 30, 27, 28, 29, 30, 27, 28};
178 static void taihu_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
180 unsigned char int_line = int_lines[PCI_DEV(dev) & 31];
182 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
185 int pci_pre_init(struct pci_controller *hose)
187 hose->fixup_irq = taihu_pci_fixup_irq;
190 #endif /* CONFIG_PCI */
192 int board_eth_init(bd_t *bis)
195 return pci_eth_init(bis);