ramdump: add ramdump support for TL1 [4/4]

PD#TV-1924

Problem:
On TL1, ramdump is not enabled.

Solution:
Add ramdump support for TL1 chips in kernel.
Also add sticky register config for other chips

Verify:
tl1_x301_v1

Change-Id: I67a11d128343ff9e615377b19914a3fc77b7acef
Signed-off-by: Tao Zeng <tao.zeng@amlogic.com>
This commit is contained in:
Tao Zeng
2019-01-04 17:04:45 +08:00
committed by Luke Go
parent 438cd09ff8
commit d502d2bb21
12 changed files with 79 additions and 0 deletions

View File

@@ -280,6 +280,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0xFF6345E0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -443,6 +443,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0xFF6345E0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -245,6 +245,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0xC88345E0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -280,6 +280,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0xC88345E0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -283,6 +283,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0xFF6345E0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -285,6 +285,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0x0 0xFF6345E0 0x0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -443,6 +443,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0x0 0xFF6345E0 0x0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -232,6 +232,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0x0 0xC88345E0 0x0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -280,6 +280,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0x0 0xC88345E0 0x0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -283,6 +283,8 @@
ram-dump {
compatible = "amlogic, ram_dump";
status = "okay";
reg = <0x0 0xFF6345E0 0x0 4>;
reg-names = "PREG_STICKY_REG8";
};
jtag {

View File

@@ -31,6 +31,7 @@
#include <linux/amlogic/ramdump.h>
#include <linux/amlogic/reboot.h>
#include <linux/arm-smccc.h>
#include <linux/of.h>
#include <linux/highmem.h>
#include <asm/cacheflush.h>
@@ -282,6 +283,46 @@ void ramdump_sync_data(void)
static int __init ramdump_probe(struct platform_device *pdev)
{
void __iomem *p = NULL;
struct device_node *np;
unsigned long dts_memory[2] = {0}, total_mem;
struct resource *res;
unsigned int dump_set;
int ret;
void __iomem *base;
np = of_find_node_by_name(NULL, "memory");
if (!np)
return -EINVAL;
#ifdef CONFIG_64BIT
ret = of_property_read_u64_array(np, "linux,usable-memory",
(u64 *)&dts_memory, 2);
if (ret)
ret = of_property_read_u64_array(np, "reg",
(u64 *)&dts_memory, 2);
#else
ret = of_property_read_u32_array(np, "linux,usable-memory",
(u32 *)&dts_memory, 2);
if (ret)
ret = of_property_read_u32_array(np, "reg",
(u32 *)&dts_memory, 2);
#endif
if (ret)
pr_info("can't get dts memory\n");
else
pr_info("MEMORY:[%lx+%lx]\n", dts_memory[0], dts_memory[1]);
of_node_put(np);
/*
* memory in dts is [start_addr size] patten. For amlogic soc,
* ddr address range is started from 0x0, usually start_addr in
* dts should be started with 0x0, but some soc must reserve a
* small framgment of memory at 0x0 for start up code. So start_addr
* can be 0x100000/0x1000000. But we always using 0x0 to get real
* DDR size for ramdump. So we using following formula to get total
* DDR size.
*/
total_mem = dts_memory[0] + dts_memory[1];
ram = kzalloc(sizeof(struct ramdump), GFP_KERNEL);
if (!ram)
@@ -320,6 +361,21 @@ static int __init ramdump_probe(struct platform_device *pdev)
INIT_WORK(&ram->clear_work, lazy_clear_work);
schedule_work(&ram->clear_work);
}
res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
"PREG_STICKY_REG8");
if (res) {
base = devm_ioremap(&pdev->dev, res->start,
res->end - res->start);
if (!base) {
pr_err("%s, map reg failed\n", __func__);
goto err;
}
dump_set = readl(base);
dump_set &= ~RAMDUMP_STICKY_DATA_MASK;
dump_set |= ((total_mem >> 20) | AMLOGIC_KERNEL_BOOTED);
writel(dump_set, base);
pr_info("%s, set sticky to %x\n", __func__, dump_set);
}
return 0;
err1:

View File

@@ -20,6 +20,9 @@
#define SET_REBOOT_REASON 0x82000049
#define AMLOGIC_KERNEL_BOOTED 0x8000
#define RAMDUMP_STICKY_DATA_MASK 0xFFFF
extern int ramdump_disabled(void);
extern void ramdump_sync_data(void);