From patchwork Mon Aug 12 23:52:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 11091007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 048AC1399 for ; Mon, 12 Aug 2019 23:53:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8E5127FA9 for ; Mon, 12 Aug 2019 23:53:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD017285D8; Mon, 12 Aug 2019 23:53:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5922827FA9 for ; Mon, 12 Aug 2019 23:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbfHLXxL (ORCPT ); Mon, 12 Aug 2019 19:53:11 -0400 Received: from enpas.org ([46.38.239.100]:55714 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726453AbfHLXxK (ORCPT ); Mon, 12 Aug 2019 19:53:10 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 3CD11100078; Mon, 12 Aug 2019 23:53:05 +0000 (UTC) From: Max Staudt To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, Wolfram Sang , Jean Delvare , Guenter Roeck Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, glaubitz@physik.fu-berlin.de, Max Staudt Subject: [PATCH v2 1/4] i2c/busses: Add i2c-icy for I2C on m68k/Amiga Date: Tue, 13 Aug 2019 01:52:34 +0200 Message-Id: <20190812235237.21797-1-max@enpas.org> X-Mailer: git-send-email 2.11.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. 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 Signed-off-by: Max Staudt --- MAINTAINERS | 6 ++ drivers/i2c/busses/Kconfig | 11 +++ drivers/i2c/busses/Makefile | 1 + drivers/i2c/busses/i2c-icy.c | 189 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 207 insertions(+) create mode 100644 drivers/i2c/busses/i2c-icy.c diff --git a/MAINTAINERS b/MAINTAINERS index 1be025959..70336c083 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7705,6 +7705,12 @@ S: Maintained F: drivers/mfd/lpc_ich.c F: drivers/gpio/gpio-ich.c +ICY I2C DRIVER +M: Max Staudt +L: linux-i2c@vger.kernel.org +S: Maintained +F: drivers/i2c/busses/i2c-icy.c + IDE SUBSYSTEM M: "David S. Miller" L: linux-ide@vger.kernel.org diff --git a/drivers/i2c/busses/Kconfig b/drivers/i2c/busses/Kconfig index ee5dfb5ae..9e57e1101 100644 --- a/drivers/i2c/busses/Kconfig +++ b/drivers/i2c/busses/Kconfig @@ -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 diff --git a/drivers/i2c/busses/Makefile b/drivers/i2c/busses/Makefile index a3245231b..d0e1c3d4e 100644 --- a/drivers/i2c/busses/Makefile +++ b/drivers/i2c/busses/Makefile @@ -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 diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c new file mode 100644 index 000000000..7910f035b --- /dev/null +++ b/drivers/i2c/busses/i2c-icy.c @@ -0,0 +1,189 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * I2C driver for stand-alone PCF8584 style adapters on Zorro cards + * + * Original ICY documentation can be found on Aminet: + * https://aminet.net/package/docs/hard/icy + * + * There has been a modern community re-print of this design in 2019: + * https://www.a1k.org/forum/index.php?threads/70106/ + * + * The card is basically a Philips PCF8584 connected straight to the + * beginning of the AutoConfig'd address space (register S1 on base+2), + * with /INT on /INT2 on the Zorro bus. + * + * Copyright (c) 2019 Max Staudt + * + * This started as a fork of i2c-elektor.c and has evolved since. + * Thanks go to its authors for providing a base to grow on. + * + * + * IRQ support is currently not implemented. + * + * As it turns out, i2c-algo-pcf is really written with i2c-elektor's + * edge-triggered ISA interrupts in mind, while the Amiga's Zorro bus has + * level-triggered interrupts. This means that once an interrupt occurs, we + * have to tell the PCF8584 to shut up immediately, or it will keep the + * interrupt line busy and cause an IRQ storm. + + * However, because of the PCF8584's host-side protocol, there is no good + * way to just quieten it without side effects. Rather, we have to perform + * the next read/write operation straight away, which will reset the /INT + * pin. This entails re-designing the core of i2c-algo-pcf in the future. + * For now, we never request an IRQ from the PCF8584, and poll it instead. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "../algos/i2c-algo-pcf.h" + + +static int clock = 0x1c; +module_param(clock, int, 0444); + + + +struct icy_i2c { + struct i2c_adapter adapter; + + void __iomem *reg_s0; + void __iomem *reg_s1; +}; + + + +/* + * Functions called by i2c-algo-pcf + */ +static void icy_pcf_setpcf(void *data, int ctl, int val) +{ + struct icy_i2c *i2c = (struct icy_i2c *)data; + + u8 __iomem *address = ctl ? i2c->reg_s1 : i2c->reg_s0; + + z_writeb(val, address); +} + +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; +} + +static int icy_pcf_getown(void *data) +{ + return 0x55; +} + +static int icy_pcf_getclock(void *data) +{ + return clock; +} + +static void icy_pcf_waitforpin(void *data) +{ + udelay(100); +} + + + +/* + * Main i2c-icy part + */ +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; + + + i2c = devm_kzalloc(&z->dev, sizeof(*i2c), GFP_KERNEL); + if (!i2c) + return -ENOMEM; + + algo_data = devm_kzalloc(&z->dev, sizeof(*algo_data), GFP_KERNEL); + if (!algo_data) + return -ENOMEM; + + dev_set_drvdata(&z->dev, i2c); + i2c->adapter.dev.parent = &z->dev; + i2c->adapter.owner = THIS_MODULE; + i2c->adapter.class = I2C_CLASS_DEPRECATED; + /* i2c->adapter.algo assigned by i2c_pcf_add_bus() */ + i2c->adapter.algo_data = algo_data; + strlcpy(i2c->adapter.name, "ICY I2C Zorro adapter", + sizeof(i2c->adapter.name)); + + if (!devm_request_mem_region(&z->dev, + z->resource.start, + 4, i2c->adapter.name)) + return -ENXIO; + + /* Driver private data */ + i2c->reg_s0 = ZTWO_VADDR(z->resource.start); + i2c->reg_s1 = ZTWO_VADDR(z->resource.start + 2); + + algo_data->data = (void *)i2c; + algo_data->setpcf = icy_pcf_setpcf; + algo_data->getpcf = icy_pcf_getpcf; + algo_data->getown = icy_pcf_getown; + algo_data->getclock = icy_pcf_getclock; + algo_data->waitforpin = icy_pcf_waitforpin; + + if (i2c_pcf_add_bus(&i2c->adapter)) { + dev_err(&z->dev, "i2c_pcf_add_bus() failed\n"); + return -ENXIO; + } + + dev_info(&z->dev, "ICY I2C controller at %#x, IRQ not implemented\n", + z->resource.start); + + return 0; +} + +static void icy_remove(struct zorro_dev *z) +{ + struct icy_i2c *i2c = dev_get_drvdata(&z->dev); + + i2c_del_adapter(&i2c->adapter); +} + + + +static const struct zorro_device_id icy_zorro_tbl[] = { + { ZORRO_ID(VMC, 15, 0), }, + { 0 } +}; + +MODULE_DEVICE_TABLE(zorro, icy_zorro_tbl); + +static struct zorro_driver icy_driver = { + .name = "i2c-icy", + .id_table = icy_zorro_tbl, + .probe = icy_probe, + .remove = icy_remove, +}; + +module_driver(icy_driver, + zorro_register_driver, + zorro_unregister_driver); + + +MODULE_AUTHOR("Max Staudt "); +MODULE_DESCRIPTION("I2C bus via PCF8584 on ICY Zorro card"); +MODULE_LICENSE("GPL"); From patchwork Mon Aug 12 23:52:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 11091009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8E6761395 for ; Mon, 12 Aug 2019 23:53:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DBAA27FA9 for ; Mon, 12 Aug 2019 23:53:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 720EF285D8; Mon, 12 Aug 2019 23:53:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 164FF27FA9 for ; Mon, 12 Aug 2019 23:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726692AbfHLXxI (ORCPT ); Mon, 12 Aug 2019 19:53:08 -0400 Received: from enpas.org ([46.38.239.100]:55726 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726578AbfHLXxI (ORCPT ); Mon, 12 Aug 2019 19:53:08 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id E6B28100171; Mon, 12 Aug 2019 23:53:05 +0000 (UTC) From: Max Staudt To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, Wolfram Sang , Jean Delvare , Guenter Roeck Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, glaubitz@physik.fu-berlin.de, Max Staudt Subject: [PATCH v2 2/4] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision Date: Tue, 13 Aug 2019 01:52:35 +0200 Message-Id: <20190812235237.21797-2-max@enpas.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812235237.21797-1-max@enpas.org> References: <20190812235237.21797-1-max@enpas.org> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Max Staudt --- drivers/i2c/busses/i2c-icy.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c index 7910f035b..8125683c5 100644 --- a/drivers/i2c/busses/i2c-icy.c +++ b/drivers/i2c/busses/i2c-icy.c @@ -59,6 +59,7 @@ struct icy_i2c { void __iomem *reg_s0; void __iomem *reg_s1; + struct i2c_client *client_ltc2990; }; @@ -105,6 +106,13 @@ static void icy_pcf_waitforpin(void *data) /* * Main i2c-icy part */ +static struct i2c_board_info icy_ltc2990_info = { + I2C_BOARD_INFO("ltc2990", 0x4c), +}; + +static unsigned short const icy_ltc2990_addresses[] = {0x4c, I2C_CLIENT_END}; + + static int icy_probe(struct zorro_dev *z, const struct zorro_device_id *ent) { @@ -153,6 +161,18 @@ static int icy_probe(struct zorro_dev *z, dev_info(&z->dev, "ICY I2C controller at %#x, 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. + */ + i2c->client_ltc2990 = i2c_new_probed_device(&i2c->adapter, + &icy_ltc2990_info, + icy_ltc2990_addresses, + NULL); + return 0; } @@ -160,6 +180,8 @@ static void icy_remove(struct zorro_dev *z) { struct icy_i2c *i2c = dev_get_drvdata(&z->dev); + i2c_unregister_device(i2c->client_ltc2990); + i2c_del_adapter(&i2c->adapter); } From patchwork Mon Aug 12 23:52:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 11091003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B7151395 for ; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A4CA285D6 for ; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A8CA285DA; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 214CC285D6 for ; Mon, 12 Aug 2019 23:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727004AbfHLXxJ (ORCPT ); Mon, 12 Aug 2019 19:53:09 -0400 Received: from enpas.org ([46.38.239.100]:55736 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbfHLXxI (ORCPT ); Mon, 12 Aug 2019 19:53:08 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 51EB01006F0; Mon, 12 Aug 2019 23:53:06 +0000 (UTC) From: Max Staudt To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, Wolfram Sang , Jean Delvare , Guenter Roeck Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, glaubitz@physik.fu-berlin.de, Max Staudt Subject: [PATCH v2 3/4] hwmon/ltc2990: Add platform_data support Date: Tue, 13 Aug 2019 01:52:36 +0200 Message-Id: <20190812235237.21797-3-max@enpas.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812235237.21797-1-max@enpas.org> References: <20190812235237.21797-1-max@enpas.org> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This allows code using i2c_new_device() to specify a measurement mode. Signed-off-by: Max Staudt Reviewed-by: Geert Uytterhoeven --- drivers/hwmon/ltc2990.c | 9 +++++++++ include/linux/platform_data/ltc2990.h | 11 +++++++++++ 2 files changed, 20 insertions(+) create mode 100644 include/linux/platform_data/ltc2990.h diff --git a/drivers/hwmon/ltc2990.c b/drivers/hwmon/ltc2990.c index f9431ad43..f19b9c50c 100644 --- a/drivers/hwmon/ltc2990.c +++ b/drivers/hwmon/ltc2990.c @@ -14,6 +14,7 @@ #include #include #include +#include #define LTC2990_STATUS 0x00 #define LTC2990_CONTROL 0x01 @@ -206,6 +207,7 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, int ret; struct device *hwmon_dev; struct ltc2990_data *data; + struct ltc2990_platform_data *pdata = dev_get_platdata(&i2c->dev); struct device_node *of_node = i2c->dev.of_node; if (!i2c_check_functionality(i2c->adapter, I2C_FUNC_SMBUS_BYTE_DATA | @@ -227,6 +229,13 @@ static int ltc2990_i2c_probe(struct i2c_client *i2c, if (data->mode[0] & ~LTC2990_MODE0_MASK || data->mode[1] & ~LTC2990_MODE1_MASK) return -EINVAL; + } else if (pdata) { + data->mode[0] = pdata->meas_mode[0]; + data->mode[1] = pdata->meas_mode[1]; + + if (data->mode[0] & ~LTC2990_MODE0_MASK || + data->mode[1] & ~LTC2990_MODE1_MASK) + return -EINVAL; } else { ret = i2c_smbus_read_byte_data(i2c, LTC2990_CONTROL); if (ret < 0) diff --git a/include/linux/platform_data/ltc2990.h b/include/linux/platform_data/ltc2990.h new file mode 100644 index 000000000..7ec89e784 --- /dev/null +++ b/include/linux/platform_data/ltc2990.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef LTC2990_PDATA_H +#define LTC2990_PDATA_H + +#include + +struct ltc2990_platform_data { + u8 meas_mode[2]; +}; + +#endif /* LTC2990_PDATA_H */ From patchwork Mon Aug 12 23:52:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Staudt X-Patchwork-Id: 11091005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 127BA14DB for ; Mon, 12 Aug 2019 23:53:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0302D285D6 for ; Mon, 12 Aug 2019 23:53:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB4ED285DA; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B4ED285D6 for ; Mon, 12 Aug 2019 23:53:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726578AbfHLXxJ (ORCPT ); Mon, 12 Aug 2019 19:53:09 -0400 Received: from enpas.org ([46.38.239.100]:55746 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726659AbfHLXxJ (ORCPT ); Mon, 12 Aug 2019 19:53:09 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id B7B7D100704; Mon, 12 Aug 2019 23:53:06 +0000 (UTC) From: Max Staudt To: linux-i2c@vger.kernel.org, linux-hwmon@vger.kernel.org, Wolfram Sang , Jean Delvare , Guenter Roeck Cc: linux-m68k@vger.kernel.org, linux-kernel@vger.kernel.org, glaubitz@physik.fu-berlin.de, Max Staudt Subject: [PATCH v2 4/4] i2c/busses/i2c-icy: Add platform_data for LTC2990 Date: Tue, 13 Aug 2019 01:52:37 +0200 Message-Id: <20190812235237.21797-4-max@enpas.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190812235237.21797-1-max@enpas.org> References: <20190812235237.21797-1-max@enpas.org> Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This enables the three additional inputs available on the 2019 a1k.org reprint of the ICY 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. Signed-off-by: Max Staudt Reviewed-by: Geert Uytterhoeven --- drivers/i2c/busses/i2c-icy.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-icy.c b/drivers/i2c/busses/i2c-icy.c index 8125683c5..6ad9910a0 100644 --- a/drivers/i2c/busses/i2c-icy.c +++ b/drivers/i2c/busses/i2c-icy.c @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -106,8 +107,21 @@ static void icy_pcf_waitforpin(void *data) /* * Main i2c-icy part */ +static struct ltc2990_platform_data icy_ltc2990_platform_data = { + /* + * Additional sensors exposed by this platform data: + * + * 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. + */ + .meas_mode = {0, 3}, +}; + static struct i2c_board_info icy_ltc2990_info = { - I2C_BOARD_INFO("ltc2990", 0x4c), + .type = "ltc2990", + .addr = 0x4c, + .platform_data = &icy_ltc2990_platform_data, }; static unsigned short const icy_ltc2990_addresses[] = {0x4c, I2C_CLIENT_END}; @@ -167,6 +181,8 @@ static int icy_probe(struct zorro_dev *z, * * in0 is the voltage of the internal 5V power supply. * temp1 is the temperature inside the chip. + * + * See platform data above for in1, in2, temp3. */ i2c->client_ltc2990 = i2c_new_probed_device(&i2c->adapter, &icy_ltc2990_info,