2
votes

I am currently working on an embedded device with Linux (based on Freescale i.MX6). My platform is DT-enabled (that is all devices instantiation origins from the flattened device tree and not from the board initialization source file).

In such a context I am in need to instantiate a device which makes use of a driver that has not been ported to DT yet... is it possible? I mean: is it possible to mix devices instantiated via device tree and devices instantiated the old way (e.g. through i2c_register_board_info for I2C devices)?

If so, is it also possible to pass platform data to the old-style driver using the usual way (e.g. through struct i2c_board_info for I2C devices)? Or, being the platform DT-based, then .platform_data field in struct i2c_board_info will always be NULL?

Are you aware of some examples available on the web?

Thanks.

1
"...is it possible?" -- Yes, even when using a DT, there can also be a board file. For example in github.com/linux4sam/linux-at91/blob/linux-3.10-at91/arch/arm/… , there are a few platform_device and platform_data structures (as well as calls to of_* procedures to retrieve FDT values).sawdust

1 Answers

0
votes

I think you are looking to instantiate a platform driver in a traditional way rather than binding with device tree.

You should refer to this function below and the usage in the kernel.

static inline struct platform_device *platform_device_register_data(
        struct device *parent, const char *name, int id,
        const void *data, size_t size)

Ref: https://elixir.bootlin.com/linux/latest/source/include/linux/platform_device.h#L160

This function can be called to register any platform driver and the platform data can be passed to this driver from a parent driver, which was probed from device tree (DT).