Simon Guinot | 16311a2 | 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 | * |
| 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 Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 24 | #include <command.h> |
Anatolij Gustschin | 5cf80f1 | 2011-10-29 11:31:19 +0000 | [diff] [blame] | 25 | #include <asm/arch/cpu.h> |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 26 | #include <asm/arch/kirkwood.h> |
| 27 | #include <asm/arch/mpp.h> |
| 28 | #include <asm/arch/gpio.h> |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 29 | |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 30 | #include "netspace_v2.h" |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 31 | #include "../common/common.h" |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 32 | |
| 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
| 35 | int 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 ARIBAUD | 4d42431 | 2012-11-26 11:27:36 +0000 | [diff] [blame] | 42 | static const u32 kwmpp_config[] = { |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 43 | 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 Longchamp | 7d0d502 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 76 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 77 | |
| 78 | return 0; |
| 79 | } |
| 80 | |
| 81 | int 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 Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 92 | #if defined(CONFIG_MISC_INIT_R) |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 93 | int misc_init_r(void) |
| 94 | { |
| 95 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
| 96 | if (!getenv("ethaddr")) { |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 97 | uchar mac[6]; |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 98 | if (lacie_read_mac_address(mac) == 0) |
| 99 | eth_setenv_enetaddr("ethaddr", mac); |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 100 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 101 | #endif |
Simon Guinot | 6e23891 | 2011-11-08 11:31:14 +0000 | [diff] [blame] | 102 | return 0; |
| 103 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 104 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 105 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 106 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 107 | /* Configure and initialize PHY */ |
| 108 | void reset_phy(void) |
| 109 | { |
Simon Guinot | 13c5ae6 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 110 | #if defined(CONFIG_NETSPACE_LITE_V2) || defined(CONFIG_NETSPACE_MINI_V2) |
| 111 | mv_phy_88e1318_init("egiga0", 0); |
| 112 | #else |
Simon Guinot | 0473b68 | 2012-06-05 13:16:00 +0000 | [diff] [blame] | 113 | mv_phy_88e1116_init("egiga0", 8); |
Simon Guinot | 13c5ae6 | 2012-09-06 10:51:42 +0000 | [diff] [blame] | 114 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 115 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 116 | #endif |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 117 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 118 | #if defined(CONFIG_KIRKWOOD_GPIO) |
Simon Guinot | 16311a2 | 2011-06-17 19:41:33 +0530 | [diff] [blame] | 119 | /* Return GPIO button status */ |
| 120 | static int |
| 121 | do_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 | |
| 126 | U_BOOT_CMD(button, 1, 1, do_read_button, |
| 127 | "Return GPIO button status 0=off 1=on", ""); |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 128 | #endif |