Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +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 | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 24 | #include <command.h> |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 25 | #include <asm/arch/cpu.h> |
| 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 | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 30 | #include "net2big_v2.h" |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 31 | #include "../common/common.h" |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +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(NET2BIG_V2_OE_VAL_LOW, NET2BIG_V2_OE_VAL_HIGH, |
| 39 | NET2BIG_V2_OE_LOW, NET2BIG_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 | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 43 | MPP0_SPI_SCn, |
| 44 | MPP1_SPI_MOSI, |
| 45 | MPP2_SPI_SCK, |
| 46 | MPP3_SPI_MISO, |
| 47 | MPP6_SYSRST_OUTn, |
| 48 | MPP7_GPO, /* Request power-off */ |
| 49 | MPP8_TW_SDA, |
| 50 | MPP9_TW_SCK, |
| 51 | MPP10_UART0_TXD, |
| 52 | MPP11_UART0_RXD, |
| 53 | MPP13_GPIO, /* Rear power switch (on|auto) */ |
| 54 | MPP14_GPIO, /* USB fuse alarm */ |
| 55 | MPP15_GPIO, /* Rear power switch (auto|off) */ |
| 56 | MPP16_GPIO, /* SATA HDD1 power */ |
| 57 | MPP17_GPIO, /* SATA HDD2 power */ |
| 58 | MPP20_SATA1_ACTn, |
| 59 | MPP21_SATA0_ACTn, |
| 60 | MPP24_GPIO, /* USB mode select */ |
| 61 | MPP26_GPIO, /* USB device vbus */ |
| 62 | MPP28_GPIO, /* USB enable host vbus */ |
| 63 | MPP29_GPIO, /* GPIO extension ALE */ |
| 64 | MPP34_GPIO, /* Rear Push button 0=on 1=off */ |
| 65 | MPP35_GPIO, /* Inhibit switch power-off */ |
| 66 | MPP36_GPIO, /* SATA HDD1 presence */ |
| 67 | MPP37_GPIO, /* SATA HDD2 presence */ |
| 68 | MPP40_GPIO, /* eSATA presence */ |
| 69 | MPP44_GPIO, /* GPIO extension (data 0) */ |
| 70 | MPP45_GPIO, /* GPIO extension (data 1) */ |
| 71 | MPP46_GPIO, /* GPIO extension (data 2) */ |
| 72 | MPP47_GPIO, /* GPIO extension (addr 0) */ |
| 73 | MPP48_GPIO, /* GPIO extension (addr 1) */ |
| 74 | MPP49_GPIO, /* GPIO extension (addr 2) */ |
| 75 | 0 |
| 76 | }; |
| 77 | |
Valentin Longchamp | 7d0d502 | 2012-06-01 01:31:00 +0000 | [diff] [blame] | 78 | kirkwood_mpp_conf(kwmpp_config, NULL); |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 79 | |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int board_init(void) |
| 84 | { |
| 85 | /* Machine number */ |
| 86 | gd->bd->bi_arch_number = MACH_TYPE_NET2BIG_V2; |
| 87 | |
| 88 | /* Boot parameters address */ |
| 89 | gd->bd->bi_boot_params = kw_sdram_bar(0) + 0x100; |
| 90 | |
| 91 | return 0; |
| 92 | } |
| 93 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 94 | #if defined(CONFIG_MISC_INIT_R) |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 95 | int misc_init_r(void) |
| 96 | { |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 97 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 98 | if (!getenv("ethaddr")) { |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 99 | uchar mac[6]; |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 100 | if (lacie_read_mac_address(mac) == 0) |
| 101 | eth_setenv_enetaddr("ethaddr", mac); |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 102 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 103 | #endif |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 104 | return 0; |
| 105 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 106 | #endif |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 107 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 108 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 109 | /* Configure and initialize PHY */ |
| 110 | void reset_phy(void) |
| 111 | { |
Simon Guinot | 0473b68 | 2012-06-05 13:16:00 +0000 | [diff] [blame] | 112 | mv_phy_88e1116_init("egiga0", 8); |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 113 | } |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 114 | #endif |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 115 | |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 116 | #if defined(CONFIG_KIRKWOOD_GPIO) |
Simon Guinot | 72198a3 | 2011-11-21 19:25:46 +0530 | [diff] [blame] | 117 | /* Return GPIO push button status */ |
| 118 | static int |
| 119 | do_read_push_button(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 120 | { |
| 121 | return !kw_gpio_get_value(NET2BIG_V2_GPIO_PUSH_BUTTON); |
| 122 | } |
| 123 | |
| 124 | U_BOOT_CMD(button, 1, 1, do_read_push_button, |
| 125 | "Return GPIO push button status 0=off 1=on", ""); |
Simon Guinot | a35cb4c | 2011-11-21 19:25:47 +0530 | [diff] [blame] | 126 | #endif |