From patchwork Tue Dec 14 09:50:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 525638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAA7EC433FE for ; Tue, 14 Dec 2021 09:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230480AbhLNJuv (ORCPT ); Tue, 14 Dec 2021 04:50:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230359AbhLNJuu (ORCPT ); Tue, 14 Dec 2021 04:50:50 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F072C061574 for ; Tue, 14 Dec 2021 01:50:50 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id o29so13828217wms.2 for ; Tue, 14 Dec 2021 01:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WHH4WiI2MxaNbM7UzjVUxrr+ROoXv/5adPxzCtUwAhQ=; b=XgVBB9UHALlGPIuK58KdiVRAPLtWiUfbLh3J0qXQf8w1DsVfquHKVtRSdooUN6XSON +wAFgwDhmrkV3lxmUSgbscXp6noFb9Cx8Fr+PnZ3qKRcTHHIThTJNerRcszAOCN1/gWf CTWwUNbQrD4lVqgvFDhY0WYCo+lFKLF4U1d2obV0f4x6dwxzwwDnn5wQoBqDzniqdx5X gW4JFycYbEBleAObCucbfLZcDlTCxSV5LWLWMytSuxCxGi7oMzJlKKnBcT+gJXeZt+rd attBewvsz07pmBI48EgQG/+ojwfzOUnYfY+OLEu9I6vb/8kt+vtZvsF9ngfgMIBG91iz S9YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=WHH4WiI2MxaNbM7UzjVUxrr+ROoXv/5adPxzCtUwAhQ=; b=7lHhZ3iQx+YNrkXmC2Ngx7PbczjQKh9K5Q1ugHqstSOLXyfhKO1+Nb3Y0sg5Q3n7xO h0F72HwwepxibccTUo5Woz9kVNQzhXjGQDR24rOXPYZQDvEyQpi1tnMGSxWEYhhVfpO6 Nqd1bB2KN8BL3N47Q82SP+11ZvjTGXqsd0AcJEhh8g0LbFT6OKN2Mbt8nx1NF9vVHoHp Ako1R3x3NzWDX7saiKr21K15lGx0ZJuHdNZQOg/IXSqAY7tljQLq2MIEKg+d694at9js HtrWvh6sp2/27/IhBIIf5Z7S6Iatwz9oJXUmDUJkLl3p3DBNenmhmUHoojt6rp+OJ1rm 7dqA== X-Gm-Message-State: AOAM532n26eiR91OknXGDieX4wPKc/yGg6Jga7HM93QPX/bmQOgEy3wn RfcgY/CGMKhZm/wCgt8SQKSkkA== X-Google-Smtp-Source: ABdhPJxd2AGCGNV2VrCPH24TV5pJ1pfhEkqXewGMXeGsNA2mh0yIGtTBTdgm+ToOl7+coLT1Z22puw== X-Received: by 2002:a05:600c:2309:: with SMTP id 9mr1376636wmo.174.1639475448937; Tue, 14 Dec 2021 01:50:48 -0800 (PST) Received: from fedora.sec.9e.network (ip-88-153-139-166.hsi04.unitymediagroup.de. [88.153.139.166]) by smtp.gmail.com with ESMTPSA id s24sm1522757wmj.26.2021.12.14.01.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 01:50:48 -0800 (PST) From: Patrick Rudolph To: Peter Rosin , Rob Herring , Laurent Pinchart Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] dt-bindings: i2c Update PCA954x Date: Tue, 14 Dec 2021 10:50:18 +0100 Message-Id: <20211214095021.572799-1-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add the Maxim MAX735x as supported chip to PCA954x and add an example how to use it. Signed-off-by: Patrick Rudolph --- .../bindings/i2c/i2c-mux-pca954x.yaml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index 9f1726d0356b..bd794cb80c11 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -11,6 +11,7 @@ maintainers: description: The binding supports NXP PCA954x and PCA984x I2C mux/switch devices. + Compatible with Maxim MAX7356 - MAX7358 I2C mux/switch devices. allOf: - $ref: /schemas/i2c/i2c-mux.yaml# @@ -19,6 +20,9 @@ properties: compatible: oneOf: - enum: + - maxim,max7356 + - maxim,max7357 + - maxim,max7358 - nxp,pca9540 - nxp,pca9542 - nxp,pca9543 @@ -40,6 +44,7 @@ properties: interrupts: maxItems: 1 + description: Only supported on NXP devices. Unsupported on Maxim MAX735x. "#interrupt-cells": const: 2 @@ -100,6 +105,41 @@ examples: #size-cells = <0>; reg = <4>; + rtc@51 { + compatible = "nxp,pcf8563"; + reg = <0x51>; + }; + }; + }; + }; + + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + i2c-mux@74 { + compatible = "maxim,max7357"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x74>; + + i2c@1 { + #address-cells = <1>; + #size-cells = <0>; + reg = <1>; + + eeprom@54 { + compatible = "atmel,24c08"; + reg = <0x54>; + }; + }; + + i2c@7 { + #address-cells = <1>; + #size-cells = <0>; + reg = <7>; + rtc@51 { compatible = "nxp,pcf8563"; reg = <0x51>; From patchwork Tue Dec 14 09:50:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 523769 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2471DC433F5 for ; Tue, 14 Dec 2021 09:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232659AbhLNJu6 (ORCPT ); Tue, 14 Dec 2021 04:50:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbhLNJu5 (ORCPT ); Tue, 14 Dec 2021 04:50:57 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 734DAC06173F for ; Tue, 14 Dec 2021 01:50:57 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso15840170wms.2 for ; Tue, 14 Dec 2021 01:50:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nsRfFjdoa2Fef1cqbeFwUOpeAISCeqGWxecBBnZatl8=; b=EkKqgbsawtEafSZAY7mZ9tIdet08L6XvSWJcQgKd2E2b0IwMDg2B3X1DSw9o4PWacQ 6m5IsruTOYWfgpkZdmTkUnXHiq4bJxrvh7CG3kLT8s+qhO2NtSESfZmRAR9NmrGGsACE YUNQ+pKUMoZxxmV2GWAuP5San5a52hrCCD/cy+br4s+CnB0VFrBOPGwIWBrP8PWBwo0T bWovcPvxLzguTM9giSjKexi5qtyEIH8Um8hT/QICCaRpfydY93to1N1HN6+z05X9kycx B9DgIW6+r+veRzR+cjjsD1LCoM4SJYOV2PtffoxjE1lyf2Cvym8bhlXQ3VyUpEA8/to7 gulg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=nsRfFjdoa2Fef1cqbeFwUOpeAISCeqGWxecBBnZatl8=; b=PrXHn3vfq0AJWUVFs3Jcw+WCL9FPXEiN4sp4TkYV+SsmYxB0jX+fA0kW3m9OguwhK1 5bLQcqBIrTSmeaYDjc7MbyG8ZGEek43F+oNrqGU5tfPliY+nGghS2SndODD+SHBXV7vH oVxWMgqvxM4Bo8yj+dusZh9+rK2L7gGR2UagZ7UVVTHxnT53/Yn1EIPnqr3A+OzxZ1R9 PYopD/jiCO7bU6iKaXcnPCN+5Or+xKou7EDbDm2e7CE7FmZHe+bOoaiyHc7DanZu5S3S Defhk6lD6E+EL0xRVmnOqYZ7m7L42OKLUyZIe+eO6bE1LqONfEbOKuRHjGAFGDgaz5nL AYpA== X-Gm-Message-State: AOAM532XqwxYa9feEZmUWzfnLg3efQukDNE3lT7iHxarfXB8iOjPLgDv e1HQkg4r0nxKDYjnZjKjjWuTtA== X-Google-Smtp-Source: ABdhPJzLvjKmZbqhj/0aEH8wjxtVwdxyNjx21q4FAZ11fNn4Z5F6J6xO2W1e2X2pRIXBKBdwO5tpzw== X-Received: by 2002:a05:600c:1987:: with SMTP id t7mr5697077wmq.24.1639475455964; Tue, 14 Dec 2021 01:50:55 -0800 (PST) Received: from fedora.sec.9e.network (ip-88-153-139-166.hsi04.unitymediagroup.de. [88.153.139.166]) by smtp.gmail.com with ESMTPSA id s24sm1522757wmj.26.2021.12.14.01.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 01:50:55 -0800 (PST) From: Patrick Rudolph To: Peter Rosin Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] drivers/i2c/mux: Add MAX735x support to PCA954x Date: Tue, 14 Dec 2021 10:50:19 +0100 Message-Id: <20211214095021.572799-2-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211214095021.572799-1-patrick.rudolph@9elements.com> References: <20211214095021.572799-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add support for MAX7356, MAX7357 and MAX7358 using the existing driver. All added Maxim chips behave like the PCA9848, where a single SMBUS byte write selects up to 8 channels to be bridged to the primary bus. The MAX7357 exposes 6 additional registers at Power-On-Reset and is configured to enable additional features: - Disabled interrupts on bus locked up detection - Enable bus locked-up clearing - Disconnect only locked bus instead of all channels The MAX7357/MAX7358 IRQs aren't supported and must not be enabled. Signed-off-by: Patrick Rudolph --- drivers/i2c/muxes/Kconfig | 4 +- drivers/i2c/muxes/i2c-mux-pca954x.c | 63 +++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig index 1708b1a82da2..621c8a5314f6 100644 --- a/drivers/i2c/muxes/Kconfig +++ b/drivers/i2c/muxes/Kconfig @@ -65,11 +65,11 @@ config I2C_MUX_PCA9541 will be called i2c-mux-pca9541. config I2C_MUX_PCA954x - tristate "NXP PCA954x and PCA984x I2C Mux/switches" + tristate "NXP PCA954x and PCA984x and Maxim MAX735x I2C Mux/switches" depends on GPIOLIB || COMPILE_TEST help If you say yes here you get support for the NXP PCA954x - and PCA984x I2C mux/switch devices. + and PCA984x and Maxim MAX735x I2C mux/switch devices. This driver can also be built as a module. If so, the module will be called i2c-mux-pca954x. diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 4ad665757dd8..23e0f24bab04 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -11,6 +11,12 @@ * PCA9540, PCA9542, PCA9543, PCA9544, PCA9545, PCA9546, PCA9547, * PCA9548, PCA9846, PCA9847, PCA9848 and PCA9849. * + * It's also compatible to Maxims MAX735x I2C switch chips, which is controlled + * as the NXP PCA9548. + * + * This includes the: + * MAX7356, MAX7357 and MAX7358. + * * These chips are all controlled via the I2C bus itself, and all have a * single 8-bit register. The upstream "parent" bus fans out to two, * four, or eight downstream busses or channels; which of these @@ -50,7 +56,12 @@ #define PCA954X_IRQ_OFFSET 4 +#define MAX7357_REG_CONFIG_DEFAULTS 0x16 + enum pca_type { + max_7356, + max_7357, + max_7358, pca_9540, pca_9542, pca_9543, @@ -69,6 +80,8 @@ struct chip_desc { u8 nchans; u8 enable; /* used for muxes only */ u8 has_irq; + u8 max7357; + u8 max735x; enum muxtype { pca954x_ismux = 0, pca954x_isswi @@ -90,8 +103,27 @@ struct pca954x { raw_spinlock_t lock; }; -/* Provide specs for the PCA954x types we know about */ +/* Provide specs for the PCA954x and MAX735x types we know about */ static const struct chip_desc chips[] = { + [max_7356] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .max735x = 1, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7357] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .max735x = 1, + .max7357 = 1, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7358] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .max735x = 1, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, [pca_9540] = { .nchans = 2, .enable = 0x4, @@ -177,6 +209,9 @@ static const struct chip_desc chips[] = { }; static const struct i2c_device_id pca954x_id[] = { + { "max7356", max_7356 }, + { "max7357", max_7357 }, + { "max7358", max_7358 }, { "pca9540", pca_9540 }, { "pca9542", pca_9542 }, { "pca9543", pca_9543 }, @@ -194,6 +229,9 @@ static const struct i2c_device_id pca954x_id[] = { MODULE_DEVICE_TABLE(i2c, pca954x_id); static const struct of_device_id pca954x_of_match[] = { + { .compatible = "maxim,max7356", .data = &chips[max_7356] }, + { .compatible = "maxim,max7357", .data = &chips[max_7357] }, + { .compatible = "maxim,max7358", .data = &chips[max_7358] }, { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, { .compatible = "nxp,pca9542", .data = &chips[pca_9542] }, { .compatible = "nxp,pca9543", .data = &chips[pca_9543] }, @@ -355,6 +393,11 @@ static int pca954x_irq_setup(struct i2c_mux_core *muxc) if (!data->chip->has_irq || client->irq <= 0) return 0; + if (data->chip->max735x) { + dev_err(&client->dev, "IRQs not supported for MAX735x\n"); + return -EOPNOTSUPP; + } + raw_spin_lock_init(&data->lock); data->irq = irq_domain_add_linear(client->dev.of_node, @@ -401,9 +444,21 @@ static int pca954x_init(struct i2c_client *client, struct pca954x *data) else data->last_chan = 0; /* Disconnect multiplexer */ - ret = i2c_smbus_write_byte(client, data->last_chan); - if (ret < 0) - data->last_chan = 0; + /* + * MAX7357 exposes 7 register on POR which allows to configure additional + * features. Disable interrupts, enable bus locked-up clearing, + * disconnect only locked bus instead of all channels. + */ + if (data->chip->max7357) { + ret = i2c_smbus_write_byte_data(client, data->last_chan, + MAX7357_REG_CONFIG_DEFAULTS); + if (ret < 0) + data->last_chan = 0; + } else { + ret = i2c_smbus_write_byte(client, data->last_chan); + if (ret < 0) + data->last_chan = 0; + } return ret; } From patchwork Tue Dec 14 09:50:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 525637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9660C433FE for ; Tue, 14 Dec 2021 09:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbhLNJvB (ORCPT ); Tue, 14 Dec 2021 04:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232630AbhLNJvA (ORCPT ); Tue, 14 Dec 2021 04:51:00 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1072DC061574 for ; Tue, 14 Dec 2021 01:51:00 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id q3so31369258wru.5 for ; Tue, 14 Dec 2021 01:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UoqofvZsTLn3SZWgvUrY2g8UHV9XmLPJnkQk172OXk4=; b=hB68tQoQD6wtqjDpVCKgTzURxRcRL4C9GdnxcUZvBu6+I4BxO6ifeDBvAuZgmGzzhh gbjn1KsaxSiHFhAkN/I1uJXEM11WgNkO7jr+tNlJ4e12NdNigaTM04CqZSFr+K95iRrL xmlwuEjCqD7y7A5BKn9sagG5I3qsehYHDBUQGFSsiN8tTsmuT7UkJspiEsk4OFLojuvl FXNNHtwLVoUSbIk5s7S2rX3NU/fl2BPgtDYhI3rzAw57UJTH9VueKbpEqKgOD3FZRkDK 94f5+6DX8H0ktrPEh0lBgU3kfXbK9dzMaClQHYrMv3FCoHkc6EWsu3tPffBKy73Qg4CF cTpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UoqofvZsTLn3SZWgvUrY2g8UHV9XmLPJnkQk172OXk4=; b=vi9YGISFay5NsNFgij5Lj0GLK2G6bWq3OJyF+WEa5UFVs68+ivgoWxYEsPYNYocA/9 pD4BlliL/3LGXL3Q8WzvW/mvGOgcJPsaP3V4f6praFvAl4WuZRH3AGLHgFrJFRmR0SqI 1f8hFVkQIjgSYPU7uY5KDeAZDS1VZqsn1HKWP6uV/f5gYkhD9v9r/3aCTd/65OBBxYtc p9zeOVQdko+u7mQd5ChL+RdOxCycxl+EzSHCjKlDa8bnKlj6pLZqEgbIH6QeZkWoi2De 5jm9FQbyUaX+i/8iacR/XGRWV9kQrT0ALfDskKIa8iKNV3it9WHTKGWTVrxcQrUvevpR mazA== X-Gm-Message-State: AOAM530gGThqVRRJdYRmxib3X9J8PiKK/YNzajzPexVP0nmqpMU2WzP6 L4fpggxdFL5oCRx6L3YUyC3BpQ== X-Google-Smtp-Source: ABdhPJynnWm78M3TOb/T++5wTbkaJyEvCtnZXR+VoAoezYTUy8+XaDPydAauILAsPLk+jz38YwylZg== X-Received: by 2002:adf:fb09:: with SMTP id c9mr4578324wrr.223.1639475458598; Tue, 14 Dec 2021 01:50:58 -0800 (PST) Received: from fedora.sec.9e.network (ip-88-153-139-166.hsi04.unitymediagroup.de. [88.153.139.166]) by smtp.gmail.com with ESMTPSA id s24sm1522757wmj.26.2021.12.14.01.50.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 01:50:58 -0800 (PST) From: Patrick Rudolph To: Peter Rosin , Rob Herring , Laurent Pinchart Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] dt-bindings: i2c Add regulator to pca954x Date: Tue, 14 Dec 2021 10:50:20 +0100 Message-Id: <20211214095021.572799-3-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211214095021.572799-1-patrick.rudolph@9elements.com> References: <20211214095021.572799-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add a regulator called vcc and update the example. Signed-off-by: Patrick Rudolph --- Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index bd794cb80c11..5add7db02c0c 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -64,6 +64,9 @@ properties: description: if present, overrides i2c-mux-idle-disconnect $ref: /schemas/mux/mux-controller.yaml#/properties/idle-state + vcc-supply: + description: An optional voltage regulator supplying power to the chip. + required: - compatible - reg @@ -84,6 +87,8 @@ examples: #size-cells = <0>; reg = <0x74>; + vcc-supply = <&p3v3>; + interrupt-parent = <&ipic>; interrupts = <17 IRQ_TYPE_LEVEL_LOW>; interrupt-controller; From patchwork Tue Dec 14 09:50:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 523768 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09876C433EF for ; Tue, 14 Dec 2021 09:51:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232685AbhLNJvD (ORCPT ); Tue, 14 Dec 2021 04:51:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232647AbhLNJvC (ORCPT ); Tue, 14 Dec 2021 04:51:02 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1530C06173F for ; Tue, 14 Dec 2021 01:51:01 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id j140-20020a1c2392000000b003399ae48f58so15826169wmj.5 for ; Tue, 14 Dec 2021 01:51:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QvL6cSotT6zCDdAPa4uv4YcC9fcfaO0IQCDs+UP7OhA=; b=To0gur3eKFHJsX21w7cmkSkqz5iIr5w0YMiedtpEZKoVBK8D+1BQsiVDU7kkOoI3um 9T+9NrM3t4ZX9nW1MT1b+74RuOVJEv+GFPoWOjzkP+7FT3b+CwoYYR54Ts44X6pdTNtr oDVsycxRgFYaw3If3u/E3cAY4Y4F9CPSf7VArxLXMWHyixqJgj1khkD7hQOYjSe6NZKT mpemjX1G44qscgbayGdeT2PiMKLYFgINd/tvy4br9ThYNpGD5ZgkUQNJM+3c42xCAWuX cv9THpGo/ZJUIuMNZWb81Nl5icftNZuHRibHY1yuePjJj1YPVELDer9UKjQBNd3wrGmA yIdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QvL6cSotT6zCDdAPa4uv4YcC9fcfaO0IQCDs+UP7OhA=; b=QulaNaO370u8dWVivJh9DL+ewU0xW7CFbzfz17KRXwdezkMBWjIOFLZ1q4r7YR6PWC G3tD48Fjnop1NgMadlYhz6RP1WtDtr85e8yW9bczIrV0Mvbxpyny/OdmjwKE2dh+nO9B SjDF62JppBpUlw+GdZSj2XLgw0Wi/ziP+INCRqzMJFgErsZ0wfOG6cekXINXnpM6tQjc 49cIJA6X7uOGvB6j40vuKMK+/fS+34DSsLryWUJVXnFwe6YJ/Pi7jKxeF//aCjc/V6Nr PL7IiRzhfDL/Y+TyYfW40KWVIaGsvTcglp61OJCvp/qTxxPKAJqVzwHYaIYV88S/Jt2S VJ0w== X-Gm-Message-State: AOAM530MGj1PLQV7JsVUbYhgo5yXi5KQyeUOsn8BG+vVQayn5cr2V/Wr hpOc7UDtfJkqu0jpfAZIZy3rmg== X-Google-Smtp-Source: ABdhPJwb27AiqA1Y3fkM3GDXYWJAC+nARejXPzWcWmTpXuBDmiJ2tkGELxbeHPoqaq3NC7uVSbIDfA== X-Received: by 2002:a05:600c:6006:: with SMTP id az6mr5954257wmb.5.1639475460298; Tue, 14 Dec 2021 01:51:00 -0800 (PST) Received: from fedora.sec.9e.network (ip-88-153-139-166.hsi04.unitymediagroup.de. [88.153.139.166]) by smtp.gmail.com with ESMTPSA id s24sm1522757wmj.26.2021.12.14.01.50.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Dec 2021 01:50:59 -0800 (PST) From: Patrick Rudolph To: Peter Rosin Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] i2c-mux-pca954x: Add regulator support Date: Tue, 14 Dec 2021 10:50:21 +0100 Message-Id: <20211214095021.572799-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211214095021.572799-1-patrick.rudolph@9elements.com> References: <20211214095021.572799-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add an optional vcc regulator and enable it when found for devices that are powered off by default. Signed-off-by: Patrick Rudolph --- drivers/i2c/muxes/i2c-mux-pca954x.c | 33 ++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 23e0f24bab04..5fa266cb02c0 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -101,6 +102,7 @@ struct pca954x { struct irq_domain *irq; unsigned int irq_mask; raw_spinlock_t lock; + struct regulator *supply; }; /* Provide specs for the PCA954x and MAX735x types we know about */ @@ -425,6 +427,9 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc) struct pca954x *data = i2c_mux_priv(muxc); int c, irq; + if (!IS_ERR_OR_NULL(data->supply)) + regulator_disable(data->supply); + if (data->irq) { for (c = 0; c < data->chip->nchans; c++) { irq = irq_find_mapping(data->irq, c); @@ -484,15 +489,31 @@ static int pca954x_probe(struct i2c_client *client, pca954x_select_chan, pca954x_deselect_mux); if (!muxc) return -ENOMEM; + data = i2c_mux_priv(muxc); i2c_set_clientdata(client, muxc); data->client = client; + data->supply = devm_regulator_get(dev, "vcc"); + if (IS_ERR(data->supply)) { + if ((PTR_ERR(data->supply) == -EPROBE_DEFER)) + return -EPROBE_DEFER; + dev_warn(dev, "Failed to get regulator for vcc: %d\n", ret); + } else { + ret = regulator_enable(data->supply); + if (ret) { + dev_err(dev, "Failed to enable regulator vcc\n"); + return ret; + } + } + /* Reset the mux if a reset GPIO is specified. */ gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH); - if (IS_ERR(gpio)) - return PTR_ERR(gpio); + if (IS_ERR(gpio)) { + ret = PTR_ERR(gpio); + goto fail_cleanup; + } if (gpio) { udelay(1); gpiod_set_value_cansleep(gpio, 0); @@ -509,7 +530,7 @@ static int pca954x_probe(struct i2c_client *client, ret = i2c_get_device_id(client, &id); if (ret && ret != -EOPNOTSUPP) - return ret; + goto fail_cleanup; if (!ret && (id.manufacturer_id != data->chip->id.manufacturer_id || @@ -517,7 +538,8 @@ static int pca954x_probe(struct i2c_client *client, dev_warn(dev, "unexpected device id %03x-%03x-%x\n", id.manufacturer_id, id.part_id, id.die_revision); - return -ENODEV; + ret = -ENODEV; + goto fail_cleanup; } } @@ -536,7 +558,8 @@ static int pca954x_probe(struct i2c_client *client, ret = pca954x_init(client, data); if (ret < 0) { dev_warn(dev, "probe failed\n"); - return -ENODEV; + ret = -ENODEV; + goto fail_cleanup; } ret = pca954x_irq_setup(muxc);