Skip to content
Digital Rhyme
Embedded development board with transparent layered device-tree overlays

drhyme_dt_probe.c Source

DTS structure, data types, buses, devices, overlays, compiling, rebooting, and Linux driver binding.

1// Minimal platform driver showing how Linux matches a device-tree node.
2#include <linux/module.h>
3#include <linux/of.h>
4#include <linux/platform_device.h>
5
6static int drhyme_probe(struct platform_device *pdev)
7{
8 const char *label = "unnamed";
9
10 of_property_read_string(pdev->dev.of_node, "label", &label);
11 dev_info(&pdev->dev, "matched device-tree node: %s\n", label);
12 return 0;
13}
14
15static const struct of_device_id drhyme_of_match[] = {
16 { .compatible = "digital-rhyme,orin-demo" },
17 { }
18};
19MODULE_DEVICE_TABLE(of, drhyme_of_match);
20
21static struct platform_driver drhyme_driver = {
22 .probe = drhyme_probe,
23 .driver = {
24 .name = "drhyme-dt-demo",
25 .of_match_table = drhyme_of_match,
26 },
27};
28module_platform_driver(drhyme_driver);
29
30MODULE_LICENSE("GPL");
31MODULE_DESCRIPTION("Device-tree platform-driver match example");