Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2060061ybl; Thu, 15 Aug 2019 06:01:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqLJjbCTEqzPlWgf13oXIYlx9Fa7n4nmi4wQRFTe7+iRb5VZVjNAQmk7xr/Wyys3mjKCnB X-Received: by 2002:a17:902:b28b:: with SMTP id u11mr4017154plr.11.1565874095509; Thu, 15 Aug 2019 06:01:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565874095; cv=none; d=google.com; s=arc-20160816; b=lEn6xNwB3PnrJZ89qwyrpLrVPx6unYnrSlsWQphC/iXr34cplF2/IB8bygxPbXr/ZX OlVDKeH/97TUZ7Jz370eYOUh3P6utsNcUovqDvMs9qvPEZ1VSnUG2wqZ5Zq6qnvfBuHf EtTZ9LmKvoBgGcZiGxrq0FpCD5L1pc33feqPCxZL+9ibAqND7JR8SrNWI/Sh4TYCUA3r fAZwNRm/1trjUXBTn0/ju0VRCI9hkJQfv2SnkJz4oAK3jsN3Oo2xDlyNX5hFFKSO29sI uJzofA0nbbSP8V8zeKyCdD2p4UjS4w+h74NTddKDiHChgxEkOtfnLrv8vOh5+pXR1IfC OAyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Fit34tilXFmD0/tdK6VcUrzVEBRK3GYsB3x0RUDeXOk=; b=RfkG5GSeu7Wn6OZgcaPw+J0MHqX2EOPx0Ffsfz9XmNtukScMTy/CZJpfqrkIX5ElHb 4xNq3/nNm4Nm7WU2+gpdL4QxNQ/21+Xyc8wM4JJiwXfviNUrQD0fRULa+nkb8xGu1T9q 1weE51Iwl96RXVTIWLfENgpFr6APY+waJFLpHgEG23aFQxpA5hgMIjWWsigjxCi2AxeK i4eYOVIWzRiznqcunCMZoJf2J1F/8PiePVxmSZmYFohi9NqDFRLPUdiWKcL6BZsLvex/ V7yjrvMFD/NLx28Wz8W1FU5YRD7GBVnaTi1zAwOc6r9WI7F0XMkjba4PkBU1SzUdqvaL 3c+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si1788701pgg.489.2019.08.15.06.01.19; Thu, 15 Aug 2019 06:01:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731998AbfHOM6M (ORCPT + 99 others); Thu, 15 Aug 2019 08:58:12 -0400 Received: from enpas.org ([46.38.239.100]:60076 "EHLO mail.enpas.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730981AbfHOM6L (ORCPT ); Thu, 15 Aug 2019 08:58:11 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail.enpas.org (Postfix) with ESMTPSA id 16FC71006F0; Thu, 15 Aug 2019 12:58:08 +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 v3 3/3] i2c/busses/i2c-icy: Add LTC2990 present on 2019 board revision Date: Thu, 15 Aug 2019 14:58:02 +0200 Message-Id: <20190815125802.16500-3-max@enpas.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190815125802.16500-1-max@enpas.org> References: <20190815125802.16500-1-max@enpas.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. v3: Merged with initial LTC2990 support on ICY. Moved defaults from platform_data to swnode. Added note to Kconfig. Signed-off-by: Max Staudt --- drivers/i2c/busses/Kconfig | 3 +++ drivers/i2c/busses/i2c-icy.c | 56 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) 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 edac515da..c43cd170f 100644 --- a/drivers/i2c/busses/i2c-icy.c +++ b/drivers/i2c/busses/i2c-icy.c @@ -54,6 +54,8 @@ struct icy_i2c { void __iomem *reg_s0; void __iomem *reg_s1; + struct fwnode_handle *ltc2990_fwnode; + struct i2c_client *ltc2990_client; }; @@ -100,11 +102,33 @@ static void icy_pcf_waitforpin(void *data) /* * Main i2c-icy part */ +static unsigned short const icy_ltc2990_addresses[] = {0x4c, 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); @@ -147,6 +171,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; } @@ -154,6 +207,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); } -- 2.11.0