From patchwork Wed Sep 20 08:53:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 13392312 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 917A5CE79AB for ; Wed, 20 Sep 2023 08:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=UU4RvAvMQevs9r3f8hEvuyQyCZrpG3AiOcFC6j2eUiU=; b=WEB4obMF+utMph zaHJ3aHHaccMaJwDtk71uvn/8x8MAoEv7ya5H8BwJiMUvxLB6nqqNA1WFIEErMQNbpFrnEI7jMb7H Wc2AheZkPQg6GOcb8JZsLoFOiSvtnnmyUR3/ST0cSaEyjt8y+9GQ4Joc9uFmmjRG3VuCiz28rT2ah IPEpfoxiwbtpFTyRX3YkrgtA4Zn4QCBEshjyYMj8HFoLIomAgXkEvfkXHfYTqHjwcxoJ5Wzz5qQRr OhbkgURRV8mFjDUlGmUf6PGoYz3QBlJhzF2Q07AG79DpTrv1/aaL5AvMB/uh6LWnik/XYX+TZklUj N9DSiPy6w+p52Iz7B45g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qisyz-002LpP-0B; Wed, 20 Sep 2023 08:54:53 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qisyv-002Lnl-1o for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2023 08:54:50 +0000 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-690bf8fdd1aso1782332b3a.2 for ; Wed, 20 Sep 2023 01:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695200088; x=1695804888; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=b2WIpX8UxaE2eUdENfJEhEi2DvYwtb84UnL6O0SUo1Q=; b=Pw6FPZDyRYyhDnjez0NXIFdqKobEF/Fi30Sgq2vuFsBYieNRnRY9R/7b3L5URYyhWh LdgizL+Zw3s2OBnC0TX6aI4PFHZMCXaHIhY5vKEX/PPryhZKYU5T6UaVt8hiJ4fBT3Km VTlMzTjHqMFkc6hf3hDqdRh3qr1CS022HMW+k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695200088; x=1695804888; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=b2WIpX8UxaE2eUdENfJEhEi2DvYwtb84UnL6O0SUo1Q=; b=jTuR+qJSiRss6pbP60KhuGdJlwMDrTLSskBEOPuruPhNUqTz+kxYbp4swyMvVPcgoe H75FEenetOzwLNEtlGV86CYsEijBQnRdns1ZrQi/JIxiXqlkSoATtWCVv1r8mPTQ/XWZ IZ9773ZgF1ySxBVsVS5MI3r3ljN5yuSGEDfNXnMyNmowf7iRJdhOyH5640SBEpJgz6PW Z45XLi3u5n0LdengdAm24o7vhiuAGMgwGNSJHMXsHaHC9gRD8/vFu3C1h3ZOilTb1L1o POnqUZtyaJKr75XkuGZmL9ZwsV/1S+FJck2TEFmzr5wEpIeMZaqW4kbTKfeIYzeW0ic4 9bjw== X-Gm-Message-State: AOJu0YyIeO08OfqH7/VeN7CGUnNECr1Ks4NGtgUWkDJblSn+FRtQXrXJ eXP2aRR50BFFsLYtqDbCrsA65w== X-Google-Smtp-Source: AGHT+IHVveuh+lATMhfAR9XUZNF/rqh9RwMphICIzbzgZrWEpzl1FQ9mTUPC9PSsdRJtmJ/PTbRk1w== X-Received: by 2002:a05:6a20:138c:b0:157:e4c6:765f with SMTP id hn12-20020a056a20138c00b00157e4c6765fmr1744078pzc.36.1695200088426; Wed, 20 Sep 2023 01:54:48 -0700 (PDT) Received: from wenstp920.tpe.corp.google.com ([2401:fa00:1:10:88b9:ebf4:698b:cf09]) by smtp.gmail.com with ESMTPSA id li11-20020a170903294b00b001b89466a5f4sm11340455plb.105.2023.09.20.01.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 01:54:48 -0700 (PDT) From: Chen-Yu Tsai To: Matthias Brugger , AngeloGioacchino Del Regno , Mark Brown Cc: Chen-Yu Tsai , Zhiyong Tao , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2] regulator: mt6358: split ops for buck and linear range LDO regulators Date: Wed, 20 Sep 2023 16:53:34 +0800 Message-ID: <20230920085336.136238-1-wenst@chromium.org> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230920_015449_596288_D13DE844 X-CRM114-Status: GOOD ( 14.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The buck and linear range LDO (VSRAM_*) regulators share one set of ops. This set includes support for get/set mode. However this only makes sense for buck regulators, not LDOs. The callbacks were not checking whether the register offset and/or mask for mode setting was valid or not. This ends up making the kernel report "normal" mode operation for the LDOs. Create a new set of ops without the get/set mode callbacks for the linear range LDO regulators. Fixes: f67ff1bd58f0 ("regulator: mt6358: Add support for MT6358 regulator") Signed-off-by: Chen-Yu Tsai --- Changes since v1: - Create a new set of ops for the LDOs, as suggested by Mark - Patch subject updated to match drivers/regulator/mt6358-regulator.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/regulator/mt6358-regulator.c b/drivers/regulator/mt6358-regulator.c index b9cda2210c33..65fbd95f1dbb 100644 --- a/drivers/regulator/mt6358-regulator.c +++ b/drivers/regulator/mt6358-regulator.c @@ -43,7 +43,7 @@ struct mt6358_regulator_info { .desc = { \ .name = #vreg, \ .of_match = of_match_ptr(match), \ - .ops = &mt6358_volt_range_ops, \ + .ops = &mt6358_buck_ops, \ .type = REGULATOR_VOLTAGE, \ .id = MT6358_ID_##vreg, \ .owner = THIS_MODULE, \ @@ -139,7 +139,7 @@ struct mt6358_regulator_info { .desc = { \ .name = #vreg, \ .of_match = of_match_ptr(match), \ - .ops = &mt6358_volt_range_ops, \ + .ops = &mt6358_buck_ops, \ .type = REGULATOR_VOLTAGE, \ .id = MT6366_ID_##vreg, \ .owner = THIS_MODULE, \ @@ -450,7 +450,7 @@ static unsigned int mt6358_regulator_get_mode(struct regulator_dev *rdev) } } -static const struct regulator_ops mt6358_volt_range_ops = { +static const struct regulator_ops mt6358_buck_ops = { .list_voltage = regulator_list_voltage_linear, .map_voltage = regulator_map_voltage_linear, .set_voltage_sel = regulator_set_voltage_sel_regmap, @@ -464,6 +464,18 @@ static const struct regulator_ops mt6358_volt_range_ops = { .get_mode = mt6358_regulator_get_mode, }; +static const struct regulator_ops mt6358_volt_range_ops = { + .list_voltage = regulator_list_voltage_linear, + .map_voltage = regulator_map_voltage_linear, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = mt6358_get_buck_voltage_sel, + .set_voltage_time_sel = regulator_set_voltage_time_sel, + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .get_status = mt6358_get_status, +}; + static const struct regulator_ops mt6358_volt_table_ops = { .list_voltage = regulator_list_voltage_table, .map_voltage = regulator_map_voltage_iterate,