From patchwork Sat Apr 25 11:03:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1115 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 A23893F078 for ; Sat, 25 Apr 2020 13:04:13 +0200 (CEST) Received: by mail-pg1-f198.google.com with SMTP id u28sf6624629pgn.18 for ; Sat, 25 Apr 2020 04:04:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812652; cv=pass; d=google.com; s=arc-20160816; b=v3wx7+/BJSIarszgmeWzPH9yqvbB35S5JXsNhxOpzqMaUo8yygKd81kZCnaS2kOTbk /OA8ELMp5EWOlqg9eaqhDSbIUReBVo29FinorOMcGm79sqmOFtVSFv1HzcSlr3XY93H0 m+Z38I7M08z56sBtqiBNJReeVEiVFdX8s+VohEaVi14oLdXslWQlq+OlyI0ieoPLFKUq dH1XoWRkSOeksnUaMwwle9WJ3uJNqgNaz1fetnd1nxGoi+r+1j+widVxNL9/vclJ5x5V VhZNEkyO3yLVlEDhDCrW2S1zsaXe6qv3uVPr8bX2uUpcgH/nWThBNIUoABQHcnFp+Yox Ledg== 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=Uw3TOvqm1NdM6ZbM9SSbZaCDIJ51DIkjmbz7Sv/GivpkitV1qoPwm5G+RZPQLWEowI kfO+rTUGOL+D/GOreWVUT222d0qdz2BFvOqPYAR2XXdC4lm2GTyycjYsvyz5bQdSxz3I t0fk6UA8/HjkjHjs4TIFp+HsR1CnFkb8mKXHq1sJzcnrnYzCMmkvsBeV5qbbKKfHyjGw T0n0+Iaw7kYvrBlGxTf5OaghJkS4vYsY6WBzvQYpiLy4FOvkmo3BMV69g0IBrVHC2YuT 3aMluobcgmEnjA1JDxfDtzoGBi8+qQq3fNlzNABU/66AYKGCp0xwuv3bUQ7ODf0hbGjb ZASA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Py6BLBmu; 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=P13QSoXvYvJ1rW5iyNt5QlMGlUd2u2IkTBGserNOX4HDOnhg+EW0VN0rmGJplXRRrT 5MRNL9eAd0hsYAMPIYNAImQSstxu2+6yqPxPBGnhtqORCKwESWgyPzE0VQ0FLZqDK1ob wZft61FGZE5Gn8ttORkizfAw16aNSatV3XMa8= 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=EUJEicapXnzAJItfJeLFVDW8zrD0XmpWD4MfansJXCw=; b=rtKjIBIkpDaWK5Fwa7YvbsgyIrfqaE/a00Fcld7Zghk60QmCzEC+Li9td6d1VmTaf7 q7Yr34ZhJtLf0jwbkGEiHKBxlvnUsOXvtYopKCxyAj1owBEgkUqf7qw9Vr9fOKaGQtIq DYMPXmmcwXGv8acVKDjn2McicMwWESADuutti+sn3XUZap+BzKzf+8N91swHKuJSewUg nvkRzAsqlp+HF8y3PExLQKqZo1H5LIZ63UISZQl2638M5jKxrrISV8dYRhoGJYjaKauI 28+REgwu9Crm3Wf3TCDAAeD/2NoI6Fmsxq6hP1XtTw1APynaXA3Xuc2RaNWZ/ZsuEPaM 66qg== X-Gm-Message-State: AGi0PuafyDTBExPmFnU4h5UKnLgcZKM2Rw+SMYPiY1ic0vSP+RXgGG6+ ptpPPv7Am2x3UY31SoCseOMjQB/f X-Google-Smtp-Source: APiQypJa6g3hXTcwx2bl6KVe1G++4bJfuUcQdP5LB8jw+RoLgjWIMfe/L/gaEjYIEJwhNBvkNda3IQ== X-Received: by 2002:a17:90a:cb86:: with SMTP id a6mr11927155pju.127.1587812651927; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:4383:: with SMTP id q125ls6782951pga.7.gmail; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) X-Received: by 2002:a62:4e88:: with SMTP id c130mr14823793pfb.122.1587812651467; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812651; cv=none; d=google.com; s=arc-20160816; b=o+KqQmN2w8oJJrN+vwICeJSU78w+Xvc/E/IgkDIoK5waGMXa3NIaE6FAoM1AxVNFhy L8vEdl/BYmS0kVdEGdoocEvsxzctqBLDyrUIphCuG2lnugVvjd0YcYp46gc/3/0PGgSN Csk6de8Z5EQUbPxD2DDI24zzDWG0d6RRCUgDaX00YBkDWCw3nghWkwfVOCbpfaCRWZL5 SWQJOcs1mXPSJ5oYToAu0IB4utujjmAsLzx+K/ezx/7DXIi1jAOjsqimiwbP9mYaAnvG VapV0fbYJf0Oyt+2YKSojGyTRNyPcVFkMQ7ev3Ihn3ZY+sFUsI6sKFKRYHKEEavOw5+N UBKA== 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=KSjRhow/FzmNp0a4JMMIZ4uuTafzN1q6iJz8aYRJVeY=; b=IpBbdYcv2fH9iORKd0/CaiSubyIckyErL6NcnVP6bn8hZsMpKXzYiUT+yayhBVGyzn bPVrlgsceN6Az95cBp++xErL4BgQDm16WSOuuGv9A2cCnyhQygMhYGYLQsMETiMNPG6J WTuJGJtMt4ffyuSpTqS6Wq3klTU4KO06QKuMOJXyQT896JzlsrxkOs6LU/sbL8IAYRCh ClX6lSaT0xAVvuQik8mtYoMiy0MBRdbpoCC4p/qXDUAuKzGhM/Ednd4tp2oCr8r2CPur MwgQb87cEp3/mQGjuewoITlEmltWRkPWLhdazOF4xuPxjiJkadh7lGJ/VDobweZWE6c1 cmHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=Py6BLBmu; 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 z19sor11435563pjq.5.2020.04.25.04.04.11 for (Google Transport Security); Sat, 25 Apr 2020 04:04:11 -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:90b:3d8:: with SMTP id go24mr11616409pjb.33.1587812651122; Sat, 25 Apr 2020 04:04:11 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:10 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki , Tom Rini Subject: [PATCH 1/8] iopoll: Add dealy to read poll Date: Sat, 25 Apr 2020 16:33:47 +0530 Message-Id: <20200425110354.12381-2-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=Py6BLBmu; 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: , Some drivers and other bsp code not only poll the register with timeout but also required to delay on each transaction. This patch add that requirement by adding sleep_us variable so-that read_poll_timeout now support delay as well. Cc: Tom Rini Signed-off-by: Jagan Teki --- include/linux/iopoll.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index ab0ae1969a..0bbd757939 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -16,6 +16,7 @@ * @addr: Address to poll * @val: Variable to read the value into * @cond: Break condition (usually involving @val) + * @sleep_us: Maximum time to sleep in us * @timeout_us: Timeout in us, 0 means never timeout * * Returns 0 on success and -ETIMEDOUT upon a timeout. In either @@ -24,7 +25,7 @@ * When available, you'll probably want to use one of the specialized * macros defined below rather than this macro directly. */ -#define readx_poll_timeout(op, addr, val, cond, timeout_us) \ +#define readx_poll_timeout(op, addr, val, cond, sleep_us, timeout_us) \ ({ \ unsigned long timeout = timer_get_us() + timeout_us; \ for (;;) { \ @@ -35,33 +36,34 @@ (val) = op(addr); \ break; \ } \ + if (sleep_us) \ + udelay(sleep_us); \ } \ (cond) ? 0 : -ETIMEDOUT; \ }) - #define readb_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readb, addr, val, cond, timeout_us) + readx_poll_timeout(readb, addr, val, cond, false, timeout_us) #define readw_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readw, addr, val, cond, timeout_us) + readx_poll_timeout(readw, addr, val, cond, false, timeout_us) #define readl_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readl, addr, val, cond, timeout_us) + readx_poll_timeout(readl, addr, val, cond, false, timeout_us) #define readq_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readq, addr, val, cond, timeout_us) + readx_poll_timeout(readq, addr, val, cond, false, timeout_us) #define readb_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readb_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readb_relaxed, addr, val, cond, false, timeout_us) #define readw_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readw_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readw_relaxed, addr, val, cond, false, timeout_us) #define readl_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readl_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readl_relaxed, addr, val, cond, false, timeout_us) #define readq_relaxed_poll_timeout(addr, val, cond, timeout_us) \ - readx_poll_timeout(readq_relaxed, addr, val, cond, timeout_us) + readx_poll_timeout(readq_relaxed, addr, val, cond, false, timeout_us) #endif /* _LINUX_IOPOLL_H */ From patchwork Sat Apr 25 11:03:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1116 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 07EFA3F078 for ; Sat, 25 Apr 2020 13:04:17 +0200 (CEST) Received: by mail-pj1-f72.google.com with SMTP id w4sf10517910pjt.2 for ; Sat, 25 Apr 2020 04:04:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812656; cv=pass; d=google.com; s=arc-20160816; b=hcMWM71v29HQcl2Tma19/orgLKE75T4slaWxPoBEHgCYJkc3YAslPKy0ihSCkT0LKf sduxn7btCxz56icTR+7743hy3kaoqiUwbPvE3aWdTVyqogkNmDogInsxGY5drBeuv+RP Q4XiYuAqCPZjs72hqeieU6ati5eKwe82yXBd5Uow/GekaJi9BHhUSW05rB2eQUhfKWvK cdamBa72n4X3AtZTGGd4vvAmBWkdDVS9QNy0E/AVWEjhY9fuduVhzasTCfibOBC257ha 4Qo7lYM4JsDhjD0kR2wY4dDS7rEWGUpEJUH+V/kTd1dClOnC7vjBVt9gDCoSze0tLnyy uPGQ== 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=WMfl8dwqqeXUmxvplaDP/NWYWijW9LJ8dnjlRbgFH9U=; b=G95xYC+6CfJFimisBEpXeD9kqthPwwzEEila/LS+n6ETmT/VqpF7KFSXoEJjF+hXaz SIjJubmRhQZY17wQatx8Ks6OMzB/ABzg1mrwEmYUP6hVIByCUjOE6Mn7AgWE4sKS4byx 6OHotxCVWec3Xkb60k4F1JTJCJJilT5cQxKMc2uNwOpptoxelAERXzk77DB3Cha55YPQ TGTwk/Z209vhuDGj9mnHc5odHwhJt4jCCLLtMPKKTApipG4+aSStFyKevQdHpzNzOfjz TiN4XOBGn1dLQfHARHcvxfRNbpt0Za0BZAof3e+GonqSGUSJ9bw7ev8ExfoaYicuvKDn fhEQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fmtndGht; 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=WMfl8dwqqeXUmxvplaDP/NWYWijW9LJ8dnjlRbgFH9U=; b=mRTjONOvUTU+XDqBnq8bbW0vAfNhj0W/13YUvrq6j/fTuZANkwBt9p2kC13ZVpLajO HCgfCUcXfynFxjTqyD3nmMLEgMotpIeRWamv5EspLH7IwMIRcoiz8vPpcTZrXAatQgDQ 57f7yJvcemdsTPNK/L1JfvARLAfUMfOOawR+c= 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=WMfl8dwqqeXUmxvplaDP/NWYWijW9LJ8dnjlRbgFH9U=; b=HRyXXB5J5ViwYYcX9uPZiRXgLa5w9iEb41Xz/cVvPqiNpLtwQYcxMrs65d4ymWKgz2 OnWzCmVNrnekgEr51z1xKac0X3Tik/KgNI7hWc/EHnHAxnNmTC/pOVcMuOwMpoYMrlEp +0b6QOs0oKqoYk7nJFKE2bsQbvlTnh2Raij1M1HksoNK2DEYTne/Kjbwykhbwkd+wJUF FFGHUm34GzpeZXXXVk2PLS9jam6oAa6XvlQitrsapoRyyIsEstxg+yC1wICMXdJ77546 r5syuCAOhF/rR6IV3eTSTfFHD4t5CIXE9JESOa/lUVdWdTIdf/bI4XSN/PSeR0bFK1UF SHZA== X-Gm-Message-State: AGi0Pubh+QAd3GG4ddAcQnNINgHhXOTfEPhQO2nUBm5MEvB5VkTlQgnW QisEL3NGq25wSqoGJan+7xnczT7u X-Google-Smtp-Source: APiQypLvSsQgR5CFkKdPoFzXZUt3w2Nk3YmajaCVOyESJkLqZXgJFT7rpeRZHcDT2c7uveyBFfyHgw== X-Received: by 2002:a62:19d5:: with SMTP id 204mr14493753pfz.75.1587812655810; Sat, 25 Apr 2020 04:04:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:5d97:: with SMTP id t23ls10599454pji.0.canary-gmail; Sat, 25 Apr 2020 04:04:15 -0700 (PDT) X-Received: by 2002:a17:902:a5c2:: with SMTP id t2mr13797332plq.151.1587812655372; Sat, 25 Apr 2020 04:04:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812655; cv=none; d=google.com; s=arc-20160816; b=IeMRg7Yv0Cgbwonbn00Uy6/ttDrM4+91ivN1sU9RTTHcfBZWo2g0kUcjRY0H21pi4z 4lUu1x5Y84o6OAC3kFXpoIw7qxIyVI7aJOTLxMgRveGizDvyXlJ3CCfUKbE91h9b6Qa3 7vTB7dj5p9Sa2I8jO907FLRSFJk+/xydmITD47bTjEScrLpuSgx1+t8cZc7aKrIOA3J1 KwVS17urfh9xecPSaVONAExyWlz7eoCKwdDNm6GaCrR+U6VVEBW93KM0cLsL9zVEQTdh P7LV9roc2PURksVUG+TCEcf8hVum4F3gL6TYFTiVQ4widZkc7R2PDzOc8j5QFVJ4AyIt pj5g== 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=aUlll32zfX7ITjPFpHp0Q7B45yE/EkgzuSyxmyuDIG4=; b=kYhoHJozoVltD7vUvcKsFRrKXoxMRpXaCiB2vK+2pGDOGxSx61wcYVrh6rXXhVBceK zhO1jLQf0sKuxsb3Moj1sMt+KT71e0ha2uABRImFD7Bz34JZB/wuT6cuajHF0EKMrYR3 z/bBuE4x5YOpTAKtr1KenVta7hK9zuSExQosThkWO2gPMYgL1w8ithGQp2XcP1j0b+Qa /o9xmY/6MrOrvBZzd3PIAUeLiZbSuYwV+jxp+P/MYNr6BRY2oUkZmjuPHbCveCflte6Q +WVl+rz5r7981pwJQ6rV6ieiLzroangQCclw+5S6SXvxiWOHtAErps70WQmEZNoFygrm K6Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fmtndGht; 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 1sor11539880pla.14.2020.04.25.04.04.15 for (Google Transport Security); Sat, 25 Apr 2020 04:04:15 -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:347:: with SMTP id 65mr13880569pld.21.1587812655032; Sat, 25 Apr 2020 04:04:15 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:14 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki , Tom Rini Subject: [PATCH 2/8] iopoll: Add readl_poll_sleep_timeout Date: Sat, 25 Apr 2020 16:33:48 +0530 Message-Id: <20200425110354.12381-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=fmtndGht; 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 readl poll API with sleep and timeout support. Cc: Tom Rini Signed-off-by: Jagan Teki --- include/linux/iopoll.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index 0bbd757939..e087f23271 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -42,6 +42,9 @@ (cond) ? 0 : -ETIMEDOUT; \ }) +#define readl_poll_sleep_timeout(addr, val, cond, sleep_us, timeout_us) \ + readx_poll_timeout(readl, addr, val, cond, sleep_us, timeout_us) + #define readb_poll_timeout(addr, val, cond, timeout_us) \ readx_poll_timeout(readb, addr, val, cond, false, timeout_us) From patchwork Sat Apr 25 11:03:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1117 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 347893F078 for ; Sat, 25 Apr 2020 13:04:21 +0200 (CEST) Received: by mail-pl1-f197.google.com with SMTP id n18sf9955526plp.17 for ; Sat, 25 Apr 2020 04:04:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812660; cv=pass; d=google.com; s=arc-20160816; b=fHwbFo9BfDlhWUkDjafcytidvfIFv1CiBtCa59EnqjO612hc9hurHtGGxSpcW04veS SkmL0HQFus/XvdSpmiyqQTQr5T/8Qb4Po6nRd/T1H+EesHL+dXYOCiyaY0uun1ZpCRYz EQ293LyeEg/p5HT3Sp2Xpdx7k6rIpNbZXY25uFe90HxZsReJevM/mcqebNMn2mhAUxPm ++Vpe/kgdZMHeIzp3g8Tu+7f1mfdubEZM5Uz0px8ShKtmT1qUfyrQz14fY4+n/Q+VB1U PePtzq+B+Z9SUUgCw6P6fmv0Twf2PgUQYY/6n7L16laFmJPxPo4GHqaucAsuYLxyW8mE qa6w== 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=f41ZVV6jsaWC1Z6wTRB2qy6CrRYqfc63EtChEoKkG5Q=; b=tLXgWWbTldrF54xxRQx9Agq4uJS8MM82mQVvb0KBVE+M+ddwJF8BRencG/ITJXK/9r 5aDHmLESrUWB63MiJfdbk62wpku4YY2oSXibbM9bzG7IiDn4c9DCy5wda1/PEbJ6OIjI VSindfWt3p5VwYGc6A4C63GtR0iztEIj3qNZkfstuxuYXR7P7Lo2Pny9M7/yhMSRJpmH bcwBT9e62q5bRIw9ecpx2KRobkmkR19gKH5x6szGBI+ne/DkKvLD3TugTnb3zYZ1Rrrd sjF1fwpGM0on/tDeU5cYKe8yQUl8nfGbMX2U/8j2LcjERF1lybQrfv1H9LRJLmJiHvaj gBsA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i4NLJ97y; 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=f41ZVV6jsaWC1Z6wTRB2qy6CrRYqfc63EtChEoKkG5Q=; b=nljygLUZXMsQ4KgC9e8cNtUnlYtyToY4O7PtdjvNY4orscyTqa1SUclZUqbmQhWX62 A21GCn/XtvowKfWgjA87qYs9FGSn/hSkn7LQVOWpGQ4Hrkq7IqFSkp6hcQEtVxmVFsnG 4o74ObZwU443xzyZvS9gsZQxaBD0qHPwGgSy8= 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=f41ZVV6jsaWC1Z6wTRB2qy6CrRYqfc63EtChEoKkG5Q=; b=Figmcog0Owb9Et3FVs06LfK1+t6hZq6+MnXfxfC1FcZlUIKy6pPqAXeeX12EAYiyr3 fSTivyfSFt+0eKeHpE13ch1WkirA6e/q/NrgLJ2dPQsKIEE2wXnQHFxFusk5qzauMX7W lcTHydDqW+s6KvGsdN+9UcL1qpkrclfDees8gkDFTl2xyXzOTu8sFSCf0NTuWTQ2s7DA +mrWkerqDKVjQATcuhVFSeBDC1Ov+p5N17yvFvbepgNkSD7h6dmL74vbFAlfzy48+uob v70EXRm13Gsbft1MX7tBVaFqvgQrN8rcudpSA+bq2jz65D7MWq3Em5pPdjFXH7mcBTa2 zuDA== X-Gm-Message-State: AGi0Pua/9rltusvpc3aE8Tmb4g5f4xaSzD1M0VD/DOe6wo5fF15vL0Ae M5dIqmqq61aBKFiaku6iKezcnHhf X-Google-Smtp-Source: APiQypKP7IpNO55eO4MXTbPFto+bjfA+s8wxfHR5UIC4785Ub25knF7x7VA3k9NmgPT4twKObbT/2Q== X-Received: by 2002:a63:4f1d:: with SMTP id d29mr14240274pgb.112.1587812660001; Sat, 25 Apr 2020 04:04:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:5d97:: with SMTP id t23ls10599514pji.0.canary-gmail; Sat, 25 Apr 2020 04:04:19 -0700 (PDT) X-Received: by 2002:a17:90a:3781:: with SMTP id v1mr11309927pjb.83.1587812659643; Sat, 25 Apr 2020 04:04:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812659; cv=none; d=google.com; s=arc-20160816; b=JnIAceHusx4O5wwmNA+aFP/Z0HmC74j0JR+FA5HxVI36IC+F5WoYxoua12UYDjtcKr m1e5VgTQfAZ28ASSmYpwPdW4P4KIEro7h6q4Ku6fzvJRjIG+7dOi7hmKW+hVjsSBwrTs ZB0I2x3PU7LmbQ4CyndEO4GsDlUW6YeQnVxuUbdn/qyatCVnfuKNmou94NmcJWGHutIE JyymlDp21c17ZFw3rld4FYLX6i9zbjhzcrkUUJBPXWlBbE4B26T+EarK0hMhXNK8lQmQ FdFIiFuU3mVgA+zLLumRyNusn4no8t8wuyLYzdbDmJrdodDVJgWqMEFt60zYjrHgZpkz rGZg== 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=/+Cg0gu73GJX3Q4AuxSiTU4pPnB0FtMO+fum27Cjz0k=; b=Xbk8spQNqoXiVE0SaiaxYUVHcRmY5k7smMPjzxUH6OW9C24fMUhSEoCKp95fLDqS9Q DGSXEXM2BPwbY7ofmvgHmvL9zKi1aCq03SNbzaKBiN5E7NTg7sDhcLekjMdyMlE9J76h iMWSU1FwiFOBeMDDCOfJ2zkFzyH6TWl39phrF+/y8cPywlp4mE0WYDnzlVE5j+yA/10V UgQIR+yx/jrt+I/NUmsW/d/kefu/xtAOiaYi2Sf1kgvoJ0oyt7RgW4OnXP3KPQrIWwvn KVEOz0SNOFqn4/ML8JLxYPCaZieFX9XHY7AoX0AgX1spBbtQKHS80JzSDFNBu5M9YzIE i37g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=i4NLJ97y; 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 a6sor11061268pgm.58.2020.04.25.04.04.19 for (Google Transport Security); Sat, 25 Apr 2020 04:04:19 -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:7f5d:: with SMTP id p29mr13240360pgn.96.1587812658781; Sat, 25 Apr 2020 04:04:18 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:18 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 3/8] clk: rk3399: Enable PCIE_PHY clock Date: Sat, 25 Apr 2020 16:33:49 +0530 Message-Id: <20200425110354.12381-4-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=i4NLJ97y; 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 PCIE_PHY clock enablement support on rk3399 clock driver. This clock is enabled by default, so do nothing if it triggers during the PCIe PHY probe other PHY users on this clock will simply fail. Signed-off-by: Jagan Teki --- drivers/clk/rockchip/clk_rk3399.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index d822acace1..8e069fbade 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1071,12 +1071,27 @@ static int __maybe_unused rk3399_clk_set_parent(struct clk *clk, return -ENOENT; } +static int rk3399_clk_enable(struct clk *clk) +{ + switch (clk->id) { + case SCLK_PCIEPHY_REF: + /* do nothing, clk is enabled by default */ + break; + default: + debug("%s: unsupported clk %ld\n", __func__, clk->id); + return -ENOENT; + } + + return 0; +} + static struct clk_ops rk3399_clk_ops = { .get_rate = rk3399_clk_get_rate, .set_rate = rk3399_clk_set_rate, #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) .set_parent = rk3399_clk_set_parent, #endif + .enable = rk3399_clk_enable, }; #ifdef CONFIG_SPL_BUILD From patchwork Sat Apr 25 11:03:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1118 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-io1-f69.google.com (mail-io1-f69.google.com [209.85.166.69]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 2AACE3F078 for ; Sat, 25 Apr 2020 13:04:25 +0200 (CEST) Received: by mail-io1-f69.google.com with SMTP id v3sf13937545iod.23 for ; Sat, 25 Apr 2020 04:04:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812663; cv=pass; d=google.com; s=arc-20160816; b=j4SZ2G25nKom+cvzrQ1HrSlFTsagVnU0NkMB8ABqHh9U2vqdi6h7Ml5OtmwoDa1uaZ wTpcZWEiyhssovxHCn5hCTuVebyJKIo2M5aZq0RWEwewRMWs0I+bXJvNKHV+gFHBzuJ9 YVjPCekmCISle2kb1mU/D8V8hUgHaBFvDXz6oh4v0xWYLx9Uxh18urAv5KDdMBZ74NgA GoJxdH2sliqnZwSz3jyPGG4kbJQk7KXMU/q/aPYotU9L7St5QeIGSL31b9MumVizIMS2 U5IXmcVKiOVEYStCmV0hGqKEQU5QE9trY287sf39cSjRP0wG7Y+woulZOjlVs4YOKsvs euxQ== 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=AEgDNlErNy2KLLrshfVUan9QDwf4O7eDX8O7rPQRMgM=; b=J+ek4K4KRcIK9zzFtqHBNgDLxZpNe4grOlvjKOZ9HiOrAMUBEoU8SezeiQfG0iijHN snDYJpBABrqMOp2V47kS+s3ViXfYqiIJNymB/9OBGe/Q7cA6XBZK4ReAmJzdCtZeGAIe x0Kezimfcp6WRs8WuV11ON+CPhphILbl48alObDmmDBm9bOFY2pq7zaCMRmRqvxVEnpv b9sKTa2uZTnR0hc480Hv0LEvoSSKITBJVqwKERv7XE24wNsX1UTRWW+6jh54XbdyG9CQ dgXdaPedFmcyts6QBAU+mHJdwfC88cQVUDac/bBTEvwLcYoNZ2g/PU9VZKUHuM4tP3kV W12g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=faUsJCUo; 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=AEgDNlErNy2KLLrshfVUan9QDwf4O7eDX8O7rPQRMgM=; b=aHJutR/7iHeAbwIChy0ar1tpFSyH/nqUpey8UQKqgBOFipv7rxAbukts7FpYKbRtLW KdxL1ow7fA9iXs1p5HZgLJDBX02WvhMCJOCBrU5HtISfnSlJg0N/9JFiaxdLSB5rzlD1 FozaywWuYxni1EKjlx1B4Oi26nWFnOzSgcoxE= 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=AEgDNlErNy2KLLrshfVUan9QDwf4O7eDX8O7rPQRMgM=; b=lbCmhXMKQZQ1ANmIk8jpWDhENtrYu3WuHT3NpXxEfL35Ofn35z3AObMNEiYv82sSpH swiQAp+Xp+ir0Rq7JwnJ3WsiV3dUm9QxUXJIZNndaxw5z80Z4IM+M0XlVBFXB45D2dhL Yru/9aWFEBECPu6WpCFKbDoVlhbyQGIYKHFhJqdaqm64VyJxrTXLqEeTQyjxrQ3Oi2Xf xVKKsacCDZUucQCgngYq3yzKuIseHOBslfzptZajGV4/nDeUz1iKK+uA/7RDtYI40D1j jm+RbhXjQljIwO9t8Q7srT4LwIy+rm20X5awYAy19ldMTfrKxgu30UuMwBvCJ7ZMphm2 VmjA== X-Gm-Message-State: AGi0PuYCkUmv+TETbE5a/zx1CPzLXe+9RKeR9tvdDnQ9yPg1PCh+6/HI PuibbLpWW8aGSwJkNOBbX/9+tF+9 X-Google-Smtp-Source: APiQypLN9DkGNuqf5cr/SbPzehCkZSjdOSfVX11H5T+4ggq7mtG1FSRfd0Ii84V0MP0StLnfKB0ySw== X-Received: by 2002:a92:5f17:: with SMTP id t23mr13101568ilb.2.1587812663229; Sat, 25 Apr 2020 04:04:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a92:4919:: with SMTP id w25ls5150290ila.10.gmail; Sat, 25 Apr 2020 04:04:23 -0700 (PDT) X-Received: by 2002:a92:d44b:: with SMTP id r11mr12661434ilm.120.1587812662876; Sat, 25 Apr 2020 04:04:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812662; cv=none; d=google.com; s=arc-20160816; b=OkQ7MYEoA5RzAJHUmktMltlRv7Mu5Wxal5cVLbx/I3UVvi7dVM1eo0DdPBx+iegs2k wcO2ZXpjf9N1WGknay7mkuOf2Kjz0m/Uj6J7sOdZiqTloKNnF2c7Kl7dJwlnisF1uXkE AM6sHs8XOsNJgrLUjdZSLS9oSzubnQzWoAmgn8p0eHwcqQJvB8RU0gtQiZAI2EDQDmtW KROLw9MpOBuKZXj1F6BS+neluVuBWXsWjP8Gyvoulm5Q6I8y7vpjq/yoFRydeMlUt5s/ bwemke7+cUTX0OPwxfPxR8Eo/Xx2VHMsDhl14dcMnWbm4fwZLbNrKQykYTbkoFIfA6V6 e/yw== 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=S9a3dMjs8BXiVqfuBIa2xvh8v1BdLUTtASwzmWB671k=; b=L8/n4bkWpg7XJYnGJm+5WXwVYqZwqMewMphbVengRaObbS365uwHjRoYWU5jjegVpZ YIjrrtCvHYHYG70NtfUZfsLPxWmjFq/ShnBCScoCmfaWq3hZwnC3NMX7dfmKk3APyD4b 0oal3xOm8ia+gnWsLGl11IFDZwRhWd+HTNQ44yRl9e9uwbxj9S1t2rDLO1+9c5hibwFe cTRIVN0vnX3uyYDC3JOhKLMlhorzoYFZFB1CS2ISVRP3EhwhVRHLZg9/Llx/vaadSxXW 65OL7c0DziVNH39wNnwLqgligUTbxIfM/khNZNzoAGbUMhuB2/Bu0/HjFE1zCMZS2gjT CyoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=faUsJCUo; 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 z6sor6507936ile.125.2020.04.25.04.04.22 for (Google Transport Security); Sat, 25 Apr 2020 04:04:22 -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:bf07:: with SMTP id bi7mr2593821plb.85.1587812662574; Sat, 25 Apr 2020 04:04:22 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:21 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 4/8] clk: rk3399: Disable PCIE_PHY clock Date: Sat, 25 Apr 2020 16:33:50 +0530 Message-Id: <20200425110354.12381-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=faUsJCUo; 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 PCIE_PHY clock disablement support on rk3399 clock driver. This would trigger if the PCIe PHY driver failed to initialize or power on the PHY. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/clk/rockchip/clk_rk3399.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/clk/rockchip/clk_rk3399.c b/drivers/clk/rockchip/clk_rk3399.c index 8e069fbade..2d447f96f7 100644 --- a/drivers/clk/rockchip/clk_rk3399.c +++ b/drivers/clk/rockchip/clk_rk3399.c @@ -1085,6 +1085,22 @@ static int rk3399_clk_enable(struct clk *clk) return 0; } +static int rk3399_clk_disable(struct clk *clk) +{ + struct rk3399_clk_priv *priv = dev_get_priv(clk->dev); + + switch (clk->id) { + case SCLK_PCIEPHY_REF: + rk_clrreg(&priv->cru->clksel_con[18], BIT(7)); + break; + default: + debug("%s: unsupported clk %ld\n", __func__, clk->id); + return -ENOENT; + } + + return 0; +} + static struct clk_ops rk3399_clk_ops = { .get_rate = rk3399_clk_get_rate, .set_rate = rk3399_clk_set_rate, @@ -1092,6 +1108,7 @@ static struct clk_ops rk3399_clk_ops = { .set_parent = rk3399_clk_set_parent, #endif .enable = rk3399_clk_enable, + .disable = rk3399_clk_disable, }; #ifdef CONFIG_SPL_BUILD From patchwork Sat Apr 25 11:03:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1119 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 1F3E03F078 for ; Sat, 25 Apr 2020 13:04:29 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id q11sf11669791pfq.9 for ; Sat, 25 Apr 2020 04:04:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812667; cv=pass; d=google.com; s=arc-20160816; b=oLFUZcHwYc3yDWQI/QW8GLey39gDZY5z0NN6MepVS0WbRSj89HewNsdxXPtjU6KKnR s9RJ1R+iyRsDz93qpYK5Y6npi8rPPDuiNr453aVGmX+Zk2ZUZU+kLl6jFHhbmUWXkb5n AbkDCrs3hduYY4gSBC0GVNkFhEF1XUcAz7SYQCFjP8gNhfATaplwVHqQTMKYOv2ptfS6 ZS70l4JUo+Ciz8P83+B3UpmxSwfbWCNRzkXbXx6nddijK68Q9T0J7iUCVEayMn7CKEsv 5YnQP0PwJ5dLTEnEOE+/E6NIYx/kJ4nW14FuNDKBxyb0iW4iMrPrFN0rckNSz+s1uR8K Zjaw== 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=E9jEnf/I0+ts6hH1LyQa8V60JTZI82jlUApllomslkg=; b=DiUeTTmNIoyzdoD7qribrIRNrgYh7KC/V3XJb6L6PeWYwzYfA2pOQi4Igm/i7a1x/3 Q6OuQlVz/FO/keR3fqhJDz1x/3RJFcmbrLRnP+Gdzdbmn/od8VNHRv2EwLcYchvItabc qTcdAPqJxAsp/erY/VOABlxLM6r0xzeZ2Fs+C1sglnm+dsNtwz2SP2+99TiLzq4NvKkL Tbi4r/L/DcizuvI5G0vrqNPsa9FGuxgu701yiOaOm4NXdIgRYUtAKlsJaH7Zf7leUgZ5 k4hVNbi+4HmBOLl2nJwV4GEDyX0M70AZ+GNqJCaSVVuPVFvDDNuSxskQFxN6BJYMdsIe E+Vw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mchUMEKP; 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=E9jEnf/I0+ts6hH1LyQa8V60JTZI82jlUApllomslkg=; b=EPzGd0Rp7SOfpXYvBGTbjyeWN/g01l6te4/A403dLQ41UlfTbDNPAPePbiTmYPcE9w UEj7WzZxiw4UuO7cusWkYg+SCYK4RW5B/4eeeYrf5JgKkJ2lEfEQDOVy185tHbcgqaG4 CPlutgEJKvaz58psVTdfNRGNU6BK0jSvF1bQQ= 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=E9jEnf/I0+ts6hH1LyQa8V60JTZI82jlUApllomslkg=; b=DCfoqCnj8jnj6jRdLPEQRwyBVk/Z3jBOpHSRk2fSLHZojzSr31g/Pu8j4ZUVuubP+5 jGsn6fJ4x4CBtL8SF0Kpl8sfK9QAtut4e+OtkWarMRMgFvt8eXqLcP0+9aynBywRpaFp KktGjpuUjGdZxXr2pPUSIwX4VNaOneaWuAKS+act2M16Vzm+VsAhksUS2ucsaO3ti2R7 Vgy60yt1sRCBFf9byDe50oEEGQXA9BRwSeMP5Q+DD8AbpEhB03Y4B5l6Py4a9Uidxz5E HNumjCnUSVIZef/HaPeFNxGlQSiNdaKpkWGpiKt8UnBh43RRp8EzwXB3eqpQmCxTWPdZ D14w== X-Gm-Message-State: AGi0PuYk7GD67CREKXhTzEtm+8l8iM9iLmq+raGL9PDog4foEVF6FO9l p/EiG1mUrMA/CgfPPjrBBa314sGb X-Google-Smtp-Source: APiQypKzNN3ljg4PfdvRLzaweX0soFaqT6qBZl+N870kWqxriHyBiLTSSKmi87C0SocC+V/OZjGE8A== X-Received: by 2002:a17:902:8697:: with SMTP id g23mr13706835plo.306.1587812667590; Sat, 25 Apr 2020 04:04:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:a701:: with SMTP id w1ls10107041plq.7.gmail; Sat, 25 Apr 2020 04:04:27 -0700 (PDT) X-Received: by 2002:a17:902:6b0a:: with SMTP id o10mr13692212plk.32.1587812667059; Sat, 25 Apr 2020 04:04:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812667; cv=none; d=google.com; s=arc-20160816; b=DD40CuP+LIWnOjiRklAl8I0oeWiWhGCdxfj2FdJNDGqWPEKR4wobx/PAJ0g9xPrgC4 BG8z9mCtARaLno7zUIyaBumFizMrIbZPFYY4iWT+cbX/1XXgpXHp/NUo9zruk5qCfgz1 Az2uhetUkuRThYLRwZYQigAvYvMrlEfblqRqg03JqewwV/EmQgR7aVkUH+NqbQnuMdP4 3kG83eePcr2DzLZ2dSkMZmGfQArT74+605Jq4IxK1DU+jr0DZHkkgSMt5i8jbxQKbyGV 6KAsDrmrDcUIvIdPWm78wlqOGB8SKqvOb7Q35+u6l4Pw64FlHlT1QJNJayc1CJdamlCt EX9g== 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=7EFV92NDB3wj8ZxOaxi0K9e4k9sGjI5XvTIkD/NH5QQ=; b=rDeU1gClDMNtHw6qFOt/G+l7BbOQzKuhT9eeH3IanftHDP3m2kUjJTBNWnuxo763yu q1sQ2twi0dpRWFTlu8n42M/iGvshP9oWpN3q1bV6O+WCjk41ousCoaDnkZBKSSKCWLzx EXSLOXLWkBsGlpJVVRR2O7plB+qkkTl+MT1qv/+VeB2GjFWpbKxHNh6L6B6STjx/nkuX xcFP3wzmDFVnJ1lR47V0w5yW3PKLI7VgP1cndARoSJ+evymdhsKWjNRqKTnduh9pUElM G3YbCfKK9Aons5GkjJYMw00x9CTA0xxUzQfeBW2pM7vaGJiiOXfREZETH22o7b1otMyd P0gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=mchUMEKP; 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 q1sor9999648pff.68.2020.04.25.04.04.27 for (Google Transport Security); Sat, 25 Apr 2020 04:04:27 -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:3006:: with SMTP id w6mr14239683pfw.29.1587812666429; Sat, 25 Apr 2020 04:04:26 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:25 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 5/8] pci: Add Rockchip PCIe controller driver Date: Sat, 25 Apr 2020 16:33:51 +0530 Message-Id: <20200425110354.12381-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=mchUMEKP; 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 PCIe controller driver for rk3399 platform. Driver support Gen1 by operating as a Root complex. Thanks to Patrick for initial work. Signed-off-by: Patrick Wildt Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/pci/Kconfig | 8 + drivers/pci/Makefile | 1 + drivers/pci/pcie_rockchip.c | 460 ++++++++++++++++++++++++++++++++++++ drivers/pci/pcie_rockchip.h | 79 +++++++ 4 files changed, 548 insertions(+) create mode 100644 drivers/pci/pcie_rockchip.c create mode 100644 drivers/pci/pcie_rockchip.h diff --git a/drivers/pci/Kconfig b/drivers/pci/Kconfig index 437cd9a055..3dba84103b 100644 --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -197,4 +197,12 @@ config PCIE_MEDIATEK Say Y here if you want to enable Gen2 PCIe controller, which could be found on MT7623 SoC family. +config PCIE_ROCKCHIP + bool "Enable Rockchip PCIe driver" + select DM_PCI + default y if ROCKCHIP_RK3399 + help + Say Y here if you want to enable PCIe controller support on + Rockchip SoCs. + endif diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index c051ecc9f3..493e9354dd 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -43,3 +43,4 @@ obj-$(CONFIG_PCI_PHYTIUM) += pcie_phytium.o obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o +obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c new file mode 100644 index 0000000000..adc64aedf5 --- /dev/null +++ b/drivers/pci/pcie_rockchip.c @@ -0,0 +1,460 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Rockchip AXI PCIe host controller driver + * + * Copyright (c) 2016 Rockchip, Inc. + * Copyright (c) 2020 Amarula Solutions(India) + * Copyright (c) 2020 Jagan Teki + * Copyright (c) 2019 Patrick Wildt + * Copyright (c) 2018 Mark Kettenis + * + * Bits taken from Linux Rockchip PCIe host controller. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie_rockchip.h" + +DECLARE_GLOBAL_DATA_PTR; + +static int rockchip_pcie_rd_conf(const struct udevice *bus, pci_dev_t bdf, + uint offset, ulong *valuep, + enum pci_size_t size) +{ + struct rockchip_pcie *priv = dev_get_priv(bus); + ulong value; + u32 off; + + off = (PCI_BUS(bdf) << 20) | (PCI_DEV(bdf) << 15) | + (PCI_FUNC(bdf) << 12) | (offset & ~0x3); + + if ((PCI_BUS(bdf) == priv->first_busno) && (PCI_DEV(bdf) == 0)) { + value = readl(priv->apb_base + PCIE_RC_NORMAL_BASE + off); + *valuep = pci_conv_32_to_size(value, offset, size); + return 0; + } + + if ((PCI_BUS(bdf) == priv->first_busno + 1) && (PCI_DEV(bdf) == 0)) { + value = readl(priv->axi_base + off); + *valuep = pci_conv_32_to_size(value, offset, size); + return 0; + } + + *valuep = pci_get_ff(size); + + return 0; +} + +static int rockchip_pcie_wr_conf(struct udevice *bus, pci_dev_t bdf, + uint offset, ulong value, + enum pci_size_t size) +{ + struct rockchip_pcie *priv = dev_get_priv(bus); + ulong old; + u32 off; + + off = (PCI_BUS(bdf) << 20) | (PCI_DEV(bdf) << 15) | + (PCI_FUNC(bdf) << 12) | (offset & ~0x3); + + if ((PCI_BUS(bdf) == priv->first_busno) && (PCI_DEV(bdf) == 0)) { + old = readl(priv->apb_base + PCIE_RC_NORMAL_BASE + off); + value = pci_conv_size_to_32(old, value, offset, size); + writel(value, priv->apb_base + PCIE_RC_NORMAL_BASE + off); + return 0; + } + + if ((PCI_BUS(bdf) == priv->first_busno + 1) && (PCI_DEV(bdf) == 0)) { + old = readl(priv->axi_base + off); + value = pci_conv_size_to_32(old, value, offset, size); + writel(value, priv->axi_base + off); + return 0; + } + + return 0; +} + +static int rockchip_pcie_atr_init(struct rockchip_pcie *priv) +{ + struct udevice *ctlr = pci_get_controller(priv->dev); + struct pci_controller *hose = dev_get_uclass_priv(ctlr); + u64 addr, size, offset; + u32 type; + int i, region; + + /* Use region 0 to map PCI configuration space. */ + writel(25 - 1, priv->apb_base + PCIE_ATR_OB_ADDR0(0)); + writel(0, priv->apb_base + PCIE_ATR_OB_ADDR1(0)); + writel(PCIE_ATR_HDR_CFG_TYPE0 | PCIE_ATR_HDR_RID, + priv->apb_base + PCIE_ATR_OB_DESC0(0)); + writel(0, priv->apb_base + PCIE_ATR_OB_DESC1(0)); + + for (i = 0; i < hose->region_count; i++) { + if (hose->regions[i].flags == PCI_REGION_SYS_MEMORY) + continue; + + if (hose->regions[i].flags == PCI_REGION_IO) + type = PCIE_ATR_HDR_IO; + else + type = PCIE_ATR_HDR_MEM; + + /* Only support identity mappings. */ + if (hose->regions[i].bus_start != + hose->regions[i].phys_start) + return -EINVAL; + + /* Only support mappings aligned on a region boundary. */ + addr = hose->regions[i].bus_start; + if (addr & (PCIE_ATR_OB_REGION_SIZE - 1)) + return -EINVAL; + + /* Mappings should lie between AXI and APB regions. */ + size = hose->regions[i].size; + if (addr < (u64)priv->axi_base + PCIE_ATR_OB_REGION0_SIZE) + return -EINVAL; + if (addr + size > (u64)priv->apb_base) + return -EINVAL; + + offset = addr - (u64)priv->axi_base - PCIE_ATR_OB_REGION0_SIZE; + region = 1 + (offset / PCIE_ATR_OB_REGION_SIZE); + while (size > 0) { + writel(32 - 1, + priv->apb_base + PCIE_ATR_OB_ADDR0(region)); + writel(0, priv->apb_base + PCIE_ATR_OB_ADDR1(region)); + writel(type | PCIE_ATR_HDR_RID, + priv->apb_base + PCIE_ATR_OB_DESC0(region)); + writel(0, priv->apb_base + PCIE_ATR_OB_DESC1(region)); + + addr += PCIE_ATR_OB_REGION_SIZE; + size -= PCIE_ATR_OB_REGION_SIZE; + region++; + } + } + + /* Passthrough inbound translations unmodified. */ + writel(32 - 1, priv->apb_base + PCIE_ATR_IB_ADDR0(2)); + writel(0, priv->apb_base + PCIE_ATR_IB_ADDR1(2)); + + return 0; +} + +static int rockchip_pcie_init_port(struct udevice *dev) +{ + struct rockchip_pcie *priv = dev_get_priv(dev); + u32 cr, val, status; + int ret; + + if (dm_gpio_is_valid(&priv->ep_gpio)) + dm_gpio_set_value(&priv->ep_gpio, 0); + + ret = reset_assert(&priv->aclk_rst); + if (ret) { + dev_err(dev, "failed to assert aclk reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_assert(&priv->pclk_rst); + if (ret) { + dev_err(dev, "failed to assert pclk reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_assert(&priv->pm_rst); + if (ret) { + dev_err(dev, "failed to assert pm reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_assert(&priv->core_rst); + if (ret) { + dev_err(dev, "failed to assert core reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_assert(&priv->mgmt_rst); + if (ret) { + dev_err(dev, "failed to assert mgmt reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_assert(&priv->mgmt_sticky_rst); + if (ret) { + dev_err(dev, "failed to assert mgmt-sticky reset (ret=%d)\n", + ret); + return ret; + } + + ret = reset_assert(&priv->pipe_rst); + if (ret) { + dev_err(dev, "failed to assert pipe reset (ret=%d)\n", ret); + return ret; + } + + udelay(10); + + ret = reset_deassert(&priv->pm_rst); + if (ret) { + dev_err(dev, "failed to deassert pm reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_deassert(&priv->aclk_rst); + if (ret) { + dev_err(dev, "failed to deassert aclk reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_deassert(&priv->pclk_rst); + if (ret) { + dev_err(dev, "failed to deassert pclk reset (ret=%d)\n", ret); + return ret; + } + + /* Select GEN1 for now */ + cr = PCIE_CLIENT_GEN_SEL_1; + /* Set Root complex mode */ + cr |= PCIE_CLIENT_CONF_ENABLE | PCIE_CLIENT_MODE_RC; + writel(cr, priv->apb_base + PCIE_CLIENT_CONFIG); + + ret = reset_deassert(&priv->mgmt_sticky_rst); + if (ret) { + dev_err(dev, "failed to deassert mgmt-sticky reset (ret=%d)\n", + ret); + return ret; + } + + ret = reset_deassert(&priv->core_rst); + if (ret) { + dev_err(dev, "failed to deassert core reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_deassert(&priv->mgmt_rst); + if (ret) { + dev_err(dev, "failed to deassert mgmt reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_deassert(&priv->pipe_rst); + if (ret) { + dev_err(dev, "failed to deassert pipe reset (ret=%d)\n", ret); + return ret; + } + + /* Enable Gen1 training */ + writel(PCIE_CLIENT_LINK_TRAIN_ENABLE, + priv->apb_base + PCIE_CLIENT_CONFIG); + + if (dm_gpio_is_valid(&priv->ep_gpio)) + dm_gpio_set_value(&priv->ep_gpio, 1); + + ret = readl_poll_sleep_timeout + (priv->apb_base + PCIE_CLIENT_BASIC_STATUS1, + status, PCIE_LINK_UP(status), 20, 500 * 1000); + if (ret) { + dev_err(dev, "PCIe link training gen1 timeout!\n"); + return ret; + } + + /* Initialize Root Complex registers. */ + writel(PCIE_LM_VENDOR_ROCKCHIP, priv->apb_base + PCIE_LM_VENDOR_ID); + writel(PCI_CLASS_BRIDGE_PCI << 16, + priv->apb_base + PCIE_RC_BASE + PCI_CLASS_REVISION); + writel(PCIE_LM_RCBARPIE | PCIE_LM_RCBARPIS, + priv->apb_base + PCIE_LM_RCBAR); + + if (dev_read_bool(dev, "aspm-no-l0s")) { + val = readl(priv->apb_base + PCIE_RC_PCIE_LCAP); + val &= ~PCIE_RC_PCIE_LCAP_APMS_L0S; + writel(val, priv->apb_base + PCIE_RC_PCIE_LCAP); + } + + /* Configure Address Translation. */ + ret = rockchip_pcie_atr_init(priv); + if (ret) { + dev_err(dev, "PCIE-%d: ATR init failed\n", dev->seq); + return ret; + } + + return 0; +} + +static int rockchip_pcie_set_vpcie(struct udevice *dev) +{ + struct rockchip_pcie *priv = dev_get_priv(dev); + int ret; + + if (!IS_ERR(priv->vpcie3v3)) { + ret = regulator_set_enable(priv->vpcie3v3, true); + if (ret) { + dev_err(dev, "failed to enable vpcie3v3 (ret=%d)\n", + ret); + return ret; + } + } + + ret = regulator_set_enable(priv->vpcie1v8, true); + if (ret) { + dev_err(dev, "failed to enable vpcie1v8 (ret=%d)\n", ret); + goto err_disable_3v3; + } + + ret = regulator_set_enable(priv->vpcie0v9, true); + if (ret) { + dev_err(dev, "failed to enable vpcie0v9 (ret=%d)\n", ret); + goto err_disable_1v8; + } + + return 0; + +err_disable_1v8: + regulator_set_enable(priv->vpcie1v8, false); +err_disable_3v3: + if (!IS_ERR(priv->vpcie3v3)) + regulator_set_enable(priv->vpcie3v3, false); + return ret; +} + +static int rockchip_pcie_parse_dt(struct udevice *dev) +{ + struct rockchip_pcie *priv = dev_get_priv(dev); + int ret; + + priv->axi_base = dev_read_addr_name(dev, "axi-base"); + if (!priv->axi_base) + return -ENODEV; + + priv->apb_base = dev_read_addr_name(dev, "apb-base"); + if (!priv->axi_base) + return -ENODEV; + + ret = gpio_request_by_name(dev, "ep-gpios", 0, + &priv->ep_gpio, GPIOD_IS_OUT); + if (ret) { + dev_err(dev, "failed to find ep-gpios property\n"); + return ret; + } + + ret = reset_get_by_name(dev, "core", &priv->core_rst); + if (ret) { + dev_err(dev, "failed to get core reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "mgmt", &priv->mgmt_rst); + if (ret) { + dev_err(dev, "failed to get mgmt reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "mgmt-sticky", &priv->mgmt_sticky_rst); + if (ret) { + dev_err(dev, "failed to get mgmt-sticky reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "pipe", &priv->pipe_rst); + if (ret) { + dev_err(dev, "failed to get pipe reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "pm", &priv->pm_rst); + if (ret) { + dev_err(dev, "failed to get pm reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "pclk", &priv->pclk_rst); + if (ret) { + dev_err(dev, "failed to get pclk reset (ret=%d)\n", ret); + return ret; + } + + ret = reset_get_by_name(dev, "aclk", &priv->aclk_rst); + if (ret) { + dev_err(dev, "failed to get aclk reset (ret=%d)\n", ret); + return ret; + } + + ret = device_get_supply_regulator(dev, "vpcie3v3-supply", + &priv->vpcie3v3); + if (ret && ret != -ENOENT) { + dev_err(dev, "failed to get vpcie3v3 supply (ret=%d)\n", ret); + return ret; + } + + ret = device_get_supply_regulator(dev, "vpcie1v8-supply", + &priv->vpcie1v8); + if (ret) { + dev_err(dev, "failed to get vpcie1v8 supply (ret=%d)\n", ret); + return ret; + } + + ret = device_get_supply_regulator(dev, "vpcie0v9-supply", + &priv->vpcie0v9); + if (ret) { + dev_err(dev, "failed to get vpcie0v9 supply (ret=%d)\n", ret); + return ret; + } + + return 0; +} + +static int rockchip_pcie_probe(struct udevice *dev) +{ + struct rockchip_pcie *priv = dev_get_priv(dev); + struct udevice *ctlr = pci_get_controller(dev); + struct pci_controller *hose = dev_get_uclass_priv(ctlr); + int ret; + + priv->first_busno = dev->seq; + priv->dev = dev; + + ret = rockchip_pcie_parse_dt(dev); + if (ret) + return ret; + + ret = rockchip_pcie_set_vpcie(dev); + if (ret) + return ret; + + ret = rockchip_pcie_init_port(dev); + if (ret) + return ret; + + dev_info(dev, "PCIE-%d: Link up (Bus%d)\n", + dev->seq, hose->first_busno); + + return 0; +} + +static const struct dm_pci_ops rockchip_pcie_ops = { + .read_config = rockchip_pcie_rd_conf, + .write_config = rockchip_pcie_wr_conf, +}; + +static const struct udevice_id rockchip_pcie_ids[] = { + { .compatible = "rockchip,rk3399-pcie" }, + { } +}; + +U_BOOT_DRIVER(rockchip_pcie) = { + .name = "rockchip_pcie", + .id = UCLASS_PCI, + .of_match = rockchip_pcie_ids, + .ops = &rockchip_pcie_ops, + .probe = rockchip_pcie_probe, + .priv_auto_alloc_size = sizeof(struct rockchip_pcie), +}; diff --git a/drivers/pci/pcie_rockchip.h b/drivers/pci/pcie_rockchip.h new file mode 100644 index 0000000000..6ded5c9553 --- /dev/null +++ b/drivers/pci/pcie_rockchip.h @@ -0,0 +1,79 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Rockchip PCIe Headers + * + * Copyright (c) 2016 Rockchip, Inc. + * Copyright (c) 2020 Amarula Solutions(India) + * Copyright (c) 2020 Jagan Teki + * Copyright (c) 2019 Patrick Wildt + * + */ + +#define HIWORD_UPDATE(mask, val) (((mask) << 16) | (val)) +#define HIWORD_UPDATE_BIT(val) HIWORD_UPDATE(val, val) + +#define ENCODE_LANES(x) ((((x) >> 1) & 3) << 4) +#define PCIE_CLIENT_BASE 0x0 +#define PCIE_CLIENT_CONFIG (PCIE_CLIENT_BASE + 0x00) +#define PCIE_CLIENT_CONF_ENABLE HIWORD_UPDATE_BIT(0x0001) +#define PCIE_CLIENT_LINK_TRAIN_ENABLE HIWORD_UPDATE_BIT(0x0002) +#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040) +#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) +#define PCIE_CLIENT_BASIC_STATUS1 0x0048 +#define PCIE_CLIENT_LINK_STATUS_UP GENMASK(21, 20) +#define PCIE_CLIENT_LINK_STATUS_MASK GENMASK(21, 20) +#define PCIE_LINK_UP(x) \ + (((x) & PCIE_CLIENT_LINK_STATUS_MASK) == PCIE_CLIENT_LINK_STATUS_UP) +#define PCIE_RC_NORMAL_BASE 0x800000 +#define PCIE_LM_BASE 0x900000 +#define PCIE_LM_VENDOR_ID (PCIE_LM_BASE + 0x44) +#define PCIE_LM_VENDOR_ROCKCHIP 0x1d87 +#define PCIE_LM_RCBAR (PCIE_LM_BASE + 0x300) +#define PCIE_LM_RCBARPIE BIT(19) +#define PCIE_LM_RCBARPIS BIT(20) +#define PCIE_RC_BASE 0xa00000 +#define PCIE_RC_CONFIG_DCR (PCIE_RC_BASE + 0x0c4) +#define PCIE_RC_CONFIG_DCR_CSPL_SHIFT 18 +#define PCIE_RC_CONFIG_DCR_CPLS_SHIFT 26 +#define PCIE_RC_PCIE_LCAP (PCIE_RC_BASE + 0x0cc) +#define PCIE_RC_PCIE_LCAP_APMS_L0S BIT(10) +#define PCIE_ATR_BASE 0xc00000 +#define PCIE_ATR_OB_ADDR0(i) (PCIE_ATR_BASE + 0x000 + (i) * 0x20) +#define PCIE_ATR_OB_ADDR1(i) (PCIE_ATR_BASE + 0x004 + (i) * 0x20) +#define PCIE_ATR_OB_DESC0(i) (PCIE_ATR_BASE + 0x008 + (i) * 0x20) +#define PCIE_ATR_OB_DESC1(i) (PCIE_ATR_BASE + 0x00c + (i) * 0x20) +#define PCIE_ATR_IB_ADDR0(i) (PCIE_ATR_BASE + 0x800 + (i) * 0x8) +#define PCIE_ATR_IB_ADDR1(i) (PCIE_ATR_BASE + 0x804 + (i) * 0x8) +#define PCIE_ATR_HDR_MEM 0x2 +#define PCIE_ATR_HDR_IO 0x6 +#define PCIE_ATR_HDR_CFG_TYPE0 0xa +#define PCIE_ATR_HDR_CFG_TYPE1 0xb +#define PCIE_ATR_HDR_RID BIT(23) + +#define PCIE_ATR_OB_REGION0_SIZE (32 * 1024 * 1024) +#define PCIE_ATR_OB_REGION_SIZE (1 * 1024 * 1024) + +struct rockchip_pcie { + fdt_addr_t axi_base; + fdt_addr_t apb_base; + int first_busno; + struct udevice *dev; + + /* resets */ + struct reset_ctl core_rst; + struct reset_ctl mgmt_rst; + struct reset_ctl mgmt_sticky_rst; + struct reset_ctl pipe_rst; + struct reset_ctl pm_rst; + struct reset_ctl pclk_rst; + struct reset_ctl aclk_rst; + + /* gpio */ + struct gpio_desc ep_gpio; + + /* vpcie regulators */ + struct udevice *vpcie12v; + struct udevice *vpcie3v3; + struct udevice *vpcie1v8; + struct udevice *vpcie0v9; +}; From patchwork Sat Apr 25 11:03:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1120 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 5A1023F078 for ; Sat, 25 Apr 2020 13:04:32 +0200 (CEST) Received: by mail-pg1-f197.google.com with SMTP id j21sf10398271pgh.12 for ; Sat, 25 Apr 2020 04:04:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812671; cv=pass; d=google.com; s=arc-20160816; b=LeEUMfIxaDs6HilqONSc1iLT5bJZSj6VBGCvY4JsGD40IiO1brunBRtczA++LgYXYh l2gUCYTRlXNdUFrh+8Q7Up1hsPgXxQ+bShjwuPsZprFVZ2r9qNQR7R6TTxoYctKrrPmW oQjlFvgDbYlOgKUeEKj88WEJjdJw3tdxEdcNGqIGHXJ7lD28C2SS8mRFZZrX6zEOn8V9 gKaK96TrTRnEm7l4i6NHTkTdPA8bgl+agIjXTyZ+QsH2Gx17SmYqcAVArzgGSDDOa3Tt cTHHTa3w1HVo7st1z/OSAPABS1eUDdRRTOCWsTtymEJKQe7mgXjwbkYDkEnR/vguN3eQ d7Og== 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=aV8Ckdg6tVXVDX9bPmBtgwQAugXcwrsE/1fgaJZeLpo=; b=QGzPjYpdUVBGXW38T2H9xUhg1EmT38aOaUCSN5c8iDYO+xaLmigkI6iWMBcV53dCWb WKXUgSA/ZdSAWFJhkE4D9kMKQ0M6N1qHJBwvQuUjOQXqzE5qOtiv92qBSTaQW2PjxbME MPekQiXOD1f+gIcYJsmZpLjnaujMTT/BjFgIIgcGkxBK1gQ5bGxCocIt4+k0IEc8vpPW INno4GPad6qo7nFgRlcp0lwDLHuT6+E12mTZzApLcpIxujWitDGUpHEr4HrqGHz3D5Oo 0b2TcAmhbebTEN6X0hl4IVVpRyV/37qCRdw2F9zvbOll84fOZntJ2t5aQFitlop1w0/4 gmEw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nUiZKKXe; 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=aV8Ckdg6tVXVDX9bPmBtgwQAugXcwrsE/1fgaJZeLpo=; b=CWa7K5+zCLU8f/M3bdw+P727cBGAyGEROAIE+sHqPBumagr0BhZJMi8YSFvYsZ0uW1 IUenlmN6XFYDKuQ6X9b4K5uQzvOxiAm0c4NygimQ2/rYDoqIXYxx1uYvbJcqVeEmvlr7 ovKH1R6DQfRdd1WZviuHGoVLupoy2PLZpN618= 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=aV8Ckdg6tVXVDX9bPmBtgwQAugXcwrsE/1fgaJZeLpo=; b=aeM4ZEzjIxU3VegJZRkTTRngaWVW6lGuMbR1MVn5tbG0eoN2PiyK79mkgEfW7S5leM H/nvPaJOOZWPCnPrkgQ8l89MRWnPbLpxEDQM0PRpJvThiWhbbCWtVVEieBMgpBQAxcAZ sttJmsIReayAvjfncg/c5KOFCV1N8BpGuEyH83s4qOfVAMQRl6Y0F/NWrTLVsTtR+hhn n9heax3Lt3DcaB/wti6mfRnWrPOwIOwBtiFccVoBUoiF5wMQzXXHEETTYy0tJKO+u4ZR D5s7hI5kOhW91GAchc/UNL8f69YxPyS0kllg5t0XFyOhh6ipbmqh3Fi+YcrtrN42542q O8tg== X-Gm-Message-State: AGi0PuYAapPBIO1JvBpwPlw7UWooWGVVwBT+oE3N8SME+fVhGfjL69P/ piaUBWYxN9zGhNk8WYmgehxZtZ09 X-Google-Smtp-Source: APiQypIZtreEoxl8SbsN7BhqmK+9oi0xGtoPBcX7v9lCC1ns52lDkHZJLZ5zY13MokvOMuYkiUe93w== X-Received: by 2002:a63:8341:: with SMTP id h62mr14179366pge.134.1587812671081; Sat, 25 Apr 2020 04:04:31 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:1c9:: with SMTP id 192ls8815155pgb.3.gmail; Sat, 25 Apr 2020 04:04:30 -0700 (PDT) X-Received: by 2002:aa7:8042:: with SMTP id y2mr14427953pfm.94.1587812670541; Sat, 25 Apr 2020 04:04:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812670; cv=none; d=google.com; s=arc-20160816; b=kW/wHuPr+P8BovbRVDqKT/o8PbgWyjyzrY8wegcKrM2yMXMVp3aSQK8U7m3UsZUd4H PoWosMdtjSxzQAp5zWOp58yCjkpQ8RCLH5+337dhbTB7HntkCLt8lVQw2UZZJYYUtPiN oSL+jpceS56KOvFjRd36FvoExieJ6p6e92ccL5elX6nm8q7lUGDZiJQsd3Ob0ZobH3uo skgaBvkbh/ceAMfKRkInBlSr65NMjYWecrYDp8lxC/omwDhZRLvgoupr/wgmsrlILZpQ nmyGf1a4Zd8Gxk3qBPm58w/iHKTczP9NmIKWcm0SwL+BP1PJ426ByBAq3zVNfwAbd8NR du7w== 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=c5jnespWE0rIxIG0BABfyPJE6shPZ97hyRQlGamv2Fs=; b=rnuhKFiF7PSrsOYKtRwme85lywm/y4De4Aqpm6VURK7ayN3/rl2+NQGeqI69MTDrJJ H4JzFmcX3AVrlNxwFkod/6bgNc9p/U37FVZ/X15s0JpcRpk/ZDUMD8Rm9QZbHB/LmsoB zJGz6RhH3zFyHyUO1JTKRtE16D/kEzHE8WzjGZXyDJKVtxXF3aZXuWGTOTnycAGLhTMu MDtkvvCgKOo4fw25HfHc1baV+oTYzWSsB2Z7qMPDREq4lxnOx/Qf1dqBCmfLop9j2qQX HI2Ji720RbBkS+ItHxsfVORZGbRSiO5Pmxo2D1+AtQ/Dva8/wQ02yeHlLNiWyiFVIvM0 xuJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=nUiZKKXe; 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 i192sor11166960pgc.62.2020.04.25.04.04.30 for (Google Transport Security); Sat, 25 Apr 2020 04:04:30 -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:d544:: with SMTP id v4mr50248pgi.361.1587812670102; Sat, 25 Apr 2020 04:04:30 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:29 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 6/8] pci: Add Rockchip PCIe PHY controller driver Date: Sat, 25 Apr 2020 16:33:52 +0530 Message-Id: <20200425110354.12381-7-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=nUiZKKXe; 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, it is possible to have a dedicated UCLASS PHY driver for this Rockchip PCIe PHY but there are some issues on Generic PHY framework to support the same. The Generic PHY framework is unable to get the PHY if the PHY parent is of a different uclass. Say if we try to get the PCIe PHY then the phy-uclass will look for PHY in the first instance if it is not in the root node it will try to probe the parent by assuming that the actual PHY is inside the parent PHY of UCLASS_PHY. But, in rk3399 hardware representation PHY like emmc, usb and pcie are part of syscon which is completely a different of UCLASS_SYSCON. Example: grf: syscon@ff770000 { compatible = "rockchip,rk3399-grf", "syscon", "simple-mfd"; reg = <0x0 0xff770000 0x0 0x10000>; #address-cells = <1>; #size-cells = <1>; pcie_phy: pcie-phy { compatible = "rockchip,rk3399-pcie-phy"; clocks = <&cru SCLK_PCIEPHY_REF>; clock-names = "refclk"; #phy-cells = <1>; resets = <&cru SRST_PCIEPHY>; drive-impedance-ohm = <50>; reset-names = "phy"; status = "disabled"; }; }; Due to this limitation, this patch adds a separate PHY driver for Rockchip PCIe. This might be removed in future once Generic PHY supports this limitation. Signed-off-by: Jagan Teki --- drivers/pci/Makefile | 2 +- drivers/pci/pcie_rockchip.c | 50 ++++++-- drivers/pci/pcie_rockchip.h | 63 ++++++++++ drivers/pci/pcie_rockchip_phy.c | 205 ++++++++++++++++++++++++++++++++ 4 files changed, 306 insertions(+), 14 deletions(-) create mode 100644 drivers/pci/pcie_rockchip_phy.c diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index 493e9354dd..955351c5c2 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -43,4 +43,4 @@ obj-$(CONFIG_PCI_PHYTIUM) += pcie_phytium.o obj-$(CONFIG_PCIE_INTEL_FPGA) += pcie_intel_fpga.o obj-$(CONFIG_PCI_KEYSTONE) += pcie_dw_ti.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie_mediatek.o -obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o +obj-$(CONFIG_PCIE_ROCKCHIP) += pcie_rockchip.o pcie_rockchip_phy.o diff --git a/drivers/pci/pcie_rockchip.c b/drivers/pci/pcie_rockchip.c index adc64aedf5..00cf036ed8 100644 --- a/drivers/pci/pcie_rockchip.c +++ b/drivers/pci/pcie_rockchip.c @@ -152,6 +152,8 @@ static int rockchip_pcie_atr_init(struct rockchip_pcie *priv) static int rockchip_pcie_init_port(struct udevice *dev) { struct rockchip_pcie *priv = dev_get_priv(dev); + struct rockchip_pcie_phy *phy = pcie_get_phy(priv); + struct rockchip_pcie_phy_ops *ops = phy_get_ops(phy); u32 cr, val, status; int ret; @@ -176,29 +178,35 @@ static int rockchip_pcie_init_port(struct udevice *dev) return ret; } + ret = ops->init(phy); + if (ret) { + dev_err(dev, "failed to init phy (ret=%d)\n", ret); + goto err_exit_phy; + } + ret = reset_assert(&priv->core_rst); if (ret) { dev_err(dev, "failed to assert core reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } ret = reset_assert(&priv->mgmt_rst); if (ret) { dev_err(dev, "failed to assert mgmt reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } ret = reset_assert(&priv->mgmt_sticky_rst); if (ret) { dev_err(dev, "failed to assert mgmt-sticky reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } ret = reset_assert(&priv->pipe_rst); if (ret) { dev_err(dev, "failed to assert pipe reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } udelay(10); @@ -206,19 +214,19 @@ static int rockchip_pcie_init_port(struct udevice *dev) ret = reset_deassert(&priv->pm_rst); if (ret) { dev_err(dev, "failed to deassert pm reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } ret = reset_deassert(&priv->aclk_rst); if (ret) { dev_err(dev, "failed to deassert aclk reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } ret = reset_deassert(&priv->pclk_rst); if (ret) { dev_err(dev, "failed to deassert pclk reset (ret=%d)\n", ret); - return ret; + goto err_exit_phy; } /* Select GEN1 for now */ @@ -227,29 +235,35 @@ static int rockchip_pcie_init_port(struct udevice *dev) cr |= PCIE_CLIENT_CONF_ENABLE | PCIE_CLIENT_MODE_RC; writel(cr, priv->apb_base + PCIE_CLIENT_CONFIG); + ret = ops->power_on(phy); + if (ret) { + dev_err(dev, "failed to power on phy (ret=%d)\n", ret); + goto err_power_off_phy; + } + ret = reset_deassert(&priv->mgmt_sticky_rst); if (ret) { dev_err(dev, "failed to deassert mgmt-sticky reset (ret=%d)\n", ret); - return ret; + goto err_power_off_phy; } ret = reset_deassert(&priv->core_rst); if (ret) { dev_err(dev, "failed to deassert core reset (ret=%d)\n", ret); - return ret; + goto err_power_off_phy; } ret = reset_deassert(&priv->mgmt_rst); if (ret) { dev_err(dev, "failed to deassert mgmt reset (ret=%d)\n", ret); - return ret; + goto err_power_off_phy; } ret = reset_deassert(&priv->pipe_rst); if (ret) { dev_err(dev, "failed to deassert pipe reset (ret=%d)\n", ret); - return ret; + goto err_power_off_phy; } /* Enable Gen1 training */ @@ -264,7 +278,7 @@ static int rockchip_pcie_init_port(struct udevice *dev) status, PCIE_LINK_UP(status), 20, 500 * 1000); if (ret) { dev_err(dev, "PCIe link training gen1 timeout!\n"); - return ret; + goto err_power_off_phy; } /* Initialize Root Complex registers. */ @@ -284,10 +298,16 @@ static int rockchip_pcie_init_port(struct udevice *dev) ret = rockchip_pcie_atr_init(priv); if (ret) { dev_err(dev, "PCIE-%d: ATR init failed\n", dev->seq); - return ret; + goto err_power_off_phy; } return 0; + +err_power_off_phy: + ops->power_off(phy); +err_exit_phy: + ops->exit(phy); + return ret; } static int rockchip_pcie_set_vpcie(struct udevice *dev) @@ -426,6 +446,10 @@ static int rockchip_pcie_probe(struct udevice *dev) if (ret) return ret; + ret = rockchip_pcie_phy_get(dev); + if (ret) + return ret; + ret = rockchip_pcie_set_vpcie(dev); if (ret) return ret; diff --git a/drivers/pci/pcie_rockchip.h b/drivers/pci/pcie_rockchip.h index 6ded5c9553..c3a0a2846d 100644 --- a/drivers/pci/pcie_rockchip.h +++ b/drivers/pci/pcie_rockchip.h @@ -53,11 +53,61 @@ #define PCIE_ATR_OB_REGION0_SIZE (32 * 1024 * 1024) #define PCIE_ATR_OB_REGION_SIZE (1 * 1024 * 1024) +/* + * The higher 16-bit of this register is used for write protection + * only if BIT(x + 16) set to 1 the BIT(x) can be written. + */ +#define HIWORD_UPDATE_MASK(val, mask, shift) \ + ((val) << (shift) | (mask) << ((shift) + 16)) + +#define PHY_CFG_DATA_SHIFT 7 +#define PHY_CFG_ADDR_SHIFT 1 +#define PHY_CFG_DATA_MASK 0xf +#define PHY_CFG_ADDR_MASK 0x3f +#define PHY_CFG_RD_MASK 0x3ff +#define PHY_CFG_WR_ENABLE 1 +#define PHY_CFG_WR_DISABLE 1 +#define PHY_CFG_WR_SHIFT 0 +#define PHY_CFG_WR_MASK 1 +#define PHY_CFG_PLL_LOCK 0x10 +#define PHY_CFG_CLK_TEST 0x10 +#define PHY_CFG_CLK_SCC 0x12 +#define PHY_CFG_SEPE_RATE BIT(3) +#define PHY_CFG_PLL_100M BIT(3) +#define PHY_PLL_LOCKED BIT(9) +#define PHY_PLL_OUTPUT BIT(10) +#define PHY_LANE_IDLE_OFF 0x1 +#define PHY_LANE_IDLE_MASK 0x1 +#define PHY_LANE_IDLE_A_SHIFT 3 +#define PHY_LANE_IDLE_B_SHIFT 4 +#define PHY_LANE_IDLE_C_SHIFT 5 +#define PHY_LANE_IDLE_D_SHIFT 6 + +#define PCIE_PHY_CONF 0xe220 +#define PCIE_PHY_STATUS 0xe2a4 +#define PCIE_PHY_LANEOFF 0xe214 + +struct rockchip_pcie_phy { + void *reg_base; + struct clk refclk; + struct reset_ctl phy_rst; + struct rockchip_pcie_phy_ops *ops; +}; + +struct rockchip_pcie_phy_ops { + int (*init)(struct rockchip_pcie_phy *phy); + int (*exit)(struct rockchip_pcie_phy *phy); + int (*power_on)(struct rockchip_pcie_phy *phy); + int (*power_off)(struct rockchip_pcie_phy *phy); +}; + struct rockchip_pcie { fdt_addr_t axi_base; fdt_addr_t apb_base; int first_busno; struct udevice *dev; + struct rockchip_pcie_phy rk_phy; + struct rockchip_pcie_phy *phy; /* resets */ struct reset_ctl core_rst; @@ -77,3 +127,16 @@ struct rockchip_pcie { struct udevice *vpcie1v8; struct udevice *vpcie0v9; }; + +int rockchip_pcie_phy_get(struct udevice *dev); + +inline struct rockchip_pcie_phy *pcie_get_phy(struct rockchip_pcie *pcie) +{ + return pcie->phy; +} + +inline +struct rockchip_pcie_phy_ops *phy_get_ops(struct rockchip_pcie_phy *phy) +{ + return (struct rockchip_pcie_phy_ops *)phy->ops; +} diff --git a/drivers/pci/pcie_rockchip_phy.c b/drivers/pci/pcie_rockchip_phy.c new file mode 100644 index 0000000000..47f5d6c7e3 --- /dev/null +++ b/drivers/pci/pcie_rockchip_phy.c @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Rockchip PCIe PHY driver + * + * Copyright (c) 2016 Rockchip, Inc. + * Copyright (c) 2020 Amarula Solutions(India) + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pcie_rockchip.h" + +DECLARE_GLOBAL_DATA_PTR; + +static void phy_wr_cfg(struct rockchip_pcie_phy *phy, u32 addr, u32 data) +{ + u32 reg; + + reg = HIWORD_UPDATE_MASK(data, PHY_CFG_DATA_MASK, PHY_CFG_DATA_SHIFT); + reg |= HIWORD_UPDATE_MASK(addr, PHY_CFG_ADDR_MASK, PHY_CFG_ADDR_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_CONF); + + udelay(1); + + reg = HIWORD_UPDATE_MASK(PHY_CFG_WR_ENABLE, + PHY_CFG_WR_MASK, + PHY_CFG_WR_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_CONF); + + udelay(1); + + reg = HIWORD_UPDATE_MASK(PHY_CFG_WR_DISABLE, + PHY_CFG_WR_MASK, + PHY_CFG_WR_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_CONF); +} + +static int rockchip_pcie_phy_power_on(struct rockchip_pcie_phy *phy) +{ + int ret = 0; + u32 reg, status; + + ret = reset_deassert(&phy->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + return ret; + } + + reg = HIWORD_UPDATE_MASK(PHY_CFG_PLL_LOCK, + PHY_CFG_ADDR_MASK, + PHY_CFG_ADDR_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_CONF); + + reg = HIWORD_UPDATE_MASK(!PHY_LANE_IDLE_OFF, + PHY_LANE_IDLE_MASK, + PHY_LANE_IDLE_A_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_LANEOFF); + + ret = -EINVAL; + ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, + status, + status & PHY_PLL_LOCKED, + 20 * 1000, + 50); + if (ret) { + dev_err(&phy->dev, "pll lock timeout!\n"); + goto err_pll_lock; + } + + phy_wr_cfg(phy, PHY_CFG_CLK_TEST, PHY_CFG_SEPE_RATE); + phy_wr_cfg(phy, PHY_CFG_CLK_SCC, PHY_CFG_PLL_100M); + + ret = -ETIMEDOUT; + ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, + status, + !(status & PHY_PLL_OUTPUT), + 20 * 1000, + 50); + if (ret) { + dev_err(&phy->dev, "pll output enable timeout!\n"); + goto err_pll_lock; + } + + reg = HIWORD_UPDATE_MASK(PHY_CFG_PLL_LOCK, + PHY_CFG_ADDR_MASK, + PHY_CFG_ADDR_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_CONF); + + ret = -EINVAL; + ret = readl_poll_sleep_timeout(phy->reg_base + PCIE_PHY_STATUS, + status, + status & PHY_PLL_LOCKED, + 20 * 1000, + 50); + if (ret) { + dev_err(&phy->dev, "pll relock timeout!\n"); + goto err_pll_lock; + } + + return 0; + +err_pll_lock: + reset_assert(&phy->phy_rst); + return ret; +} + +static int rockchip_pcie_phy_power_off(struct rockchip_pcie_phy *phy) +{ + int ret; + u32 reg; + + reg = HIWORD_UPDATE_MASK(PHY_LANE_IDLE_OFF, + PHY_LANE_IDLE_MASK, + PHY_LANE_IDLE_A_SHIFT); + writel(reg, phy->reg_base + PCIE_PHY_LANEOFF); + + ret = reset_assert(&phy->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + return ret; + } + + return 0; +} + +static int rockchip_pcie_phy_init(struct rockchip_pcie_phy *phy) +{ + int ret; + + ret = clk_enable(&phy->refclk); + if (ret) { + dev_err(dev, "failed to enable refclk clock\n"); + return ret; + } + + ret = reset_assert(&phy->phy_rst); + if (ret) { + dev_err(dev, "failed to assert phy reset\n"); + goto err_reset; + } + + return 0; + +err_reset: + clk_disable(&phy->refclk); + return ret; +} + +static int rockchip_pcie_phy_exit(struct rockchip_pcie_phy *phy) +{ + clk_disable(&phy->refclk); + + return 0; +} + +static struct rockchip_pcie_phy_ops pcie_phy_ops = { + .init = rockchip_pcie_phy_init, + .power_on = rockchip_pcie_phy_power_on, + .power_off = rockchip_pcie_phy_power_off, + .exit = rockchip_pcie_phy_exit, +}; + +int rockchip_pcie_phy_get(struct udevice *dev) +{ + struct rockchip_pcie *priv = dev_get_priv(dev); + struct rockchip_pcie_phy *phy_priv = &priv->rk_phy; + ofnode phy_node; + u32 phandle; + int ret; + + phandle = dev_read_u32_default(dev, "phys", 0); + phy_node = ofnode_get_by_phandle(phandle); + if (!ofnode_valid(phy_node)) { + dev_err(dev, "failed to found pcie-phy\n"); + return -ENODEV; + } + + phy_priv->reg_base = syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + + ret = clk_get_by_index_nodev(phy_node, 0, &phy_priv->refclk); + if (ret) { + dev_err(dev, "failed to get refclk clock phandle\n"); + return ret; + } + + ret = reset_get_by_index_nodev(phy_node, 0, &phy_priv->phy_rst); + if (ret) { + dev_err(dev, "failed to get phy reset phandle\n"); + return ret; + } + + phy_priv->ops = &pcie_phy_ops; + priv->phy = phy_priv; + + return 0; +} From patchwork Sat Apr 25 11:03:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1121 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id EDE733F078 for ; Sat, 25 Apr 2020 13:04:35 +0200 (CEST) Received: by mail-pj1-f72.google.com with SMTP id m6sf10529275pjo.0 for ; Sat, 25 Apr 2020 04:04:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812674; cv=pass; d=google.com; s=arc-20160816; b=VpHsy0N03rDgV/mFGdZAycF9vEW1iCLUvgZs2IKorwUovPs12kTt9XNvTXdvFMNFMP +S1SJgzm13wr4zXohQlQiFI4lq53gopDOo90aJ1pl7snGLFaNMorF220ArZ5pzHpyKG+ 34FK4pc8aJjTt99batNxx/iQ76mo0rtLa/s/jejs0WUDTSytgN2CpeBqQycIRjGCiXTs av1Fsgmr2oc5kUKbitYWzL3WxACawIyzlZcNO0JWTCHKsnaNCe4F/61JaH8+KR1UEdC+ oQHukmIKKEF89VBqLXFOZIG/gFMqp9UDsS0W8JQsChO08uSHrgjLf30xLBZpWaq7D9qz V2KA== 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=AOcSiMFx0N2KW1d2JmpQtMNoSmYkoE0n4e5626apCg0=; b=RtDCpWwTQmzvmqf8+xAdaRdhuH9byW4vdkRj/IIEW5OV34/vziixIfuWOuLuxul+iV PZsGQI2G4/Yvo0clX2q6el6LfaKsXvuZwh67acdyu5Z2KQSUdM7bOCMSuyv3gkJq/o9O RsqeVN/8tj0Yc0w0mRlTERSrixrKb8GEJsIQ7uVQtCnJOk3pKA6WGtEIO1yilWPD9zF8 i6vj4xQBWdlX+xLRfR8iQclQC/RBRRu5rX8JoEX9XfO1CKHXt8q92OPUvyiSnsSH1w38 7IlVycPGJsTlGwrc7lcfmvD1e+2qUUHPmnFvarl5JKIFVppuBjLANJD/+uoXx/NU6an6 0CgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ktWRb5KM; 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=AOcSiMFx0N2KW1d2JmpQtMNoSmYkoE0n4e5626apCg0=; b=lEMU0vpmd74xnU5sRJP7/NBOPbdlQAoNK0sGbKYQlo6xnl3hGCH99VNCQL8DpC87pL XMN2MsBcjbSLxUJrQfN9bm6N4pGHABf3NzqcWy8B5jvPuG9JTxEr/Bed/95ricoFNcHm 47w7x3sqbKmrn+yzA5/9BddHNCuIn5Tc+XM+I= 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=AOcSiMFx0N2KW1d2JmpQtMNoSmYkoE0n4e5626apCg0=; b=a+nFNTm/4DTxNoKUmHDUPFQe9BvmclDH62UpuqIAKQecEslUIVwcgZt55aOSYvIt7V LsuL9+Mtnt8Dqk+toRDk9IVBVudLgSDTAbzjZMUadTvJptOZn5xBXxJPGopzPPD/RTHl M3Bs2Jq8pDyIwi1WZ6n9t1E7S8CCruN8LaKqU9bKnMSxrOWByWN+bPGkhjhmvC9/LQl1 Fh33c262pgMN3Oar283lIJ/73V3HFY/SYXGWlQPhiveMwnEOaeRbCJoSKvFsnpztyASQ r3uDbTl8a8Qgb57sfx6ELQnH3G20Xma71pEvXX7rjndHvuIICbFy86S2i+R56bH2Er+9 ijMg== X-Gm-Message-State: AGi0PuZp3QjRaQyjKLxk+klfb6aArRI61Kidn9ABuwfpnuE3hNTXf1kJ UcpS8i7Sq1S+0eRGpN+fjENRISsh X-Google-Smtp-Source: APiQypKnQua5cjc1mInpEi/dCZBuFH9VNW+WA5I1DGu1fdqlwq99zKtqx4Il0vWBRflDf//gQxy+nw== X-Received: by 2002:a63:f252:: with SMTP id d18mr13271923pgk.448.1587812674684; Sat, 25 Apr 2020 04:04:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:7790:: with SMTP id s138ls9097303pfc.11.gmail; Sat, 25 Apr 2020 04:04:34 -0700 (PDT) X-Received: by 2002:a62:7cca:: with SMTP id x193mr14067346pfc.96.1587812674209; Sat, 25 Apr 2020 04:04:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812674; cv=none; d=google.com; s=arc-20160816; b=rqlugqykSL23smFkhxs6s33eVDUCLkq3lPp4J3ADweVt0t6K41kE1aTVs0pu3AyGzs 5ujfdeTAmS6whV9GrAXM+zrzBJC/+d0eZFbX5+jQRR6nQKXDzcyJkBhmFfBKurw1iXUx dqjafLH/1ClDjkAOIJwBQiTQmXDdiSbVCVaTkWGV3/LRwXkqKbjRyf4DmS+U+OpPK6n4 Q0y9ZrLTvr5bfg8icKqrdmjR5V7Rt39f0+T08BYdQgPDCEXzfQNw8Bz/sqRuH3tM8uYF 28CDFqSugPZPrbzA6P6TVtZpB7DKcN1+YTfXhQU6ckJy9bDkd1jwB35FTjKtSvhx3qYI 5lDg== 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=6gYgLijV3LtEDXmDCnnHOndc5g0iNuTtmUjrvfApMLY=; b=Y6HQr+b2X1kAsS/8bii+OvV8M66bEdn3HM7W/fQ0KUOk+2RKC4LSdZ6a7OdKweYq8Q F9z7OOBf2ColdyeN6olykH1l9CfG4rhQTDodzm7PEHbkI0Bcni3ZwTG16myFg0e0K2Vi RLMmQV02pkiuJkIWEWCf8zWxMOgNYMyZWg/ZS+3qUGTDGq1KgI4yR287cSnq5zRp+Wqe 9f7RFMvqPpVWI8uAK6d4cKcvyTEc05zIeHjjJMRCAuhWgyA1wn25NYxpzWlUg10LYsGK IGWrSDpZ4Fx3KIN0CuDalAGi6mdbT3BZELka4uQ/O2KrHcAxPWqQTGtjOYFO8fbA37Gr Sz5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ktWRb5KM; 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 e16sor10888639pfm.10.2020.04.25.04.04.34 for (Google Transport Security); Sat, 25 Apr 2020 04:04:34 -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:76c3:: with SMTP id r186mr14347430pfc.190.1587812673908; Sat, 25 Apr 2020 04:04:33 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:33 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 7/8] rockchip: Enable PCIe/M.2 on rk3399 board w/ M.2 Date: Sat, 25 Apr 2020 16:33:53 +0530 Message-Id: <20200425110354.12381-8-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=ktWRb5KM; 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 PCIe/M.2 support on - NanoPC-T4 - ROC-RK3399-PC Mezzanine boards. => pci Scanning PCI devices on bus 0 BusDevFun VendorId DeviceId Device Class Sub-Class diff --git a/arch/arm/dts/rk3399-u-boot.dtsi b/arch/arm/dts/rk3399-u-boot.dtsi index ef57c36e73..a79a2d23d8 100644 --- a/arch/arm/dts/rk3399-u-boot.dtsi +++ b/arch/arm/dts/rk3399-u-boot.dtsi @@ -8,6 +8,7 @@ aliases { mmc0 = &sdhci; mmc1 = &sdmmc; + pci0 = &pcie0; }; cic: syscon@ff620000 { diff --git a/configs/nanopc-t4-rk3399_defconfig b/configs/nanopc-t4-rk3399_defconfig index 607a00dbf7..032256fd76 100644 --- a/configs/nanopc-t4-rk3399_defconfig +++ b/configs/nanopc-t4-rk3399_defconfig @@ -18,6 +18,7 @@ CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_PCI=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y @@ -34,10 +35,13 @@ CONFIG_MMC_SDHCI_ROCKCHIP=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_NVME=y +CONFIG_PCI=y CONFIG_PMIC_RK8XX=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y +CONFIG_DM_RESET=y CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y diff --git a/configs/roc-pc-mezzanine-rk3399_defconfig b/configs/roc-pc-mezzanine-rk3399_defconfig index 5a694edc03..0b853805f3 100644 --- a/configs/roc-pc-mezzanine-rk3399_defconfig +++ b/configs/roc-pc-mezzanine-rk3399_defconfig @@ -19,6 +19,7 @@ CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_PCI=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_SPL_OF_CONTROL=y @@ -36,11 +37,14 @@ CONFIG_SPI_FLASH_WINBOND=y CONFIG_DM_ETH=y CONFIG_ETH_DESIGNWARE=y CONFIG_GMAC_ROCKCHIP=y +CONFIG_NVME=y +CONFIG_PCI=y CONFIG_PMIC_RK8XX=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y CONFIG_RAM_RK3399_LPDDR4=y +CONFIG_DM_RESET=y CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_ROCKCHIP_SPI=y From patchwork Sat Apr 25 11:03:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1122 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id DF5163F078 for ; Sat, 25 Apr 2020 13:04:39 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id c190sf11642582pfc.10 for ; Sat, 25 Apr 2020 04:04:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1587812678; cv=pass; d=google.com; s=arc-20160816; b=HgyOccP5PjSKKieNu5pnfK8V+QchyVk1SdOKqmDyBN4StzMpbSotnHj99PFdqRswbt S5uwacKwvCK6SjCRLPuNwOT9NDDz5t78XufmgdZNgxxSfjwJ4KFhWPPOnh1xww4Ratpp 79gbTQ3GgCXxqxcI6DUkcbZobacqUijpkbltw/kVGxfenpKMvvPPnCxDo2q97LEhO4Vs eRCgXtmEY+aaWuviHG2j0s94Jobb+lxPleVFN3t6Wa9M6qACzfvRO3iC8mvaYL1YkMeo k5p9HlpGU8G7vY4u0228ZPKzV9ndhK8twwXv9ITnbEWiOkAXV8TIfq5EXxNNfIXO+hcr F5Ug== 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=IwTOVFT5TV7yJCBb184BUmBvh8KdbEeIScwMeRWubI8=; b=D9Gv0UZUv9SuVwgaDz13dErViJO3Q7Y3mSKXxW7mf5N0Zrig9x0JHyypeAN+IUwppK XvDoRJ5k0tn0DRRv7PNvLs5od4C/fgqj48KzbY+9/2p87dWqfKCU8jROhe3c7NCuTp4D jIqCT6qzYb7ASPZrgvAb4lg/R6q6PAZjAdRUxm7L/LVBeHY6TX6m8408Syqr8gxV4IvO OsD+rFQ8wtY7HjajOLxXfeqBicav3Rt7k8wE+GCO4N6KEt09x32eDcFLF+oob351v+Tv xLVF58+htZ1KajXEegtbK89qAusT+CUu7NeURwdh+obGTJ9Tc7Djog+UHYY7Io/E43qQ 156g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KOTx5CK6; 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=IwTOVFT5TV7yJCBb184BUmBvh8KdbEeIScwMeRWubI8=; b=JSdA/2StLUUp1KnkCmECO9P/ywZ4SXHDisg1sB+LjIxaScHwlLSsTXTg/uE2mLEmvU v3yN1re2qQw9qmoT1iOq1Enf579Vmqh2WczSONDiGHkm2tHPlxGwj6HvfFxSddImXpwS tMnjWYrSLhVx50/SdkZJROi/JLOCDP6UI0od0= 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=IwTOVFT5TV7yJCBb184BUmBvh8KdbEeIScwMeRWubI8=; b=oM6josXdYYYEZk2buAK6cR4vxbfESdptEUFgzoWEAaxbJjWu7WxDyZMTYfA9n/m5GI 19J/siQkNXrWzKxI/mhgPIEHMIG+/51e4huWFc2utKgu3SV6lUPF44HeoA9o0TrRGVfk SaQJGVwDKngGsYXBfhafqE4LiJUKNny6NlTSCZpDR85p4WuAZRfjiXKvTaOwcFGQhA1F etYPA/jeD1i/SWZNE7QzjqCIjicFc+oasY/vpmN7EzbPckkbXh9CdsKUKBIEX4QyF5xq 5audG704IeM+AGi22EzTpDkaq7QSoSnYeXfil63XTjjM47FPRby14TwXd/SQDLStBhZA 7aAA== X-Gm-Message-State: AGi0PubBwH78e3dW6UVrgaPeEAEnMqdD97fJWfVu90ElEAD77bXvb3pW y3u9QiD32GjTfujK9b9bhtTFzub9 X-Google-Smtp-Source: APiQypKnUROrggFcOdNOUBSFtBfAa1kixX0B9wgwnGfD7z3ZGgIuIyKct/k3eWFx9aLHuvUHQr7Vew== X-Received: by 2002:a17:90a:fe9:: with SMTP id 96mr12220743pjz.13.1587812678732; Sat, 25 Apr 2020 04:04:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:b488:: with SMTP id y8ls10122398plr.2.gmail; Sat, 25 Apr 2020 04:04:38 -0700 (PDT) X-Received: by 2002:a17:90a:2e87:: with SMTP id r7mr11861218pjd.38.1587812678253; Sat, 25 Apr 2020 04:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587812678; cv=none; d=google.com; s=arc-20160816; b=f43fd6smRepSlIiuZOFp55jkA/EpwiOZTYWqFiOdKMMQhsYgn4vX5FJdM0z7Uf3zd3 LINPqRz0QuvWFT31RyrYYX+mUNFv0MhXJbFd0p2jHnSVQYRU6bkZPOAqwo0h4PbgJHM1 /yecLUo2Rfyg095hRym/YESJNzG2v/umJ+fMXT8hPA17kLEezsMDLUTKsq5IXrLvt4lC DiJkXl9S5c32uso1EhYVBYJUbsPhXWY07doeyd0hUAEan7KwJrZXTaqWjRPn0ZuDovbv 0fXgafFtH3mYvVp8J+GcXoSp7D9Wr9WY3rmNpGJSniKPXy+DuveSA+mxjlu1LL1h5Wxd hnDA== 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=q43WUa+L6irHpcR7445SOskgq/+LIo6862w0Q9Mjsg0=; b=CLFlg2OQc0NFjp1k5zV+tFBX87+MXxx9La3ZZOtV7aXwp1mRuJvAbVdFha5HZgELQn iMV/UDnFyIi2a3TWA8cSslmGbM6NuDhdHlDJAFAPiA5VXPq0G6ME8FmpP432wpJ3higP tp8vnyIi+EMpbcGwjI/uWH3UB0ShymD6Xy1cJ3lkECvK7tFVI1GTfAfV21Ty5eC69V5g UkaaHw6JYAOFJd4jzLPef/dEBe9KUfKOIRyp+APqyd1bWVEwwC17XFLWv7B7QCX8EBJs Ae1Gl8Q5ojWhYRawPFd/oXVj2j+Fo7hieyKsC693dGYxGxgu7Qf/KdE1RNBdKA6Nlnqj 3StA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=KOTx5CK6; 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 f2sor11161787pgh.43.2020.04.25.04.04.38 for (Google Transport Security); Sat, 25 Apr 2020 04:04:38 -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:a65:4c41:: with SMTP id l1mr13692106pgr.43.1587812677934; Sat, 25 Apr 2020 04:04:37 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:1d46:fa69:c34:93dc]) by smtp.gmail.com with ESMTPSA id v94sm6922831pjb.39.2020.04.25.04.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 Apr 2020 04:04:37 -0700 (PDT) From: Jagan Teki To: Kever Yang , Simon Glass , Philipp Tomsich Cc: patrick@blueri.se, sunil@amarulasolutions.com, u-boot@lists.denx.de, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki , Tom Cubie , Manivannan Sadhasivam Subject: [PATCH 8/8] rockchip: Enable PCIe/M.2 on rock960 board Date: Sat, 25 Apr 2020 16:33:54 +0530 Message-Id: <20200425110354.12381-9-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200425110354.12381-1-jagan@amarulasolutions.com> References: <20200425110354.12381-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=KOTx5CK6; 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 some on board limitation rock960 PCIe works only with 1.8V IO domain. So, this patch enables grf io_sel explicitly to make PCIe/M.2 to work. rock960 => pci Scanning PCI devices on bus 0 BusDevFun VendorId DeviceId Device Class Sub-Class diff --git a/board/vamrs/rock960_rk3399/rock960-rk3399.c b/board/vamrs/rock960_rk3399/rock960-rk3399.c index 68a127b9ac..98d62e89ca 100644 --- a/board/vamrs/rock960_rk3399/rock960-rk3399.c +++ b/board/vamrs/rock960_rk3399/rock960-rk3399.c @@ -2,3 +2,23 @@ /* * Copyright (C) 2018 Manivannan Sadhasivam */ + +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_MISC_INIT_R +int misc_init_r(void) +{ + struct rk3399_grf_regs *grf = + syscon_get_first_range(ROCKCHIP_SYSCON_GRF); + + /* BT565 is in 1.8v domain */ + rk_setreg(&grf->io_vsel, BIT(0)); + + return 0; +} +#endif diff --git a/configs/rock960-rk3399_defconfig b/configs/rock960-rk3399_defconfig index c4e954731a..cb1ec3c26b 100644 --- a/configs/rock960-rk3399_defconfig +++ b/configs/rock960-rk3399_defconfig @@ -9,6 +9,7 @@ CONFIG_DEBUG_UART_BASE=0xFF1A0000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART=y CONFIG_DEFAULT_FDT_FILE="rockchip/rk3399-rock960.dtb" +CONFIG_MISC_INIT_R=y CONFIG_DISPLAY_BOARDINFO_LATE=y # CONFIG_SPL_RAW_IMAGE_SUPPORT is not set CONFIG_SPL_STACK_R=y @@ -19,6 +20,7 @@ CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_MMC=y CONFIG_CMD_USB=y +CONFIG_CMD_PCI=y # CONFIG_CMD_SETEXPR is not set CONFIG_CMD_TIME=y CONFIG_CMD_PMIC=y @@ -36,10 +38,13 @@ CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_SDMA=y CONFIG_MMC_SDHCI_ROCKCHIP=y CONFIG_DM_ETH=y +CONFIG_NVME=y +CONFIG_PCI=y CONFIG_PMIC_RK8XX=y CONFIG_REGULATOR_PWM=y CONFIG_REGULATOR_RK8XX=y CONFIG_PWM_ROCKCHIP=y +CONFIG_DM_RESET=y CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y