Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 Wolfgang Denk <wd@denx.de> |
| 3 | * (C) Copyright 2009 Dave Srl www.dave.eu |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <asm/bitops.h> |
| 27 | #include <command.h> |
| 28 | #include <asm/io.h> |
| 29 | #include <asm/processor.h> |
Wolfgang Denk | 7629f1c | 2009-06-14 20:58:47 +0200 | [diff] [blame^] | 30 | #include <asm/mpc512x.h> |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 31 | #include <fdt_support.h> |
| 32 | #ifdef CONFIG_MISC_INIT_R |
| 33 | #include <i2c.h> |
| 34 | #endif |
| 35 | |
| 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 38 | /* Clocks in use */ |
| 39 | #define SCCR1_CLOCKS_EN (CLOCK_SCCR1_CFG_EN | \ |
| 40 | CLOCK_SCCR1_LPC_EN | \ |
| 41 | CLOCK_SCCR1_PSC_EN(CONFIG_PSC_CONSOLE) | \ |
| 42 | CLOCK_SCCR1_PSCFIFO_EN | \ |
| 43 | CLOCK_SCCR1_DDR_EN | \ |
| 44 | CLOCK_SCCR1_FEC_EN | \ |
| 45 | CLOCK_SCCR1_PATA_EN | \ |
| 46 | CLOCK_SCCR1_PCI_EN | \ |
| 47 | CLOCK_SCCR1_TPR_EN) |
| 48 | |
| 49 | #define SCCR2_CLOCKS_EN (CLOCK_SCCR2_MEM_EN | \ |
| 50 | CLOCK_SCCR2_SPDIF_EN | \ |
| 51 | CLOCK_SCCR2_DIU_EN | \ |
| 52 | CLOCK_SCCR2_I2C_EN) |
| 53 | |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 54 | int board_early_init_f(void) |
| 55 | { |
Wolfgang Denk | 7629f1c | 2009-06-14 20:58:47 +0200 | [diff] [blame^] | 56 | volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR; |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 57 | u32 spridr; |
| 58 | |
| 59 | /* |
| 60 | * Initialize Local Window for the On Board FPGA access |
| 61 | */ |
| 62 | out_be32(&im->sysconf.lpcs2aw, |
| 63 | CSAW_START(CONFIG_SYS_ARIA_FPGA_BASE) | |
| 64 | CSAW_STOP(CONFIG_SYS_ARIA_FPGA_BASE, CONFIG_SYS_ARIA_FPGA_SIZE) |
| 65 | ); |
| 66 | out_be32(&im->lpc.cs_cfg[2], CONFIG_SYS_CS2_CFG); |
Wolfgang Denk | 7629f1c | 2009-06-14 20:58:47 +0200 | [diff] [blame^] | 67 | sync_law(&im->sysconf.lpcs2aw); |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 68 | |
| 69 | /* |
| 70 | * Initialize Local Window for the On Board SRAM access |
| 71 | */ |
| 72 | out_be32(&im->sysconf.lpcs6aw, |
| 73 | CSAW_START(CONFIG_SYS_ARIA_SRAM_BASE) | |
| 74 | CSAW_STOP(CONFIG_SYS_ARIA_SRAM_BASE, CONFIG_SYS_ARIA_SRAM_SIZE) |
| 75 | ); |
| 76 | out_be32(&im->lpc.cs_cfg[6], CONFIG_SYS_CS6_CFG); |
Wolfgang Denk | 7629f1c | 2009-06-14 20:58:47 +0200 | [diff] [blame^] | 77 | sync_law(&im->sysconf.lpcs6aw); |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Configure Flash Speed |
| 81 | */ |
| 82 | out_be32(&im->lpc.cs_cfg[0], CONFIG_SYS_CS0_CFG); |
| 83 | |
| 84 | spridr = in_be32(&im->sysconf.spridr); |
| 85 | |
| 86 | if (SVR_MJREV(spridr) >= 2) |
| 87 | out_be32(&im->lpc.altr, CONFIG_SYS_CS_ALETIMING); |
| 88 | |
| 89 | /* |
| 90 | * Enable clocks |
| 91 | */ |
| 92 | out_be32(&im->clk.sccr[0], SCCR1_CLOCKS_EN); |
| 93 | out_be32(&im->clk.sccr[1], SCCR2_CLOCKS_EN); |
| 94 | #if defined(CONFIG_IIM) || defined(CONFIG_CMD_FUSE) |
| 95 | setbits_be32(&im->clk.sccr[1], CLOCK_SCCR2_IIM_EN); |
| 96 | #endif |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | phys_size_t initdram (int board_type) |
| 102 | { |
| 103 | return fixed_sdram(); |
| 104 | } |
| 105 | |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 106 | int misc_init_r(void) |
| 107 | { |
| 108 | u32 tmp; |
| 109 | |
| 110 | /* we use I2C-2 for on-board eeprom */ |
| 111 | i2c_set_bus_num(2); |
| 112 | |
| 113 | tmp = in_be32((u32*)CONFIG_SYS_ARIA_FPGA_BASE); |
| 114 | printf("FPGA: %u-%u.%u.%u\n", |
| 115 | (tmp & 0xFF000000) >> 24, |
| 116 | (tmp & 0x00FF0000) >> 16, |
| 117 | (tmp & 0x0000FF00) >> 8, |
| 118 | tmp & 0x000000FF |
| 119 | ); |
| 120 | |
| 121 | #ifdef CONFIG_FSL_DIU_FB |
| 122 | # if !(defined(CONFIG_VIDEO) || defined(CONFIG_CFB_CONSOLE)) |
| 123 | mpc5121_diu_init(); |
| 124 | # endif |
| 125 | #endif |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | static iopin_t ioregs_init[] = { |
| 130 | /* |
| 131 | * FEC |
| 132 | */ |
| 133 | |
| 134 | /* FEC on PSCx_x*/ |
| 135 | { |
| 136 | offsetof(struct ioctrl512x, io_control_psc0_0), 5, 0, |
| 137 | IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 138 | IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3) |
| 139 | }, |
| 140 | { |
| 141 | offsetof(struct ioctrl512x, io_control_psc1_0), 10, 0, |
| 142 | IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 143 | IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3) |
| 144 | }, |
| 145 | { |
| 146 | offsetof(struct ioctrl512x, io_control_spdif_txclk), 3, 0, |
| 147 | IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 148 | IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3) |
| 149 | }, |
| 150 | |
| 151 | /* |
| 152 | * DIU |
| 153 | */ |
| 154 | /* FUNC2=DIU CLK */ |
| 155 | { |
| 156 | offsetof(struct ioctrl512x, io_control_psc6_0), 1, 0, |
| 157 | IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 158 | IO_PIN_PUE(0) | IO_PIN_ST(1) | IO_PIN_DS(3) |
| 159 | }, |
| 160 | /* FUNC2=DIU_HSYNC */ |
| 161 | { |
| 162 | offsetof(struct ioctrl512x, io_control_psc6_1), 1, 0, |
| 163 | IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 164 | IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3) |
| 165 | }, |
| 166 | /* FUNC2=DIUVSYNC Sets Next 26 to DIU Pads */ |
| 167 | { |
| 168 | offsetof(struct ioctrl512x, io_control_psc6_4), 26, 0, |
| 169 | IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 170 | IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3) |
| 171 | }, |
| 172 | /* |
| 173 | * On board SRAM |
| 174 | */ |
| 175 | /* FUNC2=/LPC CS6 */ |
| 176 | { |
| 177 | offsetof(struct ioctrl512x, io_control_j1850_rx), 1, 0, |
| 178 | IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) | |
| 179 | IO_PIN_PUE(1) | IO_PIN_ST(1) | IO_PIN_DS(3) |
| 180 | }, |
| 181 | }; |
| 182 | |
Wolfgang Denk | 52568c3 | 2009-05-16 10:47:46 +0200 | [diff] [blame] | 183 | int checkboard (void) |
| 184 | { |
| 185 | puts("Board: ARIA\n"); |
| 186 | |
| 187 | /* initialize function mux & slew rate IO inter alia on IO Pins */ |
| 188 | |
| 189 | iopin_initialize(ioregs_init, ARRAY_SIZE(ioregs_init)); |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) |
| 195 | void ft_board_setup(void *blob, bd_t *bd) |
| 196 | { |
| 197 | ft_cpu_setup(blob, bd); |
| 198 | fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize); |
| 199 | } |
| 200 | #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */ |