]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
79642098 SG |
2 | /* |
3 | * Copyright (C) 2011 Simon Guinot <sguinot@lacie.com> | |
4 | * | |
5 | * Based on Kirkwood support: | |
6 | * (C) Copyright 2009 | |
7 | * Marvell Semiconductor <www.marvell.com> | |
8 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> | |
79642098 SG |
9 | */ |
10 | ||
d678a59d | 11 | #include <common.h> |
79642098 | 12 | #include <command.h> |
9fb625ce | 13 | #include <env.h> |
691d719d | 14 | #include <init.h> |
5e6267af | 15 | #include <net.h> |
401d1c4f | 16 | #include <asm/global_data.h> |
c62db35d | 17 | #include <asm/mach-types.h> |
fc168cc5 | 18 | #include <asm/arch/cpu.h> |
3dc23f78 | 19 | #include <asm/arch/soc.h> |
79642098 SG |
20 | #include <asm/arch/mpp.h> |
21 | #include <asm/arch/gpio.h> | |
77ea071f | 22 | |
79642098 | 23 | #include "netspace_v2.h" |
77ea071f | 24 | #include "../common/common.h" |
79642098 SG |
25 | |
26 | DECLARE_GLOBAL_DATA_PTR; | |
27 | ||
28 | int board_early_init_f(void) | |
29 | { | |
30 | /* Gpio configuration */ | |
d5c5132f SR |
31 | mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH, |
32 | NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH); | |
79642098 SG |
33 | |
34 | /* Multi-Purpose Pins Functionality configuration */ | |
9d86f0c3 | 35 | static const u32 kwmpp_config[] = { |
79642098 SG |
36 | MPP0_SPI_SCn, |
37 | MPP1_SPI_MOSI, | |
38 | MPP2_SPI_SCK, | |
39 | MPP3_SPI_MISO, | |
40 | MPP4_NF_IO6, | |
41 | MPP5_NF_IO7, | |
42 | MPP6_SYSRST_OUTn, | |
43 | MPP7_GPO, /* Fan speed (bit 1) */ | |
44 | MPP8_TW_SDA, | |
45 | MPP9_TW_SCK, | |
46 | MPP10_UART0_TXD, | |
47 | MPP11_UART0_RXD, | |
48 | MPP12_GPO, /* Red led */ | |
49 | MPP14_GPIO, /* USB fuse */ | |
50 | MPP16_GPIO, /* SATA 0 power */ | |
51 | MPP17_GPIO, /* SATA 1 power */ | |
52 | MPP18_NF_IO0, | |
53 | MPP19_NF_IO1, | |
54 | MPP20_SATA1_ACTn, | |
55 | MPP21_SATA0_ACTn, | |
56 | MPP22_GPIO, /* Fan speed (bit 0) */ | |
57 | MPP23_GPIO, /* Fan power */ | |
58 | MPP24_GPIO, /* USB mode select */ | |
59 | MPP25_GPIO, /* Fan rotation fail */ | |
60 | MPP26_GPIO, /* USB vbus-in detection */ | |
61 | MPP28_GPIO, /* USB enable vbus-out */ | |
62 | MPP29_GPIO, /* Blue led (slow register) */ | |
63 | MPP30_GPIO, /* Blue led (command register) */ | |
64 | MPP31_GPIO, /* Board power off */ | |
65 | MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */ | |
66 | MPP33_GPIO, /* Fan speed (bit 2) */ | |
67 | 0 | |
68 | }; | |
84683638 | 69 | kirkwood_mpp_conf(kwmpp_config, NULL); |
79642098 SG |
70 | |
71 | return 0; | |
72 | } | |
73 | ||
74 | int board_init(void) | |
75 | { | |
5f588f83 | 76 | #ifdef CONFIG_MACH_TYPE |
79642098 SG |
77 | /* Machine number */ |
78 | gd->bd->bi_arch_number = CONFIG_MACH_TYPE; | |
5f588f83 | 79 | #endif |
79642098 SG |
80 | |
81 | /* Boot parameters address */ | |
96c5f081 | 82 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
79642098 SG |
83 | |
84 | return 0; | |
85 | } | |
86 | ||
77ea071f | 87 | #if defined(CONFIG_MISC_INIT_R) |
0bfb66b6 SG |
88 | int misc_init_r(void) |
89 | { | |
90 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) | |
00caae6d | 91 | if (!env_get("ethaddr")) { |
0bfb66b6 | 92 | uchar mac[6]; |
77ea071f | 93 | if (lacie_read_mac_address(mac) == 0) |
fd1e959e | 94 | eth_env_set_enetaddr("ethaddr", mac); |
0bfb66b6 | 95 | } |
77ea071f | 96 | #endif |
0bfb66b6 SG |
97 | return 0; |
98 | } | |
77ea071f | 99 | #endif |
0bfb66b6 | 100 | |
77ea071f | 101 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
79642098 SG |
102 | /* Configure and initialize PHY */ |
103 | void reset_phy(void) | |
104 | { | |
37235496 | 105 | #if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2) |
21b1c75f | 106 | mv_phy_88e1318_init("ethernet-controller@72000", 0); |
37235496 | 107 | #else |
21b1c75f | 108 | mv_phy_88e1116_init("ethernet-controller@72000", 8); |
37235496 | 109 | #endif |
79642098 | 110 | } |
77ea071f | 111 | #endif |
79642098 | 112 | |
77ea071f | 113 | #if defined(CONFIG_KIRKWOOD_GPIO) |
79642098 SG |
114 | /* Return GPIO button status */ |
115 | static int | |
09140113 | 116 | do_read_button(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
79642098 SG |
117 | { |
118 | return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON); | |
119 | } | |
120 | ||
121 | U_BOOT_CMD(button, 1, 1, do_read_button, | |
122 | "Return GPIO button status 0=off 1=on", ""); | |
77ea071f | 123 | #endif |