mpc8315erdb.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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 <hwconfig.h>
  27. #include <i2c.h>
  28. #include <libfdt.h>
  29. #include <fdt_support.h>
  30. #include <pci.h>
  31. #include <mpc83xx.h>
  32. #include <netdev.h>
  33. #include <asm/io.h>
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int board_early_init_f(void)
  36. {
  37. volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
  38. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  39. gd->flags |= GD_FLG_SILENT;
  40. return 0;
  41. }
  42. static u8 read_board_info(void)
  43. {
  44. u8 val8;
  45. i2c_set_bus_num(0);
  46. if (i2c_read(CONFIG_SYS_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
  47. return val8;
  48. else
  49. return 0;
  50. }
  51. int checkboard(void)
  52. {
  53. static const char * const rev_str[] = {
  54. "0.0",
  55. "0.1",
  56. "1.0",
  57. "1.1",
  58. "<unknown>",
  59. };
  60. u8 info;
  61. int i;
  62. info = read_board_info();
  63. i = (!info) ? 4: info & 0x03;
  64. printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
  65. return 0;
  66. }
  67. static struct pci_region pci_regions[] = {
  68. {
  69. bus_start: CONFIG_SYS_PCI_MEM_BASE,
  70. phys_start: CONFIG_SYS_PCI_MEM_PHYS,
  71. size: CONFIG_SYS_PCI_MEM_SIZE,
  72. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  73. },
  74. {
  75. bus_start: CONFIG_SYS_PCI_MMIO_BASE,
  76. phys_start: CONFIG_SYS_PCI_MMIO_PHYS,
  77. size: CONFIG_SYS_PCI_MMIO_SIZE,
  78. flags: PCI_REGION_MEM
  79. },
  80. {
  81. bus_start: CONFIG_SYS_PCI_IO_BASE,
  82. phys_start: CONFIG_SYS_PCI_IO_PHYS,
  83. size: CONFIG_SYS_PCI_IO_SIZE,
  84. flags: PCI_REGION_IO
  85. }
  86. };
  87. static struct pci_region pcie_regions_0[] = {
  88. {
  89. .bus_start = CONFIG_SYS_PCIE1_MEM_BASE,
  90. .phys_start = CONFIG_SYS_PCIE1_MEM_PHYS,
  91. .size = CONFIG_SYS_PCIE1_MEM_SIZE,
  92. .flags = PCI_REGION_MEM,
  93. },
  94. {
  95. .bus_start = CONFIG_SYS_PCIE1_IO_BASE,
  96. .phys_start = CONFIG_SYS_PCIE1_IO_PHYS,
  97. .size = CONFIG_SYS_PCIE1_IO_SIZE,
  98. .flags = PCI_REGION_IO,
  99. },
  100. };
  101. static struct pci_region pcie_regions_1[] = {
  102. {
  103. .bus_start = CONFIG_SYS_PCIE2_MEM_BASE,
  104. .phys_start = CONFIG_SYS_PCIE2_MEM_PHYS,
  105. .size = CONFIG_SYS_PCIE2_MEM_SIZE,
  106. .flags = PCI_REGION_MEM,
  107. },
  108. {
  109. .bus_start = CONFIG_SYS_PCIE2_IO_BASE,
  110. .phys_start = CONFIG_SYS_PCIE2_IO_PHYS,
  111. .size = CONFIG_SYS_PCIE2_IO_SIZE,
  112. .flags = PCI_REGION_IO,
  113. },
  114. };
  115. void pci_init_board(void)
  116. {
  117. volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
  118. volatile sysconf83xx_t *sysconf = &immr->sysconf;
  119. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  120. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  121. volatile law83xx_t *pcie_law = sysconf->pcielaw;
  122. struct pci_region *reg[] = { pci_regions };
  123. struct pci_region *pcie_reg[] = { pcie_regions_0, pcie_regions_1, };
  124. int warmboot;
  125. /* Enable all 3 PCI_CLK_OUTPUTs. */
  126. clk->occr |= 0xe0000000;
  127. /*
  128. * Configure PCI Local Access Windows
  129. */
  130. pci_law[0].bar = CONFIG_SYS_PCI_MEM_PHYS & LAWBAR_BAR;
  131. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  132. pci_law[1].bar = CONFIG_SYS_PCI_IO_PHYS & LAWBAR_BAR;
  133. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  134. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  135. warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
  136. mpc83xx_pci_init(1, reg, warmboot);
  137. /* Configure the clock for PCIE controller */
  138. clrsetbits_be32(&clk->sccr, SCCR_PCIEXP1CM | SCCR_PCIEXP2CM,
  139. SCCR_PCIEXP1CM_1 | SCCR_PCIEXP2CM_1);
  140. /* Deassert the resets in the control register */
  141. out_be32(&sysconf->pecr1, 0xE0008000);
  142. out_be32(&sysconf->pecr2, 0xE0008000);
  143. udelay(2000);
  144. /* Configure PCI Express Local Access Windows */
  145. out_be32(&pcie_law[0].bar, CONFIG_SYS_PCIE1_BASE & LAWBAR_BAR);
  146. out_be32(&pcie_law[0].ar, LBLAWAR_EN | LBLAWAR_512MB);
  147. out_be32(&pcie_law[1].bar, CONFIG_SYS_PCIE2_BASE & LAWBAR_BAR);
  148. out_be32(&pcie_law[1].ar, LBLAWAR_EN | LBLAWAR_512MB);
  149. mpc83xx_pcie_init(2, pcie_reg, warmboot);
  150. }
  151. #if defined(CONFIG_OF_BOARD_SETUP)
  152. void fdt_tsec1_fixup(void *fdt, bd_t *bd)
  153. {
  154. const char disabled[] = "disabled";
  155. const char *path;
  156. int ret;
  157. if (hwconfig_arg_cmp("board_type", "tsec1")) {
  158. return;
  159. } else if (!hwconfig_arg_cmp("board_type", "ulpi")) {
  160. printf("NOTICE: No or unknown board_type hwconfig specified.\n"
  161. " Assuming board with TSEC1.\n");
  162. return;
  163. }
  164. ret = fdt_path_offset(fdt, "/aliases");
  165. if (ret < 0) {
  166. printf("WARNING: can't find /aliases node\n");
  167. return;
  168. }
  169. path = fdt_getprop(fdt, ret, "ethernet0", NULL);
  170. if (!path) {
  171. printf("WARNING: can't find ethernet0 alias\n");
  172. return;
  173. }
  174. do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
  175. }
  176. void ft_board_setup(void *blob, bd_t *bd)
  177. {
  178. ft_cpu_setup(blob, bd);
  179. #ifdef CONFIG_PCI
  180. ft_pci_setup(blob, bd);
  181. #endif
  182. fdt_fixup_dr_usb(blob, bd);
  183. fdt_tsec1_fixup(blob, bd);
  184. }
  185. #endif
  186. int board_eth_init(bd_t *bis)
  187. {
  188. cpu_eth_init(bis); /* Initialize TSECs first */
  189. return pci_eth_init(bis);
  190. }