i2c/busses: Add i2c-icy for I2C on m68k/Amiga
Subsystems (3)
Max Staudt
maintainerPATCH v5 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.
v5: usleep_range() instead of udelay()
Style
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 | 174 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 192 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 +174 -0
174 lines not on this page · raw message
Signature · 1 line
2.11.0
Max Staudt
maintainerPATCH v5 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 via fwnode_create_software_node().
--- drivers/hwmon/ltc2990.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/hwmon/ltc2990.c +5 -5
@@ -13,7 +13,7 @@#include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/property.h> #define LTC2990_STATUS 0x00#define LTC2990_CONTROL 0x01
@@ -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 v5 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 viafwnode_create_software_node().Signed-off-by Max Staudt <[email protected]>
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
Re: [PATCH v5 2/3] hwmon/ltc2990: Generalise DT to fwnode support
In reply to Max StaudtQuoted 9 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]>Reviewed-by Geert Uytterhoeven <[email protected]>
Applied to hwmon-next.
Thanks,
Guenter
Quoted 39 lines
--- drivers/hwmon/ltc2990.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/hwmon/ltc2990.c +5
-5@@ -13,7 +13,7 @@#include <linux/i2c.h> #include <linux/kernel.h> #include <linux/module.h> -#include <linux/of.h> +#include <linux/property.h> #define LTC2990_STATUS 0x00#define LTC2990_CONTROL 0x01@@ -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;
Max Staudt
maintainerRe: [PATCH v5 2/3] hwmon/ltc2990: Generalise DT to fwnode support
Quoted 8 lines · Guenter Roeck
Quoted 7 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().
Quoted 7 lines
Quoted 2 lines
Signed-off-by Max Staudt <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Applied to hwmon-next.
Thanks,
Guenter
Thanks for your help, reviewing, and applying!
Max
Max Staudt
maintainerPATCH v5 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.
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.
--- drivers/i2c/busses/Kconfig | 3 +++ drivers/i2c/busses/i2c-icy.c | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 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 +57 -0
86 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v5 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
Quoted 13 lines · Max Staudt
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_entryenables 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
Quoted 8 lines
v4: Style
Added other possible addresses for LTC2990.v3: Merged with initial LTC2990 support on ICY.
Moved defaults fromplatform_datato swnode.
Added note toKconfig.Signed-off-by Max Staudt <[email protected]>
One comment below...
Quoted 28 lines
drivers/i2c/busses/i2c-icy.c +21
-0@@ -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;
drivers/i2c/busses/i2c-icy.c static int icy_probe(struct zorro_dev *z, · line 199
Quoted 10 lines
drivers/i2c/busses/i2c-icy.c +8
-0+ + 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
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
maintainerRe: [PATCH v5 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
Quoted 9 lines · Geert Uytterhoeven
Since commit
d3e1b617ae20c459("i2c: allow specify device properties ini2c_board_info"), the properties could be provided byinfo->properties, too.
However, according to the comments fordevice_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
Wolfram Sang
AppliedRe: [PATCH v5 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision
In reply to Max StaudtQuoted 13 lines · Max Staudt
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_entryenables 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
Quoted 8 lines
v4: Style
Added other possible addresses for LTC2990.v3: Merged with initial LTC2990 support on ICY.
Moved defaults fromplatform_datato swnode.
Added note toKconfig.Signed-off-by Max Staudt <[email protected]>
Applied to for-next, thanks!
Quoted 18 lines · Max Staudt
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.
v5:
usleep_range()instead ofudelay()
Stylev3: Fixed %pa format string
Dropped adapter class.
Clarified licence.
Removed clock parameter.
Quoted 6 lines
v2: Matched function names to callbacks from i2c-algo-pcf
Used z_readb()/z_writeb()
RemovedBROKEN_ON_SMPinKconfig
Moved LTC2990 to a separate commitSigned-off-by Max Staudt <[email protected]>
drivers/i2c/busses/i2c-icy.c line 77
Quoted 11 lines
drivers/i2c/busses/i2c-icy.c new file +8
-0+static int icy_pcf_getpcf (void *data,int ctl) +{ +struct icy_i2c *i2c = (struct icy_i2c *)data; + +u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; +int val =z_readb (address); + +return val;
return z_readb(address);
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
maintainerQuoted 5 lines · Geert Uytterhoeven
drivers/i2c/busses/i2c-icy.c line 77
Quoted 3 lines
drivers/i2c/busses/i2c-icy.c new file +3
-0+int val =z_readb (address); + +return val;return
z_readb(address);
Argh, that slipped through the cracks. I'll mend it later. Thank you.
Max
Max Staudt
maintainerPATCH 1/1 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.
v5: usleep_range() instead of udelay()
Style
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 | 172 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 190 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 +172 -0
172 lines not on this page · raw message
Signature · 1 line
2.11.0
Quoted 18 lines · Max Staudt
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.
v5:
usleep_range()instead ofudelay()
Stylev3: Fixed %pa format string
Dropped adapter class.
Clarified licence.
Removed clock parameter.
Quoted 4 lines
v2: Matched function names to callbacks from i2c-algo-pcf
Used z_readb()/z_writeb()
RemovedBROKEN_ON_SMPinKconfig
Moved LTC2990 to a separate commit
Thanks for the changelog; it should go below the '---' line, however.
Quoted 2 lines
Signed-off-by Max Staudt <[email protected]>
Fixed a freshly introduced checkpatch warning for you.
But most importantly, applied to for-next, thanks!
Max Staudt
maintainerQuoted 1 line · Wolfram Sang
Thanks for the changelog; it should go below the '---' line, however.
Thanks if you fixed it up!
Quoted 1 line
Fixed a freshly introduced checkpatch warning for you.
Ditto.
Quoted 1 line
But most importantly, applied to for-next, thanks!
Thank you too for taking this, and Geert for the extra reviews.
Max