From patchwork Wed Dec 14 08:07:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13072847 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 A8B55C10F31 for ; Wed, 14 Dec 2022 08:07:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237618AbiLNIHa (ORCPT ); Wed, 14 Dec 2022 03:07:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237525AbiLNIHY (ORCPT ); Wed, 14 Dec 2022 03:07:24 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8A2F1EC5A for ; Wed, 14 Dec 2022 00:07:23 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id h12so18392946wrv.10 for ; Wed, 14 Dec 2022 00:07:23 -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=lrvSScxuHlRI0bKk77hVXZre2a8Ky0+wyi62OkXbDKg=; b=NDgGwNsaUJ1PgX9iay1BXJXgXFINWdGVempBeKoivktTCLLoAyuyVtxpvX2J0aEEIz LZniGOWVou+nmDF33yOkNHFq2rvq2EfxY89n3hbbHOsayoBVyM9xUt93O1tzzyjifQpU tFgWks5akwxcLUtDpk0PxE5Ap95o+oNoDYNNh7P59OfqJk0/6OjjHRmzOUOki579kHG4 U84tPO3Hgd31UwCSw5zpCuPOFzGACnJ7JVhsuxIovIMIsvsa37lgx93go9AORv8ukVTn fJ/ltGXJL7Y3QxmhpAdAFAdIlv+kRKYFxPGYRhr5SmvD6QW/NjFaBc6dP/efe72EOkZc /GXA== 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=lrvSScxuHlRI0bKk77hVXZre2a8Ky0+wyi62OkXbDKg=; b=K7JuTyGOoef2zdJXRC+KogsS5wFR1pwQfAsFUfWTInjDnOO7UduQSr5zGVsFq3qKb/ pAbO10EZKdpzaJm4Pb32/HBn+jQSUZoG4LgKyzAHp99Kyf5jsW0gFuk/YmUUcWPk3s8J /02ibsn+bMLfycdUiG4YWHbJTV+C4LKmoCVz1BtHJ6DQkQ0a1S70U/mA4UvNpajUfxxp cHMDxf4fM/K17/Ksvv5E39IEN3A0zsIeJe166gDSywCPje/JEc2ARiGYjJmrFKf7Lsxy SAss7F1N3Gqd+ruYKAIjLtc2xViTBeUUzm552pc+I1q/AAiKGBYytOfcB8hKlwsmfMx/ mGiw== X-Gm-Message-State: ANoB5pnWzUjaOrZP+4g71nWpuyZKZH/Qp4r9FdBqe/IryT18v6yix9FZ gexpxlB9JCkmCexf5dTQtQzPfg== X-Google-Smtp-Source: AA0mqf7F5kkzGdyraNSIkLcf4H2A59Fu/xayosTBykCCAFHTuDuRhWcgNbUhemuzvIJ7gj+rGaxcNQ== X-Received: by 2002:adf:fb4f:0:b0:236:621a:984c with SMTP id c15-20020adffb4f000000b00236621a984cmr14148584wrs.36.1671005242159; Wed, 14 Dec 2022 00:07:22 -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 k3-20020a5d5183000000b002422bc69111sm2500781wrv.9.2022.12.14.00.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:07:21 -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 RESEND v6 1/5] hwmon: (pmbus/core): Add interrupt support Date: Wed, 14 Dec 2022 09:07:11 +0100 Message-Id: <20221214080715.2700442-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: 364ffd2537c44cb6914ff5669153f4a86fffad29 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 Wed Dec 14 08:07: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: 13072848 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 EA760C2D0CB for ; Wed, 14 Dec 2022 08:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237621AbiLNIHb (ORCPT ); Wed, 14 Dec 2022 03:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237543AbiLNIHZ (ORCPT ); Wed, 14 Dec 2022 03:07:25 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2261EC79 for ; Wed, 14 Dec 2022 00:07:24 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id f18so18416072wrj.5 for ; Wed, 14 Dec 2022 00:07:24 -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=I7Tlplv0te9iHlBXHdq2mbDLsr157BzIU5BI9+6K31yXeihg+x0paGoP8mw+h74MGe BD3ymOvEKHI3dHriPIrtpruJMSPjn2Thb/LQuIDnWFQq9x9act5RGCFDquo4vIxGzVkU tOvFxfeZW/S5oBz1vmmegbN80P6Ai4faqxnUQdxo/a29fF0TE5mZDCywmzglvkB/vKYR RVHx7EnlylviydZyaXgaot9DYMqj26wKTAqEQ+JKsV3hbPUAM/MYyhIDRmuXc/Iu1YEk 2zUhS4s+vSMX+ohSeZKkB1TMDLSKydMQwx3EE5lDXJkiCX7X7dg2mdoZo90W2k9QtT09 fm8g== 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=rqfIVcTsA8DeryrCdsHpu/MUOTCfV6wGGy+xU7x8Zi6adVTqotmPmj0518h4ABd0bG S5PeWSZX84pFAh0J96ZoglEGZ+i69Be9mM/QDZz/Tho9GlQySVm3D8FKvvaqdXu+hWZ5 WqcXFZvTD+S5uMHk0o4nSm6NKPrBCmpETkf5+LfNQfSzhoIFcKg6uVh0VJ3Nz1bv/yy8 NyoPqCDaHymMCxbH69QnAGDR4NGSlfjubOma1hYHuor5pqSmLYAZwk52Dywc616g3fOs K1JT0AVtS9nmwpSGCJNo8BzFbEB+w6ipW0cezoU2Ks+eJFugUh9uGK4qUSbwoV1BaFl0 IXhA== X-Gm-Message-State: ANoB5pm+qCGgMm3PI9gvxLElBznp6timhAFfy0Vz81D49n9cUh8c3nDA PDAe38UxDoIXpXuysgZz8DW7GQ== X-Google-Smtp-Source: AA0mqf5xkcG/ckjidbvtP3sok0tmOJuJv35TW1zAAF1ufCiUV8homfA/rQ8mOFm8ywCeAqhZLY+2IA== X-Received: by 2002:a5d:64c5:0:b0:242:1748:130e with SMTP id f5-20020a5d64c5000000b002421748130emr20005159wri.31.1671005243234; Wed, 14 Dec 2022 00:07:23 -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 k3-20020a5d5183000000b002422bc69111sm2500781wrv.9.2022.12.14.00.07.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:07:22 -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 RESEND v6 2/5] hwmon: (pmbus/core): Notify hwmon events Date: Wed, 14 Dec 2022 09:07:12 +0100 Message-Id: <20221214080715.2700442-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221214080715.2700442-1-Naresh.Solanki@9elements.com> References: <20221214080715.2700442-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 Wed Dec 14 08:07: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: 13072849 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 39395C4332F for ; Wed, 14 Dec 2022 08:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237631AbiLNIHc (ORCPT ); Wed, 14 Dec 2022 03:07:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237592AbiLNIH0 (ORCPT ); Wed, 14 Dec 2022 03:07:26 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B3ED1EEC7 for ; Wed, 14 Dec 2022 00:07:25 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id h12so18393017wrv.10 for ; Wed, 14 Dec 2022 00:07:25 -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=GKMFGf7uTwbrGxI72tbBYjGVoIHtTjvHBLWSUmjOvGwhKnjG1sd1NNkSsecFPljB5r lg4ycYrz/8FSi/Ai9o9t2R5Bm26ByJEKc2jeKMSywKSSMzsocU8Rmx18GjSXxnxofumH pV1u8y2fyS6V3BIYWr3Kej7OcY67raaFmiuwQN0IymI8mIWzsZRGTTOsWplLnu6mZXN4 HQAyAQa3zUFAoN9rnDDjdfKxmRxfSBJc9+EZkzdbubpCPbrh84SXui/oRRJc2XXcdEic gd/VnYDd8PoaypUf8V134FPEvEf/KbMTmLoJ/BeR+5GJdO2B3ZeaYOsaH/qTUAlwkSMn 1krw== 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=278kecE5Do9YG8EGFV7lp/6MaYQy0MbBJNocA3CiBThQek/WrGY9i3xXP65DukchgH 8XHNyIiH8QxN3U4dFhp57qLnVYuhL+4d7mBCLxVhFKAt4yQ1hXs+1qSZ2BJnN6w5SVdS Y0EPguswOqUNBzNWcmmajHF+FUCptrxNsKt6f8xCcD+NsguQG7TFTrcdBIwqf+OENVdo 5+vn9Ep3jiwocv0+Q243j5C98wOy67Bk+VNY7OeXSG5SwqE8aN8zsBxfEgP1pCHBuSQS PnuDVbyC2YYn8wg0Qj1Jv+h1qQB31JUJl0W6HLMCVF3DBQB3MSCOnYcx1Iqe2Lg3WBr4 fFPA== X-Gm-Message-State: ANoB5pnxuAIe2TTza1mr6OKCINNjXw0IQTvyAAA8xF5ESEVGNZ0qE7yU UBs+03LBWokP7CW/KqrKPzSW3g== X-Google-Smtp-Source: AA0mqf7UtxNoaFBj73SD2lWLqolQ01D/5JfjnxsBZ67/H+DBrzDzvRHvJdoB1ZaFnM4TSoqX4AJJAA== X-Received: by 2002:adf:fc8a:0:b0:242:14bb:439d with SMTP id g10-20020adffc8a000000b0024214bb439dmr13317808wrr.43.1671005244192; Wed, 14 Dec 2022 00:07:24 -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 k3-20020a5d5183000000b002422bc69111sm2500781wrv.9.2022.12.14.00.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:07:23 -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 RESEND v6 3/5] hwmon: (pmbus/core): Add rdev in pmbus_data struct Date: Wed, 14 Dec 2022 09:07:13 +0100 Message-Id: <20221214080715.2700442-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221214080715.2700442-1-Naresh.Solanki@9elements.com> References: <20221214080715.2700442-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 Wed Dec 14 08:07: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: 13072850 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 98C72C4167B for ; Wed, 14 Dec 2022 08:07:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230088AbiLNIHd (ORCPT ); Wed, 14 Dec 2022 03:07:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237594AbiLNIH1 (ORCPT ); Wed, 14 Dec 2022 03:07:27 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C084C1EAC1 for ; Wed, 14 Dec 2022 00:07:26 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id m14so18410392wrh.7 for ; Wed, 14 Dec 2022 00:07:26 -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=d2f4tYg1ydCRNbpi9K6fJxUJaAagYBs6CBH5ii7Q0/v2HdNvZpwDB855rUnYjzK10U YwmsQlUPlu1Olq1oOtaVCcDvbTb8nZ885T6wBxYNNkEVa+mmbJbVjNSrgU7v6ozMJ4V6 bAVvbrX4v3UfVodsuFmwQQSqpk4kxRIPPrrsDXEjdxTpDAdlbpyCQACzkAzxh3EVK+Lk OLEpHKKtf7gVH4x1wJefIITrI4nRd3cqu0dxHFw8GnNPQkwAkGVfACcn8DeKAUQ9zWaw XN7wMv0SNnCm+yBKLcSulbHMPq94eIduM6GZTp+SquA8ymOyU3VK/aD/T+iq7v/+MJQn 6N0A== 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=mIskQJ3lkiou6x0ozRb0Mk0SJU1LYU/pY0pn7800wHxI1bm/q3B17gbukrjqNFV7tc K76L/7G2pB44bgLCb2MyQornS/CA95kYuFBXv5Xq1wmdhSp79JkEWyyHKiU1UJs193Dq gnI6GPWsQNS6yFT6+sjzEPsXrkgw32lO7qmEVxMSPOkxR9mkmF6G10RrNxa+Nx49oZTP 0z7WjXWV8yb/v7zBPKAW0aUDjE+IXIvDnLSYNN4tpvhTb0NPRy24YGI3AiJz8aeUjIKH EgiC2pALNOzYk/JEuLm3uu4ww2dDjK6wUK76Jarv1iRywmIsvK/bpzC0p99j00FPMDSP H/1A== X-Gm-Message-State: ANoB5pmGz/nMnGOxFGCdbozEJn73GZY7tE8weeU5H54Gnghhb0M9DQPf jpDQ2FNlC1HTk6N+f6PSKwEznA== X-Google-Smtp-Source: AA0mqf4i2Wp0c4O1BDXbnj48O3MA/p8zT40OJQ4M1iD62kmrP0BhY3mQp8xAKtc2Nh7HVmES/ORD1w== X-Received: by 2002:adf:fd0e:0:b0:242:1926:783d with SMTP id e14-20020adffd0e000000b002421926783dmr18661142wrr.7.1671005245266; Wed, 14 Dec 2022 00:07:25 -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 k3-20020a5d5183000000b002422bc69111sm2500781wrv.9.2022.12.14.00.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:07:25 -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 RESEND v6 4/5] hwmon: (pmbus/core): Add regulator event support Date: Wed, 14 Dec 2022 09:07:14 +0100 Message-Id: <20221214080715.2700442-4-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221214080715.2700442-1-Naresh.Solanki@9elements.com> References: <20221214080715.2700442-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 Wed Dec 14 08:07: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: 13072851 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 34DACC3DA6D for ; Wed, 14 Dec 2022 08:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237543AbiLNIHt (ORCPT ); Wed, 14 Dec 2022 03:07:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237604AbiLNIH3 (ORCPT ); Wed, 14 Dec 2022 03:07:29 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B45DA1EC4E for ; Wed, 14 Dec 2022 00:07:27 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id w15so18399873wrl.9 for ; Wed, 14 Dec 2022 00:07:27 -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=M8/xtqY2O3i3K2Yz6NqK5+aza3ypoIX9p/uaSSc4ZVwUCb2XQrkVHtxv0yjcN/kSiB SGrwjRxkjHrn4YoUiOL3CBahkHHkRXa5uywll9J70oIMl45KBCMDE7FLt4JI243Fg4ja K8iOUVGS5VrRSnXxN4xPHIIdPEAnOQGQPQb+hxvJeH3FWJUbZy19/E4ZwH3b1a/b2bpA nR/JTjWlp8NuTdqnNYny0Lk10aey91oh75kRrEB0cRD/TfNF+q3o5dhKT5Sm5FlU0XwX E6ioTc5CGAovSvL4kZfhRj9MsJ54hdrA/CnUmttLwo8v53mBwMIh1Utm8tOfM7KbqCcJ NIUQ== 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=x/RlibJc72qQCTNo37vLLD6wiDpID/JEh6hdeox96RzbMZEDPBMfHU1eMEtwSSWanq CLBNhczSL2ibP5tkkZb2Y0HEaY8skMFKJ2YKLQANmbwEWu3m6o9aRJ+7JJeasybGpk5r z21Pu/LzHbUTvz6LGgzK6EE8e5/bUUItcmYaE48l9EAr0dU6XdZLm6S59Bhc7deRkDel D5gWXwFM8Ng4sME18TNcGo6LanJBgJ9LjihCaYsy4Ouw+HqLfjhrai+cIC+7X1hNFckC Rr87KtRLCq5aygaDydMhlKIQso4PkGEg7XAC8ED3xbdru6djiBDjJhHwwKjdXwOnk5w5 2puQ== X-Gm-Message-State: ANoB5pntnhVR2dRFqB1eaashcFv6rIFrQw12jh8LvCA1nan1ukXkERbZ gz6izaIFXNwLW+lpjMhaCcP14Q== X-Google-Smtp-Source: AA0mqf4Z8Akd3gcq3Hav9sh318ZeCAA5u0fwpbqKxLHue73ihu02VidHzoLUGXJ+rEEJnl57nImA3w== X-Received: by 2002:a05:6000:1290:b0:242:733b:af28 with SMTP id f16-20020a056000129000b00242733baf28mr17016908wrx.5.1671005246307; Wed, 14 Dec 2022 00:07:26 -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 k3-20020a5d5183000000b002422bc69111sm2500781wrv.9.2022.12.14.00.07.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 00:07:26 -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 RESEND v6 5/5] hwmon: (pmbus/core): Notify regulator events Date: Wed, 14 Dec 2022 09:07:15 +0100 Message-Id: <20221214080715.2700442-5-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221214080715.2700442-1-Naresh.Solanki@9elements.com> References: <20221214080715.2700442-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) {