From owner-svn-src-head@freebsd.org Tue Jul 31 20:50:51 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 23C211064852; Tue, 31 Jul 2018 20:50:51 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CED277C387; Tue, 31 Jul 2018 20:50:50 +0000 (UTC) (envelope-from manu@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 972E518C43; Tue, 31 Jul 2018 20:50:50 +0000 (UTC) (envelope-from manu@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6VKooV9027844; Tue, 31 Jul 2018 20:50:50 GMT (envelope-from manu@FreeBSD.org) Received: (from manu@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6VKoopE027843; Tue, 31 Jul 2018 20:50:50 GMT (envelope-from manu@FreeBSD.org) Message-Id: <201807312050.w6VKoopE027843@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: manu set sender to manu@FreeBSD.org using -f From: Emmanuel Vadot Date: Tue, 31 Jul 2018 20:50:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r337004 - head/sys/dev/ofw X-SVN-Group: head X-SVN-Commit-Author: manu X-SVN-Commit-Paths: head/sys/dev/ofw X-SVN-Commit-Revision: 337004 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Jul 2018 20:50:51 -0000 Author: manu Date: Tue Jul 31 20:50:50 2018 New Revision: 337004 URL: https://svnweb.freebsd.org/changeset/base/337004 Log: ofw_cpu: Add support for getting cpu clock via clock property Nominal Mhz is either expressed via the clock-frequency property or can be get via the clock property that holds the cpu clock. Add support for the later. Reviewed by: nwhitehorn Differential Revision: https://reviews.freebsd.org/D16346 Modified: head/sys/dev/ofw/ofw_cpu.c Modified: head/sys/dev/ofw/ofw_cpu.c ============================================================================== --- head/sys/dev/ofw/ofw_cpu.c Tue Jul 31 19:35:34 2018 (r337003) +++ head/sys/dev/ofw/ofw_cpu.c Tue Jul 31 20:50:50 2018 (r337004) @@ -45,6 +45,10 @@ __FBSDID("$FreeBSD$"); #include #include +#ifdef EXT_RESOURCES +#include +#endif + static int ofw_cpulist_probe(device_t); static int ofw_cpulist_attach(device_t); static const struct ofw_bus_devinfo *ofw_cpulist_get_devinfo(device_t dev, @@ -203,6 +207,10 @@ ofw_cpu_attach(device_t dev) phandle_t node; pcell_t cell; int rv; +#ifdef EXT_RESOURCES + clk_t cpuclk; + uint64_t freq; +#endif sc = device_get_softc(dev); psc = device_get_softc(device_get_parent(dev)); @@ -269,12 +277,28 @@ ofw_cpu_attach(device_t dev) sc->sc_cpu_pcpu = pcpu_find(device_get_unit(dev)); if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) { - if (bootverbose) - device_printf(dev, - "missing 'clock-frequency' property\n"); +#ifdef EXT_RESOURCES + rv = clk_get_by_ofw_index(dev, 0, 0, &cpuclk); + if (rv == 0) { + rv = clk_get_freq(cpuclk, &freq); + if (rv != 0 && bootverbose) + device_printf(dev, + "Cannot get freq of property clocks\n"); + else + sc->sc_nominal_mhz = freq / 1000000; + } else +#endif + { + if (bootverbose) + device_printf(dev, + "missing 'clock-frequency' property\n"); + } } else sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */ + if (sc->sc_nominal_mhz != 0 && bootverbose) + device_printf(dev, "Nominal frequency %dMhz\n", + sc->sc_nominal_mhz); bus_generic_probe(dev); return (bus_generic_attach(dev)); }