Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2017 Marek Behun <marek.behun@nic.cz> |
| 4 | * Copyright (C) 2016 Tomas Hlavacek <tomas.hlavacek@nic.cz> |
| 5 | * |
| 6 | * Derived from the code for |
| 7 | * Marvell/db-88f6820-gp by Stefan Roese <sr@denx.de> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 07dc93c | 2019-08-01 09:46:47 -0600 | [diff] [blame] | 11 | #include <env.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 12 | #include <i2c.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 13 | #include <init.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 14 | #include <log.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 15 | #include <miiphy.h> |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 16 | #include <mtd.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 17 | #include <net.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 18 | #include <netdev.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 19 | #include <asm/global_data.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 20 | #include <asm/io.h> |
| 21 | #include <asm/arch/cpu.h> |
| 22 | #include <asm/arch/soc.h> |
| 23 | #include <dm/uclass.h> |
| 24 | #include <fdt_support.h> |
| 25 | #include <time.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 26 | #include <linux/bitops.h> |
Simon Glass | 48b6c6b | 2019-11-14 12:57:16 -0700 | [diff] [blame] | 27 | #include <u-boot/crc.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 28 | # include <atsha204a-i2c.h> |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 29 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 30 | #include "../drivers/ddr/marvell/a38x/ddr3_init.h" |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 31 | #include <../serdes/a38x/high_speed_env_spec.h> |
| 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 35 | #define OMNIA_SPI_NOR_PATH "/soc/spi@10600/spi-nor@0" |
| 36 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 37 | #define OMNIA_I2C_BUS_NAME "i2c@11000->i2cmux@70->i2c@0" |
| 38 | |
| 39 | #define OMNIA_I2C_MCU_CHIP_ADDR 0x2a |
| 40 | #define OMNIA_I2C_MCU_CHIP_LEN 1 |
| 41 | |
| 42 | #define OMNIA_I2C_EEPROM_CHIP_ADDR 0x54 |
| 43 | #define OMNIA_I2C_EEPROM_CHIP_LEN 2 |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 44 | #define OMNIA_I2C_EEPROM_MAGIC 0x0341a034 |
| 45 | |
Pali Rohár | 7fcda0c | 2021-11-09 17:14:02 +0100 | [diff] [blame^] | 46 | #define SYS_RSTOUT_MASK MVEBU_REGISTER(0x18260) |
| 47 | #define SYS_RSTOUT_MASK_WD BIT(10) |
| 48 | |
| 49 | #define A385_WDT_GLOBAL_CTRL MVEBU_REGISTER(0x20300) |
| 50 | #define A385_WDT_GLOBAL_RATIO_MASK GENMASK(18, 16) |
| 51 | #define A385_WDT_GLOBAL_RATIO_SHIFT 16 |
| 52 | #define A385_WDT_GLOBAL_25MHZ BIT(10) |
| 53 | #define A385_WDT_GLOBAL_ENABLE BIT(8) |
| 54 | |
| 55 | #define A385_WDT_GLOBAL_STATUS MVEBU_REGISTER(0x20304) |
| 56 | #define A385_WDT_GLOBAL_EXPIRED BIT(31) |
| 57 | |
| 58 | #define A385_WDT_DURATION MVEBU_REGISTER(0x20334) |
| 59 | |
| 60 | #define A385_WD_RSTOUT_UNMASK MVEBU_REGISTER(0x20704) |
| 61 | #define A385_WD_RSTOUT_UNMASK_GLOBAL BIT(8) |
| 62 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 63 | enum mcu_commands { |
| 64 | CMD_GET_STATUS_WORD = 0x01, |
| 65 | CMD_GET_RESET = 0x09, |
| 66 | CMD_WATCHDOG_STATE = 0x0b, |
| 67 | }; |
| 68 | |
| 69 | enum status_word_bits { |
| 70 | CARD_DET_STSBIT = 0x0010, |
| 71 | MSATA_IND_STSBIT = 0x0020, |
| 72 | }; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 73 | |
| 74 | #define OMNIA_ATSHA204_OTP_VERSION 0 |
| 75 | #define OMNIA_ATSHA204_OTP_SERIAL 1 |
| 76 | #define OMNIA_ATSHA204_OTP_MAC0 3 |
| 77 | #define OMNIA_ATSHA204_OTP_MAC1 4 |
| 78 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 79 | /* |
| 80 | * Those values and defines are taken from the Marvell U-Boot version |
| 81 | * "u-boot-2013.01-2014_T3.0" |
| 82 | */ |
| 83 | #define OMNIA_GPP_OUT_ENA_LOW \ |
| 84 | (~(BIT(1) | BIT(4) | BIT(6) | BIT(7) | BIT(8) | BIT(9) | \ |
| 85 | BIT(10) | BIT(11) | BIT(19) | BIT(22) | BIT(23) | BIT(25) | \ |
| 86 | BIT(26) | BIT(27) | BIT(29) | BIT(30) | BIT(31))) |
| 87 | #define OMNIA_GPP_OUT_ENA_MID \ |
| 88 | (~(BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(15) | \ |
| 89 | BIT(16) | BIT(17) | BIT(18))) |
| 90 | |
| 91 | #define OMNIA_GPP_OUT_VAL_LOW 0x0 |
| 92 | #define OMNIA_GPP_OUT_VAL_MID 0x0 |
| 93 | #define OMNIA_GPP_POL_LOW 0x0 |
| 94 | #define OMNIA_GPP_POL_MID 0x0 |
| 95 | |
| 96 | static struct serdes_map board_serdes_map_pex[] = { |
| 97 | {PEX0, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 98 | {USB3_HOST0, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 99 | {PEX1, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 100 | {USB3_HOST1, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 101 | {PEX2, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 102 | {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0} |
| 103 | }; |
| 104 | |
| 105 | static struct serdes_map board_serdes_map_sata[] = { |
| 106 | {SATA0, SERDES_SPEED_6_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 107 | {USB3_HOST0, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 108 | {PEX1, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 109 | {USB3_HOST1, SERDES_SPEED_5_GBPS, SERDES_DEFAULT_MODE, 0, 0}, |
| 110 | {PEX2, SERDES_SPEED_5_GBPS, PEX_ROOT_COMPLEX_X1, 0, 0}, |
| 111 | {SGMII2, SERDES_SPEED_1_25_GBPS, SERDES_DEFAULT_MODE, 0, 0} |
| 112 | }; |
| 113 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 114 | static struct udevice *omnia_get_i2c_chip(const char *name, uint addr, |
| 115 | uint offset_len) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 116 | { |
| 117 | struct udevice *bus, *dev; |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 118 | int ret; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 119 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 120 | ret = uclass_get_device_by_name(UCLASS_I2C, OMNIA_I2C_BUS_NAME, &bus); |
| 121 | if (ret) { |
| 122 | printf("Cannot get I2C bus %s: uclass_get_device_by_name failed: %i\n", |
| 123 | OMNIA_I2C_BUS_NAME, ret); |
| 124 | return NULL; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 125 | } |
| 126 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 127 | ret = i2c_get_chip(bus, addr, offset_len, &dev); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 128 | if (ret) { |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 129 | printf("Cannot get %s I2C chip: i2c_get_chip failed: %i\n", |
| 130 | name, ret); |
| 131 | return NULL; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 132 | } |
| 133 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 134 | return dev; |
| 135 | } |
Marek Behún | d0b374d | 2017-08-04 15:28:25 +0200 | [diff] [blame] | 136 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 137 | static int omnia_mcu_read(u8 cmd, void *buf, int len) |
| 138 | { |
| 139 | struct udevice *chip; |
| 140 | |
| 141 | chip = omnia_get_i2c_chip("MCU", OMNIA_I2C_MCU_CHIP_ADDR, |
| 142 | OMNIA_I2C_MCU_CHIP_LEN); |
| 143 | if (!chip) |
| 144 | return -ENODEV; |
| 145 | |
| 146 | return dm_i2c_read(chip, cmd, buf, len); |
| 147 | } |
| 148 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 149 | static int omnia_mcu_write(u8 cmd, const void *buf, int len) |
| 150 | { |
| 151 | struct udevice *chip; |
| 152 | |
| 153 | chip = omnia_get_i2c_chip("MCU", OMNIA_I2C_MCU_CHIP_ADDR, |
| 154 | OMNIA_I2C_MCU_CHIP_LEN); |
| 155 | if (!chip) |
| 156 | return -ENODEV; |
| 157 | |
| 158 | return dm_i2c_write(chip, cmd, buf, len); |
| 159 | } |
| 160 | |
Pali Rohár | 7fcda0c | 2021-11-09 17:14:02 +0100 | [diff] [blame^] | 161 | static void enable_a385_watchdog(unsigned int timeout_minutes) |
| 162 | { |
| 163 | struct sar_freq_modes sar_freq; |
| 164 | u32 watchdog_freq; |
| 165 | |
| 166 | printf("Enabling A385 watchdog with %u minutes timeout...\n", |
| 167 | timeout_minutes); |
| 168 | |
| 169 | /* |
| 170 | * Use NBCLK clock (a.k.a. L2 clock) as watchdog input clock with |
| 171 | * its maximal ratio 7 instead of default fixed 25 MHz clock. |
| 172 | * It allows to set watchdog duration up to the 22 minutes. |
| 173 | */ |
| 174 | clrsetbits_32(A385_WDT_GLOBAL_CTRL, |
| 175 | A385_WDT_GLOBAL_25MHZ | A385_WDT_GLOBAL_RATIO_MASK, |
| 176 | 7 << A385_WDT_GLOBAL_RATIO_SHIFT); |
| 177 | |
| 178 | /* |
| 179 | * Calculate watchdog clock frequency. It is defined by formula: |
| 180 | * freq = NBCLK / 2 / (2 ^ ratio) |
| 181 | * We set ratio to the maximal possible value 7. |
| 182 | */ |
| 183 | get_sar_freq(&sar_freq); |
| 184 | watchdog_freq = sar_freq.nb_clk * 1000000 / 2 / (1 << 7); |
| 185 | |
| 186 | /* Set watchdog duration */ |
| 187 | writel(timeout_minutes * 60 * watchdog_freq, A385_WDT_DURATION); |
| 188 | |
| 189 | /* Clear the watchdog expiration bit */ |
| 190 | clrbits_32(A385_WDT_GLOBAL_STATUS, A385_WDT_GLOBAL_EXPIRED); |
| 191 | |
| 192 | /* Enable watchdog timer */ |
| 193 | setbits_32(A385_WDT_GLOBAL_CTRL, A385_WDT_GLOBAL_ENABLE); |
| 194 | |
| 195 | /* Enable reset on watchdog */ |
| 196 | setbits_32(A385_WD_RSTOUT_UNMASK, A385_WD_RSTOUT_UNMASK_GLOBAL); |
| 197 | |
| 198 | /* Unmask reset for watchdog */ |
| 199 | clrbits_32(SYS_RSTOUT_MASK, SYS_RSTOUT_MASK_WD); |
| 200 | } |
| 201 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 202 | static bool disable_mcu_watchdog(void) |
| 203 | { |
| 204 | int ret; |
| 205 | |
| 206 | puts("Disabling MCU watchdog... "); |
| 207 | |
| 208 | ret = omnia_mcu_write(CMD_WATCHDOG_STATE, "\x00", 1); |
| 209 | if (ret) { |
| 210 | printf("omnia_mcu_write failed: %i\n", ret); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 211 | return false; |
| 212 | } |
| 213 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 214 | puts("disabled\n"); |
| 215 | |
| 216 | return true; |
| 217 | } |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 218 | |
| 219 | static bool omnia_detect_sata(void) |
| 220 | { |
| 221 | int ret; |
| 222 | u16 stsword; |
| 223 | |
| 224 | puts("MiniPCIe/mSATA card detection... "); |
| 225 | |
| 226 | ret = omnia_mcu_read(CMD_GET_STATUS_WORD, &stsword, sizeof(stsword)); |
| 227 | if (ret) { |
| 228 | printf("omnia_mcu_read failed: %i, defaulting to MiniPCIe card\n", |
| 229 | ret); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 230 | return false; |
| 231 | } |
| 232 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 233 | if (!(stsword & CARD_DET_STSBIT)) { |
| 234 | puts("none\n"); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 235 | return false; |
| 236 | } |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 237 | |
| 238 | if (stsword & MSATA_IND_STSBIT) |
| 239 | puts("mSATA\n"); |
| 240 | else |
| 241 | puts("MiniPCIe\n"); |
| 242 | |
| 243 | return stsword & MSATA_IND_STSBIT ? true : false; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | int hws_board_topology_load(struct serdes_map **serdes_map_array, u8 *count) |
| 247 | { |
| 248 | if (omnia_detect_sata()) { |
| 249 | *serdes_map_array = board_serdes_map_sata; |
| 250 | *count = ARRAY_SIZE(board_serdes_map_sata); |
| 251 | } else { |
| 252 | *serdes_map_array = board_serdes_map_pex; |
| 253 | *count = ARRAY_SIZE(board_serdes_map_pex); |
| 254 | } |
| 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | struct omnia_eeprom { |
| 260 | u32 magic; |
| 261 | u32 ramsize; |
| 262 | char region[4]; |
| 263 | u32 crc; |
| 264 | }; |
| 265 | |
| 266 | static bool omnia_read_eeprom(struct omnia_eeprom *oep) |
| 267 | { |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 268 | struct udevice *chip; |
| 269 | u32 crc; |
| 270 | int ret; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 271 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 272 | chip = omnia_get_i2c_chip("EEPROM", OMNIA_I2C_EEPROM_CHIP_ADDR, |
| 273 | OMNIA_I2C_EEPROM_CHIP_LEN); |
| 274 | |
| 275 | if (!chip) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 276 | return false; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 277 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 278 | ret = dm_i2c_read(chip, 0, (void *)oep, sizeof(*oep)); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 279 | if (ret) { |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 280 | printf("dm_i2c_read failed: %i, cannot read EEPROM\n", ret); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 281 | return false; |
| 282 | } |
| 283 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 284 | if (oep->magic != OMNIA_I2C_EEPROM_MAGIC) { |
| 285 | printf("bad EEPROM magic number (%08x, should be %08x)\n", |
| 286 | oep->magic, OMNIA_I2C_EEPROM_MAGIC); |
| 287 | return false; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 288 | } |
| 289 | |
Marek Behún | ba53b6b | 2019-05-02 16:53:30 +0200 | [diff] [blame] | 290 | crc = crc32(0, (void *)oep, sizeof(*oep) - 4); |
| 291 | if (crc != oep->crc) { |
| 292 | printf("bad EEPROM CRC (stored %08x, computed %08x)\n", |
| 293 | oep->crc, crc); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 294 | return false; |
| 295 | } |
| 296 | |
| 297 | return true; |
| 298 | } |
| 299 | |
Marek Behún | 77652c7 | 2019-05-02 16:53:33 +0200 | [diff] [blame] | 300 | static int omnia_get_ram_size_gb(void) |
| 301 | { |
| 302 | static int ram_size; |
| 303 | struct omnia_eeprom oep; |
| 304 | |
| 305 | if (!ram_size) { |
| 306 | /* Get the board config from EEPROM */ |
| 307 | if (omnia_read_eeprom(&oep)) { |
| 308 | debug("Memory config in EEPROM: 0x%02x\n", oep.ramsize); |
| 309 | |
| 310 | if (oep.ramsize == 0x2) |
| 311 | ram_size = 2; |
| 312 | else |
| 313 | ram_size = 1; |
| 314 | } else { |
| 315 | /* Hardcoded fallback */ |
| 316 | puts("Memory config from EEPROM read failed!\n"); |
| 317 | puts("Falling back to default 1 GiB!\n"); |
| 318 | ram_size = 1; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return ram_size; |
| 323 | } |
| 324 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 325 | /* |
| 326 | * Define the DDR layout / topology here in the board file. This will |
| 327 | * be used by the DDR3 init code in the SPL U-Boot version to configure |
| 328 | * the DDR3 controller. |
| 329 | */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 330 | static struct mv_ddr_topology_map board_topology_map_1g = { |
| 331 | DEBUG_LEVEL_ERROR, |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 332 | 0x1, /* active interfaces */ |
| 333 | /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */ |
| 334 | { { { {0x1, 0, 0, 0}, |
| 335 | {0x1, 0, 0, 0}, |
| 336 | {0x1, 0, 0, 0}, |
| 337 | {0x1, 0, 0, 0}, |
| 338 | {0x1, 0, 0, 0} }, |
| 339 | SPEED_BIN_DDR_1600K, /* speed_bin */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 340 | MV_DDR_DEV_WIDTH_16BIT, /* memory_width */ |
| 341 | MV_DDR_DIE_CAP_4GBIT, /* mem_size */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 342 | MV_DDR_FREQ_800, /* frequency */ |
Chris Packham | dd092bd | 2017-11-29 10:38:34 +1300 | [diff] [blame] | 343 | 0, 0, /* cas_wl cas_l */ |
Chris Packham | 3a09e13 | 2018-05-10 13:28:30 +1200 | [diff] [blame] | 344 | MV_DDR_TEMP_NORMAL, /* temperature */ |
| 345 | MV_DDR_TIM_2T} }, /* timing */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 346 | BUS_MASK_32BIT, /* Busses mask */ |
| 347 | MV_DDR_CFG_DEFAULT, /* ddr configuration data source */ |
Moti Buskila | 498475e | 2021-02-19 17:11:19 +0100 | [diff] [blame] | 348 | NOT_COMBINED, /* ddr twin-die combined */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 349 | { {0} }, /* raw spd data */ |
| 350 | {0} /* timing parameters */ |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 351 | }; |
| 352 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 353 | static struct mv_ddr_topology_map board_topology_map_2g = { |
| 354 | DEBUG_LEVEL_ERROR, |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 355 | 0x1, /* active interfaces */ |
| 356 | /* cs_mask, mirror, dqs_swap, ck_swap X PUPs */ |
| 357 | { { { {0x1, 0, 0, 0}, |
| 358 | {0x1, 0, 0, 0}, |
| 359 | {0x1, 0, 0, 0}, |
| 360 | {0x1, 0, 0, 0}, |
| 361 | {0x1, 0, 0, 0} }, |
| 362 | SPEED_BIN_DDR_1600K, /* speed_bin */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 363 | MV_DDR_DEV_WIDTH_16BIT, /* memory_width */ |
| 364 | MV_DDR_DIE_CAP_8GBIT, /* mem_size */ |
Chris Packham | 4bf81db | 2018-12-03 14:26:49 +1300 | [diff] [blame] | 365 | MV_DDR_FREQ_800, /* frequency */ |
Chris Packham | dd092bd | 2017-11-29 10:38:34 +1300 | [diff] [blame] | 366 | 0, 0, /* cas_wl cas_l */ |
Chris Packham | 3a09e13 | 2018-05-10 13:28:30 +1200 | [diff] [blame] | 367 | MV_DDR_TEMP_NORMAL, /* temperature */ |
| 368 | MV_DDR_TIM_2T} }, /* timing */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 369 | BUS_MASK_32BIT, /* Busses mask */ |
| 370 | MV_DDR_CFG_DEFAULT, /* ddr configuration data source */ |
Moti Buskila | 498475e | 2021-02-19 17:11:19 +0100 | [diff] [blame] | 371 | NOT_COMBINED, /* ddr twin-die combined */ |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 372 | { {0} }, /* raw spd data */ |
| 373 | {0} /* timing parameters */ |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 374 | }; |
| 375 | |
Chris Packham | 1a07d21 | 2018-05-10 13:28:29 +1200 | [diff] [blame] | 376 | struct mv_ddr_topology_map *mv_ddr_topology_map_get(void) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 377 | { |
Marek Behún | 77652c7 | 2019-05-02 16:53:33 +0200 | [diff] [blame] | 378 | if (omnia_get_ram_size_gb() == 2) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 379 | return &board_topology_map_2g; |
Marek Behún | 77652c7 | 2019-05-02 16:53:33 +0200 | [diff] [blame] | 380 | else |
| 381 | return &board_topology_map_1g; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 382 | } |
| 383 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 384 | static int set_regdomain(void) |
| 385 | { |
| 386 | struct omnia_eeprom oep; |
| 387 | char rd[3] = {' ', ' ', 0}; |
| 388 | |
| 389 | if (omnia_read_eeprom(&oep)) |
| 390 | memcpy(rd, &oep.region, 2); |
| 391 | else |
| 392 | puts("EEPROM regdomain read failed.\n"); |
| 393 | |
| 394 | printf("Regdomain set to %s\n", rd); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 395 | return env_set("regdomain", rd); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 396 | } |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 397 | |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 398 | static void handle_reset_button(void) |
| 399 | { |
Pali Rohár | 905c3bf | 2021-06-14 16:45:58 +0200 | [diff] [blame] | 400 | const char * const vars[1] = { "bootcmd_rescue", }; |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 401 | int ret; |
| 402 | u8 reset_status; |
| 403 | |
Pali Rohár | 905c3bf | 2021-06-14 16:45:58 +0200 | [diff] [blame] | 404 | /* |
| 405 | * Ensure that bootcmd_rescue has always stock value, so that running |
| 406 | * run bootcmd_rescue |
| 407 | * always works correctly. |
| 408 | */ |
| 409 | env_set_default_vars(1, (char * const *)vars, 0); |
| 410 | |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 411 | ret = omnia_mcu_read(CMD_GET_RESET, &reset_status, 1); |
| 412 | if (ret) { |
| 413 | printf("omnia_mcu_read failed: %i, reset status unknown!\n", |
| 414 | ret); |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | env_set_ulong("omnia_reset", reset_status); |
| 419 | |
| 420 | if (reset_status) { |
Pali Rohár | 905c3bf | 2021-06-14 16:45:58 +0200 | [diff] [blame] | 421 | const char * const vars[2] = { |
Marek Behún | 09f8de2 | 2021-05-28 10:00:49 +0200 | [diff] [blame] | 422 | "bootcmd", |
Marek Behún | 09f8de2 | 2021-05-28 10:00:49 +0200 | [diff] [blame] | 423 | "distro_bootcmd", |
| 424 | }; |
| 425 | |
| 426 | /* |
| 427 | * Set the above envs to their default values, in case the user |
| 428 | * managed to break them. |
| 429 | */ |
Pali Rohár | 905c3bf | 2021-06-14 16:45:58 +0200 | [diff] [blame] | 430 | env_set_default_vars(2, (char * const *)vars, 0); |
Marek Behún | 09f8de2 | 2021-05-28 10:00:49 +0200 | [diff] [blame] | 431 | |
| 432 | /* Ensure bootcmd_rescue is used by distroboot */ |
| 433 | env_set("boot_targets", "rescue"); |
| 434 | |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 435 | printf("RESET button was pressed, overwriting bootcmd!\n"); |
Marek Behún | 09f8de2 | 2021-05-28 10:00:49 +0200 | [diff] [blame] | 436 | } else { |
| 437 | /* |
| 438 | * In case the user somehow managed to save environment with |
| 439 | * boot_targets=rescue, reset boot_targets to default value. |
| 440 | * This could happen in subsequent commands if bootcmd_rescue |
| 441 | * failed. |
| 442 | */ |
| 443 | if (!strcmp(env_get("boot_targets"), "rescue")) { |
| 444 | const char * const vars[1] = { |
| 445 | "boot_targets", |
| 446 | }; |
| 447 | |
| 448 | env_set_default_vars(1, (char * const *)vars, 0); |
| 449 | } |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 450 | } |
| 451 | } |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 452 | |
| 453 | int board_early_init_f(void) |
| 454 | { |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 455 | /* Configure MPP */ |
| 456 | writel(0x11111111, MVEBU_MPP_BASE + 0x00); |
| 457 | writel(0x11111111, MVEBU_MPP_BASE + 0x04); |
| 458 | writel(0x11244011, MVEBU_MPP_BASE + 0x08); |
| 459 | writel(0x22222111, MVEBU_MPP_BASE + 0x0c); |
| 460 | writel(0x22200002, MVEBU_MPP_BASE + 0x10); |
| 461 | writel(0x30042022, MVEBU_MPP_BASE + 0x14); |
| 462 | writel(0x55550555, MVEBU_MPP_BASE + 0x18); |
| 463 | writel(0x00005550, MVEBU_MPP_BASE + 0x1c); |
| 464 | |
| 465 | /* Set GPP Out value */ |
| 466 | writel(OMNIA_GPP_OUT_VAL_LOW, MVEBU_GPIO0_BASE + 0x00); |
| 467 | writel(OMNIA_GPP_OUT_VAL_MID, MVEBU_GPIO1_BASE + 0x00); |
| 468 | |
| 469 | /* Set GPP Polarity */ |
| 470 | writel(OMNIA_GPP_POL_LOW, MVEBU_GPIO0_BASE + 0x0c); |
| 471 | writel(OMNIA_GPP_POL_MID, MVEBU_GPIO1_BASE + 0x0c); |
| 472 | |
| 473 | /* Set GPP Out Enable */ |
| 474 | writel(OMNIA_GPP_OUT_ENA_LOW, MVEBU_GPIO0_BASE + 0x04); |
| 475 | writel(OMNIA_GPP_OUT_ENA_MID, MVEBU_GPIO1_BASE + 0x04); |
| 476 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 477 | return 0; |
| 478 | } |
| 479 | |
Marek Behún | f355616 | 2021-08-16 15:19:39 +0200 | [diff] [blame] | 480 | void spl_board_init(void) |
| 481 | { |
| 482 | /* |
| 483 | * If booting from UART, disable MCU watchdog in SPL, since uploading |
Pali Rohár | 7fcda0c | 2021-11-09 17:14:02 +0100 | [diff] [blame^] | 484 | * U-Boot proper can take too much time and trigger it. Instead enable |
| 485 | * A385 watchdog with very high timeout (10 minutes) to prevent hangup. |
Marek Behún | f355616 | 2021-08-16 15:19:39 +0200 | [diff] [blame] | 486 | */ |
Pali Rohár | 7fcda0c | 2021-11-09 17:14:02 +0100 | [diff] [blame^] | 487 | if (get_boot_device() == BOOT_DEVICE_UART) { |
| 488 | enable_a385_watchdog(10); |
Marek Behún | f355616 | 2021-08-16 15:19:39 +0200 | [diff] [blame] | 489 | disable_mcu_watchdog(); |
Pali Rohár | 7fcda0c | 2021-11-09 17:14:02 +0100 | [diff] [blame^] | 490 | } |
Marek Behún | f355616 | 2021-08-16 15:19:39 +0200 | [diff] [blame] | 491 | } |
| 492 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 493 | int board_init(void) |
| 494 | { |
Marek Behún | 4dfc57e | 2019-05-02 16:53:31 +0200 | [diff] [blame] | 495 | /* address of boot parameters */ |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 496 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
| 497 | |
Marek Behún | 88dc024 | 2021-08-16 15:19:40 +0200 | [diff] [blame] | 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | int board_late_init(void) |
| 502 | { |
Marek Behún | f355616 | 2021-08-16 15:19:39 +0200 | [diff] [blame] | 503 | /* |
| 504 | * If not booting from UART, MCU watchdog was not disabled in SPL, |
| 505 | * disable it now. |
| 506 | */ |
| 507 | if (get_boot_device() != BOOT_DEVICE_UART) |
| 508 | disable_mcu_watchdog(); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 509 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 510 | set_regdomain(); |
Marek Behún | 0f2e66a | 2019-05-02 16:53:37 +0200 | [diff] [blame] | 511 | handle_reset_button(); |
Marek Behún | db1e5c6 | 2019-05-24 14:57:53 +0200 | [diff] [blame] | 512 | pci_init(); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 513 | |
| 514 | return 0; |
| 515 | } |
| 516 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 517 | static struct udevice *get_atsha204a_dev(void) |
| 518 | { |
Marek Behún | 4dfc57e | 2019-05-02 16:53:31 +0200 | [diff] [blame] | 519 | static struct udevice *dev; |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 520 | |
Marek Behún | 4dfc57e | 2019-05-02 16:53:31 +0200 | [diff] [blame] | 521 | if (dev) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 522 | return dev; |
| 523 | |
| 524 | if (uclass_get_device_by_name(UCLASS_MISC, "atsha204a@64", &dev)) { |
| 525 | puts("Cannot find ATSHA204A on I2C bus!\n"); |
| 526 | dev = NULL; |
| 527 | } |
| 528 | |
| 529 | return dev; |
| 530 | } |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 531 | |
Marek Behún | ab9447f | 2021-10-09 19:33:44 +0200 | [diff] [blame] | 532 | int show_board_info(void) |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 533 | { |
| 534 | u32 version_num, serial_num; |
| 535 | int err = 1; |
| 536 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 537 | struct udevice *dev = get_atsha204a_dev(); |
| 538 | |
| 539 | if (dev) { |
| 540 | err = atsha204a_wakeup(dev); |
| 541 | if (err) |
| 542 | goto out; |
| 543 | |
| 544 | err = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false, |
| 545 | OMNIA_ATSHA204_OTP_VERSION, |
Marek Behún | 4dfc57e | 2019-05-02 16:53:31 +0200 | [diff] [blame] | 546 | (u8 *)&version_num); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 547 | if (err) |
| 548 | goto out; |
| 549 | |
| 550 | err = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false, |
| 551 | OMNIA_ATSHA204_OTP_SERIAL, |
Marek Behún | 4dfc57e | 2019-05-02 16:53:31 +0200 | [diff] [blame] | 552 | (u8 *)&serial_num); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 553 | if (err) |
| 554 | goto out; |
| 555 | |
| 556 | atsha204a_sleep(dev); |
| 557 | } |
| 558 | |
| 559 | out: |
Marek Behún | ab9447f | 2021-10-09 19:33:44 +0200 | [diff] [blame] | 560 | printf("Model: Turris Omnia\n"); |
Marek Behún | c4ba72a | 2019-05-02 16:53:34 +0200 | [diff] [blame] | 561 | printf(" RAM size: %i MiB\n", omnia_get_ram_size_gb() * 1024); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 562 | if (err) |
Marek Behún | c4ba72a | 2019-05-02 16:53:34 +0200 | [diff] [blame] | 563 | printf(" Serial Number: unknown\n"); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 564 | else |
Marek Behún | c4ba72a | 2019-05-02 16:53:34 +0200 | [diff] [blame] | 565 | printf(" Serial Number: %08X%08X\n", be32_to_cpu(version_num), |
| 566 | be32_to_cpu(serial_num)); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 567 | |
| 568 | return 0; |
| 569 | } |
| 570 | |
| 571 | static void increment_mac(u8 *mac) |
| 572 | { |
| 573 | int i; |
| 574 | |
| 575 | for (i = 5; i >= 3; i--) { |
| 576 | mac[i] += 1; |
| 577 | if (mac[i]) |
| 578 | break; |
| 579 | } |
| 580 | } |
| 581 | |
Marek Behún | b885614 | 2021-10-09 19:33:43 +0200 | [diff] [blame] | 582 | static void set_mac_if_invalid(int i, u8 *mac) |
| 583 | { |
| 584 | u8 oldmac[6]; |
| 585 | |
| 586 | if (is_valid_ethaddr(mac) && |
| 587 | !eth_env_get_enetaddr_by_index("eth", i, oldmac)) |
| 588 | eth_env_set_enetaddr_by_index("eth", i, mac); |
| 589 | } |
| 590 | |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 591 | int misc_init_r(void) |
| 592 | { |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 593 | int err; |
| 594 | struct udevice *dev = get_atsha204a_dev(); |
| 595 | u8 mac0[4], mac1[4], mac[6]; |
| 596 | |
| 597 | if (!dev) |
| 598 | goto out; |
| 599 | |
| 600 | err = atsha204a_wakeup(dev); |
| 601 | if (err) |
| 602 | goto out; |
| 603 | |
| 604 | err = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false, |
| 605 | OMNIA_ATSHA204_OTP_MAC0, mac0); |
| 606 | if (err) |
| 607 | goto out; |
| 608 | |
| 609 | err = atsha204a_read(dev, ATSHA204A_ZONE_OTP, false, |
| 610 | OMNIA_ATSHA204_OTP_MAC1, mac1); |
| 611 | if (err) |
| 612 | goto out; |
| 613 | |
| 614 | atsha204a_sleep(dev); |
| 615 | |
| 616 | mac[0] = mac0[1]; |
| 617 | mac[1] = mac0[2]; |
| 618 | mac[2] = mac0[3]; |
| 619 | mac[3] = mac1[1]; |
| 620 | mac[4] = mac1[2]; |
| 621 | mac[5] = mac1[3]; |
| 622 | |
Marek Behún | b885614 | 2021-10-09 19:33:43 +0200 | [diff] [blame] | 623 | set_mac_if_invalid(1, mac); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 624 | increment_mac(mac); |
Marek Behún | b885614 | 2021-10-09 19:33:43 +0200 | [diff] [blame] | 625 | set_mac_if_invalid(2, mac); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 626 | increment_mac(mac); |
Marek Behún | b885614 | 2021-10-09 19:33:43 +0200 | [diff] [blame] | 627 | set_mac_if_invalid(0, mac); |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 628 | |
| 629 | out: |
Marek Behún | 09e16b8 | 2017-06-09 19:28:45 +0200 | [diff] [blame] | 630 | return 0; |
| 631 | } |
| 632 | |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 633 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 634 | /* |
| 635 | * I plan to generalize this function and move it to common/fdt_support.c. |
| 636 | * This will require some more work on multiple boards, though, so for now leave |
| 637 | * it here. |
| 638 | */ |
| 639 | static bool fixup_mtd_partitions(void *blob, int offset, struct mtd_info *mtd) |
| 640 | { |
| 641 | struct mtd_info *slave; |
| 642 | int parts; |
| 643 | |
| 644 | parts = fdt_subnode_offset(blob, offset, "partitions"); |
| 645 | if (parts < 0) |
| 646 | return false; |
| 647 | |
| 648 | if (fdt_del_node(blob, parts) < 0) |
| 649 | return false; |
| 650 | |
| 651 | parts = fdt_add_subnode(blob, offset, "partitions"); |
| 652 | if (parts < 0) |
| 653 | return false; |
| 654 | |
| 655 | if (fdt_setprop_u32(blob, parts, "#address-cells", 1) < 0) |
| 656 | return false; |
| 657 | |
| 658 | if (fdt_setprop_u32(blob, parts, "#size-cells", 1) < 0) |
| 659 | return false; |
| 660 | |
| 661 | if (fdt_setprop_string(blob, parts, "compatible", |
| 662 | "fixed-partitions") < 0) |
| 663 | return false; |
| 664 | |
| 665 | mtd_probe_devices(); |
| 666 | |
Pali Rohár | d8210ef | 2021-10-21 17:55:48 +0200 | [diff] [blame] | 667 | list_for_each_entry_reverse(slave, &mtd->partitions, node) { |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 668 | char name[32]; |
| 669 | int part; |
| 670 | |
| 671 | snprintf(name, sizeof(name), "partition@%llx", slave->offset); |
| 672 | part = fdt_add_subnode(blob, parts, name); |
| 673 | if (part < 0) |
| 674 | return false; |
| 675 | |
| 676 | if (fdt_setprop_u32(blob, part, "reg", slave->offset) < 0) |
| 677 | return false; |
| 678 | |
| 679 | if (fdt_appendprop_u32(blob, part, "reg", slave->size) < 0) |
| 680 | return false; |
| 681 | |
| 682 | if (fdt_setprop_string(blob, part, "label", slave->name) < 0) |
| 683 | return false; |
| 684 | |
| 685 | if (!(slave->flags & MTD_WRITEABLE)) |
| 686 | if (fdt_setprop_empty(blob, part, "read-only") < 0) |
| 687 | return false; |
| 688 | |
| 689 | if (slave->flags & MTD_POWERUP_LOCK) |
| 690 | if (fdt_setprop_empty(blob, part, "lock") < 0) |
| 691 | return false; |
| 692 | } |
| 693 | |
| 694 | return true; |
| 695 | } |
| 696 | |
| 697 | int ft_board_setup(void *blob, struct bd_info *bd) |
| 698 | { |
| 699 | struct mtd_info *mtd; |
| 700 | int node; |
| 701 | |
| 702 | mtd = get_mtd_device_nm(OMNIA_SPI_NOR_PATH); |
| 703 | if (IS_ERR_OR_NULL(mtd)) |
| 704 | goto fail; |
| 705 | |
| 706 | node = fdt_path_offset(blob, OMNIA_SPI_NOR_PATH); |
| 707 | if (node < 0) |
| 708 | goto fail; |
| 709 | |
| 710 | if (!fixup_mtd_partitions(blob, node, mtd)) |
| 711 | goto fail; |
| 712 | |
Marek Behún | 36feac9 | 2021-09-25 02:49:18 +0200 | [diff] [blame] | 713 | put_mtd_device(mtd); |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 714 | return 0; |
| 715 | |
| 716 | fail: |
| 717 | printf("Failed fixing SPI NOR partitions!\n"); |
Marek Behún | 36feac9 | 2021-09-25 02:49:18 +0200 | [diff] [blame] | 718 | if (!IS_ERR_OR_NULL(mtd)) |
| 719 | put_mtd_device(mtd); |
Marek Behún | 91ef59c | 2021-07-15 19:21:02 +0200 | [diff] [blame] | 720 | return 0; |
| 721 | } |
| 722 | #endif |