blob: 6b07faaa157980915e42dc71bdc392a7c5a704e0 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Christoph Hellwigec776ef2015-04-01 09:12:18 +02002/*
3 * Copyright (c) 2015, Christoph Hellwig.
Dan Williams9f53f9f2015-06-09 15:33:45 -04004 * Copyright (c) 2015, Intel Corporation.
Christoph Hellwigec776ef2015-04-01 09:12:18 +02005 */
Christoph Hellwigec776ef2015-04-01 09:12:18 +02006#include <linux/platform_device.h>
Paul Gortmaker186f4362016-07-13 20:18:56 -04007#include <linux/init.h>
Dan Williamsbc0d0d02015-11-30 09:10:33 -08008#include <linux/ioport.h>
9
Tom Lendacky1d2e7332017-10-20 09:30:51 -050010static int found(struct resource *res, void *data)
Dan Williamsbc0d0d02015-11-30 09:10:33 -080011{
12 return 1;
13}
Dan Williams9f53f9f2015-06-09 15:33:45 -040014
15static __init int register_e820_pmem(void)
Christoph Hellwigec776ef2015-04-01 09:12:18 +020016{
Dan Williams7a678322015-08-19 00:34:34 -040017 struct platform_device *pdev;
Dan Williamsbc0d0d02015-11-30 09:10:33 -080018 int rc;
19
Toshi Kanif0f47112016-01-26 21:57:30 +010020 rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY,
21 IORESOURCE_MEM, 0, -1, NULL, found);
Dan Williamsbc0d0d02015-11-30 09:10:33 -080022 if (rc <= 0)
23 return 0;
Dan Williams9f53f9f2015-06-09 15:33:45 -040024
Dan Williams7a678322015-08-19 00:34:34 -040025 /*
26 * See drivers/nvdimm/e820.c for the implementation, this is
27 * simply here to trigger the module to load on demand.
28 */
29 pdev = platform_device_alloc("e820_pmem", -1);
30 return platform_device_add(pdev);
Christoph Hellwigec776ef2015-04-01 09:12:18 +020031}
Dan Williams9f53f9f2015-06-09 15:33:45 -040032device_initcall(register_e820_pmem);