Blame view
board/keymile/kmp204x/kmp204x.c
6.85 KB
877bfe37d mpc85xx: introduc... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/* * (C) Copyright 2013 Keymile AG * Valentin Longchamp <valentin.longchamp@keymile.com> * * Copyright 2011,2012 Freescale Semiconductor, Inc. * * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> #include <command.h> #include <netdev.h> #include <linux/compiler.h> #include <asm/mmu.h> #include <asm/processor.h> #include <asm/cache.h> #include <asm/immap_85xx.h> #include <asm/fsl_law.h> #include <asm/fsl_serdes.h> #include <asm/fsl_portals.h> #include <asm/fsl_liodn.h> #include <fm_eth.h> #include "../common/common.h" #include "kmp204x.h" DECLARE_GLOBAL_DATA_PTR; int checkboard(void) { printf("Board: Keymile %s ", CONFIG_KM_BOARD_NAME); return 0; } |
f3e74d0a9 kmp204x: I2C debl... |
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
/* I2C deblocking uses the algorithm defined in board/keymile/common/common.c * 2 dedicated QRIO GPIOs externally pull the SCL and SDA lines * For I2C only the low state is activly driven and high state is pulled-up * by a resistor. Therefore the deblock GPIOs are used * -> as an active output to drive a low state * -> as an open-drain input to have a pulled-up high state */ /* QRIO GPIOs used for deblocking */ #define DEBLOCK_PORT1 GPIO_A #define DEBLOCK_SCL1 20 #define DEBLOCK_SDA1 21 /* By default deblock GPIOs are floating */ static void i2c_deblock_gpio_cfg(void) { /* set I2C bus 1 deblocking GPIOs input, but 0 value for open drain */ qrio_gpio_direction_input(DEBLOCK_PORT1, DEBLOCK_SCL1); qrio_gpio_direction_input(DEBLOCK_PORT1, DEBLOCK_SDA1); qrio_set_gpio(DEBLOCK_PORT1, DEBLOCK_SCL1, 0); qrio_set_gpio(DEBLOCK_PORT1, DEBLOCK_SDA1, 0); } void set_sda(int state) { qrio_set_opendrain_gpio(DEBLOCK_PORT1, DEBLOCK_SDA1, state); } void set_scl(int state) { qrio_set_opendrain_gpio(DEBLOCK_PORT1, DEBLOCK_SCL1, state); } int get_sda(void) { return qrio_get_gpio(DEBLOCK_PORT1, DEBLOCK_SDA1); } int get_scl(void) |
877bfe37d mpc85xx: introduc... |
76 |
{ |
f3e74d0a9 kmp204x: I2C debl... |
77 |
return qrio_get_gpio(DEBLOCK_PORT1, DEBLOCK_SCL1); |
877bfe37d mpc85xx: introduc... |
78 |
} |
f3e74d0a9 kmp204x: I2C debl... |
79 |
|
877bfe37d mpc85xx: introduc... |
80 |
#define ZL30158_RST 8 |
af47faf65 kmp204x: complete... |
81 |
#define BFTIC4_RST 0 |
a09f470d4 kmp204x: set CPU ... |
82 83 |
#define RSTRQSR1_WDT_RR 0x00200000 #define RSTRQSR1_SW_RR 0x00100000 |
877bfe37d mpc85xx: introduc... |
84 85 86 87 |
int board_early_init_f(void) { ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
a09f470d4 kmp204x: set CPU ... |
88 |
bool cpuwd_flag = false; |
877bfe37d mpc85xx: introduc... |
89 90 91 |
/* board only uses the DDR_MCK0, so disable the DDR_MCK1/2/3 */ setbits_be32(&gur->ddrclkdr, 0x001f000f); |
a09f470d4 kmp204x: set CPU ... |
92 93 94 95 96 97 98 99 |
/* set reset reason according CPU register */ if ((gur->rstrqsr1 & (RSTRQSR1_WDT_RR | RSTRQSR1_SW_RR)) == RSTRQSR1_WDT_RR) cpuwd_flag = true; qrio_cpuwd_flag(cpuwd_flag); /* clear CPU bits by writing 1 */ setbits_be32(&gur->rstrqsr1, RSTRQSR1_WDT_RR | RSTRQSR1_SW_RR); |
af47faf65 kmp204x: complete... |
100 101 102 103 |
/* set the BFTIC's prstcfg to reset at power-up and unit reset only */ qrio_prstcfg(BFTIC4_RST, PRSTCFG_POWUP_UNIT_RST); /* and enable WD on it */ qrio_wdmask(BFTIC4_RST, true); |
877bfe37d mpc85xx: introduc... |
104 |
|
af47faf65 kmp204x: complete... |
105 106 107 108 |
/* set the ZL30138's prstcfg to reset at power-up and unit reset only */ qrio_prstcfg(ZL30158_RST, PRSTCFG_POWUP_UNIT_RST); /* and take it out of reset as soon as possible (needed for Hooper) */ qrio_prst(ZL30158_RST, false, false); |
877bfe37d mpc85xx: introduc... |
109 110 111 112 113 114 |
return 0; } int board_early_init_r(void) { |
27c78e06f kmp204x: initial ... |
115 |
int ret = 0; |
877bfe37d mpc85xx: introduc... |
116 117 118 119 120 121 |
/* Flush d-cache and invalidate i-cache of any FLASH data */ flush_dcache(); invalidate_icache(); set_liodns(); setup_portals(); |
27c78e06f kmp204x: initial ... |
122 123 124 125 |
ret = trigger_fpga_config(); if (ret) printf("error triggering PCIe FPGA config "); |
a53e65d05 kmp204x: Add supp... |
126 127 |
/* enable the Unit LED (red) & Boot LED (on) */ qrio_set_leds(); |
4921a149e kmp204x: handle d... |
128 129 |
/* enable Application Buffer */ qrio_enable_app_buffer(); |
27c78e06f kmp204x: initial ... |
130 |
return ret; |
877bfe37d mpc85xx: introduc... |
131 132 133 134 135 136 |
} unsigned long get_board_sys_clk(unsigned long dummy) { return 66666666; } |
af47faf65 kmp204x: complete... |
137 138 139 140 |
#define ETH_FRONT_PHY_RST 15 #define QSFP2_RST 11 #define QSFP1_RST 10 #define ZL30343_RST 9 |
f3e74d0a9 kmp204x: I2C debl... |
141 142 143 144 |
int misc_init_f(void) { /* configure QRIO pis for i2c deblocking */ i2c_deblock_gpio_cfg(); |
af47faf65 kmp204x: complete... |
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
/* configure the front phy's prstcfg and take it out of reset */ qrio_prstcfg(ETH_FRONT_PHY_RST, PRSTCFG_POWUP_UNIT_CORE_RST); qrio_prst(ETH_FRONT_PHY_RST, false, false); /* set the ZL30343 prstcfg to reset at power-up and unit reset only */ qrio_prstcfg(ZL30343_RST, PRSTCFG_POWUP_UNIT_RST); /* and enable the WD on it */ qrio_wdmask(ZL30343_RST, true); /* set the QSFPs' prstcfg to reset at power-up and unit rst only */ qrio_prstcfg(QSFP1_RST, PRSTCFG_POWUP_UNIT_RST); qrio_prstcfg(QSFP2_RST, PRSTCFG_POWUP_UNIT_RST); /* and enable the WD on them */ qrio_wdmask(QSFP1_RST, true); qrio_wdmask(QSFP2_RST, true); |
f3e74d0a9 kmp204x: I2C debl... |
161 162 |
return 0; } |
877bfe37d mpc85xx: introduc... |
163 |
#define NUM_SRDS_BANKS 2 |
877bfe37d mpc85xx: introduc... |
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
int misc_init_r(void) { serdes_corenet_t *regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; u32 expected[NUM_SRDS_BANKS] = {SRDS_PLLCR0_RFCK_SEL_100, SRDS_PLLCR0_RFCK_SEL_125}; unsigned int i; /* check SERDES reference clocks */ for (i = 0; i < NUM_SRDS_BANKS; i++) { u32 actual = in_be32(®s->bank[i].pllcr0); actual &= SRDS_PLLCR0_RFCK_SEL_MASK; if (actual != expected[i]) { printf("Warning: SERDES bank %u expects reference \ clock %sMHz, but actual is %sMHz ", i + 1, serdes_clock_to_string(expected[i]), serdes_clock_to_string(actual)); } } |
877bfe37d mpc85xx: introduc... |
184 185 186 187 188 189 190 191 192 193 194 195 |
return 0; } #if defined(CONFIG_HUSH_INIT_VAR) int hush_init_var(void) { ivm_read_eeprom(); return 0; } #endif #if defined(CONFIG_LAST_STAGE_INIT) |
af47faf65 kmp204x: complete... |
196 |
|
877bfe37d mpc85xx: introduc... |
197 198 |
int last_stage_init(void) { |
4921a149e kmp204x: handle d... |
199 200 201 202 203 204 205 206 207 208 209 210 211 |
#if defined(CONFIG_KMCOGE4) /* on KMCOGE4, the BFTIC4 is on the LBAPP2 */ struct bfticu_iomap *bftic4 = (struct bfticu_iomap *)CONFIG_SYS_LBAPP2_BASE; u8 dip_switch = in_8((u8 *)&(bftic4->mswitch)) & BFTICU_DIPSWITCH_MASK; if (dip_switch != 0) { /* start bootloader */ puts("DIP: Enabled "); setenv("actual_bank", "0"); } #endif |
877bfe37d mpc85xx: introduc... |
212 |
set_km_env(); |
af47faf65 kmp204x: complete... |
213 |
|
877bfe37d mpc85xx: introduc... |
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
return 0; } #endif #ifdef CONFIG_SYS_DPAA_FMAN void fdt_fixup_fman_mac_addresses(void *blob) { int node, i, ret; char *tmp, *end; unsigned char mac_addr[6]; /* get the mac addr from env */ tmp = getenv("ethaddr"); if (!tmp) { printf("ethaddr env variable not defined "); return; } for (i = 0; i < 6; i++) { mac_addr[i] = tmp ? simple_strtoul(tmp, &end, 16) : 0; if (tmp) tmp = (*end) ? end+1 : end; } /* find the correct fdt ethernet path and correct it */ node = fdt_path_offset(blob, "/soc/fman/ethernet@e8000"); if (node < 0) { printf("no /soc/fman/ethernet path offset "); return; } ret = fdt_setprop(blob, node, "local-mac-address", &mac_addr, 6); if (ret) { printf("error setting local-mac-address property "); return; } } #endif void ft_board_setup(void *blob, bd_t *bd) { phys_addr_t base; phys_size_t size; ft_cpu_setup(blob, bd); base = getenv_bootm_low(); size = getenv_bootm_size(); fdt_fixup_memory(blob, (u64)base, (u64)size); #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB) fdt_fixup_dr_usb(blob, bd); #endif #ifdef CONFIG_PCI pci_of_setup(blob, bd); #endif fdt_fixup_liodn(blob); #ifdef CONFIG_SYS_DPAA_FMAN fdt_fixup_fman_ethernet(blob); fdt_fixup_fman_mac_addresses(blob); #endif } |
18794944c kmp204x: selftest... |
280 281 282 283 284 285 286 287 288 289 290 291 292 |
#if defined(CONFIG_POST) /* DIC26_SELFTEST GPIO used to start factory test sw */ #define SELFTEST_PORT GPIO_A #define SELFTEST_PIN 31 int post_hotkeys_pressed(void) { qrio_gpio_direction_input(SELFTEST_PORT, SELFTEST_PIN); return qrio_get_gpio(SELFTEST_PORT, SELFTEST_PIN); } #endif |