From owner-svn-src-all@freebsd.org Sat Feb 1 17:13:53 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 3DBA11FCDE8; Sat, 1 Feb 2020 17:13:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4891010Vhwz3JLx; Sat, 1 Feb 2020 17:13:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0C4DF22C0; Sat, 1 Feb 2020 17:13:53 +0000 (UTC) (envelope-from mhorne@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 011HDqqc032463; Sat, 1 Feb 2020 17:13:52 GMT (envelope-from mhorne@FreeBSD.org) Received: (from mhorne@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 011HDq4I032462; Sat, 1 Feb 2020 17:13:52 GMT (envelope-from mhorne@FreeBSD.org) Message-Id: <202002011713.011HDq4I032462@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mhorne set sender to mhorne@FreeBSD.org using -f From: Mitchell Horne Date: Sat, 1 Feb 2020 17:13:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357371 - head/sys/riscv/sifive X-SVN-Group: head X-SVN-Commit-Author: mhorne X-SVN-Commit-Paths: head/sys/riscv/sifive X-SVN-Commit-Revision: 357371 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Feb 2020 17:13:53 -0000 Author: mhorne Date: Sat Feb 1 17:13:52 2020 New Revision: 357371 URL: https://svnweb.freebsd.org/changeset/base/357371 Log: prci: register tlclk as a fixed clock The PRCI exports tlclk as a constant fixed divisor clock, defined as 1/2 of the coreclk frequency. In older FU540 device trees (such as the one provided by SiFive), tlclk is represented as its own entity, and is automatically registered as a fixed-divisor-clock. Unfortunately the upstream FU540 device tree (that we have in our tree) represents tlclk as an output of the PRCI block, and we must register it manually. At worst, users of the old device tree will end up with an unreferenced duplicate of tlclk. This fixes device attachment for the SiFive UART on newer device trees, since it references tlclk via the PRCI. Reviewed by: kp Differential Revision: https://reviews.freebsd.org/D23406 Modified: head/sys/riscv/sifive/fu540_prci.c Modified: head/sys/riscv/sifive/fu540_prci.c ============================================================================== --- head/sys/riscv/sifive/fu540_prci.c Sat Feb 1 17:12:15 2020 (r357370) +++ head/sys/riscv/sifive/fu540_prci.c Sat Feb 1 17:13:52 2020 (r357371) @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include @@ -119,6 +120,17 @@ struct prci_pll_def pll_clks[] = { PLL(PRCI_CLK_GEMGXLPLL, "gemgxclk", PRCI_GEMGXLPLL_CFG0), }; +/* Fixed divisor clock TLCLK. */ +struct clk_fixed_def tlclk_def = { + .clkdef.id = PRCI_CLK_TLCLK, + .clkdef.name = "prci_tlclk", + .clkdef.parent_names = (const char *[]){"coreclk"}, + .clkdef.parent_cnt = 1, + .clkdef.flags = CLK_NODE_STATIC_STRINGS, + .mult = 1, + .div = 2, +}; + static int prci_clk_pll_init(struct clknode *clk, device_t dev) { @@ -270,6 +282,16 @@ prci_attach(device_t dev) clkdef.name = pll_clks[i].name; prci_pll_register(sc, &clkdef, pll_clks[i].reg); } + + /* + * Register the fixed clock "tlclk". + * + * If an older device tree is being used, tlclk may appear as its own + * entity in the device tree, under soc/tlclk. If this is the case it + * will be registered automatically by the fixed_clk driver, and the + * version we register here will be an unreferenced duplicate. + */ + clknode_fixed_register(sc->clkdom, &tlclk_def); error = clkdom_finit(sc->clkdom); if (error)