From patchwork Tue Nov 22 13:50: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: 24387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2209574wrr; Tue, 22 Nov 2022 05:52:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf69u8FHOCurDoS01GHDghRQSlrFqzEls/hjwv2u9K/7VOoZTcwN8hBqpKIPFfE9jVTb6H9E X-Received: by 2002:a17:902:ce06:b0:188:fd3f:cb06 with SMTP id k6-20020a170902ce0600b00188fd3fcb06mr3989178plg.23.1669125131719; Tue, 22 Nov 2022 05:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669125131; cv=none; d=google.com; s=arc-20160816; b=wXtdEy+B3j5Z7K5o2rXm1jbf3kSjPN9U6FhQse5tkvWbeddf69WpjBDC8Kkcen6S6+ 2t7pZ7oNq/YoYINjE+8tT6BixyXPnlyv3hKepnbEIzdIOrJfqTzC19rGMZH7wd6wT8jg BOzgC9B4IrggR7zFRB9H40BtKZLPBJ0Ac+kndFfHlkTyc1gt/SbbbFuzl81XEFga8xBo zmxFk34Xwc1qIXMfqeLUelGSxSXELKaMgcbUOMQ5+DuKfSjMWLnls7KgLAsjjo6prxUU QUGf4UaMK6B4XDAbg84RLxAVhnPKxthV2gA4MA2nYpI8Ss5Copf9mCRhzvxccQHi4p85 2hfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c2zr/3LnDgZvKq+c4XGc3H/8wNdt4pUTOlQ5WTUoXqY=; b=iFlZ+uaup4DmzAei1pjrBVGB68EBFVp1eWcQ3axZuvIWugGd89A+s5aP8AHqeqhExh 0+ybp2QAYNzN+D5E00u3yjnbj0QTZVAuVOT/o5ql3FdAsTxG8igQIDFdz7QjOswPKTox TyBcoQiAtoAAsvVRyK+4Mz2QcFNfTTc4xL9xNMc3FthPzl+vC6G7OLM5yVbdipNljUzl 8JDq+k6quB8XaNRVkYGMXU0EhA5Rr6qczaTaLmWpbLK4UiZHAAQg5gFe1gePiGB/6EZx t8SbUdWx4VZP2vUzEl9RxWZRo/N9Py68p+eHLLbEHRYeAxrxgEViTMTLabMdiCjhmfp6 pk0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=T7dOFALU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a170902db0300b001868277386dsi15955669plx.192.2022.11.22.05.51.57; Tue, 22 Nov 2022 05:52:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@9elements.com header.s=google header.b=T7dOFALU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=9elements.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233894AbiKVNuZ (ORCPT + 99 others); Tue, 22 Nov 2022 08:50:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233885AbiKVNuX (ORCPT ); Tue, 22 Nov 2022 08:50:23 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1375B5E9C1 for ; Tue, 22 Nov 2022 05:50:22 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id l14so5922316wrw.13 for ; Tue, 22 Nov 2022 05:50:22 -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=c2zr/3LnDgZvKq+c4XGc3H/8wNdt4pUTOlQ5WTUoXqY=; b=T7dOFALULTJ7RCXwLpoc1ogo/zlyXJl7R9/WAcrl+IfjgWx1F8u61ctPcVbDoRJ3QA FuP+WQYnARMSSKbzN5/VPyK9acoyqr9JvKIS4Dkvc/ChB8EZW/csYzC+KOsI0Z8po1hB 0v7A8uljgjn/SkY8n4ZkcUIvwgl1Glp+xJkutNjjckyuGfHZoVgIE9KUnagMtYJMzV8X D7fSNeFNIpOW078i568ez0JJujhFkMmnJY9NEpioN7GQrdBtsh3nFGMV68ifDqDM2uqJ FCv1UjucOER1x+qZK+awD438DbM5symYMP5QW6fFIlEU2MY0aepVYk71l3M7JdyiXrnq M0ZQ== 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=c2zr/3LnDgZvKq+c4XGc3H/8wNdt4pUTOlQ5WTUoXqY=; b=XcaXXwpwYBzZUvjaQJzeEJmaJmuAjNW8xEGpWdONCQxXmFT7dpGeaBkU4T7i3EexOx FbAF4+UxjRkqr+6p5BkliCMDvvQN8O67pR0iIij3Y8GgSAil2auzNO6mDxMQDycW/uui oFVLUSeaC8DTII8r5rpZ94rT/QVlY9Pj9/R5zJllYzpTodwB6f72Ozmqjl+OIAYAaR3B SKQE3gqCZv4K5FINJs5IhwUsvtDYX8QliYKEZDtwx21My8ApSysUaKEI6z5716Geu765 KkCe9gNaL8M2M/1LqzuRV6M2/qV+muXXIpFXNm2TLsugH+BBXyGGKlX7cMCHhNwavCP6 eT8w== X-Gm-Message-State: ANoB5plGFw4SyKx7n1Y6s+Vg2UYkVGTDOLuK4HPHn5tpKCASXamwIXKE eu05lE2y76bofXLQ7zRCNw0tz4KZCWSs4TmL X-Received: by 2002:adf:d0ca:0:b0:236:8ead:4871 with SMTP id z10-20020adfd0ca000000b002368ead4871mr14371511wrh.498.1669125020593; Tue, 22 Nov 2022 05:50:20 -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 n17-20020a05600c465100b003cf483ee8e0sm19947254wmo.24.2022.11.22.05.50.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 05:50:20 -0800 (PST) From: Naresh Solanki X-Google-Original-From: Naresh Solanki To: Guenter Roeck , linux-hwmon@vger.kernel.org, Jean Delvare Cc: broonie@kernel.org, Patrick Rudolph , Naresh Solanki , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] hwmon: (pmbus/core): Add events to regulator flag map Date: Tue, 22 Nov 2022 14:50:12 +0100 Message-Id: <20221122135014.3504094-2-Naresh.Solanki@9elements.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221122135014.3504094-1-Naresh.Solanki@9elements.com> References: <20221122135014.3504094-1-Naresh.Solanki@9elements.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,UPPERCASE_50_75 autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750204554077387167?= X-GMAIL-MSGID: =?utf-8?q?1750204554077387167?= From: Patrick Rudolph Add regulator events corresponding to regulator error in regulator flag map. Signed-off-by: Patrick Rudolph Signed-off-by: Naresh Solanki --- drivers/hwmon/pmbus/pmbus_core.c | 68 ++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 08f96e2b4837..7d7d10039987 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -2738,9 +2738,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 */ @@ -2755,48 +2755,76 @@ 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_POUT_OP_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 }, + { PB_POUT_OP_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 }, { }, }, }, { .func = -1, .reg = PMBUS_STATUS_BYTE, .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_STATUS_IOUT_OC, REGULATOR_ERROR_OVER_CURRENT }, - { PB_STATUS_VOUT_OV, REGULATOR_ERROR_REGULATION_OUT }, - { PB_STATUS_VIN_UV, REGULATOR_ERROR_UNDER_VOLTAGE }, - { PB_STATUS_NONE_ABOVE, REGULATOR_ERROR_FAIL }, + { PB_STATUS_IOUT_OC, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, + { PB_STATUS_VOUT_OV, REGULATOR_ERROR_OVER_VOLTAGE_WARN, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + { PB_STATUS_VIN_UV, REGULATOR_ERROR_UNDER_VOLTAGE, + REGULATOR_EVENT_UNDER_VOLTAGE }, + { PB_STATUS_OFF, 0, + REGULATOR_EVENT_DISABLE }, + { PB_STATUS_NONE_ABOVE, REGULATOR_ERROR_FAIL, + REGULATOR_EVENT_FAIL }, + { }, + }, + }, { + .func = -1, + .reg = PMBUS_STATUS_WORD, + .bits = (const struct pmbus_regulator_status_assoc[]) { + { PB_STATUS_POWER_GOOD_N, 0, + REGULATOR_EVENT_REGULATION_OUT }, { }, }, }, { .func = PMBUS_HAVE_STATUS_INPUT, .reg = PMBUS_STATUS_INPUT, .bits = (const struct pmbus_regulator_status_assoc[]) { - { PB_IIN_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT }, - { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN }, - { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE }, + { PB_IIN_OC_FAULT, REGULATOR_ERROR_OVER_CURRENT, + REGULATOR_EVENT_OVER_CURRENT }, + { PB_VOLTAGE_OV_FAULT, REGULATOR_ERROR_OVER_VOLTAGE_WARN, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + { PB_VOLTAGE_OV_WARNING, REGULATOR_ERROR_OVER_VOLTAGE_WARN, + REGULATOR_EVENT_OVER_VOLTAGE_WARN }, + { PB_VOLTAGE_UV_FAULT, REGULATOR_ERROR_UNDER_VOLTAGE, + REGULATOR_EVENT_UNDER_VOLTAGE }, { }, }, },