Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1922218imu; Fri, 23 Nov 2018 02:06:54 -0800 (PST) X-Google-Smtp-Source: AFSGD/U/7ltc0qQNKMht3CYLpap7ToaB7urlFNHlUqguKNZGJ6BisjjZdAwCJ2ftrjiyRAi3h/Az X-Received: by 2002:a63:4342:: with SMTP id q63mr13535654pga.63.1542967614880; Fri, 23 Nov 2018 02:06:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542967614; cv=none; d=google.com; s=arc-20160816; b=MxnSSIohZ6EsOmxOt7e9vtjeBcn0hUuLgHJjCaQga9YFy+mxyLUwx5I/pacOV/6bvd hJM1D8IXUhesN52ySxQe2b9RcMzXFZB5jn/MvQyz31X3xx99QUX9UPgDkttKwU9kLhG1 3CkeBrjFHWN7pQC/udEFojd4BfZR0p85+B1Y+fuSPT3I8u41UV0Gs2ye6U0iEroRH1oT X0KtzUJFkCwDXCHaodNnWW+vwDVFnc35Uywf67Lt9UTQRxuZ5J2vxG7KXZMvJ3izKEQL jz5hJJjzVeB0nBjss2p4J2M3SOEC9CM15yYhKCmPJvYcY74to1kb/kpVpjh9jZpOGnuz awsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=oZCDV2gIP1iXi8uQrpfTxIRrAJXbvm0ATgHG1QNn4L0=; b=LQj1GJavkNiGfdL72N485LLvVxBRDYkjemJg8/RAe1KsqTyPpFn9mw7QcZ8VjxbRA+ LyU2WyHR+LBKOOn1r290BDgfrvMb/jNHdZ0Gkmlr1STJPaXnuls38UjZOE2YwujoXuji J7woIvZmc5rsNYukukqwgVGspzBYEF0+tRF0nLx9nnEBqxrvQTd/C0CQ58AAjoDnYgzJ G2OaXVN/xhZGGmKx7riHWG2yyz5TAxAUuc/3/1CXur9w5YYjw607nb8xhaPfc/hIjzNa sgnAPRUQkm7yUDnl11rLLpa7aj5Ydr2Buzbp42arbQQf3ICvq09yyHAQ/9ZrjuWbGRe2 d0Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i20si33883464pgh.187.2018.11.23.02.06.39; Fri, 23 Nov 2018 02:06:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393909AbeKVUuO (ORCPT + 99 others); Thu, 22 Nov 2018 15:50:14 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:53704 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390457AbeKVUuO (ORCPT ); Thu, 22 Nov 2018 15:50:14 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id C44752753E0 From: Enric Balletbo i Serra To: linux-pm@vger.kernel.org, sre@kernel.org Cc: Sameer Nanda , gwendal@chromium.org, linux-kernel@vger.kernel.org, groeck@chromium.org, Adam.Thomson.Opensource@diasemi.com, kernel@collabora.com, bleung@chromium.org, "Rafael J. Wysocki" , Len Brown , Pavel Machek Subject: [PATCH v2 1/2] power: supply: add input voltage limit property. Date: Thu, 22 Nov 2018 11:11:18 +0100 Message-Id: <20181122101119.29194-1-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have a problem with USBPD chargers which under certain conditions can result in system overheating if the voltage provided by the USBPD port is too high. While the preferred means to control this would be through devicetree or ACPI settings, this is not always possible, and we need to have a means to set a voltage limit. This patch exposes a new property, similar to input current limit, to re-configure the maximum voltage from the external supply at runtime based on system-level knowledge or user input. Signed-off-by: Enric Balletbo i Serra Reviewed-by: Guenter Roeck --- Changes in v2: - Document the new property in ABI/testing/sysfs-class-power. - Add the Reviewed-by Guenter Roeck tag. Documentation/ABI/testing/sysfs-class-power | 11 +++++++++++ Documentation/power/power_supply_class.txt | 2 ++ drivers/power/supply/power_supply_sysfs.c | 1 + include/linux/power_supply.h | 1 + 4 files changed, 15 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-power b/Documentation/ABI/testing/sysfs-class-power index 5e23e22dce1b..4fb24b0a28df 100644 --- a/Documentation/ABI/testing/sysfs-class-power +++ b/Documentation/ABI/testing/sysfs-class-power @@ -335,6 +335,17 @@ Description: Access: Read, Write Valid values: Represented in microamps +What: /sys/class/power_supply//input_voltage_limit +Date: Nov 2018 +Contact: linux-pm@vger.kernel.org +Description: + Details the incoming VBUS voltage limit currently set in the + supply. Normally this is configured based on the type of + connection made. + + Access: Read, Write + Valid values: Represented in microvolts + What: /sys/class/power_supply//online, Date: May 2007 Contact: linux-pm@vger.kernel.org diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt index 300d37896e51..7b4be615b4f8 100644 --- a/Documentation/power/power_supply_class.txt +++ b/Documentation/power/power_supply_class.txt @@ -137,6 +137,8 @@ power supply object. INPUT_CURRENT_LIMIT - input current limit programmed by charger. Indicates the current drawn from a charging source. +INPUT_VOLTAGE_LIMIT - input voltage limit programmed by charger. Indicates +the voltage limit from a charging source. CHARGE_CONTROL_LIMIT - current charge control limit setting CHARGE_CONTROL_LIMIT_MAX - maximum charge control limit setting diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index dce24f596160..5848742ebb59 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -275,6 +275,7 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(charge_control_limit), POWER_SUPPLY_ATTR(charge_control_limit_max), POWER_SUPPLY_ATTR(input_current_limit), + POWER_SUPPLY_ATTR(input_voltage_limit), POWER_SUPPLY_ATTR(energy_full_design), POWER_SUPPLY_ATTR(energy_empty_design), POWER_SUPPLY_ATTR(energy_full), diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index f80769175c56..608ba88e32ee 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -122,6 +122,7 @@ enum power_supply_property { POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT, POWER_SUPPLY_PROP_CHARGE_CONTROL_LIMIT_MAX, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, + POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT, POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN, POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN, POWER_SUPPLY_PROP_ENERGY_FULL, -- 2.19.1