Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 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 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 13 | #include <command.h> |
Simon Glass | c62db35 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 14 | #include <asm/mach-types.h> |
Anatolij Gustschin | fc168cc | 2011-10-29 11:31:19 +0000 | [diff] [blame] | 15 | #include <asm/arch/cpu.h> |
Stefan Roese | 3dc23f7 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 16 | #include <asm/arch/soc.h> |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 17 | #include <asm/arch/mpp.h> |
| 18 | #include <asm/arch/gpio.h> |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 19 | |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 20 | #include "netspace_v2.h" |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 21 | #include "../common/common.h" |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
| 25 | int board_early_init_f(void) |
| 26 | { |
| 27 | /* Gpio configuration */ |
Stefan Roese | d5c5132 | 2014-10-22 12:13:11 +0200 | [diff] [blame] | 28 | mvebu_config_gpio(NETSPACE_V2_OE_VAL_LOW, NETSPACE_V2_OE_VAL_HIGH, |
| 29 | NETSPACE_V2_OE_LOW, NETSPACE_V2_OE_HIGH); |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 30 | |
| 31 | /* Multi-Purpose Pins Functionality configuration */ |
Albert ARIBAUD | 9d86f0c | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 32 | static const u32 kwmpp_config[] = { |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 33 | MPP0_SPI_SCn, |
| 34 | MPP1_SPI_MOSI, |
| 35 | MPP2_SPI_SCK, |
| 36 | MPP3_SPI_MISO, |
| 37 | MPP4_NF_IO6, |
| 38 | MPP5_NF_IO7, |
| 39 | MPP6_SYSRST_OUTn, |
| 40 | MPP7_GPO, /* Fan speed (bit 1) */ |
| 41 | MPP8_TW_SDA, |
| 42 | MPP9_TW_SCK, |
| 43 | MPP10_UART0_TXD, |
| 44 | MPP11_UART0_RXD, |
| 45 | MPP12_GPO, /* Red led */ |
| 46 | MPP14_GPIO, /* USB fuse */ |
| 47 | MPP16_GPIO, /* SATA 0 power */ |
| 48 | MPP17_GPIO, /* SATA 1 power */ |
| 49 | MPP18_NF_IO0, |
| 50 | MPP19_NF_IO1, |
| 51 | MPP20_SATA1_ACTn, |
| 52 | MPP21_SATA0_ACTn, |
| 53 | MPP22_GPIO, /* Fan speed (bit 0) */ |
| 54 | MPP23_GPIO, /* Fan power */ |
| 55 | MPP24_GPIO, /* USB mode select */ |
| 56 | MPP25_GPIO, /* Fan rotation fail */ |
| 57 | MPP26_GPIO, /* USB vbus-in detection */ |
| 58 | MPP28_GPIO, /* USB enable vbus-out */ |
| 59 | MPP29_GPIO, /* Blue led (slow register) */ |
| 60 | MPP30_GPIO, /* Blue led (command register) */ |
| 61 | MPP31_GPIO, /* Board power off */ |
| 62 | MPP32_GPIO, /* Button (0 = Released, 1 = Pushed) */ |
| 63 | MPP33_GPIO, /* Fan speed (bit 2) */ |
| 64 | 0 |
| 65 | }; |
Valentin Longchamp | 8468363 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 66 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 67 | |
| 68 | return 0; |
| 69 | } |
| 70 | |
| 71 | int board_init(void) |
| 72 | { |
| 73 | /* Machine number */ |
| 74 | gd->bd->bi_arch_number = CONFIG_MACH_TYPE; |
| 75 | |
| 76 | /* Boot parameters address */ |
Stefan Roese | 96c5f08 | 2014-10-22 12:13:13 +0200 | [diff] [blame] | 77 | gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 78 | |
| 79 | return 0; |
| 80 | } |
| 81 | |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 82 | #if defined(CONFIG_MISC_INIT_R) |
Simon Guinot | 0bfb66b | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 83 | int misc_init_r(void) |
| 84 | { |
| 85 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
| 86 | if (!getenv("ethaddr")) { |
Simon Guinot | 0bfb66b | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 87 | uchar mac[6]; |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 88 | if (lacie_read_mac_address(mac) == 0) |
Simon Glass | fd1e959 | 2017-08-03 12:22:11 -0600 | [diff] [blame^] | 89 | eth_env_set_enetaddr("ethaddr", mac); |
Simon Guinot | 0bfb66b | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 90 | } |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 91 | #endif |
Simon Guinot | 0bfb66b | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 92 | return 0; |
| 93 | } |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 94 | #endif |
Simon Guinot | 0bfb66b | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 95 | |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 96 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 97 | /* Configure and initialize PHY */ |
| 98 | void reset_phy(void) |
| 99 | { |
Simon Guinot | 3723549 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 100 | #if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2) |
| 101 | mv_phy_88e1318_init("egiga0", 0); |
| 102 | #else |
Simon Guinot | c59c085 | 2012-06-05 13:16:00 +0000 | [diff] [blame] | 103 | mv_phy_88e1116_init("egiga0", 8); |
Simon Guinot | 3723549 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 104 | #endif |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 105 | } |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 106 | #endif |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 107 | |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 108 | #if defined(CONFIG_KIRKWOOD_GPIO) |
Simon Guinot | 7964209 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 109 | /* Return GPIO button status */ |
| 110 | static int |
| 111 | do_read_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 112 | { |
| 113 | return kw_gpio_get_value(NETSPACE_V2_GPIO_BUTTON); |
| 114 | } |
| 115 | |
| 116 | U_BOOT_CMD(button, 1, 1, do_read_button, |
| 117 | "Return GPIO button status 0=off 1=on", ""); |
Simon Guinot | 77ea071 | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 118 | #endif |