Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Christoph Hellwig | ec776ef | 2015-04-01 09:12:18 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015, Christoph Hellwig. |
Dan Williams | 9f53f9f | 2015-06-09 15:33:45 -0400 | [diff] [blame] | 4 | * Copyright (c) 2015, Intel Corporation. |
Christoph Hellwig | ec776ef | 2015-04-01 09:12:18 +0200 | [diff] [blame] | 5 | */ |
Christoph Hellwig | ec776ef | 2015-04-01 09:12:18 +0200 | [diff] [blame] | 6 | #include <linux/platform_device.h> |
Paul Gortmaker | 186f436 | 2016-07-13 20:18:56 -0400 | [diff] [blame] | 7 | #include <linux/init.h> |
Dan Williams | bc0d0d0 | 2015-11-30 09:10:33 -0800 | [diff] [blame] | 8 | #include <linux/ioport.h> |
| 9 | |
| 10 | static int found(u64 start, u64 end, void *data) |
| 11 | { |
| 12 | return 1; |
| 13 | } |
Dan Williams | 9f53f9f | 2015-06-09 15:33:45 -0400 | [diff] [blame] | 14 | |
| 15 | static __init int register_e820_pmem(void) |
Christoph Hellwig | ec776ef | 2015-04-01 09:12:18 +0200 | [diff] [blame] | 16 | { |
Dan Williams | 7a67832 | 2015-08-19 00:34:34 -0400 | [diff] [blame] | 17 | struct platform_device *pdev; |
Dan Williams | bc0d0d0 | 2015-11-30 09:10:33 -0800 | [diff] [blame] | 18 | int rc; |
| 19 | |
Toshi Kani | f0f4711 | 2016-01-26 21:57:30 +0100 | [diff] [blame] | 20 | rc = walk_iomem_res_desc(IORES_DESC_PERSISTENT_MEMORY_LEGACY, |
| 21 | IORESOURCE_MEM, 0, -1, NULL, found); |
Dan Williams | bc0d0d0 | 2015-11-30 09:10:33 -0800 | [diff] [blame] | 22 | if (rc <= 0) |
| 23 | return 0; |
Dan Williams | 9f53f9f | 2015-06-09 15:33:45 -0400 | [diff] [blame] | 24 | |
Dan Williams | 7a67832 | 2015-08-19 00:34:34 -0400 | [diff] [blame] | 25 | /* |
| 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 Hovold | 1449816 | 2022-06-20 16:07:23 +0200 | [diff] [blame] | 30 | |
| 31 | rc = platform_device_add(pdev); |
| 32 | if (rc) |
| 33 | platform_device_put(pdev); |
| 34 | |
| 35 | return rc; |
Christoph Hellwig | ec776ef | 2015-04-01 09:12:18 +0200 | [diff] [blame] | 36 | } |
Dan Williams | 9f53f9f | 2015-06-09 15:33:45 -0400 | [diff] [blame] | 37 | device_initcall(register_e820_pmem); |