Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp215131iob; Mon, 2 May 2022 17:27:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxOdnWXXblYAE4Eak4t14v7mq4MSXCAnj2Ey/uVH9+Hd9/4BvsoyKi/8qlRDhvWdMRZEve X-Received: by 2002:a63:6b42:0:b0:3c2:f3f:7a42 with SMTP id g63-20020a636b42000000b003c20f3f7a42mr6582894pgc.600.1651537647176; Mon, 02 May 2022 17:27:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651537647; cv=none; d=google.com; s=arc-20160816; b=AxlpntwTbAPaZlCYVQnIFD3F9B7IiZEuMlyfZLV22dtKXrVDxngbItgO/GmvrFbzvh OmKK2QITavsbgeRtVzdUazUqImvfpuds3DmRExBtwRBFpqy/fgacDttuxBheh6qFBBQ5 XBAaLHc1TNhS3EV0vMZYMJoWX3x1zRCJXDp3OV+0ZLFLy19/HtuCWjbkKbq+y1pQsB00 M0niLHeYxWuyHIfjyzElpOlhnw1eBvVA6NV1TKlKTqo6b8gHKgrHKb2F2Mbo6MMj++Op dYe5VJUEiB1BG9vUxniM3llS00Wn6oqnHtz2/sPU+AvUNW3dqcs2QRk0VKiYRRekivTN U3zA== 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=pikpMhYcg3LtmyyBP01zKh7b0dNBqXyk+C6F1QU+WH8=; b=HU7L59zJejN1tDWjF9JT6V641xN0+gUAblx8XNul4AO9ZLMxrvQaX+DgRynQLgGMLM 1znpoyDJklRptzGFNujMzGyivjLdBuoGPXU+pmIDDpHobz3IwTknCD9BcWVrn8J1koOT MgBa/1rbUVaYUVZIRORTwYVBhHy+jkkHz1LS8Cmpf9yWT9XFrrCxJ0hbzhr20d5KL+sq 7m7fsKLuBJ2rRcPg7XjWZqm0hQRMZGI6+YWAbAQPG13hs6hHmSsWaUPXojTvaZYsdmE1 Mz6PI7mWJC1f1eBocCoMYOQqQwlFnrVyRNslzCTxv203I8rW/4ih6jhXMgBNMwfsfHHm KbiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z1AydJsH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u14-20020a170902e80e00b00158da867027si1727052plg.624.2022.05.02.17.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 17:27:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Z1AydJsH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 91DE43B55F; Mon, 2 May 2022 17:22:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355121AbiD2WOQ (ORCPT + 99 others); Fri, 29 Apr 2022 18:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237982AbiD2WOP (ORCPT ); Fri, 29 Apr 2022 18:14:15 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8EF310DA for ; Fri, 29 Apr 2022 15:10:55 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id v12so12390807wrv.10 for ; Fri, 29 Apr 2022 15:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pikpMhYcg3LtmyyBP01zKh7b0dNBqXyk+C6F1QU+WH8=; b=Z1AydJsHe4/DVQY/qNijIW+DyLoOc9wSXwnlhUJtIkRiYF2G7tMNMmtEMKGVP5V4sG asGjR8dLd9jZ7ZAkx9mh4S1IKU2fGok8W/Ed60RlW+wpF67o6ASw+hRo/UpQFP73hkR4 uTlSH5DBMqFq9JBQwDpZvH3ha2UnWvOtXv/rdeVZffFfgERV6Qr971+dlbe8AUQtGqxV PlSfKSHwdrRi9s7FCHRUNFdsBwhQhBloLr2IZOG0gEtCIJWP38lfroAlOkbetEM9yKiw v4P1ad4WJiGf8z7IWAYvEAFhatQ0/BQrcSvU9SE9mEVvybZDokFU1ve/EeP/6BVkXJEq GdlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pikpMhYcg3LtmyyBP01zKh7b0dNBqXyk+C6F1QU+WH8=; b=ZsTyZTEPDpy0wTl7fc1nwjj2Qr60lStCQAf4B8qn9CTOcKpyuAuuxjPhJlyznyO1M4 6y0EZO5Cne+i9rJ+QO9Z8jjTfuCPwuw4C889NazJT27YWBIptfvwOzdL9hUoRX9qZK+4 Hw3GVxTuoipamYuhOvIiWt16IhGh1o32Vml33N+JBI6D4e6Y6X709BpKPbrvUKH+MjkK ++MVSgUFqpeNW218+5X1MbVeojgWGWjDJBngy+DSIsi/wJXERu+F1MewNjYIvPD/a3WO VeBP7ClIxIGJcfgnDEvlcq4FUKET3/UZldjc2aC3kLrF9ZsGTTSt9xOyh1ajmLTpfH/0 bI5g== X-Gm-Message-State: AOAM533ss6ch59JgOOpfpFcB6Oe7E4Ew2fSJBZfROb/43AW+dbYvqYVP fibYYZzt0TKRR5uKsvneqSr5KCyEVwALZA== X-Received: by 2002:a5d:48c7:0:b0:20a:c72d:279b with SMTP id p7-20020a5d48c7000000b0020ac72d279bmr844806wrs.379.1651270254328; Fri, 29 Apr 2022 15:10:54 -0700 (PDT) Received: from localhost.localdomain (cpc78119-cwma10-2-0-cust590.7-3.cable.virginm.net. [81.96.50.79]) by smtp.gmail.com with ESMTPSA id q7-20020a1cf307000000b003942a244ebfsm291985wmq.4.2022.04.29.15.10.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Apr 2022 15:10:53 -0700 (PDT) From: Caleb Connolly To: caleb.connolly@linaro.org, Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Andy Gross , Bjorn Andersson , Lee Jones , Stephen Boyd , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Jami Kettunen , Sumit Semwal Subject: [PATCH v14 00/10] iio: adc: introduce Qualcomm SPMI Round Robin ADC Date: Fri, 29 Apr 2022 23:08:55 +0100 Message-Id: <20220429220904.137297-1-caleb.connolly@linaro.org> X-Mailer: git-send-email 2.36.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 The RRADC is responsible for reading data about the current and voltage from the USB or DC in jacks, it can also read the battery ID (resistence) and some temperatures. It is found on the PMI8998 and PM660 Qualcomm PMICs. The RRADC has to calibrate some ADC values based on which chip fab the PMIC was produced in, to facilitate this the patches ("mfd: qcom-spmi-pmic: expose the PMIC revid information to clients") and ("mfd: qcom-spmi-pmic: read fab id on supported PMICs") expose the PMIC revision information and fab_id as a struct and register them as driver data in the Qualcomm SPMI PMIC driver so that it can be read by the RRADC. The first 3 patches add support for looking up an SPMI device from a struct device_node, as well as introducing support for looking up the base USID of a Qcom PMIC, see patch comments for more details. These Address Bjorns comments on v2. Changes since v13: * Address Lee Jones' feedback on the SPMI patches. * Pick up Jami's patch to enable the RRADC on the OnePlus 5 Changes since v12: * Apply Krzysztof's suggestions to rradc DT binding docs. Changes since v11: * Remove debug logging which was left in ("mfd: qcom-spmi-pmic: expose the PMIC revid information to clients") * Picked up Dmitry's Tested-by and Reviewed-by tags. Changes since v10: * Don't inline spmi_device_from_of() Changes since v9: * Add back missing copyright, this driver is originally derived from downstream (Thanks Manivannan). Changes since v8: * Drop Reported-by for the bugfix on previous revision reported by LKP * Apply Jonathans suggestions * Rework patch 2 ("expose the PMIC revid information to clients") to handle PMICs with a single USID (thanks Dmitry) Changes since v7: * Addressed Jonathans comments * Fixed bug reported by LKP Changes since v6: * Fix printf format warning in rradc Changes since v5: * Add missing EXPORT_SYMBOL_GPL() to ("spmi: add a helper to look up an SPMI device from a device node") Changes since v4: * Addressed Jonathan's comments on v4 * Reworked the qcom-spmi-pmic patches to properly walk the devicetree to find the base USID. I've tested this on SDM845 which has two PMICs (pm8998 and pmi8998) and I'm able to look up the PMIC revid from all 4 USIDs. Changes since v3: * Split PMIC patch in two, rework to support function drivers on a sibling USID * Completely rework RRADC driver to make use of the modern IIO framework. This required re-arranging a lot of the equations and results in some lost precision, where relevant I've left comments to explain this. I don't think any of it is significant enough to justify doing post-processing in driver. Thanks a lot Jonathan and John Stultz for helping me out with this Changes since v2: * Add missing include (thanks kernel test robot :D) * Rework some confusing function return values, specifically rradc_read_status_in_cont_mode and rradc_prepare_batt_id_conversion both of which didn't correctly handle "ret". This also bought up an issue as the previous implementation didn't actually wait for the channel to be ready. It doesn't seem like that's strictly necessary (same data is reported if I wait for the status to be good or not) but I've included it anyway for good measure. Changes since v1: * Rework the RRADC driver based on Jonathan's feedback * Pick up Rob's reviewed by for the dt-binding patch. --- Caleb Connolly (9): spmi: add a helper to look up an SPMI device from a device node mfd: qcom-spmi-pmic: expose the PMIC revid information to clients mfd: qcom-spmi-pmic: read fab id on supported PMICs dt-bindings: iio: adc: document qcom-spmi-rradc iio: adc: qcom-spmi-rradc: introduce round robin adc arm64: dts: qcom: pmi8998: add rradc node arm64: dts: qcom: sdm845-oneplus: enable rradc arm64: dts: qcom: sdm845-db845c: enable rradc arm64: dts: qcom: sdm845-xiaomi-beryllium: enable rradc Jami Kettunen (1): arm64: dts: qcom: msm8998-oneplus-common: enable RRADC .../bindings/iio/adc/qcom,spmi-rradc.yaml | 51 + .../boot/dts/qcom/msm8998-oneplus-common.dtsi | 4 + arch/arm64/boot/dts/qcom/pmi8998.dtsi | 8 + arch/arm64/boot/dts/qcom/sdm845-db845c.dts | 4 + .../boot/dts/qcom/sdm845-oneplus-common.dtsi | 4 + .../boot/dts/qcom/sdm845-xiaomi-beryllium.dts | 4 + drivers/iio/adc/Kconfig | 12 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/qcom-spmi-rradc.c | 1021 +++++++++++++++++ drivers/mfd/qcom-spmi-pmic.c | 272 +++-- drivers/spmi/spmi.c | 17 + include/linux/spmi.h | 3 + include/soc/qcom/qcom-spmi-pmic.h | 61 + 13 files changed, 1372 insertions(+), 90 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-rradc.yaml create mode 100644 drivers/iio/adc/qcom-spmi-rradc.c create mode 100644 include/soc/qcom/qcom-spmi-pmic.h -- 2.36.0