From mboxrd@z Thu Jan 1 00:00:00 1970 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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B524DECAAA1 for ; Sun, 30 Oct 2022 21:26:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7F023853CA; Sun, 30 Oct 2022 22:26:56 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="B+Gb8jZn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5A5B6853D1; Sun, 30 Oct 2022 22:26:55 +0100 (CET) Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 92D32853B8 for ; Sun, 30 Oct 2022 22:26:52 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x729.google.com with SMTP id s20so206349qkg.5 for ; Sun, 30 Oct 2022 14:26:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZxXTHD9phlqUTFIlb9CTs7qDm3jlqvuFowgwGs2fCKU=; b=B+Gb8jZnnW3xMBtMTv8RLA8dW24cBtw8H9QZ7trhIUrMi02CFItbHzBnoYSEprtj+G FQ9tsALXZdQJiJpKW3Uug8KGwg1F74okznSze0M6tbkFAMn8OZhuDB6dtNWXWVUgcoVu rReMiF1Yyv0Na32XCfkc5vKKgVNAvozrP8f5ZWsKIfNpZz18kFGBZc/GZsyyNWV9AowP 1rReQ8L7WIeweLjiJrTPXP6thow6rqufkEDZLV/NVVVQPo6t/BEzUxaIl/FhzAiX/aYZ Hxu9V9WxZLBz+4NLijsbYBfEiXiWZWw1LTtQrMYtRh/3GdCRRGTPz+zlR4q6UqnUYpfN W3Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZxXTHD9phlqUTFIlb9CTs7qDm3jlqvuFowgwGs2fCKU=; b=e/Zu/IfjSlOuCUMKGPTOppB1/X5TlgpRbk9Bb1vBkwopOi9Eu1JEYqOnlWGXrkMGcO fP81M8SxCj0J61Jko8orjZ8eiVyfOlZlwJ+lxk45H3XCbNg76LwYdF5Vb+KWpQnDyxvv GHfnMi+scCeFL4SLw3NwuitVp7cCnlxj338jwXUzjpJD1HokT1oguKDPbxvjYhGn/tp0 JRN1GtnFNnsJZIYi8nd7U9QKfOQn7iL6lwzaAj7abxxHvaYobd+PM9mUHXeyFUCx92Re tLPQBKk71KhEDIa31mpNN+KOC/dwnLm1BySOtDDA5/3MqEzhXk6YzpqBgozRwFpCoAod guMg== X-Gm-Message-State: ACrzQf1h29SM/fCmOfiqx5eYYHtSOheKhcv/a2Bb758wLdQ6LF1v17E7 NjJGZWKaMBdDP+G4kBhSwdY= X-Google-Smtp-Source: AMsMyM5v8Al/XzRgAHf4DydZB1gnvd38K0/dDBHZViq+kIQCFNIIEpQw9IbG/fJShFrZ4jLkjaBABQ== X-Received: by 2002:a05:620a:1293:b0:6ee:dfb8:d448 with SMTP id w19-20020a05620a129300b006eedfb8d448mr7087042qki.510.1667165211310; Sun, 30 Oct 2022 14:26:51 -0700 (PDT) Received: from [192.168.1.201] (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with ESMTPSA id r1-20020a05620a298100b006ee91ab3538sm3527090qkp.36.2022.10.30.14.26.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Oct 2022 14:26:50 -0700 (PDT) Message-ID: Date: Sun, 30 Oct 2022 17:26:50 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH 3/4] usb: dwc3: Calculate REFCLKPER based on reference clock Content-Language: en-US To: Marek Vasut , u-boot@lists.denx.de Cc: Sean Anderson , Angus Ainslie , Bin Meng , Fabio Estevam , Kunihiko Hayashi , Michal Simek , Peng Fan , Stefano Babic References: <20221030210948.344661-1-marex@denx.de> <20221030210948.344661-3-marex@denx.de> From: Sean Anderson In-Reply-To: <20221030210948.344661-3-marex@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On 10/30/22 17:09, Marek Vasut wrote: > From: Sean Anderson > > Instead of using a special property to determine the reference clock > period, use the rate of the reference clock. When we have a legacy > snps,ref-clock-period-ns property and no reference clock, use it > instead. Fractional clocks are not currently supported, and will be > dealt with in the next commit. > > [ marek: Ported from Linux kernel commit > 5114c3ee24875 ("usb: dwc3: Calculate REFCLKPER based on reference clock") ] > > Signed-off-by: Sean Anderson > Signed-off-by: Marek Vasut # Port from Linux > --- > Cc: Angus Ainslie > Cc: Bin Meng > Cc: Fabio Estevam > Cc: Kunihiko Hayashi > Cc: Michal Simek > Cc: Peng Fan > Cc: Sean Anderson > Cc: Stefano Babic > --- > drivers/usb/dwc3/core.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c > index 300450100c9..cf66976a088 100644 > --- a/drivers/usb/dwc3/core.c > +++ b/drivers/usb/dwc3/core.c > @@ -126,14 +126,24 @@ static void dwc3_frame_length_adjustment(struct dwc3 *dwc, u32 fladj) > */ > static void dwc3_ref_clk_period(struct dwc3 *dwc) > { > + unsigned long period; > + unsigned long rate; > u32 reg; > > - if (dwc->ref_clk_per == 0) > + if (dwc->ref_clk) { > + rate = clk_get_rate(dwc->ref_clk); > + if (!rate) > + return; > + period = NSEC_PER_SEC / rate; > + } else if (dwc->ref_clk_per) { > + period = dwc->ref_clk_per; > + } else { > return; > + } > > reg = dwc3_readl(dwc->regs, DWC3_GUCTL); > reg &= ~DWC3_GUCTL_REFCLKPER_MASK; > - reg |= FIELD_PREP(DWC3_GUCTL_REFCLKPER_MASK, dwc->ref_clk_per); > + reg |= FIELD_PREP(DWC3_GUCTL_REFCLKPER_MASK, period); > dwc3_writel(dwc->regs, DWC3_GUCTL, reg); > } > Reviewed-by: Sean Anderson