Received: by 2002:ac8:156:0:b0:3e0:cd10:60c8 with SMTP id f22csp2499486qtg; Thu, 23 Mar 2023 04:58:12 -0700 (PDT) X-Google-Smtp-Source: AK7set8tnlFKArL8A3Lg8n8tX/n+c54PgIiQJIJ6v0qxXyPG0kEjO/3DFYt6RvZrwV7bu2F5v9+f X-Received: by 2002:aa7:d406:0:b0:500:3a14:82c1 with SMTP id z6-20020aa7d406000000b005003a1482c1mr8581183edq.41.1679572692537; Thu, 23 Mar 2023 04:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679572692; cv=none; d=google.com; s=arc-20160816; b=jrSIBwCjoG7v4mENz/JI/fRXcveW+ZxH6SyjGi5lSHSa9CzF8cs9iB3vGCrMLSi/ir srha6wM+yKkZhlp24lCT7a4+oCRP2LZOXeUrWrLuXFRWs6BvbEu+K6nT9dGqg6IHppbN qb936T7SJPmaxcOv3SC4x5QjLTr+X4jYWzam6qvV0mAztIUtJ4Eeb7wCqCoNIgxA4357 Pq8w/7vNtDe/WQo057/eX2MNyWfLNpVt82TEVy9rhVRYnnHqku2TaJ4VKu+A0skWfSQ0 feZnNvpyzo/NSu67PeMFFtb0YOqrl6WmuZf6weA50YluQdHwVBLD5xT7GpTx/bcO4DTm GdcA== 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=xwXKfhhEqm0u3hOwcWnbc9eMv2uIS61iRmPoBGhEqx8=; b=SjsorU5TN9couPKwW4Djefk30Tjj4dL6js1Sb0dXJ+iLTHjWkrWVNF4QfQH/y1jGt5 7RW9vs7fNBgFvJwDL25mayrePXhjJFyqeox5FGupAsd4tWlW1EjYvDmE84WGtTcG17mi 7/3TpAqAUnnpUcBqQqh4WWnLUiLSV9PeUbp7/EMVZykfMAx4Qn5o+1WLREPs6Y7AmfHr asRg4f+wJs+rDcxu/A4+reVqOBFp+sud7LW2br3tMDilemg2GB2xdrd6UKmzYTyFUII7 cM4uGILvD6SGqNSgnoAM05ZdPeZiBZVYimjaoaKoDGevIvkkiXAu92Xxic/rv7+jypUc BNGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=QpVV0iCO; 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 g21-20020aa7d1d5000000b004acc575090fsi19482570edp.36.2023.03.23.04.57.46; Thu, 23 Mar 2023 04:58:12 -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=QpVV0iCO; 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 S231849AbjCWLye (ORCPT + 99 others); Thu, 23 Mar 2023 07:54:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231743AbjCWLyQ (ORCPT ); Thu, 23 Mar 2023 07:54:16 -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 9DACE36440 for ; Thu, 23 Mar 2023 04:54:03 -0700 (PDT) Received: by mail-ed1-x535.google.com with SMTP id x3so85203507edb.10 for ; Thu, 23 Mar 2023 04:54:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1679572442; 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=xwXKfhhEqm0u3hOwcWnbc9eMv2uIS61iRmPoBGhEqx8=; b=QpVV0iCOdd/v9NX41dCw4Nec0YlnHwzuiVRcNBkX/1oQQe18FO3VBXdP9ICayeP/0F aOsFvgs1DqWdHGV+C0WVQDE2fq/BRFDKnk3iINV+UEeARPHd3X56Nldv77kO4Ulm3+B3 y1TyFlb78uGpFgLMaTtD/0xhrpBxDXzQui7ZPGg3w8OUdpH0LUVvz6346xBwf71kzNrP ciShAqFPG2KfKKVTh6xBa8P3NyaKlj6G1adVAK2D5kXgmfSfxe688SfeDpEU7K7sYv/Q Le7+YxBXk9jT1vD9GXfTKhAbyxP5BGTrdBLWLXr85r6tbKWRL383TmhDVs0gvT5mehiN spcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679572442; 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=xwXKfhhEqm0u3hOwcWnbc9eMv2uIS61iRmPoBGhEqx8=; b=iAJMAgGOcutDwAdX1eKkIoTnWt530KTlpf67hY+AQobsCiWMFqTDLi9a9m2pEHY+L4 H3jqFXcJZOIH2iV4wRjbGjZSrHs0mxy9Ja8DEaBobi0Fk9dOO4aGYG7hUZtGWPrcs4zP Pd0A3bYqgtqNnl64NAxfz776eAWWHsVhubLviF9CVKsMr8YYiGG0fgRndX5IBM51RIGQ 2FIoRUAcM4hZSXrFUoTDbE6FxR9BUdHgAtrUD64VSYw8u4YieKyI/um/7TDCB1ACigis YP8ZMHMZjThXWIsLPLNrXb1ImjyEG8IiZsrNnWMNoF/xWLEYgoBcWan/yR+IehcPskcI Qe/A== X-Gm-Message-State: AO0yUKXLcZTo9XEcWCPbfzp/NPCcdJNJOS67JMQ/wKhI2yMrtolH2NcI tqLY8RPJbEesIU0x8KM6rTDjsw== X-Received: by 2002:a17:906:3389:b0:8eb:d3a5:b9f0 with SMTP id v9-20020a170906338900b008ebd3a5b9f0mr9977599eja.67.1679572442112; Thu, 23 Mar 2023 04:54:02 -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 r5-20020a1709064d0500b00923f05b2931sm8510047eju.118.2023.03.23.04.54.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Mar 2023 04:54:01 -0700 (PDT) From: Patrick Rudolph To: Peter Rosin , Liam Girdwood , Mark Brown Cc: Patrick Rudolph , linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v10 3/3] i2c: muxes: pca954x: Add regulator support Date: Thu, 23 Mar 2023 12:53:55 +0100 Message-Id: <20230323115356.2602042-4-patrick.rudolph@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230323115356.2602042-1-patrick.rudolph@9elements.com> References: <20230323115356.2602042-1-patrick.rudolph@9elements.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 --- drivers/i2c/muxes/i2c-mux-pca954x.c | 35 ++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 39f313658b18..0d966a55b727 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 */ @@ -440,6 +442,9 @@ static void pca954x_cleanup(struct i2c_mux_core *muxc) struct pca954x *data = i2c_mux_priv(muxc); int c, irq; + if (data->supply) + regulator_disable(data->supply); + if (data->irq) { for (c = 0; c < data->chip->nchans; c++) { irq = irq_find_mapping(data->irq, c); @@ -492,10 +497,28 @@ static int pca954x_probe(struct i2c_client *client) i2c_set_clientdata(client, muxc); data->client = client; + data->supply = devm_regulator_get_optional(dev, "vdd"); + if (IS_ERR(data->supply)) { + ret = PTR_ERR(data->supply); + if (ret != -ENODEV) + return dev_err_probe(dev, ret, + "Failed to request regulator\n"); + else + data->supply = NULL; + } else { + 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); @@ -512,7 +535,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 || @@ -520,7 +543,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; } } @@ -539,7 +563,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.1