Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp4336290pxb; Wed, 20 Apr 2022 00:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx52lWPycZVA7yBboT/BL3rNkVcDJ2i7nkH3JnROysxwgPiM3hNxf+O290EodEJVYVxQ9/q X-Received: by 2002:a17:902:7404:b0:158:bff8:aa13 with SMTP id g4-20020a170902740400b00158bff8aa13mr19240354pll.133.1650439839113; Wed, 20 Apr 2022 00:30:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650439839; cv=none; d=google.com; s=arc-20160816; b=zHVKZ/fWdxtYHJtB1PaioZi3Xtxy4hpvPYEXXNmx0FrssoYrfx59N8Ij1Ohl6Vi/Ob y2j0sIkwGHqfeJ73xMdDaKIxMfC45jWB2xa82fuVl9T3D6BvNzIUZk2fp6RASCvigPdX sVnvsDwvxpRE0iRukWxSjl0D1DkGLVVCCQgvFRxnMx0tukGZBqrns3MEXz3vcRPuRdYs mZOaDdx7F3TRGGqYO7D4PCuIV8JyTBMK+cFvmYtUg+8UWhtKDde48csYDG48SqxoFcEa 1zkl/uV50AclVFMJ2IbouJWob5sDnr7YN1IitbLrtsW0qNz55fnPzOlzTaPO0aKXs560 x5gg== 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=CentrNXKSQFtoskGJlxUqU8zX0zrZiDPIjJai3Ha6oE=; b=LCKFXugDVZDbRIwwoltTUcfucqN1AALWrv69zQWX96eh1OmP8v+zJ9NDCF1u89B0Dd lRWp3RqP+pK3q2+cpT+G7ziZ4TWlrowX1EdRUNzHoT5bvPqVglWDXs/fATLK6/y5JX0j l3+Gl1fz11onHnJdBhOlc01wDyVtBhhm7IaQj08upwP0Wo296CN8Y0br76VVnjCFe6dX zKLA6QUJoHTTTPDvjYpG5dGft6jeM9tCHShOXwVnkdcXWwBSYznH1uTnZ7Bq/5UXjdbP UISgO++7Rt/DCfjrdDfveoGI6X2q5R7bl+HGL1vF6OSoM4NUX5hno/teMt5Istux0sEN 9ujw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=L5qFBf76; 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 o1-20020a17090a678100b001d282c4d323si1315612pjj.104.2022.04.20.00.30.23; Wed, 20 Apr 2022 00:30:39 -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=L5qFBf76; 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 S1352360AbiDSMoF (ORCPT + 99 others); Tue, 19 Apr 2022 08:44:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350858AbiDSMnq (ORCPT ); Tue, 19 Apr 2022 08:43:46 -0400 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4917E31928 for ; Tue, 19 Apr 2022 05:41:03 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id 11so16055577edw.0 for ; Tue, 19 Apr 2022 05:41:03 -0700 (PDT) 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=CentrNXKSQFtoskGJlxUqU8zX0zrZiDPIjJai3Ha6oE=; b=L5qFBf76Si6AIGEi/Y74BymuYRaRImc3HJIwqI8zppZKsQCg/+5DUo9iOq5nm5vJaw 8+vBU1vSyMTnN1kGy8+FdYZXbjR3Yh7TiC9CTvTmBfWYNcHY1++wradcfCDogj5gsVw3 FlVb97xJDCQsVBF8tcielGJkKLEOxUnO16oePCXuO/bvC/jl8y9BqAhxWyxXUND1Pb5x eUXxSYCXb6K21I56FFQkuJZ7YpFXMUm52BAvQgjw/IMT/I3Y+w8oCXOlZYslW+Cb3exi rgFf1VKJbYsV+rveCwfGlm0zGTuV07THYyQRG4wbmG+Wov1cWAKOq4EbFOkYbTfFmP9e af6g== 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=CentrNXKSQFtoskGJlxUqU8zX0zrZiDPIjJai3Ha6oE=; b=r0a/SiLsX1N23sMwxuYbMkmQRaBDH0CnclAgm/Bc1bIe6HwN4YUvgEENXC0aT6B2lX VbfpmGrsADXtx6gcPXyAyMRYRRDaeLnGSCxeDWXbyf9O2c156uDXggoZ6PKLh7PJrCCP XeJQ4DiSv0AiMhT99kldrE/6Jd7lu0HN+SPQOgY/Dw5/G4qxBb9/pkIG0dIEj5pnpe70 blDTCqnpingnntN9uYIXinNVW0IuI+aTHQMtThiQPCPavUJ+lX791YtQWOC0do1zH4Jz Hg4ASFnsE4wvUTbGjbx7OIlp2cBkWw5GZbryRp2oqXZ77iIUXKQzYsy24g9/dqXEZoU8 xW9A== X-Gm-Message-State: AOAM531S7Mf3XF6s5DFB/QYTn4vnuhSoqp04uEFwK/+KrzxLArLFUW8Y OeNU6CTOmTIbOMTB5/RY8LYc4Q== X-Received: by 2002:a05:6402:1908:b0:423:d634:126d with SMTP id e8-20020a056402190800b00423d634126dmr14705201edz.216.1650372061871; Tue, 19 Apr 2022 05:41:01 -0700 (PDT) Received: from fedora.lab.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id n27-20020a1709062bdb00b006da975173bfsm5709274ejg.170.2022.04.19.05.41.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Apr 2022 05:41:01 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [v8 3/3] i2c: muxes: pca954x: Add regulator support Date: Tue, 19 Apr 2022 14:40:24 +0200 Message-Id: <20220419124025.1733230-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220419124025.1733230-1-patrick.rudolph@9elements.com> References: <20220419124025.1733230-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=unavailable 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: 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 122b7a28fc60..6c43d420e349 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.35.1