-
-
Save nmenon/2337eb150a64b3e405eb464998223bca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From git@z Thu Jan 1 00:00:00 1970 | |
Subject: [PATCH 1/4] misc: k3_esm: Add functionality to set and route error events within K3SoC | |
From: Hari Nagalla <hnagalla@ti.com> | |
Date: Tue, 25 Jan 2022 16:02:49 -0600 | |
Message-Id: <20220125220252.18965-2-hnagalla@ti.com> | |
To: <linux-patch-review@list.ti.com> | |
Cc: <praneeth@ti.com>, <nm@ti.com> | |
In-Reply-To: <20220125220252.18965-1-hnagalla@ti.com> | |
References: <20220125220252.18965-1-hnagalla@ti.com> | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset="utf-8" | |
Content-Transfer-Encoding: 7bit | |
Add functionality to enable, set priority to the input events and to | |
route to MCU ESM. On AM64x/AM62x devices, it is possible to route Main | |
ESM0 error events to MCU ESM. When these error events are routed to MCU | |
ESM high output, it can trigger the reset logic to reset the device, | |
when CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RESET_EN_Z is set to '0'. | |
Signed-off-by: Hari Nagalla <hnagalla@ti.com> | |
--- | |
drivers/misc/k3_esm.c | 53 ++++++++++++++++++++++++++++++++++++++++--- | |
1 file changed, 50 insertions(+), 3 deletions(-) | |
diff --git a/drivers/misc/k3_esm.c b/drivers/misc/k3_esm.c | |
index cc2a23dd66..41faeb3d85 100644 | |
--- a/drivers/misc/k3_esm.c | |
+++ b/drivers/misc/k3_esm.c | |
@@ -16,17 +16,57 @@ | |
#define ESM_SFT_RST 0x0c | |
#define ESM_SFT_RST_KEY 0x0f | |
+#define ESM_EN 0x08 | |
+#define ESM_EN_KEY 0x0f | |
#define ESM_STS(i) (0x404 + (i) / 32 * 0x20) | |
+#define ESM_STS_MASK(i) (1 << ((i) % 32)) | |
#define ESM_PIN_EN_SET_OFFSET(i) (0x414 + (i) / 32 * 0x20) | |
-#define ESM_PIN_MASK(i) BIT((i) & 0x1f) | |
+#define ESM_PIN_MASK(i) (1 << ((i) % 32)) | |
+#define ESM_INTR_EN_SET_OFFSET(i) (0x408 + (i) / 32 * 0x20) | |
+#define ESM_INTR_MASK(i) (1 << ((i) % 32)) | |
+#define ESM_INTR_PRIO_SET_OFFSET(i) (0x410 + (i) / 32 * 0x20) | |
+#define ESM_INTR_PRIO_MASK(i) (1 << ((i) % 32)) | |
static void esm_pin_enable(void __iomem *base, int pin) | |
{ | |
+ u32 value; | |
+ | |
+ value = readl(base + ESM_PIN_EN_SET_OFFSET(pin)); | |
+ value |= ESM_PIN_MASK(pin); | |
/* Enable event */ | |
- writel(ESM_PIN_MASK(pin), base + ESM_PIN_EN_SET_OFFSET(pin)); | |
+ writel(value, base + ESM_PIN_EN_SET_OFFSET(pin)); | |
+} | |
+ | |
+static void esm_intr_enable(void __iomem *base, int pin) | |
+{ | |
+ u32 value; | |
+ | |
+ value = readl(base + ESM_INTR_EN_SET_OFFSET(pin)); | |
+ value |= ESM_INTR_MASK(pin); | |
+ /* Enable Interrupt event */ | |
+ writel(value, base + ESM_INTR_EN_SET_OFFSET(pin)); | |
+} | |
+ | |
+static void esm_intr_prio_set(void __iomem *base, int pin) | |
+{ | |
+ u32 value; | |
+ | |
+ value = readl(base + ESM_INTR_PRIO_SET_OFFSET(pin)); | |
+ value |= ESM_INTR_PRIO_MASK(pin); | |
+ /* Set to priority */ | |
+ writel(value, base + ESM_INTR_PRIO_SET_OFFSET(pin)); | |
} | |
+static void esm_clear_raw_status(void __iomem *base, int pin) | |
+{ | |
+ u32 value; | |
+ | |
+ value = readl(base + ESM_STS(pin)); | |
+ value |= ESM_STS_MASK(pin); | |
+ /* Clear Event status */ | |
+ writel(value, base + ESM_STS(pin)); | |
+} | |
/** | |
* k3_esm_probe: configures ESM based on DT data | |
* | |
@@ -67,8 +107,15 @@ static int k3_esm_probe(struct udevice *dev) | |
/* Clear any pending events */ | |
writel(ESM_SFT_RST_KEY, base + ESM_SFT_RST); | |
- for (i = 0; i < num_pins; i++) | |
+ for (i = 0; i < num_pins; i++) { | |
+ esm_intr_prio_set(base, pins[i]); | |
+ esm_clear_raw_status(base, pins[i]); | |
esm_pin_enable(base, pins[i]); | |
+ esm_intr_enable(base, pins[i]); | |
+ } | |
+ | |
+ /* Enable ESM */ | |
+ writel(ESM_EN_KEY, base + ESM_EN); | |
free_pins: | |
kfree(pins); | |
-- | |
2.17.1 | |
From git@z Thu Jan 1 00:00:00 1970 | |
Subject: [PATCH 2/4] arm: dts: k3-am64: Add support for ESM device nodes | |
From: Hari Nagalla <hnagalla@ti.com> | |
Date: Tue, 25 Jan 2022 16:02:50 -0600 | |
Message-Id: <20220125220252.18965-3-hnagalla@ti.com> | |
To: <linux-patch-review@list.ti.com> | |
Cc: <praneeth@ti.com>, <nm@ti.com> | |
In-Reply-To: <20220125220252.18965-1-hnagalla@ti.com> | |
References: <20220125220252.18965-1-hnagalla@ti.com> | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset="utf-8" | |
Content-Transfer-Encoding: 7bit | |
Enable acces to ESM0 configuration space and add Main ESM0 and MCU ESM | |
nodes to the AM64 device tree. | |
Signed-off-by: Hari Nagalla <hnagalla@ti.com> | |
--- | |
arch/arm/dts/k3-am64.dtsi | 1 + | |
arch/arm/dts/k3-am642-r5-evm.dts | 19 +++++++++++++++++++ | |
arch/arm/dts/k3-am642-r5-sk.dts | 19 +++++++++++++++++++ | |
3 files changed, 39 insertions(+) | |
diff --git a/arch/arm/dts/k3-am64.dtsi b/arch/arm/dts/k3-am64.dtsi | |
index 156e20bb2e..0b7733fbd1 100644 | |
--- a/arch/arm/dts/k3-am64.dtsi | |
+++ b/arch/arm/dts/k3-am64.dtsi | |
@@ -67,6 +67,7 @@ | |
#address-cells = <2>; | |
#size-cells = <2>; | |
ranges = <0x00 0x000f4000 0x00 0x000f4000 0x00 0x000002d0>, /* PINCTRL */ | |
+ <0x00 0x00420000 0x00 0x00420000 0x00 0x00001000>, /* ESM0 */ | |
<0x00 0x00600000 0x00 0x00600000 0x00 0x00001100>, /* GPIO */ | |
<0x00 0x00a40000 0x00 0x00a40000 0x00 0x00000800>, /* Timesync router */ | |
<0x00 0x01000000 0x00 0x01000000 0x00 0x02330400>, /* First peripheral window */ | |
diff --git a/arch/arm/dts/k3-am642-r5-evm.dts b/arch/arm/dts/k3-am642-r5-evm.dts | |
index 40d369e2fe..e78cf9953a 100644 | |
--- a/arch/arm/dts/k3-am642-r5-evm.dts | |
+++ b/arch/arm/dts/k3-am642-r5-evm.dts | |
@@ -82,6 +82,25 @@ | |
}; | |
}; | |
+&cbass_main { | |
+ main_esm: esm@420000 { | |
+ compatible = "ti,j721e-esm"; | |
+ reg = <0x0 0x420000 0x0 0x1000>; | |
+ ti,esm-pins = <160>, <161>; | |
+ u-boot,dm-spl; | |
+ }; | |
+}; | |
+ | |
+&cbass_mcu { | |
+ u-boot,dm-spl; | |
+ mcu_esm: esm@4100000 { | |
+ compatible = "ti,j721e-esm"; | |
+ reg = <0x0 0x4100000 0x0 0x1000>; | |
+ ti,esm-pins = <0>, <1>; | |
+ u-boot,dm-spl; | |
+ }; | |
+}; | |
+ | |
&main_pmx0 { | |
u-boot,dm-spl; | |
main_uart0_pins_default: main-uart0-pins-default { | |
diff --git a/arch/arm/dts/k3-am642-r5-sk.dts b/arch/arm/dts/k3-am642-r5-sk.dts | |
index 1a36400775..868dce630a 100644 | |
--- a/arch/arm/dts/k3-am642-r5-sk.dts | |
+++ b/arch/arm/dts/k3-am642-r5-sk.dts | |
@@ -74,6 +74,25 @@ | |
}; | |
}; | |
+&cbass_main { | |
+ main_esm: esm@420000 { | |
+ compatible = "ti,j721e-esm"; | |
+ reg = <0x0 0x420000 0x0 0x1000>; | |
+ ti,esm-pins = <160>, <161>; | |
+ u-boot,dm-spl; | |
+ }; | |
+}; | |
+ | |
+&cbass_mcu { | |
+ u-boot,dm-spl; | |
+ mcu_esm: esm@4100000 { | |
+ compatible = "ti,j721e-esm"; | |
+ reg = <0x0 0x4100000 0x0 0x1000>; | |
+ ti,esm-pins = <0>, <1>; | |
+ u-boot,dm-spl; | |
+ }; | |
+}; | |
+ | |
&main_pmx0 { | |
u-boot,dm-spl; | |
main_uart0_pins_default: main-uart0-pins-default { | |
-- | |
2.17.1 | |
From git@z Thu Jan 1 00:00:00 1970 | |
Subject: [PATCH 3/4] arch: arm: mach-k3: am642_init: Probe ESM nodes | |
From: Hari Nagalla <hnagalla@ti.com> | |
Date: Tue, 25 Jan 2022 16:02:51 -0600 | |
Message-Id: <20220125220252.18965-4-hnagalla@ti.com> | |
To: <linux-patch-review@list.ti.com> | |
Cc: <praneeth@ti.com>, <nm@ti.com> | |
In-Reply-To: <20220125220252.18965-1-hnagalla@ti.com> | |
References: <20220125220252.18965-1-hnagalla@ti.com> | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset="utf-8" | |
Content-Transfer-Encoding: 7bit | |
On AM64x devices, it is possible to route Main ESM0 error events to MCU | |
ESM. MCU ESM high error output can trigger the reset logic to reset the | |
device. So, for these devices we expect two ESM device nodes in the | |
device tree, one for Main ESM and the another MCU ESM in the device tree. | |
When these ESM device nodes are properly configired it is possible to | |
route the Main RTI0 WWDT output to the MCU ESM high output through Main | |
ESM and trigger a device reset when | |
CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RESET_EN_Z is set to '0'. | |
On K3 AM64x devices, the R5 SPL u-boot handles the ESM device node | |
configurations. | |
Signed-off-by: Hari Nagalla <hnagalla@ti.com> | |
--- | |
arch/arm/mach-k3/am642_init.c | 37 +++++++++++++++++++++++++++++++++++ | |
1 file changed, 37 insertions(+) | |
diff --git a/arch/arm/mach-k3/am642_init.c b/arch/arm/mach-k3/am642_init.c | |
index 3871fe0002..b0e878ae17 100644 | |
--- a/arch/arm/mach-k3/am642_init.c | |
+++ b/arch/arm/mach-k3/am642_init.c | |
@@ -24,6 +24,8 @@ | |
#include <dm/root.h> | |
#ifdef CONFIG_SPL_BUILD | |
+#define MCU_CTRL_MMR0_BASE 0x04500000 | |
+#define CTRLMMR_MCU_RST_CTRL 0x04518170 | |
static void ctrl_mmr_unlock(void) | |
{ | |
@@ -39,6 +41,17 @@ static void ctrl_mmr_unlock(void) | |
mmr_unlock(CTRL_MMR0_BASE, 6); | |
} | |
+static void mcu_ctrl_mmr_unlock(void) | |
+{ | |
+ /* Unlock all MCU_CTRL_MMR0 module registers */ | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 0); | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 1); | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 2); | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 3); | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 4); | |
+ mmr_unlock(MCU_CTRL_MMR0_BASE, 6); | |
+} | |
+ | |
/* | |
* This uninitialized global variable would normal end up in the .bss section, | |
* but the .bss is cleared between writing and reading this variable, so move | |
@@ -139,6 +152,15 @@ void do_dt_magic(void) | |
} | |
#endif | |
+static void enable_mcu_esm_reset(void) | |
+{ | |
+ /* Set CTRLMMR_MCU_RST_CTRL:MCU_ESM_ERROR_RST_EN_Z to '0' (low active) */ | |
+ u32 stat = readl(CTRLMMR_MCU_RST_CTRL); | |
+ | |
+ stat = stat & 0xFFFDFFFF; | |
+ writel(stat, CTRLMMR_MCU_RST_CTRL); | |
+} | |
+ | |
void board_init_f(ulong dummy) | |
{ | |
#if defined(CONFIG_K3_LOAD_SYSFW) || defined(CONFIG_K3_AM64_DDRSS) | |
@@ -157,6 +179,9 @@ void board_init_f(ulong dummy) | |
store_boot_info_from_rom(); | |
ctrl_mmr_unlock(); | |
+ mcu_ctrl_mmr_unlock(); | |
+ | |
+ enable_mcu_esm_reset(); | |
/* Init DM early */ | |
spl_early_init(); | |
@@ -191,6 +216,18 @@ void board_init_f(ulong dummy) | |
/* Output System Firmware version info */ | |
k3_sysfw_print_ver(); | |
+#ifdef CONFIG_ESM_K3 | |
+ /* Probe/configure ESM0 */ | |
+ ret = uclass_get_device_by_name(UCLASS_MISC, "esm@420000", &dev); | |
+ if (ret) | |
+ printf("MISC init failed: %d\n", ret); | |
+ | |
+ /* Probe/configure MCUESM */ | |
+ ret = uclass_get_device_by_name(UCLASS_MISC, "esm@4100000", &dev); | |
+ if (ret) | |
+ printf("MISC2 init failed: %d\n", ret); | |
+#endif | |
+ | |
#if defined(CONFIG_K3_AM64_DDRSS) | |
ret = uclass_get_device(UCLASS_RAM, 0, &dev); | |
if (ret) | |
-- | |
2.17.1 | |
From git@z Thu Jan 1 00:00:00 1970 | |
Subject: [PATCH 4/4] configs: am64x_evm_r5_defconfig: Add support for ESM driver | |
From: Hari Nagalla <hnagalla@ti.com> | |
Date: Tue, 25 Jan 2022 16:02:52 -0600 | |
Message-Id: <20220125220252.18965-5-hnagalla@ti.com> | |
To: <linux-patch-review@list.ti.com> | |
Cc: <praneeth@ti.com>, <nm@ti.com> | |
In-Reply-To: <20220125220252.18965-1-hnagalla@ti.com> | |
References: <20220125220252.18965-1-hnagalla@ti.com> | |
MIME-Version: 1.0 | |
Content-Type: text/plain; charset="utf-8" | |
Content-Transfer-Encoding: 7bit | |
Enable ESM driver for AM64x R5 SPL/u-boot builds. | |
Signed-off-by: Hari Nagalla <hnagalla@ti.com> | |
--- | |
configs/am64x_evm_r5_defconfig | 1 + | |
1 file changed, 1 insertion(+) | |
diff --git a/configs/am64x_evm_r5_defconfig b/configs/am64x_evm_r5_defconfig | |
index cc1a705d8b..36d3fde4d7 100644 | |
--- a/configs/am64x_evm_r5_defconfig | |
+++ b/configs/am64x_evm_r5_defconfig | |
@@ -155,3 +155,4 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x0451 | |
CONFIG_USB_GADGET_PRODUCT_NUM=0x6165 | |
CONFIG_USB_GADGET_DOWNLOAD=y | |
CONFIG_FS_FAT_MAX_CLUSTSIZE=16384 | |
+CONFIG_ESM_K3=y | |
-- | |
2.17.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment