2018-05-18 14:05:24 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2016-2018 Intel Corporation <www.intel.com>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-03-24 05:11:38 +00:00
|
|
|
#include <asm/arch/handoff_soc64.h>
|
|
|
|
#include <asm/arch/system_manager.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <asm/global_data.h>
|
2018-05-18 14:05:24 +00:00
|
|
|
#include <asm/io.h>
|
2021-03-24 05:11:38 +00:00
|
|
|
#include <common.h>
|
2018-05-18 14:05:24 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2021-03-24 05:11:38 +00:00
|
|
|
u32 len, i;
|
|
|
|
u32 len_mux = socfpga_get_handoff_size((void *)SOC64_HANDOFF_MUX, BIG_ENDIAN);
|
|
|
|
u32 len_ioctl = socfpga_get_handoff_size((void *)SOC64_HANDOFF_IOCTL, BIG_ENDIAN);
|
|
|
|
u32 len_fpga = socfpga_get_handoff_size((void *)SOC64_HANDOFF_FPGA, BIG_ENDIAN);
|
|
|
|
u32 len_delay = socfpga_get_handoff_size((void *)SOC64_HANDOFF_DELAY, BIG_ENDIAN);
|
|
|
|
|
|
|
|
len = (len_mux > len_ioctl) ? len_mux : len_ioctl;
|
|
|
|
len = (len > len_fpga) ? len : len_fpga;
|
|
|
|
len = (len > len_delay) ? len : len_delay;
|
|
|
|
|
|
|
|
u32 handoff_table[len];
|
2018-05-18 14:05:24 +00:00
|
|
|
|
|
|
|
/* setup the pin sel */
|
2021-03-24 05:11:38 +00:00
|
|
|
len = (len_mux < SOC64_HANDOFF_MUX_LEN) ? len_mux : SOC64_HANDOFF_MUX_LEN;
|
|
|
|
socfpga_handoff_read((void *)SOC64_HANDOFF_MUX, handoff_table, len, BIG_ENDIAN);
|
2018-05-18 14:05:24 +00:00
|
|
|
for (i = 0; i < len; i = i + 2) {
|
2021-03-24 05:11:38 +00:00
|
|
|
writel(handoff_table[i + 1],
|
|
|
|
handoff_table[i] +
|
|
|
|
(u8 *)socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_SOC64_PINSEL0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the pin ctrl */
|
2021-03-24 05:11:38 +00:00
|
|
|
len = (len_ioctl < SOC64_HANDOFF_IOCTL_LEN) ? len_ioctl : SOC64_HANDOFF_IOCTL_LEN;
|
|
|
|
socfpga_handoff_read((void *)SOC64_HANDOFF_IOCTL, handoff_table, len, BIG_ENDIAN);
|
2018-05-18 14:05:24 +00:00
|
|
|
for (i = 0; i < len; i = i + 2) {
|
2021-03-24 05:11:38 +00:00
|
|
|
writel(handoff_table[i + 1],
|
|
|
|
handoff_table[i] +
|
|
|
|
(u8 *)socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_SOC64_IOCTRL0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* setup the fpga use */
|
2021-03-24 05:11:38 +00:00
|
|
|
len = (len_fpga < SOC64_HANDOFF_FPGA_LEN) ? len_fpga : SOC64_HANDOFF_FPGA_LEN;
|
|
|
|
socfpga_handoff_read((void *)SOC64_HANDOFF_FPGA, handoff_table, len, BIG_ENDIAN);
|
2018-05-18 14:05:24 +00:00
|
|
|
for (i = 0; i < len; i = i + 2) {
|
2021-03-24 05:11:38 +00:00
|
|
|
writel(handoff_table[i + 1],
|
|
|
|
handoff_table[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 */
|
2021-03-24 05:11:38 +00:00
|
|
|
len = (len_delay < SOC64_HANDOFF_DELAY_LEN) ? len_delay : SOC64_HANDOFF_DELAY_LEN;
|
|
|
|
socfpga_handoff_read((void *)SOC64_HANDOFF_DELAY, handoff_table, len, BIG_ENDIAN);
|
2018-05-18 14:05:24 +00:00
|
|
|
for (i = 0; i < len; i = i + 2) {
|
2021-03-24 05:11:38 +00:00
|
|
|
writel(handoff_table[i + 1],
|
|
|
|
handoff_table[i] +
|
|
|
|
(u8 *)socfpga_get_sysmgr_addr() +
|
|
|
|
SYSMGR_SOC64_IODELAY0);
|
2018-05-18 14:05:24 +00:00
|
|
|
}
|
|
|
|
}
|