2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2013-09-11 16:24:48 +00:00
|
|
|
/*
|
2017-04-25 18:44:35 +00:00
|
|
|
* Copyright (C) 2013-2017 Altera Corporation <www.altera.com>
|
2013-09-11 16:24:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/system_manager.h>
|
2014-09-08 12:08:45 +00:00
|
|
|
#include <asm/arch/fpga_manager.h>
|
2013-09-11 16:24:48 +00:00
|
|
|
|
2014-09-08 12:08:45 +00:00
|
|
|
/*
|
|
|
|
* Populate the value for SYSMGR.FPGAINTF.MODULE based on pinmux setting.
|
|
|
|
* The value is not wrote to SYSMGR.FPGAINTF.MODULE but
|
|
|
|
* CONFIG_SYSMGR_ISWGRP_HANDOFF.
|
|
|
|
*/
|
|
|
|
static void populate_sysmgr_fpgaintf_module(void)
|
|
|
|
{
|
2017-04-25 18:44:35 +00:00
|
|
|
u32 handoff_val = 0;
|
2014-09-08 12:08:45 +00:00
|
|
|
|
|
|
|
/* ISWGRP_HANDOFF_FPGAINTF */
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(0, socfpga_get_sysmgr_addr() + SYSMGR_ISWGRP_HANDOFF_OFFSET(2));
|
2014-09-08 12:08:45 +00:00
|
|
|
|
|
|
|
/* Enable the signal for those HPS peripherals that use FPGA. */
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_NAND_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_NAND;
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_RGMII1_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_EMAC1;
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_SDMMC_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SDMMC;
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_RGMII0_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_EMAC0;
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_SPIM0_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SPIM0;
|
2019-11-08 02:38:20 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_GEN5_SPIM1_USEFPGA) ==
|
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2014-09-08 12:08:45 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SPIM1;
|
|
|
|
|
|
|
|
/* populate (not writing) the value for SYSMGR.FPGAINTF.MODULE
|
|
|
|
based on pinmux setting */
|
2019-11-08 02:38:20 +00:00
|
|
|
setbits_le32(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_ISWGRP_HANDOFF_OFFSET(2),
|
|
|
|
handoff_val);
|
2014-09-08 12:08:45 +00:00
|
|
|
|
2019-11-08 02:38:20 +00:00
|
|
|
handoff_val = readl(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_ISWGRP_HANDOFF_OFFSET(2));
|
2014-09-08 12:08:45 +00:00
|
|
|
if (fpgamgr_test_fpga_ready()) {
|
|
|
|
/* Enable the required signals only */
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(handoff_val,
|
|
|
|
socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_GEN5_FPGAINFGRP_MODULE);
|
2014-09-08 12:08:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-11 16:24:48 +00:00
|
|
|
/*
|
|
|
|
* Configure all the pin muxes
|
|
|
|
*/
|
|
|
|
void sysmgr_pinmux_init(void)
|
|
|
|
{
|
2019-11-08 02:38:20 +00:00
|
|
|
u32 regs = (u32)socfpga_get_sysmgr_addr() + SYSMGR_GEN5_EMACIO;
|
2015-08-10 20:17:46 +00:00
|
|
|
const u8 *sys_mgr_init_table;
|
2015-07-25 09:09:11 +00:00
|
|
|
unsigned int len;
|
2014-09-08 12:08:45 +00:00
|
|
|
int i;
|
2013-09-11 16:24:48 +00:00
|
|
|
|
2015-07-25 09:09:11 +00:00
|
|
|
sysmgr_get_pinmux_table(&sys_mgr_init_table, &len);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
2014-09-08 12:08:45 +00:00
|
|
|
writel(sys_mgr_init_table[i], regs);
|
|
|
|
regs += sizeof(regs);
|
2013-09-11 16:24:48 +00:00
|
|
|
}
|
2014-09-08 12:08:45 +00:00
|
|
|
|
|
|
|
populate_sysmgr_fpgaintf_module();
|
2013-09-11 16:24:48 +00:00
|
|
|
}
|
2015-03-30 22:01:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This bit allows the bootrom to configure the IOs after a warm reset.
|
|
|
|
*/
|
2015-07-09 02:40:11 +00:00
|
|
|
void sysmgr_config_warmrstcfgio(int enable)
|
2015-03-30 22:01:07 +00:00
|
|
|
{
|
2015-07-09 02:40:11 +00:00
|
|
|
if (enable)
|
2019-11-08 02:38:20 +00:00
|
|
|
setbits_le32(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_GEN5_ROMCODEGRP_CTRL,
|
2015-07-09 02:40:11 +00:00
|
|
|
SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
|
|
|
|
else
|
2019-11-08 02:38:20 +00:00
|
|
|
clrbits_le32(socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_GEN5_ROMCODEGRP_CTRL,
|
2015-07-09 02:40:11 +00:00
|
|
|
SYSMGR_ROMCODEGRP_CTRL_WARMRSTCFGIO);
|
2015-03-30 22:01:07 +00:00
|
|
|
}
|