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: 539750 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 73713C4321E for ; Thu, 3 Feb 2022 16:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352377AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352323AbiBCQqi (ORCPT ); Thu, 3 Feb 2022 11:46:38 -0500 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 264E4C061714 for ; Thu, 3 Feb 2022 08:46:38 -0800 (PST) Received: by mail-lj1-x22d.google.com with SMTP id q22so4741843ljh.7 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=cxCitMW1ZNJqzo7YR6c6gkygR049c0UB5r1/sr/g8FY8arF2lhjfhDl+03dv+2rLv6 3FR4sv7j8g2EhhehX9xwKZsiaXNyzJqfrrKQWv8qEyZcGwhyZ01XP3m2xxzaJI3jMVxy oz5Vyii7ijqYh2KjXshrZEhMIR0XZqj0Al9kc2pDBL6dY0It/bbWx5ZXKVsYB3EcYKG0 KM5r4VoxCj7/kn1chfgVsMaUmpG4jAiee/EdUOo8yEEM+Yjid/yoC+vQS3WtE7PJMv7U H0ObtD244U1tvkFfzDjGKEZPmQoEQgFlAlZswxYS5zLqpTXm2IOMdfuEJh/v3JXZMalS RW7g== X-Gm-Message-State: AOAM533itrwG39cMv+ClGjxFHvAxzk9FPilUxAqiEVOfcYdPhIPyYV8X W34CL3AQqGqqLQsWm2nbaHfycA== 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-i2c@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: 539954 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 A000EC4167B for ; Thu, 3 Feb 2022 16:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347468AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240972AbiBCQqj (ORCPT ); Thu, 3 Feb 2022 11:46:39 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7DF0C061741 for ; Thu, 3 Feb 2022 08:46:38 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id f10so7180743lfu.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=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=Y2f0wlmPlT2JsYgg/JRh5ReIty1ECNmCjB2XYqPUIXOceYSSw7VrQRVWio8RaHQPGc K+Y0imzbLXIiAr/WQtc2A0cuvfpsL5CE2ubriqKjUgvBPHMBc6qfW5+AR+X4EgGALiPh /uN5SrqljoRPsvZ3BLvmNGREnGNTpr193w0piATdPfy9HSgegj6DoSgmoOE7Y4K4QhJb T5K+33fM94GImrNomVKucg9KheLSWGG8rtO/p/REQRwv4E66wKRSegxfdKR5lJs3lFKK tUikYTqji7rAR0aTPm4lmklNLLu2m9oRDGgFLnWIj3bthnogVYSXObDed0io8mSCG/hZ bdXQ== X-Gm-Message-State: AOAM532aByXkTovD3kU1/wJJ6VGW4Ei/IyyroRCW18Vr8YUImIctcAp/ CBXE9qA4titISNZHtLMG5x9aXNPcqeCnc45T 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-i2c@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 --- 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: 539749 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 79072C433EF for ; Thu, 3 Feb 2022 16:47:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbiBCQrF (ORCPT ); Thu, 3 Feb 2022 11:47:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231319AbiBCQrF (ORCPT ); Thu, 3 Feb 2022 11:47:05 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2092C061714 for ; Thu, 3 Feb 2022 08:47:04 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id u6so7169504lfm.10 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=RYoyp22T80mK+Yxyv3LQ29LR228mJ/+gPjjllwOw3ZQx2ZWLmgFiV+wigCHo3umWGA 7lMaFzEh+Se39Pg3AFV2Obz/qmiCpKaS73klZFq+LY19UXQ1ZA/y1GjcmIKoo+/jGsr4 99RmeZG+L0KMvoptcyvPasEJrvpw+urZLibg4BvwY6ueMUs0LZvQVOsi1sHgIldhSM19 o3tQhjTVshowP99o3gdSZTkh2KbCGnNrqlRwGVe+0t9KB91SG3iwv84zr9JmILezfBJY OhbR18zcL4JDYRaMHygih1R8gkSSMpG7vkXGxJp2OOk8yeKTfS55Ch4qVwv/2Gbzkfpv 5ivA== X-Gm-Message-State: AOAM531m3G0znq3t6s0Muftw6SE6qe991o79HSLw9Jb7M3ZbmV3gnwRW Z8aJPFuCng2SUR75A3yAsE/vXQ== 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-i2c@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 Reviewed-by: Robert Foss Reviewed-by: Bjorn Andersson --- 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: 539953 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 C3864C433FE for ; Thu, 3 Feb 2022 16:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352403AbiBCQrI (ORCPT ); Thu, 3 Feb 2022 11:47:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352390AbiBCQrH (ORCPT ); Thu, 3 Feb 2022 11:47:07 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE302C061714 for ; Thu, 3 Feb 2022 08:47:06 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id z20so4753392ljo.6 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=s52DYPq7GKllsCzpCOheYCZtf2YjC40mbgASdAk4h/KTswvwwA1rFrgdizzfEY3SQ1 hI1ev/5IVcyYTnn8c0fDcvGsluGRdOVNjPmlE7Su5lkpIa+gzXeKjvQQcGwSDQSEdfbM RNY/zCyRZTZr1TeCVAIY9FOdTqq56GDcVu6h6SNE6c4VW4x9gdDbWORmG3I6lGP2GP14 kKhBUmwS1EgHBEO42ISpoJH4QhMXLW5iP2RvyG7vgBshG4dRSHxwV3qyiQjLe/plF5wP zSAlsmitF2I4zWwNtrY7FCuX/MeONt+gdkshL48H9E4AOXkQMYRptWX4uR0D5R1gq+pR AEJg== X-Gm-Message-State: AOAM531i+yvm7g5TzznHrFYPzOWZtwa8MLUEQ/xwSpDZbPv+DWbkYUEs F4cwFyO/oU7aXMjcgp++SN5oaQ== 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-i2c@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: 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: 539748 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 61DAAC4332F for ; Thu, 3 Feb 2022 16:47:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231319AbiBCQrJ (ORCPT ); Thu, 3 Feb 2022 11:47:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352408AbiBCQrI (ORCPT ); Thu, 3 Feb 2022 11:47:08 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75DF6C061714 for ; Thu, 3 Feb 2022 08:47:08 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id o12so7138505lfg.12 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=1ZhatETEJ/oxXcrmvrer1nQGqF7NjQmM/EOJ20lzGn6oZZgAB/oAf6xqYvv+hFX84Q Al0dWswk+3p+wWlnlSIZigXTe7wu/RsyGnEnlkNwECpNyfa56rOTf9PvGxuNk0T1Tpr/ 9BECwIGgtU03OuamGEcsSOTjTmbEPidGtjgvG8uR9COrH3oYk7ATy2PGbwgcXzXtG42t WjW8VLyfATMklfu1dOfk81tdw/mSosfkOZ6Maj7/JP1XZR9p79/F7BlF9ao/YKCDt2nz pl77jsVA/VJ5IUyICXmD93xBpXb0quTNpSj8YaNwaQAV9aDc7iy1RvUqGht35mzXMSNn onOA== X-Gm-Message-State: AOAM530RsMajYGyWQYeQjoKs/ut+KH5S56O1cIIlXjsRr6IkoGX+ADy9 jytVX4ZWrslQpkjVXmRZktW70A== 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-i2c@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: 539952 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 3C8BDC433EF for ; Thu, 3 Feb 2022 16:47:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352408AbiBCQrM (ORCPT ); Thu, 3 Feb 2022 11:47:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242660AbiBCQrL (ORCPT ); Thu, 3 Feb 2022 11:47:11 -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 EB7C2C061714 for ; Thu, 3 Feb 2022 08:47:10 -0800 (PST) Received: by mail-lf1-x12f.google.com with SMTP id x23so7356515lfc.0 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=GEGweWEvUvpcTzYqNSGNH2O9RkcnAoMWcGP7V7FtikLFEDtFMaNi+UHa+DePngTDtF InBHmz/pou0BRqTxLuwO1lbkAxVgDkWT7TobKhou6XkI21SR4c4Dk3s07leCdhja9YcE 2GYfCB66Ktt8OTDYeQn/qXGQci8lEbpF0CHOOwJPiQBaGmFqy8V5auBzKSZjri8rEhn/ oteGF4O7jV73Qub6Yk93HlOysKbS924gqHIvkvTyuHYS1OlgA4PeXNnY6u6xIN4RilVI 6M9jNOAduqD/nncTNVWLG9bYBS3Hl7uXxM21+fuj1D3X3AIgTAbTlhaEfW5NpP1OQldV 8QqA== X-Gm-Message-State: AOAM530qlXHDUUKG24Qb0dNkaPmhMolPwERITxaWGhcGAFCWW+tvzcMV Se1wUicS4Lmbqd0S/Dk8sU0XjQ== 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-i2c@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: 539747 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 C94A3C4332F for ; Thu, 3 Feb 2022 16:47:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352351AbiBCQrO (ORCPT ); Thu, 3 Feb 2022 11:47:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242660AbiBCQrN (ORCPT ); Thu, 3 Feb 2022 11:47:13 -0500 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF323C06173B for ; Thu, 3 Feb 2022 08:47:12 -0800 (PST) Received: by mail-lf1-x12e.google.com with SMTP id l27so2454372lfe.1 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=v0CBqtErUj3e0jYg/4J1lOIqXyeISmLoXXu+2omn7PhzOJoWQMXNYvMZKRRwSHV+pu 3XR7oJ2Zl3Il/aM0nLTcF15HmV9yfohLz/cH14J4PxkNFCiH/058spXc51qay8iHAdTe TI8gnsTQT/iTwZ6YIjHtMyEobgS2yUZdKaejbf5RH/8TxYieSroY66ajRHP3t+iHP8Zs SpwKiIAGqrirZXwRoLitcfKhYU7ACdAbpHxgBkDPr6LXTUReSiKW3POVHdHkN/PewHut ZjgeOU3dm7v7mq6d/U9I1WSflC8ZLAgMNiVwJwDKV7OvghI+Re2gJ5Z5+4j/CD9ADIdX rkjQ== X-Gm-Message-State: AOAM530ZSFZj95eEt6Rq2ZwGs/Cjmrmm6fErJmmEYUpqmntHx6LerIXs 3fXfSFoROwt4W/ZCjEjYzZiIyQ== 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-i2c@vger.kernel.org Trivial non-functional change, which adds an alias to a widely used data location. Signed-off-by: Vladimir Zapolskiy Reviewed-by: Robert Foss --- 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: 539951 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 3051DC433F5 for ; Thu, 3 Feb 2022 16:47:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242660AbiBCQrP (ORCPT ); Thu, 3 Feb 2022 11:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352419AbiBCQrP (ORCPT ); Thu, 3 Feb 2022 11:47:15 -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 CD2CCC061714 for ; Thu, 3 Feb 2022 08:47:14 -0800 (PST) Received: by mail-lf1-x12b.google.com with SMTP id f10so7184343lfu.8 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=If1vnXCs4yQEMFtTIhCiIcvZthdIMjhsKXvq9zLa03LfoMdJn3Mnn7pgIbqKNwcOOC HA4silBrS2OHjccGbSN1BoA+XDtbc3cYzlw1WoNr59invB8krkRI5TkK54jHY0Twvf9v 5zleuNkF7U8fuUZyKO4ZrfBVxS1Fl3XRlyKV1FVGVxzC+A5LmZ+QHtjH0rh3eKwhGYLR +2NUqDnO6CgRAYv2T0QREIzkCvYM+5k/asvhMpbQ77Kyhf1VUXtunVc9ED5lBuM1amne 97PHFi7y7oaPls5px/x0g7TcuOJhtL9pAWMR/5xrvrkHHWJsP8cOEGeccpaJi+3VVDU7 2qjw== X-Gm-Message-State: AOAM531TspqVWeTzkT+vTAKeotZvk8uYiPdVH2woz8QBBZ/BfcsQpLI1 T7JrTx6flks+lfHqTspz9ifZBg== 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-i2c@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: 539746 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 6019CC433FE for ; Thu, 3 Feb 2022 16:47:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352426AbiBCQrR (ORCPT ); Thu, 3 Feb 2022 11:47:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352390AbiBCQrQ (ORCPT ); Thu, 3 Feb 2022 11:47:16 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D7FFC061714 for ; Thu, 3 Feb 2022 08:47:16 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id n8so7249073lfq.4 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=e3rNckwBsQ51WBrThSnH58I606X75Rm4+yDMrSpFP/9Ov+exXQr1WMqhe1wRynusQC dRybbGYv3VrfzxjA3HbeI50z0ATLtHLEJ5JnwodyBleApCR0fpVZM+FzKVxLrbIqxxWN wVM0WY3OHGwmH+wGw/57F4jEJ9x/K9ioYBPJPSvdHgE3rOnNJ7w2blX95OF0c2ySR2Gs WMtMzLMD0Pb/et5vVDWV/WojHRxCo2HMrh+bsy6fiAqtWoeF/6SB4zoU8xtjIsgBLcVB vbIDi8XGIYaKZ+WUqkho1Ywk7gQ7c3rmpfDg6KyyTeLMFfklmioLCs1dlT5FHjATyfv1 VTnQ== X-Gm-Message-State: AOAM530FlN5c1dJdlRzPXuhXkrE1ernM5kL5OYRg7mqnRt/pKY6M1/gE wW9KVewLOmOLZlriJO0p7vf2uw== 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-i2c@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 Reviewed-by: Robert Foss --- 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);