From patchwork Wed May 6 07:50:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1149 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 00CF83F1D2 for ; Wed, 6 May 2020 09:50:51 +0200 (CEST) Received: by mail-pf1-f199.google.com with SMTP id f22sf984238pfk.7 for ; Wed, 06 May 2020 00:50:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751449; cv=pass; d=google.com; s=arc-20160816; b=rQpwa+wwHfw71hXi5NgJgzuow86uQFfYYufm6zQXKHy2U5XcS9XMF7Mfl58ZdfnHzN kiMB5LS556L1ERfoltr3DscdsdrxEUR14dv6O5fF9RBDJsbo1/yaPeGWxim6FR4wy1bp oLIpDyvAXmBhVUONaOyNtjSwEua9XomMXybsaYPoTWeAqin4vnDbQ2QQgdsh0jVJAvtS akUwge46vaYJKip1nW/3yhYxU2ms5/w1TflsnsFcKEpqLeC9k9JxLrCBUnduXc80vw8g x7ROEy70ZPq8ZcOrYmRspvLAP3KWSjnugdRrKHC/bdBHDocBJWhlkURJcRQP3N+VaVt7 vocA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=HW/HUCSzlb/bmNedsPdl1TjYj/+Xo6KZt2NqKfaTVpY=; b=JV4lzqyfYC44SJUYAtQtgxygyd+f5ljH6h+2lLBuGpeFOd6fu6Tzp7QBk2BVgHllRi ijXTwUYVrSw9SVL9VAAYHccUNlnVsnydBL4AryF/SQnnrLSu3FNV84RYwHbSyLVvvte9 c4Y4h8y5UwTvuN8IZRJHpxSIoo2YyLxHMk5B57X16bj7t4novTKh7HJpAr+h4v7r3x9B 5PWNdWlcInT+FvvzaznZE0hLSEXnMdDf+0uDRxmXNSrhV4AWVpYBgXPdNGZ0r5noeDai DnOWI0cW3Pq1C5Cyfl1XjZDfvQ7CkNAikm8MLwVQ/QVdVXr8tbhAuuMRM4LghbRD52g3 76fg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bV0PnJL1; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=HW/HUCSzlb/bmNedsPdl1TjYj/+Xo6KZt2NqKfaTVpY=; b=cAtayUf1yy3w8SEtlaGPT33jKisHn4RPjYlVsCKyug5CzjBFXebNGq/iD7+J3U0Md4 Kj7tAc+PZUyDYxMc5OyijG63fGHtlioJI2mPZdNBaRdUVWqdsRWzMwn0n2lWCmVQ9aeW Jacitx1f7G/YnghKy2Omc9ppLS9H4xcQxwzSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=HW/HUCSzlb/bmNedsPdl1TjYj/+Xo6KZt2NqKfaTVpY=; b=fTQbVXjxPhw4rhSuIeS1r54n08xpjtfaTKvn24oRQ9MkXTB+0ZshiwyOn62m6rNoIv eZx84VlP+s0fSIQviQbDQT/HtOV1mDe3PvJrmANJZShNn7Wh7HrM3QCVtEwVENJtVCtk LA5fUu9qOp6MKWJLAd7Btz9HehzDjqkmKuJlgYXkFOtHbc5go2IrMmLo0r2ptxKaKZbV 1Fz4rxoF0CveUZEEjmhdCztJlD9+haG77ZIgwsPVRhltkRZEFti/u46L0hChT7uRH2a1 X5tbHUIunJjxIKk0AYnjUzXleRFfuEHEKcI/QbKHQAEihy4t8/IUJdF818Ecn/pIH8Of dbPQ== X-Gm-Message-State: AGi0PuarzOHAuhvbVa+doAAM1d3zaJ5un9pXAki9FKnWDCzXfv5kqVUY 5ZzBqU1VB1cJlLerklo6lkmS0o/V X-Google-Smtp-Source: APiQypItcJPeCTru+2HV35UQo170s/FwWJTwOzOsz4hfN3VkX0nQhNYcDOX9I3U0vxzpVhfzuDJ33g== X-Received: by 2002:a17:90a:fa0e:: with SMTP id cm14mr7494649pjb.92.1588751449522; Wed, 06 May 2020 00:50:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:81c8:: with SMTP id t191ls825699pgd.10.gmail; Wed, 06 May 2020 00:50:49 -0700 (PDT) X-Received: by 2002:a62:64cd:: with SMTP id y196mr6608638pfb.116.1588751449015; Wed, 06 May 2020 00:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751449; cv=none; d=google.com; s=arc-20160816; b=RAQvlKUHYTv7EPpTa9rLJK08WpfacdhPde499FiOJkXP55TaLtSAQK/JaJQcJAak+H cDAPqXWdqkbS8pSl1w4jxcu/fsmMjuQNzceAp/wAKRo/y9Drwdhq5sv5/hPx8WFjEHEn tnBZ2zCTysGin9nqbkyxh+AEc7n/VIReF1QQcYf+C7ff8NqKwJtZIt8IYyH/jjA7ESXv xBja+ErOlQuusb2kYt6kr3rAVy9fCdEMkKP33iyBsg/901nSxoKvJ6OyTr3iR4DrUkIl /tdkhyOuL42hj+Dp7Gvy0IkMHllmbPJSKnDdfyUcbQhax3njKiZ9lw1xfZgQrluMpPBn 6pbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7EuBhc+IxUhTFTnantvXwnfMzqtQXGOpAjLsf0kZ7fc=; b=xISXI+JBa9PmqKlJ4fbj5bwMyiw/u6sXYIvKxFPg2c5Y7tnZQtFRTQE1xBG5gFrq1K QRvI0VMmPJAygfxkzVHSaWJyhvH5PgJs6tTree2VzSl65EKjKRpRZKpHdkfdTH6y/YMm b5nlryGpE1kZ0I6wwEFfjrmaxv4Yj7w0rnGNC8Ke6V6o7uYrIaeGkI6zrp7TejDWl/Fm vI57KLXEdtGcKwGBQIBsRZNwRgM6gqISvWGwyuNWQYXs8fSd4ByzwECNTSL5xL7zVL4r 1tJ6f6xmb58U3ap0mmXVtdZA2TV6c0+gtbIne0TeN7dlfpTVvFfNh+vIn9g+xeGzosW/ aeMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bV0PnJL1; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q20sor1599567pfc.98.2020.05.06.00.50.48 for (Google Transport Security); Wed, 06 May 2020 00:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a62:6485:: with SMTP id y127mr6613854pfb.11.1588751448068; Wed, 06 May 2020 00:50:48 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.50.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:50:47 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 1/7] clk: rk3399: Enable/Disable the USB2PHY clk Date: Wed, 6 May 2020 13:20:19 +0530 Message-Id: <20200506075025.1677-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bV0PnJL1; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Enable/Disable the USB2PHY clk for rk3399. CLK is clear in enable and set in disable functionality. Signed-off-by: Jagan Teki --- Changes for v2: - none drivers/clk/rockchip/clk_rk3399.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index 7feba92f9e..b1c89ea127 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1091,6 +1091,12 @@ static int rk3399_clk_enable(struct clk *clk) case SCLK_MACREF_OUT: rk_clrreg(&priv->cru->clkgate_con[5], BIT(6)); break; + case SCLK_USB2PHY0_REF: + rk_clrreg(&priv->cru->clkgate_con[6], BIT(5)); + break; + case SCLK_USB2PHY1_REF: + rk_clrreg(&priv->cru->clkgate_con[6], BIT(6)); + break; case ACLK_GMAC: rk_clrreg(&priv->cru->clkgate_con[32], BIT(0)); break; @@ -1167,6 +1173,12 @@ static int rk3399_clk_disable(struct clk *clk) case SCLK_MACREF_OUT: rk_setreg(&priv->cru->clkgate_con[5], BIT(6)); break; + case SCLK_USB2PHY0_REF: + rk_setreg(&priv->cru->clkgate_con[6], BIT(5)); + break; + case SCLK_USB2PHY1_REF: + rk_setreg(&priv->cru->clkgate_con[6], BIT(6)); + break; case ACLK_GMAC: rk_setreg(&priv->cru->clkgate_con[32], BIT(0)); break; From patchwork Wed May 6 07:50:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1150 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id BB5D73F1D2 for ; Wed, 6 May 2020 09:50:54 +0200 (CEST) Received: by mail-pl1-f199.google.com with SMTP id g9sf1200541plm.1 for ; Wed, 06 May 2020 00:50:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751453; cv=pass; d=google.com; s=arc-20160816; b=SjI+ejNpqqGDeCBrsKVgEsf8bAqExc3WoujWXpTOWznEA+eM/YcljTPN8c5TjrWfjN vgvH4SJkF86Muq7RTW4DW0MRbN3l6e4749JZg1VUVrY8xqyWPOmW7i6rvOptyql+Wvf6 pa+IWI+EvvNw9TTdTjKK0WPET4QgZUEoSFf6/Fd/2vb/88u2+9OGOuYr6tRMByoHI1NO Aq6ciCTI0yb3RCPEw3VR1XT2FTrMI+fMQGQFQZ0hdB+lJTMs9ErBCaBTZYAGwA4twh47 5Zwe4nzrJxeSE0SSgEbBUVq9IQdHeaVTPLNKAK9x8pY/KgvmbksoSUx8EogwOmX35fkU qdrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=H1vwFTYH8+e9hqblTobeItw+YmVeZMJNsG5N/xawR7w=; b=OW9UZNsXKJiSjtFUMUQVN4rZMr1UKwO1qUq/s1V/j5LmV25JatKQRGImUoIwHUkxoP 6gOHVj3+0o7tzh3g2S23vfDlOee3ZxyjkRCTllmfCXXZ7g8VMFUR5c/GnsEbl9L+YZpA IjJ7PCFH/Ac6rAX7YbXY4I4C2Y+7b9wKaYZ06osaZ9tNj+7Fmb0oxsmkWZMjfqKXx9Hx U7xOKrOAphkAg6b+XgoFHIUs/2keQXGNwfperI79GSc+LA1rLNeabLdLnARqt5N4QA2w uHt8YSN3hKBg7JwLOeBjgZUP+TgGPv6sv7XI0QhLpCi+0kH3YxktvFYQ7bcbLlEjqnLT xeZA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="FrA/H7Y9"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=H1vwFTYH8+e9hqblTobeItw+YmVeZMJNsG5N/xawR7w=; b=qgk/WDs25W7k+bu/jXG4un3m4omYVXtBrC0YS+RN+AtI7Rq37rWbAbl+19pqHPknze e71VeWCyffbjttPhjw+7l7iSan/CKivNX8RUVhrYDQQDF2Vu8pJdpijFirrWSWOcVFs9 k/6JQ6kxZmiq6AtugG6sTPcnn4JKp3T3CbbbI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=H1vwFTYH8+e9hqblTobeItw+YmVeZMJNsG5N/xawR7w=; b=evz/XXY9M1XaYkLvdPo0kD3D9uvB3kSeBoFmdKA+xIuYnsRh8nbsoRHKCr3KCb0O4e +fk7GVHjcPt3wyRVRGHF8I4xz50epLOk0K+6cDX8viLz2uOIqvyv2HcJiAM19lj5owj7 HfNq80OLxMTvRfTgS9j7lpBAfiIYKqDtUnMOXYe8udAnhSF11SIHjGbpDhMoXAj8Wern pWbYsN3uRX/dl9EECriCnBHT8yu/I/RDVUH7URw3r0A614E1bPas3KM7/Cl+VJN/LbdM 4jrlb6zEtj9r+kH7SUNRyok5BkMeqt2yGqaFNEjLEN5nxWGWbxOnexLpARj0QZ0Yqpga vXiw== X-Gm-Message-State: AGi0PuYqHxp9igxxUUCwocY8mo1HkcPCKhK8wadRLj9PEm6oprJ4BuMv O6zluTxCcCuFc1FjGMOQTtl79OYP X-Google-Smtp-Source: APiQypLWQSsjnH6XBPi94Kd5hJq01bOvPV5WuDDVwik4FYZPJz9yraCOUFIo55xnwolIataumTjmDg== X-Received: by 2002:a62:25c6:: with SMTP id l189mr7117981pfl.28.1588751453047; Wed, 06 May 2020 00:50:53 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90b:3543:: with SMTP id lt3ls2647902pjb.3.gmail; Wed, 06 May 2020 00:50:52 -0700 (PDT) X-Received: by 2002:a17:902:9a8a:: with SMTP id w10mr6911299plp.259.1588751452616; Wed, 06 May 2020 00:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751452; cv=none; d=google.com; s=arc-20160816; b=hComKr5unoAAtvLcvhyr1nGF5bQ2lQIGSdHZLMtKFl0D7RZ2qAGxF8To42tu3T3dgY +knxFSN9wX1AGshQGxr0AgqJA0DF4NmCOVcm2Z15H5eblek/b6sEBtufQdYmrsUT4ez+ bo7OfmYBCCJtAfoMdkcmp7Vhh5Pne2AjZrSW6sTx9J/lNJBMBI3/zHZmM/u0N/H4XnMr DH8dzcWtMuAWYrogAZQzYAM90eiLvTiFfm0NLCRORdwaCN35AffV+MolzhEyKlpOK1PS m9C6dnzNC82LUJcG4ahIyFOZpu3jizL8WNNMI5urVSnJmbP/jyQ7adEzHt+Evc9G0VU2 YswQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=paY+YkRuYb6W0hB7a23R4UOoM/sR3R+9HnDYwp25OD4=; b=oYabbpv+SevZoECN2ob78fxkowse9r09KunAvknOuLt5QOIOTdYPywYvQOPYzTWt2m hObHUV4NH4plBiCm/AHR3hLgT8gcV3SAGuhPXnZfcx1jKdeZO4O0yNzIbRN7S3PNjt0b UAKtHOQuNtGXfHIJtSDb2DJk+AOOw7x7sk/a8bA9vcI4dXXh21SbYGdqJONTZphl+QH+ EXzb5ASGCxHNl2TMpzFyD4Ix7IgMTbuwbKb23tliEIKEFe/0TmhHDd0OYciSmKVkWgDA 5rdD5jcIkkkhS6oBJg7nNX2bomaQu0a8/M7/mCyWh9NcpWOne2JI2jqdG5BqmhYERlpC W1YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="FrA/H7Y9"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id q12sor1386401pgh.55.2020.05.06.00.50.52 for (Google Transport Security); Wed, 06 May 2020 00:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:6e8a:: with SMTP id j132mr5261850pgc.301.1588751452324; Wed, 06 May 2020 00:50:52 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:50:51 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 2/7] clk: rk3399: Set empty for TCPHY assigned-clocks Date: Wed, 6 May 2020 13:20:20 +0530 Message-Id: <20200506075025.1677-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="FrA/H7Y9"; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Due to v5.7-rc1 sync the SD controller nodes in rk3399.dtsi have SCLK_UPHY0_TCPDCORE, SCLK_UPHY1_TCPDCORE assigned-clocks which are usually required for Linux and don't require to handle them in U-Boot. assigned-clocks = <&cru SCLK_UPHY0_TCPDCORE>; assigned-clocks = <&cru SCLK_UPHY1_TCPDCORE>; So, mark them as empty in clock otherwise device probe on those typec phy driver would fail. Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/clk/rockchip/clk_rk3399.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index b1c89ea127..4d48f70685 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -997,6 +997,8 @@ static ulong rk3399_clk_set_rate(struct clk *clk, ulong rate) case ACLK_VOP1: case HCLK_VOP1: case HCLK_SD: + case SCLK_UPHY0_TCPDCORE: + case SCLK_UPHY1_TCPDCORE: /** * assigned-clocks handling won't require for vopl, so * return 0 to satisfy clk_set_defaults during device probe. From patchwork Wed May 6 07:50:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1151 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id D2A0E3F1D2 for ; Wed, 6 May 2020 09:50:58 +0200 (CEST) Received: by mail-pj1-f70.google.com with SMTP id l40sf1348986pjb.8 for ; Wed, 06 May 2020 00:50:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751457; cv=pass; d=google.com; s=arc-20160816; b=JunSZi0dIv9Z81DCUrDCiqML+Z0NYq9R+F+X6JKeVRsNMPvI3YJPBBc4Xrv3zrJq9q OZqgZgq691tdOSNvooywgdLkhemgE3N+8VJKsA6KD0nM/N6a5A8WmiwjSPTlHQZbGe2D vpWs14YU9uAuiTErUlz3hlfre6FmSy0oOreL9lMePF8/tPRhBB3zDFUK438J9Qzf9z8Q nLNqhGILW2RXaCEq6bIwowsmweFumv6KsbODPgYf3Q+D1hcGTepndMVMsgmjuw4tUzao xfhM4eTuV9ryPJuXf/0kXvY2C+24DmftpvmQIOZtLi8nPs1otZEOGUhbNbsMkM6IYO98 2X9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=RVxMJop7cOkjk1/JziVV4TES6ItAMRdUp4s4ZFHqUAo=; b=uhkFevzWB7VllGaZghEa1lIjN0c2/l9XxaBIrCMctHee6y7hQfgZCI3Mm0Js4CFVrh xkKJ7024zmVvrA5BRqqLrkF9QQME78f0VNqnzjF6I7q62c0pdB+ag0xRTNTKUCoz9yzN PpLEbylx2QLd4EU5kyUMo80u3i1re+vXLFcxcB5gi532kRSVKj8mDtaSq0aYdwSZ46Oi e8YROqimUYxID4YoQVeCYA8BIQxoQY6lqN8IMgDcnfIwBafN6lwu7pnSNxMxYOiuZyJE tjD6U1+/Lmy+XWuMEZcOtDR+q0J4gIieczy9vYD760AtjOxRzhqkZ9UaXTY/+ug1u1ln DNPQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ue2tPDCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=RVxMJop7cOkjk1/JziVV4TES6ItAMRdUp4s4ZFHqUAo=; b=U4qg4VTz73APBN0+diSdQqE1YoKe4TlHUO7as3V7lfy9nin7RqM3YMhzzJOzjszI2/ 6YwbqT8Ir6MRKIO8/iIA4iDfN8Hav/w5MKbHAeOClDv0b78UvOtViVk1IC2JKXojmnr9 TKcIhOLRl/9QWG32wHd7/PJ31gAnFlhgCs4+Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=RVxMJop7cOkjk1/JziVV4TES6ItAMRdUp4s4ZFHqUAo=; b=giL7OulNJcM3Ok9DvUxUgMSNZVU6HskchSAOjHUkzVG+tJwXRlTr2qGfyl1U3Y6IAo fQPA+Lb5cSpXICYu3EV7+VhViYApSugVwsJb5IvqRIPEliaEPhXbuOgnpJiNrrjJc5Hl I/ilpvqn92LFSiwQJSoU1XrxrccqVcFcepBwT6WYRbhGuqIllCq+CPPAehzkKorGY+7g 1eX95nVG1flKtiPHe7TOmMGLIcWhaR4GjzMKbO4AjpQEg99AMJyHCg1Yi/ZZzbxRm1TG EVM3cdZ91ALg3D9HhqWu5Nj3eAcUIgijd/m72k2D4TgzdKJMR0X5+IUsBFJ6SeHhjV4k bdDg== X-Gm-Message-State: AGi0PubeyeOhT3qxcU3CXIeYAtwHPoyDG1ORRED7jrQMGQrJAYI+A1NF SNkSsHZ44FrYH+vxw/kNH+1uxxkA X-Google-Smtp-Source: APiQypISvuReKVj+13DZ47rfVNDQeXJuE1A2BHQWCGJk3Zgm3Jp9z1V4PRO2fGh7z7nSpD1A9e646A== X-Received: by 2002:a63:6285:: with SMTP id w127mr5612765pgb.449.1588751457336; Wed, 06 May 2020 00:50:57 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:d713:: with SMTP id w19ls1689173ply.9.gmail; Wed, 06 May 2020 00:50:57 -0700 (PDT) X-Received: by 2002:a17:90a:5287:: with SMTP id w7mr8004712pjh.66.1588751456888; Wed, 06 May 2020 00:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751456; cv=none; d=google.com; s=arc-20160816; b=xhMYox9+jDAIazhw7RBBkENed7U0MBwtvIyovGsjStauBTSsiNYLTCS0SgZQSrAOJz 8bGclvg+afonGPLpEUzRBvN5C3Js4/bEsLVxuqb9FX7OZZr/HCNikAwR4Co+Ar6z0Kya 1cOe8e7DEo9A6oW6ysjRK79VdBHOsE9bUPvNfIyp2cuf5NjSeseqFfZXLJDCLIzmIX+s 0Blbri1S8w5mQn/4ZsvIYKU/IolRK5y722krqNm8lPzwklmoobOYT8exYgLmH9jTVZx7 prIb23ceNzBtzTIrUyfL6cuNYHZ40RScBFkkGMrAvuyvPjnwGtsGIlZM+22FI2PjBrjK IYnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qKV2YO5gxF+l5Yc20ohGDgaddB7qj/Cn7Rz0GuUAAOk=; b=ochcEpoNLSZ26Wmf2ushHXhnwoPCp3r+XksLHFumIZ9b5tLs3z5D2a71/m/axaVuHm /dRzIop/Uqrg1W7VPt1Ie1rBWL97gerFLSGLZk7LuLFgTdZPc6Z8/TTOhCqr8uJOzvnW G1f+FNT0RadPwJRxbl8u41UM2V3eDLaJ5rWJ5CelnMsaViHLjHL3PSCzXyJVNFr4pAcl N0/odM2l809dOIzoLOHnG3VGbZVhuybbuf7kzmnOiS7+ZZUXZZyU7V2ODzvxWm4ipxE0 rdrCxiweAGDJBMXImeS4SG6gMasIuCQvnhV1rzT8fWgKiahm2fqTgRrvT3tM4Oc9SJ0n YnKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ue2tPDCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n37sor5968645pjc.1.2020.05.06.00.50.56 for (Google Transport Security); Wed, 06 May 2020 00:50:56 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:e00c:: with SMTP id u12mr7486915pjy.167.1588751456586; Wed, 06 May 2020 00:50:56 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.50.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:50:55 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 3/7] clk: rk3399: Enable/Disable TCPHY clocks Date: Wed, 6 May 2020 13:20:21 +0530 Message-Id: <20200506075025.1677-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Ue2tPDCT; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Enable/Disable TCPHY clock for rk3399 platform. Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/clk/rockchip/clk_rk3399.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index 4d48f70685..2cd3fd3e68 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1144,6 +1144,18 @@ static int rk3399_clk_enable(struct clk *clk) case HCLK_HOST1_ARB: rk_clrreg(&priv->cru->clksel_con[20], BIT(8)); break; + case SCLK_UPHY0_TCPDPHY_REF: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(4)); + break; + case SCLK_UPHY0_TCPDCORE: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(5)); + break; + case SCLK_UPHY1_TCPDPHY_REF: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(6)); + break; + case SCLK_UPHY1_TCPDCORE: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(7)); + break; case SCLK_PCIEPHY_REF: rk_clrreg(&priv->cru->clksel_con[18], BIT(10)); break; @@ -1226,6 +1238,18 @@ static int rk3399_clk_disable(struct clk *clk) case HCLK_HOST1_ARB: rk_setreg(&priv->cru->clksel_con[20], BIT(8)); break; + case SCLK_UPHY0_TCPDPHY_REF: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(4)); + break; + case SCLK_UPHY0_TCPDCORE: + rk_setreg(&priv->cru->clkgate_con[13], BIT(5)); + break; + case SCLK_UPHY1_TCPDPHY_REF: + rk_clrreg(&priv->cru->clkgate_con[13], BIT(6)); + break; + case SCLK_UPHY1_TCPDCORE: + rk_setreg(&priv->cru->clkgate_con[13], BIT(7)); + break; case SCLK_PCIEPHY_REF: rk_clrreg(&priv->cru->clksel_con[18], BIT(10)); break; From patchwork Wed May 6 07:50:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1152 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 544293F1D2 for ; Wed, 6 May 2020 09:51:03 +0200 (CEST) Received: by mail-pg1-f197.google.com with SMTP id u7sf863578pga.8 for ; Wed, 06 May 2020 00:51:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751462; cv=pass; d=google.com; s=arc-20160816; b=mlXBMJjoavmmE34J8gfMFvltnjmHo72r7JR/asNLHjy/AMU3C18BzJb1nhrFealFml WuVL14L6vOT0oRMlPtAU2nW4/BiFsU8CAwzOAcZzhTl7Ff2cSo8e4mGRwxbRYYvJOXp+ 12CXOAzuKzO/D0N+O+k21Z7yNBFIlIlwgaodhZ5oYRY9kw8+gNwciCUcaGqGgO2Ck7eG j9tvBWBzU2Gd+O6OzhEbRngoip3LuwZTq54k/ifJpa16o/g7DLq2/WrJajH1lt/s7Zmc eJbecc6fUrlQ8GKCLo9OKnjnxpoGqK7a0LsPzdMUJrhAJzZ0DlxXzJLGXsLV9j7npgbK 5cSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=gmEXnif/2kUcesIDTclJFcp+GxcvXS7bdMRZVv0OBh4=; b=grS1IOvj3GHSLkKGJP/srfuKQ62ITpoX1WTGwhMqoE85ZCiGTURVyW8GbwqfZtT96f uJ49F9se4cx101o5aSTw0VghB5dmUs3WMyiTROyYDBrT2DePamKM9PGeAONLdauSqB8N mitZOKmBvuj+n0p/TRqp1cOto02Fvp5JTWIPzogF8fDH2i4brRxDgZLjdof1xMeqcqWB 9dBPR0AMPq7c2KcixXrL2Wopyxx3R2gVS4sPNo4t91CNRPADjI2KLU2sCj8XQmpuW7VV 2d2j31ir99xiqqWC5klMfTZH5cKrnvaR69qbJr6xtMLhOP4E/V8Bj0gWQH1oMQUhYtDi 8YLg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q+EEL4Uw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=gmEXnif/2kUcesIDTclJFcp+GxcvXS7bdMRZVv0OBh4=; b=Yreh3wVgYWyn4OhnBX33BrJycdL72nEBHtGgFyxFn66ifzhGPQnojROq+Dzjwxn2rF BTL2qF9i+kyKVeX/ouwl9qguY8acZUbEISRdAewKme1Sb322FsXgTb7YR4ZWqpXbdyIM 0r0yprK2gawg5uFcboZKUl5I4A1m22uOS6hmQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=gmEXnif/2kUcesIDTclJFcp+GxcvXS7bdMRZVv0OBh4=; b=TRlM8K2sxcbR8bxCtD0tFysJmZbE4L8hbhJnaUDjO5yxxNJ2/Nqlp135G1B576GiQX qZ8cFLYCMdt2rZhZIHFuR6YCUafPBIWiTWyDsMDEDOO8jsXxHJGBYN1bCQ8qvE94BHfn 2daIZRMNXOo2hDViKddCpelhh+91V/qtaambqo50Xa8ZIPzNpxkNRCSE0jmv6zBRcwqE nA9q5yZB8b90NpcNJTuTVLcHuaP+Z8B8FmLmb32TVNd0YV6de3ynDR+51phvI1dO3hpz CR2LB8XUC7Bpz0rBKNElBgX11c/7X8PbWvAET+fc6PZvMzSCSSd7cwNjFjqbmYwI6qaH Vkqw== X-Gm-Message-State: AGi0Pub9i2G7q+VeEua6yojaP7MPnWoVsTzSGAyjwI79uKoefwFOoU1j WQX6DjpY4m+N1qZBHmilc8/UTKnn X-Google-Smtp-Source: APiQypJlVoBUIKvSPAQaVmZLeLuYmAkv7jaKoZTJaLCEDy9ZXe+pHuXv/6YdHfy2tjKvUyBJPTxanA== X-Received: by 2002:a17:90b:3014:: with SMTP id hg20mr7894167pjb.56.1588751462108; Wed, 06 May 2020 00:51:02 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:48:: with SMTP id 66ls2046286pla.0.gmail; Wed, 06 May 2020 00:51:01 -0700 (PDT) X-Received: by 2002:a17:90b:3014:: with SMTP id hg20mr7894122pjb.56.1588751461533; Wed, 06 May 2020 00:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751461; cv=none; d=google.com; s=arc-20160816; b=0Syu4nL0+bEIAVu91FKHW7ncTROpqns39wITY2Nd04xpSi8577TV2/PG3QNekXw2xI GL4mLer0P6RDnPlX0VW72wZrvU/5agSlzTop4aVth0tGQG4+V/XTEDJ7WeYQkYW/i2vQ LbjAI/K6d2HClRBSCpWkikDycqfVlaqlHYsWV2D/WVAkeOFbcGHC5UyukFaJi617YpJR GuBibKxoG8/a/IjqeI0Cp+7FUcE/63xhHJHjoxyR6OUU0zh+bCS5Izv6d7az+px8vycM edB1y9CGJdf5gT67ZVVycDY/UWocQboqNnlVyzCOZD9V6hc8QBPrefoF0z7VniG4FOdo v4KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YyU2dvehRtAdVwjyyr1X/cdSXtg/WzPDSpQhjuSLpDQ=; b=yd1/rJzv+6ZYeUw7QnnXnJ5QqQ170CiRyV73wvdLUOqDNUaAQtQ0q8r9f8m0w5Vg6C Pp4nW2REPTwQ6tR3xY9hXBSQQZfykgP2EyzoUlMjhcR0nlt3reLqjjhPLjmvdPvZu6XI XDJmeRwqHTwBU7BuySj9c0aWkjbqbEWFd0Zw81B8BavA4pgzDWzu0qaNOcDdiZ/k/35u HpVic1cQh1xOh0MCEHSC2PGkoEex/mxtb4IRLeJPcuOxDhowDYn6uthC24zubxI4eTqH ypAcg3bESTKGjqG20511jROeLponBh6w5FIBF1tQhhXy/9ggtAifv06zh26icA+nHl8Y yBmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q+EEL4Uw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p9sor1714148plq.52.2020.05.06.00.51.01 for (Google Transport Security); Wed, 06 May 2020 00:51:01 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:b185:: with SMTP id s5mr6234520plr.99.1588751461127; Wed, 06 May 2020 00:51:01 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:51:00 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 4/7] phy: rockchip: Add Rockchip USB2PHY driver Date: Wed, 6 May 2020 13:20:22 +0530 Message-Id: <20200506075025.1677-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=q+EEL4Uw; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add Rockchip USB2PHY driver with initial support. This will help to use it for EHCI controller in host mode, and USB 3.0 controller in otg mode. More functionality like charge, vbus detection will add it in future changes. Signed-off-by: Jagan Teki --- Changes for v2: - update with Kconfig menu drivers/Makefile | 1 + drivers/phy/Kconfig | 1 + drivers/phy/rockchip/Kconfig | 14 + drivers/phy/rockchip/Makefile | 6 + drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 312 ++++++++++++++++++ 5 files changed, 334 insertions(+) create mode 100644 drivers/phy/rockchip/Kconfig create mode 100644 drivers/phy/rockchip/Makefile create mode 100644 drivers/phy/rockchip/phy-rockchip-inno-usb2.c diff --git a/drivers/Makefile b/drivers/Makefile index 4208750428..94e8c5da17 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -91,6 +91,7 @@ obj-y += dfu/ obj-$(CONFIG_PCH) += pch/ obj-y += phy/allwinner/ obj-y += phy/marvell/ +obj-y += phy/rockchip/ obj-y += rtc/ obj-y += scsi/ obj-y += sound/ diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index a72f34f0d4..e19a6c0aa3 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig @@ -217,4 +217,5 @@ config PHY_MTK_TPHY multi-ports is first version, otherwise is second veriosn, so you can easily distinguish them by banks layout. +source "drivers/phy/rockchip/Kconfig" endmenu diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig new file mode 100644 index 0000000000..d73ac695e1 --- /dev/null +++ b/drivers/phy/rockchip/Kconfig @@ -0,0 +1,14 @@ +# +# Phy drivers for Rockchip platforms +# + +menu "Rockchip PHY driver" + +config PHY_ROCKCHIP_INNO_USB2 + bool "Rockchip INNO USB2PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Support for Rockchip USB2.0 PHY with Innosilicon IP block. + +endmenu diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile new file mode 100644 index 0000000000..9b0cbc6acf --- /dev/null +++ b/drivers/phy/rockchip/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2020 Amarula Solutions(India) +# + +obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c new file mode 100644 index 0000000000..dd4905d834 --- /dev/null +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -0,0 +1,312 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Rockchip USB2.0 PHY with Innosilicon IP block driver + * + * Copyright (C) 2016 Fuzhou Rockchip Electronics Co., Ltd + * Copyright (C) 2020 Amarula Solutions(India) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define usleep_range(a, b) udelay((b)) +#define BIT_WRITEABLE_SHIFT 16 + +enum rockchip_usb2phy_port_id { + USB2PHY_PORT_OTG, + USB2PHY_PORT_HOST, + USB2PHY_NUM_PORTS, +}; + +struct usb2phy_reg { + unsigned int offset; + unsigned int bitend; + unsigned int bitstart; + unsigned int disable; + unsigned int enable; +}; + +struct rockchip_usb2phy_port_cfg { + struct usb2phy_reg phy_sus; + struct usb2phy_reg bvalid_det_en; + struct usb2phy_reg bvalid_det_st; + struct usb2phy_reg bvalid_det_clr; + struct usb2phy_reg ls_det_en; + struct usb2phy_reg ls_det_st; + struct usb2phy_reg ls_det_clr; + struct usb2phy_reg utmi_avalid; + struct usb2phy_reg utmi_bvalid; + struct usb2phy_reg utmi_ls; + struct usb2phy_reg utmi_hstdet; +}; + +struct rockchip_usb2phy_cfg { + unsigned int reg; + const struct rockchip_usb2phy_port_cfg port_cfgs[USB2PHY_NUM_PORTS]; +}; + +struct rockchip_usb2phy { + void *reg_base; + struct clk phyclk; + const struct rockchip_usb2phy_cfg *phy_cfg; +}; + +static inline int property_enable(void *reg_base, + const struct usb2phy_reg *reg, bool en) +{ + unsigned int val, mask, tmp; + + tmp = en ? reg->enable : reg->disable; + mask = GENMASK(reg->bitend, reg->bitstart); + val = (tmp << reg->bitstart) | (mask << BIT_WRITEABLE_SHIFT); + + return writel(val, reg_base + reg->offset); +} + +static const +struct rockchip_usb2phy_port_cfg *us2phy_get_port(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_cfg *phy_cfg = priv->phy_cfg; + + return &phy_cfg->port_cfgs[phy->id]; +} + +static int rockchip_usb2phy_power_on(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + + property_enable(priv->reg_base, &port_cfg->phy_sus, false); + + /* waiting for the utmi_clk to become stable */ + usleep_range(1500, 2000); + + return 0; +} + +static int rockchip_usb2phy_power_off(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + + property_enable(priv->reg_base, &port_cfg->phy_sus, true); + + return 0; +} + +static int rockchip_usb2phy_init(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + const struct rockchip_usb2phy_port_cfg *port_cfg = us2phy_get_port(phy); + int ret; + + ret = clk_enable(&priv->phyclk); + if (ret) { + dev_err(phy->dev, "failed to enable phyclk (ret=%d)\n", ret); + return ret; + } + + if (phy->id == USB2PHY_PORT_OTG) { + property_enable(priv->reg_base, &port_cfg->bvalid_det_clr, true); + property_enable(priv->reg_base, &port_cfg->bvalid_det_en, true); + } else if (phy->id == USB2PHY_PORT_HOST) { + property_enable(priv->reg_base, &port_cfg->bvalid_det_clr, true); + property_enable(priv->reg_base, &port_cfg->bvalid_det_en, true); + } + + return 0; +} + +static int rockchip_usb2phy_exit(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_usb2phy *priv = dev_get_priv(parent); + + clk_disable(&priv->phyclk); + + return 0; +} + +static int rockchip_usb2phy_of_xlate(struct phy *phy, + struct ofnode_phandle_args *args) +{ + const char *name = phy->dev->name; + + if (!strcasecmp(name, "host-port")) + phy->id = USB2PHY_PORT_HOST; + else if (!strcasecmp(name, "otg-port")) + phy->id = USB2PHY_PORT_OTG; + else + dev_err(phy->dev, "improper %s device\n", name); + + return 0; +} + +static struct phy_ops rockchip_usb2phy_ops = { + .init = rockchip_usb2phy_init, + .exit = rockchip_usb2phy_exit, + .power_on = rockchip_usb2phy_power_on, + .power_off = rockchip_usb2phy_power_off, + .of_xlate = rockchip_usb2phy_of_xlate, +}; + +static int rockchip_usb2phy_probe(struct udevice *dev) +{ + struct rockchip_usb2phy *priv = dev_get_priv(dev); + const struct rockchip_usb2phy_cfg *phy_cfgs; + unsigned int reg; + int index, ret; + + priv->reg_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + if (IS_ERR(priv->reg_base)) + return PTR_ERR(priv->reg_base); + + ret = dev_read_u32_index(dev, "reg", 1, ®); + if (ret) { + dev_err(dev, "failed to read reg property (ret = %d)\n", ret); + return ret; + } + + phy_cfgs = (const struct rockchip_usb2phy_cfg *) + dev_get_driver_data(dev); + if (!phy_cfgs) + return -EINVAL; + + /* find out a proper config which can be matched with dt. */ + index = 0; + while (phy_cfgs[index].reg) { + if (phy_cfgs[index].reg == reg) { + priv->phy_cfg = &phy_cfgs[index]; + break; + } + + ++index; + } + + if (!priv->phy_cfg) { + dev_err(dev, "failed find proper phy-cfg\n"); + return -EINVAL; + } + + ret = clk_get_by_name(dev, "phyclk", &priv->phyclk); + if (ret) { + dev_err(dev, "failed to get the phyclk (ret=%d)\n", ret); + return ret; + } + + return 0; +} + +static int rockchip_usb2phy_bind(struct udevice *dev) +{ + struct udevice *usb2phy_dev; + ofnode node; + const char *name; + int ret = 0; + + dev_for_each_subnode(node, dev) { + if (!ofnode_valid(node)) { + dev_info(dev, "subnode %s not found\n", dev->name); + return -ENXIO; + } + + name = ofnode_get_name(node); + dev_dbg(dev, "subnode %s\n", name); + + ret = device_bind_driver_to_node(dev, "rockchip_usb2phy_port", + name, node, &usb2phy_dev); + if (ret) { + dev_err(dev, + "'%s' cannot bind 'rockchip_usb2phy_port'\n", name); + return ret; + } + } + + return ret; +} + +static const struct rockchip_usb2phy_cfg rk3399_usb2phy_cfgs[] = { + { + .reg = 0xe450, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0xe454, 1, 0, 2, 1 }, + .bvalid_det_en = { 0xe3c0, 3, 3, 0, 1 }, + .bvalid_det_st = { 0xe3e0, 3, 3, 0, 1 }, + .bvalid_det_clr = { 0xe3d0, 3, 3, 0, 1 }, + .utmi_avalid = { 0xe2ac, 7, 7, 0, 1 }, + .utmi_bvalid = { 0xe2ac, 12, 12, 0, 1 }, + }, + [USB2PHY_PORT_HOST] = { + .phy_sus = { 0xe458, 1, 0, 0x2, 0x1 }, + .ls_det_en = { 0xe3c0, 6, 6, 0, 1 }, + .ls_det_st = { 0xe3e0, 6, 6, 0, 1 }, + .ls_det_clr = { 0xe3d0, 6, 6, 0, 1 }, + .utmi_ls = { 0xe2ac, 22, 21, 0, 1 }, + .utmi_hstdet = { 0xe2ac, 23, 23, 0, 1 } + } + }, + }, + { + .reg = 0xe460, + .port_cfgs = { + [USB2PHY_PORT_OTG] = { + .phy_sus = { 0xe464, 1, 0, 2, 1 }, + .bvalid_det_en = { 0xe3c0, 8, 8, 0, 1 }, + .bvalid_det_st = { 0xe3e0, 8, 8, 0, 1 }, + .bvalid_det_clr = { 0xe3d0, 8, 8, 0, 1 }, + .utmi_avalid = { 0xe2ac, 10, 10, 0, 1 }, + .utmi_bvalid = { 0xe2ac, 16, 16, 0, 1 }, + }, + [USB2PHY_PORT_HOST] = { + .phy_sus = { 0xe468, 1, 0, 0x2, 0x1 }, + .ls_det_en = { 0xe3c0, 11, 11, 0, 1 }, + .ls_det_st = { 0xe3e0, 11, 11, 0, 1 }, + .ls_det_clr = { 0xe3d0, 11, 11, 0, 1 }, + .utmi_ls = { 0xe2ac, 26, 25, 0, 1 }, + .utmi_hstdet = { 0xe2ac, 27, 27, 0, 1 } + } + }, + }, + { /* sentinel */ } +}; + +static const struct udevice_id rockchip_usb2phy_ids[] = { + { + .compatible = "rockchip,rk3399-usb2phy", + .data = (ulong)&rk3399_usb2phy_cfgs, + }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(rockchip_usb2phy_port) = { + .name = "rockchip_usb2phy_port", + .id = UCLASS_PHY, + .ops = &rockchip_usb2phy_ops, +}; + +U_BOOT_DRIVER(rockchip_usb2phy) = { + .name = "rockchip_usb2phy", + .id = UCLASS_PHY, + .of_match = rockchip_usb2phy_ids, + .probe = rockchip_usb2phy_probe, + .bind = rockchip_usb2phy_bind, + .priv_auto_alloc_size = sizeof(struct rockchip_usb2phy), +}; From patchwork Wed May 6 07:50:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1153 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 703E13F1D2 for ; Wed, 6 May 2020 09:51:07 +0200 (CEST) Received: by mail-pl1-f200.google.com with SMTP id a7sf1141768pll.23 for ; Wed, 06 May 2020 00:51:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751466; cv=pass; d=google.com; s=arc-20160816; b=htPwIW0L5Bks/goDRGn0UUPQ6U3V52/XzP9yQTc0SXXg1htRHHe5AW39KYGcf9zzIW weWYnCiw844v3UnT69uJxSJchHnwlgEL9DIL+NAAG2eiKUD/D5uRwH1UvSZ1OMabyTLo 5C03EYSuGXdaTiggJonXp0yFWKCgm2+fmUmrIRVnvnsFX5tS8Gh84gZgAyGT1SOgQe/R GBN/Ft/E+mtHw4VFxroBAdAMOmsZ6Sm6CRSZnlFxsfk4GPqoxmOPk+zBtQrJOThnzBAm APsWN5zqE7OIUsW5hnSKYSsknWb4cdJHi6KcL7fVvglvi/9J7uI99vc18Ai3WCubWr33 UB5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=c6pbqTNB1F4Mp6V3MneFg8ubXlObBWtqZEnorysM3ZA=; b=bUi626v1IdM5FIOAbjD/SMQgu2tTqCntdQ6avqY6qrPUHsKiZAVWV5rYI3b/mIbWjB K3XnPiMx5RK4Tc4SPyi6d2ajDheQqcKztK/WTqNfeJfdPq7v9i+Cz+5BJfwjhA6JDUwe k0d/a4RAauXIMBqr+SCkWsATahZ3wxvAoNA7Ou5AC1RyAces9o4WCXEnMOVetkrUPBaB fnzghR87lmOImn/11WFKBjLV046RkvcCvY7pS83Dgcx3SzY8MoPVMPeF2vZlzivoC/vg QaGxEpPxyBXkq1log9IwLZYZ9JTadXRErxg3lVqwzYXWxxc539WeQBF9Yq2TF6T4jf2h t+CQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=VhKBHW7D; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=c6pbqTNB1F4Mp6V3MneFg8ubXlObBWtqZEnorysM3ZA=; b=fQmej2uprL0uJ95McQgESizIvS5L+ovwuq1WrbXFHs90bIO1wecSl9Dtz/4uNnrdMu BtdKSVM3KtmJ3b2ZGebO36PEHhLdsk/fsiwEqo/WbnoVMr04LsLuidesBXvJcycYpTum +iXeCJBpbozlB4oaarMdgJn5lvbL4Q42EzbSg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=c6pbqTNB1F4Mp6V3MneFg8ubXlObBWtqZEnorysM3ZA=; b=KHwgQDzkuoQ4GM+T8rLIVIJ/AiWd6LVt8Zg8rY54NrQ/wPRdGxWM0dfWnCrMEWUQeW K4PDNJJ72LNG5dnKjoep5TrSKAHRAiUC0e4ZMUSS0huoDpreKcw4wkGeXYm4IQYNcCZw 8xi9jWThqMvypxB5QmafJYROyh3fIx3DniTQBzTdmtZSoH4MZLE/+u/DBLn5ehnWx0x7 UkC7wUeOuV4ubJEp/Rf30NDbKmeexIqzXNkYUxK1AGKfUOOmwSpI9LtYyQWCpr+fQFkF orEGGS96N71Hc0p/9pLV4o9uxUrVZhhXbx8FA6VYukGYXq8QsFj2WFxYaZgGMuLWzw6E aysQ== X-Gm-Message-State: AGi0PuaWuWmMxvIPQdS3mryvGul5jFxRhKTiMX9/wBt7kzfFSNfr2Gh1 hdySAV0XEu/CwsXP/FDKjf57i8Z6 X-Google-Smtp-Source: APiQypLuwfIwyPVpkPjQ5XSxJAYsL3T1ZFET6tibsbJgmdDOraI7nsEWTQ9qBX7kWu5SiVljfTZguw== X-Received: by 2002:a17:90a:db46:: with SMTP id u6mr7794475pjx.15.1588751466246; Wed, 06 May 2020 00:51:06 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:b702:: with SMTP id d2ls1988509pls.6.gmail; Wed, 06 May 2020 00:51:05 -0700 (PDT) X-Received: by 2002:a17:90a:db53:: with SMTP id u19mr7696746pjx.41.1588751465662; Wed, 06 May 2020 00:51:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751465; cv=none; d=google.com; s=arc-20160816; b=jEurTLo+rfnRrXqwQUpZbUwfEUDOYDsrcDKmaPTpRHk4E9Tll5pYva4wRGRqNzGM8r i7pnGjN1Pp73VL5Rglc0fEwFkAmzjnSFH5Pe39v6eHlWmk9uTGJkz5urjkAHE5rawXzu VRSB8t31+ZGo4liKaM2oN4cSLTe216aB26VGmjiHccQg/tERFKbodUUeZz6JlVr8pW0h ZaouPUc1QZPTpcTNS25PL43Jav16jnrf9oR45d5QJCrfPd2k1T9Pg+mLEfw8TO+Ip+rL etm2QgGYvud7EQtOReeilXkCvNpM8Q97yvLvEEUTl/OmqmgNPpqIWG/+zDL7+NSEf9sh NaGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VPg039izGsBvlHYInKALMlOUd753kCr+XH9uCUo1MNQ=; b=X0fMSMeLLFHhTVpIq69C2KbqJjNOkwwzHpLrFOAU7eF2T88KVj59V/Kt1OB3Mr5zX4 D/zgc7LGQn+9QOEL4zl8i2jw4BJhyPFIaPQy03WWxlNQDvNsLsWWzaUKOLARoOHTuJrd 9j/YcjS+d97t6BH224eA9uCej9Gl1bnasXHG39I9rVARJhm1m6tmIqAw9snMzTAJG/hY zufu8BqEkm9invUMHkOkTRb6LD5lKcmnwf6A1m5DrRxQe/kcJF5z+mE8tsJgjot0XL56 /wXn6zGKhXwYTSBZqLXnRfVVilhXXqFwwK7sS1ChpueJUHtmnSSFUcUgX82uX7Hdel1j GH8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=VhKBHW7D; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id co21sor5777624pjb.31.2020.05.06.00.51.05 for (Google Transport Security); Wed, 06 May 2020 00:51:05 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:90a:d808:: with SMTP id a8mr7677278pjv.6.1588751465387; Wed, 06 May 2020 00:51:05 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:51:04 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 5/7] arm64: dts: rk3399: Move u2phy into root port Date: Wed, 6 May 2020 13:20:23 +0530 Message-Id: <20200506075025.1677-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=VhKBHW7D; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Yes, This is changing the actual device tree u2phy structure but the problem with the current Generic PHY subsystem is unable to find PHY if the PHY node is not part of the root structure. This will be reverted once we support the PHY subsystem to get the PHY even though it is not part of the root node or any other relevant solution. Signed-off-by: Jagan Teki --- Changes for v2: - none arch/arm/dts/rk3399.dtsi | 108 +++++++++++++++++++-------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/arch/arm/dts/rk3399.dtsi b/arch/arm/dts/rk3399.dtsi index 74f2c3d490..6c77f25f23 100644 --- a/arch/arm/dts/rk3399.dtsi +++ b/arch/arm/dts/rk3399.dtsi @@ -1387,60 +1387,6 @@ status = "disabled"; }; - u2phy0: usb2-phy@e450 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe450 0x10>; - clocks = <&cru SCLK_USB2PHY0_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy0_480m"; - status = "disabled"; - - u2phy0_host: host-port { - #phy-cells = <0>; - interrupts = ; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy0_otg: otg-port { - #phy-cells = <0>; - interrupts = , - , - ; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - - u2phy1: usb2-phy@e460 { - compatible = "rockchip,rk3399-usb2phy"; - reg = <0xe460 0x10>; - clocks = <&cru SCLK_USB2PHY1_REF>; - clock-names = "phyclk"; - #clock-cells = <0>; - clock-output-names = "clk_usbphy1_480m"; - status = "disabled"; - - u2phy1_host: host-port { - #phy-cells = <0>; - interrupts = ; - interrupt-names = "linestate"; - status = "disabled"; - }; - - u2phy1_otg: otg-port { - #phy-cells = <0>; - interrupts = , - , - ; - interrupt-names = "otg-bvalid", "otg-id", - "linestate"; - status = "disabled"; - }; - }; - emmc_phy: phy@f780 { compatible = "rockchip,rk3399-emmc-phy"; reg = <0xf780 0x24>; @@ -1462,6 +1408,60 @@ }; }; + u2phy0: usb2-phy@e450 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe450 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY0_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy0_480m"; + status = "disabled"; + + u2phy0_host: host-port { + #phy-cells = <0>; + interrupts = ; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy0_otg: otg-port { + #phy-cells = <0>; + interrupts = , + , + ; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + + u2phy1: usb2-phy@e460 { + compatible = "rockchip,rk3399-usb2phy"; + reg = <0x0 0xe460 0x0 0x10>; + clocks = <&cru SCLK_USB2PHY1_REF>; + clock-names = "phyclk"; + #clock-cells = <0>; + clock-output-names = "clk_usbphy1_480m"; + status = "disabled"; + + u2phy1_host: host-port { + #phy-cells = <0>; + interrupts = ; + interrupt-names = "linestate"; + status = "disabled"; + }; + + u2phy1_otg: otg-port { + #phy-cells = <0>; + interrupts = , + , + ; + interrupt-names = "otg-bvalid", "otg-id", + "linestate"; + status = "disabled"; + }; + }; + tcphy0: phy@ff7c0000 { compatible = "rockchip,rk3399-typec-phy"; reg = <0x0 0xff7c0000 0x0 0x40000>; From patchwork Wed May 6 07:50:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1154 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id B7AFE3F1D2 for ; Wed, 6 May 2020 09:51:12 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id j21sf856511pgh.12 for ; Wed, 06 May 2020 00:51:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751471; cv=pass; d=google.com; s=arc-20160816; b=MIjgsz0J6wlxgair7E0xlfXchM7ch3h3tIwYvfA8Vv1Ll9hkJnuehAi3oHtVeX+Gq8 B1OaPDleMyekmJsx1cWJ0nzUFbrXgfQRepPJwv6sAjnG29ZyANQh6Xyl3SIN2InGdRwV NUegqpl1W7BuOjJkAQgHB6ffwfgx1r3/h+NF44+uO3v96ui0+SBEEVk1YP+JXeXACeyh w0MEFAu7rfTK2Rg2e4F0nDDiijKqw1h7FjEY1jDG1UQwqsMWXUorbB/8nrr/bz63SF9H hkQMjrb2br+W3c5TB4miwoBcUm8xjZQIZqB9fO/1+9e/W24+SAcc69jAJbU+dvP216FW Kq2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=TruIRsmWj0GgDi5vvHX49Vt76A/m9lhUqjX4KubefF0=; b=uKNCHlzwEEN8RNlMIyMl4xgpGpFOlnL2Vx8ttiU5C3B6ddZ7sja/Bm1RYYNofJtI4b ps2L0KYOKfnwFFbkFaK8WdaxXHw0G8MVw7YvpBhqoTUkjRk7vkUDRw2rGAD7oX0EU5dn RX2Zk8OlTflFplHSHSfzJPDZNmg2zi1fYvwRFhLTeh+EyPdNmPDc8LD7hTCl/B5nJAmm 6c2Ju8tuhE1uGRO63DiMrqSOfkwtFKkIydvucLwZ52q9DuEG5cobH5IrB1gaF/ytE5qF oRGlUwGGtAEqDT88x3hSpeqwPFRbOArgDTXZKsVvOtktP6qRFymPeqJK4w+znALWw9Z8 KkbQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bsE9ns+0; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=TruIRsmWj0GgDi5vvHX49Vt76A/m9lhUqjX4KubefF0=; b=ns+2eT5LxGOwFBypoCMgAA5cdWoJpKJIBG9C8aOGnJab8xitzPeELvsPB0Sc6SOlpY HmGjv5icDFkHLhQETuuNcyDI/Vik5AOfA8OxdUkjDd/NtEjbI/dusvZayXW/00NcmFEN OR3G3GVvS81WU+THExX0Jx2WGC0IYwCCxcvRM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=TruIRsmWj0GgDi5vvHX49Vt76A/m9lhUqjX4KubefF0=; b=CPhAbCeqysaBPfLQ1UpYLES7WKx3SOJ9LHAfWHFaowyMAURUDC12YeOf/HAbxYTSqy 4xlzpwUTmeyvNUGIjcSm8bIRvH89PcYIJ0YqqoF6MTLn1r10nw1yswxksThtYZ3kcCMH bqRs8AnyYoa0zDCjpwF500UQiXOMNSyCm5YCxT1DTP/5ppHhQuYUPAdr2MWWjQgKaLig aXamAnd+SmrbC4eqF9wSp5w7aV4Q7bU80gzg1nnmrEIjuuLdMq8jxf2bp7JFaJ9ghe1b ieGlLtgGrWFDvyrTK/I3jTnhKIPYvHnXJIIgbtih2SWTnXu72CY7gxfF1Qyy8mdfkQdA 8AWg== X-Gm-Message-State: AGi0PuYqrKfWVarx5NF+f62B/1Zat+ParLAsH46pPAc1bnD7osIjL7vZ RBllXF7CTvy/SG18ZPDEjv8XOS+z X-Google-Smtp-Source: APiQypJ68xpxPcIvSo5yE9x6bTyne/Prqbq/pCWM1eh/+BNZqDicvf11jdKnjExU3+vSFZYCMhDREw== X-Received: by 2002:a17:902:b7c9:: with SMTP id v9mr6664032plz.197.1588751471471; Wed, 06 May 2020 00:51:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:aa7:9aee:: with SMTP id y14ls783952pfp.4.gmail; Wed, 06 May 2020 00:51:11 -0700 (PDT) X-Received: by 2002:a62:19d5:: with SMTP id 204mr7018614pfz.75.1588751470823; Wed, 06 May 2020 00:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751470; cv=none; d=google.com; s=arc-20160816; b=NcsBvjaKSUPNt2I/0nIKm3F8V4lU5FFB32LFyl2P6pd3hh+nDNCDF+dYRNQQYmlBkH 9MFjYWLYjDXnYtOpqjNsFtPJr+ETqErSChhaMkLWa3o01fXrNcjU2wta8/VWGwkmjYRC Fyz32ySTY1V/77LlD1IdCOlnoPm3piFAJO3CpoJGWXjQzvIGImnjWBBoDr/zDRR//vbY BJxaAQGdRVoLuqFs7sGA+n5veVmcB/mxFL0EJeJXuh7CGInc/fNE3sTb6w7TxPjRz16A bcmuOjVwyJb+wMjG/7Xqd409x7XhM6i9ju7KmmejGP2t1Nm1I/NuI9CIiZ0IcMkZFRqr g9ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tI4TXnMD8d5t9FtfaOId8gz4S9zwGkYsDtRQ9P+oLaM=; b=lzC4bOQYW/LHSgYEy5GQ8SesJtBPGll/p37Wum6CMVpuRCdCCJiouymhihfJWkz2zL HqiJj0KieHK7sdBZ1VwExRurwy9zuSX2XhX/Zjlmtg1DriJ2XFJXfj/Zwvg1YVcm9yp3 IOA/aKMpM37wNiHy6ojW6jRaK8jMyfteArm5Xq3u5TQBGgt9VBJ/QZrGSCgryc4lEOoe GiPZIERYEYUxaUavDU4TnQW2dI24joDSjPGVGsbPvkhbjI4EL4e7oR2Nqdr6HzMvbSIb XKWhUXkD6fdjQ/OYe1SZa7Y3rJA0/Jr/NHhOShxqAwO6A3vPqqxEn9/gtDaPsAlhJ35S hDNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bsE9ns+0; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a12sor1400455pgk.70.2020.05.06.00.51.10 for (Google Transport Security); Wed, 06 May 2020 00:51:10 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a63:6f07:: with SMTP id k7mr6325986pgc.274.1588751469934; Wed, 06 May 2020 00:51:09 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:51:08 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 6/7] phy: rockchip: Add Rockchip USB TypeC PHY driver Date: Wed, 6 May 2020 13:20:24 +0530 Message-Id: <20200506075025.1677-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=bsE9ns+0; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add USB TYPEC PHY driver for rockchip platform. Referenced from Linux TypeC PHY driver, currently supporting usb3-port and dp-port need to add it in the future. Signed-off-by: Frank Wang Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/phy/rockchip/Kconfig | 7 + drivers/phy/rockchip/Makefile | 1 + drivers/phy/rockchip/phy-rockchip-typec.c | 796 ++++++++++++++++++++++ 3 files changed, 804 insertions(+) create mode 100644 drivers/phy/rockchip/phy-rockchip-typec.c diff --git a/drivers/phy/rockchip/Kconfig b/drivers/phy/rockchip/Kconfig index d73ac695e1..84cc7c876d 100644 --- a/drivers/phy/rockchip/Kconfig +++ b/drivers/phy/rockchip/Kconfig @@ -11,4 +11,11 @@ config PHY_ROCKCHIP_INNO_USB2 help Support for Rockchip USB2.0 PHY with Innosilicon IP block. +config PHY_ROCKCHIP_TYPEC + bool "Rockchip TYPEC PHY Driver" + depends on ARCH_ROCKCHIP + select PHY + help + Enable this to support the Rockchip USB TYPEC PHY. + endmenu diff --git a/drivers/phy/rockchip/Makefile b/drivers/phy/rockchip/Makefile index 9b0cbc6acf..95b2f8a3c0 100644 --- a/drivers/phy/rockchip/Makefile +++ b/drivers/phy/rockchip/Makefile @@ -4,3 +4,4 @@ # obj-$(CONFIG_PHY_ROCKCHIP_INNO_USB2) += phy-rockchip-inno-usb2.o +obj-$(CONFIG_PHY_ROCKCHIP_TYPEC) += phy-rockchip-typec.o diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c b/drivers/phy/rockchip/phy-rockchip-typec.c new file mode 100644 index 0000000000..8810dd4350 --- /dev/null +++ b/drivers/phy/rockchip/phy-rockchip-typec.c @@ -0,0 +1,796 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ROCKCHIP Type-C PHY driver. + * + * Copyright (C) 2020 Amarula Solutions(India) + * Copyright (C) Fuzhou Rockchip Electronics Co.Ltd + * Author: Chris Zhong + * Kever Yang + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define usleep_range(a, b) udelay((b)) + +#define CMN_SSM_BANDGAP (0x21 << 2) +#define CMN_SSM_BIAS (0x22 << 2) +#define CMN_PLLSM0_PLLEN (0x29 << 2) +#define CMN_PLLSM0_PLLPRE (0x2a << 2) +#define CMN_PLLSM0_PLLVREF (0x2b << 2) +#define CMN_PLLSM0_PLLLOCK (0x2c << 2) +#define CMN_PLLSM1_PLLEN (0x31 << 2) +#define CMN_PLLSM1_PLLPRE (0x32 << 2) +#define CMN_PLLSM1_PLLVREF (0x33 << 2) +#define CMN_PLLSM1_PLLLOCK (0x34 << 2) +#define CMN_PLLSM1_USER_DEF_CTRL (0x37 << 2) +#define CMN_ICAL_OVRD (0xc1 << 2) +#define CMN_PLL0_VCOCAL_OVRD (0x83 << 2) +#define CMN_PLL0_VCOCAL_INIT (0x84 << 2) +#define CMN_PLL0_VCOCAL_ITER (0x85 << 2) +#define CMN_PLL0_LOCK_REFCNT_START (0x90 << 2) +#define CMN_PLL0_LOCK_PLLCNT_START (0x92 << 2) +#define CMN_PLL0_LOCK_PLLCNT_THR (0x93 << 2) +#define CMN_PLL0_INTDIV (0x94 << 2) +#define CMN_PLL0_FRACDIV (0x95 << 2) +#define CMN_PLL0_HIGH_THR (0x96 << 2) +#define CMN_PLL0_DSM_DIAG (0x97 << 2) +#define CMN_PLL0_SS_CTRL1 (0x98 << 2) +#define CMN_PLL0_SS_CTRL2 (0x99 << 2) +#define CMN_PLL1_VCOCAL_START (0xa1 << 2) +#define CMN_PLL1_VCOCAL_OVRD (0xa3 << 2) +#define CMN_PLL1_VCOCAL_INIT (0xa4 << 2) +#define CMN_PLL1_VCOCAL_ITER (0xa5 << 2) +#define CMN_PLL1_LOCK_REFCNT_START (0xb0 << 2) +#define CMN_PLL1_LOCK_PLLCNT_START (0xb2 << 2) +#define CMN_PLL1_LOCK_PLLCNT_THR (0xb3 << 2) +#define CMN_PLL1_INTDIV (0xb4 << 2) +#define CMN_PLL1_FRACDIV (0xb5 << 2) +#define CMN_PLL1_HIGH_THR (0xb6 << 2) +#define CMN_PLL1_DSM_DIAG (0xb7 << 2) +#define CMN_PLL1_SS_CTRL1 (0xb8 << 2) +#define CMN_PLL1_SS_CTRL2 (0xb9 << 2) +#define CMN_RXCAL_OVRD (0xd1 << 2) + +#define CMN_TXPUCAL_CTRL (0xe0 << 2) +#define CMN_TXPUCAL_OVRD (0xe1 << 2) +#define CMN_TXPDCAL_CTRL (0xf0 << 2) +#define CMN_TXPDCAL_OVRD (0xf1 << 2) + +/* For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL */ +#define CMN_TXPXCAL_START BIT(15) +#define CMN_TXPXCAL_DONE BIT(14) +#define CMN_TXPXCAL_NO_RESPONSE BIT(13) +#define CMN_TXPXCAL_CURRENT_RESPONSE BIT(12) + +#define CMN_TXPU_ADJ_CTRL (0x108 << 2) +#define CMN_TXPD_ADJ_CTRL (0x10c << 2) + +/* + * For CMN_TXPUCAL_CTRL, CMN_TXPDCAL_CTRL, + * CMN_TXPU_ADJ_CTRL, CMN_TXPDCAL_CTRL + * + * NOTE: some of these registers are documented to be 2's complement + * signed numbers, but then documented to be always positive. Weird. + * In such a case, using CMN_CALIB_CODE_POS() avoids the unnecessary + * sign extension. + */ +#define CMN_CALIB_CODE_WIDTH 7 +#define CMN_CALIB_CODE_OFFSET 0 +#define CMN_CALIB_CODE_MASK GENMASK(CMN_CALIB_CODE_WIDTH, 0) +#define CMN_CALIB_CODE(x) \ + sign_extend32((x) >> CMN_CALIB_CODE_OFFSET, CMN_CALIB_CODE_WIDTH) + +#define CMN_CALIB_CODE_POS_MASK GENMASK(CMN_CALIB_CODE_WIDTH - 1, 0) +#define CMN_CALIB_CODE_POS(x) \ + (((x) >> CMN_CALIB_CODE_OFFSET) & CMN_CALIB_CODE_POS_MASK) + +#define CMN_DIAG_PLL0_FBH_OVRD (0x1c0 << 2) +#define CMN_DIAG_PLL0_FBL_OVRD (0x1c1 << 2) +#define CMN_DIAG_PLL0_OVRD (0x1c2 << 2) +#define CMN_DIAG_PLL0_V2I_TUNE (0x1c5 << 2) +#define CMN_DIAG_PLL0_CP_TUNE (0x1c6 << 2) +#define CMN_DIAG_PLL0_LF_PROG (0x1c7 << 2) +#define CMN_DIAG_PLL1_FBH_OVRD (0x1d0 << 2) +#define CMN_DIAG_PLL1_FBL_OVRD (0x1d1 << 2) +#define CMN_DIAG_PLL1_OVRD (0x1d2 << 2) +#define CMN_DIAG_PLL1_V2I_TUNE (0x1d5 << 2) +#define CMN_DIAG_PLL1_CP_TUNE (0x1d6 << 2) +#define CMN_DIAG_PLL1_LF_PROG (0x1d7 << 2) +#define CMN_DIAG_PLL1_PTATIS_TUNE1 (0x1d8 << 2) +#define CMN_DIAG_PLL1_PTATIS_TUNE2 (0x1d9 << 2) +#define CMN_DIAG_PLL1_INCLK_CTRL (0x1da << 2) +#define CMN_DIAG_HSCLK_SEL (0x1e0 << 2) + +#define XCVR_PSM_RCTRL(n) ((0x4001 | ((n) << 9)) << 2) +#define XCVR_PSM_CAL_TMR(n) ((0x4002 | ((n) << 9)) << 2) +#define XCVR_PSM_A0IN_TMR(n) ((0x4003 | ((n) << 9)) << 2) +#define TX_TXCC_CAL_SCLR_MULT(n) ((0x4047 | ((n) << 9)) << 2) +#define TX_TXCC_CPOST_MULT_00(n) ((0x404c | ((n) << 9)) << 2) +#define TX_TXCC_CPOST_MULT_01(n) ((0x404d | ((n) << 9)) << 2) +#define TX_TXCC_CPOST_MULT_10(n) ((0x404e | ((n) << 9)) << 2) +#define TX_TXCC_CPOST_MULT_11(n) ((0x404f | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_000(n) ((0x4050 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_001(n) ((0x4051 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_010(n) ((0x4052 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_011(n) ((0x4053 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_100(n) ((0x4054 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_101(n) ((0x4055 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_110(n) ((0x4056 | ((n) << 9)) << 2) +#define TX_TXCC_MGNFS_MULT_111(n) ((0x4057 | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_000(n) ((0x4058 | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_001(n) ((0x4059 | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_010(n) ((0x405a | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_011(n) ((0x405b | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_100(n) ((0x405c | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_101(n) ((0x405d | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_110(n) ((0x405e | ((n) << 9)) << 2) +#define TX_TXCC_MGNLS_MULT_111(n) ((0x405f | ((n) << 9)) << 2) + +#define XCVR_DIAG_PLLDRC_CTRL(n) ((0x40e0 | ((n) << 9)) << 2) +#define XCVR_DIAG_BIDI_CTRL(n) ((0x40e8 | ((n) << 9)) << 2) +#define XCVR_DIAG_LANE_FCM_EN_MGN(n) ((0x40f2 | ((n) << 9)) << 2) +#define TX_PSC_A0(n) ((0x4100 | ((n) << 9)) << 2) +#define TX_PSC_A1(n) ((0x4101 | ((n) << 9)) << 2) +#define TX_PSC_A2(n) ((0x4102 | ((n) << 9)) << 2) +#define TX_PSC_A3(n) ((0x4103 | ((n) << 9)) << 2) +#define TX_RCVDET_CTRL(n) ((0x4120 | ((n) << 9)) << 2) +#define TX_RCVDET_EN_TMR(n) ((0x4122 | ((n) << 9)) << 2) +#define TX_RCVDET_ST_TMR(n) ((0x4123 | ((n) << 9)) << 2) +#define TX_DIAG_TX_DRV(n) ((0x41e1 | ((n) << 9)) << 2) +#define TX_DIAG_BGREF_PREDRV_DELAY (0x41e7 << 2) + +/* Use this for "n" in macros like "_MULT_XXX" to target the aux channel */ +#define AUX_CH_LANE 8 + +#define TX_ANA_CTRL_REG_1 (0x5020 << 2) + +#define TXDA_DP_AUX_EN BIT(15) +#define AUXDA_SE_EN BIT(14) +#define TXDA_CAL_LATCH_EN BIT(13) +#define AUXDA_POLARITY BIT(12) +#define TXDA_DRV_POWER_ISOLATION_EN BIT(11) +#define TXDA_DRV_POWER_EN_PH_2_N BIT(10) +#define TXDA_DRV_POWER_EN_PH_1_N BIT(9) +#define TXDA_BGREF_EN BIT(8) +#define TXDA_DRV_LDO_EN BIT(7) +#define TXDA_DECAP_EN_DEL BIT(6) +#define TXDA_DECAP_EN BIT(5) +#define TXDA_UPHY_SUPPLY_EN_DEL BIT(4) +#define TXDA_UPHY_SUPPLY_EN BIT(3) +#define TXDA_LOW_LEAKAGE_EN BIT(2) +#define TXDA_DRV_IDLE_LOWI_EN BIT(1) +#define TXDA_DRV_CMN_MODE_EN BIT(0) + +#define TX_ANA_CTRL_REG_2 (0x5021 << 2) + +#define AUXDA_DEBOUNCING_CLK BIT(15) +#define TXDA_LPBK_RECOVERED_CLK_EN BIT(14) +#define TXDA_LPBK_ISI_GEN_EN BIT(13) +#define TXDA_LPBK_SERIAL_EN BIT(12) +#define TXDA_LPBK_LINE_EN BIT(11) +#define TXDA_DRV_LDO_REDC_SINKIQ BIT(10) +#define XCVR_DECAP_EN_DEL BIT(9) +#define XCVR_DECAP_EN BIT(8) +#define TXDA_MPHY_ENABLE_HS_NT BIT(7) +#define TXDA_MPHY_SA_MODE BIT(6) +#define TXDA_DRV_LDO_RBYR_FB_EN BIT(5) +#define TXDA_DRV_RST_PULL_DOWN BIT(4) +#define TXDA_DRV_LDO_BG_FB_EN BIT(3) +#define TXDA_DRV_LDO_BG_REF_EN BIT(2) +#define TXDA_DRV_PREDRV_EN_DEL BIT(1) +#define TXDA_DRV_PREDRV_EN BIT(0) + +#define TXDA_COEFF_CALC_CTRL (0x5022 << 2) + +#define TX_HIGH_Z BIT(6) +#define TX_VMARGIN_OFFSET 3 +#define TX_VMARGIN_MASK 0x7 +#define LOW_POWER_SWING_EN BIT(2) +#define TX_FCM_DRV_MAIN_EN BIT(1) +#define TX_FCM_FULL_MARGIN BIT(0) + +#define TX_DIG_CTRL_REG_2 (0x5024 << 2) + +#define TX_HIGH_Z_TM_EN BIT(15) +#define TX_RESCAL_CODE_OFFSET 0 +#define TX_RESCAL_CODE_MASK 0x3f + +#define TXDA_CYA_AUXDA_CYA (0x5025 << 2) +#define TX_ANA_CTRL_REG_3 (0x5026 << 2) +#define TX_ANA_CTRL_REG_4 (0x5027 << 2) +#define TX_ANA_CTRL_REG_5 (0x5029 << 2) + +#define RX_PSC_A0(n) ((0x8000 | ((n) << 9)) << 2) +#define RX_PSC_A1(n) ((0x8001 | ((n) << 9)) << 2) +#define RX_PSC_A2(n) ((0x8002 | ((n) << 9)) << 2) +#define RX_PSC_A3(n) ((0x8003 | ((n) << 9)) << 2) +#define RX_PSC_CAL(n) ((0x8006 | ((n) << 9)) << 2) +#define RX_PSC_RDY(n) ((0x8007 | ((n) << 9)) << 2) +#define RX_IQPI_ILL_CAL_OVRD (0x8023 << 2) +#define RX_EPI_ILL_CAL_OVRD (0x8033 << 2) +#define RX_SDCAL0_OVRD (0x8041 << 2) +#define RX_SDCAL1_OVRD (0x8049 << 2) +#define RX_SLC_INIT (0x806d << 2) +#define RX_SLC_RUN (0x806e << 2) +#define RX_CDRLF_CNFG2 (0x8081 << 2) +#define RX_SIGDET_HL_FILT_TMR(n) ((0x8090 | ((n) << 9)) << 2) +#define RX_SLC_IOP0_OVRD (0x8101 << 2) +#define RX_SLC_IOP1_OVRD (0x8105 << 2) +#define RX_SLC_QOP0_OVRD (0x8109 << 2) +#define RX_SLC_QOP1_OVRD (0x810d << 2) +#define RX_SLC_EOP0_OVRD (0x8111 << 2) +#define RX_SLC_EOP1_OVRD (0x8115 << 2) +#define RX_SLC_ION0_OVRD (0x8119 << 2) +#define RX_SLC_ION1_OVRD (0x811d << 2) +#define RX_SLC_QON0_OVRD (0x8121 << 2) +#define RX_SLC_QON1_OVRD (0x8125 << 2) +#define RX_SLC_EON0_OVRD (0x8129 << 2) +#define RX_SLC_EON1_OVRD (0x812d << 2) +#define RX_SLC_IEP0_OVRD (0x8131 << 2) +#define RX_SLC_IEP1_OVRD (0x8135 << 2) +#define RX_SLC_QEP0_OVRD (0x8139 << 2) +#define RX_SLC_QEP1_OVRD (0x813d << 2) +#define RX_SLC_EEP0_OVRD (0x8141 << 2) +#define RX_SLC_EEP1_OVRD (0x8145 << 2) +#define RX_SLC_IEN0_OVRD (0x8149 << 2) +#define RX_SLC_IEN1_OVRD (0x814d << 2) +#define RX_SLC_QEN0_OVRD (0x8151 << 2) +#define RX_SLC_QEN1_OVRD (0x8155 << 2) +#define RX_SLC_EEN0_OVRD (0x8159 << 2) +#define RX_SLC_EEN1_OVRD (0x815d << 2) +#define RX_REE_CTRL_DATA_MASK(n) ((0x81bb | ((n) << 9)) << 2) +#define RX_DIAG_SIGDET_TUNE(n) ((0x81dc | ((n) << 9)) << 2) +#define RX_DIAG_SC2C_DELAY (0x81e1 << 2) + +#define PMA_LANE_CFG (0xc000 << 2) +#define PIPE_CMN_CTRL1 (0xc001 << 2) +#define PIPE_CMN_CTRL2 (0xc002 << 2) +#define PIPE_COM_LOCK_CFG1 (0xc003 << 2) +#define PIPE_COM_LOCK_CFG2 (0xc004 << 2) +#define PIPE_RCV_DET_INH (0xc005 << 2) +#define DP_MODE_CTL (0xc008 << 2) +#define DP_CLK_CTL (0xc009 << 2) +#define STS (0xc00F << 2) +#define PHY_ISO_CMN_CTRL (0xc010 << 2) +#define PHY_DP_TX_CTL (0xc408 << 2) +#define PMA_CMN_CTRL1 (0xc800 << 2) +#define PHY_PMA_ISO_CMN_CTRL (0xc810 << 2) +#define PHY_ISOLATION_CTRL (0xc81f << 2) +#define PHY_PMA_ISO_XCVR_CTRL(n) ((0xcc11 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_LINK_MODE(n) ((0xcc12 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_PWRST_CTRL(n) ((0xcc13 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_TX_DATA_LO(n) ((0xcc14 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_TX_DATA_HI(n) ((0xcc15 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_RX_DATA_LO(n) ((0xcc16 | ((n) << 6)) << 2) +#define PHY_PMA_ISO_RX_DATA_HI(n) ((0xcc17 | ((n) << 6)) << 2) +#define TX_BIST_CTRL(n) ((0x4140 | ((n) << 9)) << 2) +#define TX_BIST_UDDWR(n) ((0x4141 | ((n) << 9)) << 2) + +/* + * Selects which PLL clock will be driven on the analog high speed + * clock 0: PLL 0 div 1 + * clock 1: PLL 1 div 2 + */ +#define CLK_PLL_CONFIG 0X30 +#define CLK_PLL_MASK 0x33 + +#define CMN_READY BIT(0) + +#define DP_PLL_CLOCK_ENABLE BIT(2) +#define DP_PLL_ENABLE BIT(0) +#define DP_PLL_DATA_RATE_RBR ((2 << 12) | (4 << 8)) +#define DP_PLL_DATA_RATE_HBR ((2 << 12) | (4 << 8)) +#define DP_PLL_DATA_RATE_HBR2 ((1 << 12) | (2 << 8)) + +#define DP_MODE_A0 BIT(4) +#define DP_MODE_A2 BIT(6) +#define DP_MODE_ENTER_A0 0xc101 +#define DP_MODE_ENTER_A2 0xc104 + +#define PHY_MODE_SET_TIMEOUT 100000 + +#define PIN_ASSIGN_C_E 0x51d9 +#define PIN_ASSIGN_D_F 0x5100 + +#define MODE_DISCONNECT 0 +#define MODE_UFP_USB BIT(0) +#define MODE_DFP_USB BIT(1) +#define MODE_DFP_DP BIT(2) + +struct usb3phy_reg { + u32 offset; + u32 enable_bit; + u32 write_enable; +}; + +/** + * struct rockchip_usb3phy_port_cfg: usb3-phy port configuration. + * @reg: the base address for usb3-phy config. + * @typec_conn_dir: the register of type-c connector direction. + * @usb3tousb2_en: the register of type-c force usb2 to usb2 enable. + * @external_psm: the register of type-c phy external psm clock. + * @pipe_status: the register of type-c phy pipe status. + * @usb3_host_disable: the register of type-c usb3 host disable. + * @usb3_host_port: the register of type-c usb3 host port. + * @uphy_dp_sel: the register of type-c phy DP select control. + */ +struct rockchip_usb3phy_port_cfg { + unsigned int reg; + struct usb3phy_reg typec_conn_dir; + struct usb3phy_reg usb3tousb2_en; + struct usb3phy_reg external_psm; + struct usb3phy_reg pipe_status; + struct usb3phy_reg usb3_host_disable; + struct usb3phy_reg usb3_host_port; + struct usb3phy_reg uphy_dp_sel; +}; + +struct rockchip_tcphy { + void __iomem *reg_base; + void __iomem *grf_base; + struct clk clk_core; + struct clk clk_ref; + struct reset_ctl uphy_rst; + struct reset_ctl pipe_rst; + struct reset_ctl tcphy_rst; + const struct rockchip_usb3phy_port_cfg *port_cfgs; + u8 mode; +}; + +struct phy_reg { + u16 value; + u32 addr; +}; + +static struct phy_reg usb3_pll_cfg[] = { + { 0xf0, CMN_PLL0_VCOCAL_INIT }, + { 0x18, CMN_PLL0_VCOCAL_ITER }, + { 0xd0, CMN_PLL0_INTDIV }, + { 0x4a4a, CMN_PLL0_FRACDIV }, + { 0x34, CMN_PLL0_HIGH_THR }, + { 0x1ee, CMN_PLL0_SS_CTRL1 }, + { 0x7f03, CMN_PLL0_SS_CTRL2 }, + { 0x20, CMN_PLL0_DSM_DIAG }, + { 0, CMN_DIAG_PLL0_OVRD }, + { 0, CMN_DIAG_PLL0_FBH_OVRD }, + { 0, CMN_DIAG_PLL0_FBL_OVRD }, + { 0x7, CMN_DIAG_PLL0_V2I_TUNE }, + { 0x45, CMN_DIAG_PLL0_CP_TUNE }, + { 0x8, CMN_DIAG_PLL0_LF_PROG }, +}; + +static inline int property_enable(struct rockchip_tcphy *priv, + const struct usb3phy_reg *reg, bool en) +{ + u32 mask = 1 << reg->write_enable; + u32 val = en << reg->enable_bit; + + return writel(val | mask, priv->grf_base + reg->offset); +} + +static int rockchip_tcphy_get_mode(struct rockchip_tcphy *priv) +{ + /* TODO: Add proper logic to find DP or USB3 mode */ + return MODE_DFP_USB | MODE_UFP_USB; +} + +static void rockchip_tcphy_cfg_24m(struct rockchip_tcphy *priv) +{ + u32 i, rdata; + + /* + * cmn_ref_clk_sel = 3, select the 24Mhz for clk parent + * cmn_psm_clk_dig_div = 2, set the clk division to 2 + */ + writel(0x830, priv->reg_base + PMA_CMN_CTRL1); + for (i = 0; i < 4; i++) { + /* + * The following PHY configuration assumes a 24 MHz reference + * clock. + */ + writel(0x90, priv->reg_base + XCVR_DIAG_LANE_FCM_EN_MGN(i)); + writel(0x960, priv->reg_base + TX_RCVDET_EN_TMR(i)); + writel(0x30, priv->reg_base + TX_RCVDET_ST_TMR(i)); + } + + rdata = readl(priv->reg_base + CMN_DIAG_HSCLK_SEL); + rdata &= ~CLK_PLL_MASK; + rdata |= CLK_PLL_CONFIG; + writel(rdata, priv->reg_base + CMN_DIAG_HSCLK_SEL); +} + +static void rockchip_tcphy_cfg_usb3_pll(struct rockchip_tcphy *priv) +{ + u32 i; + + /* load the configuration of PLL0 */ + for (i = 0; i < ARRAY_SIZE(usb3_pll_cfg); i++) + writel(usb3_pll_cfg[i].value, + priv->reg_base + usb3_pll_cfg[i].addr); +} + +static void rockchip_tcphy_tx_usb3_cfg_lane(struct rockchip_tcphy *priv, + u32 lane) +{ + writel(0x7799, priv->reg_base + TX_PSC_A0(lane)); + writel(0x7798, priv->reg_base + TX_PSC_A1(lane)); + writel(0x5098, priv->reg_base + TX_PSC_A2(lane)); + writel(0x5098, priv->reg_base + TX_PSC_A3(lane)); + writel(0, priv->reg_base + TX_TXCC_MGNFS_MULT_000(lane)); + writel(0xbf, priv->reg_base + XCVR_DIAG_BIDI_CTRL(lane)); +} + +static void rockchip_tcphy_rx_usb3_cfg_lane(struct rockchip_tcphy *priv, + u32 lane) +{ + writel(0xa6fd, priv->reg_base + RX_PSC_A0(lane)); + writel(0xa6fd, priv->reg_base + RX_PSC_A1(lane)); + writel(0xa410, priv->reg_base + RX_PSC_A2(lane)); + writel(0x2410, priv->reg_base + RX_PSC_A3(lane)); + writel(0x23ff, priv->reg_base + RX_PSC_CAL(lane)); + writel(0x13, priv->reg_base + RX_SIGDET_HL_FILT_TMR(lane)); + writel(0x03e7, priv->reg_base + RX_REE_CTRL_DATA_MASK(lane)); + writel(0x1004, priv->reg_base + RX_DIAG_SIGDET_TUNE(lane)); + writel(0x2010, priv->reg_base + RX_PSC_RDY(lane)); + writel(0xfb, priv->reg_base + XCVR_DIAG_BIDI_CTRL(lane)); +} + +static int rockchip_tcphy_init(struct rockchip_tcphy *priv) +{ + const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs; + u32 val; + int ret; + + ret = clk_enable(&priv->clk_core); + if (ret) { + dev_err(phy->dev, "failed to enable core clk (ret=%d)\n", ret); + return ret; + } + + ret = clk_enable(&priv->clk_ref); + if (ret) { + dev_err(phy->dev, "failed to enable ref clk (ret=%d)\n", ret); + goto err_clk_core; + } + + ret = reset_deassert(&priv->tcphy_rst); + if (ret) { + dev_err(phy->dev, "failed to deassert uphy-tcphy reset (ret=%d)\n", + ret); + goto err_clk_ref; + } + + property_enable(priv, &cfg->typec_conn_dir, 0); + + rockchip_tcphy_cfg_24m(priv); + + rockchip_tcphy_cfg_usb3_pll(priv); + + rockchip_tcphy_tx_usb3_cfg_lane(priv, 0); + rockchip_tcphy_rx_usb3_cfg_lane(priv, 1); + + ret = reset_deassert(&priv->uphy_rst); + if (ret) { + dev_err(phy->dev, "failed to deassert uphy rst (ret=%d)\n", + ret); + goto err_tcphy_rst; + } + + ret = readl_poll_sleep_timeout(priv->reg_base + PMA_CMN_CTRL1, + val, val & CMN_READY, 10, + PHY_MODE_SET_TIMEOUT); + if (ret < 0) { + dev_err(phy->dev, "PMA Timeout!\n"); + ret = -ETIMEDOUT; + goto err_uphy_rst; + } + + ret = reset_deassert(&priv->pipe_rst); + if (ret) { + dev_err(phy->dev, "failed to deassert pipe rst (ret=%d)\n", + ret); + goto err_uphy_rst; + } + + return 0; + +err_uphy_rst: + reset_assert(&priv->uphy_rst); +err_tcphy_rst: + reset_assert(&priv->tcphy_rst); +err_clk_ref: + clk_disable(&priv->clk_ref); +err_clk_core: + clk_disable(&priv->clk_core); + return ret; +} + +static void rockchip_tcphy_exit(struct rockchip_tcphy *priv) +{ + reset_assert(&priv->tcphy_rst); + reset_assert(&priv->uphy_rst); + reset_assert(&priv->pipe_rst); + clk_disable(&priv->clk_core); + clk_disable(&priv->clk_ref); +} + +static int tcphy_cfg_usb3_to_usb2_only(struct rockchip_tcphy *priv, + bool value) +{ + const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs; + + property_enable(priv, &cfg->usb3tousb2_en, value); + property_enable(priv, &cfg->usb3_host_disable, value); + property_enable(priv, &cfg->usb3_host_port, !value); + + return 0; +} + +static int rockchip_usb3_phy_power_on(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_tcphy *priv = dev_get_priv(parent); + const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs; + const struct usb3phy_reg *reg = &cfg->pipe_status; + int timeout, new_mode; + u32 val; + int ret; + + new_mode = rockchip_tcphy_get_mode(priv); + if (new_mode < 0) { + dev_err(phy->dev, "invalid mode %d\n", new_mode); + return new_mode; + } + + if (priv->mode == new_mode) + return 0; + + if (priv->mode == MODE_DISCONNECT) { + ret = rockchip_tcphy_init(priv); + if (ret) { + dev_err(dev, "failed to init tcphy (ret=%d)\n", ret); + return ret; + } + } + + /* wait TCPHY for pipe ready */ + for (timeout = 0; timeout < 100; timeout++) { + val = readl(priv->grf_base + reg->offset); + if (!(val & BIT(reg->enable_bit))) { + priv->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB); + + /* enable usb3 host */ + tcphy_cfg_usb3_to_usb2_only(priv, false); + return 0; + } + usleep_range(10, 20); + } + + if (priv->mode == MODE_DISCONNECT) + rockchip_tcphy_exit(priv); + + return -ETIMEDOUT; +} + +static int rockchip_usb3_phy_power_off(struct phy *phy) +{ + struct udevice *parent = dev_get_parent(phy->dev); + struct rockchip_tcphy *priv = dev_get_priv(parent); + + tcphy_cfg_usb3_to_usb2_only(priv, false); + + if (priv->mode == MODE_DISCONNECT) + goto exit; + + priv->mode &= ~(MODE_UFP_USB | MODE_DFP_USB); + if (priv->mode == MODE_DISCONNECT) + rockchip_tcphy_exit(priv); + +exit: + return 0; +} + +static struct phy_ops rockchip_tcphy_usb3_ops = { + .power_on = rockchip_usb3_phy_power_on, + .power_off = rockchip_usb3_phy_power_off, +}; + +static void rockchip_tcphy_pre_init(struct udevice *dev) +{ + struct rockchip_tcphy *priv = dev_get_priv(dev); + const struct rockchip_usb3phy_port_cfg *cfg = priv->port_cfgs; + + reset_assert(&priv->tcphy_rst); + reset_assert(&priv->uphy_rst); + reset_assert(&priv->pipe_rst); + + /* select external psm clock */ + property_enable(priv, &cfg->external_psm, 1); + property_enable(priv, &cfg->usb3tousb2_en, 0); + + priv->mode = MODE_DISCONNECT; +} + +static int rockchip_tcphy_parse_dt(struct udevice *dev) +{ + struct rockchip_tcphy *priv = dev_get_priv(dev); + int ret; + + priv->grf_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + if (IS_ERR(priv->grf_base)) + return PTR_ERR(priv->grf_base); + + ret = clk_get_by_name(dev, "tcpdcore", &priv->clk_core); + if (ret) { + dev_err(dev, "failed to get tcpdcore clk (ret=%d)\n", ret); + return ret; + } + + ret = clk_get_by_name(dev, "tcpdphy-ref", &priv->clk_ref); + if (ret) { + dev_err(dev, "failed to get tcpdphy-ref clk (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "uphy", &priv->uphy_rst); + if (ret) { + dev_err(dev, "failed to get uphy reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "uphy-pipe", &priv->pipe_rst); + if (ret) { + dev_err(dev, "failed to get uphy-pipe reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "uphy-tcphy", &priv->tcphy_rst); + if (ret) { + dev_err(dev, "failed to get uphy-tcphy reset (ret=%d)\n", ret); + return ret; + } + + return 0; +} + +static int rockchip_tcphy_probe(struct udevice *dev) +{ + struct rockchip_tcphy *priv = dev_get_priv(dev); + const struct rockchip_usb3phy_port_cfg *phy_cfgs; + unsigned int reg; + int index, ret; + + priv->reg_base = (void __iomem *)dev_read_addr(dev); + if (IS_ERR(priv->reg_base)) + return PTR_ERR(priv->reg_base); + + ret = dev_read_u32_index(dev, "reg", 1, ®); + if (ret) { + dev_err(dev, "failed to read reg property (ret = %d)\n", ret); + return ret; + } + + phy_cfgs = (const struct rockchip_usb3phy_port_cfg *) + dev_get_driver_data(dev); + if (!phy_cfgs) + return -EINVAL; + + /* find out a proper config which can be matched with dt. */ + index = 0; + while (phy_cfgs[index].reg) { + if (phy_cfgs[index].reg == reg) { + priv->port_cfgs = &phy_cfgs[index]; + break; + } + + ++index; + } + + if (!priv->port_cfgs) { + dev_err(dev, "failed find proper phy-cfg\n"); + return -EINVAL; + } + + ret = rockchip_tcphy_parse_dt(dev); + if (ret) + return ret; + + rockchip_tcphy_pre_init(dev); + + return 0; +} + +static int rockchip_tcphy_bind(struct udevice *dev) +{ + struct udevice *tcphy_dev; + ofnode node; + const char *name; + int ret = 0; + + dev_for_each_subnode(node, dev) { + if (!ofnode_valid(node)) { + dev_info(dev, "subnode %s not found\n", dev->name); + return -ENXIO; + } + + name = ofnode_get_name(node); + dev_dbg(dev, "subnode %s\n", name); + + if (!strcasecmp(name, "dp-port")) { + printf("Warning: dp-port not supported yet!\n"); + continue; + } else if (!strcasecmp(name, "usb3-port")) { + ret = device_bind_driver_to_node(dev, + "rockchip_tcphy_usb3_port", + name, node, &tcphy_dev); + if (ret) { + dev_err(dev, + "'%s' cannot bind 'rockchip_tcphy_usb3_port'\n", + name); + return ret; + } + } + } + + return ret; +} + +static const struct rockchip_usb3phy_port_cfg rk3399_typec_phy_cfgs[] = { + { + .reg = 0xff7c0000, + .typec_conn_dir = { 0xe580, 0, 16 }, + .usb3tousb2_en = { 0xe580, 3, 19 }, + .external_psm = { 0xe588, 14, 30 }, + .pipe_status = { 0xe5c0, 0, 0 }, + .usb3_host_disable = { 0x2434, 0, 16 }, + .usb3_host_port = { 0x2434, 12, 28 }, + .uphy_dp_sel = { 0x6268, 19, 19 }, + }, + { + .reg = 0xff800000, + .typec_conn_dir = { 0xe58c, 0, 16 }, + .usb3tousb2_en = { 0xe58c, 3, 19 }, + .external_psm = { 0xe594, 14, 30 }, + .pipe_status = { 0xe5c0, 16, 16 }, + .usb3_host_disable = { 0x2444, 0, 16 }, + .usb3_host_port = { 0x2444, 12, 28 }, + .uphy_dp_sel = { 0x6268, 3, 19 }, + }, + { /* sentinel */ } +}; + +static const struct udevice_id rockchip_typec_phy_ids[] = { + { + .compatible = "rockchip,rk3399-typec-phy", + .data = (ulong)&rk3399_typec_phy_cfgs, + }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(rockchip_tcphy_usb3_port) = { + .name = "rockchip_tcphy_usb3_port", + .id = UCLASS_PHY, + .ops = &rockchip_tcphy_usb3_ops, +}; + +U_BOOT_DRIVER(rockchip_typec_phy) = { + .name = "rockchip_typec_phy", + .id = UCLASS_PHY, + .of_match = rockchip_typec_phy_ids, + .probe = rockchip_tcphy_probe, + .bind = rockchip_tcphy_bind, + .priv_auto_alloc_size = sizeof(struct rockchip_tcphy), +}; From patchwork Wed May 6 07:50:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1155 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id A16983F1D2 for ; Wed, 6 May 2020 09:51:16 +0200 (CEST) Received: by mail-pj1-f69.google.com with SMTP id l11sf1617693pjz.4 for ; Wed, 06 May 2020 00:51:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588751475; cv=pass; d=google.com; s=arc-20160816; b=GVAfNbbXfAvaH3dFFx4/cz5kAI7Td/hGQQxmuZErHYibmQx4MhFnTxY5GsGhsu48zc segO7TlTIMIteW+kQOgjCS+UMcuS//A7HdxNnKxCtW490s5oxYe+xlzMRaLenVKji/zF GL/6p00GsMRd1huWiXjf7tg2sOxTLWFsPd4CpMEhtvYdTorqXkpd7quppzbrFESueSoj sfSExVHlau9TTPp4pQEvJ0L6TT3dnia3JQr0cJXLpzDXp5CtV1qWw2Bztp0XvYk+akOy cAzzoXdNAJ7gtKJctfnh0LApWeW3H1gsujTZdCxcxQSokLuIRztzkWyj9aZSkg/nuh4i dW4w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:references:in-reply-to:message-id:date :subject:cc:to:from:mime-version:dkim-signature; bh=jZ62OsspO1I4k0P5tmrTwQtOGmxYvSuhYb92e7R4MfI=; b=Lj4vKUquK1f14jqyUw36f5oPM73lVXA+5lJbweVe5O41vMyaDUwjxI/VDnJRKiKLKg jCHA52YFAieoyTOj6AoiXptL8a5vp++ChdltO5cyRfADBK9Wk3eMSOWS+HrMWIbvB57X Y1tsUhQdEbek22smHKinagsLiu0cpXPLgTI7zy/9xUOzxbyc5ZkhUN9NX6alw9V1rT6U TKUDTJir/D0w50mSUl5kn6MijGT5vqpFPD1Hj+/qlG4TykxRFBGoCOB2RNqQzcxViABL atPhN7Ay5MxGpfFp+XZ0Lf4M32WnPDLHw47sLfvVUhm0HR/qVWQ3PEpYqzORwPAFcvxN h2Rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SP24HoaQ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=mime-version:from:to:cc:subject:date:message-id:in-reply-to :references:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=jZ62OsspO1I4k0P5tmrTwQtOGmxYvSuhYb92e7R4MfI=; b=UBOqmkrR0IYaKgJSSYoLMegUZjdqwa8KCgB7nZ1yIa7fY3Dq8G3vivfncj1EaRBHz0 UzzQCwHjGPHS/cB97sDAq4wc+PTMC9fB2iRYPwkp4eVCCm9fXiAlMoqpQmDyd0Y/uZGi yMoSGqREoSfbW0LH/8Z3tQWiPpDr/vRzZhx8Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:to:cc:subject:date:message-id :in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=jZ62OsspO1I4k0P5tmrTwQtOGmxYvSuhYb92e7R4MfI=; b=ppt1AkvvIq/GR26Hxqln7REzh5zohdsymFsoXvo+vKMcS8ZcLufd+/rtTfP5aqAOCj k/1QxX4BxJE85wWH5wILWTUYeFe4g33sQyH9ZKKRd1ODdv1ztgaAusQ7K7J7PxrQVT3M Pxnob/MbJv2HU2kVIDGW3YJSPyhbHcu7sevBrOoTazswWGCNd12N4cc6j8HXFFuwZngE UxxxEsZKUlR68+90GDD8m7obK1cujypq+dcMPKOOZy0FLQN0tjlGYGIpTE55/cpOqioN fgnrQ+P0Euc8sPTsCBFtrnCHZEx8n1KYDNt3EMxfPFaPVttmdRD8RlNmYxy0j8Vt+9By a89g== X-Gm-Message-State: AGi0PuZWYrLqoEZI/ASNWX7oYIeP69QmYYbAnyNn2b4VCK26UOfV7CgC kl+GS1UsXMcH4rlGtOLVrjxs7UJP X-Google-Smtp-Source: APiQypJpyJAqeCHmLRXHFCg3NF7WSjZ/LMaR8PSol/ttZNXlRVYGTkyhdPLYQH6Hq4zKWzt/snPjEw== X-Received: by 2002:a17:90a:d0c3:: with SMTP id y3mr7593765pjw.133.1588751475407; Wed, 06 May 2020 00:51:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:9a03:: with SMTP id v3ls1691882plp.11.gmail; Wed, 06 May 2020 00:51:15 -0700 (PDT) X-Received: by 2002:a17:902:bf08:: with SMTP id bi8mr5995297plb.319.1588751474930; Wed, 06 May 2020 00:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588751474; cv=none; d=google.com; s=arc-20160816; b=eUMw/4AMyfjMnDXrH3z1S90C+ecbjvjkSHgDa6WZlHqcjXTM3CRVxmhn8A2d4tjU1t cdbcPjEvoD+eSlKQXWAqncj0jHZh+Dxv9psLlgdJSEBMhZ7Z8ozmgQJ86YFnhYiap4sp /H0MxHZT8FE+hjos2l/CLmiIkzD/D1DbyBQh2Q3+Ea1WAPc2mZRbtwRNkpXICHG8RaZp Mk6LncKd9SJQ5Ll45b/nWbbKBvhQt5F6YT0XnPM+cl5RLtRTb7P6JcIBwulsn4Wh2uUk wGKsubEmjjJqXcqv4Og8UQvY/+3tPWDk6KHlrHfdDQ917kujGAyF8hwOp4vFhLYjM8JD FnKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gUJPo9co6Z5KOWvrWwwrf+/d75bLFFIFHCHrCqTsa6w=; b=omsmAmdZMbKPRy67jiWt/QhOMAMG/u1HLIOREBehNNOd1k8pHp3Cpmi6RG5xqAy5IZ 12oC6lvanysCW1P7wCLzkFwYHfpS3+OJAX3Gzad1KdrQ/FeR/hmEDjrXqmalcEeRvpeM GcTIaqyX6F6YQJV7UF7QcwZ4len+jzRDJ85jZDckPXQiRrUKzOokl9ocGKIfgSFAVbJe G3cSgM48viy+MtW4mgyEe2XxC3D7v8vIKEvSm/7AH64wEAOAVvgOUBGST964mj+jtuk4 +k1n5BLIYJ39dYY3wIwKn1sMS50xd8pI3RjsaH9C6TdZcYdVQGA8F17Lal+SZVCaJZw1 wyCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SP24HoaQ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id a1sor1550251plp.28.2020.05.06.00.51.14 for (Google Transport Security); Wed, 06 May 2020 00:51:14 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:7444:: with SMTP id e4mr7140437plt.130.1588751474575; Wed, 06 May 2020 00:51:14 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:c598:8eeb:af7:7f36]) by smtp.gmail.com with ESMTPSA id y186sm1011133pfy.66.2020.05.06.00.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2020 00:51:13 -0700 (PDT) From: Jagan Teki To: kever.yang@rock-chips.com, philipp.tomsich@theobroma-systems.com, Simon Glass , Frank Wang , wmc@rock-chips.com, chenjh@rock-chips.com, heiko@sntech.de Cc: u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, Belisko Marek , linux-amarula@amarulasolutions.com, Jagan Teki , Marek Vasut Subject: [PATCH v2 7/7] usb: dwc3: add dis_del_phy_power_chg_quirk Date: Wed, 6 May 2020 13:20:25 +0530 Message-Id: <20200506075025.1677-8-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200506075025.1677-1-jagan@amarulasolutions.com> References: <20200506075025.1677-1-jagan@amarulasolutions.com> X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=SP24HoaQ; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Add a quirk to clear the GUSB3PIPECTL.DELAYP1TRANS bit, which specifies whether disable delay PHY power change from P0 to P1/P2/P3 when link state changing from U0 to U1/U2/U3 respectively. Reference from below Linux commit, commit <00fe081dc3a3> ("usb: dwc3: add dis_del_phy_power_chg_quirk") Cc: Marek Vasut Signed-off-by: Jagan Teki --- Changes for v2: - new patch drivers/usb/dwc3/core.c | 6 ++++++ drivers/usb/dwc3/core.h | 1 + include/dwc3-uboot.h | 1 + 3 files changed, 8 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 4ec3f6df6a..6e438e5604 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -377,6 +377,9 @@ static void dwc3_phy_setup(struct dwc3 *dwc) if (dwc->dis_u3_susphy_quirk) reg &= ~DWC3_GUSB3PIPECTL_SUSPHY; + if (dwc->dis_del_phy_power_chg_quirk) + reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE; + dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg); mdelay(100); @@ -715,6 +718,7 @@ int dwc3_uboot_init(struct dwc3_device *dwc3_dev) dwc->rx_detect_poll_quirk = dwc3_dev->rx_detect_poll_quirk; dwc->dis_u3_susphy_quirk = dwc3_dev->dis_u3_susphy_quirk; dwc->dis_u2_susphy_quirk = dwc3_dev->dis_u2_susphy_quirk; + dwc->dis_del_phy_power_chg_quirk = dwc3_dev->dis_del_phy_power_chg_quirk; dwc->tx_de_emphasis_quirk = dwc3_dev->tx_de_emphasis_quirk; if (dwc3_dev->tx_de_emphasis) @@ -975,6 +979,8 @@ void dwc3_of_parse(struct dwc3 *dwc) "snps,dis_u3_susphy_quirk"); dwc->dis_u2_susphy_quirk = dev_read_bool(dev, "snps,dis_u2_susphy_quirk"); + dwc->dis_del_phy_power_chg_quirk = dev_read_bool(dev, + "snps,dis-del-phy-power-chg-quirk"); dwc->tx_de_emphasis_quirk = dev_read_bool(dev, "snps,tx_de_emphasis_quirk"); tmp = dev_read_u8_array_ptr(dev, "snps,tx_de_emphasis", 1); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1c08a2c5b6..7f45a9c459 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -821,6 +821,7 @@ struct dwc3 { unsigned rx_detect_poll_quirk:1; unsigned dis_u3_susphy_quirk:1; unsigned dis_u2_susphy_quirk:1; + unsigned dis_del_phy_power_chg_quirk:1; unsigned tx_de_emphasis_quirk:1; unsigned tx_de_emphasis:2; diff --git a/include/dwc3-uboot.h b/include/dwc3-uboot.h index 3c9e204cf0..f5086fb946 100644 --- a/include/dwc3-uboot.h +++ b/include/dwc3-uboot.h @@ -32,6 +32,7 @@ struct dwc3_device { unsigned rx_detect_poll_quirk; unsigned dis_u3_susphy_quirk; unsigned dis_u2_susphy_quirk; + unsigned dis_del_phy_power_chg_quirk; unsigned tx_de_emphasis_quirk; unsigned tx_de_emphasis; int index;