From patchwork Tue Mar 28 12:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13190973 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 059F1C76195 for ; Tue, 28 Mar 2023 12:17:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229714AbjC1MRS (ORCPT ); Tue, 28 Mar 2023 08:17:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbjC1MRR (ORCPT ); Tue, 28 Mar 2023 08:17:17 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08DEA8A6A for ; Tue, 28 Mar 2023 05:17:16 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id l27so11980011wrb.2 for ; Tue, 28 Mar 2023 05:17:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680005834; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fpixAugXoZaAwUVYpLsM7+hqMka5O+Qfwz+XpgeRjTs=; b=DdfEr+id/MsD4EX/KXTGF7dom2NnWml6VBX2ms3hp9tl13YcQyka7TRbrQ8kgwm98+ n9dglToiVSIkx7BTzyKAtydVhxOlKocYd75G0KCdl4BpnEuQq7Eku0vu+onGqGsUarvI uDCxVMif68sVanItPLIYH9Xe6SkJzXfokDa8u7+2+gDNS6KvXXkd+KDmmUo+/r9yeDuu W1S1+uUTovHL7LdVpoa9S2fX3EkyLJl45TezoDDNzt2CcIAf37tNBmFPUGobldCUd1Gx qs5nvEkiuEJyJPcIOwKPJsQl/qcOiOMGm29n6E0Nmjm9EvgUM9Dw0/L/k93Bd3rfvpZH yPZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680005834; 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=fpixAugXoZaAwUVYpLsM7+hqMka5O+Qfwz+XpgeRjTs=; b=sUvtsK+d2WcMg6jcfmkxxJhmbHGqYsojWrBHmZJtWpol+wqEriAzSjpwbRdIbql/HN WUslfuAap6NrTd5/XkbGU2newNbeBYolgIK9NiauqnFSRf+BZgO2u3kQfbvtiosXoc3D 1rPJJuyRHlknQ/qlfM1raRTeDFpicif26T4EyLhzYNJYnCFBJ/c9/s7+36WO+4jN3/DY wSW4VXatqA/odF9NCPXnwcXOjenGhllaK7BmOqO8f2K1A9L4nCZnGAjtJ7Db8V4t6pZT j2sb97hk+KrV7zbruKeo/hPsWQtbeDdbJLsOgcFV7fa0/hEx7E2J0NtZWfoXh6eK/K9O IQDw== X-Gm-Message-State: AAQBX9cj/i5ocHnriyXgmHCXeqXkdWby2ygnYEDV4ZmgLX+TNRZkkyo9 HYI2nIIzkSVxIluyrWEOQlNrCzrxGDVoc45PLL3lbg== X-Google-Smtp-Source: AKy350Z4U/haF9SCuRslvAh7oWJBrD/bo6ZTNjsaoe00bHp+ERY97BdOBWKdeYJ4z5nRervvH+cR3w== X-Received: by 2002:adf:f089:0:b0:2cf:e849:e13c with SMTP id n9-20020adff089000000b002cfe849e13cmr12706092wro.61.1680005834541; Tue, 28 Mar 2023 05:17:14 -0700 (PDT) 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 c9-20020a5d4cc9000000b002d21379bcabsm27503187wrt.110.2023.03.28.05.17.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 05:17:13 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] hwmon: (pmbus/core): Add rdev in pmbus_data struct Date: Tue, 28 Mar 2023 14:17:09 +0200 Message-Id: <20230328121712.4057359-1-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 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 --- drivers/hwmon/pmbus/pmbus_core.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) base-commit: 8a863eb1b1162653d133856702e13560f3596b85 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 0ddef2c9ba9b..d93405f1a495 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 */ @@ -3109,9 +3110,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 = { }; @@ -3121,10 +3126,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], - &config); - if (IS_ERR(rdev)) - return dev_err_probe(dev, PTR_ERR(rdev), + data->rdevs[i] = devm_regulator_register(dev, &info->reg_desc[i], + &config); + 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 Tue Mar 28 12:17:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13190974 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 782A1C761A6 for ; Tue, 28 Mar 2023 12:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230363AbjC1MRU (ORCPT ); Tue, 28 Mar 2023 08:17:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbjC1MRS (ORCPT ); Tue, 28 Mar 2023 08:17:18 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 298F21AC for ; Tue, 28 Mar 2023 05:17:17 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id r29so11934621wra.13 for ; Tue, 28 Mar 2023 05:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680005835; 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=7ar4gShNRtAW6dNfXP+ZNQyd+zJtBTyR0FTUukIMwmo=; b=WidM/1dEJbFwPF3n7/GYqS0gjS/bW8qeyIzdoXnnOHbgQ3pfRJOJiYwLg65kuNOogI IvQlARmPpPDWa+EtRrdFnQTahNys8xfP0KNn4U8RxhmMpGxqN22QOONJb6a5IBGpU0RD 4LK86CxbsIHtupCkL0BLz4FRvCBeC7XCjhpunP/ai386TKuXK9dLN3o/Spy7ICCFQbgz Kd44bPu/VRdclviMr0Efw10sqQbjCsjgDEYaQCdIV1DhdBADF47OclZUyOWKDFoEvTx+ gf4pCmTNUM5mLpyRG3QDStrpMaaWD1D7HlZdDWwHnaW0onKxOj/cKGXveUGM9lsG8rHN s+HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680005835; 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=7ar4gShNRtAW6dNfXP+ZNQyd+zJtBTyR0FTUukIMwmo=; b=QDOZrvy1WIudlY8w6iDU0ZLoEsCwcdYJOPTRncoG+KaddVMMaCgryYLM3JYgYEFJjq vEwUua45ctjyqo3uNRtlIKtcA8f0Sj2JQno4Z/b86rxjNsaX/G28Ml0IhWPnd5L7bY0o 1qWzq6V7Ky/n4DIDRvGa06zcD+FukWg7uL+YInLbGv0iFEkBVr860EhEti1EII97z75h PZUNCP1fQAuDv8De375D9MPuGNrAtDIyLJBt/rQ5fHUtHf81tFVJIxAu0j3chWr99BWO CWNZGjJkCXVkEx46KQV072hXFnBDToDLFpyJZbX44oUhwTTEPNKw8O6yMpUC1YZbfY9x GfPg== X-Gm-Message-State: AAQBX9cWpM49YkElTlUEoaAFo9y3mPiJ7xmvgME8JI7EU8D0su+WTKMz UyAX4fg7nu6yfkiCI+guI/JtrPoaLUbAtfviAxSbMA== X-Google-Smtp-Source: AKy350YF6mE4g7+iUAzO8trcbKhWVc/4t9XbJ77QxcnxEfTQlduWIotXIg+ryx/5nGIGDLTu5c3BDA== X-Received: by 2002:a5d:6b83:0:b0:2d2:5971:68b0 with SMTP id n3-20020a5d6b83000000b002d2597168b0mr11853230wrx.22.1680005835537; Tue, 28 Mar 2023 05:17:15 -0700 (PDT) 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 c9-20020a5d4cc9000000b002d21379bcabsm27503187wrt.110.2023.03.28.05.17.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 05:17:15 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwmon: (pmbus/core): Add regulator event support Date: Tue, 28 Mar 2023 14:17:10 +0200 Message-Id: <20230328121712.4057359-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230328121712.4057359-1-Naresh.Solanki@9elements.com> References: <20230328121712.4057359-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 | 74 +++++++++++++++++++++----------- 1 file changed, 49 insertions(+), 25 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index d93405f1a495..18a3f3b1ec07 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2693,9 +2693,9 @@ static int pmbus_init_common(struct i2c_client *client, struct pmbus_data *data, return 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_status_assoc { - int pflag, rflag; + int pflag, rflag, eflag; }; /* PMBus->regulator bit mappings for a PMBus status register */ @@ -2710,27 +2710,36 @@ static const struct pmbus_status_category __maybe_unused pmbus_status_flag_map[] .func = PMBUS_HAVE_STATUS_VOUT, .reg = PMBUS_STATUS_VOUT, .bits = (const struct pmbus_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_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_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 }, { }, }, }, @@ -2790,7 +2799,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 *flags, - bool notify) + unsigned int *event, bool notify) { int i, status; const struct pmbus_status_category *cat; @@ -2800,6 +2809,7 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag int func = data->info->func[page]; *flags = 0; + *event = 0; for (i = 0; i < ARRAY_SIZE(pmbus_status_flag_map); i++) { cat = &pmbus_status_flag_map[i]; @@ -2810,10 +2820,11 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag if (status < 0) return status; - for (bit = cat->bits; bit->pflag; bit++) { - if (status & bit->pflag) + for (bit = cat->bits; bit->pflag; bit++) + if (status & bit->pflag) { *flags |= bit->rflag; - } + *event |= bit->eflag; + } if (notify && status) pmbus_notify(data, page, cat->reg, status); @@ -2834,20 +2845,28 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag return status; if (_pmbus_is_enabled(dev, page)) { - if (status & PB_STATUS_OFF) + if (status & PB_STATUS_OFF) { *flags |= REGULATOR_ERROR_FAIL; + *event |= REGULATOR_EVENT_FAIL; + } - if (status & PB_STATUS_POWER_GOOD_N) + if (status & PB_STATUS_POWER_GOOD_N) { *flags |= 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) { *flags |= REGULATOR_ERROR_OVER_CURRENT; - if (status & PB_STATUS_VOUT_OV) + *event |= REGULATOR_EVENT_OVER_CURRENT; + } + if (status & PB_STATUS_VOUT_OV) { *flags |= REGULATOR_ERROR_REGULATION_OUT; + *event |= REGULATOR_EVENT_FAIL; + } /* * If we haven't discovered any thermal faults or warnings via @@ -2855,8 +2874,11 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag * a (conservative) best-effort interpretation. */ if (!(*flags & (REGULATOR_ERROR_OVER_TEMP | REGULATOR_ERROR_OVER_TEMP_WARN)) && - (status & PB_STATUS_TEMPERATURE)) + (status & PB_STATUS_TEMPERATURE)) { *flags |= REGULATOR_ERROR_OVER_TEMP_WARN; + *event |= REGULATOR_EVENT_OVER_TEMP_WARN; + } + return 0; } @@ -2864,10 +2886,10 @@ static int _pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flag static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, bool notify) { - int ret; + int ret, event; mutex_lock(&data->update_lock); - ret = _pmbus_get_flags(data, page, flags, notify); + ret = _pmbus_get_flags(data, page, flags, &event, notify); mutex_unlock(&data->update_lock); return ret; @@ -2911,8 +2933,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) @@ -3152,10 +3175,11 @@ 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, event; mutex_lock(&data->update_lock); for (i = 0; i < data->info->pages; i++) - _pmbus_get_flags(data, i, &status, true); + _pmbus_get_flags(data, i, &status, &event, true); pmbus_clear_faults(client); mutex_unlock(&data->update_lock); From patchwork Tue Mar 28 12:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13190975 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 D9AC0C76196 for ; Tue, 28 Mar 2023 12:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229654AbjC1MRV (ORCPT ); Tue, 28 Mar 2023 08:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230171AbjC1MRT (ORCPT ); Tue, 28 Mar 2023 08:17:19 -0400 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 D36E193E5 for ; Tue, 28 Mar 2023 05:17:17 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id q19so8901011wrc.5 for ; Tue, 28 Mar 2023 05:17:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680005836; 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=xeUPgXrF4K4m85vkJ85zA0RhoqDQvOd+JPknE/eMLR8=; b=eBjNkUOBU95KtnjFGpzQFxa3gTNmPuNDntlkXc0qwkcbY7mHOfNLISGY6mMjTNf4sV +7TPX8S8bRz4BApgEYC/4JJAC0rXQygZeAC352q5f0q6pWgOtRrhHeAXRx8HbMoEyg8k wDzJqERukynPcleQ1ncNqqHIoewQXRVRAmvNXW0YSd8TGBkBzIQwNm5mA+T7ZdccOXJE W6A8/SdXdynu1Y6yQDTIeKN1FTMaCn+w+zJUFSt/AyKdmqRY9iLuttba8p4UifiEBsAC dp8W2mVnlKU9D52W1xxiuruzJlOqSQsajC19kgVbNo4kEq8DI/c2mdjt+8C2GtmyfqLr XwOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680005836; 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=xeUPgXrF4K4m85vkJ85zA0RhoqDQvOd+JPknE/eMLR8=; b=S6wihv++Xv8cTefY03l040JrA7uITNdX0ISncVlgSGArQ7Ht1RbWtej2iasif3hfjy CgMNdsVO1Vkg4PA8mbh4iUQkxq8dWkON9MPnoKyQQY/pth/xDbqhCC4gJmPbjkC6Dt1t b5uOy/oNjuCGJGah/ot/dGdD1KTRJUIMQ8Vzl9tXj0ZVNHY25YpvyWpbugPr3OAYnfSe 8fCivPwa2mByby/LeVoJrv0CVkquPN8Oe4gxyYhBSrCYoLPKSIzio3j5j9Y6dIGK0C3M tkhnRbFe3koQQgejvaUlFCuOKNoJLhTxTrTtq/y/ryKll17EW+09jtMFP9jn/aeb4aj3 vESw== X-Gm-Message-State: AAQBX9c+3ID+7n8pGQGKsRB3Eb5aKrY0sAgJy+RHsBA5BpT50Flu9QgK AsAbIMVmmN4ANxpxwTncA8X2wQ== X-Google-Smtp-Source: AKy350ZPv5J5EjhsTFkyeB7zHYHckKUZVcTZsIHycXcHYI0ywfBDD/aQuSB3+Bjmx+pChrH0EmpypA== X-Received: by 2002:adf:fd11:0:b0:2c7:1a86:aecd with SMTP id e17-20020adffd11000000b002c71a86aecdmr14392097wrr.2.1680005836346; Tue, 28 Mar 2023 05:17:16 -0700 (PDT) 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 c9-20020a5d4cc9000000b002d21379bcabsm27503187wrt.110.2023.03.28.05.17.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 05:17:16 -0700 (PDT) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare Cc: Patrick Rudolph , Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] hwmon: (pmbus/core): Notify regulator events Date: Tue, 28 Mar 2023 14:17:11 +0200 Message-Id: <20230328121712.4057359-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230328121712.4057359-1-Naresh.Solanki@9elements.com> References: <20230328121712.4057359-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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 18a3f3b1ec07..6475b2fe489f 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -3159,11 +3159,29 @@ static int pmbus_regulator_register(struct pmbus_data *data) return 0; } + +static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) +{ + int j; + + for (j = 0; j < data->info->num_regulators; j++) { + if (page == rdev_get_id(data->rdevs[j])) { + regulator_notifier_call_chain(data->rdevs[j], event, NULL); + break; + } + } + return 0; +} #else static int pmbus_regulator_register(struct pmbus_data *data) { return 0; } + +static int pmbus_regulator_notify(struct pmbus_data *data, int page, int event) +{ + return 0; +} #endif static int pmbus_write_smbalert_mask(struct i2c_client *client, u8 page, u8 reg, u8 val) @@ -3178,9 +3196,13 @@ static irqreturn_t pmbus_fault_handler(int irq, void *pdata) int i, status, event; mutex_lock(&data->update_lock); - for (i = 0; i < data->info->pages; i++) + for (i = 0; i < data->info->pages; i++) { _pmbus_get_flags(data, i, &status, &event, true); + if (event) + pmbus_regulator_notify(data, i, event); + } + pmbus_clear_faults(client); mutex_unlock(&data->update_lock);