blob: fbf020fde11b4b89f391f4af43ed75e12d7e7cf3 [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 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 */
22
23#include <common.h>
Simon Guinot79642092011-06-17 19:41:33 +053024#include <command.h>
Anatolij Gustschinfc168cc2011-10-29 11:31:19 +000025#include <asm/arch/cpu.h>
Simon Guinot79642092011-06-17 19:41:33 +053026#include <asm/arch/kirkwood.h>
27#include <asm/arch/mpp.h>
28#include <asm/arch/gpio.h>
Simon Guinot77ea0712011-11-21 19:25:47 +053029
Simon Guinot79642092011-06-17 19:41:33 +053030#include "netspace_v2.h"
Simon Guinot77ea0712011-11-21 19:25:47 +053031#include "../common/common.h"
Simon Guinot79642092011-06-17 19:41:33 +053032
33DECLARE_GLOBAL_DATA_PTR;
34
35int board_early_init_f(void)
36{
37 /* Gpio configuration */
38 kw_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH,
39 NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH);
40
41 /* Multi-Purpose Pins Functionality configuration */
42 u32 kwmpp_config[] = {
43 MPP0_SPI_SCn,
44 MPP1_SPI_MOSI,
45 MPP2_SPI_SCK,
46 MPP3_SPI_MISO,
47 MPP4_NF_IO6,
48 MPP5_NF_IO7,
49 MPP6_SYSRST_OUTn,
50 MPP7_GPO, /* Fan speed (bit 1) */
51 MPP8_TW_SDA,
52 MPP9_TW_SCK,
53 MPP10_UART0_TXD,
54 MPP11_UART0_RXD,
55 MPP12_GPO, /* Red led */
56 MPP14_GPIO, /* USB fuse */
57 MPP16_GPIO, /* SATA 0 power */
58 MPP17_GPIO, /* SATA 1 power */
59 MPP18_NF_IO0,
60 MPP19_NF_IO1,
61 MPP20_SATA1_ACTn,
62 MPP21_SATA0_ACTn,
63 MPP22_GPIO, /* Fan speed (bit 0) */
64 MPP23_GPIO, /* Fan power */
65 MPP24_GPIO, /* USB mode select */
66 MPP25_GPIO, /* Fan rotation fail */
67 MPP26_GPIO, /* USB vbus-in detection */
68 MPP28_GPIO, /* USB enable vbus-out */
69 MPP29_GPIO, /* Blue led (slow register) */
70 MPP30_GPIO, /* Blue led (command register) */
71 MPP31_GPIO, /* Board power off */
72 MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */
73 MPP33_GPIO, /* Fan speed (bit 2) */
74 0
75 };
76 kirkwood_mpp_conf(kwmpp_config);
77
78 return 0;
79}
80
81int board_init(void)
82{
83 /* Machine number */
84 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
85
86 /* Boot parameters address */
87 gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100;
88
89 return 0;
90}
91
Simon Guinot77ea0712011-11-21 19:25:47 +053092#if defined(CONFIG_MISC_INIT_R)
Simon Guinot0bfb66b2011-11-08 11:31:14 +000093int misc_init_r(void)
94{
95#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
96 if (!getenv("ethaddr")) {
Simon Guinot0bfb66b2011-11-08 11:31:14 +000097 uchar mac[6];
Simon Guinot77ea0712011-11-21 19:25:47 +053098 if (lacie_read_mac_address(mac) == 0)
99 eth_setenv_enetaddr("ethaddr", mac);
Simon Guinot0bfb66b2011-11-08 11:31:14 +0000100 }
Simon Guinot77ea0712011-11-21 19:25:47 +0530101#endif
Simon Guinot0bfb66b2011-11-08 11:31:14 +0000102 return 0;
103}
Simon Guinot77ea0712011-11-21 19:25:47 +0530104#endif
Simon Guinot0bfb66b2011-11-08 11:31:14 +0000105
Simon Guinot77ea0712011-11-21 19:25:47 +0530106#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
Simon Guinot79642092011-06-17 19:41:33 +0530107/* Configure and initialize PHY */
108void reset_phy(void)
109{
110 mv_phy_88e1116_init("egiga0");
111}
Simon Guinot77ea0712011-11-21 19:25:47 +0530112#endif
Simon Guinot79642092011-06-17 19:41:33 +0530113
Simon Guinot77ea0712011-11-21 19:25:47 +0530114#if defined(CONFIG_KIRKWOOD_GPIO)
Simon Guinot79642092011-06-17 19:41:33 +0530115/* Return GPIO button status */
116static int
117do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
118{
119 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
120}
121
122U_BOOT_CMD(button, 1, 1, do_read_button,
123 "Return GPIO button status 0=off 1=on", "");
Simon Guinot77ea0712011-11-21 19:25:47 +0530124#endif