2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2010-02-22 11:13:02 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2009
|
|
|
|
* Marvell Semiconductor <www.marvell.com>
|
|
|
|
* Prafulla Wadaskar <prafulla@marvell.com>
|
|
|
|
*
|
|
|
|
* (C) Copyright 2009
|
|
|
|
* Stefan Roese, DENX Software Engineering, sr@denx.de.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2010
|
|
|
|
* Heiko Schocher, DENX Software Engineering, hs@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-08-01 15:46:51 +00:00
|
|
|
#include <env.h>
|
2010-02-22 11:13:02 +00:00
|
|
|
#include <i2c.h>
|
|
|
|
#include <nand.h>
|
|
|
|
#include <netdev.h>
|
|
|
|
#include <miiphy.h>
|
2012-06-13 03:01:03 +00:00
|
|
|
#include <spi.h>
|
2010-02-22 11:13:02 +00:00
|
|
|
#include <asm/io.h>
|
2011-10-18 14:41:42 +00:00
|
|
|
#include <asm/arch/cpu.h>
|
2014-10-22 10:13:06 +00:00
|
|
|
#include <asm/arch/soc.h>
|
2010-02-22 11:13:02 +00:00
|
|
|
#include <asm/arch/mpp.h>
|
|
|
|
|
|
|
|
#include "../common/common.h"
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2011-05-31 02:12:52 +00:00
|
|
|
/*
|
|
|
|
* BOCO FPGA definitions
|
|
|
|
*/
|
|
|
|
#define BOCO 0x10
|
|
|
|
#define REG_CTRL_H 0x02
|
|
|
|
#define MASK_WRL_UNITRUN 0x01
|
|
|
|
#define MASK_RBX_PGY_PRESENT 0x40
|
|
|
|
#define REG_IRQ_CIRQ2 0x2d
|
|
|
|
#define MASK_RBI_DEFECT_16 0x01
|
|
|
|
|
2015-11-13 14:01:15 +00:00
|
|
|
/*
|
|
|
|
* PHY registers definitions
|
|
|
|
*/
|
|
|
|
#define PHY_MARVELL_OUI 0x5043
|
|
|
|
#define PHY_MARVELL_88E1118_MODEL 0x0022
|
|
|
|
#define PHY_MARVELL_88E1118R_MODEL 0x0024
|
|
|
|
|
|
|
|
#define PHY_MARVELL_PAGE_REG 0x0016
|
|
|
|
#define PHY_MARVELL_DEFAULT_PAGE 0x0000
|
|
|
|
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_PAGE 0x0003
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_REG 0x0010
|
|
|
|
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_RESERVED 0x1000
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB (0x7<<0)
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT (0x3<<4)
|
|
|
|
#define PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK (0x0<<8)
|
|
|
|
|
2015-11-13 14:01:16 +00:00
|
|
|
/* I/O pin to erase flash RGPP09 = MPP43 */
|
|
|
|
#define KM_FLASH_ERASE_ENABLE 43
|
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
/* Multi-Purpose Pins Functionality configuration */
|
2012-11-26 11:27:36 +00:00
|
|
|
static const u32 kwmpp_config[] = {
|
2010-02-22 11:13:02 +00:00
|
|
|
MPP0_NF_IO2,
|
|
|
|
MPP1_NF_IO3,
|
|
|
|
MPP2_NF_IO4,
|
|
|
|
MPP3_NF_IO5,
|
|
|
|
MPP4_NF_IO6,
|
|
|
|
MPP5_NF_IO7,
|
|
|
|
MPP6_SYSRST_OUTn,
|
2014-02-13 15:43:00 +00:00
|
|
|
#if defined(KM_PCIE_RESET_MPP7)
|
|
|
|
MPP7_GPO,
|
|
|
|
#else
|
2010-02-22 11:13:02 +00:00
|
|
|
MPP7_PEX_RST_OUTn,
|
2014-02-13 15:43:00 +00:00
|
|
|
#endif
|
2013-01-29 07:53:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_SOFT)
|
2010-02-22 11:13:02 +00:00
|
|
|
MPP8_GPIO, /* SDA */
|
|
|
|
MPP9_GPIO, /* SCL */
|
|
|
|
#endif
|
|
|
|
MPP10_UART0_TXD,
|
|
|
|
MPP11_UART0_RXD,
|
|
|
|
MPP12_GPO, /* Reserved */
|
|
|
|
MPP13_UART1_TXD,
|
|
|
|
MPP14_UART1_RXD,
|
|
|
|
MPP15_GPIO, /* Not used */
|
|
|
|
MPP16_GPIO, /* Not used */
|
|
|
|
MPP17_GPIO, /* Reserved */
|
|
|
|
MPP18_NF_IO0,
|
|
|
|
MPP19_NF_IO1,
|
|
|
|
MPP20_GPIO,
|
|
|
|
MPP21_GPIO,
|
|
|
|
MPP22_GPIO,
|
|
|
|
MPP23_GPIO,
|
|
|
|
MPP24_GPIO,
|
|
|
|
MPP25_GPIO,
|
|
|
|
MPP26_GPIO,
|
|
|
|
MPP27_GPIO,
|
|
|
|
MPP28_GPIO,
|
|
|
|
MPP29_GPIO,
|
|
|
|
MPP30_GPIO,
|
|
|
|
MPP31_GPIO,
|
|
|
|
MPP32_GPIO,
|
|
|
|
MPP33_GPIO,
|
|
|
|
MPP34_GPIO, /* CDL1 (input) */
|
|
|
|
MPP35_GPIO, /* CDL2 (input) */
|
|
|
|
MPP36_GPIO, /* MAIN_IRQ (input) */
|
|
|
|
MPP37_GPIO, /* BOARD_LED */
|
|
|
|
MPP38_GPIO, /* Piggy3 LED[1] */
|
|
|
|
MPP39_GPIO, /* Piggy3 LED[2] */
|
|
|
|
MPP40_GPIO, /* Piggy3 LED[3] */
|
|
|
|
MPP41_GPIO, /* Piggy3 LED[4] */
|
|
|
|
MPP42_GPIO, /* Piggy3 LED[5] */
|
|
|
|
MPP43_GPIO, /* Piggy3 LED[6] */
|
2011-02-22 08:13:00 +00:00
|
|
|
MPP44_GPIO, /* Piggy3 LED[7], BIST_EN_L */
|
2010-02-22 11:13:02 +00:00
|
|
|
MPP45_GPIO, /* Piggy3 LED[8] */
|
|
|
|
MPP46_GPIO, /* Reserved */
|
|
|
|
MPP47_GPIO, /* Reserved */
|
|
|
|
MPP48_GPIO, /* Reserved */
|
|
|
|
MPP49_GPIO, /* SW_INTOUTn */
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
2015-02-10 16:10:14 +00:00
|
|
|
static uchar ivm_content[CONFIG_SYS_IVM_EEPROM_MAX_LEN];
|
|
|
|
|
2012-07-05 05:05:03 +00:00
|
|
|
#if defined(CONFIG_KM_MGCOGE3UN)
|
2011-05-31 02:12:52 +00:00
|
|
|
/*
|
|
|
|
* Wait for startup OK from mgcoge3ne
|
|
|
|
*/
|
2014-01-27 15:58:23 +00:00
|
|
|
static int startup_allowed(void)
|
2011-05-31 02:12:52 +00:00
|
|
|
{
|
|
|
|
unsigned char buf;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read CIRQ16 bit (bit 0)
|
|
|
|
*/
|
|
|
|
if (i2c_read(BOCO, REG_IRQ_CIRQ2, 1, &buf, 1) != 0)
|
|
|
|
printf("%s: Error reading Boco\n", __func__);
|
|
|
|
else
|
|
|
|
if ((buf & MASK_RBI_DEFECT_16) == MASK_RBI_DEFECT_16)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
2011-06-16 12:41:15 +00:00
|
|
|
#endif
|
2011-05-31 02:12:52 +00:00
|
|
|
|
2012-07-05 05:05:03 +00:00
|
|
|
#if (defined(CONFIG_KM_PIGGY4_88E6061)|defined(CONFIG_KM_PIGGY4_88E6352))
|
2011-05-31 02:12:52 +00:00
|
|
|
/*
|
2012-07-05 05:37:46 +00:00
|
|
|
* All boards with PIGGY4 connected via a simple switch have ethernet always
|
|
|
|
* present.
|
2011-05-31 02:12:52 +00:00
|
|
|
*/
|
|
|
|
int ethernet_present(void)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#else
|
2010-02-22 11:13:02 +00:00
|
|
|
int ethernet_present(void)
|
|
|
|
{
|
|
|
|
uchar buf;
|
|
|
|
int ret = 0;
|
|
|
|
|
2011-05-31 02:12:52 +00:00
|
|
|
if (i2c_read(BOCO, REG_CTRL_H, 1, &buf, 1) != 0) {
|
2011-03-15 15:52:29 +00:00
|
|
|
printf("%s: Error reading Boco\n", __func__);
|
2010-02-22 11:13:02 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2011-05-31 02:12:52 +00:00
|
|
|
if ((buf & MASK_RBX_PGY_PRESENT) == MASK_RBX_PGY_PRESENT)
|
2010-02-22 11:13:02 +00:00
|
|
|
ret = 1;
|
2011-03-15 15:52:29 +00:00
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2011-05-31 02:12:52 +00:00
|
|
|
#endif
|
2010-02-22 11:13:02 +00:00
|
|
|
|
2013-05-06 13:04:51 +00:00
|
|
|
static int initialize_unit_leds(void)
|
2011-03-08 09:53:51 +00:00
|
|
|
{
|
|
|
|
/*
|
2011-05-31 02:12:52 +00:00
|
|
|
* Init the unit LEDs per default they all are
|
2011-03-08 09:53:51 +00:00
|
|
|
* ok apart from bootstat
|
|
|
|
*/
|
|
|
|
uchar buf;
|
|
|
|
|
2011-05-31 02:12:52 +00:00
|
|
|
if (i2c_read(BOCO, REG_CTRL_H, 1, &buf, 1) != 0) {
|
2011-03-08 09:53:51 +00:00
|
|
|
printf("%s: Error reading Boco\n", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
2011-05-31 02:12:52 +00:00
|
|
|
buf |= MASK_WRL_UNITRUN;
|
|
|
|
if (i2c_write(BOCO, REG_CTRL_H, 1, &buf, 1) != 0) {
|
2011-03-08 09:53:51 +00:00
|
|
|
printf("%s: Error writing Boco\n", __func__);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-05-06 13:04:51 +00:00
|
|
|
static void set_bootcount_addr(void)
|
2011-05-31 02:12:47 +00:00
|
|
|
{
|
|
|
|
uchar buf[32];
|
|
|
|
unsigned int bootcountaddr;
|
|
|
|
bootcountaddr = gd->ram_size - BOOTCOUNT_ADDR;
|
|
|
|
sprintf((char *)buf, "0x%x", bootcountaddr);
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("bootcountaddr", (char *)buf);
|
2011-05-31 02:12:47 +00:00
|
|
|
}
|
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
int misc_init_r(void)
|
|
|
|
{
|
2012-07-05 05:05:03 +00:00
|
|
|
#if defined(CONFIG_KM_MGCOGE3UN)
|
2011-05-31 02:12:52 +00:00
|
|
|
char *wait_for_ne;
|
2015-11-13 14:01:16 +00:00
|
|
|
u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
|
2017-08-03 18:22:12 +00:00
|
|
|
wait_for_ne = env_get("waitforne");
|
2015-11-13 14:01:16 +00:00
|
|
|
|
|
|
|
if ((wait_for_ne != NULL) && (dip_switch == 0)) {
|
2011-05-31 02:12:52 +00:00
|
|
|
if (strcmp(wait_for_ne, "true") == 0) {
|
|
|
|
int cnt = 0;
|
2011-09-27 02:54:31 +00:00
|
|
|
int abort = 0;
|
2011-05-31 02:12:52 +00:00
|
|
|
puts("NE go: ");
|
|
|
|
while (startup_allowed() == 0) {
|
2011-09-27 02:54:31 +00:00
|
|
|
if (tstc()) {
|
|
|
|
(void) getc(); /* consume input */
|
|
|
|
abort = 1;
|
|
|
|
break;
|
|
|
|
}
|
2011-05-31 02:12:52 +00:00
|
|
|
udelay(200000);
|
|
|
|
cnt++;
|
|
|
|
if (cnt == 5)
|
|
|
|
puts("wait\b\b\b\b");
|
|
|
|
if (cnt == 10) {
|
|
|
|
cnt = 0;
|
|
|
|
puts(" \b\b\b\b");
|
|
|
|
}
|
|
|
|
}
|
2011-09-27 02:54:31 +00:00
|
|
|
if (abort == 1)
|
|
|
|
printf("\nAbort waiting for ne\n");
|
|
|
|
else
|
|
|
|
puts("OK\n");
|
2011-05-31 02:12:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2011-03-08 09:53:51 +00:00
|
|
|
|
2015-02-10 16:10:18 +00:00
|
|
|
ivm_read_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
|
2015-02-10 16:10:14 +00:00
|
|
|
|
2011-03-08 09:53:51 +00:00
|
|
|
initialize_unit_leds();
|
2011-05-31 02:12:47 +00:00
|
|
|
set_km_env();
|
|
|
|
set_bootcount_addr();
|
2010-02-22 11:13:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-10-20 14:03:26 +00:00
|
|
|
int board_early_init_f(void)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
2013-01-29 07:53:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_SOFT)
|
2010-02-22 11:13:02 +00:00
|
|
|
u32 tmp;
|
|
|
|
|
2012-07-05 05:05:11 +00:00
|
|
|
/* set the 2 bitbang i2c pins as output gpios */
|
2014-10-22 10:13:11 +00:00
|
|
|
tmp = readl(MVEBU_GPIO0_BASE + 4);
|
|
|
|
writel(tmp & (~KM_KIRKWOOD_SOFT_I2C_GPIOS) , MVEBU_GPIO0_BASE + 4);
|
2012-07-05 05:05:11 +00:00
|
|
|
#endif
|
2012-07-25 06:26:03 +00:00
|
|
|
/* adjust SDRAM size for bank 0 */
|
2014-10-22 10:13:13 +00:00
|
|
|
mvebu_sdram_size_adjust(0);
|
2012-06-01 01:31:00 +00:00
|
|
|
kirkwood_mpp_conf(kwmpp_config, NULL);
|
2012-07-05 05:05:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-02-22 11:13:02 +00:00
|
|
|
|
2012-07-05 05:05:11 +00:00
|
|
|
int board_init(void)
|
|
|
|
{
|
|
|
|
/* address of boot parameters */
|
2014-10-22 10:13:13 +00:00
|
|
|
gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100;
|
2012-07-05 05:05:11 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The KM_FLASH_GPIO_PIN switches between using a
|
2010-02-22 11:13:02 +00:00
|
|
|
* NAND or a SPI FLASH. Set this pin on start
|
|
|
|
* to NAND mode.
|
|
|
|
*/
|
2012-07-05 05:05:11 +00:00
|
|
|
kw_gpio_set_valid(KM_FLASH_GPIO_PIN, 1);
|
|
|
|
kw_gpio_direction_output(KM_FLASH_GPIO_PIN, 1);
|
2010-02-22 11:13:02 +00:00
|
|
|
|
2013-01-29 07:53:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_SOFT)
|
2012-07-05 05:05:11 +00:00
|
|
|
/*
|
|
|
|
* Reinit the GPIO for I2C Bitbang driver so that the now
|
|
|
|
* available gpio framework is consistent. The calls to
|
|
|
|
* direction output in are not necessary, they are already done in
|
|
|
|
* board_early_init_f
|
|
|
|
*/
|
2011-02-22 08:13:00 +00:00
|
|
|
kw_gpio_set_valid(KM_KIRKWOOD_SDA_PIN, 1);
|
|
|
|
kw_gpio_set_valid(KM_KIRKWOOD_SCL_PIN, 1);
|
2010-02-22 11:13:02 +00:00
|
|
|
#endif
|
2012-07-05 05:05:11 +00:00
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
#if defined(CONFIG_SYS_EEPROM_WREN)
|
2011-02-22 08:13:00 +00:00
|
|
|
kw_gpio_set_valid(KM_KIRKWOOD_ENV_WP, 38);
|
|
|
|
kw_gpio_direction_output(KM_KIRKWOOD_ENV_WP, 1);
|
2011-09-13 22:41:05 +00:00
|
|
|
#endif
|
2010-10-20 14:03:26 +00:00
|
|
|
|
2012-07-05 05:05:05 +00:00
|
|
|
#if defined(CONFIG_KM_FPGA_CONFIG)
|
|
|
|
trigger_fpga_config();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int board_late_init(void)
|
|
|
|
{
|
2015-11-13 14:01:17 +00:00
|
|
|
#if (defined(CONFIG_KM_COGE5UN) | defined(CONFIG_KM_MGCOGE3UN))
|
2012-07-05 05:05:10 +00:00
|
|
|
u8 dip_switch = kw_gpio_get_value(KM_FLASH_ERASE_ENABLE);
|
|
|
|
|
|
|
|
/* if pin 1 do full erase */
|
|
|
|
if (dip_switch != 0) {
|
|
|
|
/* start bootloader */
|
|
|
|
puts("DIP: Enabled\n");
|
2017-08-03 18:22:09 +00:00
|
|
|
env_set("actual_bank", "0");
|
2012-07-05 05:05:10 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-07-05 05:05:05 +00:00
|
|
|
#if defined(CONFIG_KM_FPGA_CONFIG)
|
|
|
|
wait_for_fpga_config();
|
|
|
|
fpga_reset();
|
|
|
|
toggle_eeprom_spi_bus();
|
|
|
|
#endif
|
2010-02-22 11:13:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-06-18 06:41:02 +00:00
|
|
|
static const u32 spi_mpp_config[] = {
|
|
|
|
MPP1_SPI_MOSI,
|
|
|
|
MPP2_SPI_SCK,
|
|
|
|
MPP3_SPI_MISO,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
static u32 spi_mpp_backup[4];
|
|
|
|
|
|
|
|
int mvebu_board_spi_claim_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
spi_mpp_backup[3] = 0;
|
|
|
|
|
|
|
|
/* set new spi mpp config and save current one */
|
|
|
|
kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
|
|
|
|
|
|
|
|
kw_gpio_set_value(KM_FLASH_GPIO_PIN, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mvebu_board_spi_release_bus(struct udevice *dev)
|
|
|
|
{
|
|
|
|
/* restore saved mpp config */
|
|
|
|
kirkwood_mpp_conf(spi_mpp_backup, NULL);
|
|
|
|
|
|
|
|
kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-07-05 05:05:04 +00:00
|
|
|
#if (defined(CONFIG_KM_PIGGY4_88E6061))
|
2011-06-16 12:41:15 +00:00
|
|
|
|
2012-07-05 05:05:07 +00:00
|
|
|
#define PHY_LED_SEL_REG 0x18
|
|
|
|
#define PHY_LED0_LINK (0x5)
|
|
|
|
#define PHY_LED1_ACT (0x8<<4)
|
|
|
|
#define PHY_LED2_INT (0xe<<8)
|
|
|
|
#define PHY_SPEC_CTRL_REG 0x1c
|
2011-06-16 12:41:15 +00:00
|
|
|
#define PHY_RGMII_CLK_STABLE (0x1<<10)
|
2012-07-05 05:05:07 +00:00
|
|
|
#define PHY_CLSA (0x1<<1)
|
2011-06-16 12:41:15 +00:00
|
|
|
|
|
|
|
/* Configure and enable MV88E3018 PHY */
|
|
|
|
void reset_phy(void)
|
|
|
|
{
|
|
|
|
char *name = "egiga0";
|
|
|
|
unsigned short reg;
|
|
|
|
|
|
|
|
if (miiphy_set_current_dev(name))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* RGMII clk transition on data stable */
|
2014-01-27 15:58:26 +00:00
|
|
|
if (miiphy_read(name, CONFIG_PHY_BASE_ADR, PHY_SPEC_CTRL_REG, ®))
|
2011-06-16 12:41:15 +00:00
|
|
|
printf("Error reading PHY spec ctrl reg\n");
|
2014-01-27 15:58:26 +00:00
|
|
|
if (miiphy_write(name, CONFIG_PHY_BASE_ADR, PHY_SPEC_CTRL_REG,
|
|
|
|
reg | PHY_RGMII_CLK_STABLE | PHY_CLSA))
|
2011-06-16 12:41:15 +00:00
|
|
|
printf("Error writing PHY spec ctrl reg\n");
|
|
|
|
|
|
|
|
/* leds setup */
|
2014-01-27 15:58:26 +00:00
|
|
|
if (miiphy_write(name, CONFIG_PHY_BASE_ADR, PHY_LED_SEL_REG,
|
|
|
|
PHY_LED0_LINK | PHY_LED1_ACT | PHY_LED2_INT))
|
2011-06-16 12:41:15 +00:00
|
|
|
printf("Error writing PHY LED reg\n");
|
|
|
|
|
|
|
|
/* reset the phy */
|
|
|
|
miiphy_reset(name, CONFIG_PHY_BASE_ADR);
|
|
|
|
}
|
2012-08-16 23:35:03 +00:00
|
|
|
#elif defined(CONFIG_KM_PIGGY4_88E6352)
|
|
|
|
|
|
|
|
#include <mv88e6352.h>
|
|
|
|
|
|
|
|
#if defined(CONFIG_KM_NUSA)
|
|
|
|
struct mv88e_sw_reg extsw_conf[] = {
|
|
|
|
/*
|
2013-10-07 11:07:26 +00:00
|
|
|
* port 0, PIGGY4, autoneg
|
2012-08-16 23:35:03 +00:00
|
|
|
* first the fix for the 1000Mbits Autoneg, this is from
|
|
|
|
* a Marvell errata, the regs are undocumented
|
|
|
|
*/
|
|
|
|
{ PHY(0), PHY_PAGE, AN1000FIX_PAGE },
|
|
|
|
{ PHY(0), PHY_STATUS, AN1000FIX },
|
|
|
|
{ PHY(0), PHY_PAGE, 0 },
|
|
|
|
/* now the real port and phy configuration */
|
|
|
|
{ PORT(0), PORT_PHY, NO_SPEED_FOR },
|
|
|
|
{ PORT(0), PORT_CTRL, FORWARDING | EGRS_FLD_ALL },
|
|
|
|
{ PHY(0), PHY_1000_CTRL, NO_ADV },
|
|
|
|
{ PHY(0), PHY_SPEC_CTRL, AUTO_MDIX_EN },
|
|
|
|
{ PHY(0), PHY_CTRL, PHY_100_MBPS | AUTONEG_EN | AUTONEG_RST |
|
|
|
|
FULL_DUPLEX },
|
|
|
|
/* port 1, unused */
|
|
|
|
{ PORT(1), PORT_CTRL, PORT_DIS },
|
|
|
|
{ PHY(1), PHY_CTRL, PHY_PWR_DOWN },
|
|
|
|
{ PHY(1), PHY_SPEC_CTRL, SPEC_PWR_DOWN },
|
|
|
|
/* port 2, unused */
|
|
|
|
{ PORT(2), PORT_CTRL, PORT_DIS },
|
|
|
|
{ PHY(2), PHY_CTRL, PHY_PWR_DOWN },
|
|
|
|
{ PHY(2), PHY_SPEC_CTRL, SPEC_PWR_DOWN },
|
|
|
|
/* port 3, unused */
|
|
|
|
{ PORT(3), PORT_CTRL, PORT_DIS },
|
|
|
|
{ PHY(3), PHY_CTRL, PHY_PWR_DOWN },
|
|
|
|
{ PHY(3), PHY_SPEC_CTRL, SPEC_PWR_DOWN },
|
|
|
|
/* port 4, ICNEV, SerDes, SGMII */
|
|
|
|
{ PORT(4), PORT_STATUS, NO_PHY_DETECT },
|
|
|
|
{ PORT(4), PORT_PHY, SPEED_1000_FOR },
|
|
|
|
{ PORT(4), PORT_CTRL, FORWARDING | EGRS_FLD_ALL },
|
|
|
|
{ PHY(4), PHY_CTRL, PHY_PWR_DOWN },
|
|
|
|
{ PHY(4), PHY_SPEC_CTRL, SPEC_PWR_DOWN },
|
|
|
|
/* port 5, CPU_RGMII */
|
|
|
|
{ PORT(5), PORT_PHY, RX_RGMII_TIM | TX_RGMII_TIM | FLOW_CTRL_EN |
|
|
|
|
FLOW_CTRL_FOR | LINK_VAL | LINK_FOR | FULL_DPX |
|
|
|
|
FULL_DPX_FOR | SPEED_1000_FOR },
|
|
|
|
{ PORT(5), PORT_CTRL, FORWARDING | EGRS_FLD_ALL },
|
|
|
|
/* port 6, unused, this port has no phy */
|
|
|
|
{ PORT(6), PORT_CTRL, PORT_DIS },
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
struct mv88e_sw_reg extsw_conf[] = {};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void reset_phy(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_KM_MVEXTSW_ADDR)
|
|
|
|
char *name = "egiga0";
|
|
|
|
|
|
|
|
if (miiphy_set_current_dev(name))
|
|
|
|
return;
|
|
|
|
|
|
|
|
mv88e_sw_program(name, CONFIG_KM_MVEXTSW_ADDR, extsw_conf,
|
|
|
|
ARRAY_SIZE(extsw_conf));
|
|
|
|
mv88e_sw_reset(name, CONFIG_KM_MVEXTSW_ADDR);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-06-16 12:41:15 +00:00
|
|
|
#else
|
|
|
|
/* Configure and enable MV88E1118 PHY on the piggy*/
|
2010-02-22 11:13:02 +00:00
|
|
|
void reset_phy(void)
|
|
|
|
{
|
2015-11-13 14:01:15 +00:00
|
|
|
unsigned int oui;
|
|
|
|
unsigned char model, rev;
|
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
char *name = "egiga0";
|
|
|
|
|
|
|
|
if (miiphy_set_current_dev(name))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* reset the phy */
|
|
|
|
miiphy_reset(name, CONFIG_PHY_BASE_ADR);
|
2015-11-13 14:01:15 +00:00
|
|
|
|
|
|
|
/* get PHY model */
|
|
|
|
if (miiphy_info(name, CONFIG_PHY_BASE_ADR, &oui, &model, &rev))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* check for Marvell 88E1118R Gigabit PHY (PIGGY3) */
|
|
|
|
if ((oui == PHY_MARVELL_OUI) &&
|
|
|
|
(model == PHY_MARVELL_88E1118R_MODEL)) {
|
|
|
|
/* set page register to 3 */
|
|
|
|
if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
|
|
|
|
PHY_MARVELL_PAGE_REG,
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_PAGE))
|
|
|
|
printf("Error writing PHY page reg\n");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* leds setup as printed on PCB:
|
|
|
|
* LED2 (Link): 0x0 (On Link, Off No Link)
|
|
|
|
* LED1 (Activity): 0x3 (On Activity, Off No Activity)
|
|
|
|
* LED0 (Speed): 0x7 (On 1000 MBits, Off Else)
|
|
|
|
*/
|
|
|
|
if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_REG,
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_RESERVED |
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_LED0_1000MB |
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_LED1_ACT |
|
|
|
|
PHY_MARVELL_88E1118R_LED_CTRL_LED2_LINK))
|
|
|
|
printf("Error writing PHY LED reg\n");
|
|
|
|
|
|
|
|
/* set page register back to 0 */
|
|
|
|
if (miiphy_write(name, CONFIG_PHY_BASE_ADR,
|
|
|
|
PHY_MARVELL_PAGE_REG,
|
|
|
|
PHY_MARVELL_DEFAULT_PAGE))
|
|
|
|
printf("Error writing PHY page reg\n");
|
|
|
|
}
|
2010-02-22 11:13:02 +00:00
|
|
|
}
|
2011-06-16 12:41:15 +00:00
|
|
|
#endif
|
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_HUSH_INIT_VAR)
|
2011-03-15 15:52:29 +00:00
|
|
|
int hush_init_var(void)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
2015-02-10 16:10:14 +00:00
|
|
|
ivm_analyze_eeprom(ivm_content, CONFIG_SYS_IVM_EEPROM_MAX_LEN);
|
2010-02-22 11:13:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-01-29 07:53:15 +00:00
|
|
|
#if defined(CONFIG_SYS_I2C_SOFT)
|
2011-03-15 15:52:29 +00:00
|
|
|
void set_sda(int state)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
|
|
|
I2C_ACTIVE;
|
|
|
|
I2C_SDA(state);
|
|
|
|
}
|
|
|
|
|
2011-03-15 15:52:29 +00:00
|
|
|
void set_scl(int state)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
|
|
|
I2C_SCL(state);
|
|
|
|
}
|
|
|
|
|
2011-03-15 15:52:29 +00:00
|
|
|
int get_sda(void)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
|
|
|
I2C_TRISTATE;
|
|
|
|
return I2C_READ;
|
|
|
|
}
|
|
|
|
|
2011-03-15 15:52:29 +00:00
|
|
|
int get_scl(void)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
2011-02-22 08:13:00 +00:00
|
|
|
return kw_gpio_get_value(KM_KIRKWOOD_SCL_PIN) ? 1 : 0;
|
2010-02-22 11:13:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-09-12 04:18:42 +00:00
|
|
|
#if defined(CONFIG_POST)
|
|
|
|
|
|
|
|
#define KM_POST_EN_L 44
|
|
|
|
#define POST_WORD_OFF 8
|
|
|
|
|
|
|
|
int post_hotkeys_pressed(void)
|
|
|
|
{
|
2012-07-05 05:05:02 +00:00
|
|
|
#if defined(CONFIG_KM_COGE5UN)
|
|
|
|
return kw_gpio_get_value(KM_POST_EN_L);
|
|
|
|
#else
|
2011-09-12 04:18:42 +00:00
|
|
|
return !kw_gpio_get_value(KM_POST_EN_L);
|
2012-07-05 05:05:02 +00:00
|
|
|
#endif
|
2011-09-12 04:18:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ulong post_word_load(void)
|
|
|
|
{
|
2011-12-14 05:31:20 +00:00
|
|
|
void* addr = (void *) (gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF);
|
2011-09-12 04:18:42 +00:00
|
|
|
return in_le32(addr);
|
|
|
|
|
|
|
|
}
|
|
|
|
void post_word_store(ulong value)
|
|
|
|
{
|
2011-12-14 05:31:20 +00:00
|
|
|
void* addr = (void *) (gd->ram_size - BOOTCOUNT_ADDR + POST_WORD_OFF);
|
2011-09-12 04:18:42 +00:00
|
|
|
out_le32(addr, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int arch_memory_test_prepare(u32 *vstart, u32 *size, phys_addr_t *phys_offset)
|
|
|
|
{
|
|
|
|
*vstart = CONFIG_SYS_SDRAM_BASE;
|
|
|
|
|
|
|
|
/* we go up to relocation plus a 1 MB margin */
|
|
|
|
*size = CONFIG_SYS_TEXT_BASE - (1<<20);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-22 11:13:02 +00:00
|
|
|
#if defined(CONFIG_SYS_EEPROM_WREN)
|
2011-03-15 15:52:29 +00:00
|
|
|
int eeprom_write_enable(unsigned dev_addr, int state)
|
2010-02-22 11:13:02 +00:00
|
|
|
{
|
2011-02-22 08:13:00 +00:00
|
|
|
kw_gpio_set_value(KM_KIRKWOOD_ENV_WP, !state);
|
2010-02-22 11:13:02 +00:00
|
|
|
|
2011-02-22 08:13:00 +00:00
|
|
|
return !kw_gpio_get_value(KM_KIRKWOOD_ENV_WP);
|
2010-02-22 11:13:02 +00:00
|
|
|
}
|
|
|
|
#endif
|