Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1033962lqp; Fri, 22 Mar 2024 03:45:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU8crNymnRPbajxPvunOTPg+1yQ4ej/9aSNuPFbBodPd0cSM/zh6KTjqB3InWDa681RmqC8m5HcSHns5dMFkT24p2SpyerETHyP9SuNsA== X-Google-Smtp-Source: AGHT+IHNfXRxhYKNHT20wzwyJ85nZs949EUIYaqT1zOP8Y8zFY3S30xYUeTsVUvj5d9cFQkaCRZY X-Received: by 2002:a05:6870:d2a0:b0:222:8943:df2b with SMTP id d32-20020a056870d2a000b002228943df2bmr2045158oae.16.1711104322452; Fri, 22 Mar 2024 03:45:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711104322; cv=pass; d=google.com; s=arc-20160816; b=NwgyS7odt3vjopsG5PNI4Efzyz5kfuNYxevSMRj7f/N2Vdv6L6rcEsYSONCWubBb8A iz3EHo3zn5Kk2RputIn7uDvR8fnh9p7Y/2mZly2D2cyqQK6SwkS9EafC9J5KrtyUOeVp 4kgZrTsWEhzGmzlZPZXd1UHTjkdasrUTQpY05/dEf1ToD53J85hVQS9A1YSxmVlRK6iF T/t86p/e/OauuQtV/SuQAfp3zqf1d80Wu1mhUxYKkfV+kxqByVzyzawDglNiepQURfTD pjvdV4g4Iq7eC+LTYIrPxtu1qTvuM70/bJojU1qgyOfURmbDXghzTZvI0bdc6M9CM2lj wckw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :date:message-id:dkim-signature; bh=Ijz4cnwmta4DwRjOoVv/yS9+lUjTkF7NKjIpyzpOrv4=; fh=+wyYD4r3GEstL7unj60LNw14zNSfzbsVTPx2OzEmm28=; b=Ne71q1Ds7cxuycv1tCTYKDf1WYEUiS+Vlwmy4lROEVDxZH2Oad6kroRJsLB2FDGyYr FeiY2Nco4GUswAKRiczI4I9kwB4lhQ91xL2hJWORSMwbcIJzcGBbPGpicYLCJvyy6P0m AgY2YPyBBzvHZauglq3taNFlCP1PLbOZuF6LJkj/zY8bu+JFTza+33Ee0EmycipfK1/r gDftXeLyl3X4auCFYZtDGoujEnEfxa1xa1ZMygpfOIHO2/gr3/kSGovu35DwEmffEoAY MPEitmsUifeGu7yV4eQUaXqifnHI9QLkj3f8+1xyoHzzg7WKyCtjhKLkkA/Z59sG2WGc lE9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aiVvjJoG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-111320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111320-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v21-20020a63f215000000b005e468bd4cadsi1812145pgh.787.2024.03.22.03.45.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 03:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aiVvjJoG; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-111320-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111320-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EF0A2283163 for ; Fri, 22 Mar 2024 10:45:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4153A3D38D; Fri, 22 Mar 2024 10:45:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="aiVvjJoG" Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88D1A224F2 for ; Fri, 22 Mar 2024 10:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711104314; cv=none; b=qMCedZ8HAN9jpndY7omSm93yprB8oitBaPxwGuFHNdB/eEqr0R6mCxuwrjO0SXPSRTvPpUlS5FoqYv02/I2nYRh0a63iIomGxAnI+nmRxF9JLJ9UKcdStKS7tcjTSXKFZOpI+XuSQ/zLzDBTaP+Rg9vNq75Y+I/YvW29ZwcUvDI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711104314; c=relaxed/simple; bh=jWRuh7EGPZi+az7Aq33aapOL1INFIF3xUm8yZfIfKMU=; h=Message-ID:Date:MIME-Version:From:Subject:To:Cc:References: In-Reply-To:Content-Type; b=jwj3mx/5og+bBrzXEJoXcZLYp7evl/8MtQR11JZh2aLkflWcpxTeWbZrbyhNWjH+M1ynUl95iJ+cen7gAYI8olOjHZz054SH5HEoGXkGghmeCtZGXB4vJgxiXyrxY1Vj5pLmIa2C1o5GGpVMkFCc+rA/vzdKnN1B7ewHBiTRrv0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=aiVvjJoG; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-33ed7ba1a42so1021915f8f.2 for ; Fri, 22 Mar 2024 03:45:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711104310; x=1711709110; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=Ijz4cnwmta4DwRjOoVv/yS9+lUjTkF7NKjIpyzpOrv4=; b=aiVvjJoG80jSLyFxRYRywfwVzM2t3cEK6wFW+rDlM7+Kb8C25AtGPLDwfBaEgXQ2KL Te7NM0ap/2sD4j9y3TiEuCvF1luJuEdWqYK0Jk4igM2//0uxmcdLQLVRSo/X+I/eDaSs rpYue8vOhFCbn7wlKcrTcES3gD8JzLHAwLEgGiAiCsWY1fz+YE7jGQakTcua6QaxwOyC Vlogzmrv2+x4gHOl4VspPwGL/VTD0Z8W5WHonXDE2Ig+rDOvYUYy5tHT6Y3CLFzctct7 IXmgzNSr7mT2cSlKePOR1YvAEQICy08BqoqzCTnORko+nBOPRfcgvmF1zBoNl32NpPxR gulA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711104310; x=1711709110; h=content-transfer-encoding:in-reply-to:organization:autocrypt :content-language:references:cc:to:subject:reply-to:from:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=Ijz4cnwmta4DwRjOoVv/yS9+lUjTkF7NKjIpyzpOrv4=; b=YRfuzaFfbW5F8DH80J78kHIUvHw6ZeyJc5bEG8ZY0kQMVVJ8FVZ/pWNf2/Zfbkl8s0 RpzmYAnbuC93OCls9kvNd7R89OkY1JdBP8BHyRiTdE/iWjSFlBUPOcHbNUp661UpZSt0 +Go5FDZDpbVdztzn+axWQ28HF6IV+S9qXfUu8egmzMxqFTkKZj0oiQkx45UjJHJMtGay lTEZxVPP4grR0yADLzCtgM2dMF3Y98WfcwLpHIYQHbX1PMukDlKFGlVFYfYKBetZxJyw +S8lD0Y4cJm5uEgdaaZxOlkR+WnnaaA9MLhGX6UlDIHeMapXSirYwHFWsIFU1Vm9GQtd FwnA== X-Forwarded-Encrypted: i=1; AJvYcCWIAHaOHYTeGDdL78OIFl11e1ox+6T5+8U2HkpJM0nRS8Th155BowD7dbzmNel5wM4VyP/CUqfNwm2xp+t/DGOjF0lTBksm8HvrHl0S X-Gm-Message-State: AOJu0YwZPUL8Mcy1n60mYbLSbexd6v+DBGayNhAEqC1PPF1ajkU3guzg LwXyPZXnNnOhCNpTYGv/vWamuRtWN5UJqrpc1UbpsOWWmDfRg7lrJhvx7sNvD5qJjENGgnY72Vo r8+Y= X-Received: by 2002:a5d:69d0:0:b0:33e:7f51:c2f9 with SMTP id s16-20020a5d69d0000000b0033e7f51c2f9mr1268500wrw.49.1711104309609; Fri, 22 Mar 2024 03:45:09 -0700 (PDT) Received: from ?IPV6:2a01:e0a:982:cbb0:3ee1:a278:2b57:55f7? ([2a01:e0a:982:cbb0:3ee1:a278:2b57:55f7]) by smtp.gmail.com with ESMTPSA id j1-20020adff001000000b0033e7e9c8657sm1778124wro.45.2024.03.22.03.45.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Mar 2024 03:45:09 -0700 (PDT) Message-ID: <1dc187c1-2005-486f-a9dd-6648cf52ab70@linaro.org> Date: Fri, 22 Mar 2024 11:45:08 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Neil Armstrong Reply-To: neil.armstrong@linaro.org Subject: Re: [PATCH v2 3/7] phy: qcom: qmp-pcie: register second optional PHY AUX clock To: Dmitry Baryshkov Cc: Bjorn Andersson , Konrad Dybcio , Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240322-topic-sm8x50-upstream-pcie-1-phy-aux-clk-v2-0-3ec0a966d52f@linaro.org> <20240322-topic-sm8x50-upstream-pcie-1-phy-aux-clk-v2-3-3ec0a966d52f@linaro.org> Content-Language: en-US, fr Autocrypt: addr=neil.armstrong@linaro.org; keydata= xsBNBE1ZBs8BCAD78xVLsXPwV/2qQx2FaO/7mhWL0Qodw8UcQJnkrWmgTFRobtTWxuRx8WWP GTjuhvbleoQ5Cxjr+v+1ARGCH46MxFP5DwauzPekwJUD5QKZlaw/bURTLmS2id5wWi3lqVH4 BVF2WzvGyyeV1o4RTCYDnZ9VLLylJ9bneEaIs/7cjCEbipGGFlfIML3sfqnIvMAxIMZrvcl9 qPV2k+KQ7q+aXavU5W+yLNn7QtXUB530Zlk/d2ETgzQ5FLYYnUDAaRl+8JUTjc0CNOTpCeik 80TZcE6f8M76Xa6yU8VcNko94Ck7iB4vj70q76P/J7kt98hklrr85/3NU3oti3nrIHmHABEB AAHNKk5laWwgQXJtc3Ryb25nIDxuZWlsLmFybXN0cm9uZ0BsaW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q7fUzbn/KdlhA8XPGzwGRy 4zcsPWvwnXgfe5tk680fEKZVwOZKIEuJC3v+/yZpQzDvGYJvbyix0lHnrCzq43WefRHI5XTT QbM0WUIBIcGmq38+OgUsMYu4NzLu7uZFAcmp6h8g Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 22/03/2024 11:41, Dmitry Baryshkov wrote: > On Fri, 22 Mar 2024 at 11:43, Neil Armstrong wrote: >> >> The PCIe Gen4x2 PHY found in the SM8[456]50 SoCs have a second clock, >> add the code to register it for PHYs configs that sets a aux_clock_rate. >> >> In order to get the right clock, add qmp_pcie_clk_hw_get() which uses >> the newly introduced QMP_PCIE_PIPE_CLK & QMP_PCIE_PHY_AUX_CLK clock >> IDs and also supports the legacy bindings by returning the PIPE clock >> when #clock-cells=0. >> >> Signed-off-by: Neil Armstrong > > Reviewed-by: Dmitry Baryshkov > > Small question below. > >> --- >> drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 78 ++++++++++++++++++++++++++++++-- >> 1 file changed, 75 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c >> index e8da2e9146dc..6c9a95e62429 100644 >> --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c >> +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c >> @@ -22,6 +22,8 @@ >> #include >> #include >> >> +#include >> + >> #include "phy-qcom-qmp-common.h" >> >> #include "phy-qcom-qmp.h" >> @@ -2389,6 +2391,9 @@ struct qmp_phy_cfg { >> >> /* QMP PHY pipe clock interface rate */ >> unsigned long pipe_clock_rate; >> + >> + /* QMP PHY AUX clock interface rate */ >> + unsigned long aux_clock_rate; >> }; >> >> struct qmp_pcie { >> @@ -2420,6 +2425,7 @@ struct qmp_pcie { >> int mode; >> >> struct clk_fixed_rate pipe_clk_fixed; >> + struct clk_fixed_rate aux_clk_fixed; >> }; >> >> static inline void qphy_setbits(void __iomem *base, u32 offset, u32 val) >> @@ -3686,6 +3692,62 @@ static int phy_pipe_clk_register(struct qmp_pcie *qmp, struct device_node *np) >> return devm_clk_hw_register(qmp->dev, &fixed->hw); >> } >> >> +/* >> + * Register a fixed rate PHY aux clock. >> + * >> + * The _phy_aux_clksrc generated by PHY goes to the GCC that gate >> + * controls it. The _phy_aux_clk coming out of the GCC is requested >> + * by the PHY driver for its operations. >> + * We register the _phy_aux_clksrc here. The gcc driver takes care >> + * of assigning this _phy_aux_clksrc as parent to _phy_aux_clk. >> + * Below picture shows this relationship. >> + * >> + * +---------------+ >> + * | PHY block |<<---------------------------------------------+ >> + * | | | >> + * | +-------+ | +-----+ | >> + * I/P---^-->| PLL |---^--->phy_aux_clksrc--->| GCC |--->phy_aux_clk---+ >> + * clk | +-------+ | +-----+ >> + * +---------------+ >> + */ >> +static int phy_aux_clk_register(struct qmp_pcie *qmp, struct device_node *np) >> +{ >> + struct clk_fixed_rate *fixed = &qmp->aux_clk_fixed; >> + struct clk_init_data init = { }; >> + int ret; >> + >> + ret = of_property_read_string_index(np, "clock-output-names", 1, &init.name); >> + if (ret) { >> + dev_err(qmp->dev, "%pOFn: No clock-output-names index 1\n", np); >> + return ret; >> + } >> + >> + init.ops = &clk_fixed_rate_ops; >> + >> + fixed->fixed_rate = qmp->cfg->aux_clock_rate; >> + fixed->hw.init = &init; >> + >> + return devm_clk_hw_register(qmp->dev, &fixed->hw); >> +} >> + >> +static struct clk_hw *qmp_pcie_clk_hw_get(struct of_phandle_args *clkspec, void *data) >> +{ >> + struct qmp_pcie *qmp = data; >> + >> + /* Support legacy bindings */ >> + if (!clkspec->args_count) >> + return &qmp->pipe_clk_fixed.hw; >> + >> + switch (clkspec->args[0]) { >> + case QMP_PCIE_PIPE_CLK: >> + return &qmp->pipe_clk_fixed.hw; >> + case QMP_PCIE_PHY_AUX_CLK: >> + return &qmp->aux_clk_fixed.hw; > > Does the absence of the default case trigger a warning if compiled with W=1? Nop it doesn't with GCC arm-gnu-toolchain-13.2.Rel1-x86_64-aarch64-none-linux-gnu + W=1 and with smatch and C=1 Neil > >> + } >> + >> + return ERR_PTR(-EINVAL); >> +} >> + >> static int qmp_pcie_register_clocks(struct qmp_pcie *qmp, struct device_node *np) >> { >> int ret; >> @@ -3694,9 +3756,19 @@ static int qmp_pcie_register_clocks(struct qmp_pcie *qmp, struct device_node *np >> if (ret) >> return ret; >> >> - ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &qmp->pipe_clk_fixed.hw); >> - if (ret) >> - return ret; >> + if (qmp->cfg->aux_clock_rate) { >> + ret = phy_aux_clk_register(qmp, np); >> + if (ret) >> + return ret; >> + >> + ret = of_clk_add_hw_provider(np, qmp_pcie_clk_hw_get, qmp); >> + if (ret) >> + return ret; >> + } else { >> + ret = of_clk_add_hw_provider(np, of_clk_hw_simple_get, &qmp->pipe_clk_fixed.hw); >> + if (ret) >> + return ret; >> + } >> >> /* >> * Roll a devm action because the clock provider is the child node, but >> >> -- >> 2.34.1 >> >> > >