From patchwork Thu Feb 3 16:46:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 539619 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 64AC4C43217 for ; Thu, 3 Feb 2022 16:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352369AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352344AbiBCQqi (ORCPT ); Thu, 3 Feb 2022 11:46:38 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A5B8C061401 for ; Thu, 3 Feb 2022 08:46:38 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id t14so4732741ljh.8 for ; Thu, 03 Feb 2022 08:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8jB3QWFPq4tYyo9a6LQnVJfW1OWpkZK4X0yVs9VUaIA=; b=upiZmsHDarYV6iwQW1DlW79cmGmkJb2uWOokRc4WAwcuONG8v0taVQDKEwJheifFhp g/RzSBJtmQhsLPkhCKD/fXfkYe0ij4W/YO/gXQqZBP7EGG4D1TiO126bhJjo6EsBP0+3 ypqXqeo84EhpiAFNVehcXO87sfGdQ/43EgRLxaWrpmqDmdqj7d/tMwRYdSC2rSmrCb/7 5EOqURXReMMC4ACx2CxRMofbhlL7WEWmupdIZPKx8rItraA3sUt7WVKP8+UOBMHVwJlf xo6kog77+QKuQqh0x7PJ7xTVFsAfQ6QOQHug5wxxZlJmm+z2+viYl1dAdWeqCzADi5Ey TY2Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=8jB3QWFPq4tYyo9a6LQnVJfW1OWpkZK4X0yVs9VUaIA=; b=X86IKeyKPd8X9lRuOlJd0ejylg4JroAing3YX7yl6wzf7KsyONcVQAdOcqyc6v3Ein /AFnFkWfDzTd6ojTloySWL+0gVFj9s0bJyCxpjSTR9DVb+ZrYXDZirNITTde/DXP+z9U 4PMVPraQ47jxqZIellmLnhFVDe1ipndV7bQS64OGj6ROi3TUHsk4l1pcxcS26m+iJTfX mCpmNLfG+68eO30SI0xA4I0I8HngnKH5lJ1gEocEEPymyWG223V8DF/yoK500e4lXzH8 hWiggAXcyDS/hs94D+y/K2pVHKfPFyHg5F6pGzXqh+l6IY9qHQA7Qrd7m5lQI8SoicTW 8E0g== X-Gm-Message-State: AOAM531dSycWZamOwQ147g0DV1yP87LT3aRRUhqtkr8cRBx5e7vndj1M a2oUtyFWoiBs+9CEB9vyj2cmhA== X-Google-Smtp-Source: ABdhPJwIkL4AyrPYHs2BAQP+p95jSYywBKSJ62hIbgp1eN1PcZEpj4nIVyw/Q0DNp1Tv1rxo0HOE1A== X-Received: by 2002:a2e:5ca:: with SMTP id 193mr23681605ljf.213.1643906796460; Thu, 03 Feb 2022 08:46:36 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id h6sm269999lfm.237.2022.02.03.08.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:46:36 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss , Rob Herring Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 1/9] dt-bindings: i2c: qcom-cci: add QCOM SM8450 compatible Date: Thu, 3 Feb 2022 18:46:28 +0200 Message-Id: <20220203164629.1711958-2-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change adds QCOM SM8450 compatible value to the list of QCOM CCI controller compatibles, the controller found on the SoC is equal to the ones found on previous SoC generations. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss Acked-by: Rob Herring --- Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt index 7b9fc0c22eaf..924ad8c03464 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt @@ -10,6 +10,7 @@ PROPERTIES: "qcom,msm8996-cci" "qcom,sdm845-cci" "qcom,sm8250-cci" + "qcom,sm8450-cci" - reg Usage: required @@ -43,7 +44,8 @@ PROPERTIES: SUBNODES: The CCI provides I2C masters for one (msm8916) or two i2c busses (msm8996, -sdm845 and sm8250), described as subdevices named "i2c-bus@0" and "i2c-bus@1". +sdm845, sm8250 and sm8450), described as subdevices named "i2c-bus@0" and +"i2c-bus@1". PROPERTIES: From patchwork Thu Feb 3 16:46:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 539618 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 912E0C4167D for ; Thu, 3 Feb 2022 16:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352344AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242631AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE2F1C061744 for ; Thu, 3 Feb 2022 08:46:38 -0800 (PST) Received: by mail-lf1-x12a.google.com with SMTP id i34so7287491lfv.2 for ; Thu, 03 Feb 2022 08:46:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6eCj/v8zX5auOFJWHqJA0245e7LfVyGUd0icgsO85GA=; b=QACmUevu70dLEDO4C7OXJEzJ/auhpnKawKYZ9fJ5cghANwS9BmlM+IBRUvSTaTNg6w an1Ex0u3Xr4d9n+5CeFq3wIPmeFbKLAFrtlD2zmZRUBN7ymf8/55hgJseG/FQTR9CJN3 tz8Avn81lL5fIxmaBHhQYFmtuWvpPv8DhKLCf6IAVIyp9mqubknz7d7TtpMcwPj5+A80 ijuPgZWFTrnBuL4//sFAttg2+l4gkE/pcRxhFtQ+pPWva9jSBQ7MuaP+WlBZneAnSwLV 0ke92LZQrbx5+s6EG85J/o5zuHVSysVWZB00Nlh/yalDf2xsmlZme7t/q/9z7BVP35CK Iieg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=6eCj/v8zX5auOFJWHqJA0245e7LfVyGUd0icgsO85GA=; b=cfgfr7ta/RvvRBmugKWk+qxncapq08qbecnaNPr/Ly9KvQ3c/qXTIeQUCn/4c8xCPR mfiL/jgDbTatAcL9hqWOe5rdfDJGZOtgLqAgBvqO3a9VUPsyC1gq8l01RxafLmFDkKvu pPmkKiRCCw5IeF/hXpsi+aq63oRT/VsyWR47lSSw0NIVr/MOD0IZYALZBHwhpDZls74d yRNBpLAFOOvq3542Etzl6529lAcM9VQf+OmqNwi/2UJtdcRd/mbq19IGSXOx2NKhth9F IpBnniUSKy876LhMnVlU80mY40M3R17w3IN1jht859wRyYYB9+1exBlrK074Qhuo4mNU /YDQ== X-Gm-Message-State: AOAM533x8ICYrB+CQVWlTzSudzi6mLpvwYXsAYb2Ni+xP1Du8RcYiEQq uz6Ub1+U7W8qwtwwfl8zBb5nUg== X-Google-Smtp-Source: ABdhPJxsAyvdMto3oEeJ+xFPUhuckio4nahIIoeIh6orsZByx3/fa9XQZnFbY0cY/5bNGVo+ijpCKw== X-Received: by 2002:ac2:4357:: with SMTP id o23mr28496643lfl.680.1643906797192; Thu, 03 Feb 2022 08:46:37 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id h6sm269999lfm.237.2022.02.03.08.46.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:46:36 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss , Rob Herring Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH 2/9] dt-bindings: i2c: qcom-cci: add description of a vbus-supply property Date: Thu, 3 Feb 2022 18:46:29 +0200 Message-Id: <20220203164629.1711958-3-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Quite regularly I2C bus lines on QCOM CCI controller require an external pull-up to a regulator powered line, to be able to define all such cases an additional vbus-supply property of a bus subnode is wanted. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt index 924ad8c03464..9f5b321748f1 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-qcom-cci.txt @@ -60,6 +60,11 @@ PROPERTIES: Definition: Desired I2C bus clock frequency in Hz, defaults to 100 kHz if omitted. +- vbus-supply: + Usage: optional + Value type: phandle + Definition: Regulator that provides power to SCL/SDA lines + Example: cci@a0c000 { From patchwork Thu Feb 3 16:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 540112 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 8841BC433FE for ; Thu, 3 Feb 2022 16:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242631AbiBCQrF (ORCPT ); Thu, 3 Feb 2022 11:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240972AbiBCQrF (ORCPT ); Thu, 3 Feb 2022 11:47:05 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C58F2C06173B for ; Thu, 3 Feb 2022 08:47:04 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id i34so7289997lfv.2 for ; Thu, 03 Feb 2022 08:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=npRH7vRKW6sr8ga77ZpB533YBv6nJOMH1HOGWpxJJcI=; b=e7EbWgjxdid5lXnkoPKdVoMyRMXw6MVrUbkyyKb2/dSYFi/Wdv4EZdp31RUmxrLJd3 2A1rbICAOqawWk/Dhdu2BXbc+y/+jRcSsLfTdOv1O8wuMZnePO5p0zoZcpt5XN3/PL0w F321/cw73+Mk+fvw0wlAGVNQwe+Ej+T5YL7rmObAlZkwKJwrxPgkGvKOlhPCZ6O3CUqa jP/mXZavbzTa3KS9Oa4BclfnYgfdVBoAnnbfubCY8/c7YvJw2VGfCz/CS+hrVKeoAQYh kDC1CugIbuHHrkUaVm00mlDuJ+219SOTe7BDkGUxvGrwEdB4bW2caemdNImal9EFL2Et ED+A== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=npRH7vRKW6sr8ga77ZpB533YBv6nJOMH1HOGWpxJJcI=; b=03gvXWJQytKUjglAgxxSpdKiCoQCxKRjSx72ZR2p5nawC8VlHPaQ2b/JPdsak5CBnb nYHYrLgbqnno2xQuUSkRuL4NqCwg8npUqRv9ayW+jUWtJSa93TZe4a72h9w1NcfLhq8g qkxeTG6/xko0ZyZO3owa+h1fQdk1I/lFOmYQxPv/t0yznCFcvtZhmchaaKxLzPfLRRPZ 6aM6aM3MUZSxluBzbtZQItn31npTXtv+qH5ZP4iNn05qNEYVa0bclM52bdcRhE/uiaxa e1clyggsT6bhq1HdWbbZBo1QjO6X6C3XNAl9k0ZtYGf3nlM3LabEtlhyme8hSR3yGcyd tGXg== X-Gm-Message-State: AOAM533NcPBgIerSJONCuYS2FtqVkYoJFCDnb7JplT7tCwYvQwMwz9j7 +xqiMxwqAZL63jCFC9WvTn++jA== X-Google-Smtp-Source: ABdhPJwlb9LKAPt+1JJZfwzI5qnxiLn1plPZB/hVTFD7Wsr9En8QaO8UILxVT11UIzG7DUYveun9cg== X-Received: by 2002:a19:f24a:: with SMTP id d10mr27531787lfk.649.1643906823163; Thu, 03 Feb 2022 08:47:03 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id u9sm4328650lfc.168.2022.02.03.08.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:02 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 3/9] i2c: qcom-cci: don't delete an unregistered adapter Date: Thu, 3 Feb 2022 18:47:00 +0200 Message-Id: <20220203164700.1711985-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If i2c_add_adapter() fails to add an I2C adapter found on QCOM CCI controller, on error path i2c_del_adapter() is still called. Fortunately there is a sanity check in the I2C core, so the only visible implication is a printed debug level message: i2c-core: attempting to delete unregistered adapter [Qualcomm-CCI] Nevertheless it would be reasonable to correct the probe error path. Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver") Signed-off-by: Vladimir Zapolskiy --- drivers/i2c/busses/i2c-qcom-cci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index c1de8eb66169..fd4260d18577 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -655,7 +655,7 @@ static int cci_probe(struct platform_device *pdev) return 0; error_i2c: - for (; i >= 0; i--) { + for (--i ; i >= 0; i--) { if (cci->master[i].cci) i2c_del_adapter(&cci->master[i].adap); } From patchwork Thu Feb 3 16:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 539617 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 B4916C433F5 for ; Thu, 3 Feb 2022 16:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352402AbiBCQrI (ORCPT ); Thu, 3 Feb 2022 11:47:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbiBCQrH (ORCPT ); Thu, 3 Feb 2022 11:47:07 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D203EC06173B for ; Thu, 3 Feb 2022 08:47:06 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id t14so4734688ljh.8 for ; Thu, 03 Feb 2022 08:47:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ueO5vydjulfg6IAl/bg9DbwgRIt1DtlTq0JPzG+//dg=; b=JlGjdMcZycKCy10A5TSFArTGlANFYneCRY06g30OP7ENeQnaPa+TuSH6boUJxEuIgj fMrFDyPfClkjSI8MlLwry38v7hXfHLs5MgsAzcKz2jN/sPAVK6eFeArg91V/vlX7CKFV zv5AF3JzuVDwVos67yGU5elyEWfem+YUP8cU4UyZHD4Hat/QPxJssiKoLabuveTNIEDd CLIn8+j8jdomyWwOD/jUScFKZhB3XRUVgRvcW++GgwBSJamRrpDjfFWp8X+budxhWj7v PN088UL5e1qZKANmAkOvquWCTOMh0Qa5Vx8EZtfbk+7xfp8FR6r+X4aUc3S1PbUxPnfB OIHQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ueO5vydjulfg6IAl/bg9DbwgRIt1DtlTq0JPzG+//dg=; b=dteAm24MBO4ZpoV2BBFxjjeaKlDysmXaNlkTqa4vOfYmUC9aR3oZDo1eqFMJdKqeJu fAnCPQZ5fbtdXuKuotf+7PqU+QEo69b2j17UfonmO1Vf8zaWMgwuv8b+6rdEuhsQjoFF LqvjBy3NZXgi5MMoMuQXYyWC/R59+Iy+A9BjF4sfeHGmLQpFZD64tJ2RraoXwZXM9+2S qsQckRy37idanm33C2JJRZ6tDZmuAj4w2v7TfrwkCv9u/57DXOPdaZE67oAi+ei7WXII Q8TSoK0OrjjlIskbxURfs9l54vrGc3D/VOSSi6z5zK076ei+TdCHseqVymQps9m0ztZp 7ySA== X-Gm-Message-State: AOAM531TUB2UbDKUHS2XoqMv04SkD2tIY2NbOO7HbwCfVKVSDL0HJurW vGF6Ug+XtW/gd3pzLhKDN8Zzyg== X-Google-Smtp-Source: ABdhPJwgMZnwrzpipl0cAh0PoT+qCjiupZasfLufcUm5wqwMWpfR/cdDE8FzkB8mQBx7dOpFL97/1g== X-Received: by 2002:a2e:a49c:: with SMTP id h28mr22411905lji.489.1643906825174; Thu, 03 Feb 2022 08:47:05 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id n21sm932769lfe.38.2022.02.03.08.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:04 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 4/9] i2c: qcom-cci: don't put a device tree node before i2c_add_adapter() Date: Thu, 3 Feb 2022 18:47:03 +0200 Message-Id: <20220203164703.1712006-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org There is a minor chance for a race, if a pointer to an i2c-bus subnode is stored and then reused after releasing its reference, and it would be sufficient to get one more reference under a loop over children subnodes. Fixes: e517526195de ("i2c: Add Qualcomm CCI I2C driver") Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss Reviewed-by: Bjorn Andersson --- drivers/i2c/busses/i2c-qcom-cci.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index fd4260d18577..cf54f1cb4c57 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -558,7 +558,7 @@ static int cci_probe(struct platform_device *pdev) cci->master[idx].adap.quirks = &cci->data->quirks; cci->master[idx].adap.algo = &cci_algo; cci->master[idx].adap.dev.parent = dev; - cci->master[idx].adap.dev.of_node = child; + cci->master[idx].adap.dev.of_node = of_node_get(child); cci->master[idx].master = idx; cci->master[idx].cci = cci; @@ -643,8 +643,10 @@ static int cci_probe(struct platform_device *pdev) continue; ret = i2c_add_adapter(&cci->master[i].adap); - if (ret < 0) + if (ret < 0) { + of_node_put(cci->master[i].adap.dev.of_node); goto error_i2c; + } } pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC); @@ -656,8 +658,10 @@ static int cci_probe(struct platform_device *pdev) error_i2c: for (--i ; i >= 0; i--) { - if (cci->master[i].cci) + if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap); + of_node_put(cci->master[i].adap.dev.of_node); + } } error: disable_irq(cci->irq); @@ -673,8 +677,10 @@ static int cci_remove(struct platform_device *pdev) int i; for (i = 0; i < cci->data->num_masters; i++) { - if (cci->master[i].cci) + if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap); + of_node_put(cci->master[i].adap.dev.of_node); + } cci_halt(cci, i); } From patchwork Thu Feb 3 16:47:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 540111 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 485C6C433EF for ; Thu, 3 Feb 2022 16:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240972AbiBCQrJ (ORCPT ); Thu, 3 Feb 2022 11:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352351AbiBCQrI (ORCPT ); Thu, 3 Feb 2022 11:47:08 -0500 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76E38C06173B for ; Thu, 3 Feb 2022 08:47:08 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id u14so7151173lfo.11 for ; Thu, 03 Feb 2022 08:47:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=reEPrw9sqpKkfTltdTv+Hj/7serim+AXRNC/H74bgHM=; b=OWFstwB2gFB/0kMFf5Vs2iED+LaRqQrFkoghdt6xdDbpKgVusiczw/ynb+caQoqJPI 5E7YLIQA7OoJbyT5zddPa+PXn7ljWqa4/mV5pCKuy9ApiqTWpEsHbUoiaXrHxAdvSKl0 ghOL9zgfPf7py/2Q5qK8KaH0Nb/CcPMNcOcGzS7azsd2ilENpfP949pZzQ903+0i+Z9R q8CbV5zam8mbQfoKonjZixx4bQ6bkIw4WzDIagv8rgQoN5vy/GnxgmV2H47gbjY/nN34 gf5EVEkAflePAIP6fZg0MoBvqg8I/taHw2OrojZsp9sYZm37uKETy1gjdtkS+FUcq5AZ NJ+g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=reEPrw9sqpKkfTltdTv+Hj/7serim+AXRNC/H74bgHM=; b=yKZTtnZUmotE76Uj0PmxanNVcTaT6zd4QDwz1+4id/kB9kkWO2iBgf1Z9lnK3qFy6m jXqgmCn6+7uJHmeHUF6Tl9a4LX+PHu2kZR6XFDusjhuR/wiUgkdEwJ+EepZ1ByddeyVw 184MYPEL0xqcUg4mNHjyved4JbLlJC8gzgrNr6YOUDe0V6AVhJWIxL/UloJKcI7p5n7Q KLDOKYBysbiLyNLxqDyrFxj7VEcbDGit2r+q94BKqzKD0mVvPOAZ/nHylu26RT75kdiQ 62NSXRPpf7AzLrCx5QghP4rGqJ2ZUW0WnZPigrHUemlynglujHf+0bjG4ilVepJmi5kM vSrA== X-Gm-Message-State: AOAM533dpz60eLgrk4o+Nd4COjN7TZGFJy7+dor8NgqtZiCgI05fVtpV xmsVU0hSpz/X8XFd2SB7oVgGlA== X-Google-Smtp-Source: ABdhPJwPyySBBtqTR0AgfkJFyxuAXgiUcz+WqWhlpUsO74QjQfGbU19Edvm/MIOKZGf9Nc9ZKE5rnA== X-Received: by 2002:a19:c201:: with SMTP id l1mr27512108lfc.485.1643906826872; Thu, 03 Feb 2022 08:47:06 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id p2sm4208017lfh.55.2022.02.03.08.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:06 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 5/9] i2c: qcom-cci: initialize CCI controller after registration of adapters Date: Thu, 3 Feb 2022 18:47:05 +0200 Message-Id: <20220203164705.1712027-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change is wanted to postpone initialization of busses on CCI controller by cci_init() and cci_reset() till adapters are registered, the later is needed for adding I2C bus devices and get correspondent vbus regulators. Signed-off-by: Vladimir Zapolskiy --- drivers/i2c/busses/i2c-qcom-cci.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index cf54f1cb4c57..eebf9603d3d1 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -630,14 +630,6 @@ static int cci_probe(struct platform_device *pdev) val = readl(cci->base + CCI_HW_VERSION); dev_dbg(dev, "CCI HW version = 0x%08x", val); - ret = cci_reset(cci); - if (ret < 0) - goto error; - - ret = cci_init(cci); - if (ret < 0) - goto error; - for (i = 0; i < cci->data->num_masters; i++) { if (!cci->master[i].cci) continue; @@ -649,6 +641,14 @@ static int cci_probe(struct platform_device *pdev) } } + ret = cci_reset(cci); + if (ret < 0) + goto error_i2c; + + ret = cci_init(cci); + if (ret < 0) + goto error_i2c; + pm_runtime_set_autosuspend_delay(dev, MSEC_PER_SEC); pm_runtime_use_autosuspend(dev); pm_runtime_set_active(dev); @@ -663,7 +663,6 @@ static int cci_probe(struct platform_device *pdev) of_node_put(cci->master[i].adap.dev.of_node); } } -error: disable_irq(cci->irq); disable_clocks: cci_disable_clocks(cci); From patchwork Thu Feb 3 16:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 539616 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 2D5DCC433F5 for ; Thu, 3 Feb 2022 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352413AbiBCQrM (ORCPT ); Thu, 3 Feb 2022 11:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352351AbiBCQrL (ORCPT ); Thu, 3 Feb 2022 11:47:11 -0500 Received: from mail-lf1-x130.google.com (mail-lf1-x130.google.com [IPv6:2a00:1450:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC3D6C06173B for ; Thu, 3 Feb 2022 08:47:10 -0800 (PST) Received: by mail-lf1-x130.google.com with SMTP id n8so7248481lfq.4 for ; Thu, 03 Feb 2022 08:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CZkW/5anEw5GrivfXwnX+cAuoc6zYllNAJ26zHVAzzA=; b=clR2GdAbej5ki7kv6ANbm+BsBtf/uWblDU8kRHZz9d+fMUhLt43E9+0alRcE1SpOrK gwv95xz3tiQa8x0hhpdlJFx04GMlSZOVslgt4eJnTDKSe5uLQaJG5PRco4Htg38TVU9G UCWNFIb87/yuo3wEtoZ4NlZhTYKAVgZfJ7eMXQY07EEin5BLRx2wTJTCPkFbo4mUEo1z thcgLPNyGrWNZfMptGs1GNEl/6TC8BfsxfMHMwHDrrHTncdrkIp4Lc8XiaVx4SRXumQJ 2q41azt8xY47UjVFo2BwkZni/RksU8ZTFkAD3dkxLoL1/Yg1vUqEBH9nnizfW7SB78JI 7Dlw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=CZkW/5anEw5GrivfXwnX+cAuoc6zYllNAJ26zHVAzzA=; b=gwEhW/qAmv3DVnF0p16eUhKMSe3s0OYXBJ11cX06SuDpmQ6Pibe/VhpWH8MFQNx7R7 fL5wv6cddVMGd8rRerfOsAOfSiDVdN/Gkbl75jzYaDA2IiCurHxaF8ijLpLwGHvIWn6L qBazTjQTg/I3dJ4QYNiVbKcV1C6Z9RisOMLQhin9zftG3INKNHc+S9JN+YxOpvQsPaAL JiKOvFrA5baKfrd8PAyxHkmUL/5WS98iiTV8SpcdrY14IczbmKpg8L9K82hn8mE/TndL OYrZwh4yqgbOJYHplQlYACcOwLrOQgKTbANKl0PN/uyKXbFAKYaEvah7gTIWVaZHZ2li mG5A== X-Gm-Message-State: AOAM530yg+DCRJo0CCOpiLjnalM1eL4QlYrqBdIM5n6uMytle/MeUWFd s/0uTk8RoAf9HU94f8uhYAffew== X-Google-Smtp-Source: ABdhPJxOV0nyX/VBI6df0uxPSocrpS1o8pdYoUdtjq5jjc48S8Yv+Ohxi4CQzJJTzHLloUa74wuEaw== X-Received: by 2002:a19:7507:: with SMTP id y7mr26804715lfe.224.1643906829297; Thu, 03 Feb 2022 08:47:09 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id t25sm5144559lfr.86.2022.02.03.08.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:09 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 6/9] i2c: qcom-cci: simplify probe by removing one loop over busses Date: Thu, 3 Feb 2022 18:47:07 +0200 Message-Id: <20220203164707.1712048-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org It's possible to slightly simplify cci_probe() function by merging a loop over I2C busses found on CCI controller with a loop which actually registers I2C adapters, the data per I2C bus collected early on probe is not used before calling i2c_add_adapter() since cci_reset() and cci_init() calls were moved to the end of probe. The change is intended to be non-functional. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- drivers/i2c/busses/i2c-qcom-cci.c | 82 +++++++++++++++---------------- 1 file changed, 39 insertions(+), 43 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index eebf9603d3d1..cffc01b2285b 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -540,44 +540,6 @@ static int cci_probe(struct platform_device *pdev) if (!cci->data) return -ENOENT; - for_each_available_child_of_node(dev->of_node, child) { - u32 idx; - - ret = of_property_read_u32(child, "reg", &idx); - if (ret) { - dev_err(dev, "%pOF invalid 'reg' property", child); - continue; - } - - if (idx >= cci->data->num_masters) { - dev_err(dev, "%pOF invalid 'reg' value: %u (max is %u)", - child, idx, cci->data->num_masters - 1); - continue; - } - - cci->master[idx].adap.quirks = &cci->data->quirks; - cci->master[idx].adap.algo = &cci_algo; - cci->master[idx].adap.dev.parent = dev; - cci->master[idx].adap.dev.of_node = of_node_get(child); - cci->master[idx].master = idx; - cci->master[idx].cci = cci; - - i2c_set_adapdata(&cci->master[idx].adap, &cci->master[idx]); - snprintf(cci->master[idx].adap.name, - sizeof(cci->master[idx].adap.name), "Qualcomm-CCI"); - - cci->master[idx].mode = I2C_MODE_STANDARD; - ret = of_property_read_u32(child, "clock-frequency", &val); - if (!ret) { - if (val == I2C_MAX_FAST_MODE_FREQ) - cci->master[idx].mode = I2C_MODE_FAST; - else if (val == I2C_MAX_FAST_MODE_PLUS_FREQ) - cci->master[idx].mode = I2C_MODE_FAST_PLUS; - } - - init_completion(&cci->master[idx].irq_complete); - } - /* Memory */ r = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -630,13 +592,47 @@ static int cci_probe(struct platform_device *pdev) val = readl(cci->base + CCI_HW_VERSION); dev_dbg(dev, "CCI HW version = 0x%08x", val); - for (i = 0; i < cci->data->num_masters; i++) { - if (!cci->master[i].cci) + for_each_available_child_of_node(dev->of_node, child) { + u32 idx; + + ret = of_property_read_u32(child, "reg", &idx); + if (ret) { + dev_err(dev, "%pOF invalid 'reg' property", child); continue; + } + + if (idx >= cci->data->num_masters) { + dev_err(dev, "%pOF invalid 'reg' value: %u (max is %u)", + child, idx, cci->data->num_masters - 1); + continue; + } + + cci->master[idx].adap.quirks = &cci->data->quirks; + cci->master[idx].adap.algo = &cci_algo; + cci->master[idx].adap.dev.parent = dev; + cci->master[idx].adap.dev.of_node = of_node_get(child); + cci->master[idx].master = idx; + cci->master[idx].cci = cci; + + i2c_set_adapdata(&cci->master[idx].adap, &cci->master[idx]); + snprintf(cci->master[idx].adap.name, + sizeof(cci->master[idx].adap.name), "Qualcomm-CCI"); - ret = i2c_add_adapter(&cci->master[i].adap); + cci->master[idx].mode = I2C_MODE_STANDARD; + ret = of_property_read_u32(child, "clock-frequency", &val); + if (!ret) { + if (val == I2C_MAX_FAST_MODE_FREQ) + cci->master[idx].mode = I2C_MODE_FAST; + else if (val == I2C_MAX_FAST_MODE_PLUS_FREQ) + cci->master[idx].mode = I2C_MODE_FAST_PLUS; + } + + init_completion(&cci->master[idx].irq_complete); + + ret = i2c_add_adapter(&cci->master[idx].adap); if (ret < 0) { - of_node_put(cci->master[i].adap.dev.of_node); + of_node_put(child); + cci->master[idx].cci = NULL; goto error_i2c; } } @@ -657,7 +653,7 @@ static int cci_probe(struct platform_device *pdev) return 0; error_i2c: - for (--i ; i >= 0; i--) { + for (i = 0; i < cci->data->num_masters; i++) { if (cci->master[i].cci) { i2c_del_adapter(&cci->master[i].adap); of_node_put(cci->master[i].adap.dev.of_node); From patchwork Thu Feb 3 16:47:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 540110 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 D95D6C43217 for ; Thu, 3 Feb 2022 16:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352385AbiBCQrO (ORCPT ); Thu, 3 Feb 2022 11:47:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352390AbiBCQrN (ORCPT ); Thu, 3 Feb 2022 11:47:13 -0500 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEE65C061714 for ; Thu, 3 Feb 2022 08:47:12 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id u14so7151681lfo.11 for ; Thu, 03 Feb 2022 08:47:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IvlQ+rENmCpAj7qWt57rq8vkztahIT254tiNK/GFl+U=; b=RGYSj/148H3f+D2H8wk1BxK28dRoGJwtqGzVRSCRYQucxPxvMoMiPSwiKt2AD++JKC NQ0QxMjgZO91nxgm156s/oid30WWMrjXR5MUs6I2635avbvDCauCyzxsxUN2/V2yILai 04qsOo49g8w5acvv4nEcAkXr/3ayzD2ymLRr0Xi6qiW/MxmwqwT9/EpyzrmBJvnO3JKk 5nK4CHDhv46oN/6LBl6gBSPwtsQZumhL4aNgaTk/bECPxReMD2T4L0N1L/vrt1dhCNJh o9hFAtskvExruweqkHljYNAiD5r0KvDczyBtp4VjZT5slfWWvxWLI4G+XX5qXKXBcP1S OSFA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=IvlQ+rENmCpAj7qWt57rq8vkztahIT254tiNK/GFl+U=; b=GDbmMt+kPZPX3CSbkwN++QDF9CLTTe8ZJji1NybasxEZrn0OxVDO7ixPwglyMucJdR oYcNf/7Z1LOQZy+zR/bYOUsY/E5T6qa6xr2FOwAWl/85aLuVVmGFiw7Cy0Ys/D98tk0T S9mPyIL1dlgZqFALYu9mEUuD8hwaKe1+KfYLaB5y+BFEkYJPUBfLvv4CA9UZAeL/VVlq mLakVKC8WIaUI9DGMtUZRsj67d8KWR80cJbGStccxCjkcGn+fT5fGXCs7Ob+bmpZQMOa e2e83uBysZEPxMdvH6WQgcvkoZyEdC/B83O6YBZ5sqZ7xWefKBTCd1fbwr8yYFUUXFBQ Akbw== X-Gm-Message-State: AOAM531q/LTRIaxy9u0GZEQrM2366N95eDhFb4xejZkqwsEaVR8wEqQx Tyaj+CHdg7nIQ00HOu8EyjRqlA== X-Google-Smtp-Source: ABdhPJz6sKPo+9ZkxBUDlXkYHJdg7d3/h6qngUyHTSDuX3HUIf6lug0Xc48OzPYJPD8wXblrzjPGfw== X-Received: by 2002:ac2:48ac:: with SMTP id u12mr27162061lfg.50.1643906831309; Thu, 03 Feb 2022 08:47:11 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id q11sm3186110lfu.88.2022.02.03.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:10 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 7/9] i2c: qcom-cci: simplify access to bus data structure Date: Thu, 3 Feb 2022 18:47:09 +0200 Message-Id: <20220203164709.1712069-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Trivial non-functional change, which adds an alias to a widely used data location. Signed-off-by: Vladimir Zapolskiy --- drivers/i2c/busses/i2c-qcom-cci.c | 32 ++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index cffc01b2285b..775945f7b4cd 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -593,6 +593,7 @@ static int cci_probe(struct platform_device *pdev) dev_dbg(dev, "CCI HW version = 0x%08x", val); for_each_available_child_of_node(dev->of_node, child) { + struct cci_master *master; u32 idx; ret = of_property_read_u32(child, "reg", &idx); @@ -607,32 +608,33 @@ static int cci_probe(struct platform_device *pdev) continue; } - cci->master[idx].adap.quirks = &cci->data->quirks; - cci->master[idx].adap.algo = &cci_algo; - cci->master[idx].adap.dev.parent = dev; - cci->master[idx].adap.dev.of_node = of_node_get(child); - cci->master[idx].master = idx; - cci->master[idx].cci = cci; + master = &cci->master[idx]; + master->adap.quirks = &cci->data->quirks; + master->adap.algo = &cci_algo; + master->adap.dev.parent = dev; + master->adap.dev.of_node = of_node_get(child); + master->master = idx; + master->cci = cci; - i2c_set_adapdata(&cci->master[idx].adap, &cci->master[idx]); - snprintf(cci->master[idx].adap.name, - sizeof(cci->master[idx].adap.name), "Qualcomm-CCI"); + i2c_set_adapdata(&master->adap, master); + snprintf(master->adap.name, + sizeof(master->adap.name), "Qualcomm-CCI"); - cci->master[idx].mode = I2C_MODE_STANDARD; + master->mode = I2C_MODE_STANDARD; ret = of_property_read_u32(child, "clock-frequency", &val); if (!ret) { if (val == I2C_MAX_FAST_MODE_FREQ) - cci->master[idx].mode = I2C_MODE_FAST; + master->mode = I2C_MODE_FAST; else if (val == I2C_MAX_FAST_MODE_PLUS_FREQ) - cci->master[idx].mode = I2C_MODE_FAST_PLUS; + master->mode = I2C_MODE_FAST_PLUS; } - init_completion(&cci->master[idx].irq_complete); + init_completion(&master->irq_complete); - ret = i2c_add_adapter(&cci->master[idx].adap); + ret = i2c_add_adapter(&master->adap); if (ret < 0) { of_node_put(child); - cci->master[idx].cci = NULL; + master->cci = NULL; goto error_i2c; } } From patchwork Thu Feb 3 16:47:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 539615 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 21670C433EF for ; Thu, 3 Feb 2022 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352424AbiBCQrP (ORCPT ); Thu, 3 Feb 2022 11:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352390AbiBCQrP (ORCPT ); Thu, 3 Feb 2022 11:47:15 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE39C06173B for ; Thu, 3 Feb 2022 08:47:14 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id z19so7139053lfq.13 for ; Thu, 03 Feb 2022 08:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LWTTS6cNG1lHs9tV1LFBIhAQTBfTKeF7kFMQ+dBIqKs=; b=A0Ter7ED0JuleUrlJVlwedem5p2FbiGXny2G6lOEAnGixlqgLnJgBQZls9DHKIXnJQ w60a+wcbBiFMba4A1LU5a7+BcldzS96eLqscb5Nph/DznvDw4c6gQ2jwa4GTsrf9d1E7 phwH1C60ayYrRd2g4GAbVwqyAj903v4a0Dm41a0ZBnTXMYDmB2GrMAZUeYGlfXRhM8rX nFw/BMe+cKVSQXPFK4XteWk7cP0oPriTDuMuZ0YZ809JFonTcbwtWqWVri14ubKzmBmK jxNUVmeMtE4LmzJoRDY8jIm+B5iT705WHlRm/Lkg8Y0eQnNn81TEe9sCMXtHDgEX2GYr 7ANw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=LWTTS6cNG1lHs9tV1LFBIhAQTBfTKeF7kFMQ+dBIqKs=; b=uDT3McLPOCiCw44ewmXTT012udCOuiR/QrXg8MbSYegcsZqXzM2SkD/1hJnie8fHKY asBygjgiBdjvm23wlXEcKxQsbdNew+Fp81rXre5hPF2pGkgcSL42FWZgDS5iStMwYZOo vJaFQPOR5OIhfnkeYyrOCxFN6oxPgKW6eRDNexZG7/tLDKDCRo2oFE3HC+dddnSXOTVd f6HeG84XW/fFOO2oHQD5WO2b5SiiaWgn/juZErkR+bsGFXjenttXPrCxq8q6CRP3iYLU mTTnZfTKmfgZda0PoJywAKgYTXmyuWA6KfJH7uhObUoAo1jW9Rlue8BXfQ+YeeKcRkP/ R1eQ== X-Gm-Message-State: AOAM5306FYfp24r9e3M3OsR8KLbcOleJFkNAKnC8lO+Tu2+9G28vV83h FZZwxGNMi/rH6JVdyBN4IsqGG5m8SUYbTtNv X-Google-Smtp-Source: ABdhPJzVBgyfbNzgFxGqTcERYCOl7xleJup4s8UDCnfMoKdrzXgVYTqwGh6bM4XBPIaD2aJ4tfHHjQ== X-Received: by 2002:a05:6512:39c2:: with SMTP id k2mr27282461lfu.53.1643906833201; Thu, 03 Feb 2022 08:47:13 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id p28sm4702488lfo.79.2022.02.03.08.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:12 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 8/9] i2c: qcom-cci: add support of optional vbus-supply regulators Date: Thu, 3 Feb 2022 18:47:11 +0200 Message-Id: <20220203164711.1712090-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The change adds handling of optional vbus regulators in the driver. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- drivers/i2c/busses/i2c-qcom-cci.c | 49 +++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 775945f7b4cd..2fc7f1f2616f 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -11,6 +11,7 @@ #include #include #include +#include #define CCI_HW_VERSION 0x0 #define CCI_RESET_CMD 0x004 @@ -480,6 +481,20 @@ static void cci_disable_clocks(struct cci *cci) static int __maybe_unused cci_suspend_runtime(struct device *dev) { struct cci *cci = dev_get_drvdata(dev); + struct regulator *bus_regulator; + unsigned int i; + + for (i = 0; i < cci->data->num_masters; i++) { + if (!cci->master[i].cci) + continue; + + bus_regulator = cci->master[i].adap.bus_regulator; + if (!bus_regulator) + continue; + + if (regulator_is_enabled(bus_regulator) > 0) + regulator_disable(bus_regulator); + } cci_disable_clocks(cci); return 0; @@ -488,12 +503,30 @@ static int __maybe_unused cci_suspend_runtime(struct device *dev) static int __maybe_unused cci_resume_runtime(struct device *dev) { struct cci *cci = dev_get_drvdata(dev); + struct regulator *bus_regulator; + unsigned int i; int ret; ret = cci_enable_clocks(cci); if (ret) return ret; + for (i = 0; i < cci->data->num_masters; i++) { + if (!cci->master[i].cci) + continue; + + bus_regulator = cci->master[i].adap.bus_regulator; + if (!bus_regulator) + continue; + + if (!regulator_is_enabled(bus_regulator)) { + ret = regulator_enable(bus_regulator); + if (ret) + dev_err(dev, "failed to enable regulator: %d\n", + ret); + } + } + cci_init(cci); return 0; } @@ -593,6 +626,7 @@ static int cci_probe(struct platform_device *pdev) dev_dbg(dev, "CCI HW version = 0x%08x", val); for_each_available_child_of_node(dev->of_node, child) { + struct regulator *bus_regulator; struct cci_master *master; u32 idx; @@ -637,6 +671,21 @@ static int cci_probe(struct platform_device *pdev) master->cci = NULL; goto error_i2c; } + + /* + * It might be possible to find an optional vbus supply, but + * it requires to pass the registration of an I2C adapter + * device and its association with a bus device tree node. + */ + bus_regulator = devm_regulator_get_optional(&master->adap.dev, + "vbus"); + if (IS_ERR(bus_regulator)) { + ret = PTR_ERR(bus_regulator); + if (ret == -EPROBE_DEFER) + goto error_i2c; + bus_regulator = NULL; + } + master->adap.bus_regulator = bus_regulator; } ret = cci_reset(cci); From patchwork Thu Feb 3 16:47:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Zapolskiy X-Patchwork-Id: 540109 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 4B17EC433F5 for ; Thu, 3 Feb 2022 16:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352427AbiBCQrR (ORCPT ); Thu, 3 Feb 2022 11:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239584AbiBCQrQ (ORCPT ); Thu, 3 Feb 2022 11:47:16 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC6CC06173B for ; Thu, 3 Feb 2022 08:47:16 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id b9so7229983lfq.6 for ; Thu, 03 Feb 2022 08:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rr7HzGbHwYsK7mCJe032Gz1nhZI4xO0z3CxPo8njYGo=; b=mPWt8OS5kkir1lqkTGi6VRk0bTG/zhJJYRuPsBsqk7Z1d0LXaZ/0w67JM3h/UgnRDR 2t2K/4pKlfrv+mE/Bmf/4lEd/lhdur8i6ErjnoaVlbJSI02gAlFsz3oBdNjondLIJVmO Qedqiej2VkRXKrMHpt9va4D0vfyTom0iknQpC60ZkqG2gHt6vCVF1SF2vElx6LE4Y45P RIzrkft7ANY5/IxLFCk3excD3XfzYEnMr9CzhcVopD2VQIbt4s+um7ZqCDcvLqctsP56 6oPDsBjUH0D1aS2jZOCOszo1APjyxxNfAbyPgS+Aoq9TR8R5C0GWgT91B4EcJcPBE4rH YxYQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Rr7HzGbHwYsK7mCJe032Gz1nhZI4xO0z3CxPo8njYGo=; b=zZQ2fQW3/mkh4kSv5TA+YsShxdC2s3Qy/7En+gVb82G2Rn627jMMhNSxOBHSZJTUQR M6w1QlgTYtUcdTbBJRfZZZdRmNi2i54wPtLBWwK7MMzUYRYvavgGC902HyAoVHN2y0Ue 6aWeE7wRYJntvgyjHxcAsOFB4MScf5TuHZ+dqjJMjbMEB6m2A1rQ1NaqMtHvduM0BB4o kVgbFKqxIpHGPOgRyMmMiuHBFBEzlCZdZp7f5b81+relGgx4UHu4x7KSdSYTnv+s10RV tkmhvJx0g883fknV5Jc9mnH04uYzrhpBJPrLwISRpxjQFO6xADSOM7BxNZIXdlriMfb/ Qkcw== X-Gm-Message-State: AOAM533tHQQfeNWuymSp6py91fKvTwglIUMc/biEvaqpx/WlG6+C8OsI 6Z9r7pKGsTPtKEvPNwUYDjkU+Bz2eA6Y/xHU X-Google-Smtp-Source: ABdhPJzLv3v+160PG42pegKfiCZr0PqsC6hWIE/uZgxt8u/3PELJ6uBFSD6FQKwUtZyVSqDjZIQ0zg== X-Received: by 2002:a05:6512:10ce:: with SMTP id k14mr26190370lfg.210.1643906834991; Thu, 03 Feb 2022 08:47:14 -0800 (PST) Received: from localhost.localdomain (88-113-46-102.elisa-laajakaista.fi. [88.113.46.102]) by smtp.gmail.com with ESMTPSA id f10sm4756433lfk.209.2022.02.03.08.47.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Feb 2022 08:47:14 -0800 (PST) From: Vladimir Zapolskiy To: Loic Poulain , Robert Foss Cc: Wolfram Sang , linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: [PATCH 9/9] i2c: qcom-cci: add sm8450 compatible Date: Thu, 3 Feb 2022 18:47:13 +0200 Message-Id: <20220203164713.1712111-1-vladimir.zapolskiy@linaro.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> References: <20220203164629.1711958-1-vladimir.zapolskiy@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add QCOM SM8450 specific compatible for CCI controller, which is equal to CCI controllers found on QCOM SDM845 and QCOM SM8250 SoCs. Signed-off-by: Vladimir Zapolskiy --- drivers/i2c/busses/i2c-qcom-cci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-qcom-cci.c b/drivers/i2c/busses/i2c-qcom-cci.c index 2fc7f1f2616f..e625857fde41 100644 --- a/drivers/i2c/busses/i2c-qcom-cci.c +++ b/drivers/i2c/busses/i2c-qcom-cci.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 // Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. -// Copyright (c) 2017-20 Linaro Limited. +// Copyright (c) 2017-2022 Linaro Limited. #include #include @@ -822,6 +822,7 @@ static const struct of_device_id cci_dt_match[] = { { .compatible = "qcom,msm8996-cci", .data = &cci_v2_data}, { .compatible = "qcom,sdm845-cci", .data = &cci_v2_data}, { .compatible = "qcom,sm8250-cci", .data = &cci_v2_data}, + { .compatible = "qcom,sm8450-cci", .data = &cci_v2_data}, {} }; MODULE_DEVICE_TABLE(of, cci_dt_match);