blob: 0aa5345ddcc8040ecff6e0948e0a2b3c93dc89a6 [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 *
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 Guinot16311a22011-06-17 19:41:33 +053024#include <command.h>
Anatolij Gustschin5cf80f12011-10-29 11:31:19 +000025#include <asm/arch/cpu.h>
Simon Guinot16311a22011-06-17 19:41:33 +053026#include <asm/arch/kirkwood.h>
27#include <asm/arch/mpp.h>
28#include <asm/arch/gpio.h>
Simon Guinota35cb4c2011-11-21 19:25:47 +053029
Simon Guinot16311a22011-06-17 19:41:33 +053030#include "netspace_v2.h"
Simon Guinota35cb4c2011-11-21 19:25:47 +053031#include "../common/common.h"
Simon Guinot16311a22011-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 */
Albert ARIBAUD4d424312012-11-26 11:27:36 +000042 static const u32 kwmpp_config[] = {
Simon Guinot16311a22011-06-17 19:41:33 +053043 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 };
Valentin Longchamp7d0d5022012-06-01 01:31:00 +000076 kirkwood_mpp_conf(kwmpp_config, NULL);
Simon Guinot16311a22011-06-17 19:41:33 +053077
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 Guinota35cb4c2011-11-21 19:25:47 +053092#if defined(CONFIG_MISC_INIT_R)
Simon Guinot6e238912011-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 Guinot6e238912011-11-08 11:31:14 +000097 uchar mac[6];
Simon Guinota35cb4c2011-11-21 19:25:47 +053098 if (lacie_read_mac_address(mac) == 0)
99 eth_setenv_enetaddr("ethaddr", mac);
Simon Guinot6e238912011-11-08 11:31:14 +0000100 }
Simon Guinota35cb4c2011-11-21 19:25:47 +0530101#endif
Simon Guinot6e238912011-11-08 11:31:14 +0000102 return 0;
103}
Simon Guinota35cb4c2011-11-21 19:25:47 +0530104#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530105
Simon Guinota35cb4c2011-11-21 19:25:47 +0530106#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
Simon Guinot16311a22011-06-17 19:41:33 +0530107/* Configure and initialize PHY */
108void reset_phy(void)
109{
Simon Guinot13c5ae62012-09-06 10:51:42 +0000110#if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2)
111 mv_phy_88e1318_init("egiga0", 0);
112#else
Simon Guinot0473b682012-06-05 13:16:00 +0000113 mv_phy_88e1116_init("egiga0", 8);
Simon Guinot13c5ae62012-09-06 10:51:42 +0000114#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530115}
Simon Guinota35cb4c2011-11-21 19:25:47 +0530116#endif
Simon Guinot16311a22011-06-17 19:41:33 +0530117
Simon Guinota35cb4c2011-11-21 19:25:47 +0530118#if defined(CONFIG_KIRKWOOD_GPIO)
Simon Guinot16311a22011-06-17 19:41:33 +0530119/* Return GPIO button status */
120static int
121do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
122{
123 return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON);
124}
125
126U_BOOT_CMD(button, 1, 1, do_read_button,
127 "Return GPIO button status 0=off 1=on", "");
Simon Guinota35cb4c2011-11-21 19:25:47 +0530128#endif