Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5233391rwr; Mon, 1 May 2023 02:17:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4se7IqJrqcvznMTqsZo3NzWGu1CtMc9jjxMf2+FkrAEfF4riMDjO6fRyVNd1Fg3CcJUkle X-Received: by 2002:a17:902:db04:b0:1a6:b5b2:6a25 with SMTP id m4-20020a170902db0400b001a6b5b26a25mr16775698plx.2.1682932648787; Mon, 01 May 2023 02:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682932648; cv=none; d=google.com; s=arc-20160816; b=cQqWN8BPVab9FPmU1/EFlsnW5xOOU4l5caV+BM4yBn5hRtBrTqSzcEmHhAZGnxM9/c gvmSUYeIkFknSmyoPofCQCsLeXSXyC7Vq2t/wmE5SRWQ0f+R9jWoW8dWW3ZAexl1jArx sa5pwrJreBJtg2YREYDrdM1l83JXT2nAV4iOda0cHfzVEdG9KUmBZ3r0mjKjU82wrKCD EU+posUZvyCBTUfrQwT8euRadjxEbBZixwkSwO7a+ms5QMiwSY/2y5apuMe+W0Oje0YR MN1j49XGLfyQ0hlCdTH21kp78aHjX64QA546IqWyKp5llnB3AuvL9EB9vSF/Kq5cQ36e W1Hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=deLhqHNlkRGaOVPkjyoMd684bHUV64uU06CP2w8Rkjc=; b=WI4Spm9KXzUkiyiAn/+GvmQDbstK7Hvje4G+ARYB8KT2Py0g4pgmELBpxUgQzgy9nl Dpe7zosOGK2amff4GJK2sw+flZM5jmCtc/j7c2FaWTBKzP//t4MbNMAVB7jhqAK5gJSl CwJBVt5Q2LpaGUm0JJnZBcKDan+OTF0aHJ40DFRhppWllire138XpksGEKyfc5Q6qfpa F7XkvvC8a0nQsfcQlnZ7ntlXTs98qWOCEufM4ZKnGPQVhJ5tV3Bf9Bg4bCPF1z34ectm NSGXT7bXTvmKK80d5AiBHH42Y4hyIdB+WJe+85lG0wF7uGDVuhDb9gwgxLg0eeVRQcOK n3Cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=gj0WDZrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s10-20020a170902c64a00b001a6d08dc834si25534086pls.22.2023.05.01.02.17.14; Mon, 01 May 2023 02:17:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=gj0WDZrv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbjEAJQO (ORCPT + 99 others); Mon, 1 May 2023 05:16:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjEAJQC (ORCPT ); Mon, 1 May 2023 05:16:02 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A03961AB for ; Mon, 1 May 2023 02:16:00 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-94a342f7c4cso467945466b.0 for ; Mon, 01 May 2023 02:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1682932560; x=1685524560; 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=deLhqHNlkRGaOVPkjyoMd684bHUV64uU06CP2w8Rkjc=; b=gj0WDZrvDo6kdPGp5lFtedx5wR7mFPU8FR0fdP8cVEhniVnsLG1KeCwwwnzFaUILX0 Caa1boWYSK1UkDkNcEXV0Pc9oOEvhyrWlWtdpazA65ypqCGKOEGgDVbYW9zt6w/uscZ9 yiolFislJzxwOdEH2pXWnabryAs8MJhTu1XTkMqe7OjGXxIhYJXgWVocGoPv1VfJHb1w V7RDc2/LQOjrHEpUAD4LShHCLdq2Jzr2BNUy8ldShYiUQ4I5rajthijHF0DJYtJXVTfX ZU7C/FCiyJo7d8YuIUjM2+i5eIq1Dg5oOO/VS5eBdofjNK+o4h4W+761L9A8EH5GxYEh zHhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682932560; x=1685524560; 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=deLhqHNlkRGaOVPkjyoMd684bHUV64uU06CP2w8Rkjc=; b=JsWGqglT133CZDtF8dwshWCJjFrYLlv1zOSKH2A7kyMHIiSFhOnfLDDglkntg+qEdg lNpYclYjQCrkCf+oKTxT3GW+Npy9HaM/d3gK4i8QpxrQF0WKYsDwFvR38DqD0ZwkvHCG RtDgfPPcQCtkLp1U4x4HpdsfqvjXT30u52K1umbddnUD2V9ggkRngbLs6X8Cd8c9qxRq RAKwv0ookdEnL91oC1MLxI31vR7q2HJoT7uVBumXmgKKOKitfJXBz35dppt4ofym0Ma4 ELZ7Xvti1TzM9rrAijRV+9QrDZFBd5me1LIo9SXXVK6XCubq4c7U/z5TnIPasLKJoFso OfkA== X-Gm-Message-State: AC+VfDxlp5es6Pyeg1SumUVDun9jyvYarNll+QyrnSERGbv9CqSZsJ7b 3Kfwi24DnG49H2ExI8B/d7QRRA== X-Received: by 2002:a17:907:728d:b0:95f:2046:d20d with SMTP id dt13-20020a170907728d00b0095f2046d20dmr12568044ejc.2.1682932560217; Mon, 01 May 2023 02:16:00 -0700 (PDT) Received: from fedora.. (ip-095-222-150-251.um34.pools.vodafone-ip.de. [95.222.150.251]) by smtp.gmail.com with ESMTPSA id xa3-20020a170907b9c300b0094e954fd015sm14714266ejc.175.2023.05.01.02.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 02:15:59 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin Cc: Patrick Rudolph , Andi Shyti , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v14 4/4] i2c: muxes: pca954x: Add regulator support Date: Mon, 1 May 2023 11:15:51 +0200 Message-Id: <20230501091552.847240-5-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501091552.847240-1-patrick.rudolph@9elements.com> References: <20230501091552.847240-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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: Andi Shyti --- drivers/i2c/muxes/i2c-mux-pca954x.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 968111442625..b863f7b18190 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 @@ -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 MAX735x, PCA954x and PCA984x types we know about */ @@ -444,6 +446,8 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc) struct pca954x *data = i2c_mux_priv(muxc); int c, irq; + regulator_disable(data->supply); + if (data->irq) { for (c = 0; c < data->chip->nchans; c++) { irq = irq_find_mapping(data->irq, c); @@ -496,10 +500,22 @@ static int pca954x_probe(struct i2c_client *client) i2c_set_clientdata(client, muxc); data->client = client; + data->supply = devm_regulator_get(dev, "vdd"); + if (IS_ERR(data->supply)) + return dev_err_probe(dev, PTR_ERR(data->supply), + "Failed to request regulator\n"); + + ret = regulator_enable(data->supply); + if (ret) + return dev_err_probe(dev, ret, + "Failed to enable vdd supply\n"); + /* 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); @@ -516,7 +532,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 || @@ -524,7 +540,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; } } @@ -543,7 +560,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); -- 2.39.2