2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2014-04-04 17:16:53 +00:00
|
|
|
/*
|
|
|
|
* Keystone2: Architecture initialization
|
|
|
|
*
|
|
|
|
* (C) Copyright 2012-2014
|
|
|
|
* Texas Instruments Incorporated, <www.ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2020-05-10 17:40:02 +00:00
|
|
|
#include <init.h>
|
2014-05-29 15:57:12 +00:00
|
|
|
#include <ns16550.h>
|
2020-05-10 17:39:56 +00:00
|
|
|
#include <asm/cache.h>
|
2014-04-04 17:16:53 +00:00
|
|
|
#include <asm/io.h>
|
2014-07-15 21:59:24 +00:00
|
|
|
#include <asm/arch/msmc.h>
|
2014-04-04 17:16:53 +00:00
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/hardware.h>
|
2014-10-22 13:32:32 +00:00
|
|
|
#include <asm/arch/psc_defs.h>
|
2020-05-10 17:40:13 +00:00
|
|
|
#include <linux/bitops.h>
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2014-12-09 19:32:26 +00:00
|
|
|
#define MAX_PCI_PORTS 2
|
|
|
|
enum pci_mode {
|
|
|
|
ENDPOINT,
|
|
|
|
LEGACY_ENDPOINT,
|
|
|
|
ROOTCOMPLEX,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEVCFG_MODE_MASK (BIT(2) | BIT(1))
|
|
|
|
#define DEVCFG_MODE_SHIFT 1
|
|
|
|
|
2014-04-04 17:16:53 +00:00
|
|
|
void chip_configuration_unlock(void)
|
|
|
|
{
|
2014-07-09 20:44:44 +00:00
|
|
|
__raw_writel(KS2_KICK0_MAGIC, KS2_KICK0);
|
|
|
|
__raw_writel(KS2_KICK1_MAGIC, KS2_KICK1);
|
2014-04-04 17:16:53 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 13:32:32 +00:00
|
|
|
#ifdef CONFIG_SOC_K2L
|
|
|
|
void osr_init(void)
|
|
|
|
{
|
|
|
|
u32 i;
|
|
|
|
u32 j;
|
|
|
|
u32 val;
|
|
|
|
u32 base = KS2_OSR_CFG_BASE;
|
|
|
|
u32 ecc_ctrl[KS2_OSR_NUM_RAM_BANKS];
|
|
|
|
|
|
|
|
/* Enable the OSR clock domain */
|
|
|
|
psc_enable_module(KS2_LPSC_OSR);
|
|
|
|
|
|
|
|
/* Disable OSR ECC check for all the ram banks */
|
|
|
|
for (i = 0; i < KS2_OSR_NUM_RAM_BANKS; i++) {
|
|
|
|
val = i | KS2_OSR_ECC_VEC_TRIG_RD |
|
|
|
|
(KS2_OSR_ECC_CTRL << KS2_OSR_ECC_VEC_RD_ADDR_SH);
|
|
|
|
|
|
|
|
writel(val , base + KS2_OSR_ECC_VEC);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* wait till read is done.
|
|
|
|
* Print should be added after earlyprintk support is added.
|
|
|
|
*/
|
|
|
|
for (j = 0; j < 10000; j++) {
|
|
|
|
val = readl(base + KS2_OSR_ECC_VEC);
|
|
|
|
if (val & KS2_OSR_ECC_VEC_RD_DONE)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ecc_ctrl[i] = readl(base + KS2_OSR_ECC_CTRL) ^
|
|
|
|
KS2_OSR_ECC_CTRL_CHK;
|
|
|
|
|
|
|
|
writel(ecc_ctrl[i], KS2_MSMC_DATA_BASE + i * 4);
|
|
|
|
writel(ecc_ctrl[i], base + KS2_OSR_ECC_CTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reset OSR memory to all zeros */
|
|
|
|
for (i = 0; i < KS2_OSR_SIZE; i += 4)
|
|
|
|
writel(0, KS2_OSR_DATA_BASE + i);
|
|
|
|
|
|
|
|
/* Enable OSR ECC check for all the ram banks */
|
|
|
|
for (i = 0; i < KS2_OSR_NUM_RAM_BANKS; i++)
|
|
|
|
writel(ecc_ctrl[i] |
|
|
|
|
KS2_OSR_ECC_CTRL_CHK, base + KS2_OSR_ECC_CTRL);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-12-09 19:32:26 +00:00
|
|
|
/* Function to set up PCIe mode */
|
|
|
|
static void config_pcie_mode(int pcie_port, enum pci_mode mode)
|
|
|
|
{
|
|
|
|
u32 val = __raw_readl(KS2_DEVCFG);
|
|
|
|
|
|
|
|
if (pcie_port >= MAX_PCI_PORTS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* each pci port has two bits for mode and it starts at
|
|
|
|
* bit 1. So use port number to get the right bit position.
|
|
|
|
*/
|
|
|
|
pcie_port <<= 1;
|
|
|
|
val &= ~(DEVCFG_MODE_MASK << pcie_port);
|
|
|
|
val |= ((mode << DEVCFG_MODE_SHIFT) << pcie_port);
|
|
|
|
__raw_writel(val, KS2_DEVCFG);
|
|
|
|
}
|
|
|
|
|
2016-03-23 15:14:18 +00:00
|
|
|
static void msmc_k2hkle_common_setup(void)
|
|
|
|
{
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_0);
|
2016-03-23 15:14:18 +00:00
|
|
|
msmc_share_all_segments(K2HKLE_MSMC_SEGMENT_ARM);
|
|
|
|
msmc_share_all_segments(K2HKLE_MSMC_SEGMENT_NETCP);
|
|
|
|
msmc_share_all_segments(K2HKLE_MSMC_SEGMENT_QM_PDSP);
|
|
|
|
msmc_share_all_segments(K2HKLE_MSMC_SEGMENT_PCIE0);
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_DEBUG);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void msmc_k2hk_setup(void)
|
|
|
|
{
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_1);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_2);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_3);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_4);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_5);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_6);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_7);
|
|
|
|
msmc_share_all_segments(K2HKE_MSMC_SEGMENT_HYPERLINK);
|
2016-03-23 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void msmc_k2l_setup(void)
|
|
|
|
{
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_1);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_2);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_3);
|
2016-03-23 15:14:18 +00:00
|
|
|
msmc_share_all_segments(K2L_MSMC_SEGMENT_PCIE1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void msmc_k2e_setup(void)
|
|
|
|
{
|
|
|
|
msmc_share_all_segments(K2E_MSMC_SEGMENT_PCIE1);
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(K2HKE_MSMC_SEGMENT_HYPERLINK);
|
|
|
|
msmc_share_all_segments(K2E_MSMC_SEGMENT_TSIP);
|
2016-03-23 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
2016-03-23 15:14:19 +00:00
|
|
|
static void msmc_k2g_setup(void)
|
2016-03-23 15:14:18 +00:00
|
|
|
{
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_C6X_0);
|
2016-03-23 15:14:18 +00:00
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_ARM);
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_ICSS0);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_ICSS1);
|
2016-03-23 15:14:18 +00:00
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_NSS);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_PCIE);
|
2016-03-23 15:14:19 +00:00
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_USB);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_MLB);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_PMMC);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_DSS);
|
|
|
|
msmc_share_all_segments(K2G_MSMC_SEGMENT_MMC);
|
|
|
|
msmc_share_all_segments(KS2_MSMC_SEGMENT_DEBUG);
|
2016-03-23 15:14:18 +00:00
|
|
|
}
|
|
|
|
|
2014-04-04 17:16:53 +00:00
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
|
|
|
chip_configuration_unlock();
|
|
|
|
icache_enable();
|
|
|
|
|
2016-03-23 15:14:18 +00:00
|
|
|
if (cpu_is_k2g()) {
|
|
|
|
msmc_k2g_setup();
|
|
|
|
} else {
|
|
|
|
msmc_k2hkle_common_setup();
|
|
|
|
if (cpu_is_k2e())
|
|
|
|
msmc_k2e_setup();
|
|
|
|
else if (cpu_is_k2l())
|
|
|
|
msmc_k2l_setup();
|
2016-03-23 15:14:19 +00:00
|
|
|
else
|
|
|
|
msmc_k2hk_setup();
|
2016-03-23 15:14:18 +00:00
|
|
|
}
|
2014-12-09 19:32:26 +00:00
|
|
|
|
|
|
|
/* Initialize the PCIe-0 to work as Root Complex */
|
|
|
|
config_pcie_mode(0, ROOTCOMPLEX);
|
2014-10-22 13:32:30 +00:00
|
|
|
#if defined(CONFIG_SOC_K2E) || defined(CONFIG_SOC_K2L)
|
2014-12-09 19:32:26 +00:00
|
|
|
/* Initialize the PCIe-1 to work as Root Complex */
|
|
|
|
config_pcie_mode(1, ROOTCOMPLEX);
|
2014-04-04 17:16:53 +00:00
|
|
|
#endif
|
2014-10-22 13:32:32 +00:00
|
|
|
#ifdef CONFIG_SOC_K2L
|
|
|
|
osr_init();
|
|
|
|
#endif
|
2014-04-04 17:16:53 +00:00
|
|
|
|
2014-05-29 15:57:12 +00:00
|
|
|
/*
|
|
|
|
* just initialise the COM2 port so that TI specific
|
|
|
|
* UART register PWREMU_MGMT is initialized. Linux UART
|
|
|
|
* driver doesn't handle this.
|
|
|
|
*/
|
2015-09-19 09:30:16 +00:00
|
|
|
#ifndef CONFIG_DM_SERIAL
|
2020-12-23 02:30:19 +00:00
|
|
|
ns16550_init((struct ns16550 *)(CONFIG_SYS_NS16550_COM2),
|
2014-05-29 15:57:12 +00:00
|
|
|
CONFIG_SYS_NS16550_CLK / 16 / CONFIG_BAUDRATE);
|
2015-09-19 09:30:16 +00:00
|
|
|
#endif
|
2014-05-29 15:57:12 +00:00
|
|
|
|
2014-04-04 17:16:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-12-15 15:47:52 +00:00
|
|
|
void reset_cpu(void)
|
2014-04-04 17:16:53 +00:00
|
|
|
{
|
|
|
|
volatile u32 *rstctrl = (volatile u32 *)(KS2_RSTCTRL);
|
|
|
|
u32 tmp;
|
|
|
|
|
|
|
|
tmp = *rstctrl & KS2_RSTCTRL_MASK;
|
|
|
|
*rstctrl = tmp | KS2_RSTCTRL_KEY;
|
|
|
|
|
|
|
|
*rstctrl &= KS2_RSTCTRL_SWRST;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
2019-05-03 13:41:00 +00:00
|
|
|
#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
|
2014-04-04 17:16:53 +00:00
|
|
|
/* Enable D-cache. I-cache is already enabled in start.S */
|
|
|
|
dcache_enable();
|
|
|
|
#endif
|
|
|
|
}
|
2015-07-28 08:46:42 +00:00
|
|
|
|
|
|
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
|
|
|
int print_cpuinfo(void)
|
|
|
|
{
|
|
|
|
u16 cpu = get_part_number();
|
|
|
|
u8 rev = cpu_revision();
|
|
|
|
|
|
|
|
puts("CPU: ");
|
|
|
|
switch (cpu) {
|
|
|
|
case CPU_66AK2Hx:
|
|
|
|
puts("66AK2Hx SR");
|
|
|
|
break;
|
|
|
|
case CPU_66AK2Lx:
|
|
|
|
puts("66AK2Lx SR");
|
|
|
|
break;
|
|
|
|
case CPU_66AK2Ex:
|
|
|
|
puts("66AK2Ex SR");
|
|
|
|
break;
|
2015-09-19 10:56:38 +00:00
|
|
|
case CPU_66AK2Gx:
|
2017-12-28 15:09:59 +00:00
|
|
|
puts("66AK2Gx");
|
|
|
|
#ifdef CONFIG_SOC_K2G
|
|
|
|
{
|
|
|
|
int speed = get_max_arm_speed(speeds);
|
|
|
|
if (speed == SPD1000)
|
|
|
|
puts("-100 ");
|
|
|
|
else if (speed == SPD600)
|
|
|
|
puts("-60 ");
|
|
|
|
else
|
|
|
|
puts("-xx ");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
puts("SR");
|
2015-09-19 10:56:38 +00:00
|
|
|
break;
|
2015-07-28 08:46:42 +00:00
|
|
|
default:
|
|
|
|
puts("Unknown\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rev == 2)
|
|
|
|
puts("2.0\n");
|
|
|
|
else if (rev == 1)
|
|
|
|
puts("1.1\n");
|
|
|
|
else if (rev == 0)
|
|
|
|
puts("1.0\n");
|
2017-12-28 15:09:59 +00:00
|
|
|
else if (rev == 8)
|
|
|
|
puts("1.0\n");
|
2015-07-28 08:46:42 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|