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