1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/platform_device.h>
3 #include <linux/memregion.h>
4 #include <linux/module.h>
5 #include <linux/pfn_t.h>
8 static bool region_idle
;
9 module_param_named(region_idle
, region_idle
, bool, 0644);
11 static int dax_hmem_probe(struct platform_device
*pdev
)
13 struct device
*dev
= &pdev
->dev
;
14 struct dax_region
*dax_region
;
15 struct memregion_info
*mri
;
16 struct dev_dax_data data
;
17 struct dev_dax
*dev_dax
;
21 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
25 mri
= dev
->platform_data
;
26 range
.start
= res
->start
;
28 dax_region
= alloc_dax_region(dev
, pdev
->id
, &range
, mri
->target_node
,
33 data
= (struct dev_dax_data
) {
34 .dax_region
= dax_region
,
36 .size
= region_idle
? 0 : resource_size(res
),
38 dev_dax
= devm_create_dev_dax(&data
);
40 return PTR_ERR(dev_dax
);
42 /* child dev_dax instances now own the lifetime of the dax_region */
43 dax_region_put(dax_region
);
47 static int dax_hmem_remove(struct platform_device
*pdev
)
49 /* devm handles teardown */
53 static struct platform_driver dax_hmem_driver
= {
54 .probe
= dax_hmem_probe
,
55 .remove
= dax_hmem_remove
,
61 module_platform_driver(dax_hmem_driver
);
63 MODULE_ALIAS("platform:hmem*");
64 MODULE_LICENSE("GPL v2");
65 MODULE_AUTHOR("Intel Corporation");