From patchwork Sat Feb 18 20:49: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: 58964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp543898wrn; Sat, 18 Feb 2023 12:50:25 -0800 (PST) X-Google-Smtp-Source: AK7set+yWJdy4G3/RIQEaLv7wJE22dZjJL87rkRJsA2DQXp2ZZzTx5IGgDr210FQgytTK5Rgn4vH X-Received: by 2002:a17:90b:e0d:b0:234:b964:570b with SMTP id ge13-20020a17090b0e0d00b00234b964570bmr2308704pjb.22.1676753425249; Sat, 18 Feb 2023 12:50:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676753425; cv=none; d=google.com; s=arc-20160816; b=v3sEElIELwVSnEoVbPlqTaYOEouyj5j5BSIsyREeOqoqX6U8DQWcK3DZigprDINIbs aekGfk66IwRZHd5EjKcK4IIIempulcGxMwAP9A5jSR8lCl8uN6g841U06u7Iw2DDMgZz mbI23XKbhBJD9uokKTuMVFTFVS7t5Zq+1vDpkRg1grhHuGRQnZGpwg2RSa8605QV6ih+ LU+wrK6T2XvAhUpI5KXQhqSLUJbPC8tG5eNFL23Vhi7848b4AdGPJtuuyzOw6QQ2Ctfh LOLL7Q5ujVcRhFRtCFJsk02WJZocfZKY0Ucstc/NrREVaaCNZOZBWs9RXHyB9tuQexeo GePQ== 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=NG/0rtz1GL/zeG1hLy9V3uBQ4HgVtO+uaFmz4BS4MxgcNWPf5p5dCpAabDN+mrURBz ZZiUFSA+NSiRQcnCmsrwCQH/lSqZmHt/tAHIAJqAapQf1qhAkbu2OarkaiP9VJDNJF64 GfQr1JY4J+BmhcxKTr0CA40ECzmEeaeQbX36IcH7VSi816IhpRmxguD0wc9y/ZEWTnWC wAGwI9UNCTiaU2lewqvQRJWCKy2RKd3YM1ezII5lz+6/bqEFK90qLnOX9/vmJ1OuZNXU Cy1aM+T9xdvZdQ/F4xuXwcWp6NtlYyMhsSBLsvUsA9AcPgm8C0acdukD+VAFbvBkymrk Js5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dwFJETju; 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 jb20-20020a17090b409400b00233aee947fesi4706022pjb.184.2023.02.18.12.50.09; Sat, 18 Feb 2023 12:50:25 -0800 (PST) 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=20210112 header.b=dwFJETju; 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 S229712AbjBRUt6 (ORCPT + 99 others); Sat, 18 Feb 2023 15:49:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjBRUt4 (ORCPT ); Sat, 18 Feb 2023 15:49:56 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A21914203; Sat, 18 Feb 2023 12:49:54 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id m22-20020a7bcb96000000b003e21e018039so354329wmi.3; Sat, 18 Feb 2023 12:49:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=dwFJETju9IHoSilXKf3xnJT/UUz3P9fv5rW0+7nBP2vUVJQuRUftowkg9NmmD+SI1r 5pB71mFrHJXvMJ1mu+hBpOCfD9fm3Cx3dGnCITkme4JNune8R5SjcTMpkDVd5D3o8OHC pgNDJW83J++B4EAtP01s7VgieslJsE3vDh1/nJWixcdbv9sDFK6+DG9IURsShtC7XDbZ lT3QX4+gZTAWoirEmjMVqAE/DX/7RuZrtKKT2rmSGO1LF0hU5P80nZDAVvGhxdsgFmD/ hy+XNCxJ0H5mvFswoOeKTds+8vtdfN/PXT2NSPJdKI+gIp5XMbfxYKnOg60LsUcLdIec Yg4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Yqm7eWCcYeBoiOwEQgROe4H2K1G2FAWXq9f7c6PnRrOCLYVRNkg1N6urVC3PbefUie kqXoFt1Sljc8KEFGBSfEspnkiDK9hUGFYComgrHj4APCnEwmcCvVzSFKCjm6TO6ASDt4 6xPbblq8cPAXk49MISUzaGdY+m9g3X8hFdR2GhUdFN3xGD9Q3cyx8qrmcgq2LKRieppe iQDVUX/hvyvCEp5+9dMyA3cJEDhm6PwgiRO/chhRmppIe2r7++Ir+1swBCYtm8S5X34+ P1asw2kjqC/Sfr4wZ13/InteH0xaPQtZCdaQ5ChzwFzcu80rDmeOdmaVmsikRi9s9km7 jqHw== X-Gm-Message-State: AO0yUKWsps3GANxuE3ngRafzbURj8HaEDF2rYCcFG9jPdeLN76lCYEUW nt00xNdNgyuC2nXyVeZQgRA= X-Received: by 2002:a05:600c:2b46:b0:3e0:1ab:cf2a with SMTP id e6-20020a05600c2b4600b003e001abcf2amr3529420wmf.39.1676753392757; Sat, 18 Feb 2023 12:49:52 -0800 (PST) Received: from localhost (94.197.47.81.threembb.co.uk. [94.197.47.81]) by smtp.gmail.com with ESMTPSA id ip24-20020a05600ca69800b003e223fe0a3asm5676563wmb.27.2023.02.18.12.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:49:52 -0800 (PST) From: Aidan MacDonald To: sre@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] power: supply: axp20x_usb_power: Simplify USB current limit handling Date: Sat, 18 Feb 2023 20:49:42 +0000 Message-Id: <20230218204946.106316-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> References: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 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 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?1758203399282565348?= X-GMAIL-MSGID: =?utf-8?q?1758203399282565348?= 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 Sat Feb 18 20:49: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: 58973 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553844wrn; Sat, 18 Feb 2023 13:16:57 -0800 (PST) X-Google-Smtp-Source: AK7set+mJnlXXfC+RKPVoqnNEqbsvjcDX2GF+S1xCHQhHLZbXUiDz95PW+B1TWUn+U5z/gXVCU8L X-Received: by 2002:a17:90b:3b82:b0:234:8e7:4e5b with SMTP id pc2-20020a17090b3b8200b0023408e74e5bmr2277932pjb.3.1676755017121; Sat, 18 Feb 2023 13:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676755017; cv=none; d=google.com; s=arc-20160816; b=C1Z14LhF1pSOrG0bYZ1R5kze5boQn6VetmXlpqKtm7ko24wf0BY3OHbXLVh6OvUiyn WDG5vrzwaD4UWieoJl6bBxDiFIt/l+SnLSuuRvtQCoCnHSJ++sYv5w3Ub5YyFQ6WxM1O JJFPjHN5LeIuHVL+hOEYw6WON3LlWO6OK9Ihu0Hhl8wGNctQny/Wm/h83uWCLe48VGWp Bq5L6adCW49aKccVBijJYT1gZWLnM+ukv0jF4aMPe1xvTsiPDiMwV2LYNsI5NWUjNyBq JkktP7eHfwPW3MF6MD+jWgABBFZ9n5WyWPla68czv4FsDshUB81Nqz7dWogvsAzLhGl+ Dxiw== 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=s512cftoU1tSc2pnW4l3sldnxLoUjGISztN7omYSvz7XuMRSkybqFd6ccuw5fVldHw TKbbbboQmXm8haWA53trbYJAt9orUAVD/BUH/k9HQwNlcOuLYYJJsQgquglcGg4MsCL1 DMIUGYPrCAz49otAWQskQvE088MvvjRC6kCOkUcFyR94YgnraC1ym9FLVQMLPga4j77D Kllp9/p2D8AXNdpTV9Jfy49B4n/ftuRR4hVotoFO77KIwuVysZ2XV4UIy1PNmQJpwNVV yNMtYRCf5ngICjYXWiTxLjuZRau9b12G8Y8yiofddEkcsAK65Wxeh3YEPQAA+A6RG4Oz E7EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MmvtPHyQ; 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 a18-20020a17090abe1200b0022c0d4652e3si8332553pjs.86.2023.02.18.13.16.44; Sat, 18 Feb 2023 13:16:57 -0800 (PST) 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=20210112 header.b=MmvtPHyQ; 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 S229769AbjBRUuC (ORCPT + 99 others); Sat, 18 Feb 2023 15:50:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbjBRUt7 (ORCPT ); Sat, 18 Feb 2023 15:49:59 -0500 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 6854F14200; Sat, 18 Feb 2023 12:49:55 -0800 (PST) Received: by mail-wm1-x32b.google.com with SMTP id k3-20020a05600c1c8300b003e1f5f2a29cso1065282wms.4; Sat, 18 Feb 2023 12:49:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=MmvtPHyQ6AUYjlWORkjFWTlD0S09Nfwj6e8TcyHkeP0sUNuDu2PZGMWhwB/bybPQbq /41IR7w5+SmBZuI/3odnfLsJZixszvPyKzSzLNblsLp5TB6+x5PYqzeh+L1T6irGJPkR rKBEWrQGlDdg5R0zavsG4voCO7uJfbb5FMqzIZOS3MZ2eSNtbNdkeSXPjAh8Rbh/Q/XL pMEOqxfho/eG4+qB5yGMrbQHrCKFFr4TLrmJ6LcuZuVODhQydOQJIYED/IzrFRPI3Hse 6B4bu78NBDvCIcodcqFm69XFCTS/vzXhZw6nX19UaAfs4I99F6yVxYfXgJA2x6HllsLZ hb6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=sNxz4AgaKD0J7TwXrF6c56r4ZXsP4QtiZSJDeEHIMU0mLubsHrv6jUnlV9kME54fGZ YZRAAHClDnRtO49yDgaOIS+RQ7vgT1YkAXksH6TkP/Tqsb1Zfa7KE2Fai7OzeIYVP1PH H1p9dc2rqHsnBeRtSqP+X7jZkr84z08SeDoEa1EZ+LsBb5fWYGWGftfBQjAE2EBGmAr7 uMG0Q5LLLyXyv0EAJdd+eGGj7nz97qvsGXnGb6VFN64SUKJcJyEGsn4dOlG2nvXe+rs4 At0Yc57qPT4/JhABQ6TNS07QevwS9UhjAi37kxd8YUBacVIxJ3LPe5cPap0380ZvpKKm rmCQ== X-Gm-Message-State: AO0yUKWwWVwnpmZSiarf4r2kWUL2fIJ6y9L+Jeo4RSDW0C51zkxT9lG8 3y3qkcfadG/Kh/NbJY94/Cw= X-Received: by 2002:a05:600c:2b45:b0:3df:85d2:c768 with SMTP id e5-20020a05600c2b4500b003df85d2c768mr3952547wmf.26.1676753393905; Sat, 18 Feb 2023 12:49:53 -0800 (PST) Received: from localhost (94.197.47.81.threembb.co.uk. [94.197.47.81]) by smtp.gmail.com with ESMTPSA id 9-20020a05600c22c900b003e224ff61a8sm5617947wmg.43.2023.02.18.12.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:49:53 -0800 (PST) From: Aidan MacDonald To: sre@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] power: supply: axp20x_usb_power: Use regmap fields for VBUS monitor feature Date: Sat, 18 Feb 2023 20:49:43 +0000 Message-Id: <20230218204946.106316-3-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> References: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 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 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?1758205068434991893?= X-GMAIL-MSGID: =?utf-8?q?1758205068434991893?= 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 Sat Feb 18 20:49: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: 58966 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553635wrn; Sat, 18 Feb 2023 13:16:28 -0800 (PST) X-Google-Smtp-Source: AK7set/w5z+TlJux4lZ6vpR95vr2gbO2lf3wyhri9K/wwNxKop1JFsm9+u8yDrH7bLc/gylOoThg X-Received: by 2002:a17:902:c408:b0:19a:996c:5c2e with SMTP id k8-20020a170902c40800b0019a996c5c2emr207393plk.49.1676754987936; Sat, 18 Feb 2023 13:16:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676754987; cv=none; d=google.com; s=arc-20160816; b=JM9IqKNOfmMt2Ewr3u4RugWBAg0Pv6mzjK5Guu2yeK++6DNT7Lkl/6++YAWN8wuH2j je8hv76UV7aBSAqzTCkWpHVOQlJ0ckHU+/wTBjbn6/7BTZYlz3S9spLXhO7+rY9wHr27 ZrwZqM7+C2VBON2G1pvj0JQe7zSqPavGPQaaP01eaIS2cO+03VIX/qkSO2yzNUyG+/bl KCgGMP15ci1RqpstT4QUX+J0sG9OLjylXwRakNTqCbP+mh+RgnerF4vEmFlOquJ2uhAx 9CmGvUTt9PWUGHYm9rRKx9IMNCJOWl13EYoQEZA3fq1xV+0Z1JesodESxeuUPxFIseYr oF9A== 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=RGZehDf9LM0pBiTZM72GnYlIwcTB8Mth6KGocta6NJw8uxLhMJ0zD4u5NibYosaUNu V2PenarPFjAUTaCOQH4wBE/XYG4/e5WONuZXhqAPKTvvPkKDz0qrG6WwXeWKG/1wXb4x zWtQrG1JyItjpLUwEuaKXyRpYPL2Wo82kR9nRMHWNuIgIN2cEp6ra9M5TaZRBhs0atu7 LDV+kqTqOlvzuel3aIetzutH3TAUQScWf9QpBTlnU+dFmL7ETOirogu+ccYR5UR4+R7S O7IyGuSdvuzSt54VAGIM08Bz3cH82v28e6PObUADVs72UkDY2slWwZzjzToyWwKcCa+K 7jTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=UKuBerBa; 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 h13-20020a170902680d00b0019a716b3b1csi3744804plk.226.2023.02.18.13.16.15; Sat, 18 Feb 2023 13:16:27 -0800 (PST) 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=20210112 header.b=UKuBerBa; 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 S229746AbjBRUuA (ORCPT + 99 others); Sat, 18 Feb 2023 15:50:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbjBRUt5 (ORCPT ); Sat, 18 Feb 2023 15:49:57 -0500 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 8EB7C1420D; Sat, 18 Feb 2023 12:49:56 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id j27so1052671wms.3; Sat, 18 Feb 2023 12:49:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=UKuBerBaLV/EDCGvEVXWrIxbbQtQBHoiC5Kvd5FYL1vS2r2L5WSq3oC3SbFEXZI5GC z3DMGF+lSkKgIn3Ng2qpFHIL9Be/eCset6N+xFPhGHB6zMRwEvMqso1RxzsFwSIhjgy5 xd0bttjAQziQW16ecEvcRhgqaiWimYtL8GN8OKXOYgOUyO2kXJvUzNSr681fMZeGtH0f AXxfewAPLbmB5cQh8hitmQOfCTQT5s8l3EQiZO7GKJa8kCaUyexP8taA+cy0a77fG/fr BEjKpWVHPEKoXy5Dlow/PdnIfurtkAqrnKvEoj7HRqriPUKZ/bn9ytYCsE16Z9Qybu3y bNQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=TMrIqW/slk0DBtiOKikd2WclBA9DIvtsi9ttmQOg/vAHT5bWQTUrUtcUnx+HAcAaIf yHiVui4ydPdpDcIoZeGCg+EuSPhpg6uMgaLTINJRQK/fr979YOnFS56r2jcpF8pAsDFD yl+hXfXGJZV16+6uZC+V7NRdaPZ3oKGh+vhZKjLyruBkV45TS7Zzb8gawgl9BB9lu+V5 5jSk7AUCKD57q+thS19V9iw7WcoZx2FgqYRO2RRzvSPQSFUIDXiMFaROvVYJT+p1eGvo SbDlZPD1P9KOQNmQogfDZ8zlDCycyEqr5i4m/Mxv6Pjt4DwSW77zzWK+VjV/4Qj9VDdK g/3g== X-Gm-Message-State: AO0yUKW7v/+/nFOANt41H67wGP6po7KyUlkSkrGXYtECCkPQV2ZD3/Hv Y2GpDALamy1CmA48d5pUH/0= X-Received: by 2002:a05:600c:4b29:b0:3e2:147f:ac1a with SMTP id i41-20020a05600c4b2900b003e2147fac1amr6993905wmp.21.1676753395078; Sat, 18 Feb 2023 12:49:55 -0800 (PST) Received: from localhost (94.197.47.81.threembb.co.uk. [94.197.47.81]) by smtp.gmail.com with ESMTPSA id o2-20020a05600c4fc200b003e2059c7978sm10160847wmq.36.2023.02.18.12.49.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:49:54 -0800 (PST) From: Aidan MacDonald To: sre@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] power: supply: axp20x_usb_power: Use regmap fields for USB BC feature Date: Sat, 18 Feb 2023 20:49:44 +0000 Message-Id: <20230218204946.106316-4-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> References: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 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 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?1758205038064334073?= X-GMAIL-MSGID: =?utf-8?q?1758205038064334073?= 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 Sat Feb 18 20:49: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: 58967 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553650wrn; Sat, 18 Feb 2023 13:16:29 -0800 (PST) X-Google-Smtp-Source: AK7set81fgJFvVgyZzAHWjvO+uWySY163fXJGs0fQW527i2U043Mcj766KtkZ8RydPsGWThcpe0I X-Received: by 2002:a62:1a49:0:b0:5a8:ae60:eb4a with SMTP id a70-20020a621a49000000b005a8ae60eb4amr4645270pfa.28.1676754989470; Sat, 18 Feb 2023 13:16:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676754989; cv=none; d=google.com; s=arc-20160816; b=NGvS3M1xREbmHgO7vor4Af97l8GEmSznB1j09I6K7U/dhZ0fr3abdFSOoewi3SP7a5 DMveyQal6Y8jkjPOG40K9qSiqcZNyEq34mpCR4mSelOimqBxjZhmdHtqyrm8utKWSaEy x5uUhq2HEOmR854uLusJALRp3IKQvJR8PvsG8tY4BmMHp8JG60CygWBatXBSO3PE+RsY nVuAT8+IKe58g6ih6I1bF+93VheE3IzNAQp7UdpN9H7hRyorUYlcwaFV1cBBst6LUmNv xGSTWhyz6uDepEzkPDDYFdUeC8Ggl0vcS31aXY1Kfwj0w4E7QQCaddw3WcrsBFwzhqMT x0ag== 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=W/t4hmWCyWpBB1OHQTumQXmPVgxztVQtCPg6G9WxmcnWbLwuMknD9NA3RrorY+N7N7 SQnDicQPbEAzd/eHpH1ts/mTuL0nehkuu9UsUSSRkj0I2CF84ZKi8tjtFtHgMf1Gyw7e 2vOj/yu9vgTPLoWsuTW0heYsECn/VovXYqbIMuIJ4rRHS5txNo9QbX4chkt/Y8CCOXFq pecBBDpeOfzFRQjDHr695rCl8flQKdUgCqCVZP/iHq2z4leECC66btUiNsXj8oauDFSJ MiR33+0YHg1kTZ3X6xBBAbXHfQ2cm92+NdSXQlg+F8DNVNwOWdHBbOBDijWRn7ye77d/ Y9hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="f/q2/34T"; 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 p13-20020a63fe0d000000b004fbcde9147dsi8960919pgh.375.2023.02.18.13.16.17; Sat, 18 Feb 2023 13:16:29 -0800 (PST) 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=20210112 header.b="f/q2/34T"; 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 S229793AbjBRUuI (ORCPT + 99 others); Sat, 18 Feb 2023 15:50:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjBRUuB (ORCPT ); Sat, 18 Feb 2023 15:50:01 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B23A614203; Sat, 18 Feb 2023 12:49:57 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id 2so1119918wrz.9; Sat, 18 Feb 2023 12:49:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=f/q2/34THR9pa5fDB9GLXMRJsOU1d0u+06pzMTnvLm0bY8B20k0aeobEJs8G+JD5Dz YFRqqSV3tfv7kae+1eDRvZUCuUpjtqoslWqLR+srWXn3RGXvgpIv5qBwSXbxVxvI0AON 0P/j48nqCviABLqLz875C8znhcnqzywiwSi3tXTyK6SF+epyZCMJACIyWxLpjo/LaSlC kTJwHns4Gz9DMVRPmRFpoqnyiTtKPARFjmfba1ekkg4ME0KZ8zkjgaSn5dcoY8d3VVpR 9yKCzFHc2+g/SGQqm8KF+QlRf+PJPSr5OHItbslscFEwf9Kn+sqENBAqi2+nZDIFz15c BWyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=edxBbMFm7IV1yTDyrEUQvhSz0+GFkZNatnkcfor6LII5OVER28g3dR2PFOXNOPNQ1w 4fRu3mcR8LWMnqP6bKt19KiSlTxdctchAH5tdZ15EZBSI2YtTGAf2w/ty451VSP1hMTG m1QVIFSXsZRvA83suna4ffCuAipZC/VYraKGzTSXeulDnZLzBV00TVm/9yJtio8DSFmr NXasTwmY3iteXYT5+RtiC5xQ5nAEm2x96TU/PJrGllEShNNh62KS1qslppdb2F91dH+H QfBvVgqdOR5SGPMIlTGSQ4kA/wlMOqD+j97kF4X15fbRjYnfSvrebHV2QVvCn6USum57 LUEA== X-Gm-Message-State: AO0yUKWjeG6G66QM7ymXyB5fgy7ybIS8v1sLKN6uivmcRGeJkYosUkUU a3zwgdYxRuLyb7iux6RSwziGvPcJLQ0= X-Received: by 2002:a5d:4ecd:0:b0:2c5:4fde:7716 with SMTP id s13-20020a5d4ecd000000b002c54fde7716mr2512784wrv.24.1676753396153; Sat, 18 Feb 2023 12:49:56 -0800 (PST) Received: from localhost (94.197.47.81.threembb.co.uk. [94.197.47.81]) by smtp.gmail.com with ESMTPSA id b5-20020adfee85000000b002c559626a50sm772305wro.13.2023.02.18.12.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:49:55 -0800 (PST) From: Aidan MacDonald To: sre@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] power: supply: axp20x_usb_power: Use regmap field for VBUS disabling Date: Sat, 18 Feb 2023 20:49:45 +0000 Message-Id: <20230218204946.106316-5-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> References: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 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 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?1758205039640884328?= X-GMAIL-MSGID: =?utf-8?q?1758205039640884328?= 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 Sat Feb 18 20:49: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: 58965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp553510wrn; Sat, 18 Feb 2023 13:16:09 -0800 (PST) X-Google-Smtp-Source: AK7set/eLFurOJrEchRlCkdRcAxOWszgpwny0ZhSFjLdCMFWuOGEXybSDxlXnWX0hzpZ1E5F9mui X-Received: by 2002:a05:6a21:7888:b0:bc:f336:98ed with SMTP id bf8-20020a056a21788800b000bcf33698edmr6013929pzc.45.1676754968902; Sat, 18 Feb 2023 13:16:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676754968; cv=none; d=google.com; s=arc-20160816; b=Td0QE8htAR1wXrEOw8u9LbxWUggzvnVZqNrf31DNxLQzy4lB2OsTzKIgYKsf6EGomf 3ThDuwMwK9kwr+CiBbW5vP+KAuu8ELrTzwzRtVNb5qvDNpyU0irVsNZ74V1laZfeSSaW ReS8j0bofRoIQ6HdCXTnWJYls3DmGNxJ2oNqXclMU9ed9QAKjLchV+sSHtA9f02c/UMW QXoeH3vIqqEOq4gNx0JdI9fYA6GE45NtoYwoJ4sEOH3trZertNWzyVUCIbCMtHrA0T+X b9lC1oX80GX27WhLZdWICtzHXRRnVGRNBiJq/91foY8P1Q5f2Vo5uK6VUhMc1ph2M0sr 9LQQ== 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=tXYzkyo8Jw0GQeKZh4QN8w+Kac2BHD7f2WtTVEAGp/RZfy7wPkWF5fZftgnvXCHRUU WAl8hf/Am9U7tyiM+/33Bd4/h0QcwEmkDSdEG5xgqrzuwt7ShVH5lPdLLnVfLVMaqEcc 51Hw5AlKDacvBCrJtSTzeCAjhl+GQyXyDsF6dxi1cQ8GPI/ZLQ2QAhdpnet+KmAKmHRX rixQwZHckGgYW3XADulwu41VRbvZAFoJ8ZccydBeovyMkYSst7D0dXia34fCXgklml5y sW4QfOh5AvuQFb3dZjjbzPH5MKZSXaycIVcyJE6vONqONZRKjFst9EB95EgYOsJQVLm0 svoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Il5L5cPl; 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 g69-20020a636b48000000b004fb20bf0a73si9384774pgc.112.2023.02.18.13.15.52; Sat, 18 Feb 2023 13:16:08 -0800 (PST) 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=20210112 header.b=Il5L5cPl; 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 S229781AbjBRUuF (ORCPT + 99 others); Sat, 18 Feb 2023 15:50:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229740AbjBRUuA (ORCPT ); Sat, 18 Feb 2023 15:50:00 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA4B614EA9; Sat, 18 Feb 2023 12:49:58 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id k14-20020a05600c1c8e00b003e22107b7ccso814639wms.0; Sat, 18 Feb 2023 12:49:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=Il5L5cPlhAHrh4Ia3DeD4zTlMK3BeZCon21HTwzfeskwaSTUGEV1jKUzcIAPj0Mj23 MCE1Q+aweforLcOWJAobIWXh6UxedaTKYxldG5hlOzSv7T7VsgYPszTdAL2pkqMiV4Fm 0KnpmtOq3K+pbMI+5SNUdm2QgKpZuiylL0gFs8h5esoEvfra0Qjyv2p2hkhempxFnCs1 TF8wzTcFajRF9pMCZECGPBFt4mUOiIs32rdZyvdmJRnO1MxsoyjOToQeCam1oCg53MNG CpOyqH3XgDnWBG7C65TJ0TvaxWZY9pyJnoVt92ExvkwxfRWhGUskWyHNtmjVXyfjDfiU JfwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=rV1CeYr+mTD64ZLKJ3HRq4G5N4jckI0nDCsQ1RtTOU4Y/ixdo4kKZBDriT1772JKVP vxAjY8Zj1a9ShI/mLPwnczKwrjJOS2Ts356opOGeTreUBkEFbNlh/1pOJUJdNb0Rg3qu +J59z8cqWnNrrRz2Dx/LKbR1gTMgHMP+ukFmnhZ5heyEVHH4LhfTsKDHIUMu9mvUt1a7 Y9dqRoQbXWrbzxxcx0xC8BujyJbsOztyIOGn4IJu74AxFq4dEBmNRDSgne3URxV3KqDx V7XwXu40Eu/M5y64FpSRKtAfbh81mz7aoWK7aHlo9bf63voeEfSW21dC2aY5RqUzYzCZ YsdQ== X-Gm-Message-State: AO0yUKXTMsBnm3G1iKuPGlmr92x5/PXOlaBWS8QJRSWK+cIQ0gcBT/b4 qm8lCFiInUz1dGZEBYnZJHXMRBsx3s8= X-Received: by 2002:a05:600c:1695:b0:3e2:6dc:4d6e with SMTP id k21-20020a05600c169500b003e206dc4d6emr9508359wmn.31.1676753397393; Sat, 18 Feb 2023 12:49:57 -0800 (PST) Received: from localhost (94.197.47.81.threembb.co.uk. [94.197.47.81]) by smtp.gmail.com with ESMTPSA id s10-20020a7bc38a000000b003dc1a525f22sm8866551wmj.25.2023.02.18.12.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 12:49:57 -0800 (PST) From: Aidan MacDonald To: sre@kernel.org, wens@csie.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] power: supply: axp20x_usb_power: Remove variant IDs from VBUS polling check Date: Sat, 18 Feb 2023 20:49:46 +0000 Message-Id: <20230218204946.106316-6-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> References: <20230218204946.106316-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 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 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?1758205018113132805?= X-GMAIL-MSGID: =?utf-8?q?1758205018113132805?= 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;