From patchwork Wed Nov 16 10:21:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Armstrong X-Patchwork-Id: 20878 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp62422wru; Wed, 16 Nov 2022 02:23:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf4oeHWlz6woECy4UMHJc5d7moJTpjIshLj9hrWzrxieQFjpSxJdIPm9a41ILAewuJ+7+dY/ X-Received: by 2002:aa7:d281:0:b0:462:79ec:55eb with SMTP id w1-20020aa7d281000000b0046279ec55ebmr17912077edq.151.1668594198772; Wed, 16 Nov 2022 02:23:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668594198; cv=none; d=google.com; s=arc-20160816; b=xl+odf1lSU3xNExOfLUeooOXtuI6jB9aZGOllVGhG+nBrV1zIdzq0AEZRZDZujNi/p VTX47a3ODLhKLvbOmce0RACKgEsu+rnZ4qZ5G2c+DsoutvyTbWwFuOgQ6Trn4DUxzZ6c g/LGZAZpNvVSirl3YNEhTbztxMOa2bcVykVgeRb4O5p45n4ye675I9GwdXVg+khx7qKL 22goMFwBl8UF4q7AGsFXq9RamrxoqVQAm81CkONHQw8uGTGBvblZlUaJZSevbZEYpZEH JEr6JKx/XwnC+c75yi8w86p/dvi58upZkzv9T7H2ecKdK/p7iZFNq4LK1crN/PmM7d6h bvMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=GhLipikR7108xt+mQGUUpQ8DfphnyPitqRKsqUFWNfk=; b=iLlJLNWPfao5Q/MOH7ZJDggCUh/lVfjpTJPHr2xMA4/NgDrWHza85H5pB8usoaOTeM nncsk9Zuztp4uYbPkEN5YAhKKvWArne+CjWY9hrA/eSwwcoxTl8bmst+0Z7F6MErt68Q +L2JbykInz2w0sN0x2xjhHKZPoXuycROvJJ+4W0nuGEsc0RroIicbcZ/ElYhAHMUocEY TWkQYMmF9/fcklRrx4y+/Ko9tK2UaE8XoJrd2nYWa+MCgItHOZX5j/K+35hD7t49SELv eqiH3zDnFPpvSMqrNYoQRzP5uN+UufTxxUK/g/KWVy5YvsARaEDVB9Cq0X70qi04+iQM lYjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uzGLOFK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b23-20020aa7c917000000b00456e33b69e1si11799847edt.347.2022.11.16.02.22.52; Wed, 16 Nov 2022 02:23:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uzGLOFK7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238725AbiKPKWZ (ORCPT + 99 others); Wed, 16 Nov 2022 05:22:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233569AbiKPKVy (ORCPT ); Wed, 16 Nov 2022 05:21:54 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 167E92314E for ; Wed, 16 Nov 2022 02:21:53 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id cl5so29115553wrb.9 for ; Wed, 16 Nov 2022 02:21:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=GhLipikR7108xt+mQGUUpQ8DfphnyPitqRKsqUFWNfk=; b=uzGLOFK7HLGuw5ikgGebxyMvFO/YG/0WPs2EZK7lQL9wOc+ovH2QiL5jyClmZDb++I TgLk9JewfYlZ/tM/I95VAvNpDv96sWTM/cY2ien470qNK+LusJG39CWx7+4JTu3oC5LA d/mcWzx5lhj+coxrVaUMCsjoOor4VX3d5xBRYPj136r65+oAEsXRnznn9Kwg53YgMxmX QKAime4lKE6UtHKOD1dnZZI6mgJ44YCn4BZS9Q4MmnBhg09XTl/sV/8qKkJ3sflK8jHA rm5grcfNAuPXIv3yeGhb8d0r0+GbB0tre0Q5bXNmWygQsSHHkUqG3NM/jDyMd6Z92dCx usiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GhLipikR7108xt+mQGUUpQ8DfphnyPitqRKsqUFWNfk=; b=ifw6Gj/KXj6OWGghb9OJlLuJHDKXWEjuwI4XzWAjeBADM90rYN8aL4VaPgSaaLxQAr LwEPkTIKv7A1CKVJvNPQ56knNzZbSTxsEcuPe7OPi+ZIBwYf4oqCNKqDpJWSnQmYqBrN vWZOi6T3vwb5JoPnW4vI9zDP5peHLw2IBJHITRBIL7m+4WpKHavHBSm6RyJfrNkEK4W4 0ZC08VEzaGkEP2CqJL4kOo1SILpJkfif4uVQ+NGd8bwPCziIvYpqiiMObsT68S43uBga Qq4A2jiJ5DN/3xU+KfX15W2sWFsJ4Zq1LZLKbYTsWL+8yWmbM7q2Y4XA66sn6Uxwn2VL mMjw== X-Gm-Message-State: ANoB5pkGuv0zKcvNauya3/lJLTQBB44KKnq5gCpqa7qbmNtf0XljVt+F bE/oeW9Tb3aPLrf5hSVb+6yBUQ== X-Received: by 2002:adf:e2d1:0:b0:236:8638:121a with SMTP id d17-20020adfe2d1000000b002368638121amr12635622wrj.188.1668594111621; Wed, 16 Nov 2022 02:21:51 -0800 (PST) Received: from arrakeen.starnux.net ([2a01:e0a:982:cbb0:52eb:f6ff:feb3:451a]) by smtp.gmail.com with ESMTPSA id o5-20020a05600c510500b003b4ff30e566sm6133615wms.3.2022.11.16.02.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 02:21:51 -0800 (PST) From: Neil Armstrong Date: Wed, 16 Nov 2022 11:21:50 +0100 Subject: [PATCH 3/6] soc: qcom: geni-se: add desc struct to specify clocks from device match data MIME-Version: 1.0 Message-Id: <20221114-narmstrong-sm8550-upstream-i2c-master-hub-v1-3-64449106a148@linaro.org> References: <20221114-narmstrong-sm8550-upstream-i2c-master-hub-v1-0-64449106a148@linaro.org> In-Reply-To: <20221114-narmstrong-sm8550-upstream-i2c-master-hub-v1-0-64449106a148@linaro.org> To: Rob Herring , Konrad Dybcio , Andy Gross , Krzysztof Kozlowski , Bjorn Andersson Cc: linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Neil Armstrong X-Mailer: b4 0.10.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749647830499450473?= X-GMAIL-MSGID: =?utf-8?q?1749647830499450473?= The I2C Master Hub is a stripped down version of the GENI Serial Engine QUP Wrapper Controller but only supporting I2C serial engines without DMA support. This prepares support for the I2C Master Hub variant, by moving the required clocks list to a new desc struct then passing it through the compatible match data. Signed-off-by: Neil Armstrong Reviewed-by: Konrad Dybcio --- drivers/soc/qcom/qcom-geni-se.c | 57 +++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 14 deletions(-) diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c index a0ceeede450f..f4f54d92a01a 100644 --- a/drivers/soc/qcom/qcom-geni-se.c +++ b/drivers/soc/qcom/qcom-geni-se.c @@ -81,19 +81,31 @@ */ #define MAX_CLK_PERF_LEVEL 32 -#define NUM_AHB_CLKS 2 +#define MAX_CLKS 2 /** * struct geni_wrapper - Data structure to represent the QUP Wrapper Core * @dev: Device pointer of the QUP wrapper core * @base: Base address of this instance of QUP wrapper core - * @ahb_clks: Handle to the primary & secondary AHB clocks + * @clks: Handle to the primary & optional secondary AHB clocks + * @num_clks: Count of clocks * @to_core: Core ICC path */ struct geni_wrapper { struct device *dev; void __iomem *base; - struct clk_bulk_data ahb_clks[NUM_AHB_CLKS]; + struct clk_bulk_data clks[MAX_CLKS]; + unsigned int num_clks; +}; + +/** + * struct geni_se_desc - Data structure to represent the QUP Wrapper resources + * @clks: Name of the primary & optional secondary AHB clocks + * @num_clks: Count of clock names + */ +struct geni_se_desc { + unsigned int num_clks; + const char * const *clks; }; static const char * const icc_path_names[] = {"qup-core", "qup-config", @@ -496,8 +508,7 @@ static void geni_se_clks_off(struct geni_se *se) struct geni_wrapper *wrapper = se->wrapper; clk_disable_unprepare(se->clk); - clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks), - wrapper->ahb_clks); + clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks); } /** @@ -528,15 +539,13 @@ static int geni_se_clks_on(struct geni_se *se) int ret; struct geni_wrapper *wrapper = se->wrapper; - ret = clk_bulk_prepare_enable(ARRAY_SIZE(wrapper->ahb_clks), - wrapper->ahb_clks); + ret = clk_bulk_prepare_enable(wrapper->num_clks, wrapper->clks); if (ret) return ret; ret = clk_prepare_enable(se->clk); if (ret) - clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks), - wrapper->ahb_clks); + clk_bulk_disable_unprepare(wrapper->num_clks, wrapper->clks); return ret; } @@ -887,11 +896,21 @@ static int geni_se_probe(struct platform_device *pdev) return PTR_ERR(wrapper->base); if (!has_acpi_companion(&pdev->dev)) { - wrapper->ahb_clks[0].id = "m-ahb"; - wrapper->ahb_clks[1].id = "s-ahb"; - ret = devm_clk_bulk_get(dev, NUM_AHB_CLKS, wrapper->ahb_clks); + const struct geni_se_desc *desc; + int i; + + desc = device_get_match_data(&pdev->dev); + if (!desc) + return -EINVAL; + + wrapper->num_clks = min_t(unsigned int, desc->num_clks, MAX_CLKS); + + for (i = 0; i < wrapper->num_clks; ++i) + wrapper->clks[i].id = desc->clks[i]; + + ret = devm_clk_bulk_get(dev, wrapper->num_clks, wrapper->clks); if (ret) { - dev_err(dev, "Err getting AHB clks %d\n", ret); + dev_err(dev, "Err getting clks %d\n", ret); return ret; } } @@ -901,8 +920,18 @@ static int geni_se_probe(struct platform_device *pdev) return devm_of_platform_populate(dev); } +static const char * const qup_clks[] = { + "m-ahb", + "s-ahb", +}; + +static const struct geni_se_desc qup_desc = { + .clks = qup_clks, + .num_clks = ARRAY_SIZE(qup_clks), +}; + static const struct of_device_id geni_se_dt_match[] = { - { .compatible = "qcom,geni-se-qup", }, + { .compatible = "qcom,geni-se-qup", .data = &qup_desc }, {} }; MODULE_DEVICE_TABLE(of, geni_se_dt_match);