i2c/busses: Add i2c-icy for I2C on m68k/Amiga
Subsystems (3)
Max Staudt
maintainerPATCH v3 1/3 i2c/busses: Add i2c-icy for I2C on m68k/Amiga
This is the i2c-icy driver for the ICY board for Amiga computers. It connects a PCF8584 I2C controller to the Zorro bus, providing I2C connectivity. The original documentation can be found on Aminet:
https://aminet.net/package/docs/hard/icy
IRQ support is currently not implemented, as i2c-algo-pcf is built for the ISA bus and a straight implementation of the same stack locks up a Zorro machine.
v3: Fixed %pa format string
Dropped adapter class.
Clarified licence.
Removed clock parameter.
v2: Matched function names to callbacks from i2c-algo-pcf
Used z_readb()/z_writeb()
Removed BROKEN_ON_SMP in Kconfig
Moved LTC2990 to a separate commit
--- MAINTAINERS | 6 ++ drivers/i2c/busses/Kconfig | 11 +++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-icy.c | 183 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 201 insertions(+) create mode 100644 drivers/i2c/busses/i2c-icy.c
MAINTAINERS +6 -0
@@ -7705,6 +7705,12 @@ S: Maintained F: drivers/mfd/lpc_ich.c F: drivers/gpio/gpio-ich.c +ICY I2C DRIVER +M: Max Staudt <[email protected]> +L: [email protected] +S: Maintained +F: drivers/i2c/busses/i2c-icy.c + IDE SUBSYSTEM M: "David S. Miller" <[email protected]> L: [email protected]
drivers/i2c/busses/Kconfig +11 -0
@@ -1300,6 +1300,17 @@ config I2C_ELEKTOR This support is also available as a module. If so, the module will be called i2c-elektor. +config I2C_ICY + tristate "ICY Zorro card" + depends on ZORRO + select I2C_ALGOPCF + help + This supports the PCF8584 Zorro bus I2C adapter, known as ICY. + Say Y if you own such an adapter. + + This support is also available as a module. If so, the module + will be called i2c-icy. + config I2C_MLXCPLD tristate "Mellanox I2C driver" depends on X86_64
drivers/i2c/busses/Makefile +1 -0
@@ -139,6 +139,7 @@ obj-$(CONFIG_I2C_BCM_KONA) += i2c-bcm-kona.o obj-$(CONFIG_I2C_BRCMSTB) += i2c-brcmstb.o obj-$(CONFIG_I2C_CROS_EC_TUNNEL) += i2c-cros-ec-tunnel.o obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o +obj-$(CONFIG_I2C_ICY) += i2c-icy.o obj-$(CONFIG_I2C_MLXCPLD) += i2c-mlxcpld.o obj-$(CONFIG_I2C_OPAL) += i2c-opal.o obj-$(CONFIG_I2C_PCA_ISA) += i2c-pca-isa.o
drivers/i2c/busses/i2c-icy.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.11.0
Max Staudt
maintainerPATCH v3 2/3 hwmon/ltc2990: Generalise DT to fwnode support
ltc2990 will now use device_property_read_u32_array() instead of of_property_read_u32_array() - allowing the use of software nodes via fwnode_create_software_node().
This allows code using i2c_new_device() to specify a default measurement mode for the LTC2990.
--- drivers/hwmon/ltc2990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/ltc2990.c +4 -4
@@ -206,7 +206,6 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,int ret;struct device *hwmon_dev;struct ltc2990_data *data; -struct device_node *of_node = i2c->dev.of_node;if (!i2c_check_functionality (i2c->adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))
@@ -218,9 +217,10 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, data->i2c = i2c; -if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (i2c->dev.of_node || i2c->dev.fwnode) { + ret =device_property_read_u32_array (&i2c->dev, +"lltc,meas-mode" , + data->mode,2 );if (ret <0 )return ret;
Signature · 1 line
2.11.0
Re: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 8 lines · Max Staudt
ltc2990 will now use
device_property_read_u32_array()instead ofof_property_read_u32_array()- allowing the use of software nodes viafwnode_create_software_node().This allows code using
i2c_new_device()to specify a default measurement mode for the LTC2990.Signed-off-by Max Staudt <[email protected]>
Applied to hwmon-next.
Thanks,
Guenter
Max Staudt
maintainerRe: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 11 lines · Guenter Roeck
Quoted 8 lines · Max Staudt
ltc2990 will now use
device_property_read_u32_array()instead ofof_property_read_u32_array()- allowing the use of software nodes viafwnode_create_software_node().This allows code using
i2c_new_device()to specify a default measurement mode for the LTC2990.Signed-off-by Max Staudt <[email protected]>Applied to hwmon-next.
Hi Guenter,
Thank you for reviewing and taking this patch, as well as teaching me about swnode.
Max
Max Staudt
maintainerRe: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
In reply to Max Staudtdrivers/hwmon/ltc2990.c static int ltc2990_i2c_probe(struct i2c_client *i2c, · line 220
Quoted 4 lines · Max Staudt
drivers/hwmon/ltc2990.c +1
-3-if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (i2c->dev.of_node || i2c->dev.fwnode) {
One more idea, would it be better here to do the following?
if (device_property_present(i2c->dev, "lltc,meas-mode")) {
ret = of_property_read_u32_array(of_node, "lltc,meas-mode",
data->mode, 2);
}I'm happy to prepare a patch if you wish to have this in - just let me know whether it should be on top of the last one, or instead of it.
Thanks,
Max
Guenter Roeck
maintainerRe: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 8 lines · Max Staudt
drivers/hwmon/ltc2990.c static int ltc2990_i2c_probe(struct i2c_client *i2c, · line 220
Quoted 4 lines · Max Staudt
drivers/hwmon/ltc2990.c +1
-3-if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (i2c->dev.of_node || i2c->dev.fwnode) {One more idea, would it be better here to do the following?
Quoted 6 lines
if (device_property_present(i2c->dev, "lltc,meas-mode")) { ret = of_property_read_u32_array(of_node, "lltc,meas-mode", data->mode, 2); }I'm happy to prepare a patch if you wish to have this in - just let me know whether it should be on top of the last one, or instead of it.
That would be semantically different. The property is currently mandatory. The above code would make it optional. This might work:
if (dev_fwnode(&i2c->dev)) {
ret = device_property_read_u32_array(...);
...
}Feel free to send another version of your patch.
Thanks,
Guenter
Re: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 6 lines · Guenter Roeck
Quoted 5 lines · Max Staudt
drivers/hwmon/ltc2990.c static int ltc2990_i2c_probe(struct i2c_client *i2c, · line 220
Quoted 4 lines · Max Staudt
drivers/hwmon/ltc2990.c +1
-3-if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (i2c->dev.of_node || i2c->dev.fwnode) {
I was just going to comment on this check...
Quoted 9 lines
Quoted 8 lines
One more idea, would it be better here to do the following?
if (device_property_present(i2c->dev, "lltc,meas-mode")) { ret = of_property_read_u32_array(of_node, "lltc,meas-mode", data->mode, 2); }I'm happy to prepare a patch if you wish to have this in - just let me know whether it should be on top of the last one, or instead of it.
Quoted 7 lines
That would be semantically different. The property is currently mandatory. The above code would make it optional. This might work:
if (dev_fwnode(&i2c->dev)) { ret = device_property_read_u32_array(...); ... }
Much better, thanks!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Max Staudt
maintainerRe: [PATCH v3 2/3] hwmon/ltc2990: Generalise DT to fwnode support
In reply to Guenter RoeckQuoted 16 lines · Guenter Roeck
Quoted 8 lines · Max Staudt
drivers/hwmon/ltc2990.c static int ltc2990_i2c_probe(struct i2c_client *i2c, · line 220
Quoted 4 lines · Max Staudt
drivers/hwmon/ltc2990.c +1
-3-if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (i2c->dev.of_node || i2c->dev.fwnode) {One more idea, would it be better here to do the following?
Quoted 6 lines
if (device_property_present(i2c->dev, "lltc,meas-mode")) { ret = of_property_read_u32_array(of_node, "lltc,meas-mode", data->mode, 2); }I'm happy to prepare a patch if you wish to have this in - just let me know whether it should be on top of the last one, or instead of it.
Quoted 7 lines
That would be semantically different. The property is currently mandatory. The above code would make it optional. This might work:
if (dev_fwnode(&i2c->dev)) { ret = device_property_read_u32_array(...); ... }
Fair point. The semantic change was part of my question, but the more I think about it, the less I want to open this can of worms. We can still make the property optional later on, while it's not as easy to make it mandatory.
I'll send a patch with your suggestion.
Thanks!
Max
Max Staudt
maintainerPATCH 1/1 hwmon/ltc2990: Generalise DT to fwnode support
ltc2990 will now use device_property_read_u32_array() instead of of_property_read_u32_array() - allowing the use of software nodes via fwnode_create_software_node().
This allows code using i2c_new_device() to specify a default measurement mode for the LTC2990 via fwnode_create_software_node().
--- drivers/hwmon/ltc2990.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/ltc2990.c +4 -4
@@ -206,7 +206,6 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,int ret;struct device *hwmon_dev;struct ltc2990_data *data; -struct device_node *of_node = i2c->dev.of_node;if (!i2c_check_functionality (i2c->adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))
@@ -218,9 +217,10 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, data->i2c = i2c; -if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (dev_fwnode (&i2c->dev)) { + ret =device_property_read_u32_array (&i2c->dev, +"lltc,meas-mode" , + data->mode,2 );if (ret <0 )return ret;
Signature · 1 line
2.11.0
Re: [PATCH] hwmon/ltc2990: Generalise DT to fwnode support
Hi Max,
Quoted 8 lines · Max Staudt
ltc2990 will now use
device_property_read_u32_array()instead ofof_property_read_u32_array()- allowing the use of software nodes viafwnode_create_software_node().This allows code using
i2c_new_device()to specify a default measurement mode for the LTC2990 viafwnode_create_software_node().Signed-off-by Max Staudt <[email protected]>
Thanks for your patch!
One minor nit: as the driver no longer uses any of_*() symbols, you can replace #include <linux/of.h> by #include <linux/property.h>.
Quoted 13 lines
drivers/hwmon/ltc2990.c +0
-1@@ -206,7 +206,6 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c,int ret;struct device *hwmon_dev;struct ltc2990_data *data; -struct device_node *of_node = i2c->dev.of_node;if (!i2c_check_functionality (i2c->adapter,I2C_FUNC_SMBUS_BYTE_DATA |I2C_FUNC_SMBUS_WORD_DATA ))@@ -218,9 +217,10 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, data->i2c = i2c;
drivers/hwmon/ltc2990.c static int ltc2990_i2c_probe(struct i2c_client *i2c, · line 225
Quoted 10 lines
drivers/hwmon/ltc2990.c +4
-3-if (of_node) { - ret =of_property_read_u32_array (of_node,"lltc,meas-mode" , - data->mode,2 ); +if (dev_fwnode (&i2c->dev)) { + ret =device_property_read_u32_array (&i2c->dev, +"lltc,meas-mode" , + data->mode,2 );if (ret <0 )return ret;
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Max Staudt
maintainerRe: [PATCH] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 1 line · Geert Uytterhoeven
Reviewed-by Geert Uytterhoeven <[email protected]>
Thank you!
Quoted 2 lines
One minor nit: as the driver no longer uses any of_*() symbols, you can replace #include <
linux/of.h> by #include <linux/property.h>.
I should have thought of that, sorry.
Another patch, or will you do it?
Max
Re: [PATCH] hwmon/ltc2990: Generalise DT to fwnode support
Hi Max,
Quoted 7 lines · Max Staudt
Quoted 2 lines · Geert Uytterhoeven
One minor nit: as the driver no longer uses any of_*() symbols, you can replace #include <
linux/of.h> by #include <linux/property.h>.I should have thought of that, sorry.
Another patch, or will you do it?
As the patch won't go through my tree, I cannot, but the hwmon maintainer might do.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Max Staudt
maintainerRe: [PATCH] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 7 lines · Geert Uytterhoeven
Hi Max,
Quoted 4 lines · Max Staudt
Quoted 2 lines · Geert Uytterhoeven
One minor nit: as the driver no longer uses any of_*() symbols, you can replace #include <
linux/of.h> by #include <linux/property.h>.
Quoted 6 lines
Quoted 3 lines
I should have thought of that, sorry.
Another patch, or will you do it?
As the patch won't go through my tree, I cannot, but the hwmon maintainer might do.
As I'll be fixing one of the I2C patches, I'll send an updated hwmon patch with it.
Thanks!
Max
Guenter Roeck
maintainerRe: [PATCH] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 8 lines · Max Staudt
Quoted 7 lines · Geert Uytterhoeven
Hi Max,
Quoted 4 lines · Max Staudt
Quoted 2 lines · Geert Uytterhoeven
One minor nit: as the driver no longer uses any of_*() symbols, you can replace #include <
linux/of.h> by #include <linux/property.h>.
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
I should have thought of that, sorry.
Another patch, or will you do it?
As the patch won't go through my tree, I cannot, but the hwmon maintainer might do.
As I'll be fixing one of the I2C patches, I'll send an updated hwmon patch with it.
Ok, I'll wait for that patch.
Guenter
Max Staudt
maintainerPATCH v3 3/3 i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
In reply to Max StaudtSince 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.
v3: Merged with initial LTC2990 support on ICY.
Moved defaults from platform_data to swnode.
Added note to Kconfig.
--- drivers/i2c/busses/Kconfig | 3 +++ drivers/i2c/busses/i2c-icy.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
drivers/i2c/busses/Kconfig +3 -0
@@ -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
drivers/i2c/busses/i2c-icy.c +56 -0
85 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v3 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 187
Quoted 5 lines
drivers/i2c/busses/i2c-icy.c +4
-0+if (IS_ERR (new_fwnode)) +dev_info (&z->dev,"Failed to create fwnode for LTC2990, error: %ld\n" , +PTR_ERR (new_fwnode)); +else {
Braces for both blocks. Did you run checkpatch?
drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 200
Quoted 13 lines
drivers/i2c/busses/i2c-icy.c +13
-0+/* +* 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 );
i2c_new_device (or better, the new i2c_new_client_device) should be sufficient, or? You only have one potential address.
Max Staudt
maintainerRe: [PATCH v3 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
Quoted 7 lines · Wolfram Sang
drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 187
Quoted 5 lines
drivers/i2c/busses/i2c-icy.c +4
-0+if (IS_ERR (new_fwnode)) +dev_info (&z->dev,"Failed to create fwnode for LTC2990, error: %ld\n" , +PTR_ERR (new_fwnode)); +else {Braces for both blocks. Did you run checkpatch?
I did, and it didn't say anything.
Turns out I misremembered the CodingStyle as having a corner case where it doesn't. I'll fix the style - I dislike the above, too ;)
Quoted 8 lines
Quoted 8 lines
drivers/i2c/busses/i2c-icy.c +8
-0+/* +* 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; +
Quoted 8 lines
drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 200
Quoted 5 lines
drivers/i2c/busses/i2c-icy.c +5
-0+ i2c->ltc2990_client = +i2c_new_probed_device (&i2c->adapter, + <c2990_info, + icy_ltc2990_addresses, +NULL );
i2c_new_device(or better, the newi2c_new_client_device) should be sufficient, or? You only have one potential address.
Yes and no. Now that you mention it - the LTC2990 can be at four addresses (0x4c - 0x4f), and there are jumpers (solder pads) on the PCB to select its address. Shall I add all 4 addresses to the array?
It's also possible that there is no LTC2990 at all (because it's hard to solder at home), and that's why we need to probe for it first. I believe i2c_new[_client]_device doesn't do probing, but rather assumes the device to be there. Correct?
Max
Re: [PATCH v3 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
Quoted 4 lines
Quoted 2 lines
Braces for both blocks. Did you run checkpatch?
I did, and it didn't say anything.
Hmm, strange, does is complain when you use '--strict'?
Quoted 2 lines
Turns out I misremembered the CodingStyle as having a corner case where it doesn't. I'll fix the style - I dislike the above, too ;)
Thanks!
Quoted 3 lines
Yes and no. Now that you mention it - the LTC2990 can be at four addresses (
0x4c-0x4f), and there are jumpers (solder pads) on the PCB to select its address. Shall I add all 4 addresses to the array?
Yes, please.
Quoted 4 lines
It's also possible that there is no LTC2990 at all (because it's hard to solder at home), and that's why we need to probe for it first. I believe i2c_new[_client]_device doesn't do probing, but rather assumes the device to be there. Correct?
Correct. I assumed the sensor is always there. But it is not and can be at multiple addresses, so updating the array of addresses is the right thing to do(tm).
Max Staudt
maintainerRe: [PATCH v3 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
Quoted 6 lines · Wolfram Sang
Quoted 4 lines
Quoted 2 lines
Braces for both blocks. Did you run checkpatch?
I did, and it didn't say anything.
Hmm, strange, does is complain when you use '--strict'?
Yes, --strict catches it. Thanks, I didn't know about that parameter.
I'll send a v5 with all requested fixes.
Max