From patchwork Thu Sep 24 21:54:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chu Lin X-Patchwork-Id: 11798289 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52827112E for ; Thu, 24 Sep 2020 21:55:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33AB421D20 for ; Thu, 24 Sep 2020 21:55:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="pEOtua9k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726704AbgIXVy4 (ORCPT ); Thu, 24 Sep 2020 17:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726703AbgIXVyx (ORCPT ); Thu, 24 Sep 2020 17:54:53 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC88FC0613CE for ; Thu, 24 Sep 2020 14:54:52 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id 135so289907pfu.9 for ; Thu, 24 Sep 2020 14:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=2E/xrZXG4snTQvNN8sxghzfzhE3a0xWl+7B2al7VEYQ=; b=pEOtua9kRm7qArbE3RNJ2+Erz9ivP52Rq0skDG57m+FhTp9Nd/1U+9lKec8f22lqWg 2WXSsCGkmwZdJ2QmeddXSV9JIEDPZSWxmFRDA6R1gI7dVK00H6VYEpfKxhT7/4kO4TiK yQXdwckSDQFrMX8B6M3mZJTPpJh0EtF9ZG9QTZawhBlpiPvEUDzKIfYVr0CwRmJ16PBF 9CVlqSHR+HRr+nFDJiETIRwXTAzcLmWlQwU0utyLKDk8gX64LUCpnC1jW6ZO70n69MI2 pzCEWx6u1j2+57KN92mRpMrrfkyNJBFN93hdqz5VG2p8qku8jC3fIEFhBgjqaWucf/bT OGZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=2E/xrZXG4snTQvNN8sxghzfzhE3a0xWl+7B2al7VEYQ=; b=P0D0k8n8/zTYk85YIbjGFemoCMjSR2LvPUZougttivixU5W/0JFlC/JgziDjkKXTtl F6WwFpBXB+Fb+QjvIEQn2Q2bASC4U4CY8SGUJr0qN2U2APjSL+1IrTR0Qfmux7EdWJiN 6HkqPzgrZ9vTYds5XpHNEqbfPwfBjPFguR0FqqzPagSj540miTLMxN69+gIUyrdF0nRV vg2TUF4Zsf1yb97DaJctxMVGnDKVAFu5bD1GLKppjq1b2/Ql0+QPv8ksZ5OTMlElTD35 8iiLcQJvw8bgCJM7nuwnCOJXee4G1/9WDXEbBgaAVWBt7GA4AtX/uREss3sdPyhlWCy+ +IMw== X-Gm-Message-State: AOAM532Z91Z9CqdiFY+ohMs4lzegOeCYzjC6pMyC+/qGJq1QmjZOco9F +qpfTKb9GlfllcuUOg318Vli+jFaugZXSbrk X-Google-Smtp-Source: ABdhPJxCEpZGKUe+br0m5BAiDOO8++/bbUvm0kfVYfjlQAxW7eZ48JBasD2RGg0kCCymB93FF3Q65dGvDi4KqHck Sender: "linchuyuan via sendgmr" X-Received: from chu-dev.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:3cfb]) (user=linchuyuan job=sendgmr) by 2002:a63:b47:: with SMTP id a7mr914923pgl.57.1600984492269; Thu, 24 Sep 2020 14:54:52 -0700 (PDT) Date: Thu, 24 Sep 2020 21:54:43 +0000 In-Reply-To: <20200924215444.2865885-1-linchuyuan@google.com> Message-Id: <20200924215444.2865885-2-linchuyuan@google.com> Mime-Version: 1.0 References: <20200924215444.2865885-1-linchuyuan@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 1/2] dt-bindings: hwmon: max20730: adding device tree doc for max20730 From: Chu Lin To: linchuyuan@google.com, jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, qiongwang@google.com, zhongqil@google.com, jasonling@google.com, belgaied@google.com Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org max20730 Integrated, Step-Down Switching Regulator with PMBus Signed-off-by: Chu Lin --- .../bindings/hwmon/maxim,max20730.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml diff --git a/Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml b/Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml new file mode 100644 index 000000000000..7372b27334c3 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/maxim,max20730.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/maxim,max20730.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim max20730 + +maintainers: + - Jean Delvare + - Guenter Roeck + +description: | + The MAX20730 is a fully integrated, highly efficient switching regulator + with PMBus for applications operating from 4.5V to 16V and requiring + up to 25A (max) load. This single-chip regulator provides extremely + compact, highefficiency power-delivery solutions with high-precision + output voltages and excellent transient response + + Datasheets: + https://datasheets.maximintegrated.com/en/ds/MAX20730.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20734.pdf + https://datasheets.maximintegrated.com/en/ds/MAX20743.pdf + +properties: + compatible: + enum: + - maxim,max20730 + - maxim,max20734 + - maxim,max20743 + + reg: + maxItems: 1 + + vout-voltage-divider: + description: | + If voltage divider presents at vout, the voltage at voltage sensor pin + will be scaled. The properties will convert the raw reading to a more + meaningful number if voltage divider presents. It has two numbers, + the first number is the output resistor, the second number is the total + resistance. Therefore, the adjusted vout is equal to + Vout = Vout * output_resistance / total resistance. + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + max20730@10 { + compatible = "maxim,max20730"; + reg = <0x10>; + vout-voltage-divider = <1000 2000>; // vout would be scaled to 0.5 + }; + }; From patchwork Thu Sep 24 21:54:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chu Lin X-Patchwork-Id: 11798287 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 47DE7112E for ; Thu, 24 Sep 2020 21:54:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2AA442399A for ; Thu, 24 Sep 2020 21:54:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="FWvIVB4n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726709AbgIXVy4 (ORCPT ); Thu, 24 Sep 2020 17:54:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726705AbgIXVyz (ORCPT ); Thu, 24 Sep 2020 17:54:55 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F84C0613D6 for ; Thu, 24 Sep 2020 14:54:55 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id u35so650124ybd.13 for ; Thu, 24 Sep 2020 14:54:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to; bh=TuyfSxIkZi+P/JhBNIB6urUJLMN4tVR/8LkLgR5gW14=; b=FWvIVB4nFy3TjF5TUaGKfr+gr0IDuCj3iVXYiz3beykXZPAzbGXNgRRCPQB206Y1KQ WdZtttptVeUthPPTUhjCn1TS4PeYU2tViVkVdp3dP9LaFDi7T6qd8VsmnDZeQZWmODM1 9Znb9S+vKoQy59WNTM1nvYuWItx4WnHMy0G52VerG4CajSRNUvoGkGUJIxFRLBawOzAu uDnJ7UAuk0mW8VgMcKRk5EJZTQohl3aUyJtzunt+Y+/gBZhM3kCWCKsblFn0HCOlJulg 4JciRiKxwuf1siqUq3/Eu7De/jsoTXRVXgrx3AOhb83Xz/oUmnVtaT+IKXkIavPcAgjD vCfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to; bh=TuyfSxIkZi+P/JhBNIB6urUJLMN4tVR/8LkLgR5gW14=; b=F2CHyKDPIRjN1qeGKELDaHz9FJ0VeL7+9qq3tpwymS51quX1MGnQppYilLwiB/e2NT q7CIRE5c/GbWU3ev3YKmI5n5Q8155ZWAasTZGus8U99sRndfPlBkq+qlGO0/lxNsfup3 osLnI3OoDNzGDeCJm9018OxLMVCV6KFNS86TLzSIVazNcIvQSDHFePqFajwcFtpcYV7p /tB/ooYXj7qajDAgtBjlFyxtO5jZWz6DZqx2QYy1BAUO/3jSZuKSuTbL6w+ZKrlNhr3W jl20loJBSinvIgr37lEhurqAwSrl7Cyn4oBYODTm6wlOKpbpyDe9cw8fGK9tBbpnTH3H sAaQ== X-Gm-Message-State: AOAM533W9fA94f+XheO1ftZ7IP+qmb2gyQdkiGnM14Qab85ST54wQj1Y h9g8NpgS85YBVO1ALeh4Sg3ktNvs1AM43g61 X-Google-Smtp-Source: ABdhPJzk4yQgT36MZ0fV0H+HiXWybvORRJARsR02oEoMKu0Ap8ErrcXpHPJ3T5bsC1iNb+dOpAdOjLETvfnRZ1cH Sender: "linchuyuan via sendgmr" X-Received: from chu-dev.c.googlers.com ([fda3:e722:ac3:10:24:72f4:c0a8:3cfb]) (user=linchuyuan job=sendgmr) by 2002:a25:e0d2:: with SMTP id x201mr1323962ybg.180.1600984494820; Thu, 24 Sep 2020 14:54:54 -0700 (PDT) Date: Thu, 24 Sep 2020 21:54:44 +0000 In-Reply-To: <20200924215444.2865885-1-linchuyuan@google.com> Message-Id: <20200924215444.2865885-3-linchuyuan@google.com> Mime-Version: 1.0 References: <20200924215444.2865885-1-linchuyuan@google.com> X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 2/2] hwmon: pmbus: max20730: adjust the vout reading given voltage divider From: Chu Lin To: linchuyuan@google.com, jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, qiongwang@google.com, zhongqil@google.com, jasonling@google.com, belgaied@google.com Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Problem: We use voltage dividers so that the voltage presented at the voltage sense pins is confusing. We might need to convert these readings to more meaningful readings given the voltage divider. Solution: Read the voltage divider resistance from dts and convert the voltage reading to a more meaningful reading. Testing: max20730 with voltage divider Signed-off-by: Chu Lin --- drivers/hwmon/pmbus/max20730.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/hwmon/pmbus/max20730.c b/drivers/hwmon/pmbus/max20730.c index a151a2b588a5..fbf2f1e6c969 100644 --- a/drivers/hwmon/pmbus/max20730.c +++ b/drivers/hwmon/pmbus/max20730.c @@ -31,6 +31,7 @@ struct max20730_data { struct pmbus_driver_info info; struct mutex lock; /* Used to protect against parallel writes */ u16 mfr_devset1; + u32 vout_voltage_divider[2]; }; #define to_max20730_data(x) container_of(x, struct max20730_data, info) @@ -114,6 +115,14 @@ static int max20730_read_word_data(struct i2c_client *client, int page, max_c = max_current[data->id][(data->mfr_devset1 >> 5) & 0x3]; ret = val_to_direct(max_c, PSC_CURRENT_OUT, info); break; + case PMBUS_READ_VOUT: + ret = pmbus_read_word_data(client, page, phase, reg); + if (ret > 0 && data->vout_voltage_divider[0] && data->vout_voltage_divider[1]) { + u64 temp = DIV_ROUND_CLOSEST_ULL((u64)ret * data->vout_voltage_divider[1], + data->vout_voltage_divider[0]); + ret = clamp_val(temp, 0, 0xffff); + } + break; default: ret = -ENODATA; break; @@ -364,6 +373,15 @@ static int max20730_probe(struct i2c_client *client, data->id = chip_id; mutex_init(&data->lock); memcpy(&data->info, &max20730_info[chip_id], sizeof(data->info)); + if (of_property_read_u32_array(client->dev.of_node, "vout-voltage-divider", + data->vout_voltage_divider, + ARRAY_SIZE(data->vout_voltage_divider)) != 0) + memset(data->vout_voltage_divider, 0, sizeof(data->vout_voltage_divider)); + if (data->vout_voltage_divider[1] < data->vout_voltage_divider[0]) { + dev_err(dev, + "The total resistance of voltage divider is less than output resistance\n"); + return -ENODEV; + } ret = i2c_smbus_read_word_data(client, MAX20730_MFR_DEVSET1); if (ret < 0)