Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp30226ybk; Fri, 8 May 2020 17:34:39 -0700 (PDT) X-Google-Smtp-Source: APiQypJzpdpdANBz5zlY5dyt6TbNu0SVdVNNOo5hShfHX2F9pPMzBakZnhVVfDuu/mrCgfsPPyXX X-Received: by 2002:a50:f381:: with SMTP id g1mr4495253edm.219.1588984479762; Fri, 08 May 2020 17:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588984479; cv=none; d=google.com; s=arc-20160816; b=OFUFbt2RH3Ti5FOfSQ2winNc/5ce2jcUCFuPUoYW3coRupryn54vaUp2N0mM6PWKaO BkwN/feRthV659M23nneQjAzFngedb7Hm2FigbVTSQCe5U9e4At7MSBB74lo7vR8X7IP D8Rj+O8oEiCqVpVd6BeDPGS2tZQpMObjWoRsNikU0I5dcBH4piwd9fGXryq/mgQvKiVh qv3oCWF6DxmbPXdrrRCPuonqt8fNrTp1lJrEg03T17EjDmQrrTcVOf1L7Oiu3FZ+6zS6 1G6iLcjNphR1PiLk9Uy2vQDWZv80WerKGXuWllmHEYfTRkGIU9BuIIH7dehHBHDCa/6A Tkfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :thread-index:content-transfer-encoding:mime-version:message-id:date :subject:in-reply-to:cc:to:from:dkim-signature:dkim-filter; bh=neo+HlKkQMCxdPB9fgCSJEAlMpQVKOxhn4oUXLHS10E=; b=BG+qRGek5GQpfdRcNGZpZEqM0+Ii9QMhbdkzb7SnAcze2NMpNs68NUbDH8iGBa/35n RzpnnLO6o/TaZiB0VCFhqlWPlU1D9bvywb1g+o9Hj2/ww/gsyjQnTV4YPDaz5XLLywN/ sqXm2L8pvV2GhkNQZ32pqMRopSRjtBZl56OG5931jmEQS4rr/N9pTwaW9oa4eZYt34+r qz3bl42DPqolFHnrk6TcmLKuCAOSz5o0xbuY1yogoHX2AUvtYhycBIaoli2aKefduUow 8FET1VuqclsffDRw5eYKIZ9W/fXCFJPEP8gKgPsV4B+uf7c461ItrpgFTGC1QtCZ/u7W XuDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=hAiMPJi+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si1873129ejh.219.2020.05.08.17.34.16; Fri, 08 May 2020 17:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=hAiMPJi+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728380AbgEIAc6 (ORCPT + 99 others); Fri, 8 May 2020 20:32:58 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:46083 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728051AbgEIAc6 (ORCPT ); Fri, 8 May 2020 20:32:58 -0400 Received: from epcas5p2.samsung.com (unknown [182.195.41.40]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20200509003254epoutp01ea169529c0e61e71b001695db19547f4~NNN61qehl3255532555epoutp01c for ; Sat, 9 May 2020 00:32:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20200509003254epoutp01ea169529c0e61e71b001695db19547f4~NNN61qehl3255532555epoutp01c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1588984374; bh=neo+HlKkQMCxdPB9fgCSJEAlMpQVKOxhn4oUXLHS10E=; h=From:To:Cc:In-Reply-To:Subject:Date:References:From; b=hAiMPJi+nizBw2Fj/dnHMciZK9KPIa6IJwQTAji8h10W6euA+4TKz62jSFO+xFcrd /lc34pmvu239DrIG1IBCUHi0GkvAmROTHaIac18THQ7mHl2i/rkDUnMaoN7ZmzY/2Z e6n6OEiB0xxVJg+ugXNOeV6JGo6kMsD/+fXKQo7o= Received: from epsmges5p1new.samsung.com (unknown [182.195.42.73]) by epcas5p1.samsung.com (KnoxPortal) with ESMTP id 20200509003253epcas5p12e5c0818bdeb7dd26794d78ea4f841dd~NNN5oftA52572825728epcas5p1f; Sat, 9 May 2020 00:32:53 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id E9.13.10010.53AF5BE5; Sat, 9 May 2020 09:32:53 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas5p1.samsung.com (KnoxPortal) with ESMTPA id 20200509003252epcas5p105fcdf77df196a4f581f51fc7e82f1f8~NNN43vH4C0506305063epcas5p1v; Sat, 9 May 2020 00:32:52 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200509003252epsmtrp2b1babae60489d2cafa01eac8fa1ed4b3~NNN424e_p1992219922epsmtrp2L; Sat, 9 May 2020 00:32:52 +0000 (GMT) X-AuditID: b6c32a49-735ff7000000271a-b9-5eb5fa351a28 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id A0.1A.25866.43AF5BE5; Sat, 9 May 2020 09:32:52 +0900 (KST) Received: from alimakhtar02 (unknown [107.108.234.165]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200509003248epsmtip2b6fddca22f966ae2f394d65a39833f31~NNN1ile1w2388123881epsmtip2O; Sat, 9 May 2020 00:32:48 +0000 (GMT) From: "Alim Akhtar" To: "'Kishon Vijay Abraham I'" , Cc: , , , , , , , , , , , "'Vinod Koul'" In-Reply-To: Subject: RE: [PATCH v7 07/10] phy: samsung-ufs: add UFS PHY driver for samsung SoC Date: Sat, 9 May 2020 06:02:36 +0530 Message-ID: <006701d62599$5fbc2c80$1f348580$@samsung.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQINaKJiJYqhfY8pF8dQGQjTbFgO/QI75FnYAdd4tKsCTMaX9af9XhAA Content-Language: en-in X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKKsWRmVeSWpSXmKPExsWy7bCmhq7pr61xBm83CFm8/HmVzeLT+mWs FvOPnGO1uPC0h83i/PkN7BY3txxlsdj0+BqrxeVdc9gsZpzfx2TRfX0Hm8Xy4/+YLP7v2cFu sXTrTUaLnXdOMDvweVzu62Xy2LSqk81j85J6j5aT+1k8Pj69xeLRt2UVo8fxG9uZPD5vkvNo P9DNFMAZxWWTkpqTWZZapG+XwJWx/PUz1oKruhX3rx9jbWDsVOli5OSQEDCRmPB1PksXIxeH kMBuRonbq3ZAOZ+AnJt/WSGcz4wS115OYoRp2XFvAiNEYhejxIcPrcwQzhtGiYaWl0wgVWwC uhI7FrexdTFycIgIOEo07IoDqWEWeMUk8XfbRhaQGk4BK4mbHWeYQWxhgRCJa++2gcVZBFQk etuug23jFbCUONh3GMoWlDg58wlYDbOAtsSyha+ZIS5SkPj5dBkriC0i4CaxcepWNogacYmj P3vAjpMQeMAhcbP1DytEg4vExJ+3oZqFJV4d38IOYUtJfH63F+xoCYFsiZ5dxhDhGoml846x QNj2EgeuzGEBKWEW0JRYv0sfYhWfRO/vJ0wQnbwSHW1CENWqEs3vrkJ1SktM7O6GOsBDYv7m s+wTGBVnIXlsFpLHZiF5YBbCsgWMLK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WMkqkFxbnpucWGBUZ5qeV6xYm5xaV56XrJ+bmbGMHxq6W1 g3HPqg96hxiZOBgPMUpwMCuJ8E6s2BInxJuSWFmVWpQfX1Sak1p8iFGag0VJnPfrrIVxQgLp iSWp2ampBalFMFkmDk6pBqalDd837vr9qY89RvacjuCHA4bhAf2OIRfDZBOlrONK1j7Oc15z vibx03kWNfdnFyfNnLxhi0ZEbGGQavjLUpumLFHHFyGiO2d+WMdqznj/SsbsiD3cCQL8jmLM 01U/aq/d/EtI+ZqfrPSudWWxAnXBC6ccq3TKWSrkH/KxJ4v9ybFjd5oUI0wVOFVWBtae9ub7 cuj8skcHU5dtqNDTZl54J1co8H3L4Y03PwbYnJ/K7MVUFrPwxLxVDG+CXI+cFA14Ozc03Fbk u8hOZS+2AOv55Telf1hw+KUn8C3+tGDl+7UHPdZUWqe092gdsePdoLLJqMrCPrpkZ1lNqu2l myGx904ny/jcrjzD7juxW4mlOCPRUIu5qDgRAM2N5vdOAwAA X-CMS-MailID: 20200509003252epcas5p105fcdf77df196a4f581f51fc7e82f1f8 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" CMS-TYPE: 105P X-CMS-RootMailID: 20200426174217epcas5p2c7d1606b641b73f67a169b8d22f0637d References: <20200426173024.63069-1-alim.akhtar@samsung.com> <20200426173024.63069-8-alim.akhtar@samsung.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kishon, Thanks for review. > -----Original Message----- > From: Kishon Vijay Abraham I > Sent: 07 May 2020 10:49 > To: Alim Akhtar ; robh=40kernel.org > Cc: devicetree=40vger.kernel.org; linux-scsi=40vger.kernel.org; krzk=40ke= rnel.org; > avri.altman=40wdc.com; martin.petersen=40oracle.com; > kwmad.kim=40samsung.com; stanley.chu=40mediatek.com; > cang=40codeaurora.org; linux-samsung-soc=40vger.kernel.org; linux-arm- > kernel=40lists.infradead.org; linux-kernel=40vger.kernel.org; Vinod Koul > > Subject: Re: =5BPATCH v7 07/10=5D phy: samsung-ufs: add UFS PHY driver fo= r > samsung SoC >=20 =2E =2E =2E > Okay, here you are using a state machine for the PHY configuration becaus= e of > the way the PHY is integrated with the UFS. Would be nice to have the sta= te > machine documented somewhere. I only have the PHY patch in my inbox. Ok, will document in the driver file as well as in the header file. > > + > > + if (ufs_phy->ufs_phy_state =3D=3D CFG_POST_PWR_HS) > > + err =3D samsung_ufs_phy_wait_for_lock_acq(phy); > > +out: > > + return err; > > +=7D > > + > > +static int samsung_ufs_phy_symbol_clk_init(struct samsung_ufs_phy > > +*phy) =7B > > + struct clk *clk; > > + int ret =3D 0; > > + > > + clk =3D devm_clk_get(phy->dev, =22tx0_symbol_clk=22); >=20 > There is no =22exit=22 callback in phy_ops which means if there are multi= ple phy_init > calls, this clock will not be freed. This could be moved to =22probe=22 I= MO. Ok, will add exit callback. > > + if (IS_ERR(clk)) =7B > > + dev_err(phy->dev, =22failed to get tx0_symbol_clk clock=5Cn=22); > > + goto out; > > + =7D else =7B >=20 > =22else=22 here and below is not required. Something like below >=20 Ack > clk =3D devm_clk_get(phy->dev, =22tx0_symbol_clk=22); > if (IS_ERR(clk)) =7B > dev_err(phy->dev, =22failed to get tx0_symbol_clk clock=5Cn=22); > goto out; > =7D > phy->tx0_symbol_clk =3D clk; >=20 > > + phy->tx0_symbol_clk =3D clk; > > + =7D > > + > > + clk =3D devm_clk_get(phy->dev, =22rx0_symbol_clk=22); > > + if (IS_ERR(clk)) =7B > > + dev_err(phy->dev, =22failed to get rx0_symbol_clk clock=5Cn=22); > > + goto out; > > + =7D else =7B > > + phy->rx0_symbol_clk =3D clk; > > + =7D > > + > > + clk =3D devm_clk_get(phy->dev, =22rx1_symbol_clk=22); > > + if (IS_ERR(clk)) =7B > > + dev_err(phy->dev, =22failed to get rx1_symbol_clk clock=5Cn=22); > > + goto out; > > + =7D else =7B > > + phy->rx1_symbol_clk =3D clk; > > + =7D > > + > > + ret =3D clk_prepare_enable(phy->tx0_symbol_clk); > > + if (ret) =7B > > + dev_err(phy->dev, =22%s: tx0_symbol_clk enable failed %d=5Cn=22, > > + __func__, ret); > > + goto out; > > + =7D > > + ret =3D clk_prepare_enable(phy->rx0_symbol_clk); > > + if (ret) =7B > > + dev_err(phy->dev, =22%s: rx0_symbol_clk enable failed %d=5Cn=22, > > + __func__, ret); > > + goto out; > > + =7D > > + ret =3D clk_prepare_enable(phy->rx1_symbol_clk); > > + if (ret) =7B > > + dev_err(phy->dev, =22%s: rx1_symbol_clk enable failed %d=5Cn=22, > > + __func__, ret); > > + goto out; > > + =7D >=20 > All these clocks are never disabled? Sure, will add disabling of clocks in exit callback=20 > > +out: > > + return ret; > > +=7D > > + > > +static int samsung_ufs_phy_clks_init(struct samsung_ufs_phy *phy) =7B > > + struct clk *phy_ref_clk; > > + int ret; > > + > > + phy_ref_clk =3D devm_clk_get(phy->dev, =22ref_clk=22); > > + if (IS_ERR(phy_ref_clk)) > > + dev_err(phy->dev, =22failed to get ref_clk clock=5Cn=22); > > + else > > + phy->ref_clk =3D phy_ref_clk; > > + > > + ret =3D clk_prepare_enable(phy->ref_clk); > > + if (ret) =7B > > + dev_err(phy->dev, =22%s: ref_clk enable failed %d=5Cn=22, > > + __func__, ret); > > + return ret; > > + =7D > > + > > + dev_info(phy->dev, =22UFS MPHY ref_clk_rate =3D %ld=5Cn=22, > > +clk_get_rate(phy_ref_clk)); > > + > > + return 0; > > +=7D > > + > > +static int samsung_ufs_phy_init(struct phy *phy) =7B > > + struct samsung_ufs_phy *_phy =3D get_samsung_ufs_phy(phy); > > + int ret; > > + > > + _phy->lane_cnt =3D phy->attrs.bus_width; > > + _phy->ufs_phy_state =3D CFG_PRE_INIT; > > + > > + _phy->is_pre_init =3D true; > > + _phy->is_post_init =3D false; > > + _phy->is_pre_pmc =3D false; > > + _phy->is_post_pmc =3D false; > > + > > + > > + if (of_device_is_compatible(_phy->dev->of_node, > > + =22samsung,exynos7-ufs-phy=22)) =7B >=20 > Can't it be added in driver data for this compatible? Sure, will handle via driver data. > > + ret =3D samsung_ufs_phy_symbol_clk_init(_phy); > > + if (ret) > > + dev_err(_phy->dev, > > + =22failed to set ufs phy symbol clocks=5Cn=22); > > + =7D > > + =2E =2E =2E > > +static int samsung_ufs_phy_set_mode(struct phy *generic_phy, > > + enum phy_mode mode, int submode) =7B > > + struct samsung_ufs_phy *_phy =3D get_samsung_ufs_phy(generic_phy); > > + > > + _phy->mode =3D PHY_MODE_INVALID; > > + > > + if (mode > 0) > > + _phy->mode =3D mode; > > + > > + return 0; > > +=7D > > + > > +static struct phy_ops samsung_ufs_phy_ops =3D =7B > > + .init =3D samsung_ufs_phy_init, > > + .power_on =3D samsung_ufs_phy_power_on, > > + .power_off =3D samsung_ufs_phy_power_off, > > + .calibrate =3D samsung_ufs_phy_calibrate, > > + .set_mode =3D samsung_ufs_phy_set_mode, >=20 > missing .owner. Ack, > > +=7D > > +; =2E =2E > > +++ b/drivers/phy/samsung/phy-samsung-ufs.h > > =40=40 -0,0 +1,142 =40=40 > > +/* SPDX-License-Identifier: GPL-2.0-only */ > > +/* > > + * UFS PHY driver for Samsung EXYNOS SoC > > + * > > + * Copyright (C) 2015 Samsung Electronics Co., Ltd. >=20 > 2020 >=20 Sure, will update. > Thanks > Kishon