From patchwork Tue Mar 28 15:03:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13191177 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 29A0DC76196 for ; Tue, 28 Mar 2023 15:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbjC1PFC (ORCPT ); Tue, 28 Mar 2023 11:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233836AbjC1PFA (ORCPT ); Tue, 28 Mar 2023 11:05:00 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9876EB41 for ; Tue, 28 Mar 2023 08:03:44 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id j18-20020a05600c1c1200b003ee5157346cso9644230wms.1 for ; Tue, 28 Mar 2023 08:03:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680015818; 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=SwYO599zCOMIb+ah0SxNIpjnaqvUaPRoqNOQOnLbI/08m5dkKLq0vxapCVvHBMfYp3 y2wPQeJbC9lJ/Xz7WFhvhsJZJvPHgGA7b7fPNOroAu3qVuXFxPYaKiM66TjUbm+DKV2O RUDkUkOqJDW+Da43id/Jcrf6ijm5Rz4bvNbQFkguPhq3lXCqduLRCLNC72JfRpgrqm9e hj/jMh2PT+ZrDMGa5NXqAg8lb5/vg4pdDNnR/oZIc5ZlB51dx/1GCVrASzZ85bIoYce4 vqb4y0bjWCN8mi/X6/4EDlXkASNlKIgXFZB+jTo+K45BhB07FJ0OR/v4+Ku3jLH/J8uk F6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680015818; 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=z9ricK5M6R7Xln4Um/mX6lgnoS//2N1r4MP/PkL0hbbDxo0oL72RG+Nm/PUcJQ84+o Dmc7AMiAIejx3zGD9d7NbC0TmiR7um7Zpb/M8v0Ul8u2q2YaQQcFob2RkGx4SdT/SotW K0jhpXse3CGQc/Gtig/qrRSgqL+e2kxjhEcOS0T6puYBKsdaGHG4vUjvzDYFAuVOfNLZ ZeUX3+UeoGCK99QACy8RjQ7UCue+Ea9D5CLP3C84AJmHcF+y3THLOsCm+QguMDBk5pXJ DDXduCwBiQlgEYBp0d1a1s6xml1VXDPfTCdCf2AgoMSlMzfeRT3g4UEBSRAuZmUvl2nT 4Xmg== X-Gm-Message-State: AO0yUKWMyhBHYxYwzyAs+6Y6b3F241hnEJN3jrRC5tx4aEZQQzqz+JRB k75Cpi1yYqKzuyFnO4EaB+O4SA== X-Google-Smtp-Source: AK7set/bN893UfIkzTqJL0r2e1oMezo/ssoDSEOpOtBuDCXyf3mu4WIawWcjgm5d3NzpFN2m3luumA== X-Received: by 2002:a7b:c7c5:0:b0:3ed:809b:79ac with SMTP id z5-20020a7bc7c5000000b003ed809b79acmr12587433wmk.19.1680015817802; Tue, 28 Mar 2023 08:03:37 -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 a2-20020a05600c224200b003ee63fe5203sm17429293wmm.36.2023.03.28.08.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 08:03:37 -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 v2 1/3] hwmon: (pmbus/core): Add rdev in pmbus_data struct Date: Tue, 28 Mar 2023 17:03:33 +0200 Message-Id: <20230328150335.90238-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 15:03:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13191178 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 6214DC77B62 for ; Tue, 28 Mar 2023 15:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233820AbjC1PFE (ORCPT ); Tue, 28 Mar 2023 11:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233845AbjC1PFD (ORCPT ); Tue, 28 Mar 2023 11:05:03 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A447EB4A for ; Tue, 28 Mar 2023 08:03:47 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id j18-20020a05600c1c1200b003ee5157346cso9644258wms.1 for ; Tue, 28 Mar 2023 08:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680015818; 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=jOMsSAwCIa8BFHDhgS4zqD3/u9bUaW/8QybvTpBaQmE=; b=d56Zz8LGPEnb5KUkvkHhKjzllTpdhYM/Zcnui/LE9lYSV6bJIQ6nuBVzER9AZwzoEL ynbWzJR8DWKgfOL9htGbgZP5pHqb9eSyCAXtQ4N8pdFHDC+fNjqMYQMQNYpqXozt2cio H0kz6u/3ERov2rU3FqMtLtSovIJkxHTIapn2BFc5azvogN/PRG1W9kRHyKVC90jXNbRK zcctjbs9eFHjY8atRFVLvo6eIVZWXzm4h/xhzxIzmH87MZ3+CMX8TnOc7htJ4J0JOmWr aA1ZwMhnMDfPSB1gu85yd7CQmgu6f4N0ZDAs3qU2Jve20tzZFevR4p9zbE8TAsuLWmvw GKQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680015818; 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=jOMsSAwCIa8BFHDhgS4zqD3/u9bUaW/8QybvTpBaQmE=; b=avUyBmBCHmdlWttsRu9M+TC9fOzL1xb2P5Lcvp0ATKKG4ht4g4wYrO1SRVJZAWY8v+ iKWWkzLLNCc5gTbFERMRs+Nm5jekun+TYA9guFrbp1/qCIZxdEbAw/Js+TLjrmVQMz10 RrnUQx6DYDbfjTsgstDIk7bjgd8msAia9+kmiqt7Jfd7vjatttstR6CZsheeB3aTYLK4 K1tLHJSXqTgoap4wDq3jDpWXl+yD17U5Jf6789MvAkU5sJhENATHO763ZRuB3HhwUpiq ingVfK0JrKshg+r3C3gYuCoLT/gZSRPGI6JN5LQ5HEa2NXOHYQvC842MACbJm5hNRVbJ tWKA== X-Gm-Message-State: AO0yUKUtZIq+8hxeaRFT8Rx2dsSPhM792niE0Yi2HUDg9krw/0AvA9hr Rl93qx252dmPzoEJFbaZ6260lw== X-Google-Smtp-Source: AK7set/ceOSdFcqJgAuGnfupgeL/+F+cMO6E0rMvZT3NeIWsJKES9QAEzXJp+hwt0ZNcZY1+AVLTAQ== X-Received: by 2002:a05:600c:ad0:b0:3ed:abb9:7515 with SMTP id c16-20020a05600c0ad000b003edabb97515mr13151196wmr.11.1680015818611; Tue, 28 Mar 2023 08:03:38 -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 a2-20020a05600c224200b003ee63fe5203sm17429293wmm.36.2023.03.28.08.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 08:03:38 -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 v2 2/3] hwmon: (pmbus/core): Add regulator event support Date: Tue, 28 Mar 2023 17:03:34 +0200 Message-Id: <20230328150335.90238-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230328150335.90238-1-Naresh.Solanki@9elements.com> References: <20230328150335.90238-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..509bc0ef1706 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,19 +2874,22 @@ 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; } static int __maybe_unused pmbus_get_flags(struct pmbus_data *data, u8 page, unsigned int *flags, - bool notify) + unsigned int *event, bool notify) { int ret; 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 15:03:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naresh Solanki X-Patchwork-Id: 13191179 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 427D2C76196 for ; Tue, 28 Mar 2023 15:05:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233813AbjC1PFI (ORCPT ); Tue, 28 Mar 2023 11:05:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233821AbjC1PFH (ORCPT ); Tue, 28 Mar 2023 11:05:07 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AB7FEB77 for ; Tue, 28 Mar 2023 08:03:51 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id bg16-20020a05600c3c9000b003eb34e21bdfso9667152wmb.0 for ; Tue, 28 Mar 2023 08:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=9elements.com; s=google; t=1680015819; 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=rfc+TC6H1PlSlxFpFQCACZ1XBg01+cDV6KBw8cNxn8g=; b=OSxGGIhx4Vg56wUYCQ8KPg1Tn15IEXVy/NE8SBWMkUB+t1fVYmTGzMzAm3e0QMWpo0 mFD0OFqbk4JF9UVuu1sLUF9zcmjB200QemNxXvwGQEWJ+cauUTiF/NLLKfW5i33tr9x6 IOZxSnymHZ0Q/vqSBEr0C5QY/RNWiyhS/ANwMlBW0A5f3aJCb4j1shzwZfnt9/a/74ip 3jcHt6CYFKkvo2t90KcW6wjsCdbRg5eCxBDIYkx6nE5tIToF27jJ4c5ldWacSZfKOc8o RN93a69cFu2mrGGIzqa41H/UwG4OSbxPV53X/65FGZ+17LkXm8VynWqRWAKAOmCdv+la c+rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680015819; 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=rfc+TC6H1PlSlxFpFQCACZ1XBg01+cDV6KBw8cNxn8g=; b=kN74UIbvdXzAyQWi2s4bfRRp7v6FMprbu0btotvK6N/c3wHTrleoBY3lp2nt2BzKkE xY1Ag4ma3OPSEI2XGbl9ATl7ShXo2sLxhrzCiFyXpfM3vbIBk3rhEwqkLdpKXKFQgekB 9kZPdKga/GgZlWFZ+nKBF9KRsS6pHTExgNL8bxm+Fff2qu7z4p5o2yUz7qQuuWtBaw8+ 2gpLUVj7xSzPPwzqrmfWE4ttytGq2GQJJp9SaFPIvFckQKBJ09+vmm35gHNrgumTKse5 /Y/rj13AcCrL+pkZRWSh9u7Ckmq6AmmOaTk5jCQh31D+0/NnJSqBsNaRGOyG/WDR3UDV IesA== X-Gm-Message-State: AAQBX9e5tRAnD2LdfTO9VxUbye+bMreXsRpu0IBX03iuTbYbOLMa8ssR SpO6fa1xx4+7qhptEJfd5gTBgw== X-Google-Smtp-Source: AKy350Zq9kh1XDdBrXtJ26uONjHkQWtkYQ+GRH/EveKHYfw0tWJwIteiGoDJWP4n9ulHqlgwF9iL+Q== X-Received: by 2002:a1c:7714:0:b0:3ed:ea48:cd92 with SMTP id t20-20020a1c7714000000b003edea48cd92mr5643697wmi.15.1680015819441; Tue, 28 Mar 2023 08:03:39 -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 a2-20020a05600c224200b003ee63fe5203sm17429293wmm.36.2023.03.28.08.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Mar 2023 08:03:39 -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 v2 3/3] hwmon: (pmbus/core): Notify regulator events Date: Tue, 28 Mar 2023 17:03:35 +0200 Message-Id: <20230328150335.90238-3-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230328150335.90238-1-Naresh.Solanki@9elements.com> References: <20230328150335.90238-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 509bc0ef1706..86cc8001a788 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);