From patchwork Fri Oct 7 07:53:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 613676 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 61148C4332F for ; Fri, 7 Oct 2022 07:55:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229578AbiJGHzV (ORCPT ); Fri, 7 Oct 2022 03:55:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbiJGHzT (ORCPT ); Fri, 7 Oct 2022 03:55:19 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95FD99F750 for ; Fri, 7 Oct 2022 00:55:17 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id d26so2480540eje.10 for ; Fri, 07 Oct 2022 00:55:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tipzJfhoPrPCegKX++Rgd/gqgDZoB8bwOjI9b3+6wlM=; b=EKaWKLNPo2nQO3u8MiVwHe5jcphecx07+dFdDbvuksLwA9koPd04uiqcwt9itNfA1C ni8+Z6jvMyWicfrkNHGGXNaay5A1rN71frAkx7aVSJp5ZeMUYbrv7V/mv/gpryACwiQl U+quLN9o347sazffUsDHkD8t6rriy0Ozi0fbmUqoZApmDuxyBHdF3HK5S35vCzWVninj 6xuBH7uJZcbuIE1CkB2WCCcIRZtXP2EsiKFkOBC9/SF0m+HMiWXrows0pxm27Ly6OdZ/ z3KzlQ2wAoKRi3/eplsX7o0iS+LtWhuV+eckGgDUnMwSS0/Cvrgm+R0ZaFp626RJaAlB m8Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tipzJfhoPrPCegKX++Rgd/gqgDZoB8bwOjI9b3+6wlM=; b=TNlUyKwpjPA1dKdj5u2KpoC48GTI8AlyMwLgOLO+OKdS5Ih5XZcXaN2CLI/zJGLZew WgvUl0c8mGaUmZW/d2m0/PdS0uYei1rheUWP4cWZ6Eu0tCN5FUYmoEfOxtJFDgPMFAR2 Y78CDg0HzrJMcxDeTR+JBfdg0kz19uc664C/q96U3h7bM9OrBCUyGs9zdo1l7w0UTGy/ euMYXC6equWedVDGE9c73+9dubWdgi1/In223xn9cMLfzj5k34ESR3BP61x8iYs72qFW NuRGlF9j7BXfynt3y49P03XxtfQdSpOqAbNdMORKCAS7sHMtxnfAG+5WVsz+ziPG0QJS jTkQ== X-Gm-Message-State: ACrzQf00nioTAlyK0c5pYCCGARzHq++ojwZEp3Bqkgi2fi8EN+SdswQ0 ANK7Vdg1PDCg6CBkWlO7QDg/7jxcALlB8w== X-Google-Smtp-Source: AMsMyM7revYPkS3AA8AdrLnBhuq07TxztXSu70zQWk/sqHIiSqMyEXRNFEKZyZg4jG894S4UHgPbYg== X-Received: by 2002:a17:907:d07:b0:72e:ec79:ad0f with SMTP id gn7-20020a1709070d0700b0072eec79ad0fmr3229360ejc.296.1665129316138; Fri, 07 Oct 2022 00:55:16 -0700 (PDT) Received: from fedora.sec.9e.network (ip-094-114-232-236.um31.pools.vodafone-ip.de. [94.114.232.236]) by smtp.gmail.com with ESMTPSA id hv13-20020a17090760cd00b00741a0c3f4cdsm782281ejc.189.2022.10.07.00.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 00:55:15 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin , Laurent Pinchart Cc: robh@kernel.org, wsa@kernel.org, Patrick Rudolph , Rob Herring , Krzysztof Kozlowski , linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v9 1/4] dt-bindings: i2c: Add Maxim MAX735x/MAX736x variants Date: Fri, 7 Oct 2022 09:53:50 +0200 Message-Id: <20221007075354.568752-2-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007075354.568752-1-patrick.rudolph@9elements.com> References: <20221007075354.568752-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Update the pca954x bindings to add support for the Maxim MAX735x/MAX736x chips. The functionality will be provided by the exisintg pca954x driver. While on it make the interrupts support conditionally as not all of the existing chips have interrupts. For chips that are powered off by default add an optional regulator called vdd-supply. Signed-off-by: Patrick Rudolph --- .../bindings/i2c/i2c-mux-pca954x.yaml | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml index 9f1726d0356b..efad0a95806f 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.yaml @@ -4,21 +4,25 @@ $id: http://devicetree.org/schemas/i2c/i2c-mux-pca954x.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: NXP PCA954x I2C bus switch +title: NXP PCA954x I2C and compatible bus switches maintainers: - Laurent Pinchart description: - The binding supports NXP PCA954x and PCA984x I2C mux/switch devices. - -allOf: - - $ref: /schemas/i2c/i2c-mux.yaml# + The binding supports NXP PCA954x and PCA984x I2C mux/switch devices, + and the Maxim MAX735x and MAX736x I2C mux/switch devices. properties: compatible: oneOf: - enum: + - maxim,max7356 + - maxim,max7357 + - maxim,max7358 + - maxim,max7367 + - maxim,max7368 + - maxim,max7369 - nxp,pca9540 - nxp,pca9542 - nxp,pca9543 @@ -59,10 +63,33 @@ properties: description: if present, overrides i2c-mux-idle-disconnect $ref: /schemas/mux/mux-controller.yaml#/properties/idle-state + vdd-supply: + description: A voltage regulator supplying power to the chip. + required: - compatible - reg +allOf: + - $ref: /schemas/i2c/i2c-mux.yaml# + - if: + not: + properties: + compatible: + contains: + enum: + - maxim,max7367 + - maxim,max7369 + - nxp,pca9542 + - nxp,pca9543 + - nxp,pca9544 + - nxp,pca9545 + then: + properties: + interrupts: false + "#interrupt-cells": false + interrupt-controller: false + unevaluatedProperties: false examples: @@ -79,6 +106,8 @@ examples: #size-cells = <0>; reg = <0x74>; + vdd-supply = <&p3v3>; + interrupt-parent = <&ipic>; interrupts = <17 IRQ_TYPE_LEVEL_LOW>; interrupt-controller; From patchwork Fri Oct 7 07:53:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 613325 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 2E15AC433FE for ; Fri, 7 Oct 2022 07:55:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbiJGHz2 (ORCPT ); Fri, 7 Oct 2022 03:55:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229791AbiJGHzX (ORCPT ); Fri, 7 Oct 2022 03:55:23 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C83A4193D2 for ; Fri, 7 Oct 2022 00:55:20 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id ot12so9634655ejb.1 for ; Fri, 07 Oct 2022 00:55:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yKgH3a6XYZYRbdYUiD+yjslcikmARUMCSXz+IUE2mjY=; b=bwc+GsmPqEKE2JavSCnG7kb0QRlT45LpS7yZfHbDFLm8iiAsyElSdR8KxzLNxCoY4Z zoidpYBSW+Htnr+DNqaKLW8Gm9yROR1T/P4lz1kXHjBnjhZKP7eME8s0WVanFYyeksIN hhHIteAeE6nBWaf1dsen12Dk/SIfgtGScuTqQjTweBe90FaCFB6gZWeQ41BcSZ3JLzX+ f9lDILNUaHKhF4oOPU6715qgizEm6vCCvKYZiRM3y21BL5ZZC9wp8h2gbW5+U4sqUyoQ g7k+l4wDMlU6SY92AB5dPoz9Er7UM8AlLBM3Kk7zpVHoIjwGIDFAPMz0OUkCs4yJMW3L cGNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yKgH3a6XYZYRbdYUiD+yjslcikmARUMCSXz+IUE2mjY=; b=J0tpOTSnLWXmuqqk6foxIjFBj5LrQzn3spPNNwIYqyxD4WN10DltEmTuZG0e4P0qrO lsoAz5epkeKMGhQN3z5bDr+7YJlGmkD0+lVti4JWnjYB0N5E52Jj/f2+4z8hbKhjAAw5 iQ4myZyBSlbcR6lMSxSsoZzTAbdoWvckwhVY9Tcww3fx3IQYKkz+FjGjVc4cPwUA8Snc gP8nN2dqkYcuMoZnzhSOa+pfmPfsOmF0BuERaGkLFkyqKnalWW3doaRLsbia43hhH7eY t8f7p0Ofon/aQf+4Dd+AihhrImQ4AdzNCYMH66XX5Ngvv3i5Yil8ysc95xhYdPZ2y0m4 h96g== X-Gm-Message-State: ACrzQf2FnASl8FsiKIK1dNoUaEM/ZbjNnWvNBKh68Z/P7BAhcb34bZZ7 T2ZCgjfZGW5pR90CNmECIHZZAQ== X-Google-Smtp-Source: AMsMyM4kObS+QeW/7TGits+ZFmYAD21zjTnNfSdcFDFw87aeRN4+iDo7Ru10J3DMHGnwdONiKJa7ow== X-Received: by 2002:a17:907:2cee:b0:779:d10c:25a5 with SMTP id hz14-20020a1709072cee00b00779d10c25a5mr3138695ejc.678.1665129320346; Fri, 07 Oct 2022 00:55:20 -0700 (PDT) Received: from fedora.sec.9e.network (ip-094-114-232-236.um31.pools.vodafone-ip.de. [94.114.232.236]) by smtp.gmail.com with ESMTPSA id hv13-20020a17090760cd00b00741a0c3f4cdsm782281ejc.189.2022.10.07.00.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 00:55:20 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin Cc: robh@kernel.org, laurent.pinchart@ideasonboard.com, wsa@kernel.org, Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v9 2/4] i2c: muxes: pca954x: Add MAX735x/MAX736x support Date: Fri, 7 Oct 2022 09:53:51 +0200 Message-Id: <20221007075354.568752-3-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007075354.568752-1-patrick.rudolph@9elements.com> References: <20221007075354.568752-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add support for the following Maxim chips using the existing PCA954x driver: - MAX7356 - MAX7357 - MAX7358 - MAX7367 - MAX7368 - MAX7369 All added Maxim chips behave like the PCA954x, where a single SMBUS byte write selects up to 8 channels to be bridged to the primary bus. While the MAX7357/MAX7358 have interrupt support, they don't act as interrupt controller like the PCA9545 does. Thus don't enable IRQ support and handle them like the PCA9548. Tested using the MAX7357 and verified that the stalled bus is disconnected while the other channels remain operational. Signed-off-by: Patrick Rudolph --- drivers/i2c/muxes/Kconfig | 6 +-- drivers/i2c/muxes/i2c-mux-pca954x.c | 60 ++++++++++++++++++++++++++++- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig index ea838dbae32e..db1b9057612a 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/PCA984x and Maxim MAX735x/MAX736x 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. + If you say yes here you get support for NXP PCA954x/PCA984x + and Maxim MAX735x/MAX736x 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 a5f458b635df..4b63b1eb669e 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -4,6 +4,7 @@ * * Copyright (c) 2008-2009 Rodolfo Giometti * Copyright (c) 2008-2009 Eurotech S.p.A. + * Copyright (c) 2022 9elements GmbH * * This module supports the PCA954x and PCA984x series of I2C multiplexer/switch * chips made by NXP Semiconductors. @@ -11,6 +12,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 are controlled + * as the NXP PCA9548 and the MAX736x chips that act like the PCA9544. + * + * This includes the: + * MAX7356, MAX7357, MAX7358, MAX7367, MAX7368 and MAX7369 + * * 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 @@ -51,6 +58,12 @@ #define PCA954X_IRQ_OFFSET 4 enum pca_type { + max_7367, + max_7368, + max_7369, + max_7356, + max_7357, + max_7358, pca_9540, pca_9542, pca_9543, @@ -90,8 +103,41 @@ struct pca954x { raw_spinlock_t lock; }; -/* Provide specs for the PCA954x types we know about */ +/* Provide specs for the MAX735x, PCA954x and PCA984x types we know about */ static const struct chip_desc chips[] = { + [max_7356] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7357] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7358] = { + .nchans = 8, + .muxtype = pca954x_isswi, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7367] = { + .nchans = 4, + .muxtype = pca954x_isswi, + .has_irq = 1, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7368] = { + .nchans = 4, + .muxtype = pca954x_isswi, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, + [max_7369] = { + .nchans = 4, + .enable = 0x4, + .muxtype = pca954x_ismux, + .has_irq = 1, + .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, + }, [pca_9540] = { .nchans = 2, .enable = 0x4, @@ -177,6 +223,12 @@ static const struct chip_desc chips[] = { }; static const struct i2c_device_id pca954x_id[] = { + { "max7356", max_7356 }, + { "max7357", max_7357 }, + { "max7358", max_7358 }, + { "max7367", max_7367 }, + { "max7368", max_7368 }, + { "max7369", max_7369 }, { "pca9540", pca_9540 }, { "pca9542", pca_9542 }, { "pca9543", pca_9543 }, @@ -194,6 +246,12 @@ 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 = "maxim,max7367", .data = &chips[max_7367] }, + { .compatible = "maxim,max7368", .data = &chips[max_7368] }, + { .compatible = "maxim,max7369", .data = &chips[max_7369] }, { .compatible = "nxp,pca9540", .data = &chips[pca_9540] }, { .compatible = "nxp,pca9542", .data = &chips[pca_9542] }, { .compatible = "nxp,pca9543", .data = &chips[pca_9543] }, From patchwork Fri Oct 7 07:53:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 613324 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 261E6C433F5 for ; Fri, 7 Oct 2022 07:55:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbiJGHzg (ORCPT ); Fri, 7 Oct 2022 03:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229949AbiJGHzd (ORCPT ); Fri, 7 Oct 2022 03:55:33 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84EECA3F72 for ; Fri, 7 Oct 2022 00:55:23 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id k2so9617535ejr.2 for ; Fri, 07 Oct 2022 00:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IAsasmO7g/6k+o87zhE3eY9RjJZRdde+lIh1KAwHyqU=; b=GvNuFPVrtrMw596Rv+jIptEuBFw0MpxQ7nzQ5TquuYZgP1HWdJlQxh0rKhl0FsXx6N wq4dUBu9cRkHn7jn/jsy6y5083zt34pXeSd7685JwSpOPE2ihzpyCLK/WzHaAs6zmJvo /1DQIuVv9s6YXSP+aadyQivDtxtr4NICM8YyGoXwYHvVPizgeK3t10woTTMPQ52azK8R ZoE22uo2O/LtYKmNVxj1pMUWuB5/8co9Ox7TwFhw9UpnQQ2poQRGNUb6OK+82O+EczQE n/XbvhG+1SfIHYAQrprWbo6DbgL30kWmaN91o8bSlq4/+avovt0m6kVPVOh4gk7lgMIk qjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IAsasmO7g/6k+o87zhE3eY9RjJZRdde+lIh1KAwHyqU=; b=I0tCUNknVVLvU6Aiic2TcTBTgpEHU3foej14ujVBWGEa6SY9FL4sqiLIAH+BJ1yG+J uzrXzsQznVdcvozyEta8PRJfYDc0cGltCtiGEJ0+Ooj9DPm6IaW5X4/1A7l7F0csW41M pqDT73tnc55CNhlzLBjgCezVQT6dCOP1/nBjIgrZnIfBUBcQJ98EvLe8hojuGa1DPhw7 UpP+E7PlNjBreRFJ2iW6fRemFrjf+ZdGF4i3wUyQ+A80buJCEVpp+7RnW7UDHAbGWnY4 mlVQXuFwJK5iLPk745ZqRX26+HMwgi+uNbjm52PxNH3Ebu0u5dEUlB+QWEGtqbRsgpe8 uIlg== X-Gm-Message-State: ACrzQf2lN5eF/UyQ7No5lVloE9RpGMtNyVUPhS1En3vqBGilKkiKMOA2 WozdMOppar/olWRxsjDOvdEXOA== X-Google-Smtp-Source: AMsMyM4Wa5/r7AkPfMTO1KcRDqVn3IeXxzQ5ysyTXBnV/hSpQ4VeJnwsOLblARxfOivJzWcCeXRT/g== X-Received: by 2002:a17:907:7204:b0:783:e152:f1f1 with SMTP id dr4-20020a170907720400b00783e152f1f1mr3112681ejc.119.1665129321410; Fri, 07 Oct 2022 00:55:21 -0700 (PDT) Received: from fedora.sec.9e.network (ip-094-114-232-236.um31.pools.vodafone-ip.de. [94.114.232.236]) by smtp.gmail.com with ESMTPSA id hv13-20020a17090760cd00b00741a0c3f4cdsm782281ejc.189.2022.10.07.00.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 00:55:21 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin Cc: robh@kernel.org, laurent.pinchart@ideasonboard.com, wsa@kernel.org, Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v9 3/4] i2c: muxes: pca954x: Configure MAX7357 in enhanced mode Date: Fri, 7 Oct 2022 09:53:52 +0200 Message-Id: <20221007075354.568752-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007075354.568752-1-patrick.rudolph@9elements.com> References: <20221007075354.568752-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org The MAX7357 and MAX7358 have 6 additional registers called enhanced mode in the following paragraphs. While the MAX7357 exposes those registers without a special sequence, the MAX7358 requires an unlock sequence. The enhanced mode allows to configure optional features which are nice to have on an I2C mux, but are not mandatory for it's general operation. As I don't have a MAX7358 for testing the special unlock sequence the enhanced mode isn't used on the MAX7358, but it could be added later if required. The MAX7357 enhanced mode is used to configure the chip to - Disable interrupts on bus locked up detection - Enable bus locked-up clearing - Disconnect only locked bus instead of all channels This configuration protects the I2C tree from total failure and attempts to unbrick the faulty bus. It's unclear why this isn't the default configuration. Tested using the MAX7357 and verified that the stalled bus is disconnected while the other channels remain operational. Signed-off-by: Patrick Rudolph --- drivers/i2c/muxes/i2c-mux-pca954x.c | 46 ++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 4b63b1eb669e..992976fa6798 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -57,6 +57,37 @@ #define PCA954X_IRQ_OFFSET 4 +/* + * The MAX7357 and MAX7358 have 6 additional registers called enhanced mode + * in the following paragraphs. While the MAX7357 exposes those registers + * without a special sequence, the MAX7358 requires an unlock sequence. + * + * The first enhanced mode register called CONF allows to configure + * additional features. + */ +#define MAX7357_REG_SWITCH 0 +#define MAX7357_REG_CONF 1 +#define MAX7357_CONF_INT_ENABLE BIT(0) +#define MAX7357_CONF_FLUSH_OUT BIT(1) +#define MAX7357_CONF_RELEASE_INT BIT(2) +#define MAX7357_CONF_LOCK_UP_CLEAR_ON_READ BIT(3) +#define MAX7357_CONF_DISCON_SINGLE_CHAN BIT(4) +#define MAX7357_CONF_BUS_LOCKUP_DETECTION_DISABLE BIT(5) +#define MAX7357_CONF_ENABLE_BASIC_MODE BIT(6) +#define MAX7357_CONF_PRECONNECT_TEST BIT(7) + +/* + * On boot the MAX735x behave like a regular MUX. Apply a fixed + * default configuration on MAX7357 that: + * - disables interrupts + * - sents automatically flush-out sequence on locked-up channels + when a lock-up condition is detected + * - isolates only the locked channel instead of all channels + * - doesn't disable bus lock-up detection. + */ +#define MAX7357_CONF_DEFAULTS (MAX7357_CONF_FLUSH_OUT | \ + MAX7357_CONF_DISCON_SINGLE_CHAN) + enum pca_type { max_7367, max_7368, @@ -82,6 +113,7 @@ struct chip_desc { u8 nchans; u8 enable; /* used for muxes only */ u8 has_irq; + u8 maxim_enhanced_mode; enum muxtype { pca954x_ismux = 0, pca954x_isswi @@ -113,6 +145,7 @@ static const struct chip_desc chips[] = { [max_7357] = { .nchans = 8, .muxtype = pca954x_isswi, + .maxim_enhanced_mode = 1, .id = { .manufacturer_id = I2C_DEVICE_ID_NONE }, }, [max_7358] = { @@ -452,6 +485,7 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc) static int pca954x_init(struct i2c_client *client, struct pca954x *data) { + struct i2c_adapter *adap = client->adapter; int ret; if (data->idle_state >= 0) @@ -459,7 +493,17 @@ 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 (data->chip->maxim_enhanced_mode) { + if (i2c_check_functionality(adap, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + ret = i2c_smbus_write_byte_data(client, data->last_chan, + MAX7357_CONF_DEFAULTS); + } else { + dev_warn(&client->dev, "Didn't configure enhanced defaults\n"); + ret = i2c_smbus_write_byte(client, data->last_chan); + } + } else { + ret = i2c_smbus_write_byte(client, data->last_chan); + } if (ret < 0) data->last_chan = 0; From patchwork Fri Oct 7 07:53:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Rudolph X-Patchwork-Id: 613675 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 849E6C433FE for ; Fri, 7 Oct 2022 07:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229980AbiJGHzf (ORCPT ); Fri, 7 Oct 2022 03:55:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiJGHzd (ORCPT ); Fri, 7 Oct 2022 03:55:33 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83C0E48EBD for ; Fri, 7 Oct 2022 00:55:24 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id l22so5921546edj.5 for ; Fri, 07 Oct 2022 00:55:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BYnWsZ0o5AknCBOblpHFLOK7lMI23PzUmjP6lQfCMsQ=; b=avOmEXJ6cStT+owLJndU87sr6b/pMzEYqRcsQYA1o7N41r1bLRrsz2hPfaDds2s52w KgywaP3cKvGgE/wamq8qicWJQ2H2nuif8Ust4HTrnG4dFeFQsBN3kYsjnfWxioE1bhSs 8sROmt2UKBsJvVylcN/VyLHpH3lurz8h3PwJX9oj2GbCWuPkVL/IX/Mm7T/spKAYxUR/ SIulbdY5vb/5JdfOhEAOK8QYQVl7SWqdx+dvj3zxIGK6VMy63AjFJsjhjH2Hdt4vtOdS q8QbdmAHGcSXD+unGR/ZJLH+UCS0rcaAJkFyJ60HtLNNyrdGG+YorbMvo8HlSynZi/rk ZPaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BYnWsZ0o5AknCBOblpHFLOK7lMI23PzUmjP6lQfCMsQ=; b=RVhCvIqQQ+PQLapw5MQCOJF3eqaYeSBNBJhoLxfKO9Wko01l7VGEKJecc5cjg3wP3g vOBsuHUV5S3Gmyo+gSZD7VMBo/XQbJ1ljo3vidZfmEL43xwtnFw0zyymatJIl+hu0qSS o3qQWz52ajlGnjTcTN7wEgyId5nXKTQ5X7zK47EtlZzopqdYXRn9n+TwubfcHavlmpg4 iZ/lGGnNVPU07PrvvoaSrk2THOWpG5TAGjLGpzlntMQpF46IFB458Hk+ezULyYmkCARj 270IT9Hl21TnznyGY63R1siWhaiUApK7VejENNk3EaTrc0hee6HKY9ADGq67lK1W4ROa +cZA== X-Gm-Message-State: ACrzQf0bGOENlUEc7qDrsj+EqgTm5PjPr6LIwLd0HryB+GzInj7wrm2f fdetkc241mLDKzAfd8heXw76MQ== X-Google-Smtp-Source: AMsMyM68rpMJy/RPe5slntPvR0+sj6c9rJWQ/6TZKc+/UJZagyRK49iVg8RHaE+sI1eBsinloVuF5Q== X-Received: by 2002:a05:6402:1d55:b0:459:9dc3:85cb with SMTP id dz21-20020a0564021d5500b004599dc385cbmr3383488edb.353.1665129322550; Fri, 07 Oct 2022 00:55:22 -0700 (PDT) Received: from fedora.sec.9e.network (ip-094-114-232-236.um31.pools.vodafone-ip.de. [94.114.232.236]) by smtp.gmail.com with ESMTPSA id hv13-20020a17090760cd00b00741a0c3f4cdsm782281ejc.189.2022.10.07.00.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Oct 2022 00:55:22 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin Cc: robh@kernel.org, laurent.pinchart@ideasonboard.com, wsa@kernel.org, Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v9 4/4] i2c: muxes: pca954x: Add regulator support Date: Fri, 7 Oct 2022 09:53:53 +0200 Message-Id: <20221007075354.568752-5-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221007075354.568752-1-patrick.rudolph@9elements.com> References: <20221007075354.568752-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Add a vdd regulator and enable it for boards that have the mux powered off by default. Signed-off-by: Patrick Rudolph Reviewed-by: Peter Rosin --- drivers/i2c/muxes/i2c-mux-pca954x.c | 34 ++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 992976fa6798..857a4ec387be 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -133,6 +134,7 @@ struct pca954x { struct irq_domain *irq; unsigned int irq_mask; raw_spinlock_t lock; + struct regulator *supply; }; /* Provide specs for the MAX735x, PCA954x and PCA984x types we know about */ @@ -473,6 +475,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); @@ -531,15 +536,32 @@ 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, "vdd"); + if (IS_ERR(data->supply)) { + ret = PTR_ERR(data->supply); + if (ret != -EPROBE_DEFER) + dev_err(dev, "Failed to request regulator: %d\n", ret); + return ret; + } + + ret = regulator_enable(data->supply); + if (ret) { + dev_err(dev, "Failed to enable regulator: %d\n", ret); + 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); @@ -556,7 +578,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 || @@ -564,7 +586,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; } } @@ -583,7 +606,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);