Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp452269lqo; Fri, 10 May 2024 05:15:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWHHRA3kUX9kMcY3l2eWyl373ZMGFpIxBbAinRlN6xicw2ZD3kMG6/j9wJxAYQedk24LoZMpWkXpEbtz1bAn2ZZ9lSgJF1YBfBfKZF/8Q== X-Google-Smtp-Source: AGHT+IEfegjhjG3klaXOs+yZ+G2t0o896XUGXQrKVmEGzA8NfBZURiT/mTMfo/lmNXQgQFpw6Cuz X-Received: by 2002:a05:6a21:601:b0:1af:cbd3:ab48 with SMTP id adf61e73a8af0-1afde0af528mr2418292637.3.1715343316212; Fri, 10 May 2024 05:15:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715343316; cv=pass; d=google.com; s=arc-20160816; b=X6rQ9sGJIrN3DTLwppWS6MIKw48+VDqTYGPQrkwwO3JT+pRQOz0k2PfwTEgCvl99Ci SZQOFWGQdvhwFrKf0hgDH/ZOi5I8cT1xl/x91cXxtary212B5crH52gGhLNSR1UWvL9Q AqoIVVYRyJPzXf2DcaCSB32U2JNSOUoonvF0R/QOZw62VTMl0v0KTtwRHe0foaSoWVrq 8sFJVDsUCMEYUa42yr7TAa2ri+i0fxRQmFuQFJ3Fv+AURMuUi7iArvT39DfC+e8tz5V0 s3HBfNWN/AhIM8116/ahWhsTDh+DiM4Y1McXjB6JRMBnckVvumtsON9PMtaiRHBqQ2u1 GJ6g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kaxYcbrb/9Pnuq7HbvF6NNsDEjH/9/v3t51VOdwTq+s=; fh=qPRq5XK4fWV0/iYtozG4A3WG6T1iyjVlgVQyi05onrM=; b=bL2ICAa+CZeSne/J9LfErAXy+5AjoJlyNg+e3BtdakEaoeG2SJBo0J9zVrT2d89I7u AOVf6LTqlplxqDwQJ9Lwy/+s2WmvpNuIYTlBdTPqj9JRnREAK/+bf/BfygtrRIeb3kvC RtMoMRpjJyLdpPGOtFXTo0DPqtJoUkAitwwJOWKWnk04Ho3UnKG53gNfpUgbthPutJjX SQ+d3qtq8iWF6bjdy+oYoHZlEs6n7SrAyE+A5hyW5F1bBMnagU4/VRhA0xD1DCgL5z48 fWrDRgK6al4snvB5WLc4qsN8KtcY9OMgRrXJKHNu4/d+GA2HE5+ykUzYon0mvSOh5s68 7xwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@richtek.com header.s=richtek header.b="R/4RG5DX"; arc=pass (i=1 spf=pass spfdomain=richtek.com dkim=pass dkdomain=richtek.com dmarc=pass fromdomain=richtek.com); spf=pass (google.com: domain of linux-kernel+bounces-175763-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=richtek.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-63412c369e6si3615515a12.747.2024.05.10.05.15.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 05:15:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175763-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@richtek.com header.s=richtek header.b="R/4RG5DX"; arc=pass (i=1 spf=pass spfdomain=richtek.com dkim=pass dkdomain=richtek.com dmarc=pass fromdomain=richtek.com); spf=pass (google.com: domain of linux-kernel+bounces-175763-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=richtek.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F31628EAAA for ; Fri, 10 May 2024 12:08:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFFE0171E4F; Fri, 10 May 2024 12:06:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=richtek.com header.i=@richtek.com header.b="R/4RG5DX" Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB3F816F296; Fri, 10 May 2024 12:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.130.44.152 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715342818; cv=none; b=q4OZFfNVzDepReH4TpSbQfw7Q8pZXUrpIFG5u8MEgr7+uxPKrG8rNBWAkziCOpRSKw2BFMqC6BbDtX7EyQ+lwTckJ3R/OvazDeWfnsUrFl8FdcXFbaXFEUt6NnDSWdFbzmHD4H0hM44Qvmtt3i3P6RGk8fdV85afcDAy2HQsCDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715342818; c=relaxed/simple; bh=g4vwY7Rm39oLvhxj4PQq6HqNHGET+DLV/YkHzXIxdHU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e6bEMNhPBODdrpWtV3oVyPFHpzPvMAwJZrD8vEIn7Ftvw+N8WjV/Fake+Pv0YfywJnGoU2aKAikO75zUU208P9Hzk6WNky5uYDISimfwseR3ZkoRvravxXvVm3YLe2vG/wvQlnU9nlxqDZyP0PnYswbS+8RlTe+6d5gQdg+rRng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=richtek.com; spf=pass smtp.mailfrom=richtek.com; dkim=pass (2048-bit key) header.d=richtek.com header.i=@richtek.com header.b=R/4RG5DX; arc=none smtp.client-ip=220.130.44.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=richtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=richtek.com X-MailGates: (SIP:2,PASS,NONE)(compute_score:DELIVER,40,3) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=richtek.com; s=richtek; t=1715342807; bh=kaxYcbrb/9Pnuq7HbvF6NNsDEjH/9/v3t51VOdwTq+s=; l=3451; h=From:To:Subject:Date:Message-ID:MIME-Version; b=R/4RG5DX87sAnovzHbiNuoNjR7l4h77JzrCqhUOLrcQLNyYOJhTUh61ZHTJRm7ABt C2l1kPubmfUsqY87rZSfobdlPey8j7/zV38R0YWUvKRhT0/V4cp4eb+d4IPE3p4PfI UAu9uVHAuFEhVZBMFCHxexMrWQp1HuILQjHKVIBmxFU3a1dMvCBjM33pPwr16oun3B aq2iPnxrzWvSiFJ8sPyT9qp92frVNzL9hazZ/JUna3nJfdtC6MY3idOAE9j6CG9o/M zSU9yQzutV3mXayvOb2WOL/HxWSNbbnJvYCECrT4otFlucgZhrwhe/A/46QgyHa151 PJVnKNp4PVYAg== Received: from 192.168.10.47 by mg.richtek.com with MailGates ESMTPS Server V6.0(3213204:0:AUTH_RELAY) (envelope-from ) (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256); Fri, 10 May 2024 20:06:33 +0800 (CST) Received: from ex3.rt.l (192.168.10.46) by ex4.rt.l (192.168.10.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 10 May 2024 20:06:33 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex3.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Fri, 10 May 2024 20:06:33 +0800 From: Alina Yu To: , , , , CC: , , , , Subject: [PATCH v3 5/6] regulator: rtq2208: Fix LDO to be compatible with both fixed and adjustable vout Date: Fri, 10 May 2024 20:06:24 +0800 Message-ID: X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain In this patch, LDO's adjustable and fixed Vout settings are compatible. The LDO Vout ability depends on "richtek,fixed-microvolt". If adjustable, the Vout can be set to either 1800mV or 3300mV. Signed-off-by: Alina Yu --- v3 - Add "richtek,fixed-microvolt" to specify LDO fixed voltage - Check specified desc->fixed_uV matches with constraints->min_uV and constraints->max_uV --- drivers/regulator/rtq2208-regulator.c | 43 ++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/rtq2208-regulator.c b/drivers/regulator/rtq2208-regulator.c index 2e9387f..c2c1689 100644 --- a/drivers/regulator/rtq2208-regulator.c +++ b/drivers/regulator/rtq2208-regulator.c @@ -219,7 +219,7 @@ static const struct regulator_ops rtq2208_regulator_buck_ops = { .set_suspend_mode = rtq2208_set_suspend_mode, }; -static const struct regulator_ops rtq2208_regulator_ldo_ops = { +static const struct regulator_ops rtq2208_regulator_ldo_fix_ops = { .enable = regulator_enable_regmap, .disable = regulator_disable_regmap, .is_enabled = regulator_is_enabled_regmap, @@ -228,6 +228,23 @@ static const struct regulator_ops rtq2208_regulator_ldo_ops = { .set_suspend_disable = rtq2208_set_suspend_disable, }; +static const struct regulator_ops rtq2208_regulator_ldo_adj_ops = { + .enable = regulator_enable_regmap, + .disable = regulator_disable_regmap, + .is_enabled = regulator_is_enabled_regmap, + .list_voltage = regulator_list_voltage_table, + .set_voltage_sel = regulator_set_voltage_sel_regmap, + .get_voltage_sel = regulator_get_voltage_sel_regmap, + .set_active_discharge = regulator_set_active_discharge_regmap, + .set_suspend_enable = rtq2208_set_suspend_enable, + .set_suspend_disable = rtq2208_set_suspend_disable, +}; + +static const unsigned int rtq2208_ldo_volt_table[] = { + 1800000, + 3300000, +}; + static struct of_regulator_match rtq2208_ldo_match[] = { {.name = "ldo2", }, {.name = "ldo1", }, @@ -358,8 +375,9 @@ static int rtq2208_of_get_ldo_dvs_ability(struct device *dev) { struct device_node *np; struct of_regulator_match *match; - struct rtq2208_regulator_desc *rdesc; + struct regulator_desc *desc; struct regulator_init_data *init_data; + u32 fixed_uV; int ret, i; if (!dev->of_node) @@ -379,13 +397,26 @@ static int rtq2208_of_get_ldo_dvs_ability(struct device *dev) for (i = 0; i < ARRAY_SIZE(rtq2208_ldo_match); i++) { match = rtq2208_ldo_match + i; init_data = match->init_data; - rdesc = (struct rtq2208_regulator_desc *)match->driver_data; + desc = (struct regulator_desc *)match->desc; - if (!init_data || !rdesc) + if (!init_data || !desc) continue; - if (init_data->constraints.min_uV == init_data->constraints.max_uV) - rdesc->desc.fixed_uV = init_data->constraints.min_uV; + /* specify working fixed voltage if the propery exists */ + ret = of_property_read_u32(match->of_node, "richtek,fixed-microvolt", &fixed_uV); + + if (!ret) { + if (fixed_uV != init_data->constraints.min_uV || + fixed_uV != init_data->constraints.max_uV) + return -EINVAL; + desc->n_voltages = 1; + desc->fixed_uV = fixed_uV; + desc->ops = &rtq2208_regulator_ldo_fix_ops; + } else { + desc->n_voltages = ARRAY_SIZE(rtq2208_ldo_volt_table); + desc->volt_table = rtq2208_ldo_volt_table; + desc->ops = &rtq2208_regulator_ldo_adj_ops; + } } return 0; -- 2.7.4