Adds a platform driver to support pstore on HiKey (copied from the in-kernel ChromeOS driver).
Also adds reservation in the hikey DTS and enables the feature in hikey_defconfig.
Note: Unfortunately the ramoops DT driver never made it upstream, so I'm adding this via a platform driver. Would appreciate thoughts on how to best handle this.
Cc: Rob Herring rob.herring@linaro.org Cc: Arnd Bergmann arnd.bergmann@linaro.org Cc: Haojian Zhuang haojian.zhuang@linaro.org Cc: Guodong Xu guodong.xu@linaro.org Cc: Vishal Bhoj vishal.bhoj@linaro.org Signed-off-by: John Stultz john.stultz@linaro.org --- arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts | 5 +++ arch/arm64/configs/hikey_defconfig | 9 +++++ drivers/platform/Kconfig | 2 ++ drivers/platform/Makefile | 1 + drivers/platform/hikey/Kconfig | 27 +++++++++++++++ drivers/platform/hikey/Makefile | 2 ++ drivers/platform/hikey/hikey_pstore.c | 47 ++++++++++++++++++++++++++ 7 files changed, 93 insertions(+) create mode 100644 drivers/platform/hikey/Kconfig create mode 100644 drivers/platform/hikey/Makefile create mode 100644 drivers/platform/hikey/hikey_pstore.c
diff --git a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts index f0cd5fa..a94f955 100644 --- a/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts +++ b/arch/arm64/boot/dts/hisilicon/hi6220-hikey.dts @@ -61,6 +61,11 @@ no-map; reg = <0x0 0x06dff000 0x0 0x00001000>; /* Mailbox message buf */ }; + + pstore@0x21f00000 { + no-map; + reg = <0x0 0x21f00000 0x0 0x00100000>; /* pstore/ramoops buffer */ + }; };
reboot_reason: reboot-reason@05f01000 { diff --git a/arch/arm64/configs/hikey_defconfig b/arch/arm64/configs/hikey_defconfig index e3cd02d..5313620 100644 --- a/arch/arm64/configs/hikey_defconfig +++ b/arch/arm64/configs/hikey_defconfig @@ -345,6 +345,8 @@ CONFIG_ANDROID_LOW_MEMORY_KILLER=y CONFIG_SYNC=y CONFIG_ION=y CONFIG_ION_HISI=y +CONFIG_HIKEY_PLATFORM=y +CONFIG_HIKEY_PSTORE=y CONFIG_MAILBOX=y CONFIG_HISI_MBOX=y CONFIG_HI6220_MBOX=y @@ -354,6 +356,7 @@ CONFIG_ANDROID=y CONFIG_ANDROID_BINDER_IPC=y CONFIG_REBOOT_REASON_SRAM=y CONFIG_EFI_VARS=y +CONFIG_EFI_VARS_PSTORE_DEFAULT_DISABLE=y CONFIG_EXT4_FS=y CONFIG_EXT4_FS_SECURITY=y CONFIG_BTRFS_FS=y @@ -371,6 +374,10 @@ CONFIG_TMPFS=y CONFIG_HUGETLBFS=y CONFIG_SQUASHFS=y CONFIG_SQUASHFS_XZ=y +CONFIG_PSTORE=y +CONFIG_PSTORE_CONSOLE=y +CONFIG_PSTORE_PMSG=y +CONFIG_PSTORE_RAM=y CONFIG_NFS_FS=y # CONFIG_NFS_V2 is not set CONFIG_NFS_V3_ACL=y @@ -385,6 +392,8 @@ CONFIG_PRINTK_TIME=y CONFIG_DEBUG_INFO=y CONFIG_MAGIC_SYSRQ=y CONFIG_LOCKUP_DETECTOR=y +CONFIG_PANIC_ON_OOPS=y +CONFIG_PANIC_TIMEOUT=10 # CONFIG_SCHED_DEBUG is not set CONFIG_SCHEDSTATS=y CONFIG_TIMER_STATS=y diff --git a/drivers/platform/Kconfig b/drivers/platform/Kconfig index 5bd93a2..881c62b 100644 --- a/drivers/platform/Kconfig +++ b/drivers/platform/Kconfig @@ -7,3 +7,5 @@ endif source "drivers/platform/goldfish/Kconfig"
source "drivers/platform/chrome/Kconfig" + +source "drivers/platform/hikey/Kconfig" diff --git a/drivers/platform/Makefile b/drivers/platform/Makefile index ca26925..b0e7286 100644 --- a/drivers/platform/Makefile +++ b/drivers/platform/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_MIPS) += mips/ obj-$(CONFIG_OLPC) += olpc/ obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_CHROME_PLATFORMS) += chrome/ +obj-$(CONFIG_HIKEY_PLATFORM) += hikey/ diff --git a/drivers/platform/hikey/Kconfig b/drivers/platform/hikey/Kconfig new file mode 100644 index 0000000..5b36bba --- /dev/null +++ b/drivers/platform/hikey/Kconfig @@ -0,0 +1,27 @@ +# +# Platform support for Chrome OS hardware (Chromebooks and Chromeboxes) +# + +menuconfig HIKEY_PLATFORM + bool "Platform support for HiKey hardware" + depends on ARM64 + ---help--- + Say Y here to get to see options for platform support for + the HiKey board. This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if HIKEY_PLATFORM + +config HIKEY_PSTORE + tristate "HiKey pstore support" + depends on ARM64 + ---help--- + This module instantiates the persistent storage on Hikey + devices. It can be used to store away console logs and crash + information across reboots. + + If you have a HiKey board, choose Y or M here. + The module will be called hikey_pstore. + +endif # HIKEY_PLATFORM diff --git a/drivers/platform/hikey/Makefile b/drivers/platform/hikey/Makefile new file mode 100644 index 0000000..7ab9173 --- /dev/null +++ b/drivers/platform/hikey/Makefile @@ -0,0 +1,2 @@ + +obj-$(CONFIG_HIKEY_PSTORE) += hikey_pstore.o diff --git a/drivers/platform/hikey/hikey_pstore.c b/drivers/platform/hikey/hikey_pstore.c new file mode 100644 index 0000000..1ab218b --- /dev/null +++ b/drivers/platform/hikey/hikey_pstore.c @@ -0,0 +1,47 @@ +/* + * hikey.c - Driver to instantiate HiKey ramoops device + * (Copied from ChromeOS ramoops implementation) + * + * Copyright (C) 2013 Google, Inc. + * Copyright (C) 2016 Linaro Limited + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 2 of the License. + */ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/pstore_ram.h> + +static struct ramoops_platform_data hikey_ramoops_data = { + .mem_size = 0x00100000, + .mem_address = 0x21f00000, + .record_size = 0x20000, + .console_size = 0x20000, + .ftrace_size = 0x20000, + .dump_oops = 1, +}; + +static struct platform_device hikey_ramoops = { + .name = "ramoops", + .dev = { + .platform_data = &hikey_ramoops_data, + }, +}; + +static int __init hikey_pstore_init(void) +{ + return platform_device_register(&hikey_ramoops); +} + +static void __exit hikey_pstore_exit(void) +{ + platform_device_unregister(&hikey_ramoops); +} + +module_init(hikey_pstore_init); +module_exit(hikey_pstore_exit); + +MODULE_DESCRIPTION("HiKey pstore module"); +MODULE_LICENSE("GPL");
On Tue, Jan 5, 2016 at 6:32 PM, John Stultz john.stultz@linaro.org wrote:
Adds a platform driver to support pstore on HiKey (copied from the in-kernel ChromeOS driver).
Also adds reservation in the hikey DTS and enables the feature in hikey_defconfig.
Note: Unfortunately the ramoops DT driver never made it upstream, so I'm adding this via a platform driver. Would appreciate thoughts on how to best handle this.
I've acked the DT binding part of it recently. Probably just need to ping the pstore maintainer if it hasn't been picked up.
Rob