blob: ada7c077ec2f61003c25af0520208600886a4a1b [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
10static int found(u64 start, u64 end, void *data)
11{
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);
Johan Hovold14498162022-06-20 16:07:23 +020030
31 rc = platform_device_add(pdev);
32 if (rc)
33 platform_device_put(pdev);
34
35 return rc;
Christoph Hellwigec776ef2015-04-01 09:12:18 +020036}
Dan Williams9f53f9f2015-06-09 15:33:45 -040037device_initcall(register_e820_pmem);