2018-05-18 14:05:24 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/system_manager.h>
|
|
|
|
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure all the pin muxes
|
|
|
|
*/
|
|
|
|
void sysmgr_pinmux_init(void)
|
|
|
|
{
|
|
|
|
populate_sysmgr_pinmux();
|
|
|
|
populate_sysmgr_fpgaintf_module();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
void populate_sysmgr_fpgaintf_module(void)
|
|
|
|
{
|
|
|
|
u32 handoff_val = 0;
|
|
|
|
|
|
|
|
/* Enable the signal for those HPS peripherals that use FPGA. */
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_NAND_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_NAND;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_SDMMC_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SDMMC;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_SPIM0_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SPIM0;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_SPIM1_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_SPIM1;
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(handoff_val,
|
2019-11-27 07:55:18 +00:00
|
|
|
socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGAINTF_EN2);
|
2018-05-18 14:05:24 +00:00
|
|
|
|
|
|
|
handoff_val = 0;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_EMAC0_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_EMAC0;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_EMAC1_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_EMAC1;
|
2019-11-27 07:55:18 +00:00
|
|
|
if (readl(socfpga_get_sysmgr_addr() + SYSMGR_SOC64_EMAC2_USEFPGA) ==
|
2019-11-08 02:38:20 +00:00
|
|
|
SYSMGR_FPGAINTF_USEFPGA)
|
2018-05-18 14:05:24 +00:00
|
|
|
handoff_val |= SYSMGR_FPGAINTF_EMAC2;
|
2019-11-08 02:38:20 +00:00
|
|
|
writel(handoff_val,
|
2019-11-27 07:55:18 +00:00
|
|
|
socfpga_get_sysmgr_addr() + SYSMGR_SOC64_FPGAINTF_EN3);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Configure all the pin muxes
|
|
|
|
*/
|
|
|
|
void populate_sysmgr_pinmux(void)
|
|
|
|
{
|
|
|
|
const u32 *sys_mgr_table_u32;
|
|
|
|
unsigned int len, i;
|
|
|
|
|
|
|
|
/* setup the pin sel */
|
|
|
|
sysmgr_pinmux_table_sel(&sys_mgr_table_u32, &len);
|
|
|
|
for (i = 0; i < len; i = i + 2) {
|
|
|
|
writel(sys_mgr_table_u32[i + 1],
|
2019-11-08 02:38:20 +00:00
|
|
|
sys_mgr_table_u32[i] +
|
2019-11-27 07:55:18 +00:00
|
|
|
(u8 *)socfpga_get_sysmgr_addr() + SYSMGR_SOC64_PINSEL0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the pin ctrl */
|
|
|
|
sysmgr_pinmux_table_ctrl(&sys_mgr_table_u32, &len);
|
|
|
|
for (i = 0; i < len; i = i + 2) {
|
|
|
|
writel(sys_mgr_table_u32[i + 1],
|
2019-11-08 02:38:20 +00:00
|
|
|
sys_mgr_table_u32[i] +
|
2019-11-27 07:55:18 +00:00
|
|
|
(u8 *)socfpga_get_sysmgr_addr() + SYSMGR_SOC64_IOCTRL0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the fpga use */
|
|
|
|
sysmgr_pinmux_table_fpga(&sys_mgr_table_u32, &len);
|
|
|
|
for (i = 0; i < len; i = i + 2) {
|
|
|
|
writel(sys_mgr_table_u32[i + 1],
|
|
|
|
sys_mgr_table_u32[i] +
|
2019-11-08 02:38:20 +00:00
|
|
|
(u8 *)socfpga_get_sysmgr_addr() +
|
2019-11-27 07:55:18 +00:00
|
|
|
SYSMGR_SOC64_EMAC0_USEFPGA);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the IO delay */
|
|
|
|
sysmgr_pinmux_table_delay(&sys_mgr_table_u32, &len);
|
|
|
|
for (i = 0; i < len; i = i + 2) {
|
|
|
|
writel(sys_mgr_table_u32[i + 1],
|
2019-11-08 02:38:20 +00:00
|
|
|
sys_mgr_table_u32[i] +
|
2019-11-27 07:55:18 +00:00
|
|
|
(u8 *)socfpga_get_sysmgr_addr() + SYSMGR_SOC64_IODELAY0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
}
|