October 2017
Intermediate to advanced
586 pages
14h 8m
English
Devices are registered along with their resources and data. In this old and deprecated method, they are declared in a separate module, or in the board init file in the arch/<arch>/mach-xxx/yyyy.c, which is arch/arm/mach-imx/mach-imx6q.c in our case, since we use a UDOO quad based on an i.MX6Q from NXP. The platform_device_register() function lets you do that:
static struct platform_device my_device = {
.name = "my_drv_name",
.id = 0,
.dev.platform_data = &my_device_pdata,
.resource = jz4740_udc_resources,
.num_resources = ARRY_SIZE(jz4740_udc_resources),
};
platform_device_register(&my_device);
The name of the device is very important, and is used by the kernel to match the driver with the same name.