Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp624557pxb; Wed, 16 Feb 2022 00:10:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJydiXd9+mlpCW0SqIXULje2FNo2NiSD8oRCObRXjaCoL3uYOJlBBJp3xvAPHtBkz3Tm6H2U X-Received: by 2002:a63:50a:0:b0:363:79e7:ba6f with SMTP id 10-20020a63050a000000b0036379e7ba6fmr1337135pgf.280.1644999032585; Wed, 16 Feb 2022 00:10:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644999032; cv=none; d=google.com; s=arc-20160816; b=Y2uAiOfjnSpeVA2eB4X85qpoeRLprXvucKTwP2hGNt2WYZOl3aTX1pQJVunU0vmv60 CPzRYunAc9RRzOGye4VdXts8GHMYyforvCPzADPZmA1wHkt86plCHWrSfxd0chJ2L+N8 /2j+fOAEXGyyOdNyTiL0uq1n9EeaD4WhnFgQ2eOdGbAQRtWnFlAp3b6k8JvdAyou2I3J s55WoKmVtsD41/3AhIjhDfyUMx3KK/jHogF8SsshlVypSgc2Lf9u20qw4WjV15GOGkK/ 1Bl/iQHR9UEto4rhaU3bl8r04vSNGvGPrDKX3dbHYVfXLqbQhizCDCbH0SbMvVT/pf80 G5bA== 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=UXFVdha6mdWIMpTuHA+4tNIC4aJVupleztPzYIr+WPI=; b=UR05lfctk9kzgDJR2LDXZhUj+7TmCQCGqmfFe55kv90kyRYz3kvEMUEMi/V28GJJPo +fpvHh/9zsh0ym9k4z92n75Kh6PjMV5cQ4r1L/r8qL9F3XJdyKmUa6DORZVQDZ07N41T NfsgDoK2pp0jiab8ytYx23QiFrCdU5Bv5REtz+VLJpz2AkIsazhsY2IUVzHGaB8pT+lL SOwxyjuTePGC6eFnI3Mgx7iuBrJyF/c6n+xGzc9AVj2DWix1/pFUvlnrJlyr9E9ppLfI bbNyroFoRFT6aHoy7pe+J45VDJ9ceC3oTq5GwfjqdmHWjCULdZIMiqtPgxBHY1WZxw4Q yiCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=IWGOoTDE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u4si722280pfc.11.2022.02.16.00.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Feb 2022 00:10:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=IWGOoTDE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5E9CC9FB7C; Tue, 15 Feb 2022 23:48:16 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230521AbiBPHrd (ORCPT + 99 others); Wed, 16 Feb 2022 02:47:33 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:49454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbiBPHrR (ORCPT ); Wed, 16 Feb 2022 02:47:17 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1387CD30F for ; Tue, 15 Feb 2022 23:46:54 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id q17so2448822edd.4 for ; Tue, 15 Feb 2022 23:46:54 -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=UXFVdha6mdWIMpTuHA+4tNIC4aJVupleztPzYIr+WPI=; b=IWGOoTDEmlPr6DtIASuFxDjhqh5/L0fV+GCo/Si5iX3xTv5LSIB/gHCtw/jl/17UhV o8B9B91aM7Ay2uW/kJkTld1BNFL8oQhsz/JzoOEV2Ei6Gb1f6ABBYu1E1nnPcm4c3AIx KccTMJdDOg/2rXec48mltO60Om5XKWGSqP4QgjOa8MB7Txybrkb5eEEp6v0A1xxEfPQp gxaLx82Pjmh48q9sLqqU0AWpZ7yB6VUubrSnYaLCwXEdpGfJC2ZvQapy80SraRdztfHE Z/gDKy7aeJLNWkgdpmhD1a6m6J0FkxFZ4ThoST3TJhNenyVJjVgslooDOSULFlv94OCZ IEBA== 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=UXFVdha6mdWIMpTuHA+4tNIC4aJVupleztPzYIr+WPI=; b=tnUJlrx4vSmY6KD6cu9Z9RCuDWkXOHGFFP1ETg8pdQkezZBH23pTKWIGSIm/KdAaO5 dY7owMZmV5jUoRCUagJ4aL/OKA5NIoHtBMNFAcADDFnAbJBKRc00ZoWhdPebuz/HQwU5 MbqvwJqrXjmP9+MCI8ByvqYG6KXKeYLeFERPJeJSni3qccZ5hf00Z5Xg7XGvPGzZKXKe ++C20qqiDREe8gLQ6Fh5Up/DDNpdSdZeNi4WyFa3G6Vbl3psmJ2uEgQ95tAADtHqio6p /5Si+GttHqMQcMb/h5QyD/QAm1BG8tRXIvNNyrtRFJCpcVO6dIoKs7w3Sjd7Yx1zPBUN gJ4w== X-Gm-Message-State: AOAM531Ufgjn4nC4lTRpmXzLCRBNJWq7+1m+iVAZMLknhGjsgziPPiOY MONzdW3frfDy1un6KcCAHHD7qQ== X-Received: by 2002:aa7:c793:0:b0:408:4a69:90b4 with SMTP id n19-20020aa7c793000000b004084a6990b4mr1608214eds.58.1644997613266; Tue, 15 Feb 2022 23:46:53 -0800 (PST) Received: from fedora.sec.9e.network (ip-088-153-139-166.um27.pools.vodafone-ip.de. [88.153.139.166]) by smtp.gmail.com with ESMTPSA id gq1sm11615202ejb.58.2022.02.15.23.46.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:46:52 -0800 (PST) From: Patrick Rudolph To: Peter Rosin Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v6 3/3] i2c: muxes: pca954x: Add regulator support Date: Wed, 16 Feb 2022 08:46:12 +0100 Message-Id: <20220216074613.235725-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220216074613.235725-1-patrick.rudolph@9elements.com> References: <20220216074613.235725-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 --- 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 33b9a6a1fffa..e25383752616 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 @@ -119,6 +120,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 */ @@ -459,6 +461,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); @@ -513,15 +518,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); @@ -538,7 +560,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 || @@ -546,7 +568,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; } } @@ -565,7 +588,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.34.1