From patchwork Mon Dec 5 19:19:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13065017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4A34C47089 for ; Mon, 5 Dec 2022 19:24:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233145AbiLETYr (ORCPT ); Mon, 5 Dec 2022 14:24:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233823AbiLETYT (ORCPT ); Mon, 5 Dec 2022 14:24:19 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F12B22B27E for ; Mon, 5 Dec 2022 11:19:36 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id bj12so820209ejb.13 for ; Mon, 05 Dec 2022 11:19:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5L+qTAfuZPG5WnKaVEWtwjcOqVnyYOacNUwcNu1tFHs=; b=Y31lbTMUiQr0kXpiCqWx16+GvJOMMjMmzARKZjw8mjNl3+1Y20WLfJ+6J7WBeDDv9R 3OKW6WKcuQ5A6H8csb7jfgKTIouKnIbrMUKjX6/Tnlsd++n6HPhprexi5skue4poGt+l H0qKJfrgyAEwTUa+BhGPDdSSk9EzYmVGUzmoKU8rku3nRK6xHhE70jw8eOrIANcKknXW Sbv1qLeuHhShcJyVW8YfPTPnfQxFJdHcqFezTrixidwLST+SqV6MYYTQtZoW9PHQBAW8 N6wLiypYh8CPKYPFY2ornU1zj5d4BvX1UDnZLRXxbzaX2dFSKTk7GwOPmvLJR/dmUUHu kkEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5L+qTAfuZPG5WnKaVEWtwjcOqVnyYOacNUwcNu1tFHs=; b=wWrOFEu9VlCzlK/jRhDF5HjvGx8NdUKOxuHrUQvJwvUsY23exO3kEP36gygmlTv0tO rq87M4sxUenEfi5RKZZUhxMgDzC2F9zHb0MlllCXVgpFbKlTNUeJv/hJS8mHqk5foZwj qZeEYZwKuezh/RghCzigJ7LmqkozNZJecB4CMkHstbAjm/k3Okk9BrV/BG7iynGomJYd QdWjAOZRMDPfr6O8+hJtI+kmgwfP3u+sGYs0R7Dk032lDKm8PK/k9cfvU7Pbx0El31M4 4DhsR58WPc0sNa8jdwDqcsdQE26T+oqtgESczMnBo8RSOUrCYgM/alaF4xnfDtsSWZoa kn/Q== X-Gm-Message-State: ANoB5pn95upS09YtVDlw7r7Y+nM22RDpf1Ce4bKHgrU+xFyd+bMtIG2H 07l6h95XG2prbX/aZyzNaRAtpw== X-Google-Smtp-Source: AA0mqf5VNbbalgVMqqH4SE6bfakYXlA038qT0LPKYSLdVX2azR4i+BC5AHu9UJRLisgaGTnQKdfTDw== X-Received: by 2002:a17:906:b811:b0:7c0:9ff2:c206 with SMTP id dv17-20020a170906b81100b007c09ff2c206mr20485560ejb.609.1670267975533; Mon, 05 Dec 2022 11:19:35 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id t16-20020aa7db10000000b0045cf4f72b04sm112739eds.94.2022.12.05.11.19.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 11:19:35 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH v6 1/5] hwmon: (pmbus/core): Add interrupt support Date: Mon, 5 Dec 2022 20:19:12 +0100 Message-Id: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Patrick Rudolph Implement PMBUS irq handler. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus.h | 2 +- drivers/hwmon/pmbus/pmbus_core.c | 84 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) base-commit: 9494c53e1389b120ba461899207ac8a3aab2632c diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 10fb17879f8e..6b2e6cf93b19 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h @@ -26,7 +26,7 @@ enum pmbus_regs { PMBUS_CAPABILITY = 0x19, PMBUS_QUERY = 0x1A, - + PMBUS_SMBALERT_MASK = 0x1B, PMBUS_VOUT_MODE = 0x20, PMBUS_VOUT_COMMAND = 0x21, PMBUS_VOUT_TRIM = 0x22, diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 95e95783972a..244fd2597252 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3072,11 +3072,89 @@ static int pmbus_regulator_register(struct pmbus_data *data) return 0; } + +static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) +{ + return pmbus_write_word_data(client, page, PMBUS_SMBALERT_MASK, reg | (val << 8)); +} + +static irqreturn_t pmbus_fault_handler(int irq, void *pdata) +{ + struct pmbus_data *data = pdata; + struct i2c_client *client = to_i2c_client(data->dev); + int i, status; + + for (i = 0; i < data->info->pages; i++) { + + mutex_lock(&data->update_lock); + status = pmbus_read_status_word(client, i); + if (status < 0) { + mutex_unlock(&data->update_lock); + return status; + } + + if (status & ~(PB_STATUS_OFF | PB_STATUS_BUSY | PB_STATUS_POWER_GOOD_N)) + pmbus_clear_fault_page(client, i); + + mutex_unlock(&data->update_lock); + } + + return IRQ_HANDLED; +} + +static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data) +{ + struct device *dev = &client->dev; + const struct pmbus_regulator_status_category *cat; + const struct pmbus_regulator_status_assoc *bit; + int i, j, err, ret, func; + u8 mask; + + for (i = 0; i < data->info->pages; i++) { + func = data->info->func[i]; + + for (j = 0; j < ARRAY_SIZE(pmbus_regulator_flag_map); j++) { + cat = &pmbus_regulator_flag_map[j]; + if (!(func & cat->func)) + continue; + mask = 0; + for (bit = cat->bits; bit->pflag; bit++) + mask |= bit->pflag; + + err = pmbus_write_smbalert_mask(client, i, cat->reg, ~mask); + if (err) + dev_err(dev, "Failed to set smbalert for reg 0x%02x\n", cat->reg); + } + + pmbus_write_smbalert_mask(client, i, PMBUS_STATUS_CML, 0xff); + pmbus_write_smbalert_mask(client, i, PMBUS_STATUS_OTHER, 0xff); + pmbus_write_smbalert_mask(client, i, PMBUS_STATUS_MFR_SPECIFIC, 0xff); + if (data->info->func[i] & PMBUS_HAVE_FAN12) + pmbus_write_smbalert_mask(client, i, PMBUS_STATUS_FAN_12, 0xff); + if (data->info->func[i] & PMBUS_HAVE_FAN34) + pmbus_write_smbalert_mask(client, i, PMBUS_STATUS_FAN_34, 0xff); + } + + /* Register notifiers - can fail if IRQ is not given */ + ret = devm_request_threaded_irq(dev, client->irq, NULL, pmbus_fault_handler, + 0, "pmbus-irq", data); + if (ret) { + dev_warn(dev, "IRQ disabled %d\n", ret); + return ret; + } + + return 0; +} + #else static int pmbus_regulator_register(struct pmbus_data *data) { return 0; } +static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data) +{ + return 0; +} #endif static struct dentry *pmbus_debugfs_dir; /* pmbus debugfs directory */ @@ -3441,6 +3519,12 @@ int pmbus_do_probe(struct i2c_client *client, struct pmbus_driver_info *info) if (ret) return ret; + if (client->irq > 0) { + ret = pmbus_irq_setup(client, data); + if (ret) + return ret; + } + ret = pmbus_init_debugfs(client, data); if (ret) dev_warn(dev, "Failed to register debugfs\n"); From patchwork Mon Dec 5 19:19:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13065018 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75D21C47089 for ; Mon, 5 Dec 2022 19:24:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233889AbiLETYu (ORCPT ); Mon, 5 Dec 2022 14:24:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbiLETYW (ORCPT ); Mon, 5 Dec 2022 14:24:22 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA8727CC2 for ; Mon, 5 Dec 2022 11:19:40 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id ud5so916133ejc.4 for ; Mon, 05 Dec 2022 11:19:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; 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=cxBW8yp9uVxjnMmLtiQH8YKJ4OzTSN8FpMGVyjSKVsU=; b=EgfF4L9WnVGuj5kiAv6q10Bm41y9KAvnDik2cbYyS7TA+fNQM5spcaL7JwOPbXXrjO yC61N8TXxMYM5UUEbfArcLLdQ0eazVnG5EV/vPY1KAMRxhpJOJlBsETKq+K8joqjQ9uE vvKxrvbfqOl5ELFBYnKO1zbu0jNkBsYkRzqtJDxSmKLqaA01aarWmK/rh/DR7uvxL33T yt4ZOBNGABqP06YK7HsM35mObRz2bAcfKdV5KY41yK6gdVf6wHU+MYGjrpvVWM/dJTPI ulBh/3APVS5U4QIv7M2ETTgS1WGup2Q/DGsXjjKY92ObesgR8LV/xlRFoDmWLi2pBfyL 1tTA== 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=cxBW8yp9uVxjnMmLtiQH8YKJ4OzTSN8FpMGVyjSKVsU=; b=J8x69O+mUwx7zhXtj4P0/juojQW3PM7ItErmUQQNyR9SMlEVZrA+pANVr8XcJtcepk C9NuYQQZIuvIUWw0hPTL5CXuJoshau/OONxRN2kWt6DBLS+1w3swy80yFBMfO3Jo0Gie J1assqDHhNPKUoJ8PSlACoHOuYaE9jHxk3ReiuWeRgUVKhTL6XGoJZ1Clskydrb1ulTW qysLQKV4VB0focULWKWBsmpi5v7MkZiX4IYrdqusHcPUZL8ZBiq9cx2Xe2YcyhI2Tz0Z efctEjkpVs3INfcBWyLjWPfvN9dYMTj+oW74bXBmXmEijCUcQNdTSEqn5lvTzfx188uU DLAQ== X-Gm-Message-State: ANoB5pl/sPkSAEYKmmHwETRSS50UrloAemGCBvRDIRyeSI2h21zWo49q ZlqqjsMbCCBjvisBaiUB3LhCGw== X-Google-Smtp-Source: AA0mqf53fCQueU6/b/N/g3O7wxIDQTfhZlPfRRo+hdaDy4APtFYIOy/XilGhgzMGkxICwkQj7O3SAg== X-Received: by 2002:a17:906:79c4:b0:778:e3e2:8311 with SMTP id m4-20020a17090679c400b00778e3e28311mr57786836ejo.342.1670267979453; Mon, 05 Dec 2022 11:19:39 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id t16-20020aa7db10000000b0045cf4f72b04sm112739eds.94.2022.12.05.11.19.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 11:19:39 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH v6 2/5] hwmon: (pmbus/core): Notify hwmon events Date: Mon, 5 Dec 2022 20:19:13 +0100 Message-Id: <20221205191917.2614603-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> References: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Notify hwmon events using the pmbus irq handler. Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 95 ++++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 244fd2597252..b005a1c8ad7e 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2781,18 +2781,43 @@ static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] = }, }; -static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags) +#define to_dev_attr(_dev_attr) \ + container_of(_dev_attr, struct device_attribute, attr) + +static void pmbus_notify(struct pmbus_data *data, int page, int reg, int flags) +{ + int i; + + for (i = 0; i < data->num_attributes; i++) { + struct device_attribute *da = to_dev_attr(data->group.attrs[i]); + struct sensor_device_attribute *attr = to_sensor_dev_attr(da); + int index = attr->index; + u16 smask = pb_index_to_mask(index); + u8 spage = pb_index_to_page(index); + u16 sreg = pb_index_to_reg(index); + + if (reg == sreg && page == spage && (smask & flags)) { + dev_dbg(data->dev, "sysfs notify: %s", da->attr.name); + sysfs_notify(&data->dev->kobj, NULL, da->attr.name); + kobject_uevent(&data->dev->kobj, KOBJ_CHANGE); + flags &= ~smask; + } + + if (!flags) + break; + } +} + +static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error, + bool notify) { - int i, status; const struct pmbus_regulator_status_category *cat; const struct pmbus_regulator_status_assoc *bit; - struct device *dev = rdev_get_dev(rdev); - struct i2c_client *client = to_i2c_client(dev->parent); - struct pmbus_data *data = i2c_get_clientdata(client); - u8 page = rdev_get_id(rdev); + struct i2c_client *client = to_i2c_client(data->dev); int func = data->info->func[page]; + int i, status, ret; - *flags = 0; + *error = 0; mutex_lock(&data->update_lock); @@ -2803,14 +2828,17 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned status = _pmbus_read_byte_data(client, page, cat->reg); if (status < 0) { - mutex_unlock(&data->update_lock); - return status; + ret = status; + goto unlock; } for (bit = cat->bits; bit->pflag; bit++) { if (status & bit->pflag) - *flags |= bit->rflag; + *error |= bit->rflag; } + + if (notify && status) + pmbus_notify(data, page, cat->reg, status); } /* @@ -2823,36 +2851,53 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned * REGULATOR_ERROR__WARN. */ status = pmbus_get_status(client, page, PMBUS_STATUS_WORD); - mutex_unlock(&data->update_lock); - if (status < 0) - return status; - if (pmbus_regulator_is_enabled(rdev)) { + if (status < 0) { + ret = status; + goto unlock; + } + + ret = _pmbus_read_byte_data(client, page, PMBUS_OPERATION); + if (ret < 0) + goto unlock; + + if (ret & PB_OPERATION_CONTROL_ON) { if (status & PB_STATUS_OFF) - *flags |= REGULATOR_ERROR_FAIL; + *error |= REGULATOR_ERROR_FAIL; if (status & PB_STATUS_POWER_GOOD_N) - *flags |= REGULATOR_ERROR_REGULATION_OUT; + *error |= REGULATOR_ERROR_REGULATION_OUT; } /* * Unlike most other status bits, PB_STATUS_{IOUT_OC,VOUT_OV} are * defined strictly as fault indicators (not warnings). */ if (status & PB_STATUS_IOUT_OC) - *flags |= REGULATOR_ERROR_OVER_CURRENT; + *error |= REGULATOR_ERROR_OVER_CURRENT; if (status & PB_STATUS_VOUT_OV) - *flags |= REGULATOR_ERROR_REGULATION_OUT; + *error |= REGULATOR_ERROR_REGULATION_OUT; /* * If we haven't discovered any thermal faults or warnings via * PMBUS_STATUS_TEMPERATURE, map PB_STATUS_TEMPERATURE to a warning as * a (conservative) best-effort interpretation. */ - if (!(*flags & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) && + if (!(*error & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) && (status & PB_STATUS_TEMPERATURE)) - *flags |= REGULATOR_ERROR_OVER_TEMP_WARN; + *error |= REGULATOR_ERROR_OVER_TEMP_WARN; - return 0; +unlock: + mutex_unlock(&data->update_lock); + return ret; +} + +static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned int *flags) +{ + struct device *dev = rdev_get_dev(rdev); + struct i2c_client *client = to_i2c_client(dev->parent); + struct pmbus_data *data = i2c_get_clientdata(client); + + return pmbus_get_flags(data, rdev_get_id(rdev), flags, false); } static int pmbus_regulator_get_status(struct regulator_dev *rdev) @@ -3082,10 +3127,14 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) { struct pmbus_data *data = pdata; struct i2c_client *client = to_i2c_client(data->dev); - int i, status; + int i, status, ret; for (i = 0; i < data->info->pages; i++) { + ret = pmbus_get_flags(data, i, &status, true); + if (ret) + return ret; + mutex_lock(&data->update_lock); status = pmbus_read_status_word(client, i); if (status < 0) { @@ -3099,7 +3148,7 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) mutex_unlock(&data->update_lock); } - return IRQ_HANDLED; + return ret; } static int pmbus_irq_setup(struct i2c_client *client, struct pmbus_data *data) From patchwork Mon Dec 5 19:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13065019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 145DAC47089 for ; Mon, 5 Dec 2022 19:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233552AbiLETYx (ORCPT ); Mon, 5 Dec 2022 14:24:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233863AbiLETYX (ORCPT ); Mon, 5 Dec 2022 14:24:23 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AA8027CCE for ; Mon, 5 Dec 2022 11:19:43 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id bj12so820861ejb.13 for ; Mon, 05 Dec 2022 11:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; 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=DPKbqc0ak5V4UJgzOj7j3ooXS6vGnBnkbq2OKYA/WT4=; b=DIi5u4t6g9JgH5XoC4drvV8Izbr9aVvc4hCrSjc3S11Chs7ShVAECZJ3qrDFTtPPgm lahrxw56tiHndSBVtvsjtLuoMulsicVgzsL8jREK7k9JDx2V4JG33oiU1ofiL/UP2LEz hi8RWX4EN7Zn3KtA96dd+6jOVMPvCmKiwDTyQBGhkdK1sm2it8wjSaCxnS7vRe7t51dK dqUj0HCRP8J6NUaCfEPORe+xiEAOVaCXBISAQVZnO8Y6SZHfGQdESr9mhtEUWC5N3J+d CZuX/KprWZPIw1p9v0BDB+dS05zvKq5BDw002KAPZCM1EbyexUSmnAfpxFuLdC917PoG KC4A== 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=DPKbqc0ak5V4UJgzOj7j3ooXS6vGnBnkbq2OKYA/WT4=; b=5kuWGQEcpclIzp5eCbxv3vHX1haY0l+MlBKlEEnUFedcXWosZfCH1fUfriLi0mx0kh qT7BKnJmVGlHkIp2E0E14LVnYy7wRsJ6OER9wcePkYyA/FYIcBLDjSNdRXj/pD7oa2d0 7wd+4qtTz+FewcWEsKp8X9Un0LU7OgoOxrqL2g5r/uWT2WMtvIL5Ty6an7RAygDlAavE tNAwrgj+SGNXjr72mQ6vsgwiJypIGaZeK0zgpAC0wMw4a9BSWZHsPpSfwtQHCPsKQZnU /+j8RmSNSUUYp8usFVjJr2YL3Vd63nJ20HuKX5jQfnu8WQdD6malDHeLPKQDSwpuWRO9 vVfg== X-Gm-Message-State: ANoB5pnEtYc8G6J6ZeLMhj5xMXkyp25pQE+wfHyWPhGEEvqRxf/JDS/1 i1sIF+yeh7xQC6zYqD6BLNy55sqQhQ5YFnv+qy4= X-Google-Smtp-Source: AA0mqf7u7VnY3Ni45y0AxJmuFN08d/uOHDX0qADbA2dYsG9Zjl6nCXFSiG0DUzYmpaNDKZK/7vTPJQ== X-Received: by 2002:a17:906:7852:b0:7b7:718d:22c with SMTP id p18-20020a170906785200b007b7718d022cmr56888823ejm.507.1670267982697; Mon, 05 Dec 2022 11:19:42 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id t16-20020aa7db10000000b0045cf4f72b04sm112739eds.94.2022.12.05.11.19.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 11:19:42 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH v6 3/5] hwmon: (pmbus/core): Add rdev in pmbus_data struct Date: Mon, 5 Dec 2022 20:19:14 +0100 Message-Id: <20221205191917.2614603-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> References: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add regulator device in pmbus_data & initialize the same during PMBus regulator register. Signed-off-by: Naresh Solanki --- Change in V5: - Fix error check for rdev --- drivers/hwmon/pmbus/pmbus_core.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index b005a1c8ad7e..afd98e639b4f 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -81,6 +81,7 @@ struct pmbus_label { struct pmbus_data { struct device *dev; struct device *hwmon_dev; + struct regulator_dev **rdevs; u32 flags; /* from platform data */ @@ -3095,9 +3096,13 @@ static int pmbus_regulator_register(struct pmbus_data *data) struct device *dev = data->dev; const struct pmbus_driver_info *info = data->info; const struct pmbus_platform_data *pdata = dev_get_platdata(dev); - struct regulator_dev *rdev; int i; + data->rdevs = devm_kzalloc(dev, sizeof(struct regulator_dev *) * info->num_regulators, + GFP_KERNEL); + if (!data->rdevs) + return -ENOMEM; + for (i = 0; i < info->num_regulators; i++) { struct regulator_config config = { }; @@ -3107,10 +3112,10 @@ static int pmbus_regulator_register(struct pmbus_data *data) if (pdata && pdata->reg_init_data) config.init_data = &pdata->reg_init_data[i]; - rdev = devm_regulator_register(dev, &info->reg_desc[i], + data->rdevs[i] = devm_regulator_register(dev, &info->reg_desc[i], &config); - if (IS_ERR(rdev)) - return dev_err_probe(dev, PTR_ERR(rdev), + if (IS_ERR(data->rdevs[i])) + return dev_err_probe(dev, PTR_ERR(data->rdevs[i]), "Failed to register %s regulator\n", info->reg_desc[i].name); } From patchwork Mon Dec 5 19:19:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13065020 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F626C47089 for ; Mon, 5 Dec 2022 19:25:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233932AbiLETZS (ORCPT ); Mon, 5 Dec 2022 14:25:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233747AbiLETYj (ORCPT ); Mon, 5 Dec 2022 14:24:39 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 296ED2C11F for ; Mon, 5 Dec 2022 11:19:49 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id n20so1029409ejh.0 for ; Mon, 05 Dec 2022 11:19:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; 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=l4I7a1GqXJo8TnUT7+EadFpwe8WXb+46MsnUGIDBeH8=; b=TUHSjLLuGa7GOd7typuCY1RhKrIUaQfEqj18f9tSZ7+XQbIz8InRJHdukCEF/cM/Xl YXLyJQPhLeUO2flF9tkHV5ckCe9wM8Cn7x48KV7LxoDoIybO28Px09NJ4oVNZwHVk4Tq JI+ztfBKvYowCqm8KyLfHpqRBkQAn/3AfY8UkA3pVp49O1rxESbVjmo9rxTwv7ZrTNoZ a8m04+TrRPkABXlb3Rrow5jc1miDkgzcN/mowT4zqGFnGynWnsptW3IeR4t69Q/F56lH yOCpwvfdUA9dGOOzAreK6IPqIuVJyrf9cJhU3ucxXbdJRT9Mq2qwP0VAFsVAPsL0czoE XC+g== 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=l4I7a1GqXJo8TnUT7+EadFpwe8WXb+46MsnUGIDBeH8=; b=ZNk1QrNwcrjNcYNMNlNTK8/DHfa6PCF6J7KD3MOvfxCtvjCcro7Kk6YHC/tLpL+hXe WUN12XYY6VAI0R1SVBBQR3tfI6s/Tlyc9MFDch9w4Eqzw296ihs+y6dG0uBJ4Yas4OzS /QJb8sVHgPWJ9yDAiWCwqgH3eJgDg764bwLPZgCGfWEHzUfjWcX7FUEzdMTP5jOGG7iy e2d61q4tmDWCIwiTmC5HEBrJ5QQSfmE/o4fgBe8wOmDk8W3lSOdei3a3G49zmHi9BLgq /2A3dLhbjrvlGry0MC1MWnmb7dSKYu3BMVJJ/dI7bRXHf5uNHvSH89NuNA7LN7+U+aSC G2Ww== X-Gm-Message-State: ANoB5pkiXJ3eJk++ptCP3TN2R0/3cv9vXpRBFYn2L2NSEnlV7MlnQFYq nCBuAN19eZvEFl0/jpdiElx9+i57zSP8gSH6uIE= X-Google-Smtp-Source: AA0mqf4YuOPV4uAnSrfJjttM6ekc9EDG8jik0lDo5HNJq+Nu9RD3A1iMchlIad6bOo+jYRvG9oAVSA== X-Received: by 2002:a17:906:5a94:b0:7bc:34d3:31fe with SMTP id l20-20020a1709065a9400b007bc34d331femr43514132ejq.427.1670267987737; Mon, 05 Dec 2022 11:19:47 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id t16-20020aa7db10000000b0045cf4f72b04sm112739eds.94.2022.12.05.11.19.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 11:19:47 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH v6 4/5] hwmon: (pmbus/core): Add regulator event support Date: Mon, 5 Dec 2022 20:19:15 +0100 Message-Id: <20221205191917.2614603-4-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> References: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Patrick Rudolph Add regulator events corresponding to regulator error in regulator flag map. Also capture the same in pmbus_regulator_get_flags. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 69 +++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index afd98e639b4f..22176f266891 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2739,9 +2739,9 @@ static int pmbus_regulator_disable(struct regulator_dev *rdev) return _pmbus_regulator_on_off(rdev, 0); } -/* A PMBus status flag and the corresponding REGULATOR_ERROR_* flag */ +/* A PMBus status flag and the corresponding REGULATOR_ERROR_* and REGULATOR_EVENTS_* flag */ struct pmbus_regulator_status_assoc { - int pflag, rflag; + int pflag, rflag, eflag; }; /* PMBus->regulator bit mappings for a PMBus status register */ @@ -2756,27 +2756,36 @@ static const struct pmbus_regulator_status_category pmbus_regulator_flag_map[] = .func = PMBUS_HAVE_STATUS_VOUT, .reg = PMBUS_STATUS_VOUT, .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN }, - { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE }, - { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT }, + { PB_VOLTAGE_UV_WARNING, REGULATOR_ERROR_UNDER_VOLTAGE_WARN, + REGULATOR_EVENT_UNDER_VOLTAGE_WARN }, + { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE, + REGULATOR_EVENT_UNDER_VOLTAGE }, + { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_REGULATION_OUT, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, { }, }, }, { .func = PMBUS_HAVE_STATUS_IOUT, .reg = PMBUS_STATUS_IOUT, .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN }, - { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT }, - { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT }, + { PB_IOUT_OC_WARNING, REGULATOR_ERROR_OVER_CURRENT_WARN, + REGULATOR_EVENT_OVER_CURRENT_WARN }, + { PB_IOUT_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, + { PB_IOUT_OC_LV_FAULT, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_TEMP, .reg = PMBUS_STATUS_TEMPERATURE, .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN }, - { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP }, + { PB_TEMP_OT_WARNING, REGULATOR_ERROR_OVER_TEMP_WARN, + REGULATOR_EVENT_OVER_TEMP_WARN }, + { PB_TEMP_OT_FAULT, REGULATOR_ERROR_OVER_TEMP, + REGULATOR_EVENT_OVER_TEMP }, { }, }, }, @@ -2810,7 +2819,7 @@ static void pmbus_notify(struct pmbus_data *data, int page, int reg, int flags) } static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error, - bool notify) + unsigned int *event, bool notify) { const struct pmbus_regulator_status_category *cat; const struct pmbus_regulator_status_assoc *bit; @@ -2819,6 +2828,7 @@ static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error int i, status, ret; *error = 0; + *event = 0; mutex_lock(&data->update_lock); @@ -2833,10 +2843,11 @@ static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error goto unlock; } - for (bit = cat->bits; bit->pflag; bit++) { - if (status & bit->pflag) + for (bit = cat->bits; bit->pflag; bit++) + if (status & bit->pflag) { *error |= bit->rflag; - } + *event |= bit->eflag; + } if (notify && status) pmbus_notify(data, page, cat->reg, status); @@ -2863,20 +2874,28 @@ static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error goto unlock; if (ret & PB_OPERATION_CONTROL_ON) { - if (status & PB_STATUS_OFF) + if (status & PB_STATUS_OFF) { *error |= REGULATOR_ERROR_FAIL; + *event |= REGULATOR_EVENT_FAIL; + } - if (status & PB_STATUS_POWER_GOOD_N) + if (status & PB_STATUS_POWER_GOOD_N) { *error |= REGULATOR_ERROR_REGULATION_OUT; + *event |= REGULATOR_EVENT_REGULATION_OUT; + } } /* * Unlike most other status bits, PB_STATUS_{IOUT_OC,VOUT_OV} are * defined strictly as fault indicators (not warnings). */ - if (status & PB_STATUS_IOUT_OC) + if (status & PB_STATUS_IOUT_OC) { *error |= REGULATOR_ERROR_OVER_CURRENT; - if (status & PB_STATUS_VOUT_OV) + *event |= REGULATOR_EVENT_OVER_CURRENT; + } + if (status & PB_STATUS_VOUT_OV) { *error |= REGULATOR_ERROR_REGULATION_OUT; + *event |= REGULATOR_EVENT_FAIL; + } /* * If we haven't discovered any thermal faults or warnings via @@ -2884,8 +2903,10 @@ static int pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *error * a (conservative) best-effort interpretation. */ if (!(*error & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) && - (status & PB_STATUS_TEMPERATURE)) + (status & PB_STATUS_TEMPERATURE)) { *error |= REGULATOR_ERROR_OVER_TEMP_WARN; + *event |= REGULATOR_EVENT_OVER_TEMP_WARN; + } unlock: mutex_unlock(&data->update_lock); @@ -2897,8 +2918,9 @@ static int pmbus_regulator_get_error_flags(struct regulator_dev *rdev, unsigned struct device *dev = rdev_get_dev(rdev); struct i2c_client *client = to_i2c_client(dev->parent); struct pmbus_data *data = i2c_get_clientdata(client); + int event; - return pmbus_get_flags(data, rdev_get_id(rdev), flags, false); + return pmbus_get_flags(data, rdev_get_id(rdev), flags, &event, false); } static int pmbus_regulator_get_status(struct regulator_dev *rdev) @@ -3132,11 +3154,12 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) { struct pmbus_data *data = pdata; struct i2c_client *client = to_i2c_client(data->dev); - int i, status, ret; + int i, status, ret, event; for (i = 0; i < data->info->pages; i++) { - ret = pmbus_get_flags(data, i, &status, true); + ret = pmbus_get_flags(data, i, &status, &event, true); + if (ret) return ret; From patchwork Mon Dec 5 19:19:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13065021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DF5DC4321E for ; Mon, 5 Dec 2022 19:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233785AbiLETZU (ORCPT ); Mon, 5 Dec 2022 14:25:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233781AbiLETYl (ORCPT ); Mon, 5 Dec 2022 14:24:41 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C2CD25C5D for ; Mon, 5 Dec 2022 11:19:50 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id bj12so821649ejb.13 for ; Mon, 05 Dec 2022 11:19:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; 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=YmisXUUTcc/2wLYtw2JwGMf2iLn2WSeYXglBIEeZoho=; b=Y4YvMsNmXqwQtQ6fylpBqSvy3d7S0QQKyzC+msMpaJ9yJ2fXrCtlT8C6h1WiGav9r4 TDZ3jUw0Gsmhvma6muAvIM/saALuR5+52UawobQWBDvSS5Ew2WxebwU/YuO/PrsvpTMk gfwlDJ0LQvEQkbTqdoiWwQUHgkra8WZWKwtSKF9bYjQNUshjJi73kqWZFv4Nz/hmJrz2 98myjXjxobhazglF9IJyWQlrhaaZpKQZ75vM0vyHYpdAAAEUdsmMn7UI7BMRAGFewOtk TiRCnmEHDvo5dJ6kMIdW6pELmO5XoPZeiaCy0qVeG2Kr+Myn85Fm7lK7tBGphWc17N8v DdJw== 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=YmisXUUTcc/2wLYtw2JwGMf2iLn2WSeYXglBIEeZoho=; b=UdXKU3duHwWsGuTzxNEM42bXDNOGWq77PrIqTHdWQdI2v44JL5JHHUE4EGjrH/dHFN SOy+0wTVHTqiKdd3CsqKsUakxxvqJBQHbj0uooXIrDYEE8WIse/OPfUPtRaC0lCnCpDj 8TQKNfetI/NcoGHAAefJoLqSZ4jE/0iwrSymOAMmQlo+xgabTpM8prUd8srsDBisjvcv jxo+S8ZIN2jYZn96L+1Ad0DVnaSsy8g/L5V6TA4rRYlKvbttDcNKPQ0UugIU/brvZJvA /J4GeHcCZdb5gvZswwWyB68Nyo64NJQtjd1azhI3gWJcRI8LnxHjpnpYdfkU8CvmAm58 HV3A== X-Gm-Message-State: ANoB5plEJ7q9ImAvT3I6Xvb8+eW5wf4V6EOSmPyFuDoq7ZSbXOxjBnOt LCZGHEzdtWSe2jLEOu/I/xojuw== X-Google-Smtp-Source: AA0mqf62EG0f6npo76wD2RQldxw2ZuSO3bPY8/OKQ9K9hhSaGTbejpbzJ3Z1YlSk4OWCtLd/Gmdfpg== X-Received: by 2002:a17:906:5156:b0:7c0:efb6:8744 with SMTP id jr22-20020a170906515600b007c0efb68744mr5950005ejc.267.1670267990223; Mon, 05 Dec 2022 11:19:50 -0800 (PST) Received: from stroh80.sec.9e.network (ip-078-094-000-051.um19.pools.vodafone-ip.de. [78.94.0.51]) by smtp.gmail.com with ESMTPSA id t16-20020aa7db10000000b0045cf4f72b04sm112739eds.94.2022.12.05.11.19.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Dec 2022 11:19:50 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: devicetree@vger.kernel.org, Guenter Roeck , Jean Delvare , Liam Girdwood , Mark Brown Cc: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, Patrick Rudolph , Naresh Solanki Subject: [PATCH v6 5/5] hwmon: (pmbus/core): Notify regulator events Date: Mon, 5 Dec 2022 20:19:16 +0100 Message-Id: <20221205191917.2614603-5-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> References: <20221205191917.2614603-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Notify regulator events in PMBus irq handler. Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 22176f266891..c8fae2a9502d 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3154,7 +3154,7 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) { struct pmbus_data *data = pdata; struct i2c_client *client = to_i2c_client(data->dev); - int i, status, ret, event; + int i, j, status, ret, event; for (i = 0; i < data->info->pages; i++) { @@ -3163,6 +3163,15 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) if (ret) return ret; + if (event) { + for (j = 0; j < data->info->num_regulators; j++) { + if (i == rdev_get_id(data->rdevs[i])) { + regulator_notifier_call_chain(data->rdevs[i], event, NULL); + ret = IRQ_HANDLED; + } + } + } + mutex_lock(&data->update_lock); status = pmbus_read_status_word(client, i); if (status < 0) {