mpc8315erdb.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. DECLARE_GLOBAL_DATA_PTR;
  32. int board_early_init_f(void)
  33. {
  34. volatile immap_t *im = (immap_t *)CFG_IMMR;
  35. if (im->pmc.pmccr1 & PMCCR1_POWER_OFF)
  36. gd->flags |= GD_FLG_SILENT;
  37. return 0;
  38. }
  39. static u8 read_board_info(void)
  40. {
  41. u8 val8;
  42. i2c_set_bus_num(0);
  43. if (i2c_read(CFG_I2C_PCF8574A_ADDR, 0, 0, &val8, 1) == 0)
  44. return val8;
  45. else
  46. return 0;
  47. }
  48. int checkboard(void)
  49. {
  50. static const char * const rev_str[] = {
  51. "0.0",
  52. "0.1",
  53. "1.0",
  54. "1.1",
  55. "<unknown>",
  56. };
  57. u8 info;
  58. int i;
  59. info = read_board_info();
  60. i = (!info) ? 4: info & 0x03;
  61. printf("Board: Freescale MPC8315ERDB Rev %s\n", rev_str[i]);
  62. return 0;
  63. }
  64. static struct pci_region pci_regions[] = {
  65. {
  66. bus_start: CFG_PCI_MEM_BASE,
  67. phys_start: CFG_PCI_MEM_PHYS,
  68. size: CFG_PCI_MEM_SIZE,
  69. flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
  70. },
  71. {
  72. bus_start: CFG_PCI_MMIO_BASE,
  73. phys_start: CFG_PCI_MMIO_PHYS,
  74. size: CFG_PCI_MMIO_SIZE,
  75. flags: PCI_REGION_MEM
  76. },
  77. {
  78. bus_start: CFG_PCI_IO_BASE,
  79. phys_start: CFG_PCI_IO_PHYS,
  80. size: CFG_PCI_IO_SIZE,
  81. flags: PCI_REGION_IO
  82. }
  83. };
  84. void pci_init_board(void)
  85. {
  86. volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
  87. volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
  88. volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
  89. struct pci_region *reg[] = { pci_regions };
  90. int warmboot;
  91. /* Enable all 3 PCI_CLK_OUTPUTs. */
  92. clk->occr |= 0xe0000000;
  93. /*
  94. * Configure PCI Local Access Windows
  95. */
  96. pci_law[0].bar = CFG_PCI_MEM_PHYS & LAWBAR_BAR;
  97. pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
  98. pci_law[1].bar = CFG_PCI_IO_PHYS & LAWBAR_BAR;
  99. pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
  100. warmboot = gd->bd->bi_bootflags & BOOTFLAG_WARM;
  101. warmboot |= immr->pmc.pmccr1 & PMCCR1_POWER_OFF;
  102. mpc83xx_pci_init(1, reg, warmboot);
  103. }
  104. #if defined(CONFIG_OF_BOARD_SETUP)
  105. void fdt_tsec1_fixup(void *fdt, bd_t *bd)
  106. {
  107. char *mpc8315erdb = getenv("mpc8315erdb");
  108. const char disabled[] = "disabled";
  109. const char *path;
  110. int ret;
  111. if (!mpc8315erdb) {
  112. if (!strcmp(mpc8315erdb, "tsec1")) {
  113. return;
  114. } else if (strcmp(mpc8315erdb, "ulpi")) {
  115. printf("WARNING: wrong `mpc8315erdb' environment "
  116. "variable specified: `%s'. Should be `ulpi' "
  117. "or `tsec1'.\n", mpc8315erdb);
  118. return;
  119. }
  120. }
  121. ret = fdt_path_offset(fdt, "/aliases");
  122. if (ret < 0) {
  123. printf("WARNING: can't find /aliases node\n");
  124. return;
  125. }
  126. path = fdt_getprop(fdt, ret, "ethernet0", NULL);
  127. if (!path) {
  128. printf("WARNING: can't find ethernet0 alias\n");
  129. return;
  130. }
  131. do_fixup_by_path(fdt, path, "status", disabled, sizeof(disabled), 1);
  132. }
  133. void ft_board_setup(void *blob, bd_t *bd)
  134. {
  135. ft_cpu_setup(blob, bd);
  136. #ifdef CONFIG_PCI
  137. ft_pci_setup(blob, bd);
  138. #endif
  139. fdt_fixup_dr_usb(blob, bd);
  140. fdt_tsec1_fixup(blob, bd);
  141. }
  142. #endif