10ad6c34cSSuriyan Ramasami /* 20ad6c34cSSuriyan Ramasami * Copyright (C) 2013 Suriyan Ramasami <suriyan.r@gmail.com> 30ad6c34cSSuriyan Ramasami * 40ad6c34cSSuriyan Ramasami * Based on dockstar.c originally written by 50ad6c34cSSuriyan Ramasami * Copyright (C) 2010 Eric C. Cooper <ecc@cmu.edu> 60ad6c34cSSuriyan Ramasami * 70ad6c34cSSuriyan Ramasami * Based on sheevaplug.c originally written by 80ad6c34cSSuriyan Ramasami * Prafulla Wadaskar <prafulla@marvell.com> 90ad6c34cSSuriyan Ramasami * (C) Copyright 2009 100ad6c34cSSuriyan Ramasami * Marvell Semiconductor <www.marvell.com> 110ad6c34cSSuriyan Ramasami * 121a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 130ad6c34cSSuriyan Ramasami */ 140ad6c34cSSuriyan Ramasami 150ad6c34cSSuriyan Ramasami #include <common.h> 160ad6c34cSSuriyan Ramasami #include <miiphy.h> 173dc23f78SStefan Roese #include <asm/arch/soc.h> 180ad6c34cSSuriyan Ramasami #include <asm/arch/mpp.h> 190ad6c34cSSuriyan Ramasami #include <asm/arch/cpu.h> 200ad6c34cSSuriyan Ramasami #include <asm/io.h> 210ad6c34cSSuriyan Ramasami 220ad6c34cSSuriyan Ramasami DECLARE_GLOBAL_DATA_PTR; 230ad6c34cSSuriyan Ramasami 240ad6c34cSSuriyan Ramasami int board_early_init_f(void) 250ad6c34cSSuriyan Ramasami { 260ad6c34cSSuriyan Ramasami /* Multi-Purpose Pins Functionality configuration */ 270ad6c34cSSuriyan Ramasami static const u32 kwmpp_config[] = { 280ad6c34cSSuriyan Ramasami MPP0_NF_IO2, 290ad6c34cSSuriyan Ramasami MPP1_NF_IO3, 300ad6c34cSSuriyan Ramasami MPP2_NF_IO4, 310ad6c34cSSuriyan Ramasami MPP3_NF_IO5, 320ad6c34cSSuriyan Ramasami MPP4_NF_IO6, 330ad6c34cSSuriyan Ramasami MPP5_NF_IO7, 340ad6c34cSSuriyan Ramasami MPP6_SYSRST_OUTn, 350ad6c34cSSuriyan Ramasami MPP7_GPO, 360ad6c34cSSuriyan Ramasami MPP8_UART0_RTS, 370ad6c34cSSuriyan Ramasami MPP9_UART0_CTS, 380ad6c34cSSuriyan Ramasami MPP10_UART0_TXD, 390ad6c34cSSuriyan Ramasami MPP11_UART0_RXD, 400ad6c34cSSuriyan Ramasami MPP12_SD_CLK, 410ad6c34cSSuriyan Ramasami MPP13_SD_CMD, 420ad6c34cSSuriyan Ramasami MPP14_SD_D0, 430ad6c34cSSuriyan Ramasami MPP15_SD_D1, 440ad6c34cSSuriyan Ramasami MPP16_SD_D2, 450ad6c34cSSuriyan Ramasami MPP17_SD_D3, 460ad6c34cSSuriyan Ramasami MPP18_NF_IO0, 470ad6c34cSSuriyan Ramasami MPP19_NF_IO1, 480ad6c34cSSuriyan Ramasami MPP20_GPIO, 490ad6c34cSSuriyan Ramasami MPP21_GPIO, 500ad6c34cSSuriyan Ramasami MPP22_GPIO, 510ad6c34cSSuriyan Ramasami MPP23_GPIO, 520ad6c34cSSuriyan Ramasami MPP24_GPIO, 530ad6c34cSSuriyan Ramasami MPP25_GPIO, 540ad6c34cSSuriyan Ramasami MPP26_GPIO, 550ad6c34cSSuriyan Ramasami MPP27_GPIO, 560ad6c34cSSuriyan Ramasami MPP28_GPIO, 570ad6c34cSSuriyan Ramasami MPP29_TSMP9, 580ad6c34cSSuriyan Ramasami MPP30_GPIO, 590ad6c34cSSuriyan Ramasami MPP31_GPIO, 600ad6c34cSSuriyan Ramasami MPP32_GPIO, 610ad6c34cSSuriyan Ramasami MPP33_GPIO, 620ad6c34cSSuriyan Ramasami MPP34_GPIO, 630ad6c34cSSuriyan Ramasami MPP35_GPIO, 640ad6c34cSSuriyan Ramasami MPP36_GPIO, 650ad6c34cSSuriyan Ramasami MPP37_GPIO, 660ad6c34cSSuriyan Ramasami MPP38_GPIO, 670ad6c34cSSuriyan Ramasami MPP39_GPIO, 680ad6c34cSSuriyan Ramasami MPP40_GPIO, 690ad6c34cSSuriyan Ramasami MPP41_GPIO, 700ad6c34cSSuriyan Ramasami MPP42_GPIO, 710ad6c34cSSuriyan Ramasami MPP43_GPIO, 720ad6c34cSSuriyan Ramasami MPP44_GPIO, 730ad6c34cSSuriyan Ramasami MPP45_GPIO, 740ad6c34cSSuriyan Ramasami MPP46_GPIO, 750ad6c34cSSuriyan Ramasami MPP47_GPIO, 760ad6c34cSSuriyan Ramasami MPP48_GPIO, 770ad6c34cSSuriyan Ramasami MPP49_GPIO, 780ad6c34cSSuriyan Ramasami 0 790ad6c34cSSuriyan Ramasami }; 800ad6c34cSSuriyan Ramasami 810ad6c34cSSuriyan Ramasami /* 820ad6c34cSSuriyan Ramasami * default gpio configuration 830ad6c34cSSuriyan Ramasami * There are maximum 64 gpios controlled through 2 sets of registers 840ad6c34cSSuriyan Ramasami * the below configuration configures mainly initial LED status 850ad6c34cSSuriyan Ramasami */ 86d5c5132fSStefan Roese mvebu_config_gpio(GOFLEXHOME_OE_VAL_LOW, 870ad6c34cSSuriyan Ramasami GOFLEXHOME_OE_VAL_HIGH, 880ad6c34cSSuriyan Ramasami GOFLEXHOME_OE_LOW, GOFLEXHOME_OE_HIGH); 890ad6c34cSSuriyan Ramasami kirkwood_mpp_conf(kwmpp_config, NULL); 900ad6c34cSSuriyan Ramasami return 0; 910ad6c34cSSuriyan Ramasami } 920ad6c34cSSuriyan Ramasami 930ad6c34cSSuriyan Ramasami int board_init(void) 940ad6c34cSSuriyan Ramasami { 95*94ba26f2STom Rini /* 96*94ba26f2STom Rini * arch number of board 97*94ba26f2STom Rini */ 98*94ba26f2STom Rini gd->bd->bi_arch_number = MACH_TYPE_GOFLEXHOME; 99*94ba26f2STom Rini 1000ad6c34cSSuriyan Ramasami /* address of boot parameters */ 10196c5f081SStefan Roese gd->bd->bi_boot_params = mvebu_sdram_bar(0) + 0x100; 1020ad6c34cSSuriyan Ramasami 1030ad6c34cSSuriyan Ramasami return 0; 1040ad6c34cSSuriyan Ramasami } 1050ad6c34cSSuriyan Ramasami 1060ad6c34cSSuriyan Ramasami #ifdef CONFIG_RESET_PHY_R 1070ad6c34cSSuriyan Ramasami /* Configure and enable MV88E1116 PHY */ 1080ad6c34cSSuriyan Ramasami void reset_phy(void) 1090ad6c34cSSuriyan Ramasami { 1100ad6c34cSSuriyan Ramasami u16 reg; 1110ad6c34cSSuriyan Ramasami u16 devadr; 1120ad6c34cSSuriyan Ramasami char *name = "egiga0"; 1130ad6c34cSSuriyan Ramasami 1140ad6c34cSSuriyan Ramasami if (miiphy_set_current_dev(name)) 1150ad6c34cSSuriyan Ramasami return; 1160ad6c34cSSuriyan Ramasami 1170ad6c34cSSuriyan Ramasami /* command to read PHY dev address */ 1180ad6c34cSSuriyan Ramasami if (miiphy_read(name, 0xEE, 0xEE, (u16 *)&devadr)) { 1190ad6c34cSSuriyan Ramasami printf("Err..%s could not read PHY dev address\n", 1200ad6c34cSSuriyan Ramasami __func__); 1210ad6c34cSSuriyan Ramasami return; 1220ad6c34cSSuriyan Ramasami } 1230ad6c34cSSuriyan Ramasami 1240ad6c34cSSuriyan Ramasami /* 1250ad6c34cSSuriyan Ramasami * Enable RGMII delay on Tx and Rx for CPU port 1260ad6c34cSSuriyan Ramasami * Ref: sec 4.7.2 of chip datasheet 1270ad6c34cSSuriyan Ramasami */ 1280ad6c34cSSuriyan Ramasami miiphy_write(name, devadr, MV88E1116_PGADR_REG, 2); 1290ad6c34cSSuriyan Ramasami miiphy_read(name, devadr, MV88E1116_MAC_CTRL_REG, ®); 1300ad6c34cSSuriyan Ramasami reg |= (MV88E1116_RGMII_RXTM_CTRL | MV88E1116_RGMII_TXTM_CTRL); 1310ad6c34cSSuriyan Ramasami miiphy_write(name, devadr, MV88E1116_MAC_CTRL_REG, reg); 1320ad6c34cSSuriyan Ramasami miiphy_write(name, devadr, MV88E1116_PGADR_REG, 0); 1330ad6c34cSSuriyan Ramasami 1340ad6c34cSSuriyan Ramasami /* reset the phy */ 1350ad6c34cSSuriyan Ramasami miiphy_reset(name, devadr); 1360ad6c34cSSuriyan Ramasami 1370ad6c34cSSuriyan Ramasami printf("88E1116 Initialized on %s\n", name); 1380ad6c34cSSuriyan Ramasami } 1390ad6c34cSSuriyan Ramasami #endif /* CONFIG_RESET_PHY_R */ 1400ad6c34cSSuriyan Ramasami 1410ad6c34cSSuriyan Ramasami #define GREEN_LED (1 << 14) 1420ad6c34cSSuriyan Ramasami #define ORANGE_LED (1 << 15) 1430ad6c34cSSuriyan Ramasami #define BOTH_LEDS (GREEN_LED | ORANGE_LED) 1440ad6c34cSSuriyan Ramasami #define NEITHER_LED 0 1450ad6c34cSSuriyan Ramasami 1460ad6c34cSSuriyan Ramasami static void set_leds(u32 leds, u32 blinking) 1470ad6c34cSSuriyan Ramasami { 1480ad6c34cSSuriyan Ramasami struct kwgpio_registers *r; 1490ad6c34cSSuriyan Ramasami u32 oe; 1500ad6c34cSSuriyan Ramasami u32 bl; 1510ad6c34cSSuriyan Ramasami 152d5c5132fSStefan Roese r = (struct kwgpio_registers *)MVEBU_GPIO1_BASE; 1530ad6c34cSSuriyan Ramasami oe = readl(&r->oe) | BOTH_LEDS; 1540ad6c34cSSuriyan Ramasami writel(oe & ~leds, &r->oe); /* active low */ 1550ad6c34cSSuriyan Ramasami bl = readl(&r->blink_en) & ~BOTH_LEDS; 1560ad6c34cSSuriyan Ramasami writel(bl | blinking, &r->blink_en); 1570ad6c34cSSuriyan Ramasami } 1580ad6c34cSSuriyan Ramasami 1590ad6c34cSSuriyan Ramasami void show_boot_progress(int val) 1600ad6c34cSSuriyan Ramasami { 1610ad6c34cSSuriyan Ramasami switch (val) { 1620ad6c34cSSuriyan Ramasami case BOOTSTAGE_ID_RUN_OS: /* booting Linux */ 1630ad6c34cSSuriyan Ramasami set_leds(BOTH_LEDS, NEITHER_LED); 1640ad6c34cSSuriyan Ramasami break; 1650ad6c34cSSuriyan Ramasami case BOOTSTAGE_ID_NET_ETH_START: /* Ethernet initialization */ 1660ad6c34cSSuriyan Ramasami set_leds(GREEN_LED, GREEN_LED); 1670ad6c34cSSuriyan Ramasami break; 1680ad6c34cSSuriyan Ramasami default: 1690ad6c34cSSuriyan Ramasami if (val < 0) /* error */ 1700ad6c34cSSuriyan Ramasami set_leds(ORANGE_LED, ORANGE_LED); 1710ad6c34cSSuriyan Ramasami break; 1720ad6c34cSSuriyan Ramasami } 1730ad6c34cSSuriyan Ramasami } 174