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/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 *s = getenv("serial#");
69
70 puts("Board: Taihu - AMCC PPC405EP Evaluation Board");
71
72 if (s != NULL) {
73 puts(", serial# ");
74 puts(s);
75 }
76 putc('\n');
77
78 return 0;
79}
80
81static int do_sw_stat(cmd_tbl_t* cmd_tp, int flags, int argc, char *argv[])
82{
83 char stat;
84 int i;
85
86 stat = in_8((u8 *) CPLD_REG0_ADDR);
87 printf("SW2 status: ");
88 for (i=0; i<4; i++)
89 printf("%d:%s ", i, stat & (0x08 >> i)?"on":"off");
90 printf("\n");
91 return 0;
92}
93
94U_BOOT_CMD (
95 sw2_stat, 1, 1, do_sw_stat,
96 "show status of switch 2",
97 ""
98);
99
100static int do_led_ctl(cmd_tbl_t* cmd_tp, int flags, int argc, char *argv[])
101{
102 int led_no;
103
104 if (argc != 3) {
105 cmd_usage(cmd_tp);
106 return -1;
107 }
108
109 led_no = simple_strtoul(argv[1], NULL, 16);
110 if (led_no != 1 && led_no != 2) {
111 cmd_usage(cmd_tp);
112 return -1;
113 }
114
115 if (strcmp(argv[2],"off") == 0x0) {
116 if (led_no == 1)
117 gpio_write_bit(30, 1);
118 else
119 gpio_write_bit(31, 1);
120 } else if (strcmp(argv[2],"on") == 0x0) {
121 if (led_no == 1)
122 gpio_write_bit(30, 0);
123 else
124 gpio_write_bit(31, 0);
125 } else {
126 cmd_usage(cmd_tp);
127 return -1;
128 }
129
130 return 0;
131}
132
133U_BOOT_CMD (
134 led_ctl, 3, 1, do_led_ctl,
135 "make led 1 or 2 on or off",
136 "<led_no> <on/off> - make led <led_no> on/off,\n"
137 "\tled_no is 1 or 2"
138);
139
140#define SPI_CS_GPIO0 0
141#define SPI_SCLK_GPIO14 14
142#define SPI_DIN_GPIO15 15
143#define SPI_DOUT_GPIO16 16
144
145void spi_scl(int bit)
146{
147 gpio_write_bit(SPI_SCLK_GPIO14, bit);
148}
149
150void spi_sda(int bit)
151{
152 gpio_write_bit(SPI_DOUT_GPIO16, bit);
153}
154
155unsigned char spi_read(void)
156{
157 return (unsigned char)gpio_read_in_bit(SPI_DIN_GPIO15);
158}
159
160int spi_cs_is_valid(unsigned int bus, unsigned int cs)
161{
162 return bus == 0 && cs == 0;
163}
164
165void spi_cs_activate(struct spi_slave *slave)
166{
167 gpio_write_bit(SPI_CS_GPIO0, 1);
168}
169
170void spi_cs_deactivate(struct spi_slave *slave)
171{
172 gpio_write_bit(SPI_CS_GPIO0, 0);
173}
174
175#ifdef CONFIG_PCI
176static unsigned char int_lines[32] = {
177 29, 30, 27, 28, 29, 30, 25, 27,
178 29, 30, 27, 28, 29, 30, 27, 28,
179 29, 30, 27, 28, 29, 30, 27, 28,
180 29, 30, 27, 28, 29, 30, 27, 28};
181
182static void taihu_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
183{
184 unsigned char int_line = int_lines[PCI_DEV(dev) & 31];
185
186 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
187}
188
189int pci_pre_init(struct pci_controller *hose)
190{
191 hose->fixup_irq = taihu_pci_fixup_irq;
192 return 1;
193}
194#endif
195
196int board_eth_init(bd_t *bis)
197{
198 cpu_eth_init(bis);
199 return pci_eth_init(bis);
200}
201