mpc8308rdb.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Copyright (C) 2010 Freescale Semiconductor, Inc.
  3. * Copyright (C) 2010 Ilya Yanok, Emcraft Systems, yanok@emcraft.com
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  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.
  12. *
  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.
  17. *
  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,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <hwconfig.h>
  25. #include <i2c.h>
  26. #include <spi.h>
  27. #include <libfdt.h>
  28. #include <fdt_support.h>
  29. #include <pci.h>
  30. #include <mpc83xx.h>
  31. #include <vsc7385.h>
  32. #include <netdev.h>
  33. #include <asm/io.h>
  34. #include <asm/fsl_serdes.h>
  35. #include <asm/fsl_mpc83xx_serdes.h>
  36. DECLARE_GLOBAL_DATA_PTR;
  37. /*
  38. * The following are used to control the SPI chip selects for the SPI command.
  39. */
  40. #ifdef CONFIG_MPC8XXX_SPI
  41. #define SPI_CS_MASK 0x00400000
  42. int spi_cs_is_valid(unsigned int bus, unsigned int cs)
  43. {
  44. return bus == 0 && cs == 0;
  45. }
  46. void spi_cs_activate(struct spi_slave *slave)
  47. {
  48. immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  49. /* active low */
  50. clrbits_be32(&immr->gpio[0].dat, SPI_CS_MASK);
  51. }
  52. void spi_cs_deactivate(struct spi_slave *slave)
  53. {
  54. immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  55. /* inactive high */
  56. setbits_be32(&immr->gpio[0].dat, SPI_CS_MASK);
  57. }
  58. #endif /* CONFIG_MPC8XXX_SPI */
  59. static u8 read_board_info(void)
  60. {
  61. u8 val8;
  62. i2c_set_bus_num(0);
  63. if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
  64. return val8;
  65. else
  66. return 0;
  67. }
  68. int checkboard(void)
  69. {
  70. static const char * const rev_str[] = {
  71. "1.0",
  72. "<reserved>",
  73. "<reserved>",
  74. "<reserved>",
  75. "<unknown>",
  76. };
  77. u8 info;
  78. int i;
  79. info = read_board_info();
  80. i = (!info) ? 4 : info & 0x03;
  81. printf("Board: Freescale MPC8308RDB Rev %s\n", rev_str[i]);
  82. return 0;
  83. }
  84. static struct pci_region pcie_regions_0[] = {
  85. {
  86. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  87. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  88. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  89. .flags = PCI_REGION_MEM,
  90. },
  91. {
  92. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  93. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  94. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  95. .flags = PCI_REGION_IO,
  96. },
  97. };
  98. void pci_init_board(void)
  99. {
  100. immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  101. sysconf83xx_t *sysconf = &immr->sysconf;
  102. law83xx_t *pcie_law = sysconf->pcielaw;
  103. struct pci_region *pcie_reg[] = { pcie_regions_0 };
  104. fsl_setup_serdes(CONFIG_FSL_SERDES1, FSL_SERDES_PROTO_PEX,
  105. FSL_SERDES_CLK_100, FSL_SERDES_VDD_1V);
  106. /* Deassert the resets in the control register */
  107. out_be32(&sysconf->pecr1, 0xE0008000);
  108. udelay(2000);
  109. /* Configure PCI Express Local Access Windows */
  110. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  111. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  112. mpc83xx_pcie_init(1, pcie_reg);
  113. }
  114. /*
  115. * Miscellaneous late-boot configurations
  116. *
  117. * If a VSC7385 microcode image is present, then upload it.
  118. */
  119. int misc_init_r(void)
  120. {
  121. #ifdef CONFIG_MPC8XXX_SPI
  122. immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  123. sysconf83xx_t *sysconf = &immr->sysconf;
  124. /*
  125. * Set proper bits in SICRH to allow SPI on header J8
  126. *
  127. * NOTE: this breaks the TSEC2 interface, attached to the Vitesse
  128. * switch. The pinmux configuration does not have a fine enough
  129. * granularity to support both simultaneously.
  130. */
  131. clrsetbits_be32(&sysconf->sicrh, SICRH_GPIO_A_TSEC2, SICRH_GPIO_A_GPIO);
  132. puts("WARNING: SPI enabled, TSEC2 support is broken\n");
  133. /* Set header J8 SPI chip select output, disabled */
  134. setbits_be32(&immr->gpio[0].dir, SPI_CS_MASK);
  135. setbits_be32(&immr->gpio[0].dat, SPI_CS_MASK);
  136. #endif
  137. #ifdef CONFIG_VSC7385_IMAGE
  138. if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE,
  139. CONFIG_VSC7385_IMAGE_SIZE)) {
  140. puts("Failure uploading VSC7385 microcode.\n");
  141. return 1;
  142. }
  143. #endif
  144. return 0;
  145. }
  146. #if defined(CONFIG_OF_BOARD_SETUP)
  147. void ft_board_setup(void *blob, bd_t *bd)
  148. {
  149. ft_cpu_setup(blob, bd);
  150. fdt_fixup_dr_usb(blob, bd);
  151. }
  152. #endif
  153. int board_eth_init(bd_t *bis)
  154. {
  155. int rv, num_if = 0;
  156. /* Initialize TSECs first */
  157. rv = cpu_eth_init(bis);
  158. if (rv >= 0)
  159. num_if += rv;
  160. else
  161. printf("ERROR: failed to initialize TSECs.\n");
  162. rv = pci_eth_init(bis);
  163. if (rv >= 0)
  164. num_if += rv;
  165. else
  166. printf("ERROR: failed to initialize PCI Ethernet.\n");
  167. return num_if;
  168. }