1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26#include <common.h>
27#include <command.h>
28#include <asm/processor.h>
29#include <asm/io.h>
30#include <spi.h>
31#include <netdev.h>
32#include <asm/ppc4xx-gpio.h>
33
34extern int lcd_init(void);
35
36
37
38
39int board_early_init_f(void)
40{
41 lcd_init();
42
43 mtdcr(UIC0SR, 0xFFFFFFFF);
44 mtdcr(UIC0ER, 0x00000000);
45 mtdcr(UIC0CR, 0x00000000);
46 mtdcr(UIC0PR, 0xFFFF7F00);
47 mtdcr(UIC0TR, 0x00000000);
48 mtdcr(UIC0SR, 0xFFFFFFFF);
49 mtdcr(UIC0VCR, 0x00000001);
50
51 mtebc(PB3AP, CONFIG_SYS_EBC_PB3AP);
52 mtebc(PB3CR, CONFIG_SYS_EBC_PB3CR);
53
54
55
56
57
58 mtdcr(CPC0_PCI, CPC0_PCI_SPE | CPC0_PCI_HOST_CFG_EN | CPC0_PCI_ARBIT_EN);
59
60 return 0;
61}
62
63
64
65
66int checkboard(void)
67{
68 char buf[64];
69 int i = getenv_f("serial#", buf, sizeof(buf));
70
71 puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
72
73 if (i > 0) {
74 puts(", serial# ");
75 puts(buf);
76 }
77 putc('\n');
78
79 return 0;
80}
81
82static int do_sw_stat(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
83{
84 char stat;
85 int i;
86
87 stat = in_8((u8 *) CPLD_REG0_ADDR);
88 printf("SW2 status: ");
89 for (i=0; i<4; i++)
90 printf("%d:%s ", i, stat & (0x08 >> i)?"on":"off");
91 printf("\n");
92 return 0;
93}
94
95U_BOOT_CMD (
96 sw2_stat, 1, 1, do_sw_stat,
97 "show status of switch 2",
98 ""
99);
100
101static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char * const argv[])
102{
103 int led_no;
104
105 if (argc != 3)
106 return cmd_usage(cmd_tp);
107
108 led_no = simple_strtoul(argv[1], NULL, 16);
109 if (led_no != 1 && led_no != 2)
110 return cmd_usage(cmd_tp);
111
112 if (strcmp(argv[2],"off") == 0x0) {
113 if (led_no == 1)
114 gpio_write_bit(30, 1);
115 else
116 gpio_write_bit(31, 1);
117 } else if (strcmp(argv[2],"on") == 0x0) {
118 if (led_no == 1)
119 gpio_write_bit(30, 0);
120 else
121 gpio_write_bit(31, 0);
122 } else {
123 return cmd_usage(cmd_tp);
124 }
125
126 return 0;
127}
128
129U_BOOT_CMD (
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"
133 "\tled_no is 1 or 2"
134);
135
136#define SPI_CS_GPIO0 0
137#define SPI_SCLK_GPIO14 14
138#define SPI_DIN_GPIO15 15
139#define SPI_DOUT_GPIO16 16
140
141void spi_scl(int bit)
142{
143 gpio_write_bit(SPI_SCLK_GPIO14, bit);
144}
145
146void spi_sda(int bit)
147{
148 gpio_write_bit(SPI_DOUT_GPIO16, bit);
149}
150
151unsigned char spi_read(void)
152{
153 return (unsigned char)gpio_read_in_bit(SPI_DIN_GPIO15);
154}
155
156int spi_cs_is_valid(unsigned int bus, unsigned int cs)
157{
158 return bus == 0 && cs == 0;
159}
160
161void spi_cs_activate(struct spi_slave *slave)
162{
163 gpio_write_bit(SPI_CS_GPIO0, 1);
164}
165
166void spi_cs_deactivate(struct spi_slave *slave)
167{
168 gpio_write_bit(SPI_CS_GPIO0, 0);
169}
170
171#ifdef CONFIG_PCI
172static 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};
177
178static void taihu_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
179{
180 unsigned char int_line = int_lines[PCI_DEV(dev) & 31];
181
182 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
183}
184
185int pci_pre_init(struct pci_controller *hose)
186{
187 hose->fixup_irq = taihu_pci_fixup_irq;
188 return 1;
189}
190#endif
191
192int board_eth_init(bd_t *bis)
193{
194 cpu_eth_init(bis);
195 return pci_eth_init(bis);
196}
197