]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/LaCie/netspace_v2/netspace_v2.c
ot1200: add sata support
[karo-tx-uboot.git] / board / LaCie / netspace_v2 / netspace_v2.c
1 /*
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  * SPDX-License-Identifier:     GPL-2.0+
10  */
11
12 #include <common.h>
13 #include <command.h>
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/kirkwood.h>
16 #include <asm/arch/mpp.h>
17 #include <asm/arch/gpio.h>
18
19 #include "netspace_v2.h"
20 #include "../common/common.h"
21
22 DECLARE_GLOBAL_DATA_PTR;
23
24 int 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 */
31         static const u32 kwmpp_config[] = {
32                 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         };
65         kirkwood_mpp_conf(kwmpp_config, NULL);
66
67         return 0;
68 }
69
70 int 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
81 #if defined(CONFIG_MISC_INIT_R)
82 int misc_init_r(void)
83 {
84 #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
85         if (!getenv("ethaddr")) {
86                 uchar mac[6];
87                 if (lacie_read_mac_address(mac) == 0)
88                         eth_setenv_enetaddr("ethaddr", mac);
89         }
90 #endif
91         return 0;
92 }
93 #endif
94
95 #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
96 /* Configure and initialize PHY */
97 void reset_phy(void)
98 {
99 #if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2)
100         mv_phy_88e1318_init("egiga0", 0);
101 #else
102         mv_phy_88e1116_init("egiga0", 8);
103 #endif
104 }
105 #endif
106
107 #if defined(CONFIG_KIRKWOOD_GPIO)
108 /* Return GPIO button status */
109 static int
110 do_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
115 U_BOOT_CMD(button, 1, 1, do_read_button,
116            "Return GPIO button status 0=off 1=on", "");
117 #endif