blob: 8620e4b5d135fa1022043a4cf53f40b2491dde20 [file] [log] [blame]
Albert ARIBAUD7202e8a2012-11-26 11:27:37 +00001/*
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+
Albert ARIBAUD7202e8a2012-11-26 11:27:37 +000010 */
11
12#include <common.h>
13#include <command.h>
14#include <asm/arch/cpu.h>
Stefan Roese3dc23f72014-10-22 12:13:06 +020015#include <asm/arch/soc.h>
Albert ARIBAUD7202e8a2012-11-26 11:27:37 +000016#include <asm/arch/mpp.h>
17#include <asm/arch/gpio.h>
18
19#include "../common/common.h"
20#include "netdev.h"
21
22DECLARE_GLOBAL_DATA_PTR;
23
24/* GPIO configuration: start FAN at low speed, USB and HDD */
25
26#define WIRELESS_SPACE_OE_LOW 0xFF006808
27#define WIRELESS_SPACE_OE_HIGH 0x0000F989
28#define WIRELESS_SPACE_OE_VAL_LOW 0x00010080
29#define WIRELESS_SPACE_OE_VAL_HIGH 0x00000240
30
31#define WIRELESS_SPACE_REAR_BUTTON 13
32#define WIRELESS_SPACE_FRONT_BUTTON 43
33
34const u32 kwmpp_config[] = {
35 MPP0_NF_IO2,
36 MPP1_NF_IO3,
37 MPP2_NF_IO4,
38 MPP3_NF_IO5,
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 MPP13_GPIO, /* Red led */
48 MPP14_GPIO, /* USB fuse */
49 MPP15_SATA0_ACTn,
50 MPP16_GPIO, /* SATA 0 power */
51 MPP17_GPIO, /* SATA 1 power */
52 MPP18_NF_IO0,
53 MPP19_NF_IO1,
54 MPP20_GE1_0, /* Gigabit Ethernet 1 */
55 MPP21_GE1_1,
56 MPP22_GE1_2,
57 MPP23_GE1_3,
58 MPP24_GE1_4,
59 MPP25_GE1_5,
60 MPP26_GE1_6,
61 MPP27_GE1_7,
62 MPP28_GE1_8,
63 MPP29_GE1_9,
64 MPP30_GE1_10,
65 MPP31_GE1_11,
66 MPP32_GE1_12,
67 MPP33_GE1_13,
68 MPP34_GE1_14,
69 MPP35_GE1_15,
70 MPP36_GPIO, /* Fan speed (bit 2) */
71 MPP37_GPIO, /* Fan speed (bit 0) */
72 MPP38_GPIO, /* Fan power */
73 MPP39_GPIO, /* Fan rotation fail */
74 MPP40_GPIO, /* Ethernet switch link */
75 MPP41_GPIO, /* USB enable host vbus */
76 MPP42_GPIO, /* LED clock control */
77 MPP43_GPIO, /* WPS button (0=Pushed, 1=Released) */
78 MPP44_GPIO, /* Red LED on/off */
79 MPP45_GPIO, /* Red LED timer blink (on=off=100ms) */
80 MPP46_GPIO, /* Green LED on/off */
81 MPP47_GPIO, /* LED (blue, green) SATA activity blink */
82 MPP48_GPIO, /* Blue LED on/off */
83 0
84};
85
86struct mv88e61xx_config swcfg = {
87 .name = "egiga0",
88 .vlancfg = MV88E61XX_VLANCFG_ROUTER,
89 .rgmii_delay = MV88E61XX_RGMII_DELAY_EN,
90 .led_init = MV88E61XX_LED_INIT_EN,
91 .mdip = MV88E61XX_MDIP_NOCHANGE,
92 .portstate = MV88E61XX_PORTSTT_FORWARDING,
93 .cpuport = 0x20,
94 .ports_enabled = 0x3F,
95};
96
97int board_early_init_f(void)
98{
99 /* Gpio configuration */
Stefan Roesed5c51322014-10-22 12:13:11 +0200100 mvebu_config_gpio(WIRELESS_SPACE_OE_VAL_LOW, WIRELESS_SPACE_OE_VAL_HIGH,
101 WIRELESS_SPACE_OE_LOW, WIRELESS_SPACE_OE_HIGH);
Albert ARIBAUD7202e8a2012-11-26 11:27:37 +0000102
103 /* Multi-Purpose Pins Functionality configuration */
104 kirkwood_mpp_conf(kwmpp_config, NULL);
105
106 return 0;
107}
108
109int board_init(void)
110{
111 /* Machine number */
112 gd->bd->bi_arch_number = CONFIG_MACH_TYPE;
113
114 /* Boot parameters address */
Stefan Roese96c5f082014-10-22 12:13:13 +0200115 gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
Albert ARIBAUD7202e8a2012-11-26 11:27:37 +0000116
117 return 0;
118}
119
120#if defined(CONFIG_MISC_INIT_R)
121int misc_init_r(void)
122{
123#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
124 if (!getenv("ethaddr")) {
125 uchar mac[6];
126 if (lacie_read_mac_address(mac) == 0)
127 eth_setenv_enetaddr("ethaddr", mac);
128 }
129#endif
130 return 0;
131}
132#endif
133
134#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
135/* Configure and initialize PHY */
136void reset_phy(void)
137{
138 /* configure switch on egiga0 */
139 mv88e61xx_switch_initialize(&swcfg);
140}
141#endif
142
143#if defined(CONFIG_KIRKWOOD_GPIO) && defined(CONFIG_WIRELESS_SPACE_CMD)
144/* Return GPIO button status */
145static int
146do_ws(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
147{
148 if (strcmp(argv[1], "button") == 0) {
149 if (strcmp(argv[2], "rear") == 0)
150 /* invert GPIO result for intuitive while/until use */
151 return !kw_gpio_get_value(WIRELESS_SPACE_REAR_BUTTON);
152 else if (strcmp(argv[2], "front") == 0)
153 return kw_gpio_get_value(WIRELESS_SPACE_FRONT_BUTTON);
154 else
155 return -1;
156 } else {
157 return -1;
158 }
159}
160
161U_BOOT_CMD(ws, 3, 0, do_ws,
162 "Return GPIO button status 0=off 1=on",
163 "- ws button rear|front: test buttons' states\n"
164);
165#endif