summaryrefslogtreecommitdiffstats
path: root/drivers/platform/tegra/tegra_ramoops.c
blob: 36812aa1871f7ed11f5b10733958fe3f983811b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
 * Copyright (c) 2015-2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 */

#include <linux/init.h>
#include <linux/of.h>
#include <linux/of_fdt.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
#include <linux/pstore_ram.h>

static __init int display_tegra_dt_info(void)
{
	int ret_d;
	int ret_t;
	unsigned long dt_root;
	const char *dts_fname;
	const char *dtb_bdate;
	const char *dtb_btime;

	dt_root = of_get_flat_dt_root();

	dts_fname = of_get_flat_dt_prop(dt_root, "nvidia,dtsfilename", NULL);
	if (dts_fname)
		pr_info("DTS File Name: %s\n", dts_fname);
	else
		pr_info("DTS File Name: <unknown>\n");

	ret_d = of_property_read_string_index(of_find_node_by_path("/"),
					"nvidia,dtbbuildtime", 0, &dtb_bdate);
	ret_t = of_property_read_string_index(of_find_node_by_path("/"),
					"nvidia,dtbbuildtime", 1, &dtb_btime);
	if (!ret_d && !ret_t)
		pr_info("DTB Build time: %s %s\n", dtb_bdate, dtb_btime);
	else
		pr_info("DTB Build time: <unknown>\n");

	return 0;
}
arch_initcall(display_tegra_dt_info);

#define RECORD_MEM_SIZE SZ_64K
#define CONSOLE_MEM_SIZE SZ_512K
#define FTRACE_MEM_SIZE SZ_512K
#define PMSG_MEM_SIZE SZ_256K

static struct ramoops_platform_data ramoops_data;

static struct platform_device ramoops_dev = {
	.name = "ramoops",
	.dev = {
		.platform_data = &ramoops_data,
	},
};

static int __init ramoops_init(struct reserved_mem *rmem)
{
	ramoops_data.mem_address = rmem->base;
	ramoops_data.mem_size = rmem->size;
	ramoops_data.record_size = RECORD_MEM_SIZE;
#ifdef CONFIG_PSTORE_CONSOLE
	ramoops_data.console_size = CONSOLE_MEM_SIZE;
#endif
#ifdef CONFIG_PSTORE_FTRACE
	ramoops_data.ftrace_size = FTRACE_MEM_SIZE;
#endif
#ifdef CONFIG_PSTORE_PMSG
	ramoops_data.pmsg_size = PMSG_MEM_SIZE;
#endif

	ramoops_data.dump_oops = 1;
	return 0;
}
RESERVEDMEM_OF_DECLARE(tegra_ramoops, "nvidia,ramoops", ramoops_init);

static int __init tegra_register_ramoops_device(void)
{
	int ret;

	ret = platform_device_register(&ramoops_dev);
	if (ret)
		pr_err("Unable to register ramoops platform device\n");
	return ret;
}
core_initcall(tegra_register_ramoops_device);