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 * SPDX-License-Identifier: GPL-2.0+
12 #include <asm/processor.h>
16 #include <asm/ppc4xx-gpio.h>
18 extern int lcd_init(void);
23 int board_early_init_f(void)
27 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
28 mtdcr(UIC0ER, 0x00000000); /* disable all ints */
29 mtdcr(UIC0CR, 0x00000000);
30 mtdcr(UIC0PR, 0xFFFF7F00); /* set int polarities */
31 mtdcr(UIC0TR, 0x00000000); /* set int trigger levels */
32 mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
33 mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority */
35 mtebc(PB3AP, CONFIG_SYS_EBC_PB3AP); /* memory bank 3 (CPLD_LCM) initialization */
36 mtebc(PB3CR, CONFIG_SYS_EBC_PB3CR);
39 * Configure CPC0_PCI to enable PerWE as output
40 * and enable the internal PCI arbiter
42 mtdcr(CPC0_PCI, CPC0_PCI_SPE | CPC0_PCI_HOST_CFG_EN | CPC0_PCI_ARBIT_EN);
48 * Check Board Identity:
53 int i = getenv_f("serial#", buf, sizeof(buf));
55 puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
66 static int do_sw_stat(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
71 stat = in_8((u8 *) CPLD_REG0_ADDR);
72 printf("SW2 status: ");
73 for (i=0; i<4; i++) /* 4-position */
74 printf("%d:%s ", i, stat & (0x08 >> i)?"on":"off");
80 sw2_stat, 1, 1, do_sw_stat,
81 "show status of switch 2",
85 static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
90 return cmd_usage(cmd_tp);
92 led_no = simple_strtoul(argv[1], NULL, 16);
93 if (led_no != 1 && led_no != 2)
94 return cmd_usage(cmd_tp);
96 if (strcmp(argv[2],"off") == 0x0) {
98 gpio_write_bit(30, 1);
100 gpio_write_bit(31, 1);
101 } else if (strcmp(argv[2],"on") == 0x0) {
103 gpio_write_bit(30, 0);
105 gpio_write_bit(31, 0);
107 return cmd_usage(cmd_tp);
114 led_ctl, 3, 1, do_led_ctl,
115 "make led 1 or 2 on or off",
116 "<led_no> <on/off> - make led <led_no> on/off,\n"
120 #define SPI_CS_GPIO0 0
121 #define SPI_SCLK_GPIO14 14
122 #define SPI_DIN_GPIO15 15
123 #define SPI_DOUT_GPIO16 16
125 void spi_scl(int bit)
127 gpio_write_bit(SPI_SCLK_GPIO14, bit);
130 void spi_sda(int bit)
132 gpio_write_bit(SPI_DOUT_GPIO16, bit);
135 unsigned char spi_read(void)
137 return (unsigned char)gpio_read_in_bit(SPI_DIN_GPIO15);
140 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
142 return bus == 0 && cs == 0;
145 void spi_cs_activate(struct spi_slave *slave)
147 gpio_write_bit(SPI_CS_GPIO0, 1);
150 void spi_cs_deactivate(struct spi_slave *slave)
152 gpio_write_bit(SPI_CS_GPIO0, 0);
156 static unsigned char int_lines[32] = {
157 29, 30, 27, 28, 29, 30, 25, 27,
158 29, 30, 27, 28, 29, 30, 27, 28,
159 29, 30, 27, 28, 29, 30, 27, 28,
160 29, 30, 27, 28, 29, 30, 27, 28};
162 static void taihu_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
164 unsigned char int_line = int_lines[PCI_DEV(dev) & 31];
166 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
169 int pci_pre_init(struct pci_controller *hose)
171 hose->fixup_irq = taihu_pci_fixup_irq;
174 #endif /* CONFIG_PCI */
176 int board_eth_init(bd_t *bis)
179 return pci_eth_init(bis);