Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1908391lqa; Tue, 30 Apr 2024 02:59:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXspEtyELScKDdAkyCZcr8NWfE1Gl97HfO0HKY8W4S/hyntts/ANbL9M74IsGqIbtlRSjlf4oEGyItgMwJCwziWJUoyNLbrTHZR9DOGEg== X-Google-Smtp-Source: AGHT+IE3Qa5UqlDDvISv3JzMj8PMLN73mo8nJ1bCX9OwMFii0wMdN6Uk15516v3Q7p4v3cOh0bYd X-Received: by 2002:a17:907:175c:b0:a52:71d6:d605 with SMTP id lf28-20020a170907175c00b00a5271d6d605mr2160886ejc.23.1714471158572; Tue, 30 Apr 2024 02:59:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714471158; cv=pass; d=google.com; s=arc-20160816; b=eeTwNS5DQvD6M9mgfWLKy2hFiuPVuZDNpdRHQQCllULHX7LdC2PVOZ57iUsTbbF2l9 cts0yz88bQ8ZeZ2r48ytCgRbQNYhGCxHkaTs+D6YHw6tR8QhecgifF8fLat2OCn7bHRu bLWiWsW1G4QMTR5WnrHtwGvleSiVjza6fnm4wCrteT7Knro88JV4Q+CxqX8Jz5MJyjP7 odBsZZHZn+7NbX0jvKnWi3c4KyXto9WJJ7qwtdnwhZscjhRpY29T0XMy1usTzDoIRcCZ BVohSQnXpDs3+myH9MIswabYKa2P2gDcBiaReC5MOKqEfl6hdDsRz6RO/ajpbzux7yq6 9chg== 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; bh=MEhRx/eminGXkoHU/GdpShrTkROQbmG+qbsPtXK6wVk=; fh=tnqHSLcNjGPJ99BdeEeSs5RnuwjnVS1kZmtKFj0LaU0=; b=YYsofwq7D4MxCVG5BWMz+wMSZnYVoDVKoYchQixTtWQWXMbHRsbjIaLEMySTOtS1p1 Ve0EkD8C7XwvPs4KNEDD2mWYDPyuALRX/baxCbBeoFB/uLqT9FRP/RAR2/wnODG9EcDt fC5tK1fGyNs9b7FC2JvrArWKXCMrYvZ9qMOrjiWOTiSfGbv1rAdFWmaVqXw9hMcGARTE dvgpIgIIj0c3V7i5MD1QN9p9CdgRCURg5uHIPb9kyFaDMoP/F8F96Hn91QAXvRUhYb4X zywrDVhajbpuFXtwUe0wJ6JQEEaU+YQ3b4vWiScxzwnlB6hKaFADTgVENwACuURyw/x2 De5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=richtek.com); spf=pass (google.com: domain of linux-kernel+bounces-163731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163731-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b3-20020a170906150300b00a555eae898esi15038611ejd.108.2024.04.30.02.59.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 02:59:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=richtek.com); spf=pass (google.com: domain of linux-kernel+bounces-163731-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163731-linux.lists.archive=gmail.com@vger.kernel.org" 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 518401F24384 for ; Tue, 30 Apr 2024 09:59:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E03F129E92; Tue, 30 Apr 2024 09:58:53 +0000 (UTC) Received: from mg.richtek.com (mg.richtek.com [220.130.44.152]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9717127B66 for ; Tue, 30 Apr 2024 09:58:49 +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=1714471132; cv=none; b=umR29tjSxSbw4AXO6ZQJEigO6kYYREb4YHJG5VxsnXyXorUA/dXuEoKIqp+foIei3ufLWSOX5Gh7af3FvpEqIUXmZ6+tLrv0MyhxL6Yl2oOFoTteOPN8MjyKs3Zur/9K78hY9mmewWGvUgNTABaFDjK1r0IvZTMeK5wCx3QTOWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714471132; c=relaxed/simple; bh=TAIbU6KIXHjSHkPESe/qiPcIp+0I21hFgkQKToxiK8w=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=knOLZsV/6LVb1NgcJnM7S2R8cbCAVFAQ/4LfEee2h/VwyHOA/NWyJdRjS8ywCKod+jGyW8FeLZarUhLM6IGyabfQV/Sj3W23b51O0e9q61Kwd+mHLnuQP0A/M4hq3wS8Hdq8YxcwoBXS8XB3uYXe2dzHfCGySx9FnBTl7ILHY/c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=richtek.com; spf=pass smtp.mailfrom=richtek.com; arc=none smtp.client-ip=220.130.44.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none 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) Received: from 192.168.10.46 by mg.richtek.com with MailGates ESMTPS Server V6.0(3367349:0:AUTH_RELAY) (envelope-from ) (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256/256); Tue, 30 Apr 2024 17:58:30 +0800 (CST) Received: from ex4.rt.l (192.168.10.47) by ex3.rt.l (192.168.10.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 30 Apr 2024 17:58:30 +0800 Received: from linuxcarl2.richtek.com (192.168.10.154) by ex4.rt.l (192.168.10.45) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 30 Apr 2024 17:58:30 +0800 From: Alina Yu To: , CC: , , , Subject: [PATCH v2 2/4] regulator: rtq2208: Fix LDO to be compatible with both fixed and adjustable vout Date: Tue, 30 Apr 2024 17:58:25 +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 the init_data->constraints. If adjustable, the Vout can be set to either 1800mV or 3300mV. Signed-off-by: Alina Yu --- drivers/regulator/rtq2208-regulator.c | 41 +++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/drivers/regulator/rtq2208-regulator.c b/drivers/regulator/rtq2208-regulator.c index 63d4037..80a4d2f 100644 --- a/drivers/regulator/rtq2208-regulator.c +++ b/drivers/regulator/rtq2208-regulator.c @@ -220,7 +220,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, @@ -229,6 +229,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 unsigned int rtq2208_of_map_mode(unsigned int mode) { switch (mode) { @@ -323,12 +340,12 @@ static irqreturn_t rtq2208_irq_handler(int irqno, void *devid) return IRQ_HANDLED; } -static int rtq2208_of_get_fixed_voltage(struct device *dev, +static int rtq2208_of_get_ldo_dvs_ability(struct device *dev, struct of_regulator_match *rtq2208_ldo_match, int n_fixed) { struct device_node *np; struct of_regulator_match *match; - struct rtq2208_regulator_desc *rdesc; + struct regulator_desc *desc; struct regulator_init_data *init_data; int ret, i; @@ -349,13 +366,20 @@ static int rtq2208_of_get_fixed_voltage(struct device *dev, for (i = 0; i < n_fixed; 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; + if (init_data->constraints.min_uV == init_data->constraints.max_uV) { + desc->n_voltages = 1; + desc->fixed_uV = init_data->constraints.min_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; @@ -482,8 +506,7 @@ static int rtq2208_parse_regulator_dt_data(int n_regulator, const unsigned int * rtq2208_ldo_match[idx - RTQ2208_LDO2].desc = &rdesc[i]->desc; } - /* init ldo fixed_uV */ - ret = rtq2208_of_get_fixed_voltage(dev, rtq2208_ldo_match, ldo_idx); + ret = rtq2208_of_get_ldo_dvs_ability(dev, rtq2208_ldo_match, ldo_idx); if (ret) return dev_err_probe(dev, ret, "Failed to get ldo fixed_uV\n"); -- 2.7.4