From patchwork Wed May 10 11:50:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92061 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3559011vqo; Wed, 10 May 2023 04:53:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4pQkXYgma7ZcAnI0rWxa2F2AH6boJ9T28OGXlhNpTE7z/wDVWzyDjKpfHhgAnxmmscR8X2 X-Received: by 2002:a17:90a:f30d:b0:24e:5f04:d72b with SMTP id ca13-20020a17090af30d00b0024e5f04d72bmr15737213pjb.48.1683719615988; Wed, 10 May 2023 04:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719615; cv=none; d=google.com; s=arc-20160816; b=P51WM+jh8ZFM5TTfAtl9wQpl2A0Q2P89ar52H54LpJZHVi4GjQfDf6+/GBDls+0VIa FRyHQo7I9XTveKEUFTFhaO4IuhYieMpraELpNiGWvTu3gAxr/krM6AQiMGOdioi6vkHY /h86Qab5Sfm5Xqkjk3ZQCf6B5hCmGsAGR8hsIQr66PLgTRhugbfpTYLmLvGFAmXHqgCb w+doH9AShP9oFvHgpiaf1RXXCsqDuUY2SchpvuLDdR1ImpKOm3lriybukIblCwi//mrv l+hVRrQRUfjmaNj7nJcvFG51MERsLuzq0SnwagMSlCj74oKoLxb+ukYp0LAX+2jiCXkh 7b+g== 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=R1tUd+v3AgC5rEmN1z0CLTt+c2Ip3+6zTXGdLmF/kHw=; b=ovh5vzX86MMm1iIvk9Zi0vq4CQjn/LqbpOWjBqPpgpkTS3r0TdPSvXAGw37CzBtgHV K+aF/P0B3C10/KFboHYEyiXylEa25BEASJyYDjPUabUY0EQwRo+UdRU4xsZoeGIh3NkV 6b4cyc4L2wQ9tL6dmSkmT1V37z5J50Kbvobjed6T2IG7Q734e7MdH9XTaBM9o73hKCS5 kNjiAgRzxysn6b0YgXFLpzwA1/tzHzH9r3FoLA8+/pTdgXo6sixROZvVodDIAtIHR+1B tcUffGwsxsRUxBgeOpBduTkCVSYowepuHH6WmPYOYdTroHtK8SB8aVScBvi0BwF8d7e7 y1lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JpqHeVrC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j15-20020a636e0f000000b00524ea62bcbcsi3825139pgc.209.2023.05.10.04.53.22; Wed, 10 May 2023 04:53:35 -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=@gmail.com header.s=20221208 header.b=JpqHeVrC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237031AbjEJLvx (ORCPT + 99 others); Wed, 10 May 2023 07:51:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236908AbjEJLvs (ORCPT ); Wed, 10 May 2023 07:51:48 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67448E4C; Wed, 10 May 2023 04:51:46 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3062c1e7df8so4717928f8f.1; Wed, 10 May 2023 04:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719504; x=1686311504; 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=R1tUd+v3AgC5rEmN1z0CLTt+c2Ip3+6zTXGdLmF/kHw=; b=JpqHeVrC++Xx5E+Ovc/2JHadctgwmHSwEYUFZPa4BxcBU3AZLwyKDvpAyi+tZufJDZ puSqH/FhXNNIhip6S9r2NenanPUblCK1slrRNpcvwTZJiya8LpOFJOWKPqdBrRBlfxsz JMA4RyR66eXbH+aGx6JrFkBXxLQ9zcXaaa8XdvJluCgXzlrwx+xBO2PmGI2mk/PDAa4C CLMbryoPD9tirahrGtDHqYAnmf1K5BjpaUK37oikVIaDCuRcPrwFXDOUONZm4ezkSOIl njR82dnr0P2HLNhJba5l4g5/Rs7hs+8+ih1gpBLrEkC2gNYrA+P1Cywobg/tzEOOGm9J NGXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719504; x=1686311504; 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=R1tUd+v3AgC5rEmN1z0CLTt+c2Ip3+6zTXGdLmF/kHw=; b=fejrCrvGLCH6ZviUBpYLXsJAnPS7hw4FNqv2HbDvR9UBiLDXrJnkJVnj0jUTxoFsKh Bu9cUWfIz5KypBW8U01EBnd54mz/sp38T7wZdKoBzSwfiaFhf/mxi75GLE4g7azPkDPE s6MpOACtsiz8NhAbAxzWiSqpDE+VX/SN8Y5OcCiqCigYjL9BYqBQCV0RWk3zaqhbE+I0 lRnWX5/GCkasm8jKGfXEo9KkSQetWCwMdrUVhJFrX7MdwLM/5j9+aEEk0d4EyEhkkhyl M+NXFkR1T2vGtMnfutUGHRuV86W+okCW77IwJD9ja+guiGAPYxQXLlokmRTBiOLF9WBf rRbg== X-Gm-Message-State: AC+VfDw7sAJw1alOl4bBzhkLwL1Be2GMuRQ1pop6meNxJII5XG/2E/Rd 99IyBZrXKrS5fQZsZ50iusXQjs/Fl6w= X-Received: by 2002:a5d:428f:0:b0:2f7:e3aa:677a with SMTP id k15-20020a5d428f000000b002f7e3aa677amr12137132wrq.46.1683719504349; Wed, 10 May 2023 04:51:44 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id p8-20020a056000018800b002f28de9f73bsm17395302wrx.55.2023.05.10.04.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:43 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/7] power: supply: axp20x_usb_power: Simplify USB current limit handling Date: Wed, 10 May 2023 12:50:40 +0100 Message-Id: <20230510115046.963432-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507979956534694?= X-GMAIL-MSGID: =?utf-8?q?1765507979956534694?= Handle the USB current limit with a lookup table and regmap field, which minimizes code duplication. Invalid or unlimited values are denoted by -1 entries, and can't be selected from userspace. Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 172 ++++++++---------------- 1 file changed, 57 insertions(+), 115 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index a1e6d1d44808..67998fba702a 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -37,16 +37,6 @@ #define AXP20X_VBUS_VHOLD_uV(b) (4000000 + (((b) >> 3) & 7) * 100000) #define AXP20X_VBUS_VHOLD_MASK GENMASK(5, 3) #define AXP20X_VBUS_VHOLD_OFFSET 3 -#define AXP20X_VBUS_CLIMIT_MASK 3 -#define AXP20X_VBUS_CLIMIT_900mA 0 -#define AXP20X_VBUS_CLIMIT_500mA 1 -#define AXP20X_VBUS_CLIMIT_100mA 2 -#define AXP20X_VBUS_CLIMIT_NONE 3 - -#define AXP813_VBUS_CLIMIT_900mA 0 -#define AXP813_VBUS_CLIMIT_1500mA 1 -#define AXP813_VBUS_CLIMIT_2000mA 2 -#define AXP813_VBUS_CLIMIT_2500mA 3 #define AXP20X_ADC_EN1_VBUS_CURR BIT(2) #define AXP20X_ADC_EN1_VBUS_VOLT BIT(3) @@ -61,10 +51,21 @@ */ #define DEBOUNCE_TIME msecs_to_jiffies(50) +struct axp_data { + const struct power_supply_desc *power_desc; + const char * const *irq_names; + unsigned int num_irq_names; + enum axp20x_variants axp20x_id; + const int *curr_lim_table; + struct reg_field curr_lim_fld; +}; + struct axp20x_usb_power { struct regmap *regmap; + struct regmap_field *curr_lim_fld; struct power_supply *supply; enum axp20x_variants axp20x_id; + const struct axp_data *axp_data; struct iio_channel *vbus_v; struct iio_channel *vbus_i; struct delayed_work vbus_detect; @@ -121,60 +122,6 @@ static void axp20x_usb_power_poll_vbus(struct work_struct *work) mod_delayed_work(system_power_efficient_wq, &power->vbus_detect, DEBOUNCE_TIME); } -static int axp20x_get_current_max(struct axp20x_usb_power *power, int *val) -{ - unsigned int v; - int ret = regmap_read(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, &v); - - if (ret) - return ret; - - switch (v & AXP20X_VBUS_CLIMIT_MASK) { - case AXP20X_VBUS_CLIMIT_100mA: - if (power->axp20x_id == AXP221_ID) - *val = -1; /* No 100mA limit */ - else - *val = 100000; - break; - case AXP20X_VBUS_CLIMIT_500mA: - *val = 500000; - break; - case AXP20X_VBUS_CLIMIT_900mA: - *val = 900000; - break; - case AXP20X_VBUS_CLIMIT_NONE: - *val = -1; - break; - } - - return 0; -} - -static int axp813_get_current_max(struct axp20x_usb_power *power, int *val) -{ - unsigned int v; - int ret = regmap_read(power->regmap, AXP20X_VBUS_IPSOUT_MGMT, &v); - - if (ret) - return ret; - - switch (v & AXP20X_VBUS_CLIMIT_MASK) { - case AXP813_VBUS_CLIMIT_900mA: - *val = 900000; - break; - case AXP813_VBUS_CLIMIT_1500mA: - *val = 1500000; - break; - case AXP813_VBUS_CLIMIT_2000mA: - *val = 2000000; - break; - case AXP813_VBUS_CLIMIT_2500mA: - *val = 2500000; - break; - } - return 0; -} - static int axp20x_usb_power_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) { @@ -213,9 +160,12 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, val->intval = ret * 1700; /* 1 step = 1.7 mV */ return 0; case POWER_SUPPLY_PROP_CURRENT_MAX: - if (power->axp20x_id == AXP813_ID) - return axp813_get_current_max(power, &val->intval); - return axp20x_get_current_max(power, &val->intval); + ret = regmap_field_read(power->curr_lim_fld, &v); + if (ret) + return ret; + + val->intval = power->axp_data->curr_lim_table[v]; + return 0; case POWER_SUPPLY_PROP_CURRENT_NOW: if (IS_ENABLED(CONFIG_AXP20X_ADC)) { ret = iio_read_channel_processed(power->vbus_i, @@ -316,50 +266,17 @@ static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power, return -EINVAL; } -static int axp813_usb_power_set_current_max(struct axp20x_usb_power *power, - int intval) +static int axp20x_usb_power_set_current_max(struct axp20x_usb_power *power, int intval) { - int val; + const unsigned int max = GENMASK(power->axp_data->curr_lim_fld.msb, + power->axp_data->curr_lim_fld.lsb); - switch (intval) { - case 900000: - return regmap_update_bits(power->regmap, - AXP20X_VBUS_IPSOUT_MGMT, - AXP20X_VBUS_CLIMIT_MASK, - AXP813_VBUS_CLIMIT_900mA); - case 1500000: - case 2000000: - case 2500000: - val = (intval - 1000000) / 500000; - return regmap_update_bits(power->regmap, - AXP20X_VBUS_IPSOUT_MGMT, - AXP20X_VBUS_CLIMIT_MASK, val); - default: + if (intval == -1) return -EINVAL; - } - return -EINVAL; -} - -static int axp20x_usb_power_set_current_max(struct axp20x_usb_power *power, - int intval) -{ - int val; - - switch (intval) { - case 100000: - if (power->axp20x_id == AXP221_ID) - return -EINVAL; - fallthrough; - case 500000: - case 900000: - val = (900000 - intval) / 400000; - return regmap_update_bits(power->regmap, - AXP20X_VBUS_IPSOUT_MGMT, - AXP20X_VBUS_CLIMIT_MASK, val); - default: - return -EINVAL; - } + for (unsigned int i = 0; i <= max; ++i) + if (power->axp_data->curr_lim_table[i] == intval) + return regmap_field_write(power->curr_lim_fld, i); return -EINVAL; } @@ -380,9 +297,6 @@ static int axp20x_usb_power_set_property(struct power_supply *psy, return axp20x_usb_power_set_voltage_min(power, val->intval); case POWER_SUPPLY_PROP_CURRENT_MAX: - if (power->axp20x_id == AXP813_ID) - return axp813_usb_power_set_current_max(power, - val->intval); return axp20x_usb_power_set_current_max(power, val->intval); default: @@ -461,11 +375,25 @@ static const char * const axp22x_irq_names[] = { "VBUS_REMOVAL", }; -struct axp_data { - const struct power_supply_desc *power_desc; - const char * const *irq_names; - unsigned int num_irq_names; - enum axp20x_variants axp20x_id; +static int axp20x_usb_curr_lim_table[] = { + 900000, + 500000, + 100000, + -1, +}; + +static int axp221_usb_curr_lim_table[] = { + 900000, + 500000, + -1, + -1, +}; + +static int axp813_usb_curr_lim_table[] = { + 900000, + 1500000, + 2000000, + 2500000, }; static const struct axp_data axp202_data = { @@ -473,6 +401,8 @@ static const struct axp_data axp202_data = { .irq_names = axp20x_irq_names, .num_irq_names = ARRAY_SIZE(axp20x_irq_names), .axp20x_id = AXP202_ID, + .curr_lim_table = axp20x_usb_curr_lim_table, + .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), }; static const struct axp_data axp221_data = { @@ -480,6 +410,8 @@ static const struct axp_data axp221_data = { .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), .axp20x_id = AXP221_ID, + .curr_lim_table = axp221_usb_curr_lim_table, + .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), }; static const struct axp_data axp223_data = { @@ -487,6 +419,8 @@ static const struct axp_data axp223_data = { .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), .axp20x_id = AXP223_ID, + .curr_lim_table = axp20x_usb_curr_lim_table, + .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), }; static const struct axp_data axp813_data = { @@ -494,6 +428,8 @@ static const struct axp_data axp813_data = { .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), .axp20x_id = AXP813_ID, + .curr_lim_table = axp813_usb_curr_lim_table, + .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), }; #ifdef CONFIG_PM_SLEEP @@ -592,9 +528,15 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) platform_set_drvdata(pdev, power); power->axp20x_id = axp_data->axp20x_id; + power->axp_data = axp_data; power->regmap = axp20x->regmap; power->num_irqs = axp_data->num_irq_names; + power->curr_lim_fld = devm_regmap_field_alloc(&pdev->dev, power->regmap, + axp_data->curr_lim_fld); + if (IS_ERR(power->curr_lim_fld)) + return PTR_ERR(power->curr_lim_fld); + ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect, axp20x_usb_power_poll_vbus); if (ret) From patchwork Wed May 10 11:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92057 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3558889vqo; Wed, 10 May 2023 04:53:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5dYDZEuQiS6alahxPvx3nNoGZ3E2gmBf5HlqiS4k75TfyIzSWt/qHSe+qfKM2iCYeaFa7e X-Received: by 2002:a05:6a00:2396:b0:646:6c71:ee13 with SMTP id f22-20020a056a00239600b006466c71ee13mr11004799pfc.24.1683719602142; Wed, 10 May 2023 04:53:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719602; cv=none; d=google.com; s=arc-20160816; b=fYX72FAa+n4wcPeB0Fae1OzhWJd2Cxn5g1FPEzRI14mfq7LD+EyAJLcwW0IHx0WIJL aMj9HeiXKAyFluftSLWK5qjFEvovBXPX4N92p3mSHmPKOqTWWN2Mw0i4pIxsMrxBOuKN WDM/QSTA1t5rUBfVW4sOC8alyH9uoo6f4GcrYJcYsNylVycyXhExVxaaXZZSye+rlGZ0 a/2bgVUGVXyK02IlggRf57PhIlXueIpVBTikUxt30aeQi9i3vrOVrg3k1H+xYjCVbp24 fqouR79qtqaGXWKIKm4rmzdBMuEvJ6gnL2B3I87InsRaEKjpjd1jej0lq5uqQIxOegNH XuZQ== 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=pN2mbhhRwU/XXivi0isPSjAJELATakPrcNi/RQdW9Lg=; b=sOMGyIL5Kektt3x0nN/Pt/xqNRYCCX7xYRQBafh6oEHXetxvI7wUrun8dL6CZJhYnt d2VTBDl7lVbR+pPmbgQM6/uZv+wQHceVoruaRzLXTz7vd1AFgMuzteBpoT746Ls6YXdo OwBFE5GTWWfhcwKUA3quCba5XKhiaPp+ViL+0cP/5Gx1UktFHOfaonJ8ChegRVqhnTdc m8izBs0NPuntjgKpgGbFWETuyXnwQHu1NrUnp8UFYo6CjKMzQlcJjBFEH+f+PuN9lKgn /W4+FrHm63+A7djcpnCezpykCUOAOqE5uTBzqO2n0w2ElSNP4YW2N8BxTI4QF3UBtBed KHpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UavLsZCm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n26-20020aa7985a000000b0063b88c406c4si5040298pfq.171.2023.05.10.04.53.10; Wed, 10 May 2023 04:53:22 -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=@gmail.com header.s=20221208 header.b=UavLsZCm; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235985AbjEJLv5 (ORCPT + 99 others); Wed, 10 May 2023 07:51:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236935AbjEJLvs (ORCPT ); Wed, 10 May 2023 07:51:48 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 059D11725; Wed, 10 May 2023 04:51:47 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3f42d937d2eso9930785e9.2; Wed, 10 May 2023 04:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719505; x=1686311505; 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=pN2mbhhRwU/XXivi0isPSjAJELATakPrcNi/RQdW9Lg=; b=UavLsZCmhV/UqjGQKMpLAepZc1rNomzLV6CrY6y8QkMjTWPgIrRON+cNcQtfAZ31z2 Ol4UyEKsZUmRxh/1R+4qU92z2Mo79oZGgLJoYKza+PWqq8AUFajSRY66Bmf6lZS8R/2l aUjvUaiZjeAWp7SiDACTwPTg/MLSR/TyzMPjC55KK6eKFHQM/Mza+tjsvbZ/JovWn/UH smXfzHB0BYWvX3qUAeob7LTxPuc3AaBfuNBgPJ16BuwyTDH3nxoWGTNxOO9DwZOX+vCO 31gXXFAUh5X73LOsLcFe9oqsL1m+BPWgai2GkDJhO+fHuUsUSJ8oS/oCL8aD9lcVwUhR g+Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719505; x=1686311505; 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=pN2mbhhRwU/XXivi0isPSjAJELATakPrcNi/RQdW9Lg=; b=PYwuV8a2lc/waXl/U2TbFOZ0V6kBaZ/RDuLlYgFypxneZgbYiZxQBvVtaVoWnbL+5I anfEEuDsOosaMOsFyVQOMbyKPutvBy6LEsKRd7OkwiEdNCq1XIJuf1LInmZQRAONgq0f DagJtRvyz48k6VCuaIrfE5o3IJCAl06ZMQxFB4387kIrzaFHYQO13Z61Gm1TAZhz1N/9 o9ex7J8iW5Pd/Pd1xLftJMX8fpxziMosaZB1tmIlFMvWRx1ruJi1w9H0UcaJDeb7AtfN e3X+ObRRJNgNovTU4HNMItY/HgmcRAWA9AKNUBe5NH3qHAdvJPzWlef3befnut0aPYYP A8Sw== X-Gm-Message-State: AC+VfDznXGhDIPxyQDUmF1QzZFaYFYwBhDJc2C0KMM1/V/INMDQ96Yjn jbuMZJncFLr9m9ZvZEEcV9w= X-Received: by 2002:adf:ee49:0:b0:306:2701:5346 with SMTP id w9-20020adfee49000000b0030627015346mr13146778wro.39.1683719505398; Wed, 10 May 2023 04:51:45 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id r15-20020a5d694f000000b00306415ac69asm17124236wrw.15.2023.05.10.04.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:45 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/7] power: supply: axp20x_usb_power: Use regmap fields for VBUS monitor feature Date: Wed, 10 May 2023 12:50:41 +0100 Message-Id: <20230510115046.963432-3-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507965399093467?= X-GMAIL-MSGID: =?utf-8?q?1765507965399093467?= Use regmap fields to describe the VBUS valid bit and VBUS monitor enable bit. This allows the driver to easily support other chips, eg. the AXP192, that have the VBUS valid bit in a different register. Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 57 +++++++++++++++++++------ 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index 67998fba702a..b2049b7d95fe 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -41,8 +41,6 @@ #define AXP20X_ADC_EN1_VBUS_CURR BIT(2) #define AXP20X_ADC_EN1_VBUS_VOLT BIT(3) -#define AXP20X_VBUS_MON_VBUS_VALID BIT(3) - #define AXP813_BC_EN BIT(0) /* @@ -58,11 +56,15 @@ struct axp_data { enum axp20x_variants axp20x_id; const int *curr_lim_table; struct reg_field curr_lim_fld; + struct reg_field vbus_valid_bit; + struct reg_field vbus_mon_bit; }; struct axp20x_usb_power { struct regmap *regmap; struct regmap_field *curr_lim_fld; + struct regmap_field *vbus_valid_bit; + struct regmap_field *vbus_mon_bit; struct power_supply *supply; enum axp20x_variants axp20x_id; const struct axp_data *axp_data; @@ -206,16 +208,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_HEALTH_GOOD; - if (power->axp20x_id == AXP202_ID) { - ret = regmap_read(power->regmap, - AXP20X_USB_OTG_STATUS, &v); + if (power->vbus_valid_bit) { + ret = regmap_field_read(power->vbus_valid_bit, &v); if (ret) return ret; - if (!(v & AXP20X_USB_STATUS_VBUS_VALID)) - val->intval = - POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; + if (v == 0) + val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE; } + break; case POWER_SUPPLY_PROP_PRESENT: val->intval = !!(input & AXP20X_PWR_STATUS_VBUS_PRESENT); @@ -403,6 +404,8 @@ static const struct axp_data axp202_data = { .axp20x_id = AXP202_ID, .curr_lim_table = axp20x_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), + .vbus_valid_bit = REG_FIELD(AXP20X_USB_OTG_STATUS, 2, 2), + .vbus_mon_bit = REG_FIELD(AXP20X_VBUS_MON, 3, 3), }; static const struct axp_data axp221_data = { @@ -501,6 +504,26 @@ static int configure_adc_registers(struct axp20x_usb_power *power) AXP20X_ADC_EN1_VBUS_VOLT); } +static int axp20x_regmap_field_alloc_optional(struct device *dev, + struct regmap *regmap, + struct reg_field fdesc, + struct regmap_field **fieldp) +{ + struct regmap_field *field; + + if (fdesc.reg == 0) { + *fieldp = NULL; + return 0; + } + + field = devm_regmap_field_alloc(dev, regmap, fdesc); + if (IS_ERR(field)) + return PTR_ERR(field); + + *fieldp = field; + return 0; +} + static int axp20x_usb_power_probe(struct platform_device *pdev) { struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); @@ -537,16 +560,26 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) if (IS_ERR(power->curr_lim_fld)) return PTR_ERR(power->curr_lim_fld); + ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap, + axp_data->vbus_valid_bit, + &power->vbus_valid_bit); + if (ret) + return ret; + + ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap, + axp_data->vbus_mon_bit, + &power->vbus_mon_bit); + if (ret) + return ret; + ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect, axp20x_usb_power_poll_vbus); if (ret) return ret; - if (power->axp20x_id == AXP202_ID) { + if (power->vbus_mon_bit) { /* Enable vbus valid checking */ - ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON, - AXP20X_VBUS_MON_VBUS_VALID, - AXP20X_VBUS_MON_VBUS_VALID); + ret = regmap_field_write(power->vbus_mon_bit, 1); if (ret) return ret; From patchwork Wed May 10 11:50:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92058 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3558932vqo; Wed, 10 May 2023 04:53:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77/266biwsKgS1PFf0nyCFYcekrxHNBweD9p7cPwSXe9FFNJLJtuaH0ezk++Pmd4WZB4m8 X-Received: by 2002:a17:902:da90:b0:19a:a520:b203 with SMTP id j16-20020a170902da9000b0019aa520b203mr21609952plx.25.1683719606992; Wed, 10 May 2023 04:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719606; cv=none; d=google.com; s=arc-20160816; b=d0OFOL7EpfK5YicGLjUTki/qM9gXBg0CFmFgMTgUQ8AAeqkkTBY0q1y0IcWBsGioWg wkXKe+96zYQ16E3sDVKxZQWLf7NCLumcMydcn017J2Mv+bIrTYLjaumHUOTX0H9q2rDw uJuNsWj4NtjjSUxwBGOFCJGm/OQQ46Pw7UX3iNVgNQN6d60qnbwJZQKkqNMUsX6z/k6e 3cTOpEw6h45+FA2/0soGdNOcYDbghLaUMwQjN2W//FkI09aEcFMMLHx7QplMuLZmfp5K GwTVHaLv+O7S6iDuoA9KJsI1rxewXRFCJNM/Ww3NEXdv+pbB0FjH1cAsfJPVJjZXwksL aOrQ== 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=iWpn+xWGvtGBH62qOXih/XCmqiF9B5PS3ayiTGHqtfM=; b=bRQ+S7FpXg6xaBa4iNG795CxcKe4hXz0A7pivmnPBzNU70D9iwbaTuHw4/avFOqxM8 RdOi9q/pRMrey3t2unkPLiwtDm+4TDFIbjghof4ONRT4re+6PAdCFQqTi2ZJYRoVKGtU 8vw83rppyd++0IKn767xs+pgDgsUW22zepYZj451KK1CmlDIKWrzRGgnVdFCLhUR/Cwn ynKMObgXsxXLvSIS8MG78fo4NwPYedRmYO+xF43YbwI/F7bpE2m+Y0J8eWhukuJIEinZ dpxvRxYpbuPpNtAXxAMCXgxUrWNTyO1Ra1BLCtA2osxK0wqTMyzq/6I9jhSgkhLo5vHl e/UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=gekOZaVL; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je14-20020a170903264e00b001aae1997455si3716057plb.651.2023.05.10.04.53.13; Wed, 10 May 2023 04:53:26 -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=@gmail.com header.s=20221208 header.b=gekOZaVL; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237043AbjEJLwA (ORCPT + 99 others); Wed, 10 May 2023 07:52:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237016AbjEJLvu (ORCPT ); Wed, 10 May 2023 07:51:50 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CEEE30F7; Wed, 10 May 2023 04:51:48 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f49bf0223cso5541625e9.1; Wed, 10 May 2023 04:51:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719507; x=1686311507; 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=iWpn+xWGvtGBH62qOXih/XCmqiF9B5PS3ayiTGHqtfM=; b=gekOZaVLpelaVYbt9IyjFaRxlz5FQFgaGlMVTj/7zDxb2YrKvCLzmkhTEpMchNxv99 ytxazcVcCjcj42EfrsXjY6CYzfU2IuZuk9EW//rjl3+eon/safD/n78VHsaJ/2b+XqIm 0s+VLWBkjSAzOCFpibmRECeCNR7PRUBH0TdR3Q9GH1p/20oEId/FH5KaBG1wRa5Iol9b dGEtECf9Sa1LJJA5d3svN9bpOwjQC9oZsLP2+vu9ZimL5VdwP4DcSk85j1NvX++BGK1B ru9NJQhEGnXYT4UwbOY8bIiPT9AmNCU/B1lEDFmTrK/mHD539LuSkpSo7tzKyfqg7i0Y kpTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719507; x=1686311507; 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=iWpn+xWGvtGBH62qOXih/XCmqiF9B5PS3ayiTGHqtfM=; b=IvZItMTHRDTOBI93/zJta5brpKBXFfoqELANBbS9bYUhVXbrQfoq/DdkUwd8WJ8wFf w/MG7zXbdhv+rmPWQ+FIRQif9Qu1VNOcwU48jRS6Men41IR8nRpu77T1HPN5zEDUNaMY cNPxXqbD2EMSGlbLfvDVewwDv6tzNqULJZyg5dvBTwqIioLcGqHsHJ5drArPJKIBm5uy Zk1J44gePLpN5H/08SY1hkQB2muoOy8NmuMFg5Acv4Io0Y6Lz6j8zRQfEScxJ/ZASMcn s1YXtNRtTCc1qdKeqmmGUU68F0Dvw96ecPgFlzTemFT/g6y5lUcZVv8PS1YNr0T4NOaw Rd0Q== X-Gm-Message-State: AC+VfDz+1cxI+yl2Ii0XTeamSQr6pq50/KKJ6E2Hg0hkbAB2goiW9YCE H6iLPJgZVwfQQy9Un92vAPY= X-Received: by 2002:a05:600c:c5:b0:3f4:2610:5cd0 with SMTP id u5-20020a05600c00c500b003f426105cd0mr6362397wmm.7.1683719506527; Wed, 10 May 2023 04:51:46 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id 12-20020a05600c020c00b003f4b6bcbd8bsm1285113wmi.31.2023.05.10.04.51.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:46 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/7] power: supply: axp20x_usb_power: Use regmap fields for USB BC feature Date: Wed, 10 May 2023 12:50:42 +0100 Message-Id: <20230510115046.963432-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507970862511787?= X-GMAIL-MSGID: =?utf-8?q?1765507970862511787?= Replace the use of variant IDs with a regmap field, to reduce dependence on variant IDs. Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index b2049b7d95fe..20a76c19cfad 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -41,8 +41,6 @@ #define AXP20X_ADC_EN1_VBUS_CURR BIT(2) #define AXP20X_ADC_EN1_VBUS_VOLT BIT(3) -#define AXP813_BC_EN BIT(0) - /* * Note do not raise the debounce time, we must report Vusb high within * 100ms otherwise we get Vbus errors in musb. @@ -58,6 +56,7 @@ struct axp_data { struct reg_field curr_lim_fld; struct reg_field vbus_valid_bit; struct reg_field vbus_mon_bit; + struct reg_field usb_bc_en_bit; }; struct axp20x_usb_power { @@ -65,6 +64,7 @@ struct axp20x_usb_power { struct regmap_field *curr_lim_fld; struct regmap_field *vbus_valid_bit; struct regmap_field *vbus_mon_bit; + struct regmap_field *usb_bc_en_bit; struct power_supply *supply; enum axp20x_variants axp20x_id; const struct axp_data *axp_data; @@ -433,6 +433,7 @@ static const struct axp_data axp813_data = { .axp20x_id = AXP813_ID, .curr_lim_table = axp813_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), + .usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0), }; #ifdef CONFIG_PM_SLEEP @@ -572,6 +573,12 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) if (ret) return ret; + ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap, + axp_data->usb_bc_en_bit, + &power->usb_bc_en_bit); + if (ret) + return ret; + ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect, axp20x_usb_power_poll_vbus); if (ret) @@ -592,10 +599,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) return ret; } - if (power->axp20x_id == AXP813_ID) { + if (power->usb_bc_en_bit) { /* Enable USB Battery Charging specification detection */ - ret = regmap_update_bits(axp20x->regmap, AXP288_BC_GLOBAL, - AXP813_BC_EN, AXP813_BC_EN); + ret = regmap_field_write(power->usb_bc_en_bit, 1); if (ret) return ret; } From patchwork Wed May 10 11:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92059 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3558979vqo; Wed, 10 May 2023 04:53:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4fc0s9jOYb0KrO+U/M8FaBu1J+C2vUjN6ddYz2Q7SX+sCv3Y+sd6tPOkLhks8vp8ZMPQL0 X-Received: by 2002:a05:6a20:9143:b0:f0:2ba6:8406 with SMTP id x3-20020a056a20914300b000f02ba68406mr23889431pzc.26.1683719612168; Wed, 10 May 2023 04:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719612; cv=none; d=google.com; s=arc-20160816; b=cis2u23VEg7BsTrSMkNBoaHnOXMfThWoV4TCmsMTSOMAG+ASNRoHrVFOHQl+3f/2fa eW4BVdq7WrHZCVlyM/kzVjxU15rDLM4bnAxz5Hr/8xOijkeTIsP4vx4AsPvhx6Hh6QXy hAiY82g1kJr38joFHiuKhmQnFzXjgO9iSTWwUEyU5FCnwzRJ7Vb2a1zSrunzS/f9hdhs eGLUZ3u1jipkSykNT799UxcNP3CV3wGroC49CyaTktstaq0x8P1cn+XKI4S6OZD9mkxH 7/IZIxvuNCkWKb2rQuCvrRzi0my2iSpkiRwyMEXiR4r8Xj90aRVmrOAocivNIKVHznHT +A3g== 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=r+e0WO9314+22bYk2/c0IG6PriU+XsPi5/aWiGwjMuE=; b=ph8xNE3EhDHi25NfJ3AjZoYpAXeDsVs6rCkPBV4zJqyeFu6EygiLIAN0MLVz3OBB1q 2L0MW/7QETqQXxWrna0d0mWHViuuWTKOWxjurmc4BOuH7h3Vh+zMs5GBupxGmtJM9nrA WGqYwOilO0CULTHhdLDxciaaI1hEF73pMmgr3+9VH6hKxtn8jUbAaG/YYrVAQRY7pqqy E8DACOxLwR6n73yaNHLZiJ2JpovD/joOQgyvaXNoULkwGVqpKl4vp8qpiMQtr+KaB+I8 7tl/HLcdhNjA4QnEb7KVDxPcHcsCBI6/OOQPOi7LFANqvPI/2jcdfxzCXsU4K+lmYnyw DplQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="Q/E/T1aH"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e21-20020a637455000000b0052856cec949si3726310pgn.875.2023.05.10.04.53.19; Wed, 10 May 2023 04:53:32 -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=@gmail.com header.s=20221208 header.b="Q/E/T1aH"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236853AbjEJLwE (ORCPT + 99 others); Wed, 10 May 2023 07:52:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237021AbjEJLvu (ORCPT ); Wed, 10 May 2023 07:51:50 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F5A435A3; Wed, 10 May 2023 04:51:49 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-2f27a9c7970so6730361f8f.2; Wed, 10 May 2023 04:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719507; x=1686311507; 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=r+e0WO9314+22bYk2/c0IG6PriU+XsPi5/aWiGwjMuE=; b=Q/E/T1aHHQGd8tG4pCXUPk93NhLvFH0M+pemyAz0J37e8tRIPpFC1XoJprjPtlpkXx VxZudODg3w+OZnbq2u2Of/01KfEKLKU4S74UnmRlcUs1iwoyp9bZHa2xXoaewgkF3K8C UFFitLWAWJK3BHODRC8x4qlXLNsHW/l9T3PiWqHBkS2yHAPXzjlLgOincgaq9x9YyHni jQzdkT9iTlaqlJ16zFl5/VQqJRRybTyE5kmsJracyG7MCl2P2Yw8lZvD+wSU2jzl+M2U PtSZ6xX+JCzRsl5+gZQqO+iG1ekHSS1GsM/iaJKHx28obrCPfUdo1rcyz6X+Y4yRK4Yk GR0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719507; x=1686311507; 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=r+e0WO9314+22bYk2/c0IG6PriU+XsPi5/aWiGwjMuE=; b=BpU1LAVJ8Npw00rMXXB6T41jM0mg+wlbe93CkHa79lPXi/H/3GfL9lX7hAi49FlhEb n1wDtUIilS0R1bf+dcLtAxZ0uTLCf3TDsE9NllRpqEQS3Cus/y8I0623X7uI5Xl51wtz NrtQ0P7YZ6YUrKyDyXKG2siY6NztNbFPK2DdpVYLwREk27jjyL3W3u5Jk5t1CH/+WCwU dgie97n2rlYHYg0HUPI4u2YCHVQTqnefO0ECnri6Dkp2BtsYJbijwJB1GSSXbsIHuJZv Qm5dNL/ztqZ1KTH3b727MiDdlVyqT7OQxMXxfqHgu4HsHtI3QL2SNScozNKlVRqUPeSp bQNQ== X-Gm-Message-State: AC+VfDx+y30mbFbUp0bcB+WiATkXNb42ZCmEAjzD1G1G5ejwCghbDOEa PYx4uHpyIxCsqTCixOJ9yCEtD++30r4= X-Received: by 2002:a5d:6d4d:0:b0:306:2927:b581 with SMTP id k13-20020a5d6d4d000000b003062927b581mr11419223wri.46.1683719507494; Wed, 10 May 2023 04:51:47 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id z8-20020adfec88000000b003062675d4c9sm17094885wrn.39.2023.05.10.04.51.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:47 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/7] power: supply: axp20x_usb_power: Use regmap field for VBUS disabling Date: Wed, 10 May 2023 12:50:43 +0100 Message-Id: <20230510115046.963432-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507975868292057?= X-GMAIL-MSGID: =?utf-8?q?1765507975868292057?= The POWER_SUPPLY_PROP_ONLINE property allows controlling the VBUS enable state on supported PMICs. Switch to regmap fields to reduce dependence on variant IDs. Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 29 +++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index 20a76c19cfad..89f076615d2e 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -31,9 +31,6 @@ #define AXP20X_USB_STATUS_VBUS_VALID BIT(2) -#define AXP20X_VBUS_PATH_SEL BIT(7) -#define AXP20X_VBUS_PATH_SEL_OFFSET 7 - #define AXP20X_VBUS_VHOLD_uV(b) (4000000 + (((b) >> 3) & 7) * 100000) #define AXP20X_VBUS_VHOLD_MASK GENMASK(5, 3) #define AXP20X_VBUS_VHOLD_OFFSET 3 @@ -57,6 +54,7 @@ struct axp_data { struct reg_field vbus_valid_bit; struct reg_field vbus_mon_bit; struct reg_field usb_bc_en_bit; + struct reg_field vbus_disable_bit; }; struct axp20x_usb_power { @@ -65,6 +63,7 @@ struct axp20x_usb_power { struct regmap_field *vbus_valid_bit; struct regmap_field *vbus_mon_bit; struct regmap_field *usb_bc_en_bit; + struct regmap_field *vbus_disable_bit; struct power_supply *supply; enum axp20x_variants axp20x_id; const struct axp_data *axp_data; @@ -231,16 +230,6 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, return 0; } -static int axp813_usb_power_set_online(struct axp20x_usb_power *power, - int intval) -{ - int val = !intval << AXP20X_VBUS_PATH_SEL_OFFSET; - - return regmap_update_bits(power->regmap, - AXP20X_VBUS_IPSOUT_MGMT, - AXP20X_VBUS_PATH_SEL, val); -} - static int axp20x_usb_power_set_voltage_min(struct axp20x_usb_power *power, int intval) { @@ -290,9 +279,10 @@ static int axp20x_usb_power_set_property(struct power_supply *psy, switch (psp) { case POWER_SUPPLY_PROP_ONLINE: - if (power->axp20x_id != AXP813_ID) + if (!power->vbus_disable_bit) return -EINVAL; - return axp813_usb_power_set_online(power, val->intval); + + return regmap_field_write(power->vbus_disable_bit, !val->intval); case POWER_SUPPLY_PROP_VOLTAGE_MIN: return axp20x_usb_power_set_voltage_min(power, val->intval); @@ -320,7 +310,7 @@ static int axp20x_usb_power_prop_writeable(struct power_supply *psy, * the VBUS input offline. */ if (psp == POWER_SUPPLY_PROP_ONLINE) - return power->axp20x_id == AXP813_ID; + return power->vbus_disable_bit != NULL; return psp == POWER_SUPPLY_PROP_VOLTAGE_MIN || psp == POWER_SUPPLY_PROP_CURRENT_MAX; @@ -434,6 +424,7 @@ static const struct axp_data axp813_data = { .curr_lim_table = axp813_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), .usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0), + .vbus_disable_bit = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 7, 7), }; #ifdef CONFIG_PM_SLEEP @@ -579,6 +570,12 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) if (ret) return ret; + ret = axp20x_regmap_field_alloc_optional(&pdev->dev, power->regmap, + axp_data->vbus_disable_bit, + &power->vbus_disable_bit); + if (ret) + return ret; + ret = devm_delayed_work_autocancel(&pdev->dev, &power->vbus_detect, axp20x_usb_power_poll_vbus); if (ret) From patchwork Wed May 10 11:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92062 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3559024vqo; Wed, 10 May 2023 04:53:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55WcNtWwfk3BOq41rCwUnVOUMP3RRTf7mxNLRnRWSyDdKmoV+SfmVSOEdgt/V4bpILeFEk X-Received: by 2002:a05:6a20:7491:b0:f5:ae09:ce02 with SMTP id p17-20020a056a20749100b000f5ae09ce02mr23970439pzd.18.1683719617964; Wed, 10 May 2023 04:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719617; cv=none; d=google.com; s=arc-20160816; b=h2KP1D/6aEnq+/7eHsqiXiNkHfNW4HNNPu3cBIz8OlFb8WgKBK2yUNCDLN6q41LUUW Kdh7P55Zys7iTKDz7hYDsdvnHfbgHIRqqZYjus+TgmX0X5WQdZq4NOLjzY2eDuHjFXhw KSaaw81hASYWDWiLZCRlQLD8SOFRO73zX6mMVXSExT56/3mpP24E5quRIreBop5sjt4Q atvAtBq/PhMLwNHDSp+sedmWEyzDltMKRx18xqUcrHkSkGUwYUJYtNnFWpfdObpGlyxi KZU6V2e6V2tEtSnEqwwaCsSmIrelmh5NoE95Gw4/0L1A9Hj8cnAR/WbGkUwZOf+U9DcL YJ2g== 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=sdCsH2d8zg6wheMJGk9jqr1Puc+kcdg3d/O4BTVakwc=; b=ucvd87zUpyl12nP57/Y3LmDY+c8C1VaAkftdG9dOp3PwLgFVbjyDm/+KyXiUe2KXaZ Y0b+6qh0ogP+hhfY5nnwFUq+wAnaA3rkqVuIQVuDojYbQbGnYwJH1NFmMCR6EIMRFvLA lD9013G1rafNvI7o06AeNLrd6WBHaaK80c9jM9HxegkX81CjSqp02sfW2j5//kl1lDz/ xf2EZ+mpYQde/1vmmqYTNMLty/UKKGtsF0NO/WUYOJsW84LB95KlQdFLqOw3QX9jP26d p4kFxtf5tqa3f8Rte5HMHuuXH2Fl5NiRctc5wlEsVIGk+N/NwB8WPvRw1yGANbPpFvfh PQbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=JMVjlHpk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v19-20020a63b953000000b004fbc2116e0esi3839903pgo.205.2023.05.10.04.53.25; Wed, 10 May 2023 04:53:37 -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=@gmail.com header.s=20221208 header.b=JMVjlHpk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236824AbjEJLwK (ORCPT + 99 others); Wed, 10 May 2023 07:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237026AbjEJLvw (ORCPT ); Wed, 10 May 2023 07:51:52 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D4995FC2; Wed, 10 May 2023 04:51:50 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f42bcf5df1so18708735e9.3; Wed, 10 May 2023 04:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719509; x=1686311509; 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=sdCsH2d8zg6wheMJGk9jqr1Puc+kcdg3d/O4BTVakwc=; b=JMVjlHpkletbHyZMVIVo5SEiHVHe9HN5MHzA6s1NqWsBobJl97afhQnQWXnGWBbumW K1h8dMYJQqGP6mr5vJIlU/MfVEjkth194lBHpUWzmLV3qmMipBh8Lfrz4yLfoQnvl5SD VIc/cBxOlHOVtd4TrM/rhLDlaSKhyN8SExIy4OI3Nr1GBLskVJZjER9Fbw41GCtTqDj6 UXWRoGRESgBJ2HqgwJuETWdJg7mJtD2/oL/aU0BjIrU2Jc2agJsHy2VpPdn6E7ozEuCC /XVK8wF6Bik/Up5iI2fd8PYRPeRUhHzsv7MEGsGl2wcNtrr2Bs4CgE2Hz6FdQ6NUhbP1 Y5iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719509; x=1686311509; 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=sdCsH2d8zg6wheMJGk9jqr1Puc+kcdg3d/O4BTVakwc=; b=V85DZPZW/T0Eoe7zUCSWecaQc6CwCArqKZed4MIYvMlvoY6u+JLM1hE1/MVdZfxgrw Hwwbh2U6WZRPgcSk6c9y5HX8nw0K2PgZXtYE0Vo6fNVW1MyZRA5aD9bjURF5zNEiEWwm dBxamJ/6Q8HvsDCjHve2GiF1hKY49eiSRUv4yO9ljQE1HXtprFXWudKYZPdA2xvHmGCY +hEdPZnJpA+HERHQ3Ra140TZsr13ZWHoBvTMBgQSEmRMBe3z89k818XGh+6o6HAwrELW ghho1dnKYEefa0LuplndnNRIxi18kTeU86rw2iR9WCqySjfq4zLJ/5toaz3yyZaU/Z/9 5Yeg== X-Gm-Message-State: AC+VfDyOKJzDMjXnawGhRHV3d7KIohydNeE0TFCaB4xuZ0d5B+SRje3A +JzuOrmbFnBBpBhEmJw1Yc8= X-Received: by 2002:a7b:c449:0:b0:3f4:2d04:f3f0 with SMTP id l9-20020a7bc449000000b003f42d04f3f0mr3102760wmi.39.1683719508505; Wed, 10 May 2023 04:51:48 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id 2-20020a05600c22c200b003f42328b5d9sm10525514wmg.39.2023.05.10.04.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:48 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 5/7] power: supply: axp20x_usb_power: Remove variant IDs from VBUS polling check Date: Wed, 10 May 2023 12:50:44 +0100 Message-Id: <20230510115046.963432-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507981868993650?= X-GMAIL-MSGID: =?utf-8?q?1765507981868993650?= Use an explicit boolean flag instead of a check based on the variant ID. Since this is the last use of variant IDs in the driver, also remove the IDs. Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index 89f076615d2e..089fe837a4b2 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -48,13 +48,13 @@ struct axp_data { const struct power_supply_desc *power_desc; const char * const *irq_names; unsigned int num_irq_names; - enum axp20x_variants axp20x_id; const int *curr_lim_table; struct reg_field curr_lim_fld; struct reg_field vbus_valid_bit; struct reg_field vbus_mon_bit; struct reg_field usb_bc_en_bit; struct reg_field vbus_disable_bit; + bool vbus_needs_polling: 1; }; struct axp20x_usb_power { @@ -65,7 +65,6 @@ struct axp20x_usb_power { struct regmap_field *usb_bc_en_bit; struct regmap_field *vbus_disable_bit; struct power_supply *supply; - enum axp20x_variants axp20x_id; const struct axp_data *axp_data; struct iio_channel *vbus_v; struct iio_channel *vbus_i; @@ -83,7 +82,7 @@ static bool axp20x_usb_vbus_needs_polling(struct axp20x_usb_power *power) * present->absent transition implies an online->offline transition * and will trigger the VBUS_REMOVAL IRQ. */ - if (power->axp20x_id >= AXP221_ID && !power->online) + if (power->axp_data->vbus_needs_polling && !power->online) return true; return false; @@ -391,7 +390,6 @@ static const struct axp_data axp202_data = { .power_desc = &axp20x_usb_power_desc, .irq_names = axp20x_irq_names, .num_irq_names = ARRAY_SIZE(axp20x_irq_names), - .axp20x_id = AXP202_ID, .curr_lim_table = axp20x_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), .vbus_valid_bit = REG_FIELD(AXP20X_USB_OTG_STATUS, 2, 2), @@ -402,29 +400,29 @@ static const struct axp_data axp221_data = { .power_desc = &axp22x_usb_power_desc, .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), - .axp20x_id = AXP221_ID, .curr_lim_table = axp221_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), + .vbus_needs_polling = true, }; static const struct axp_data axp223_data = { .power_desc = &axp22x_usb_power_desc, .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), - .axp20x_id = AXP223_ID, .curr_lim_table = axp20x_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), + .vbus_needs_polling = true, }; static const struct axp_data axp813_data = { .power_desc = &axp22x_usb_power_desc, .irq_names = axp22x_irq_names, .num_irq_names = ARRAY_SIZE(axp22x_irq_names), - .axp20x_id = AXP813_ID, .curr_lim_table = axp813_usb_curr_lim_table, .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), .usb_bc_en_bit = REG_FIELD(AXP288_BC_GLOBAL, 0, 0), .vbus_disable_bit = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 7, 7), + .vbus_needs_polling = true, }; #ifdef CONFIG_PM_SLEEP @@ -542,7 +540,6 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) platform_set_drvdata(pdev, power); - power->axp20x_id = axp_data->axp20x_id; power->axp_data = axp_data; power->regmap = axp20x->regmap; power->num_irqs = axp_data->num_irq_names; From patchwork Wed May 10 11:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92060 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3558994vqo; Wed, 10 May 2023 04:53:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6U7VM4WKHMLykj4a/2oX0H3rlYl6T5sSk0TjEuos29i15c+N/5THt3Q6VqMOZIRpFyhos8 X-Received: by 2002:a05:6a20:914d:b0:ef:e240:b559 with SMTP id x13-20020a056a20914d00b000efe240b559mr23716812pzc.46.1683719614096; Wed, 10 May 2023 04:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719614; cv=none; d=google.com; s=arc-20160816; b=pAZuf2XkFpoemejyZAhhEGFUwIgPTU/y6x5LOVMGdPzOrAoYWdzD4MnJgE8FrA4ykE B318ONXoye8ctD6E6iCwIHJPupmzvWfRD9M1M03xLOio7bNWpTOY3Q0ay7KdFsC5zXwP OoyzDP5O/qaHLKb9VpsQq2GA1My4/3ctorAgQBvwFAVGFtp5OPEZiZs5G6wKcPWlPsip ODXEvnbLT7sdDhJ2KVEoJxmq1bNnbIs4i1TuNhYKaFWSbsGmAhpLduiDnsIgX2apu5LU ZbTwWFNCNUi1RdQBDV1HFllo4qPF2vdbaI/gsMzsmUnF4FGNirMnh24iwc1+X+h5jqNF GzAg== 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=CR46O1ewornF4KltourK6EuEJV9QcToba83RDfovgnI=; b=f+67PeCahtMVjrUyMWQuB6LtZeoHOvDjST99ydRVC26TQ1dmG6YOBGo3GsUKr9P0cm X21246QwsMD+5b2Isn/c176xD4bghkxE+/bDkMaZ9H78l5BSmOtCRPoQaGYswtqKBdjm 039y79IR7p/fqpzoWmMcjRaeNvitIv+SNS9Poo8JV9qP5Phr0CogVZx330d6i0dde8CE +n2GY0k4qocKivBv9Zp5EOVOIWM1iX7MKDpGTTylLJzwKuN9SP6CLQyKgy+IqfPZKrpu IVGpy+SgBFU7g3SNyjCYs8eSKGL2EuaYnANdzpxG3elZr7iTHtMLKL8HJcuUyziiIxzI mnJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=EIrVFwBo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j5-20020a637a45000000b005133c334fe0si3887628pgn.192.2023.05.10.04.53.20; Wed, 10 May 2023 04:53:34 -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=@gmail.com header.s=20221208 header.b=EIrVFwBo; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237054AbjEJLwH (ORCPT + 99 others); Wed, 10 May 2023 07:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237022AbjEJLvv (ORCPT ); Wed, 10 May 2023 07:51:51 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A7761B7; Wed, 10 May 2023 04:51:49 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3f49bf0223cso5542085e9.1; Wed, 10 May 2023 04:51:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719509; x=1686311509; 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=CR46O1ewornF4KltourK6EuEJV9QcToba83RDfovgnI=; b=EIrVFwBoQ73odE5gh3AtMWRfGoVQ4blS7eoVlR5sfuLr21zl1CsOESFbQG4nLANrdA ayMOi4qPvy2PZhZP7+JPPZjCsluyL6JiO5biJBWNbss0Vaiene/1yc5HLu3qAF3N1i3k dwEEHOzSJ1vc0LGQ08hz+hH4URCIpypAxu6wLHizBrH/oJlOvNOn1lgtWlsa2Q0hzI31 SoAzyKYfCn6gDTGPqifUj/ipOHVzK5KJtm10BRj/v0wL4XIImxaHGo5cVaC8j9keLAj7 6eh88/pzks4NJfmd2eetp11BIdNZ75HpKjKUj7CvcY1FltB+WAXybAPXwmxThnCqGbVo DjWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719509; x=1686311509; 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=CR46O1ewornF4KltourK6EuEJV9QcToba83RDfovgnI=; b=jJiKI1fQI5MdK3Xqr8WHIMQxOyhuJLITmESLUAP+PWx2dz+CbEmwvvoEaeGvYpUGlh tZ4jSswnQtlVzv+RAk61i7rYfGOVm3hZotks6+JrFGwBSGHpsXLNYzi2MM5nzZhvWzOj d0RkzVhWPbJv6Hg/9+RiOU5Eu+zf4sTOkgdGDeJrzn8k4KwUR6NB+OK6qrrQnOJCwipl zhzz2GpWMMRwYdFEUB61uLPthn68+phqeffKhW6I1MY/bueivjOKeuI0/PoFbd+GMwPC YBuILPSiGWF0jzwx63vAkYyuH2PcmVHe9nsPqpWBPgaDKsCFFt990Ui+z7I6nVKHTHdv Y2TQ== X-Gm-Message-State: AC+VfDzd9n4LqF9PV4kOffuB+xwxKpWZSw/LzaL1Nc/4OWC/aZUUPoPh 9n1IZ04s8RqQyvLb6yxDLG8= X-Received: by 2002:a1c:f70b:0:b0:3ed:e5db:52e1 with SMTP id v11-20020a1cf70b000000b003ede5db52e1mr11794556wmh.15.1683719509423; Wed, 10 May 2023 04:51:49 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id q3-20020a1cf303000000b003f3157988f8sm22540802wmq.26.2023.05.10.04.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:49 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 6/7] power: supply: axp20x_usb_power: Add support for AXP192 Date: Wed, 10 May 2023 12:50:45 +0100 Message-Id: <20230510115046.963432-7-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765507977929837374?= X-GMAIL-MSGID: =?utf-8?q?1765507977929837374?= Add support for the AXP192. It is most similar to the AXP202 but the current limits are different and the USB OTG status register has a different address (0x04 instead of 0x02). Signed-off-by: Aidan MacDonald --- drivers/power/supply/axp20x_usb_power.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index 089fe837a4b2..51c3f9b6458d 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -26,6 +26,8 @@ #define DRVNAME "axp20x-usb-power-supply" +#define AXP192_USB_OTG_STATUS 0x04 + #define AXP20X_PWR_STATUS_VBUS_PRESENT BIT(5) #define AXP20X_PWR_STATUS_VBUS_USED BIT(4) @@ -365,6 +367,13 @@ static const char * const axp22x_irq_names[] = { "VBUS_REMOVAL", }; +static int axp192_usb_curr_lim_table[] = { + -1, + -1, + 500000, + 100000, +}; + static int axp20x_usb_curr_lim_table[] = { 900000, 500000, @@ -386,6 +395,16 @@ static int axp813_usb_curr_lim_table[] = { 2500000, }; +static const struct axp_data axp192_data = { + .power_desc = &axp20x_usb_power_desc, + .irq_names = axp20x_irq_names, + .num_irq_names = ARRAY_SIZE(axp20x_irq_names), + .curr_lim_table = axp192_usb_curr_lim_table, + .curr_lim_fld = REG_FIELD(AXP20X_VBUS_IPSOUT_MGMT, 0, 1), + .vbus_valid_bit = REG_FIELD(AXP192_USB_OTG_STATUS, 2, 2), + .vbus_mon_bit = REG_FIELD(AXP20X_VBUS_MON, 3, 3), +}; + static const struct axp_data axp202_data = { .power_desc = &axp20x_usb_power_desc, .irq_names = axp20x_irq_names, @@ -634,6 +653,9 @@ static int axp20x_usb_power_probe(struct platform_device *pdev) static const struct of_device_id axp20x_usb_power_match[] = { { + .compatible = "x-powers,axp192-usb-power-supply", + .data = &axp192_data, + }, { .compatible = "x-powers,axp202-usb-power-supply", .data = &axp202_data, }, { From patchwork Wed May 10 11:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aidan MacDonald X-Patchwork-Id: 92063 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3559878vqo; Wed, 10 May 2023 04:55:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cVC9p1O0/e3C2JuzdrBsZjhMh47SNc+rXdvggOne2LxvP0qQTk6SGuYJBXXrloSb+aTtr X-Received: by 2002:a05:6a21:338e:b0:101:6f60:11fd with SMTP id yy14-20020a056a21338e00b001016f6011fdmr6297293pzb.3.1683719721794; Wed, 10 May 2023 04:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683719721; cv=none; d=google.com; s=arc-20160816; b=KS6hJsCCMrGY6mCR/mvH/JnqzO3qFcqONmxV+0NiDF11BbQny0fLT00Ey75C23uTY6 XLcrpJg1lJ1qyOStuXeRzHz9sPqBTxFlj/C9YPjYFdoHcmBEv3OZyptWdF+FlmbqhntH bWsUiqlkaqusOJOX+IyHv13o0MFDxIra1AfmKBE6KOmiDIzhvbYdzGhN4tG/8I07KgJM chHUJaxFdP7lfijJK5s4r2woDLdQyy9v1xZUS26f+Xx9RixCYo508G+62FPMmzrvN/+4 9oXAc9CF23qcTZQHt5IuqXEjZLGCC2tPTyYGhQrO84J8mKS9g/qflAH0IS8i2lfJ4n2Y i60A== 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=ytZ68tiM2bcXYJ2+O2GzY517mWAuTLJSh4tOV0KVU9I=; b=tglz6m6p4vpR/Ofy0VA4XTyvWXoohMXf7e+JiWOfU35D1MnRkivaeEJK7sbB8cSoRA iFdZq2KdcLtbXDtHaThA8LEgoJL6JXr7DA4csyNlOhhBCfRvzbndyDLmpVWLn3SKInDV AZePJUR0W3zGTQS+nktQAJmA+LlguYhcoFKcTvS2GO3NUxU9JCIRWzVZcbu/G7toi+V4 MebEsF2YYEM3ZUklSeG1WRiLvHHWKVZvnkKXfrmSZJBaM3DwJzkFjvaDhY6JUH9aREQo sLjf7Maeq+IqDcO3XVDQ5AEPr2P9CeVyLrDliJ1HjX4e60ipei8sy7ZC5JUVA4GC0+OF KL5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=ijsTzZaA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v4-20020a637a04000000b005303a7ca04bsi3833385pgc.486.2023.05.10.04.55.09; Wed, 10 May 2023 04:55:21 -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=@gmail.com header.s=20221208 header.b=ijsTzZaA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236785AbjEJLwN (ORCPT + 99 others); Wed, 10 May 2023 07:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237034AbjEJLvx (ORCPT ); Wed, 10 May 2023 07:51:53 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4049A7ABA; Wed, 10 May 2023 04:51:52 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f4449fa085so7299595e9.0; Wed, 10 May 2023 04:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683719510; x=1686311510; 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=ytZ68tiM2bcXYJ2+O2GzY517mWAuTLJSh4tOV0KVU9I=; b=ijsTzZaAqckKfvhgTUMbkkTQpxnD4u2W9Cz8veW+Gr9jmU/jrxUmlq8raZiBy4nFCM 3aow/CgynVKCibGthN6xjpUjdusD/Ig9UjBh8L7kLKNR/86bIJIMCQNyR2me6qx82d9y q2mEulNjQHMGjXPNfdHVptEckRrwQu4wSjxqQMccuHAibAGRuGdqsOHScATE+6k6xLyt big9awMJzVzofMOVj6DRl9qGVgFCtDqFgsC50bUm1UJycr+jxDggXtVZCPPnVHIsTIzq p0YlGWtufsS++XMr4QUyZaiFIo8OOBGFPJWW5W/J4GEOSWF70v8gso8XpMBzSOypTZRQ 5C1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683719510; x=1686311510; 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=ytZ68tiM2bcXYJ2+O2GzY517mWAuTLJSh4tOV0KVU9I=; b=isFIeX972H1cCuBH0VbvU7tGyauC4Kwv7IRZR043EX8EV8LmBGUeWp9upQAqbrnEmJ 3yCEZz6CcqvsY8GfJmDSRVDrktN4bWUojZfImhtLKayOeU4fRSbSU6gDp9HBCJNECIMc 0SY3SkneSeIRZKYaW5I9a6dQl8942qe1kRhvcUH7w7GjkG1lHgAePl8FRcEtPK7tUqrL UPGdwgl7MGDOK/+0PjRdFVnGjOBm5v3YNAxCe06uXkYWd/KbvQmaECbxxq/enKAu26Zl ZWWK2JfC5AnpGx8ts2eeVZ+CV/74fFK+K9GNAwaG48iBPqHnQGZAVGowuFUQa5ZTg4Go xMcw== X-Gm-Message-State: AC+VfDydgbJIsTvH2lhJSPudKidchOWthK5JLIqZq7tYvIM+nwYfpq1Y k9jYXU2rmk6/ADzLad05lVc= X-Received: by 2002:a1c:7406:0:b0:3f4:2e01:83fa with SMTP id p6-20020a1c7406000000b003f42e0183famr2868935wmc.26.1683719510520; Wed, 10 May 2023 04:51:50 -0700 (PDT) Received: from localhost ([167.98.27.226]) by smtp.gmail.com with ESMTPSA id v13-20020a05600c214d00b003f42461ac75sm9560047wml.12.2023.05.10.04.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 04:51:50 -0700 (PDT) From: Aidan MacDonald To: sre@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 7/7] dt-bindings: power: supply: axp20x: Add AXP192 compatible Date: Wed, 10 May 2023 12:50:46 +0100 Message-Id: <20230510115046.963432-8-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> References: <20230510115046.963432-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765508090991260716?= X-GMAIL-MSGID: =?utf-8?q?1765508090991260716?= The AXP192 is most similar to the AXP202, but the current limits are different and the USB OTG status register has a different address (0x04 instead of 0x02). Signed-off-by: Aidan MacDonald Acked-by: Krzysztof Kozlowski --- .../bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml index 3ce648dd91bd..34b7959d6772 100644 --- a/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml +++ b/Documentation/devicetree/bindings/power/supply/x-powers,axp20x-usb-power-supply.yaml @@ -22,6 +22,7 @@ properties: compatible: oneOf: - enum: + - x-powers,axp192-usb-power-supply - x-powers,axp202-usb-power-supply - x-powers,axp221-usb-power-supply - x-powers,axp223-usb-power-supply