11.1Sskrll/* $NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $ */ 21.1Sskrll 31.1Sskrll/*- 41.1Sskrll * Copyright (c) 2023 The NetBSD Foundation, Inc. 51.1Sskrll * All rights reserved. 61.1Sskrll * 71.1Sskrll * This code is derived from software contributed to The NetBSD Foundation 81.1Sskrll * by Nick Hudson 91.1Sskrll * 101.1Sskrll * Redistribution and use in source and binary forms, with or without 111.1Sskrll * modification, are permitted provided that the following conditions 121.1Sskrll * are met: 131.1Sskrll * 1. Redistributions of source code must retain the above copyright 141.1Sskrll * notice, this list of conditions and the following disclaimer. 151.1Sskrll * 2. Redistributions in binary form must reproduce the above copyright 161.1Sskrll * notice, this list of conditions and the following disclaimer in the 171.1Sskrll * documentation and/or other materials provided with the distribution. 181.1Sskrll * 191.1Sskrll * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sskrll * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sskrll * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sskrll * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sskrll * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sskrll * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sskrll * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sskrll * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sskrll * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sskrll * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sskrll * POSSIBILITY OF SUCH DAMAGE. 301.1Sskrll */ 311.1Sskrll 321.1Sskrll#include <sys/cdefs.h> 331.1Sskrll__KERNEL_RCSID(0, "$NetBSD: cpus_fdt.c,v 1.1 2023/06/12 12:58:17 skrll Exp $"); 341.1Sskrll 351.1Sskrll#include <sys/param.h> 361.1Sskrll#include <sys/types.h> 371.1Sskrll 381.1Sskrll#include <dev/fdt/fdtvar.h> 391.1Sskrll 401.1Sskrll#include <machine/machdep.h> 411.1Sskrll 421.1Sskrllvoid 431.1Sskrllfdtbus_cpus_md_attach(device_t parent, device_t self, void *aux) 441.1Sskrll{ 451.1Sskrll struct fdt_attach_args * const faa = aux; 461.1Sskrll const int cpus = faa->faa_phandle; 471.1Sskrll 481.1Sskrll uint32_t tbfreq; 491.1Sskrll int ret = of_getprop_uint32(cpus, "timebase-frequency", &tbfreq); 501.1Sskrll if (ret < 0) { 511.1Sskrll aprint_error(": can't get timebase frequency\n"); 521.1Sskrll return; 531.1Sskrll } 541.1Sskrll riscv_timer_frequency_set(tbfreq); 551.1Sskrll} 56