From patchwork Wed Nov 15 13:44:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: marius.cristea@microchip.com X-Patchwork-Id: 16610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2545628vqg; Wed, 15 Nov 2023 05:46:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IH6Kqqe1ACLd3+tL289h6n2DNffysJb5wcNaDehVM/MrZypTRJ4xdjUxCIZb1R+FfK3Sk/z X-Received: by 2002:a05:6a20:d38f:b0:181:671f:445e with SMTP id iq15-20020a056a20d38f00b00181671f445emr10581426pzb.33.1700056001168; Wed, 15 Nov 2023 05:46:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700056001; cv=none; d=google.com; s=arc-20160816; b=I85RjdiYPlCZq7aD6hH+jdervNP8vHxkcvcEFAjo2Y0erNVKBrTUK7v57hz5ke8j3A X49nqhnxxhuDhRbQwVkFW/fioDYRYqCACdD97jgUBMPq+mQMsAoXVjjHbLbyKFrsyuwL hbwKjE2+KNLSruVOWG9OV6XcOrmQYnBxega3ioMRqjh7bz8pSiqe96iHQxRmNIKfYe6n StiYWjHupyjfXRR+8TZkaz/wpeVvoMN6hRTYqOq7PsI/UL1Bar/KrBymwLnrbL32dgrG lEWyHTyZxrlRNCX0ENvugHCJeDFq2b5w9hlCM7ts1G8AFQWc7/03emWgzLJCuahDMNGT uV7Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=aFRRDGcjXhSyugb+LjCY+Xv3zS8vucwQ9+o7lWz+EI0=; fh=nv5mPDyL+gn29yYCkp4H0xRtubiLqqseGw1hdBUIMrI=; b=Z2lJfxSig/7t96Vu5BN+wkbKQByOHJZX+kze/gek/L/avMia3iP9tzuBYoGdQpZEPH b2h7OJvORkkBWn0PuDobY7uggO7Qgf2wtKk+J7Q3rWan1TUV5ZG07BabSFs3wW5OlKwJ r65pB8SHn5xotWKI9z2PvWRpBp3ALizoAqF9kGWK6JBrcsGWZZIZpkPWpcUllNMvpq15 BfnSPtR6Uo9tYoetqqP6P5PJqUujmTJZkg45qUc9IrFNSOnktAN/69V0IDgQ5D9/hy7o wiPseLNjydN084VV7pYc28gRMXK2+Rri7KvQsubtFv7o2fzuB0xI4UqrkbsfFT2+loFq 06sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="QBT/K71t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id y1-20020a655b41000000b005b960674526si10382521pgr.779.2023.11.15.05.46.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:46:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b="QBT/K71t"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id C8F618077531; Wed, 15 Nov 2023 05:46:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344017AbjKONqJ (ORCPT + 28 others); Wed, 15 Nov 2023 08:46:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344058AbjKONqE (ORCPT ); Wed, 15 Nov 2023 08:46:04 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE331FA; Wed, 15 Nov 2023 05:45:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1700055958; x=1731591958; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=eiHhnwxmDdZ6uny+ZcBXgoWY+2o1D01iokPBwa8lAqY=; b=QBT/K71t52GzIeVl+byh/5EVkQl3AymLPmObR231p3lUoIDRfWcTbdZP OsQGxVzVFHMTOQM+XKzKz5Yj9mUHHhuudBGKOiqcfReevLWFMH1AahOsZ v4KF7xi85pDShePB4xySO7uoWtsSxQM3A3utWM/lc/FQbnS7Oup/58FV8 aF/uXZJviaYhGMV9z82HMckvR3gNKONRg1qxpIQeR3dhjX5WPXuQRh+mL GHNrBhUHlPvMdLeCPTjOCrC7nk15q+LUM5FQzXqdExTt+VCcrRKpfR2qz eP5jjL50uJrkEpB3NRXGthXumqrjj2drSXkMz1eVJ5ULn0TDm552XrJHQ Q==; X-CSE-ConnectionGUID: LgQt6nmvRtWORLzOkR+vzg== X-CSE-MsgGUID: xozfofjNR0uC+f6mWO+Xjw== X-ThreatScanner-Verdict: Negative X-IronPort-AV: E=Sophos;i="6.03,305,1694761200"; d="scan'208";a="12423813" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES128-GCM-SHA256; 15 Nov 2023 06:45:57 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 15 Nov 2023 06:44:59 -0700 Received: from marius-VM.mshome.net (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Wed, 15 Nov 2023 06:44:55 -0700 From: To: , , , , , CC: , , , , , Subject: [PATCH v3 0/2] adding support for Microchip PAC193X Power Monitor Date: Wed, 15 Nov 2023 15:44:51 +0200 Message-ID: <20231115134453.6656-1-marius.cristea@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 15 Nov 2023 05:46:38 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782637921640044868 X-GMAIL-MSGID: 1782637921640044868 From: Marius Cristea Adding support for Microchip PAC193X series of Power Monitor with Accumulator chip family. This driver covers the following part numbers: - PAC1931, PAC1932, PAC1933 and PAC1934 This device is at the boundary between IIO and HWMON (if you are looking just at the "shunt resistors, vsense, power, energy"). The device also has ADC internally that can measure voltages (up to 4 channels) and also currents (up to 4 channels). The current is measured as voltage across the shunt_resistor. I have started with a simple driver (this one that is more appropriate to be a HWMON) and willing to add more functionality later (like data buffering that is quite important for example if someone wants to profile power consumption of the processor itself, or a peripheral device, or a battery, this kind of functionality was requested by our customers). Differences related to previous patch: v3: - this version was sent also to HWMON list - fix review comments: - drop redundant description from device tree bindings - reorder "patternProperties:" to follow "properties:" in device tree bindings - update comments to proper describe code - use numbers instead of defines for clarity in some part of the code - use the new "guard(mutex)" - use "clamp()" instead of duplicating code - remove extra layer of checking in some switch cases - use "i2c_get_match_data()" - replace while with for loops for the code to look cleaner - reverse the logic to reduce indent. - add comment related to channels numbering - remove memory duplicate when creating dynamic channels - add "devm_add_action_or_reset" to handle the "cancel_delayed_work_sync" - remove "pac1934_remove()" function v2: - fix review comments: - change the device tree bindings - use label property - fix coding style issues - remove unused headers - use get_unaligned_bexx instead of own functions - change to use a system work queue - use probe_new instead of old probe v1: - first version committed to review Marius Cristea (2): dt-bindings: iio: adc: adding support for PAC193X iio: adc: adding support for PAC193x .../ABI/testing/sysfs-bus-iio-adc-pac1934 | 15 + .../bindings/iio/adc/microchip,pac1934.yaml | 137 ++ MAINTAINERS | 7 + drivers/iio/adc/Kconfig | 12 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/pac1934.c | 1673 +++++++++++++++++ 6 files changed, 1845 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-pac1934 create mode 100644 Documentation/devicetree/bindings/iio/adc/microchip,pac1934.yaml create mode 100644 drivers/iio/adc/pac1934.c base-commit: 5e99f692d4e32e3250ab18d511894ca797407aec