From patchwork Tue Nov 12 20:09:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Peltier X-Patchwork-Id: 13872920 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5D32217472; Tue, 12 Nov 2024 20:09:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731442173; cv=none; b=HhY99F2RE4Xfn/A+eWsjKZ+P3zRI91UT+LBFAQkR092GZLj5MvI7/6f/5gyokNkjBA6Zb6+b096zvaFIrhTlkIr3d+CyScdgPgZujk2p8j9ebHoBhEbLE41UJdmnFz6dBJuiYBWk8SoX4SORzT05zAe5oqSrcfPtD/OWDugQCmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731442173; c=relaxed/simple; bh=0NUxq/gGaXjb17hIjFnhDTrdltKpFNdhlU6m+AA7E8A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bDqE8N2HmtD6ss7zSH85/7zjn6chCh+27pn8cHG7VkuvmOmo1JN5dipR6m1DH5/jksV/VSbKKgddx1nZg773myrbmwc+1uvIlBfra3KuQcykl/k/2+WwSmEhJ20DutSx5pnV5YuHicZZtXsLIXHleR6q+59QQGmZl9wUYKqOeDM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YLD9USJ6; arc=none smtp.client-ip=209.85.160.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YLD9USJ6" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-288916b7fceso3104469fac.3; Tue, 12 Nov 2024 12:09:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731442171; x=1732046971; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8uJq0Du4rqp6q8MnkfQL3y7/Gdb34NR8DXejlN7qrL8=; b=YLD9USJ6iBmLbNjpquyM80AIXffQIqZfbqp1R9tHd2D+SqVFAKtCX7L2TtCez62z26 oe1ZvI3b7iaN3s2m2lDnZBPXP0vw5qn2gmNfuksYJs1gtyIMuU+yZw2Mf/OOqhF+mA1o vrDZjmteP2za4Q1t6frMSzc+2/IZeluDNSWRjWxoWV2K2WNwX0lYcjyXQEMjav3tL/W6 qLVecFNY4IpOf5d+A8beMid/RvFIG8ya5NfT+VxFpxtfWxJDPwgcRZ3/nXRBZHxEiJ98 apeXtqYYp3n48eIJ+X5U2JD7jMCUXG6hyQxCmBqqvQ4LEZn7tiB0bWUf/2ri0rq9Wky1 lakg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731442171; x=1732046971; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8uJq0Du4rqp6q8MnkfQL3y7/Gdb34NR8DXejlN7qrL8=; b=h/CFRM6Z2USIG6DEvDM7ActRqu58jY1J+4t/0ox8S8+evl+jq6Iv6G7sUnXb/6Jjxw Nj5DiFVv397OVjUjPwLWpfhB/sjpkZSeaFBbeP5LrlsZ1D57OCZzQhho+IjoeqU94BGO LmHJG5UWTCewoTvqAsqFn3BiHd9+RI1nJKsCHckZXuCu2GNuZ9Wzsll4c3iVKBLIf+P9 OzmuFBBSI9Mwfm2tf5skRBRyQLc8qZnxOwh3nTdt3Bn160kRwPbq+2Vkc0JPB2IELHQo ZurlJduicmdGJz1gITqrb62/FZtoXDKGBl8TUjkJ8Xl9105AE40sd4Y+/v2JJcsvSJ2Q rFjQ== X-Forwarded-Encrypted: i=1; AJvYcCUJSabh/OQ9doLAcQ9t5uC+O6bMZmusOO0vJYuqMzTd6srw2cBN74TSeuq8N62fi73/7XGn7X8viWIk@vger.kernel.org, AJvYcCWX80KbcOYipwMhH0d9rXNehTiHZinsuhL+IpIzwAbfQ2LVwJA3fBeO5F87QD7oudO1x20vq8LctVGpVEg=@vger.kernel.org, AJvYcCXg5Elij4xEm0KQcKn98GEPXsUNhBNbAE85/Y3fL2HDIw9YifHW+6LRi3ZvnFmNzo76Gvcsll77LI/v@vger.kernel.org X-Gm-Message-State: AOJu0Yy/84x8U1XA8To9wKGgge916Mzeas/EMBkY1VvoJLCQfDXVdAbS iy/gGk/lOXEkjrcKc1SEiDYedgLlm2XQvknd4MT28D+iVIIPe+BQ/pWYTHg1 X-Google-Smtp-Source: AGHT+IGGN416Kl54mfU8omFPFmxwyaSOQAvIuqBrXk7rttMt/O8EIclf5sdN5kdOIsiZC82LQQoxeg== X-Received: by 2002:a05:6870:80cc:b0:277:df58:1647 with SMTP id 586e51a60fabf-295e903e1bcmr367764fac.35.1731442170857; Tue, 12 Nov 2024 12:09:30 -0800 (PST) Received: from raspberrypi ([2600:1700:90:4c80::3b]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-71a600a2af3sm42372a34.67.2024.11.12.12.09.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 12:09:30 -0800 (PST) Date: Tue, 12 Nov 2024 14:09:28 -0600 From: Grant Peltier To: robh@kernel.org, linux@roeck-us.net, geert+renesas@glider.be, magnus.damm@gmail.com Cc: grant.peltier.jg@renesas.com, brandon.howell.jg@renesas.com, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v7 1/2] hwmon: (pmbus/isl68137) add support for voltage divider on Vout Message-ID: <8c2d048f87282bcf66313afbf5e923d8fc17b4d7.1731439797.git.grantpeltier93@gmail.com> References: Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Some applications require Vout to be higher than the detectable voltage range of the Vsense pin for a given rail. In such applications, a voltage divider may be placed between Vout and the Vsense pin, but this results in erroneous telemetry being read back from the part. This change adds support for a voltage divider to be defined in the devicetree for a (or multiple) specific rail(s) for a supported digital multiphase device and for the applicable Vout telemetry to be scaled based on the voltage divider configuration. This change copies the implementation of the vout-voltage-divider devicetree property defined in the maxim,max20730 bindings schema since it is the best fit for the use case of scaling hwmon PMBus telemetry. The generic voltage-divider property used by many iio drivers was determined to be a poor fit because that schema is tied directly to iio and the isl68137 driver is not an iio driver. Signed-off-by: Grant Peltier --- drivers/hwmon/pmbus/isl68137.c | 210 ++++++++++++++++++++++++++++++++- 1 file changed, 205 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/pmbus/isl68137.c b/drivers/hwmon/pmbus/isl68137.c index 7e53fb1d5ea3..97cc951a13a4 100644 --- a/drivers/hwmon/pmbus/isl68137.c +++ b/drivers/hwmon/pmbus/isl68137.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,7 @@ #define ISL68137_VOUT_AVS 0x30 #define RAA_DMPVR2_READ_VMON 0xc8 +#define MAX_CHANNELS 4 enum chips { isl68137, @@ -72,6 +74,17 @@ enum variants { raa_dmpvr2_hv, }; +struct isl68137_channel { + u32 vout_voltage_divider[2]; +}; + +struct isl68137_data { + struct pmbus_driver_info info; + struct isl68137_channel channel[MAX_CHANNELS]; +}; + +#define to_isl68137_data(x) container_of(x, struct isl68137_data, info) + static const struct i2c_device_id raa_dmpvr_id[]; static ssize_t isl68137_avs_enable_show_page(struct i2c_client *client, @@ -163,13 +176,32 @@ static const struct attribute_group *isl68137_attribute_groups[] = { static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page, int phase, int reg) { + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); + const struct isl68137_data *data = to_isl68137_data(info); int ret; + u64 temp; switch (reg) { case PMBUS_VIRT_READ_VMON: ret = pmbus_read_word_data(client, page, phase, RAA_DMPVR2_READ_VMON); break; + case PMBUS_READ_POUT: + case PMBUS_READ_VOUT: + /* + * In cases where a voltage divider is attached to the target + * rail between Vout and the Vsense pin, both Vout and Pout + * should be scaled by the voltage divider scaling factor. + * I.e. Vout = Vsense * Rtotal / Rout + */ + ret = pmbus_read_word_data(client, page, phase, reg); + if (ret > 0) { + temp = DIV_U64_ROUND_CLOSEST((u64)ret * + data->channel[page].vout_voltage_divider[1], + data->channel[page].vout_voltage_divider[0]); + ret = clamp_val(temp, 0, 0xffff); + } + break; default: ret = -ENODATA; break; @@ -178,6 +210,40 @@ static int raa_dmpvr2_read_word_data(struct i2c_client *client, int page, return ret; } +static int raa_dmpvr2_write_word_data(struct i2c_client *client, int page, + int reg, u16 word) +{ + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); + const struct isl68137_data *data = to_isl68137_data(info); + int ret; + u64 temp; + + switch (reg) { + case PMBUS_VOUT_MAX: + case PMBUS_VOUT_MARGIN_HIGH: + case PMBUS_VOUT_MARGIN_LOW: + case PMBUS_VOUT_OV_FAULT_LIMIT: + case PMBUS_VOUT_UV_FAULT_LIMIT: + case PMBUS_VOUT_COMMAND: + /* + * In cases where a voltage divider is attached to the target + * rail between Vout and the Vsense pin, Vout related PMBus + * commands should be scaled based on the expected voltage + * at the Vsense pin. + * I.e. Vsense = Vout * Rout / Rtotal + */ + temp = DIV_U64_ROUND_CLOSEST((u64)word * + data->channel[page].vout_voltage_divider[0], + data->channel[page].vout_voltage_divider[1]); + ret = clamp_val(temp, 0, 0xffff); + break; + default: + ret = -ENODATA; + break; + } + return ret; +} + static struct pmbus_driver_info raa_dmpvr_info = { .pages = 3, .format[PSC_VOLTAGE_IN] = direct, @@ -220,14 +286,90 @@ static struct pmbus_driver_info raa_dmpvr_info = { | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT, }; +static int isl68137_probe_child_from_dt(struct device *dev, + struct device_node *child, + struct isl68137_data *data) +{ + u32 channel, rout, rtotal; + int err; + + err = of_property_read_u32(child, "reg", &channel); + if (err) { + dev_err(dev, "missing reg property of %pOFn\n", child); + return err; + } + if (channel >= data->info.pages) { + dev_err(dev, "invalid reg %d of %pOFn\n", channel, child); + return -EINVAL; + } + + err = of_property_read_u32_array(child, "vout-voltage-divider", + data->channel[channel].vout_voltage_divider, + ARRAY_SIZE(data->channel[channel].vout_voltage_divider)); + if (err && err != -EINVAL) { + dev_err(dev, + "malformed vout-voltage-divider value for channel %d\n", + channel); + return err; + } + + rout = data->channel[channel].vout_voltage_divider[0]; + rtotal = data->channel[channel].vout_voltage_divider[1]; + if (rout == 0) { + dev_err(dev, + "Voltage divider output resistance must be greater than 0\n"); + return -EINVAL; + } + if (rtotal < rout) { + dev_err(dev, + "Voltage divider total resistance is less than output resistance\n"); + return -EINVAL; + } + + return 0; +} + +static int isl68137_probe_from_dt(struct device *dev, + struct isl68137_data *data) +{ + const struct device_node *np = dev->of_node; + struct device_node *child; + int err; + + for_each_child_of_node(np, child) { + if (strcmp(child->name, "channel")) + continue; + + err = isl68137_probe_child_from_dt(dev, child, data); + if (err) + return err; + } + + return 0; +} + static int isl68137_probe(struct i2c_client *client) { + struct device *dev = &client->dev; struct pmbus_driver_info *info; + struct isl68137_data *data; + int i, err; - info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); - if (!info) + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) return -ENOMEM; - memcpy(info, &raa_dmpvr_info, sizeof(*info)); + + /* + * Initialize all voltage dividers to Rout=1 and Rtotal=1 to simplify + * logic in PMBus word read/write functions + */ + for (i = 0; i < MAX_CHANNELS; i++) + memset(data->channel[i].vout_voltage_divider, + 1, + sizeof(data->channel[i].vout_voltage_divider)); + + memcpy(&data->info, &raa_dmpvr_info, sizeof(data->info)); + info = &data->info; switch (i2c_match_id(raa_dmpvr_id, client)->driver_data) { case raa_dmpvr1_2rail: @@ -237,11 +379,14 @@ static int isl68137_probe(struct i2c_client *client) info->func[1] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT | PMBUS_HAVE_IOUT | PMBUS_HAVE_STATUS_IOUT | PMBUS_HAVE_POUT; + info->read_word_data = raa_dmpvr2_read_word_data; + info->write_word_data = raa_dmpvr2_write_word_data; info->groups = isl68137_attribute_groups; break; case raa_dmpvr2_1rail: info->pages = 1; info->read_word_data = raa_dmpvr2_read_word_data; + info->write_word_data = raa_dmpvr2_write_word_data; break; case raa_dmpvr2_2rail_nontc: info->func[0] &= ~PMBUS_HAVE_TEMP3; @@ -250,9 +395,11 @@ static int isl68137_probe(struct i2c_client *client) case raa_dmpvr2_2rail: info->pages = 2; info->read_word_data = raa_dmpvr2_read_word_data; + info->write_word_data = raa_dmpvr2_write_word_data; break; case raa_dmpvr2_3rail: info->read_word_data = raa_dmpvr2_read_word_data; + info->write_word_data = raa_dmpvr2_write_word_data; break; case raa_dmpvr2_hv: info->pages = 1; @@ -263,11 +410,16 @@ static int isl68137_probe(struct i2c_client *client) info->m[PSC_POWER] = 2; info->R[PSC_POWER] = -1; info->read_word_data = raa_dmpvr2_read_word_data; + info->write_word_data = raa_dmpvr2_write_word_data; break; default: return -ENODEV; } + err = isl68137_probe_from_dt(dev, data); + if (err) + return err; + return pmbus_do_probe(client, info); } @@ -318,11 +470,59 @@ static const struct i2c_device_id raa_dmpvr_id[] = { MODULE_DEVICE_TABLE(i2c, raa_dmpvr_id); +static const struct of_device_id isl68137_of_match[] = { + { .compatible = "isil,isl68137", .data = (void *)raa_dmpvr1_2rail }, + { .compatible = "renesas,isl68220", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl68221", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl68222", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl68223", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl68224", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl68225", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl68226", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl68227", .data = (void *)raa_dmpvr2_1rail }, + { .compatible = "renesas,isl68229", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl68233", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl68239", .data = (void *)raa_dmpvr2_3rail }, + + { .compatible = "renesas,isl69222", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69223", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl69224", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69225", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69227", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl69228", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl69234", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69236", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69239", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl69242", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69243", .data = (void *)raa_dmpvr2_1rail }, + { .compatible = "renesas,isl69247", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69248", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69254", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69255", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69256", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69259", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "isil,isl69260", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,isl69268", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "isil,isl69269", .data = (void *)raa_dmpvr2_3rail }, + { .compatible = "renesas,isl69298", .data = (void *)raa_dmpvr2_2rail }, + + { .compatible = "renesas,raa228000", .data = (void *)raa_dmpvr2_hv }, + { .compatible = "renesas,raa228004", .data = (void *)raa_dmpvr2_hv }, + { .compatible = "renesas,raa228006", .data = (void *)raa_dmpvr2_hv }, + { .compatible = "renesas,raa228228", .data = (void *)raa_dmpvr2_2rail_nontc }, + { .compatible = "renesas,raa229001", .data = (void *)raa_dmpvr2_2rail }, + { .compatible = "renesas,raa229004", .data = (void *)raa_dmpvr2_2rail }, + { }, +}; + +MODULE_DEVICE_TABLE(of, isl68137_of_match); + /* This is the driver that will be inserted */ static struct i2c_driver isl68137_driver = { .driver = { - .name = "isl68137", - }, + .name = "isl68137", + .of_match_table = isl68137_of_match, + }, .probe = isl68137_probe, .id_table = raa_dmpvr_id, }; From patchwork Tue Nov 12 20:10:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Peltier X-Patchwork-Id: 13872921 Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 69819219C8D; Tue, 12 Nov 2024 20:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731442212; cv=none; b=KlQn3XjePOmh4FZeLTmPOyc8HLoX2xH59WXz/z6F0k8M4aW/MG+juCETNA6ZIslZSEAPp7wOyW291hqGt4cH/PdcvTcbL/WeZT972xKi/ShbiAi6FJFxWMKHJxbrDW+bfM6CXa2gF3gAQp6HT9iTWLU/Sn/RLAGTS2wl1TvDoek= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731442212; c=relaxed/simple; bh=Ft4reouLgmooGNp1IzuEgObU1EGpzYrvBVstwPJi/I4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pkdJEKDr6lx5A4cHvJRuIYutoXlocLJ5MZzmVo1blUWQvXF5qGRL0oBaYgynAYuiTh/pxJI6Uw19RgjPOG3rE/ToQyMk9i31TZwXKh5Ivrm/CRD2AfCacicAKceCVYouR76ohAaSVt2qNldzcIebHQwGgjYEbsfryQ2ocGu2CC0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h8quB+Ph; arc=none smtp.client-ip=209.85.167.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h8quB+Ph" Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3e604425aa0so3543129b6e.0; Tue, 12 Nov 2024 12:10:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731442209; x=1732047009; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8gaVCPXgww8S01oVPq24IM08aAIF+M/sEyh1exT53yE=; b=h8quB+PhAoBh2WGKBX4B8XjswMrgMZYRS9WBDulzGU9XEzIHqb84ThaK6vFupekTcS 6mGfhqubq06IEJFL0iaaktbMv5l0r/M9YQ3grE/vce5l6C1bJaGP7rWTLSrpnQWzQ/SS KZ2XtvbVjz6BDCRlwPTf+2UcQ1uccg22+577ai2AQeC5YyHfv8zBdC1oo7ouc2FsBM9x S3WGDL1E/buWW9HqO5gJktrcBrLrSH0OL7mgORFqHDU2ZUjN/Dz8cLOXgiO2QgIR9t2S pArtJAhDnX3dJsh8DSm6NKH+Z0yH9g00V7ItMi+IzL80qk/ro7RP1EniMXVISzY9NVi7 JOLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731442209; x=1732047009; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=8gaVCPXgww8S01oVPq24IM08aAIF+M/sEyh1exT53yE=; b=T20ZSW+P5TqcaXA3hxm9bnuWRp9dREWo/rV2nXWKxnlKesRbB8u9sVXmrmoTQEBzff tdwrghBMpnMplcqQc1nW1W7X4jAUa1fdhEhOcroY/gISe1rQhIxtr+ObGIfz+EbwaRl/ tPZrTF6ulbPoaL6hscy517OHzqtE/cb44wTZBl0sO+hpI2VWkeAfA9RLbKXjO/ufrpTE hrr7ZlTMaiFlOl6mggjvlxZCoiVA95jsUdK9Phw5C6U4QCNM1Q8uymJidCABJQOOEnMR XzRRMjiNpOV0g+69lPBgCCzuKzzWO/89UNTTNS0Mwebn/wz6ykEkXqDurLOVfM4md9aT cPPw== X-Forwarded-Encrypted: i=1; AJvYcCU93nq77alP5ogLE9hhsvJjjPSxToenCh/KVFlv/Vzd9VUqT3dcMBnmCrpIE0Ae4jHKn1gGxWSPidk69pA=@vger.kernel.org, AJvYcCWOqr6vxk2iOSPElTEr5k9y08F8pW6Ex3cBg1dGwNM4FX0YWQiICr1x6/FajOPT6Yggk/ZdJquPKiF4@vger.kernel.org, AJvYcCWij9fOJ9En79RgIWJss1ImaqfO3CnT3W3PbTtbMOjBF6HfAlNxxL8y18b9Hbr8h+D/AIJlN13Lvz1C@vger.kernel.org X-Gm-Message-State: AOJu0YzL2c466OU/KItYXqWLT2VVK0bWdSRg88bVnbtVQffeqKJh0MKI O4gqeDZE92SWDjonP/24y8ugLrLbZiw6dduE+Tne6Gp2DEjhGMaG X-Google-Smtp-Source: AGHT+IHHe3B1JqqFy8F72j5meLToyh+TFOncLelRarysE4VBAHZgBlb5vFh8P2CQ8ScXCIgpB3hI2g== X-Received: by 2002:a05:6870:5a6:b0:288:865e:1864 with SMTP id 586e51a60fabf-2955fc63dd2mr15035475fac.0.1731442208545; Tue, 12 Nov 2024 12:10:08 -0800 (PST) Received: from raspberrypi ([2600:1700:90:4c80::3b]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-295e8eb8c83sm60791fac.4.2024.11.12.12.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 12:10:07 -0800 (PST) Date: Tue, 12 Nov 2024 14:10:06 -0600 From: Grant Peltier To: robh@kernel.org, linux@roeck-us.net, geert+renesas@glider.be, magnus.damm@gmail.com Cc: grant.peltier.jg@renesas.com, brandon.howell.jg@renesas.com, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v7 2/2] dt-bindings: hwmon: isl68137: add bindings to support voltage dividers Message-ID: References: Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Add devicetree bindings to support declaring optional voltage dividers to the rail outputs of supported digital multiphase regulators. Some applications require Vout to exceed the voltage range that the Vsense pin can detect. This binding definition allows users to define the characteristics of a voltage divider placed between Vout and the Vsense pin for any rail powered by the device. These bindings copy the vout-voltage-divider property defined in the maxim,max20730 bindings schema since it is the best fit for the use case of scaling hwmon PMBus telemetry. The generic voltage-divider property used by many iio drivers was determined to be a poor fit because that schema is tied directly to iio for the purpose of scaling io-channel voltages and the isl68137 driver is not an iio driver. New schema file named isil,isl68137.yaml to align with the corresponding driver name and pre-existing bindings ported from trivial bindings. However, all new device bindings use renesas as the vendor prefix since Renesas acquired Intersil and now maintains all documentation for the devices. Signed-off-by: Grant Peltier Reviewed-by: Rob Herring (Arm) --- .../bindings/hwmon/pmbus/isil,isl68137.yaml | 148 ++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 6 - 2 files changed, 148 insertions(+), 6 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/pmbus/isil,isl68137.yaml diff --git a/Documentation/devicetree/bindings/hwmon/pmbus/isil,isl68137.yaml b/Documentation/devicetree/bindings/hwmon/pmbus/isil,isl68137.yaml new file mode 100644 index 000000000000..bac5f8e352aa --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/pmbus/isil,isl68137.yaml @@ -0,0 +1,148 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- + +$id: http://devicetree.org/schemas/hwmon/pmbus/isil,isl68137.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas Digital Multiphase Voltage Regulators with PMBus + +maintainers: + - Grant Peltier + +description: | + Renesas digital multiphase voltage regulators with PMBus. + https://www.renesas.com/en/products/power-management/multiphase-power/multiphase-dcdc-switching-controllers + +properties: + compatible: + enum: + - isil,isl68137 + - renesas,isl68220 + - renesas,isl68221 + - renesas,isl68222 + - renesas,isl68223 + - renesas,isl68224 + - renesas,isl68225 + - renesas,isl68226 + - renesas,isl68227 + - renesas,isl68229 + - renesas,isl68233 + - renesas,isl68239 + - renesas,isl69222 + - renesas,isl69223 + - renesas,isl69224 + - renesas,isl69225 + - renesas,isl69227 + - renesas,isl69228 + - renesas,isl69234 + - renesas,isl69236 + - renesas,isl69239 + - renesas,isl69242 + - renesas,isl69243 + - renesas,isl69247 + - renesas,isl69248 + - renesas,isl69254 + - renesas,isl69255 + - renesas,isl69256 + - renesas,isl69259 + - isil,isl69260 + - renesas,isl69268 + - isil,isl69269 + - renesas,isl69298 + - renesas,raa228000 + - renesas,raa228004 + - renesas,raa228006 + - renesas,raa228228 + - renesas,raa229001 + - renesas,raa229004 + + reg: + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + +patternProperties: + "^channel@([0-3])$": + type: object + description: + Container for properties specific to a particular channel (rail). + + properties: + reg: + description: The channel (rail) index. + items: + minimum: 0 + maximum: 3 + + vout-voltage-divider: + description: | + Resistances of a voltage divider placed between Vout and the voltage + sense (Vsense) pin for the given channel (rail). It has two numbers + representing the resistances of the voltage divider provided as + which yields an adjusted Vout as + Vout_adj = Vout * Rtotal / Rout given the original Vout as reported + by the Vsense pin. Given a circuit configuration similar to the one + below, Rtotal = R1 + Rout. + + Vout ----. + | + .-----. + | R1 | + '-----' + | + +---- Vsense + | + .-----. + | Rout| + '-----' + | + GND + + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + + required: + - reg + + additionalProperties: false + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + isl68239@60 { + compatible = "isil,isl68137"; + reg = <0x60>; + }; + }; + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + isl68239@60 { + compatible = "renesas,isl68239"; + reg = <0x60>; + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + vout-voltage-divider = <1000 2000>; // Reported Vout/Pout would be scaled by 2 + }; + }; + }; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 0108d7507215..5afe09026938 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -155,12 +155,6 @@ properties: - isil,isl29028 # Intersil ISL29030 Ambient Light and Proximity Sensor - isil,isl29030 - # Intersil ISL68137 Digital Output Configurable PWM Controller - - isil,isl68137 - # Intersil ISL69260 PMBus Voltage Regulator - - isil,isl69260 - # Intersil ISL69269 PMBus Voltage Regulator - - isil,isl69269 # Intersil ISL76682 Ambient Light Sensor - isil,isl76682 # JEDEC JESD300 (SPD5118) Hub and Serial Presence Detect