3 * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/processor.h>
33 #include <asm/cache.h>
34 #include <asm/immap_85xx.h>
35 #include <asm/fsl_pci.h>
36 #include <fsl_ddr_sdram.h>
37 #include <asm/fsl_serdes.h>
39 #include <linux/libfdt.h>
40 #include <fdt_support.h>
43 #include <asm/fsl_law.h>
48 #include "../common/dp501.h"
49 #include "controlcenterd-id.h"
58 u32 reflection_low; /* 0x0000 */
59 u32 versions; /* 0x0004 */
60 u32 fpga_version; /* 0x0008 */
61 u32 fpga_features; /* 0x000c */
62 u32 reserved[4]; /* 0x0010 */
63 u32 control; /* 0x0020 */
66 #ifndef CONFIG_TRAILBLAZER
67 static struct pci_device_id hydra_supported[] = {
72 static void hydra_initialize(void);
75 int board_early_init_f(void)
77 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
78 ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO3_ADDR);
80 /* Reset eLBC_DIU and SPI_eLBC in case we are booting from SD */
81 clrsetbits_be32(&gur->pmuxcr, 0x00600000, 0x80000000);
83 /* Set pmuxcr to allow both i2c1 and i2c2 */
84 setbits_be32(&gur->pmuxcr, 0x00001000);
86 /* Set pmuxcr to enable GPIO 3_11-3_13 */
87 setbits_be32(&gur->pmuxcr, 0x00000010);
89 /* Set pmuxcr to enable GPIO 2_31,3_9+10 */
90 setbits_be32(&gur->pmuxcr, 0x00000020);
92 /* Set pmuxcr to enable GPIO 2_28-2_30 */
93 setbits_be32(&gur->pmuxcr, 0x000000c0);
95 /* Set pmuxcr to enable GPIO 3_20-3_22 */
96 setbits_be32(&gur->pmuxcr2, 0x03000000);
98 /* Set pmuxcr to enable IRQ0-2 */
99 clrbits_be32(&gur->pmuxcr, 0x00000300);
101 /* Set pmuxcr to disable IRQ3-11 */
102 setbits_be32(&gur->pmuxcr, 0x000000F0);
104 /* Read back the register to synchronize the write. */
105 in_be32(&gur->pmuxcr);
107 /* Set the pin muxing to enable ETSEC2. */
108 clrbits_be32(&gur->pmuxcr2, 0x001F8000);
110 #ifdef CONFIG_TRAILBLAZER
112 * GPIO3_10 SPERRTRIGGER
114 setbits_be32(&pgpio->gpdir, 0x00200000);
115 clrbits_be32(&pgpio->gpdat, 0x00200000);
117 setbits_be32(&pgpio->gpdat, 0x00200000);
119 clrbits_be32(&pgpio->gpdat, 0x00200000);
123 * GPIO3_11 CPU-TO-FPGA-RESET#
125 setbits_be32(&pgpio->gpdir, 0x00100000);
126 clrbits_be32(&pgpio->gpdat, 0x00100000);
129 * GPIO3_21 CPU-STATUS-WATCHDOG-TRIGGER#
131 setbits_be32(&pgpio->gpdir, 0x00000400);
138 printf("Board: ControlCenter DIGITAL\n");
143 int misc_init_r(void)
149 * A list of PCI and SATA slots
162 * This array maps the slot identifiers to their names on the P1022DS board.
164 static const char * const slot_names[] = {
165 [SLOT_PCIE1] = "Slot 1",
166 [SLOT_PCIE2] = "Slot 2",
167 [SLOT_PCIE3] = "Slot 3",
168 [SLOT_PCIE4] = "Slot 4",
169 [SLOT_PCIE5] = "Mini-PCIe",
170 [SLOT_SATA1] = "SATA 1",
171 [SLOT_SATA2] = "SATA 2",
175 * This array maps a given SERDES configuration and SERDES device to the PCI or
176 * SATA slot that it connects to. This mapping is hard-coded in the FPGA.
178 static u8 serdes_dev_slot[][SATA2 + 1] = {
179 [0x01] = { [PCIE3] = SLOT_PCIE4, [PCIE2] = SLOT_PCIE5 },
180 [0x02] = { [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
181 [0x09] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE4,
182 [PCIE2] = SLOT_PCIE5 },
183 [0x16] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
184 [PCIE2] = SLOT_PCIE3,
185 [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
186 [0x17] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE2,
187 [PCIE2] = SLOT_PCIE3 },
188 [0x1a] = { [PCIE1] = SLOT_PCIE1, [PCIE2] = SLOT_PCIE3,
189 [PCIE2] = SLOT_PCIE3,
190 [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
191 [0x1c] = { [PCIE1] = SLOT_PCIE1,
192 [SATA1] = SLOT_SATA1, [SATA2] = SLOT_SATA2 },
193 [0x1e] = { [PCIE1] = SLOT_PCIE1, [PCIE3] = SLOT_PCIE3 },
194 [0x1f] = { [PCIE1] = SLOT_PCIE1 },
199 * Returns the name of the slot to which the PCIe or SATA controller is
202 const char *board_serdes_name(enum srds_prtcl device)
204 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
205 u32 pordevsr = in_be32(&gur->pordevsr);
206 unsigned int srds_cfg = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >>
207 MPC85xx_PORDEVSR_IO_SEL_SHIFT;
208 enum slot_id slot = serdes_dev_slot[srds_cfg][device];
209 const char *name = slot_names[slot];
217 void hw_watchdog_reset(void)
219 ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO3_ADDR);
221 clrbits_be32(&pgpio->gpdat, 0x00000400);
222 setbits_be32(&pgpio->gpdat, 0x00000400);
225 #ifdef CONFIG_TRAILBLAZER
226 int do_bootd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
228 return run_command(env_get("bootcmd"), flag);
231 int board_early_init_r(void)
233 ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO3_ADDR);
236 * GPIO3_12 PPC_SYSTEMREADY#
238 setbits_be32(&pgpio->gpdir, 0x00080000);
239 setbits_be32(&pgpio->gpodr, 0x00080000);
240 clrbits_be32(&pgpio->gpdat, 0x00080000);
242 return ccdm_compute_self_hash();
245 int last_stage_init(void)
247 startup_ccdm_id_module();
252 void pci_init_board(void)
254 fsl_pcie_init_board(0);
259 int board_early_init_r(void)
262 ccsr_gpio_t *pgpio = (void *)(CONFIG_SYS_MPC85xx_GPIO3_ADDR);
264 /* wait for FPGA configuration to finish */
265 while (!pca9698_get_value(0x22, 11) && (k++ < 30))
269 puts("FPGA configuration timed out.\n");
271 /* clear FPGA reset */
273 setbits_be32(&pgpio->gpdat, 0x00100000);
276 /* give time for PCIe link training */
280 * GPIO3_12 PPC_SYSTEMREADY#
282 setbits_be32(&pgpio->gpdir, 0x00080000);
283 setbits_be32(&pgpio->gpodr, 0x00080000);
284 clrbits_be32(&pgpio->gpdat, 0x00080000);
289 int last_stage_init(void)
291 /* Turn on Parade DP501 */
292 pca9698_direction_output(0x22, 7, 1);
297 startup_ccdm_id_module();
303 * Initialize on-board and/or PCI Ethernet devices
307 * 0, no ethernet devices found
308 * >0, number of ethernet devices initialized
310 int board_eth_init(bd_t *bis)
312 struct fsl_pq_mdio_info mdio_info;
313 struct tsec_info_struct tsec_info[2];
314 unsigned int num = 0;
317 SET_STD_TSEC_INFO(tsec_info[num], 1);
321 SET_STD_TSEC_INFO(tsec_info[num], 2);
325 mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
326 mdio_info.name = DEFAULT_MII_NAME;
327 fsl_pq_mdio_init(bis, &mdio_info);
329 return tsec_eth_init(bis, tsec_info, num) + pci_eth_init(bis);
332 #ifdef CONFIG_OF_BOARD_SETUP
333 int ft_board_setup(void *blob, bd_t *bd)
338 ft_cpu_setup(blob, bd);
340 base = env_get_bootm_low();
341 size = env_get_bootm_size();
343 fdt_fixup_memory(blob, (u64)base, (u64)size);
345 #ifdef CONFIG_HAS_FSL_DR_USB
346 fsl_fdt_fixup_dr_usb(blob, bd);
355 static void hydra_initialize(void)
360 /* Find and probe all the matching PCI devices */
361 for (i = 0; (devno = pci_find_devices(hydra_supported, i)) >= 0; i++) {
363 struct ihs_fpga *fpga;
368 unsigned hardware_version;
369 unsigned feature_uart_channels;
370 unsigned feature_sb_channels;
372 /* Try to enable I/O accesses and bus-mastering */
373 val = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
374 pci_write_config_dword(devno, PCI_COMMAND, val);
376 /* Make sure it worked */
377 pci_read_config_dword(devno, PCI_COMMAND, &val);
378 if (!(val & PCI_COMMAND_MEMORY)) {
379 puts("Can't enable I/O memory\n");
382 if (!(val & PCI_COMMAND_MASTER)) {
383 puts("Can't enable bus-mastering\n");
387 /* read FPGA details */
388 fpga = pci_map_bar(devno, PCI_BASE_ADDRESS_0,
391 /* disable sideband clocks */
392 writel(1, &fpga->control);
394 versions = readl(&fpga->versions);
395 fpga_version = readl(&fpga->fpga_version);
396 fpga_features = readl(&fpga->fpga_features);
398 hardware_version = versions & 0xf;
399 feature_uart_channels = (fpga_features >> 6) & 0x1f;
400 feature_sb_channels = fpga_features & 0x1f;
402 printf("FPGA%d: ", i);
404 switch (hardware_version) {
406 printf("HW-Ver 1.00\n");
410 printf("HW-Ver 1.10\n");
414 printf("HW-Ver 1.20\n");
418 printf("HW-Ver %d(not supported)\n",
423 printf(" FPGA V %d.%02d, features:",
424 fpga_version / 100, fpga_version % 100);
426 printf(" %d uart channel(s)", feature_uart_channels);
427 printf(" %d sideband channel(s)\n", feature_sb_channels);