Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) Freescale Semiconductor, Inc. 2006-2007 |
| 4 | * |
| 5 | * Author: Scott Wood <scottwood@freescale.com> |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Kim Phillips | b3458d2 | 2007-12-20 15:57:28 -0600 | [diff] [blame] | 9 | #if defined(CONFIG_OF_LIBFDT) |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 10 | #include <linux/libfdt.h> |
Kim Phillips | 3fde9e8 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 11 | #endif |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 12 | #include <pci.h> |
| 13 | #include <mpc83xx.h> |
Timur Tabi | 89c7784 | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 14 | #include <vsc7385.h> |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 15 | #include <ns16550.h> |
| 16 | #include <nand.h> |
Scott Wood | 22f4442 | 2012-12-06 13:33:18 +0000 | [diff] [blame] | 17 | #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD) |
Joe Hershberger | 0eaf8f9 | 2011-11-11 15:55:38 -0600 | [diff] [blame] | 18 | #include <asm/gpio.h> |
| 19 | #endif |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 20 | |
| 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
| 23 | int board_early_init_f(void) |
| 24 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 25 | #ifndef CONFIG_SYS_8313ERDB_BROKEN_PMC |
| 26 | volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 27 | |
| 28 | if (im->pmc.pmccr1 & PMCCR1_POWER_OFF) |
| 29 | gd->flags |= GD_FLG_SILENT; |
| 30 | #endif |
Scott Wood | 22f4442 | 2012-12-06 13:33:18 +0000 | [diff] [blame] | 31 | #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD) |
Joe Hershberger | 0eaf8f9 | 2011-11-11 15:55:38 -0600 | [diff] [blame] | 32 | mpc83xx_gpio_init_f(); |
| 33 | #endif |
| 34 | |
| 35 | return 0; |
| 36 | } |
| 37 | |
| 38 | int board_early_init_r(void) |
| 39 | { |
Scott Wood | 22f4442 | 2012-12-06 13:33:18 +0000 | [diff] [blame] | 40 | #if defined(CONFIG_MPC83XX_GPIO) && !defined(CONFIG_SPL_BUILD) |
Joe Hershberger | 0eaf8f9 | 2011-11-11 15:55:38 -0600 | [diff] [blame] | 41 | mpc83xx_gpio_init_r(); |
| 42 | #endif |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int checkboard(void) |
| 48 | { |
| 49 | puts("Board: Freescale MPC8313ERDB\n"); |
| 50 | return 0; |
| 51 | } |
| 52 | |
Scott Wood | 22f4442 | 2012-12-06 13:33:18 +0000 | [diff] [blame] | 53 | #ifndef CONFIG_SPL_BUILD |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 54 | static struct pci_region pci_regions[] = { |
| 55 | { |
Kim Phillips | a2873bd | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 56 | .bus_start = CONFIG_SYS_PCI1_MEM_BASE, |
| 57 | .phys_start = CONFIG_SYS_PCI1_MEM_PHYS, |
| 58 | .size = CONFIG_SYS_PCI1_MEM_SIZE, |
| 59 | .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 60 | }, |
| 61 | { |
Kim Phillips | a2873bd | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 62 | .bus_start = CONFIG_SYS_PCI1_MMIO_BASE, |
| 63 | .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS, |
| 64 | .size = CONFIG_SYS_PCI1_MMIO_SIZE, |
| 65 | .flags = PCI_REGION_MEM |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 66 | }, |
| 67 | { |
Kim Phillips | a2873bd | 2012-10-29 13:34:39 +0000 | [diff] [blame] | 68 | .bus_start = CONFIG_SYS_PCI1_IO_BASE, |
| 69 | .phys_start = CONFIG_SYS_PCI1_IO_PHYS, |
| 70 | .size = CONFIG_SYS_PCI1_IO_SIZE, |
| 71 | .flags = PCI_REGION_IO |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 72 | } |
| 73 | }; |
| 74 | |
| 75 | void pci_init_board(void) |
| 76 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 78 | volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk; |
| 79 | volatile law83xx_t *pci_law = immr->sysconf.pcilaw; |
| 80 | struct pci_region *reg[] = { pci_regions }; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 81 | |
| 82 | /* Enable all 3 PCI_CLK_OUTPUTs. */ |
| 83 | clk->occr |= 0xe0000000; |
| 84 | |
| 85 | /* |
| 86 | * Configure PCI Local Access Windows |
| 87 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 89 | pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB; |
| 90 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 91 | pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 92 | pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB; |
| 93 | |
Peter Tyser | 6aa3d3b | 2010-09-14 19:13:50 -0500 | [diff] [blame] | 94 | mpc83xx_pci_init(1, reg); |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 95 | } |
| 96 | |
Timur Tabi | 89c7784 | 2008-02-08 13:15:55 -0600 | [diff] [blame] | 97 | /* |
| 98 | * Miscellaneous late-boot configurations |
| 99 | * |
| 100 | * If a VSC7385 microcode image is present, then upload it. |
| 101 | */ |
| 102 | int misc_init_r(void) |
| 103 | { |
| 104 | int rc = 0; |
| 105 | |
| 106 | #ifdef CONFIG_VSC7385_IMAGE |
| 107 | if (vsc7385_upload_firmware((void *) CONFIG_VSC7385_IMAGE, |
| 108 | CONFIG_VSC7385_IMAGE_SIZE)) { |
| 109 | puts("Failure uploading VSC7385 microcode.\n"); |
| 110 | rc = 1; |
| 111 | } |
| 112 | #endif |
| 113 | |
| 114 | return rc; |
| 115 | } |
| 116 | |
Kim Phillips | 3fde9e8 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 117 | #if defined(CONFIG_OF_BOARD_SETUP) |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 118 | int ft_board_setup(void *blob, bd_t *bd) |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 119 | { |
Kim Phillips | 3fde9e8 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 120 | ft_cpu_setup(blob, bd); |
| 121 | #ifdef CONFIG_PCI |
| 122 | ft_pci_setup(blob, bd); |
| 123 | #endif |
Simon Glass | e895a4b | 2014-10-23 18:58:47 -0600 | [diff] [blame] | 124 | |
| 125 | return 0; |
Scott Wood | 96b8a05 | 2007-04-16 14:54:15 -0500 | [diff] [blame] | 126 | } |
| 127 | #endif |
Scott Wood | 22f4442 | 2012-12-06 13:33:18 +0000 | [diff] [blame] | 128 | #else /* CONFIG_SPL_BUILD */ |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 129 | void board_init_f(ulong bootflag) |
| 130 | { |
| 131 | board_early_init_f(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 132 | NS16550_init((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 133 | CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE); |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 134 | puts("NAND boot... "); |
Simon Glass | 70e2aaf | 2017-03-28 10:27:24 -0600 | [diff] [blame] | 135 | timer_init(); |
Simon Glass | f1683aa | 2017-04-06 12:47:05 -0600 | [diff] [blame] | 136 | dram_init(); |
Mingkai Hu | 6e1385d | 2009-09-11 10:53:08 +0800 | [diff] [blame] | 137 | relocate_code(CONFIG_SYS_NAND_U_BOOT_RELOC_SP, (gd_t *)gd, |
Wolfgang Denk | 93e1459 | 2013-10-04 17:43:24 +0200 | [diff] [blame] | 138 | CONFIG_SYS_NAND_U_BOOT_RELOC); |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | void board_init_r(gd_t *gd, ulong dest_addr) |
| 142 | { |
| 143 | nand_boot(); |
| 144 | } |
| 145 | |
| 146 | void putc(char c) |
| 147 | { |
| 148 | if (gd->flags & GD_FLG_SILENT) |
| 149 | return; |
| 150 | |
| 151 | if (c == '\n') |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 152 | NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), '\r'); |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 153 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 154 | NS16550_putc((NS16550_t)(CONFIG_SYS_IMMR + 0x4500), c); |
Scott Wood | e4c0950 | 2008-06-30 14:13:28 -0500 | [diff] [blame] | 155 | } |
| 156 | #endif |