mpc8315erdb.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. * Copyright (C) 2007 Freescale Semiconductor, Inc.
  3. *
  4. * Author: Scott Wood <scottwood@freescale.com>
  5. * Dave Liu <daveliu@freescale.com>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS for A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <i2c.h>
  27. #include <libfdt.h>
  28. #include <fdt_support.h>
  29. #include <pci.h>
  30. #include <mpc83xx.h>
  31. #include <netdev.h>
  32. #include <asm/io.h>
  33. DECLARE_GLOBAL_DATA_PTR;
  34. int board_early_init_f(void)
  35. {
  36. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  37. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  38. gd->flags |= GD_FLG_SILENT;
  39. return 0;
  40. }
  41. static u8 read_board_info(void)
  42. {
  43. u8 val8;
  44. i2c_set_bus_num(0);
  45. if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
  46. return val8;
  47. else
  48. return 0;
  49. }
  50. int checkboard(void)
  51. {
  52. static const char * const rev_str[] = {
  53. "0.0",
  54. "0.1",
  55. "1.0",
  56. "1.1",
  57. "<unknown>",
  58. };
  59. u8 info;
  60. int i;
  61. info = read_board_info();
  62. i = (!info) ? 4: info & 0x03;
  63. printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
  64. return 0;
  65. }
  66. static struct pci_region pci_regions[] = {
  67. {
  68. bus_start: CONFIG_SYS_PCI_MEM_BASE,
  69. phys_start: CONFIG_SYS_PCI_MEM_PHYS,
  70. size: CONFIG_SYS_PCI_MEM_SIZE,
  71. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  72. },
  73. {
  74. bus_start: CONFIG_SYS_PCI_MMIO_BASE,
  75. phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
  76. size: CONFIG_SYS_PCI_MMIO_SIZE,
  77. flags: PCI_REGION_MEM
  78. },
  79. {
  80. bus_start: CONFIG_SYS_PCI_IO_BASE,
  81. phys_start: CONFIG_SYS_PCI_IO_PHYS,
  82. size: CONFIG_SYS_PCI_IO_SIZE,
  83. flags: PCI_REGION_IO
  84. }
  85. };
  86. static struct pci_region pcie_regions_0[] = {
  87. {
  88. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  89. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  90. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  91. .flags = PCI_REGION_MEM,
  92. },
  93. {
  94. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  95. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  96. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  97. .flags = PCI_REGION_IO,
  98. },
  99. };
  100. static struct pci_region pcie_regions_1[] = {
  101. {
  102. .bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
  103. .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
  104. .size = CONFIG_SYS_PCIE2_MEM_SIZE,
  105. .flags = PCI_REGION_MEM,
  106. },
  107. {
  108. .bus_start = CONFIG_SYS_PCIE2_IO_BASE,
  109. .phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
  110. .size = CONFIG_SYS_PCIE2_IO_SIZE,
  111. .flags = PCI_REGION_IO,
  112. },
  113. };
  114. void pci_init_board(void)
  115. {
  116. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  117. volatile sysconf83xx_t *sysconf = &immr->sysconf;
  118. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  119. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  120. volatile law83xx_t *pcie_law = sysconf->pcielaw;
  121. struct pci_region *reg[] = { pci_regions };
  122. struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
  123. int warmboot;
  124. /* Enable all 3 PCI_CLK_OUTPUTs. */
  125. clk->occr |= 0xe0000000;
  126. /*
  127. * Configure PCI Local Access Windows
  128. */
  129. pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
  130. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  131. pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
  132. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  133. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  134. warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
  135. mpc83xx_pci_init(1, reg, warmboot);
  136. /* Configure the clock for PCIE controller */
  137. clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM,
  138. SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1);
  139. /* Deassert the resets in the control register */
  140. out_be32(&sysconf->pecr1, 0xE0008000);
  141. out_be32(&sysconf->pecr2, 0xE0008000);
  142. udelay(2000);
  143. /* Configure PCI Express Local Access Windows */
  144. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  145. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  146. out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
  147. out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
  148. mpc83xx_pcie_init(2, pcie_reg, warmboot);
  149. }
  150. #if defined(CONFIG_OF_BOARD_SETUP)
  151. void fdt_tsec1_fixup(void *fdt, bd_t *bd)
  152. {
  153. char *mpc8315erdb = getenv("mpc8315erdb");
  154. const char disabled[] = "disabled";
  155. const char *path;
  156. int ret;
  157. if (!mpc8315erdb)
  158. return;
  159. if (!strcmp(mpc8315erdb, "tsec1")) {
  160. return;
  161. } else if (strcmp(mpc8315erdb, "ulpi")) {
  162. printf("WARNING: wrong `mpc8315erdb' environment "
  163. "variable specified: `%s'. Should be `ulpi' "
  164. "or `tsec1'.\n", mpc8315erdb);
  165. return;
  166. }
  167. ret = fdt_path_offset(fdt, "/aliases");
  168. if (ret < 0) {
  169. printf("WARNING: can't find /aliases node\n");
  170. return;
  171. }
  172. path = fdt_getprop(fdt, ret, "ethernet0", NULL);
  173. if (!path) {
  174. printf("WARNING: can't find ethernet0 alias\n");
  175. return;
  176. }
  177. do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
  178. }
  179. void ft_board_setup(void *blob, bd_t *bd)
  180. {
  181. ft_cpu_setup(blob, bd);
  182. #ifdef CONFIG_PCI
  183. ft_pci_setup(blob, bd);
  184. #endif
  185. fdt_fixup_dr_usb(blob, bd);
  186. fdt_tsec1_fixup(blob, bd);
  187. }
  188. #endif
  189. int board_eth_init(bd_t *bis)
  190. {
  191. cpu_eth_init(bis); /* Initialize TSECs first */
  192. return pci_eth_init(bis);
  193. }