summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorPhilipp Zabel <p.zabel@pengutronix.de>2019-03-15 10:14:51 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-18 09:43:35 +0100
commitaf85a0f8864e5888406bb13c3e3f99c5770959ca (patch)
tree00a371a06ac052d4499041964362fdc814777fa6 /fs
parentda9b86ec0fbec0eb60646e7a3c700076a423717d (diff)
downloadbarebox-af85a0f8864e5888406bb13c3e3f99c5770959ca.tar.gz
pstore: pass ramoops configuration to kernel via device tree
Instead of setting ramoops module parameters on the kernel command line, add a /reserved-memory/ramoops node to the device tree via of_fixup. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Documentation-added-by: Juergen Borleis <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/pstore/ram.c98
1 files changed, 80 insertions, 18 deletions
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index fcf6b30..3daec0d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -468,6 +468,66 @@ static int ramoops_parse_dt(struct device_d *dev,
return 0;
}
+static int ramoops_of_fixup(struct device_node *root, void *data)
+{
+ struct ramoops_platform_data *pdata = data;
+ struct device_node *node;
+ u32 reg[2];
+ int ret;
+
+ node = of_get_child_by_name(root, "reserved-memory");
+ if (!node) {
+ pr_info("Adding reserved-memory node\n");
+ node = of_create_node(root, "/reserved-memory");
+ if (!node)
+ return -ENOMEM;
+
+ of_property_write_u32(node, "#address-cells", 1);
+ of_property_write_u32(node, "#size-cells", 1);
+ of_new_property(node, "ranges", NULL, 0);
+ }
+
+ node = of_get_child_by_name(node, "ramoops");
+ if (!node) {
+ pr_info("Adding ramoops node\n");
+ node = of_create_node(root, "/reserved-memory/ramoops");
+ if (!node)
+ return -ENOMEM;
+ }
+
+ ret = of_property_write_string(node, "compatible", "ramoops");
+ if (ret)
+ return ret;
+ reg[0] = pdata->mem_address;
+ reg[1] = pdata->mem_size;
+ ret = of_property_write_u32_array(node, "reg", reg, 2);
+ if (ret)
+ return ret;
+
+ ret = of_property_write_bool(node, "unbuffered", pdata->mem_type);
+ if (ret)
+ return ret;
+ ret = of_property_write_bool(node, "no-dump-oops", !pdata->dump_oops);
+ if (ret)
+ return ret;
+
+#define store_size(name, field) { \
+ ret = of_property_write_u32(node, name, field); \
+ if (ret < 0) \
+ return ret; \
+ }
+
+ store_size("record-size", pdata->record_size);
+ store_size("console-size", pdata->console_size);
+ store_size("ftrace-size", pdata->ftrace_size);
+ store_size("pmsg-size", pdata->pmsg_size);
+ store_size("ecc-size", pdata->ecc_info.ecc_size);
+
+#undef store_size
+
+ return 0;
+}
+
static int ramoops_probe(struct device_d *dev)
{
struct ramoops_platform_data *pdata = dummy_data;
@@ -574,25 +634,27 @@ static int ramoops_probe(struct device_d *dev)
cxt->size, (unsigned long long)cxt->phys_addr,
cxt->ecc_info.ecc_size, cxt->ecc_info.block_size);
- scnprintf(kernelargs, sizeof(kernelargs),
- "ramoops.record_size=0x%x "
- "ramoops.console_size=0x%x "
- "ramoops.ftrace_size=0x%x "
- "ramoops.pmsg_size=0x%x "
- "ramoops.mem_address=0x%llx "
- "ramoops.mem_size=0x%lx "
- "ramoops.ecc=%d",
- cxt->record_size,
- cxt->console_size,
- cxt->ftrace_size,
- cxt->pmsg_size,
- (unsigned long long)cxt->phys_addr,
- mem_size,
- ramoops_ecc);
- globalvar_add_simple("linux.bootargs.ramoops", kernelargs);
-
- if (IS_ENABLED(CONFIG_OFTREE))
+ if (!IS_ENABLED(CONFIG_OFTREE)) {
+ scnprintf(kernelargs, sizeof(kernelargs),
+ "ramoops.record_size=0x%x "
+ "ramoops.console_size=0x%x "
+ "ramoops.ftrace_size=0x%x "
+ "ramoops.pmsg_size=0x%x "
+ "ramoops.mem_address=0x%llx "
+ "ramoops.mem_size=0x%lx "
+ "ramoops.ecc=%d",
+ cxt->record_size,
+ cxt->console_size,
+ cxt->ftrace_size,
+ cxt->pmsg_size,
+ (unsigned long long)cxt->phys_addr,
+ mem_size,
+ ramoops_ecc);
+ globalvar_add_simple("linux.bootargs.ramoops", kernelargs);
+ } else {
of_add_reserve_entry(cxt->phys_addr, cxt->phys_addr + mem_size);
+ of_register_fixup(ramoops_of_fixup, pdata);
+ }
return 0;