blob: 3773587cc6d1ea9ffb553009b8ff2de0354568ec [file] [log] [blame]
Simon Guinot79642092011-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 Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Simon Guinot79642092011-06-17 19:41:33 +053010 */
11
12#include <common.h>
Simon Guinot79642092011-06-17 19:41:33 +053013#include <command.h>
Anatolij Gustschinfc168cc2011-10-29 11:31:19 +000014#include <asm/arch/cpu.h>
Simon Guinot79642092011-06-17 19:41:33 +053015#include <asm/arch/kirkwood.h>
16#include <asm/arch/mpp.h>
17#include <asm/arch/gpio.h>
Simon Guinot77ea0712011-11-21 19:25:47 +053018
Simon Guinot79642092011-06-17 19:41:33 +053019#include "netspace_v2.h"
Simon Guinot77ea0712011-11-21 19:25:47 +053020#include "../common/common.h"
Simon Guinot79642092011-06-17 19:41:33 +053021
22DECLARE_GLOBAL_DATA_PTR;
23
24int board_early_init_f(void)
25{
26 /* Gpio configuration */
27 kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
28 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
29
30 /* Multi-Purpose Pins Functionality configuration */
Albert ARIBAUD9d86f0c2012-11-26 11:27:36 +000031 static const u32 kwmpp_config[] = {
Simon Guinot79642092011-06-17 19:41:33 +053032 MPP0_SPI_SCn,
33 MPP1_SPI_MOSI,
34 MPP2_SPI_SCK,
35 MPP3_SPI_MISO,
36 MPP4_NF_IO6,
37 MPP5_NF_IO7,
38 MPP6_SYSRST_OUTn,
39 MPP7_GPO, /* Fan speed (bit 1) */
40 MPP8_TW_SDA,
41 MPP9_TW_SCK,
42 MPP10_UART0_TXD,
43 MPP11_UART0_RXD,
44 MPP12_GPO, /* Red led */
45 MPP14_GPIO, /* USB fuse */
46 MPP16_GPIO, /* SATA 0 power */
47 MPP17_GPIO, /* SATA 1 power */
48 MPP18_NF_IO0,
49 MPP19_NF_IO1,
50 MPP20_SATA1_ACTn,
51 MPP21_SATA0_ACTn,
52 MPP22_GPIO, /* Fan speed (bit 0) */
53 MPP23_GPIO, /* Fan power */
54 MPP24_GPIO, /* USB mode select */
55 MPP25_GPIO, /* Fan rotation fail */
56 MPP26_GPIO, /* USB vbus-in detection */
57 MPP28_GPIO, /* USB enable vbus-out */
58 MPP29_GPIO, /* Blue led (slow register) */
59 MPP30_GPIO, /* Blue led (command register) */
60 MPP31_GPIO, /* Board power off */
61 MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */
62 MPP33_GPIO, /* Fan speed (bit 2) */
63 0
64 };
Valentin Longchamp84683632012-06-01 01:31:00 +000065 kirkwood_mpp_conf(kwmpp_config, NULL);
Simon Guinot79642092011-06-17 19:41:33 +053066
67 return 0;
68}
69
70int board_init(void)
71{
72 /* Machine number */
73 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
74
75 /* Boot parameters address */
76 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
77
78 return 0;
79}
80
Simon Guinot77ea0712011-11-21 19:25:47 +053081#if defined(CONFIG_MISC_INIT_R)
Simon Guinot0bfb66b2011-11-08 11:31:14 +000082int misc_init_r(void)
83{
84#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
85 if (!getenv("ethaddr")) {
Simon Guinot0bfb66b2011-11-08 11:31:14 +000086 uchar mac[6];
Simon Guinot77ea0712011-11-21 19:25:47 +053087 if (lacie_read_mac_address(mac) == 0)
88 eth_setenv_enetaddr("ethaddr", mac);
Simon Guinot0bfb66b2011-11-08 11:31:14 +000089 }
Simon Guinot77ea0712011-11-21 19:25:47 +053090#endif
Simon Guinot0bfb66b2011-11-08 11:31:14 +000091 return 0;
92}
Simon Guinot77ea0712011-11-21 19:25:47 +053093#endif
Simon Guinot0bfb66b2011-11-08 11:31:14 +000094
Simon Guinot77ea0712011-11-21 19:25:47 +053095#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
Simon Guinot79642092011-06-17 19:41:33 +053096/* Configure and initialize PHY */
97void reset_phy(void)
98{
Simon Guinot37235492012-09-06 10:51:42 +000099#if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2)
100 mv_phy_88e1318_init("egiga0", 0);
101#else
Simon Guinotc59c0852012-06-05 13:16:00 +0000102 mv_phy_88e1116_init("egiga0", 8);
Simon Guinot37235492012-09-06 10:51:42 +0000103#endif
Simon Guinot79642092011-06-17 19:41:33 +0530104}
Simon Guinot77ea0712011-11-21 19:25:47 +0530105#endif
Simon Guinot79642092011-06-17 19:41:33 +0530106
Simon Guinot77ea0712011-11-21 19:25:47 +0530107#if defined(CONFIG_KIRKWOOD_GPIO)
Simon Guinot79642092011-06-17 19:41:33 +0530108/* Return GPIO button status */
109static int
110do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
111{
112 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
113}
114
115U_BOOT_CMD(button, 1, 1, do_read_button,
116 "Return GPIO button status 0=off 1=on", "");
Simon Guinot77ea0712011-11-21 19:25:47 +0530117#endif