Skip to contentSkip to conversation

I2C device tree driver compatible strings

PATCH Jakub Kiciński 2 participants 2 messages Apr 11, 2015 – Apr 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hello,

sc16is7xx declares two device id tables, one with OF ids:

static const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = {
	{ .compatible = "nxp,sc16is740",	.data = &sc16is74x_devtype, },
	{ .compatible = "nxp,sc16is741",	.data = &sc16is74x_devtype, },
	{ .compatible = "nxp,sc16is750",	.data = &sc16is750_devtype, },	
	{ .compatible = "nxp,sc16is752",	.data = &sc16is752_devtype, },
	{ .compatible = "nxp,sc16is760",	.data = &sc16is760_devtype, },
	{ .compatible = "nxp,sc16is762",	.data = &sc16is762_devtype, },
	{ }
};

MODULE_DEVICE_TABLE(of, sc16is7xx_dt_ids);

and one with i2c ids:

static const struct i2c_device_id sc16is7xx_i2c_id_table[] = {
	{ "sc16is74x",	(kernel_ulong_t)&sc16is74x_devtype, },
	{ "sc16is750",	(kernel_ulong_t)&sc16is750_devtype, },
	{ "sc16is752",	(kernel_ulong_t)&sc16is752_devtype, },
	{ "sc16is760",	(kernel_ulong_t)&sc16is760_devtype, },
	{ "sc16is762",	(kernel_ulong_t)&sc16is762_devtype, },
	{ }
};

MODULE_DEVICE_TABLE(i2c, sc16is7xx_i2c_id_table);

I declare my device in DT under I2C controller as

Quoted 1 line
	compatible = "nxp,sc16is740";

However, the driver does not get loaded automatically because its i2c id table contains "sc16is74x" instead of "sc16is740".

I have three questions:

(1) What is the relation between i2c_device_id and of_device_id strings and why does the driver define both?

(2) What are the rules for loading i2c drivers based on DT and why is the driver not loaded even though its compatible with one of the OF ids?

(3) Is it OK for the driver to define incompatible strings or should I correct them like this (keeping the old entry for backwards compatibility):

(quoted diff) +0 -0

b/drivers/tty/serial/sc16is7xx.c index eaf0008a39cb..efe286d00174 100644

drivers/tty/serial/sc16is7xx.c +0 -0
@@ -1219,6 +1219,8 @@ static int sc16is7xx_i2c_remove(struct i2c_client

*client)

 static const struct i2c_device_id sc16is7xx_i2c_id_table[] = {
        { "sc16is74x",  (kernel_ulong_t)&sc16is74x_devtype, },
+       { "sc16is740",  (kernel_ulong_t)&sc16is74x_devtype, },
+       { "sc16is741",  (kernel_ulong_t)&sc16is74x_devtype, },
        { "sc16is750",  (kernel_ulong_t)&sc16is750_devtype, },
        { "sc16is752",  (kernel_ulong_t)&sc16is752_devtype, },
        { "sc16is760",  (kernel_ulong_t)&sc16is760_devtype, },

Thanks,
Kuba
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

CC linux-i2c

Quoted 65 lines · Jakub Kiciński

Hello,

sc16is7xx declares two device id tables, one with OF ids:

static const struct of_device_id __maybe_unused sc16is7xx_dt_ids[] = {
        { .compatible = "nxp,sc16is740",        .data = &sc16is74x_devtype, },
        { .compatible = "nxp,sc16is741",        .data = &sc16is74x_devtype, },
        { .compatible = "nxp,sc16is750",        .data = &sc16is750_devtype, },
        { .compatible = "nxp,sc16is752",        .data = &sc16is752_devtype, },
        { .compatible = "nxp,sc16is760",        .data = &sc16is760_devtype, },
        { .compatible = "nxp,sc16is762",        .data = &sc16is762_devtype, },
        { }
};

MODULE_DEVICE_TABLE(of, sc16is7xx_dt_ids);

and one with i2c ids:

static const struct i2c_device_id sc16is7xx_i2c_id_table[] = {
        { "sc16is74x",  (kernel_ulong_t)&sc16is74x_devtype, },
        { "sc16is750",  (kernel_ulong_t)&sc16is750_devtype, },
        { "sc16is752",  (kernel_ulong_t)&sc16is752_devtype, },
        { "sc16is760",  (kernel_ulong_t)&sc16is760_devtype, },
        { "sc16is762",  (kernel_ulong_t)&sc16is762_devtype, },
        { }
};

MODULE_DEVICE_TABLE(i2c, sc16is7xx_i2c_id_table);

I declare my device in DT under I2C controller as

Quoted 1 line
      compatible = "nxp,sc16is740";

However, the driver does not get loaded automatically because its i2c id table contains "sc16is74x" instead of "sc16is740".

I have three questions:

(1) What is the relation between i2c_device_id and of_device_id strings and why does the driver define both?

(2) What are the rules for loading i2c drivers based on DT and why is the driver not loaded even though its compatible with one of the OF ids?

(3) Is it OK for the driver to define incompatible strings or should I correct them like this (keeping the old entry for backwards compatibility):

(quoted diff) +0 -0

b/drivers/tty/serial/sc16is7xx.c index eaf0008a39cb..efe286d00174 100644

drivers/tty/serial/sc16is7xx.c +2 -0
@@ -1219,6 +1219,8 @@ static int sc16is7xx_i2c_remove(struct i2c_client
 *client)
 static const struct i2c_device_id sc16is7xx_i2c_id_table[] = {
        { "sc16is74x",  (kernel_ulong_t)&sc16is74x_devtype, },
+       { "sc16is740",  (kernel_ulong_t)&sc16is74x_devtype, },
+       { "sc16is741",  (kernel_ulong_t)&sc16is74x_devtype, },
        { "sc16is750",  (kernel_ulong_t)&sc16is750_devtype, },
        { "sc16is752",  (kernel_ulong_t)&sc16is752_devtype, },
        { "sc16is760",  (kernel_ulong_t)&sc16is760_devtype, },

Thanks,
Kuba
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html