blob: 3bd9fa96338f8b1ab1dd3731774d5b7dfbefc52e [file] [log] [blame]
Simon Guinot16311a22011-06-17 19:41:33 +05301/*
2 * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com>
3 *
4 * Based on Kirkwood support:
5 * (C) Copyright 2009
6 * Marvell Semiconductor <www.marvell.com>
7 * Written-by: Prafulla Wadaskar <prafulla@marvell.com>
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Simon Guinot16311a22011-06-17 19:41:33 +053010 */
11
12#include <common.h>
Simon Guinot16311a22011-06-17 19:41:33 +053013#include <command.h>
Alex Kiernan9c215492018-04-01 09:22:38 +000014#include <environment.h>
Simon Glass0ffb9d62017-05-31 19:47:48 -060015#include <asm/mach-types.h>
Anatolij Gustschin5cf80f12011-10-29 11:31:19 +000016#include <asm/arch/cpu.h>
Stefan Roesec2437842014-10-22 12:13:06 +020017#include <asm/arch/soc.h>
Simon Guinot16311a22011-06-17 19:41:33 +053018#include <asm/arch/mpp.h>
19#include <asm/arch/gpio.h>
Simon Guinota35cb4c2011-11-21 19:25:47 +053020
Simon Guinot16311a22011-06-17 19:41:33 +053021#include "netspace_v2.h"
Simon Guinota35cb4c2011-11-21 19:25:47 +053022#include "../common/common.h"
Simon Guinot16311a22011-06-17 19:41:33 +053023
24DECLARE_GLOBAL_DATA_PTR;
25
26int board_early_init_f(void)
27{
28 /* Gpio configuration */
Stefan Roesec50ab392014-10-22 12:13:11 +020029 mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
30 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
Simon Guinot16311a22011-06-17 19:41:33 +053031
32 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000033 static const u32 kwmpp_config[] = {
Simon Guinot16311a22011-06-17 19:41:33 +053034 MPP0_SPI_SCn,
35 MPP1_SPI_MOSI,
36 MPP2_SPI_SCK,
37 MPP3_SPI_MISO,
38 MPP4_NF_IO6,
39 MPP5_NF_IO7,
40 MPP6_SYSRST_OUTn,
41 MPP7_GPO, /* Fan speed (bit 1) */
42 MPP8_TW_SDA,
43 MPP9_TW_SCK,
44 MPP10_UART0_TXD,
45 MPP11_UART0_RXD,
46 MPP12_GPO, /* Red led */
47 MPP14_GPIO, /* USB fuse */
48 MPP16_GPIO, /* SATA 0 power */
49 MPP17_GPIO, /* SATA 1 power */
50 MPP18_NF_IO0,
51 MPP19_NF_IO1,
52 MPP20_SATA1_ACTn,
53 MPP21_SATA0_ACTn,
54 MPP22_GPIO, /* Fan speed (bit 0) */
55 MPP23_GPIO, /* Fan power */
56 MPP24_GPIO, /* USB mode select */
57 MPP25_GPIO, /* Fan rotation fail */
58 MPP26_GPIO, /* USB vbus-in detection */
59 MPP28_GPIO, /* USB enable vbus-out */
60 MPP29_GPIO, /* Blue led (slow register) */
61 MPP30_GPIO, /* Blue led (command register) */
62 MPP31_GPIO, /* Board power off */
63 MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */
64 MPP33_GPIO, /* Fan speed (bit 2) */
65 0
66 };
Valentin Longchamp7d0d5022012-06-01 01:31:00 +000067 kirkwood_mpp_conf(kwmpp_config, NULL);
Simon Guinot16311a22011-06-17 19:41:33 +053068
69 return 0;
70}
71
72int board_init(void)
73{
74 /* Machine number */
75 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
76
77 /* Boot parameters address */
Stefan Roese0b741752014-10-22 12:13:13 +020078 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Simon Guinot16311a22011-06-17 19:41:33 +053079
80 return 0;
81}
82
Simon Guinota35cb4c2011-11-21 19:25:47 +053083#if defined(CONFIG_MISC_INIT_R)
Simon Guinot6e238912011-11-08 11:31:14 +000084int misc_init_r(void)
85{
86#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
Simon Glass64b723f2017-08-03 12:22:12 -060087 if (!env_get("ethaddr")) {
Simon Guinot6e238912011-11-08 11:31:14 +000088 uchar mac[6];
Simon Guinota35cb4c2011-11-21 19:25:47 +053089 if (lacie_read_mac_address(mac) == 0)
Simon Glass8551d552017-08-03 12:22:11 -060090 eth_env_set_enetaddr("ethaddr", mac);
Simon Guinot6e238912011-11-08 11:31:14 +000091 }
Simon Guinota35cb4c2011-11-21 19:25:47 +053092#endif
Simon Guinot6e238912011-11-08 11:31:14 +000093 return 0;
94}
Simon Guinota35cb4c2011-11-21 19:25:47 +053095#endif
Simon Guinot16311a22011-06-17 19:41:33 +053096
Simon Guinota35cb4c2011-11-21 19:25:47 +053097#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
Simon Guinot16311a22011-06-17 19:41:33 +053098/* Configure and initialize PHY */
99void reset_phy(void)
100{
Simon Guinot13c5ae62012-09-06 10:51:42 +0000101#if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2)
102 mv_phy_88e1318_init("egiga0", 0);
103#else
Simon Guinot0473b682012-06-05 13:16:00 +0000104 mv_phy_88e1116_init("egiga0", 8);
Simon Guinot13c5ae62012-09-06 10:51:42 +0000105#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530106}
Simon Guinota35cb4c2011-11-21 19:25:47 +0530107#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530108
Simon Guinota35cb4c2011-11-21 19:25:47 +0530109#if defined(CONFIG_KIRKWOOD_GPIO)
Simon Guinot16311a22011-06-17 19:41:33 +0530110/* Return GPIO button status */
111static int
112do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
113{
114 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
115}
116
117U_BOOT_CMD(button, 1, 1, do_read_button,
118 "Return GPIO button status 0=off 1=on", "");
Simon Guinota35cb4c2011-11-21 19:25:47 +0530119#endif