From patchwork Wed Aug 4 11:01:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5ZCnIeeOi+Wptw==?= X-Patchwork-Id: 12418575 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AB55C4338F for ; Wed, 4 Aug 2021 11:03:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8080B60F43 for ; Wed, 4 Aug 2021 11:03:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235764AbhHDLD4 (ORCPT ); Wed, 4 Aug 2021 07:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237728AbhHDLDz (ORCPT ); Wed, 4 Aug 2021 07:03:55 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6499C0613D5; Wed, 4 Aug 2021 04:03:42 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id k2so2548308plk.13; Wed, 04 Aug 2021 04:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=sa/54MoTBKoG2PK7xRr6gc5uJIE4iaKki/KNCSsDWfk=; b=SNDCJuNxfWBvjNS/tc48F3zWKBKQlmZCEI2s1Yd2y/vIlPdS0hl2rfrh6s+PqVtO6N gG8j7wDwGPXl8wWYEwgzQ3gUzy/CQp60U8XB3La4Z62vG9TeH+P34Z0aSR2WugyZ1ymL ZcFcueb9eOtenc7srxmkbN6QReGUBw/ved35YC/4NEwigGwriT5LhPZDjMDpS2+Mo0hc zyAH9FVHVNyOFki9+Q3z52Ct1ZFnn36I75sfUAX2yiT0hc74D1BYqrbkYCr++Rwo95OU ueDY31j7VuUvqRC0gn0YICkAoUQg4O5zUj4AyQ8movKFol8I+i0jULSflxZ8RhWVyAZd xC1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=sa/54MoTBKoG2PK7xRr6gc5uJIE4iaKki/KNCSsDWfk=; b=jWuvDOjKSsEsCOHgFU5CKvv15mbT5sV+0jQeq+AGmkUjjpfyBxCBY/W/b79OvuGY/y ZBLga1pOUdnO4DkX6X4svkCb2y8ujtvqG7OB6zlLNbXMCtQ8qV8rdFUqpcZN0/qEUxIb G+0dFCEGakPC54Fa9duIDkCPurN9EWLR0EMziVuSXa0NRLogtu9rexiZG8j3MeMyw7uy jKWZfPOJXmQ9bfVIBhUSSpVnY4rQg+EbJDUsjsN8764+4z9W49/dFgcBiFceZ2w9cnCL eluLNIiQZiYOyxUWorMIofWn9Cl1ww++Wquc+flzy7yOUb5MMz7f4O6CdPV5YPnJd9Rd Xn3g== X-Gm-Message-State: AOAM530G05bvxoMsJsVSZDvBN123cNFtZzh7eH7EuyVwIfeghzZA6uHR ukRI56KQfIA5prj18ygRu4cHoi9fCfnjn6pE X-Google-Smtp-Source: ABdhPJxxdAYU4W3ViEW5MLSntrSnQRt5V/xWdD14VFDP8jgxSsSftmIVxQiJIAazGaTLywB++nK7Sg== X-Received: by 2002:a17:90a:cc8:: with SMTP id 8mr28131544pjt.194.1628075022521; Wed, 04 Aug 2021 04:03:42 -0700 (PDT) Received: from wangting-OptiPlex-7050.mioffice.cn ([2408:8607:1b00:7:529a:4cff:fe0e:1dd3]) by smtp.gmail.com with ESMTPSA id f6sm2306220pfv.69.2021.08.04.04.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 04:03:42 -0700 (PDT) From: Ting Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, wangting11 Subject: [PATCH v11 1/4] power: supply: core: add quick charge type property Date: Wed, 4 Aug 2021 19:01:58 +0800 Message-Id: <0d7753ae1e908f38a650eb6565de65f9f7c56e28.1627992564.git.wangting11@xiaomi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: wangting11 Reports the kind of quick charge type based on different adapter power. Signed-off-by: wangting11 --- Documentation/ABI/testing/sysfs-class-power | 21 ++++++ drivers/power/supply/power_supply_sysfs.c | 1 + drivers/power/supply/qcom_smbb.c | 81 ++++++++++++++++++++- include/linux/power_supply.h | 14 ++++ 4 files changed, 116 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index ca830c6cd809..a49e1049cd9b 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -736,3 +736,24 @@ Description: Access: Read Valid values: 1-31 + +What: /sys/class/power_supply//quick_charge_type +Date: Jul 2020 +Contact: Fei Jiang + Description: + Reports the kind of quick charge type based on different adapter power. + Different quick charge type represent different charging power. + QUICK_CHARGE_NORMAL : Charging Power <= 10W + QUICK_CHARGE_FAST : 10W < Charging Power <= 20W + QUICK_CHARGE_FLASH : 20W < Charging Power <= 30W + QUICK_CHARGE_TURBE : 30W < Charging Power <= 50W + QUICK_CHARGE_SUPER : Charging Power > 50W + + Access: Read-Only + Valid values: + 0: QUICK_CHARGE_NORMAL, + 1: QUICK_CHARGE_FAST, + 2: QUICK_CHARGE_FLASH, + 3: QUICK_CHARGE_TURBE, + 4: QUICK_CHARGE_SUPER. + diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index c3d7cbcd4fad..21f0ab748e5e 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -211,6 +211,7 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(MODEL_NAME), POWER_SUPPLY_ATTR(MANUFACTURER), POWER_SUPPLY_ATTR(SERIAL_NUMBER), + POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE), }; static struct attribute * diff --git a/drivers/power/supply/qcom_smbb.c b/drivers/power/supply/qcom_smbb.c index c890e1cec720..21ddfa39f655 100644 --- a/drivers/power/supply/qcom_smbb.c +++ b/drivers/power/supply/qcom_smbb.c @@ -90,6 +90,12 @@ #define STATUS_CHG_FAST BIT(7) /* Fast charging */ #define STATUS_CHG_GONE BIT(8) /* No charger is connected */ +#define IMAX_NORMAL 2000000 +#define IMAX_FAST 4000000 +#define IMAX_FLASH 6000000 +#define IMAX_TURBE 10000000 +#define IMAX_SUPER 12000000 + enum smbb_attr { ATTR_BAT_ISAFE, ATTR_BAT_IMAX, @@ -111,6 +117,7 @@ struct smbb_charger { bool dc_disabled; bool jeita_ext_temp; + bool pd_verifed; unsigned long status; struct mutex statlock; @@ -485,6 +492,58 @@ static const struct smbb_irq { { "dc-valid", smbb_dc_valid_handler }, }; +struct quick_charge { + enum power_supply_type adap_type; + enum power_supply_quick_charge_type adap_cap; +}; + +static struct quick_charge adapter_cap[10] = { + { POWER_SUPPLY_TYPE_USB, QUICK_CHARGE_NORMAL }, + { POWER_SUPPLY_TYPE_USB_DCP, QUICK_CHARGE_NORMAL }, + { POWER_SUPPLY_TYPE_USB_CDP, QUICK_CHARGE_NORMAL }, + { POWER_SUPPLY_TYPE_USB_ACA, QUICK_CHARGE_NORMAL }, + { POWER_SUPPLY_TYPE_USB_FLOAT, QUICK_CHARGE_NORMAL }, + { POWER_SUPPLY_TYPE_USB_PD, QUICK_CHARGE_FAST }, + { POWER_SUPPLY_TYPE_USB_HVDCP, QUICK_CHARGE_FAST }, + { POWER_SUPPLY_TYPE_USB_HVDCP_3, QUICK_CHARGE_FAST }, + { POWER_SUPPLY_TYPE_USB_HVDCP_3P5, QUICK_CHARGE_FAST }, + {0, 0}, +}; + +static int get_quick_charge_type(struct smbb_charger *chg) +{ + union power_supply_propval prop = {0, }; + int charger_type, rc; + int i = 0; + + rc = power_supply_get_property(chg->bat_psy, + POWER_SUPPLY_PROP_STATUS, &prop); + if (rc < 0) + return rc; + if (prop.intval == POWER_SUPPLY_STATUS_DISCHARGING) + return 0; + + rc = power_supply_get_property(chg->usb_psy, + POWER_SUPPLY_PROP_USB_TYPE, &prop); + if (rc < 0) + return rc; + charger_type = prop.intval; + + /* when pd adapter is authenticated successfully */ + if ((charger_type == POWER_SUPPLY_TYPE_USB_PD) && chg->pd_verifed) { + return QUICK_CHARGE_TURBE; + } + + while (adapter_cap[i].adap_type != 0) { + if (charger_type == adapter_cap[i].adap_type) { + return adapter_cap[i].adap_cap; + } + i++; + } + + return 0; +} + static int smbb_usbin_get_property(struct power_supply *psy, enum power_supply_property psp, union power_supply_propval *val) @@ -505,6 +564,9 @@ static int smbb_usbin_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX: val->intval = 2500000; break; + case POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE: + val->intval = get_quick_charge_type(chg); + break; default: rc = -EINVAL; break; @@ -662,11 +724,27 @@ static int smbb_battery_set_property(struct power_supply *psy, const union power_supply_propval *val) { struct smbb_charger *chg = power_supply_get_drvdata(psy); + int charger_type, bat_imax; int rc; switch (psp) { case POWER_SUPPLY_PROP_CURRENT_MAX: - rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, val->intval); + charger_type = get_quick_charge_type(chg); + if (charger_type == QUICK_CHARGE_NORMAL) + bat_imax = IMAX_NORMAL; + else if (charger_type == QUICK_CHARGE_FAST) + bat_imax = IMAX_FAST; + else if (charger_type == QUICK_CHARGE_FLASH) + bat_imax = IMAX_FLASH; + else if (charger_type == QUICK_CHARGE_TURBE) + bat_imax = IMAX_TURBE; + else if (charger_type == QUICK_CHARGE_SUPER) + bat_imax = IMAX_SUPER; + else + bat_imax = IMAX_NORMAL; + + bat_imax = min(val->intval, bat_imax); + rc = smbb_charger_attr_write(chg, ATTR_BAT_IMAX, bat_imax); break; case POWER_SUPPLY_PROP_VOLTAGE_MAX: rc = smbb_charger_attr_write(chg, ATTR_BAT_VMAX, val->intval); @@ -695,6 +773,7 @@ static enum power_supply_property smbb_charger_properties[] = { POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, + POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE, }; static enum power_supply_property smbb_battery_properties[] = { diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index be203985ecdd..3dc3e53c5df1 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -171,6 +171,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER, + POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE, }; enum power_supply_type { @@ -187,6 +188,10 @@ enum power_supply_type { POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ POWER_SUPPLY_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ POWER_SUPPLY_TYPE_WIRELESS, /* Wireless */ + POWER_SUPPLY_TYPE_USB_HVDCP, /* High Voltage DCP */ + POWER_SUPPLY_TYPE_USB_HVDCP_3, /* Efficient High Voltage DCP */ + POWER_SUPPLY_TYPE_USB_HVDCP_3P5, /* Efficient High Voltage DCP */ + POWER_SUPPLY_TYPE_USB_FLOAT, /* Floating charger */ }; enum power_supply_usb_type { @@ -202,6 +207,15 @@ enum power_supply_usb_type { POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID, /* Apple Charging Method */ }; +enum power_supply_quick_charge_type { + QUICK_CHARGE_NORMAL = 0, /* Charging Power <= 10W */ + QUICK_CHARGE_FAST, /* 10W < Charging Power <= 20W */ + QUICK_CHARGE_FLASH, /* 20W < Charging Power <= 30W */ + QUICK_CHARGE_TURBE, /* 30W < Charging Power <= 50W */ + QUICK_CHARGE_SUPER, /* Charging Power > 50W */ + QUICK_CHARGE_MAX, +}; + enum power_supply_notifier_events { PSY_EVENT_PROP_CHANGED, }; From patchwork Wed Aug 4 11:01:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5ZCnIeeOi+Wptw==?= X-Patchwork-Id: 12418577 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F4206C4338F for ; Wed, 4 Aug 2021 11:04:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEA8261029 for ; Wed, 4 Aug 2021 11:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237482AbhHDLEN (ORCPT ); Wed, 4 Aug 2021 07:04:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237821AbhHDLEL (ORCPT ); Wed, 4 Aug 2021 07:04:11 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8967C0613D5; Wed, 4 Aug 2021 04:03:58 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id b1-20020a17090a8001b029017700de3903so5424652pjn.1; Wed, 04 Aug 2021 04:03:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=2HCYsp3V1C0S5jgoA//TBG3tZQ9KgtlQdV6PXheIk70=; b=f+WL5NZhzStujLqiMkkIwb9xaCW0DPxRQnEKb4pPgfyfM4cHWtWCe+IRqSPOYHwmCv CI3tHl9i0XsiaeFM4yVM2KYk4LDQe3Avg/imsS96pxjHUjeOIfm7mMrSO500bcszaVWa wvqqLC/wYewkmJt0NAvOSG8O0vxAkn1vmQa0Ek48A4MSaVbV599vBdc3kJUn5VdNRCVx MXC5O3Mj88GeiHAVzXZCemfEVgAsMcSBPVWHxxqk5LoEiiI+Yl9Q4BRM+vItauaC5L88 LRWMXGa/4bvq/yTSZqRPqccLv7zm3IHiSCxQ9zlYLpRltk5ynFAAdzynnQmiLK5zTEil gtsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=2HCYsp3V1C0S5jgoA//TBG3tZQ9KgtlQdV6PXheIk70=; b=VzoNlOB1Fs1ujy89A08HXb6DsBgFD3ekF/kFcn1DAT6Lhyx0WkVyQgWNg/s3URni5F 3UjwwmLo19C/YKhW/mZY4PJV6WTkVMSgAAQkHOD+e4bfDfDP1QIUW5AuSTz5NVgJ98LO WN4Kzv+6WjVUh9EbohaB8zY9TY8TS8PMnq85efOe/Tu+OsPwLNvdJk6Lm3Gx3e4j9Y/h YqnVa6JbpvfmA3/h1cHAB5KIyKrlzifF+MfT/oMpyDHJV/19Q4ZzYqW5ybNiQv16qiNN TMz/QYoXkkCcXcVtqXTsCzFeufHevHhCwoxXH1+PEyRhhEZCc2ER7JdfGKQz9kQNDoZ5 ntJg== X-Gm-Message-State: AOAM530pwf14qlXalgupXk/1exJ0xfxZbvNeCxKwN+epzuk9+7Z+yBKQ 89ejN3PGHQ4OQnpw50WpRDg= X-Google-Smtp-Source: ABdhPJzWVZGkirIblOT+0R32Us09OoIy7bJpht0vlAJLMST4g4xHtGFvrkdDjTkcJraqWDb0h/q26g== X-Received: by 2002:a17:902:db08:b029:12c:c5d2:534c with SMTP id m8-20020a170902db08b029012cc5d2534cmr8097863plx.47.1628075038379; Wed, 04 Aug 2021 04:03:58 -0700 (PDT) Received: from wangting-OptiPlex-7050.mioffice.cn ([2408:8607:1b00:7:529a:4cff:fe0e:1dd3]) by smtp.gmail.com with ESMTPSA id f6sm2306220pfv.69.2021.08.04.04.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 04:03:58 -0700 (PDT) From: Ting Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, wangting11 Subject: [PATCH v11 2/4] power: supply: core: add wireless charger adapter type property Date: Wed, 4 Aug 2021 19:01:59 +0800 Message-Id: <48bae506e78556b50349e87b356387e46c2923cb.1627992564.git.wangting11@xiaomi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: wangting11 Reports what type of wireless adapter connection is currently active for the supply. for example it can show if ADAPTER_PD capable source is attached. Signed-off-by: wangting11 --- Documentation/ABI/testing/sysfs-class-power | 28 +++++++++++++++++++++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 19 ++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index a49e1049cd9b..36808bf8731b 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -757,3 +757,31 @@ Contact: Fei Jiang 3: QUICK_CHARGE_TURBE, 4: QUICK_CHARGE_SUPER. +===== Wireless Charger Properties ===== +What: /sys/class/power_supply//tx_adapter +Date: Jul 2020 +Contact: Fei Jiang +Description: + Reports the type of wireless adapter connection is currently active for + the supply, for example it can show if ADAPTER_PD capable source + is attached. Expect common wireless adapter type, also increase by + some vendor private adapter type(ex. ADAPTER_PD_40W). + + Access: Read-Only + Valid values: + 0: ADAPTER_NONE, + 1: ADAPTER_SDP, + 2: ADAPTER_DCP, + 3: ADAPTER_CDP, + 4: ADAPTER_OCP, + 5: ADAPTER_QC2, + 6: ADAPTER_QC3, + 7: ADAPTER_PD, + 8: ADAPTER_AUTH_FAILED, + 9: ADAPTER_PRIVATE_QC3, + 10: ADAPTER_PRIVATE_PD, + 11: ADAPTER_CAR_POWER, + 12: ADAPTER_PRIVATE_PD_40W, + 13: ADAPTER_VOICE_BOX, + 14: ADAPTER_PRIVATE_PD_50W. + diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 21f0ab748e5e..561cffef9d61 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -212,6 +212,7 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(MANUFACTURER), POWER_SUPPLY_ATTR(SERIAL_NUMBER), POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE), + POWER_SUPPLY_ATTR(TX_ADAPTER), }; static struct attribute * diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 3dc3e53c5df1..bcfadf2a995f 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -172,6 +172,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_SERIAL_NUMBER, POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE, + POWER_SUPPLY_PROP_TX_ADAPTER, }; enum power_supply_type { @@ -216,6 +217,24 @@ enum power_supply_quick_charge_type { QUICK_CHARGE_MAX, }; +enum power_supply_tx_adapter_type { + ADAPTER_NONE = 0, /* Nothing Attached */ + ADAPTER_SDP, /* Standard Downstream Port */ + ADAPTER_CDP, /* Charging Downstream Port */ + ADAPTER_DCP, /* Dedicated Charging Port */ + ADAPTER_OCP, /* Other Charging Port */ + ADAPTER_QC2, /* Qualcomm Charge 2.0 */ + ADAPTER_QC3, /* Qualcomm Charge 3.0 */ + ADAPTER_PD, /* Power Delivery Port */ + ADAPTER_AUTH_FAILED, /* Authenticated Failed Adapter */ + ADAPTER_PRIVATE_QC3, /* Qualcomm Charge 3.0 with Private Protocol */ + ADAPTER_PRIVATE_PD, /* PD Adapter with Private Protocol */ + ADAPTER_CAR_POWER, /* Wireless Car Charger */ + ADAPTER_PRIVATE_PD_40W, /* 40W PD Adapter with Private Protocol */ + ADAPTER_VOICE_BOX, /* Voice Box which Support Wireless Charger */ + ADAPTER_PRIVATE_PD_50W, /* 50W PD Adapter with Private Protocol */ +}; + enum power_supply_notifier_events { PSY_EVENT_PROP_CHANGED, }; From patchwork Wed Aug 4 11:02:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5ZCnIeeOi+Wptw==?= X-Patchwork-Id: 12418579 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBC89C432BE for ; Wed, 4 Aug 2021 11:04:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D236A61040 for ; Wed, 4 Aug 2021 11:04:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237766AbhHDLET (ORCPT ); Wed, 4 Aug 2021 07:04:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237768AbhHDLES (ORCPT ); Wed, 4 Aug 2021 07:04:18 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B774C06179A; Wed, 4 Aug 2021 04:04:05 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id dw2-20020a17090b0942b0290177cb475142so8145398pjb.2; Wed, 04 Aug 2021 04:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=v5VrqkSgwcCOdp//iZ1+g23cZqbac3VU++EnpM9xUWo=; b=bdXX9UkIiNxdKTu55zA79ScTv3KBbwcD60BGbO4c5FTbCJ1yXmeRL1sSOnODMrwqaw vdyOiaiJCDCoMgCYNT7mXaZpc5q72wNVYtonp57/R26n+HmH4IcjusYJCVd6r+91TivH IQ33hOSA9VULtDS263o3siUjaxr6+Am9PfEJOj3/mjqS2yIZAoedii2nYh4L6X8l367G 8Q18zSV+ydnp5gbWmSSAIaLG7/iwXhzi1/t9zoAKDSdWMY00RaVw+OM99lFcaOldOLGt Vs69FL+d3q+AOQcGPloMFormCzeR3wknSXQ1UlrE7+Bqk2hKzzqudFAG/fRkXOQq81K9 oQ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=v5VrqkSgwcCOdp//iZ1+g23cZqbac3VU++EnpM9xUWo=; b=EsgNY7j1O7be+qahMqJpABLT/F58rDIQlG/x7U+JP/LKB989VUxtN173OESkKmAEf2 x9zhrClWAx7riAbnAdjPLLc7yf/Ik2/Vhwh7jJS0b41BlqLO8mY3iyBE4w+F8WGGb8Q7 n9FwAaUWjJI9YBztRakGZM7HWwbCg1Ju7/d37TeupoJFqBtFSQ3oAvh7JjFDWP5Fnv5l OiSsfOwO3Dzg6sBRrjgwL8hQ6DdrWK96kGbi3l2iuPlbURUO77eq5JL/jridPAGOJzVf MfYA5vgv+WAXiuhcaq9WkE6UbSOuXACcbOLMlrfPQR2QoBTMerqhaiWyhV4qVS6CGitH /VZQ== X-Gm-Message-State: AOAM532xcUV+py/OIsJi4aWrxHnydFgS71T9Plfcd6QpvqFfkvmlA0t2 Up18r5Wl6BeuAqd69HwDLxk= X-Google-Smtp-Source: ABdhPJyf17/KCD/KDGkCC5YNeZ6PbVZA6xobce3OQP6nVQoJYNnbhLAMnZfLWV90yBvJ+g5/SVnItQ== X-Received: by 2002:a17:90a:ccc:: with SMTP id 12mr27577608pjt.57.1628075045064; Wed, 04 Aug 2021 04:04:05 -0700 (PDT) Received: from wangting-OptiPlex-7050.mioffice.cn ([2408:8607:1b00:7:529a:4cff:fe0e:1dd3]) by smtp.gmail.com with ESMTPSA id f6sm2306220pfv.69.2021.08.04.04.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 04:04:04 -0700 (PDT) From: Ting Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, wangting11 Subject: [PATCH v11 3/4] power: supply: core: add wireless signal strength property Date: Wed, 4 Aug 2021 19:02:00 +0800 Message-Id: <8599adb4d1c966c8d0cd6e25137a660546c1115c.1627992564.git.wangting11@xiaomi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: wangting11 reports wireless signal strength. The value show degree of coupling between tx and rx. Signed-off-by: wangting11 --- Documentation/ABI/testing/sysfs-class-power | 22 +++++++++++++++++++++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 24 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 36808bf8731b..4a6b4970cb7d 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -785,3 +785,25 @@ Description: 13: ADAPTER_VOICE_BOX, 14: ADAPTER_PRIVATE_PD_50W. +What: /sys/class/power_supply//signal_strength +Date: Jul 2020 +Contact: Fei Jiang +Description: + In PING phase, RX transmits a signal strength packet as the + first communication packet to instruct the base to keep power + signal on.The value reports wireless signal strength and show + degree of coupling. + + The Qi Wireless Power Transfer System is published by the + Wireless Power Consortium.The ping phase is the necessary stage + for matching transmitter and receiver. In this phase,the Power + Transmitter executes a Digital Ping, and listens for a response. + If the Power Transmitter discovers a Power Receiver, the Power + Transmitter may extend the Digital Ping,i.e. maintain the Power + Signal at the level of the Digital Ping. This causes the system + to proceed to the identification & configuration phase. If the + Power Transmitter does not extend the Digital Ping, the system + shall revert to the selection phase. + + Access: Read-Only + Valid values: 0 - 100 diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 561cffef9d61..4de91dce2001 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -213,6 +213,7 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(SERIAL_NUMBER), POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE), POWER_SUPPLY_ATTR(TX_ADAPTER), + POWER_SUPPLY_ATTR(SIGNAL_STRENGTH), }; static struct attribute * diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index bcfadf2a995f..0dfec19cb473 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -173,6 +173,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_SERIAL_NUMBER, POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE, POWER_SUPPLY_PROP_TX_ADAPTER, + POWER_SUPPLY_PROP_SIGNAL_STRENGTH, }; enum power_supply_type { From patchwork Wed Aug 4 11:02:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5ZCnIeeOi+Wptw==?= X-Patchwork-Id: 12418581 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB344C4338F for ; Wed, 4 Aug 2021 11:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87DB760F43 for ; Wed, 4 Aug 2021 11:04:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237891AbhHDLEc (ORCPT ); Wed, 4 Aug 2021 07:04:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237741AbhHDLE1 (ORCPT ); Wed, 4 Aug 2021 07:04:27 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB70C0617A0; Wed, 4 Aug 2021 04:04:12 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id c16so2586072plh.7; Wed, 04 Aug 2021 04:04:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=7ipuFcAF0hi+YGdtGdT1Vm/pxhGoa9kh3ysl0IJnuL8=; b=CwxFZjlEgvFV8xQjYWnzhmyymTw9EBVKFtGtSqffodm55NGxSOlQiuoxY2IvRLQaLm eHJtshg6pMW+qc7MVFau4YJSvrZUguXESzLUOK4LoPdmj6UYD9TNA/rE6kdknmhmjUPx FQhVibPFzujaUUu27gFJ9Rez3t8iR/JlxcTtjP2TA7KfBYOWZO48zcTag3UGttcDTLQX 8yJOlUP4r+XH+J1MKBus1YaI162hsvaF8QzffAheITSHzCLd5LCCAG0HGm+cHKTTxjqi P8x4X9TUoaiNxZSlmUOMtxtWBxx78kinwntY1QKXpGkyiWQ4ZA/a9aS8dEmb+ne5hrIe FfJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=7ipuFcAF0hi+YGdtGdT1Vm/pxhGoa9kh3ysl0IJnuL8=; b=ezZ8IBn4gsBTVyDahW9njZRKzC+iogUmM7gatYquBzcthOsdj3DkcxQGXXC0aqL9wX nsdD9GxuF7ornIsD+jb7JC5Hweewnkufueh9zub9EP8Jr2+6fr9XxMwdjy2Nhi4OcOpD qKQwPrTxiBHaxcGz78/0cNVQnjTuOvEAaK2+mM60KeFhQrtPQx+6aN+gi7m8P11KaOQi kEtEx0SO32vdehIPE9BnBZi5fKaKZXVU5N2sE4QIMLeJnuIiCWBEKTa778fg0vjNbJA4 gdFv+pt3VlzGJ0Tb0HAmpNzMY+qHoDBCFpQNbGQZnSbyTSKn8pgljoZchT0tQrd7Knnf TJQg== X-Gm-Message-State: AOAM531WQM5G3iMhDt5EoRXdg12N+V1ZweEFoqFdwcj/1RMe2TE6AfmA 6Ayhn2la3QL94CAx00+lNes= X-Google-Smtp-Source: ABdhPJyQ/9mreaAe00O7y1fFI176mhfOvMGrtteEhkhKKcPIUgXof/ODYwI0eFkbW1jPr3bbqoYcWw== X-Received: by 2002:a63:f44a:: with SMTP id p10mr384144pgk.11.1628075051875; Wed, 04 Aug 2021 04:04:11 -0700 (PDT) Received: from wangting-OptiPlex-7050.mioffice.cn ([2408:8607:1b00:7:529a:4cff:fe0e:1dd3]) by smtp.gmail.com with ESMTPSA id f6sm2306220pfv.69.2021.08.04.04.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 04:04:11 -0700 (PDT) From: Ting Wang To: sre@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, wangting11 Subject: [PATCH v11 4/4] power: supply: core: property to control reverse charge Date: Wed, 4 Aug 2021 19:02:01 +0800 Message-Id: <0d72b2e799ec764b851f3efecffbcc20f9b2c55c.1627992564.git.wangting11@xiaomi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: wangting11 Interface to control wireless reverse charge. Signed-off-by: wangting11 --- Documentation/ABI/testing/sysfs-class-power | 14 ++++++++++++++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 3 files changed, 16 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 4a6b4970cb7d..59518568d594 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -807,3 +807,17 @@ Description: Access: Read-Only Valid values: 0 - 100 + +What: /sys/class/power_supply//reverse_chg_mode +Date: Jul 2020 +Contact: Fei Jiang +Description: + Some devices support wireless reverse charge function which + charge other devices.The property provider interface to + enable/disable wireless reverse charge.If enabled, start TX + mode and detect RX. Disabled when timeout or manual setting. + + Access: Read, Write + Valid values: + - 1: enabled + - 0: disabled diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 4de91dce2001..934563eed155 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -214,6 +214,7 @@ static struct power_supply_attr power_supply_attrs[] = { POWER_SUPPLY_ATTR(QUICK_CHARGE_TYPE), POWER_SUPPLY_ATTR(TX_ADAPTER), POWER_SUPPLY_ATTR(SIGNAL_STRENGTH), + POWER_SUPPLY_ATTR(REVERSE_CHG_MODE), }; static struct attribute * diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 0dfec19cb473..3fe3f9665389 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -174,6 +174,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_QUICK_CHARGE_TYPE, POWER_SUPPLY_PROP_TX_ADAPTER, POWER_SUPPLY_PROP_SIGNAL_STRENGTH, + POWER_SUPPLY_PROP_REVERSE_CHG_MODE, }; enum power_supply_type {