Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com> |
| 4 | * |
| 5 | * Based on Kirkwood support: |
| 6 | * (C) Copyright 2009 |
| 7 | * Marvell Semiconductor <www.marvell.com> |
| 8 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | #include <common.h> |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 12 | #include <command.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 13 | #include <env.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 14 | #include <init.h> |
Simon Glass | 0c36441 | 2019-12-28 10:44:48 -0700 | [diff] [blame] | 15 | #include <net.h> |
Simon Glass | 3ba929a | 2020-10-30 21:38:53 -0600 | [diff] [blame] | 16 | #include <asm/global_data.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 17 | #include <asm/mach-types.h> |
Anatolij Gustschin | 5cf80f1 | 2011-10-29 11:31:19 +0000 | [diff] [blame] | 18 | #include <asm/arch/cpu.h> |
Stefan Roese | c243784 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 19 | #include <asm/arch/soc.h> |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 20 | #include <asm/arch/mpp.h> |
| 21 | #include <asm/arch/gpio.h> |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 22 | |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 23 | #include "netspace_v2.h" |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 24 | #include "../common/common.h" |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 25 | |
| 26 | DECLARE_GLOBAL_DATA_PTR; |
| 27 | |
| 28 | int board_early_init_f(void) |
| 29 | { |
| 30 | /* Gpio configuration */ |
Stefan Roese | c50ab39 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 31 | mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH, |
| 32 | NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH); |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 33 | |
| 34 | /* Multi-Purpose Pins Functionality configuration */ |
Albert ARIBAUD | 4d42431 | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 35 | static const u32 kwmpp_config[] = { |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 36 | MPP0_SPI_SCn, |
| 37 | MPP1_SPI_MOSI, |
| 38 | MPP2_SPI_SCK, |
| 39 | MPP3_SPI_MISO, |
| 40 | MPP4_NF_IO6, |
| 41 | MPP5_NF_IO7, |
| 42 | MPP6_SYSRST_OUTn, |
| 43 | MPP7_GPO, /* Fan speed (bit 1) */ |
| 44 | MPP8_TW_SDA, |
| 45 | MPP9_TW_SCK, |
| 46 | MPP10_UART0_TXD, |
| 47 | MPP11_UART0_RXD, |
| 48 | MPP12_GPO, /* Red led */ |
| 49 | MPP14_GPIO, /* USB fuse */ |
| 50 | MPP16_GPIO, /* SATA 0 power */ |
| 51 | MPP17_GPIO, /* SATA 1 power */ |
| 52 | MPP18_NF_IO0, |
| 53 | MPP19_NF_IO1, |
| 54 | MPP20_SATA1_ACTn, |
| 55 | MPP21_SATA0_ACTn, |
| 56 | MPP22_GPIO, /* Fan speed (bit 0) */ |
| 57 | MPP23_GPIO, /* Fan power */ |
| 58 | MPP24_GPIO, /* USB mode select */ |
| 59 | MPP25_GPIO, /* Fan rotation fail */ |
| 60 | MPP26_GPIO, /* USB vbus-in detection */ |
| 61 | MPP28_GPIO, /* USB enable vbus-out */ |
| 62 | MPP29_GPIO, /* Blue led (slow register) */ |
| 63 | MPP30_GPIO, /* Blue led (command register) */ |
| 64 | MPP31_GPIO, /* Board power off */ |
| 65 | MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */ |
| 66 | MPP33_GPIO, /* Fan speed (bit 2) */ |
| 67 | 0 |
| 68 | }; |
Valentin Longchamp | 7d0d502 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 69 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 70 | |
| 71 | return 0; |
| 72 | } |
| 73 | |
| 74 | int board_init(void) |
| 75 | { |
Tom Rini | eb6aadc | 2021-08-30 09:16:32 -0400 | [diff] [blame] | 76 | #ifdef CONFIG_MACH_TYPE |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 77 | /* Machine number */ |
| 78 | gd->bd->bi_arch_number = CONFIG_MACH_TYPE; |
Tom Rini | eb6aadc | 2021-08-30 09:16:32 -0400 | [diff] [blame] | 79 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 80 | |
| 81 | /* Boot parameters address */ |
Stefan Roese | 0b74175 | 2014-10-22 12:13:13 +0200 | [diff] [blame] | 82 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 83 | |
| 84 | return 0; |
| 85 | } |
| 86 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 87 | #if defined(CONFIG_MISC_INIT_R) |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 88 | int misc_init_r(void) |
| 89 | { |
| 90 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 91 | if (!env_get("ethaddr")) { |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 92 | uchar mac[6]; |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 93 | if (lacie_read_mac_address(mac) == 0) |
Simon Glass | 8551d55 | 2017-08-03 12:22:11 -0600 | [diff] [blame] | 94 | eth_env_set_enetaddr("ethaddr", mac); |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 95 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 96 | #endif |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 97 | return 0; |
| 98 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 99 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 100 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 101 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 102 | /* Configure and initialize PHY */ |
| 103 | void reset_phy(void) |
| 104 | { |
Simon Guinot | 13c5ae6 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 105 | #if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2) |
Simon Guinot | ab07aa2 | 2020-06-28 19:00:31 +0200 | [diff] [blame] | 106 | mv_phy_88e1318_init("ethernet-controller@72000", 0); |
Simon Guinot | 13c5ae6 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 107 | #else |
Simon Guinot | ab07aa2 | 2020-06-28 19:00:31 +0200 | [diff] [blame] | 108 | mv_phy_88e1116_init("ethernet-controller@72000", 8); |
Simon Guinot | 13c5ae6 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 109 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 110 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 111 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 112 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 113 | #if defined(CONFIG_KIRKWOOD_GPIO) |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 114 | /* Return GPIO button status */ |
| 115 | static int |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 116 | do_read_button(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 117 | { |
| 118 | return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON); |
| 119 | } |
| 120 | |
| 121 | U_BOOT_CMD(button, 1, 1, do_read_button, |
| 122 | "Return GPIO button status 0=off 1=on", ""); |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 123 | #endif |