Message ID | 20190819121618.16557-3-max@enpas.org (mailing list archive) |
---|---|
State | Not Applicable |
Headers | show |
Series | [v5,1/3] i2c/busses: Add i2c-icy for I2C on m68k/Amiga | expand |
On Mon, Aug 19, 2019 at 2:17 PM Max Staudt <max@enpas.org> wrote: > Since the 2019 a1k.org community re-print of these PCBs sports an > LTC2990 hwmon chip as an example use case, let this driver autoprobe > for that as well. If it is present, modprobing ltc2990 is sufficient. > > The property_entry enables the three additional inputs available on > this particular board: > > in1 will be the voltage of the 5V rail, divided by 2. > in2 will be the voltage of the 12V rail, divided by 4. > temp3 will be measured using a PCB loop next the chip. > > v5: Style > > v4: Style > Added other possible addresses for LTC2990. > > v3: Merged with initial LTC2990 support on ICY. > Moved defaults from platform_data to swnode. > Added note to Kconfig. > > Signed-off-by: Max Staudt <max@enpas.org> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org> One comment below... > --- a/drivers/i2c/busses/i2c-icy.c > +++ b/drivers/i2c/busses/i2c-icy.c > @@ -141,6 +166,35 @@ static int icy_probe(struct zorro_dev *z, > dev_info(&z->dev, "ICY I2C controller at %pa, IRQ not implemented\n", > &z->resource.start); > > + /* > + * The 2019 a1k.org PCBs have an LTC2990 at 0x4c, so start > + * it automatically once ltc2990 is modprobed. > + * > + * in0 is the voltage of the internal 5V power supply. > + * temp1 is the temperature inside the chip. > + * > + * See property_entry above for in1, in2, temp3. > + */ > + new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL); > + if (IS_ERR(new_fwnode)) { > + dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n", > + PTR_ERR(new_fwnode)); > + } else { > + /* > + * Store the fwnode so we can destroy it on .remove(). > + * Only store it on success, as fwnode_remove_software_node() > + * is NULL safe, but not PTR_ERR safe. > + */ > + i2c->ltc2990_fwnode = new_fwnode; > + ltc2990_info.fwnode = new_fwnode; > + > + i2c->ltc2990_client = > + i2c_new_probed_device(&i2c->adapter, > + <c2990_info, > + icy_ltc2990_addresses, > + NULL); > + } > + > return 0; > } Since commit d3e1b617ae20c459 ("i2c: allow specify device properties in i2c_board_info"), the properties could be provided by info->properties, too. However, according to the comments for device_add_properties(), this is valid only if there is a real firmware node present. If that is true, Max' use is correct, while e.g. commit 6a7836ba7fb4abf6 ("ARM: imx: pca100: use device properties for at24 eeprom") isn't? Gr{oetje,eeting}s, Geert
On August 20, 2019 11:18:36 AM GMT+02:00, Geert Uytterhoeven <geert@linux-m68k.org> wrote: >Since commit d3e1b617ae20c459 ("i2c: allow specify device properties in >i2c_board_info"), the properties could be provided by info->properties, >too. >However, according to the comments for device_add_properties(), this is >valid only if there is a real firmware node present. > >If that is true, Max' use is correct, while e.g. commit >6a7836ba7fb4abf6 >("ARM: imx: pca100: use device properties for at24 eeprom") isn't? Yup, I saw that too. Any hints would be greatly appreciated! Max
On Mon, Aug 19, 2019 at 02:16:18PM +0200, Max Staudt wrote: > Since the 2019 a1k.org community re-print of these PCBs sports an > LTC2990 hwmon chip as an example use case, let this driver autoprobe > for that as well. If it is present, modprobing ltc2990 is sufficient. > > The property_entry enables the three additional inputs available on > this particular board: > > in1 will be the voltage of the 5V rail, divided by 2. > in2 will be the voltage of the 12V rail, divided by 4. > temp3 will be measured using a PCB loop next the chip. > > v5: Style > > v4: Style > Added other possible addresses for LTC2990. > > v3: Merged with initial LTC2990 support on ICY. > Moved defaults from platform_data to swnode. > Added note to Kconfig. > > Signed-off-by: Max Staudt <max@enpas.org> Applied to for-next, thanks!
diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index 9e57e1101..a311d07f3 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -1311,6 +1311,9 @@ config I2C_ICY This support is also available as a module. If so, the module will be called i2c-icy. + If you have a 2019 edition board with an LTC2990 sensor at address + 0x4c, loading the module 'ltc2990' is sufficient to enable it. + config I2C_MLXCPLD tristate "Mellanox I2C driver" depends on X86_64 diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c index 20c0fbacf..6dd303dc1 100644 --- a/drivers/i2c/busses/i2c-icy.c +++ b/drivers/i2c/busses/i2c-icy.c @@ -53,6 +53,8 @@ struct icy_i2c { void __iomem *reg_s0; void __iomem *reg_s1; + struct fwnode_handle *ltc2990_fwnode; + struct i2c_client *ltc2990_client; }; /* @@ -95,11 +97,34 @@ static void icy_pcf_waitforpin(void *data) /* * Main i2c-icy part */ +static unsigned short const icy_ltc2990_addresses[] = { + 0x4c, 0x4d, 0x4e, 0x4f, I2C_CLIENT_END +}; + +/* + * Additional sensors exposed once this property is applied: + * + * in1 will be the voltage of the 5V rail, divided by 2. + * in2 will be the voltage of the 12V rail, divided by 4. + * temp3 will be measured using a PCB loop next the chip. + */ +static const u32 icy_ltc2990_meas_mode[] = {0, 3}; + +static const struct property_entry icy_ltc2990_props[] = { + PROPERTY_ENTRY_U32_ARRAY("lltc,meas-mode", icy_ltc2990_meas_mode), + { } +}; + static int icy_probe(struct zorro_dev *z, const struct zorro_device_id *ent) { struct icy_i2c *i2c; struct i2c_algo_pcf_data *algo_data; + struct fwnode_handle *new_fwnode; + struct i2c_board_info ltc2990_info = { + .type = "ltc2990", + .addr = 0x4c, + }; i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL); if (!i2c) @@ -141,6 +166,35 @@ static int icy_probe(struct zorro_dev *z, dev_info(&z->dev, "ICY I2C controller at %pa, IRQ not implemented\n", &z->resource.start); + /* + * The 2019 a1k.org PCBs have an LTC2990 at 0x4c, so start + * it automatically once ltc2990 is modprobed. + * + * in0 is the voltage of the internal 5V power supply. + * temp1 is the temperature inside the chip. + * + * See property_entry above for in1, in2, temp3. + */ + new_fwnode = fwnode_create_software_node(icy_ltc2990_props, NULL); + if (IS_ERR(new_fwnode)) { + dev_info(&z->dev, "Failed to create fwnode for LTC2990, error: %ld\n", + PTR_ERR(new_fwnode)); + } else { + /* + * Store the fwnode so we can destroy it on .remove(). + * Only store it on success, as fwnode_remove_software_node() + * is NULL safe, but not PTR_ERR safe. + */ + i2c->ltc2990_fwnode = new_fwnode; + ltc2990_info.fwnode = new_fwnode; + + i2c->ltc2990_client = + i2c_new_probed_device(&i2c->adapter, + <c2990_info, + icy_ltc2990_addresses, + NULL); + } + return 0; } @@ -148,6 +202,9 @@ static void icy_remove(struct zorro_dev *z) { struct icy_i2c *i2c = dev_get_drvdata(&z->dev); + i2c_unregister_device(i2c->ltc2990_client); + fwnode_remove_software_node(i2c->ltc2990_fwnode); + i2c_del_adapter(&i2c->adapter); }
Since the 2019 a1k.org community re-print of these PCBs sports an LTC2990 hwmon chip as an example use case, let this driver autoprobe for that as well. If it is present, modprobing ltc2990 is sufficient. The property_entry enables the three additional inputs available on this particular board: in1 will be the voltage of the 5V rail, divided by 2. in2 will be the voltage of the 12V rail, divided by 4. temp3 will be measured using a PCB loop next the chip. v5: Style v4: Style Added other possible addresses for LTC2990. v3: Merged with initial LTC2990 support on ICY. Moved defaults from platform_data to swnode. Added note to Kconfig. Signed-off-by: Max Staudt <max@enpas.org> --- drivers/i2c/busses/Kconfig | 3 +++ drivers/i2c/busses/i2c-icy.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+)