blob: 3a2fdb5c1546a3332338fe92afd7124866d47993 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Guinot16311a22011-06-17 19:41:33 +05302/*
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 Guinot16311a22011-06-17 19:41:33 +05309 */
10
Simon Guinot16311a22011-06-17 19:41:33 +053011#include <command.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060012#include <env.h>
Simon Glass97589732020-05-10 11:40:02 -060013#include <init.h>
Simon Glass0c364412019-12-28 10:44:48 -070014#include <net.h>
Simon Glass3ba929a2020-10-30 21:38:53 -060015#include <asm/global_data.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060016#include <asm/mach-types.h>
Anatolij Gustschin5cf80f12011-10-29 11:31:19 +000017#include <asm/arch/cpu.h>
Stefan Roesec2437842014-10-22 12:13:06 +020018#include <asm/arch/soc.h>
Simon Guinot16311a22011-06-17 19:41:33 +053019#include <asm/arch/mpp.h>
20#include <asm/arch/gpio.h>
Simon Guinota35cb4c2011-11-21 19:25:47 +053021
Simon Guinot16311a22011-06-17 19:41:33 +053022#include "netspace_v2.h"
Simon Guinota35cb4c2011-11-21 19:25:47 +053023#include "../common/common.h"
Simon Guinot16311a22011-06-17 19:41:33 +053024
25DECLARE_GLOBAL_DATA_PTR;
26
27int board_early_init_f(void)
28{
29 /* Gpio configuration */
Stefan Roesec50ab392014-10-22 12:13:11 +020030 mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
31 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
Simon Guinot16311a22011-06-17 19:41:33 +053032
33 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000034 static const u32 kwmpp_config[] = {
Simon Guinot16311a22011-06-17 19:41:33 +053035 MPP0_SPI_SCn,
36 MPP1_SPI_MOSI,
37 MPP2_SPI_SCK,
38 MPP3_SPI_MISO,
39 MPP4_NF_IO6,
40 MPP5_NF_IO7,
41 MPP6_SYSRST_OUTn,
42 MPP7_GPO, /* Fan speed (bit 1) */
43 MPP8_TW_SDA,
44 MPP9_TW_SCK,
45 MPP10_UART0_TXD,
46 MPP11_UART0_RXD,
47 MPP12_GPO, /* Red led */
48 MPP14_GPIO, /* USB fuse */
49 MPP16_GPIO, /* SATA 0 power */
50 MPP17_GPIO, /* SATA 1 power */
51 MPP18_NF_IO0,
52 MPP19_NF_IO1,
53 MPP20_SATA1_ACTn,
54 MPP21_SATA0_ACTn,
55 MPP22_GPIO, /* Fan speed (bit 0) */
56 MPP23_GPIO, /* Fan power */
57 MPP24_GPIO, /* USB mode select */
58 MPP25_GPIO, /* Fan rotation fail */
59 MPP26_GPIO, /* USB vbus-in detection */
60 MPP28_GPIO, /* USB enable vbus-out */
61 MPP29_GPIO, /* Blue led (slow register) */
62 MPP30_GPIO, /* Blue led (command register) */
63 MPP31_GPIO, /* Board power off */
64 MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */
65 MPP33_GPIO, /* Fan speed (bit 2) */
66 0
67 };
Valentin Longchamp7d0d5022012-06-01 01:31:00 +000068 kirkwood_mpp_conf(kwmpp_config, NULL);
Simon Guinot16311a22011-06-17 19:41:33 +053069
70 return 0;
71}
72
73int board_init(void)
74{
Tom Rinieb6aadc2021-08-30 09:16:32 -040075#ifdef CONFIG_MACH_TYPE
Simon Guinot16311a22011-06-17 19:41:33 +053076 /* Machine number */
77 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
Tom Rinieb6aadc2021-08-30 09:16:32 -040078#endif
Simon Guinot16311a22011-06-17 19:41:33 +053079
80 /* Boot parameters address */
Stefan Roese0b741752014-10-22 12:13:13 +020081 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Simon Guinot16311a22011-06-17 19:41:33 +053082
83 return 0;
84}
85
Simon Guinota35cb4c2011-11-21 19:25:47 +053086#if defined(CONFIG_MISC_INIT_R)
Simon Guinot6e238912011-11-08 11:31:14 +000087int misc_init_r(void)
88{
89#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Simon Glass64b723f2017-08-03 12:22:12 -060090 if (!env_get("ethaddr")) {
Simon Guinot6e238912011-11-08 11:31:14 +000091 uchar mac[6];
Simon Guinota35cb4c2011-11-21 19:25:47 +053092 if (lacie_read_mac_address(mac) == 0)
Simon Glass8551d552017-08-03 12:22:11 -060093 eth_env_set_enetaddr("ethaddr", mac);
Simon Guinot6e238912011-11-08 11:31:14 +000094 }
Simon Guinota35cb4c2011-11-21 19:25:47 +053095#endif
Simon Guinot6e238912011-11-08 11:31:14 +000096 return 0;
97}
Simon Guinota35cb4c2011-11-21 19:25:47 +053098#endif
Simon Guinot16311a22011-06-17 19:41:33 +053099
Simon Guinota35cb4c2011-11-21 19:25:47 +0530100#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
Simon Guinot16311a22011-06-17 19:41:33 +0530101/* Configure and initialize PHY */
102void reset_phy(void)
103{
Simon Guinot13c5ae62012-09-06 10:51:42 +0000104#if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2)
Simon Guinotab07aa22020-06-28 19:00:31 +0200105 mv_phy_88e1318_init("ethernet-controller@72000", 0);
Simon Guinot13c5ae62012-09-06 10:51:42 +0000106#else
Simon Guinotab07aa22020-06-28 19:00:31 +0200107 mv_phy_88e1116_init("ethernet-controller@72000", 8);
Simon Guinot13c5ae62012-09-06 10:51:42 +0000108#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530109}
Simon Guinota35cb4c2011-11-21 19:25:47 +0530110#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530111
Simon Guinota35cb4c2011-11-21 19:25:47 +0530112#if defined(CONFIG_KIRKWOOD_GPIO)
Simon Guinot16311a22011-06-17 19:41:33 +0530113/* Return GPIO button status */
114static int
Simon Glassed38aef2020-05-10 11:40:03 -0600115do_read_button(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Simon Guinot16311a22011-06-17 19:41:33 +0530116{
117 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
118}
119
120U_BOOT_CMD(button, 1, 1, do_read_button,
121 "Return GPIO button status 0=off 1=on", "");
Simon Guinota35cb4c2011-11-21 19:25:47 +0530122#endif