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 X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51120C433DF for ; Wed, 1 Jul 2020 06:55:05 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1E02C20663 for ; Wed, 1 Jul 2020 06:55:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q+pkj/j6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="C8eB5xTv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E02C20663 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=NvFazi0Jh26RNxt3P6j/W8HmGZ3uaqr7ANvrYt3B+4Y=; b=q+pkj/j6ROLX3qVAcqRVvihNO Tb0z/5cUNjSRDZ/2A6m+HhhRL3Ev+0rZ200svxjhQ22ISXhFuTcb2Ee6a8nB/iJ+hfsp4lTlFEkI7 JU9vpmgICighyActm9UuYASxlaqyWR2opsYDXotWis1jbYN6vqtcCON7G4wNais4lGI5TuW2YAJST KQFxuytzGFKFufVlLZyx4+hkhHACQqL360Sg0CLzlAwISZYwtIgK8z8TP9dVpvophDJ+VRmwTZBF9 VMTsiPIxKC2qu5RKGqUZwgFbAL5SYqhg8dRS4v5SCJ/zSnncqfLJu6T3Zh1pVvNTH+fcTS1ujMmOJ LMicdLQJA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqWcS-0006Ny-VR; Wed, 01 Jul 2020 06:53:21 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jqWcP-0006N2-Jn for linux-arm-kernel@lists.infradead.org; Wed, 01 Jul 2020 06:53:18 +0000 Received: from localhost (unknown [122.182.251.219]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8CF220663; Wed, 1 Jul 2020 06:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593586396; bh=dXBhHEPls7hLBapRWS5AGMEC2erUdD9Csqr28fSP9pw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=C8eB5xTvyZai8hXpd1pcdc0CHm9taDe6vDGfPYx7sXpwjVz6r8ExHPUmXgBS8QhTm ayonsd3cJSSzuIZSGVuDce2UEWd0NYgViIxwqpz5gu0hKCi+y2ptcujuKz3Iv9h/aI cAZ8r14PQlW36iTVEBtUIUWAPVvSOx26j3Ocs5gE= Date: Wed, 1 Jul 2020 12:23:10 +0530 From: Vinod Koul To: Alim Akhtar Subject: Re: [RESEND PATCH v10 2/2] phy: samsung-ufs: add UFS PHY driver for samsung SoC Message-ID: <20200701065310.GX2599@vkoul-mobl> References: <20200624235631.11232-1-alim.akhtar@samsung.com> <20200624235631.11232-2-alim.akhtar@samsung.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200624235631.11232-2-alim.akhtar@samsung.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200701_025317_803405_6A94A60E X-CRM114-Status: GOOD ( 15.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, krzk@kernel.org, kwmad.kim@samsung.com, robh+dt@kernel.org, kishon@ti.com, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Alim, On 25-06-20, 05:26, Alim Akhtar wrote: > +int samsung_ufs_phy_wait_for_lock_acq(struct phy *phy) static ? > +{ > + struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy); > + const unsigned int timeout_us = 100000; > + const unsigned int sleep_us = 10; > + u32 val; > + int err; > + > + err = readl_poll_timeout( > + ufs_phy->reg_pma + PHY_APB_ADDR(PHY_PLL_LOCK_STATUS), > + val, (val & PHY_PLL_LOCK_BIT), sleep_us, timeout_us); > + if (err) { > + dev_err(ufs_phy->dev, > + "failed to get phy pll lock acquisition %d\n", err); > + goto out; > + } > + > + err = readl_poll_timeout( > + ufs_phy->reg_pma + PHY_APB_ADDR(PHY_CDR_LOCK_STATUS), > + val, (val & PHY_CDR_LOCK_BIT), sleep_us, timeout_us); > + if (err) { > + dev_err(ufs_phy->dev, > + "failed to get phy cdr lock acquisition %d\n", err); > + goto out; this one can be dropped > + } > + > +out: > + return err; > +} > + > +int samsung_ufs_phy_calibrate(struct phy *phy) static? > +{ > + struct samsung_ufs_phy *ufs_phy = get_samsung_ufs_phy(phy); > + struct samsung_ufs_phy_cfg **cfgs = ufs_phy->cfg; > + const struct samsung_ufs_phy_cfg *cfg; > + int i; > + int err = 0; err before i would make it look better > + > + if (unlikely(ufs_phy->ufs_phy_state < CFG_PRE_INIT || > + ufs_phy->ufs_phy_state >= CFG_TAG_MAX)) { > + dev_err(ufs_phy->dev, "invalid phy config index %d\n", > + ufs_phy->ufs_phy_state); single line now? > + return -EINVAL; > + } > + > + if (ufs_phy->is_pre_init) > + ufs_phy->is_pre_init = false; that sounds bit strange, you clear it if set? Can you explain what is going on here, and add comments > +static int samsung_ufs_phy_symbol_clk_init(struct samsung_ufs_phy *phy) > +{ > + int ret = 0; superfluous init > + > + phy->tx0_symbol_clk = devm_clk_get(phy->dev, "tx0_symbol_clk"); > + if (IS_ERR(phy->tx0_symbol_clk)) { > + dev_err(phy->dev, "failed to get tx0_symbol_clk clock\n"); > + goto out; > + } > + > + phy->rx0_symbol_clk = devm_clk_get(phy->dev, "rx0_symbol_clk"); > + if (IS_ERR(phy->rx0_symbol_clk)) { > + dev_err(phy->dev, "failed to get rx0_symbol_clk clock\n"); > + goto out; > + } > + > + phy->rx1_symbol_clk = devm_clk_get(phy->dev, "rx1_symbol_clk"); > + if (IS_ERR(phy->rx0_symbol_clk)) { > + dev_err(phy->dev, "failed to get rx1_symbol_clk clock\n"); > + goto out; > + } > + > + ret = clk_prepare_enable(phy->tx0_symbol_clk); > + if (ret) { > + dev_err(phy->dev, "%s: tx0_symbol_clk enable failed %d\n", > + __func__, ret); > + goto out; > + } > + ret = clk_prepare_enable(phy->rx0_symbol_clk); > + if (ret) { > + dev_err(phy->dev, "%s: rx0_symbol_clk enable failed %d\n", > + __func__, ret); so we keep tx0_symbol_clk enabled when bailing out? > + goto out; > + } > + ret = clk_prepare_enable(phy->rx1_symbol_clk); > + if (ret) { > + dev_err(phy->dev, "%s: rx1_symbol_clk enable failed %d\n", > + __func__, ret); here as well > +static int samsung_ufs_phy_init(struct phy *phy) > +{ > + struct samsung_ufs_phy *_phy = get_samsung_ufs_phy(phy); > + int ret; > + > + _phy->lane_cnt = phy->attrs.bus_width; > + _phy->ufs_phy_state = CFG_PRE_INIT; > + > + /** > + * In ufs, PHY need to be calibrated at different stages / state > + * mainly before Linkstartup, after Linkstartup, before power > + * mode change and after power mode change. > + * Below state machine initialize the initial state to handle > + * PHY calibration at various stages of UFS initialization and power > + * mode changes > + */ > + _phy->is_pre_init = true; > + _phy->is_post_init = false; > + _phy->is_pre_pmc = false; > + _phy->is_post_pmc = false; hmm why not have phy_state and assign that pre_init/post_init/pre_pmc/post_pmc states? > +static int samsung_ufs_phy_set_mode(struct phy *generic_phy, > + enum phy_mode mode, int submode) pls align this to preceding line opening brace (tip: checkpatch with --strict can tell you about these) -- ~Vinod _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel