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 int dax_hmem_probe(struct platform_device
*pdev
)
10 struct device
*dev
= &pdev
->dev
;
11 struct dev_pagemap pgmap
= { };
12 struct dax_region
*dax_region
;
13 struct memregion_info
*mri
;
14 struct dev_dax
*dev_dax
;
17 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
21 mri
= dev
->platform_data
;
22 memcpy(&pgmap
.res
, res
, sizeof(*res
));
24 dax_region
= alloc_dax_region(dev
, pdev
->id
, res
, mri
->target_node
,
25 PMD_SIZE
, PFN_DEV
|PFN_MAP
);
29 dev_dax
= devm_create_dev_dax(dax_region
, 0, &pgmap
);
31 return PTR_ERR(dev_dax
);
33 /* child dev_dax instances now own the lifetime of the dax_region */
34 dax_region_put(dax_region
);
38 static int dax_hmem_remove(struct platform_device
*pdev
)
40 /* devm handles teardown */
44 static struct platform_driver dax_hmem_driver
= {
45 .probe
= dax_hmem_probe
,
46 .remove
= dax_hmem_remove
,
52 module_platform_driver(dax_hmem_driver
);
54 MODULE_ALIAS("platform:hmem*");
55 MODULE_LICENSE("GPL v2");
56 MODULE_AUTHOR("Intel Corporation");