Path: blob/main/sys/arm/broadcom/bcm2835/bcm2835_machdep.c
39566 views
/*-1* SPDX-License-Identifier: BSD-4-Clause2*3* Copyright (c) 2012 Oleksandr Tymoshenko.4* Copyright (c) 1994-1998 Mark Brinicombe.5* Copyright (c) 1994 Brini.6* All rights reserved.7*8* This code is derived from software written for Brini by Mark Brinicombe9*10* Redistribution and use in source and binary forms, with or without11* modification, are permitted provided that the following conditions12* are met:13* 1. Redistributions of source code must retain the above copyright14* notice, this list of conditions and the following disclaimer.15* 2. Redistributions in binary form must reproduce the above copyright16* notice, this list of conditions and the following disclaimer in the17* documentation and/or other materials provided with the distribution.18* 3. All advertising materials mentioning features or use of this software19* must display the following acknowledgement:20* This product includes software developed by Brini.21* 4. The name of the company nor the name of the author may be used to22* endorse or promote products derived from this software without specific23* prior written permission.24*25* THIS SOFTWARE IS PROVIDED BY BRINI ``AS IS'' AND ANY EXPRESS OR IMPLIED26* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF27* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.28* IN NO EVENT SHALL BRINI OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,29* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES30* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR31* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)32* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT33* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY34* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF35* SUCH DAMAGE.36*37* from: FreeBSD: //depot/projects/arm/src/sys/arm/at91/kb920x_machdep.c, rev 4538*/3940#include "opt_ddb.h"41#include "opt_platform.h"4243#include <sys/param.h>44#include <sys/systm.h>45#include <sys/bus.h>46#include <sys/devmap.h>4748#include <vm/vm.h>49#include <vm/pmap.h>5051#include <machine/bus.h>52#include <machine/machdep.h>53#include <machine/platform.h>54#include <machine/platformvar.h>5556#include <dev/ofw/openfirm.h>5758#include <arm/broadcom/bcm2835/bcm2835_wdog.h>59#include <arm/broadcom/bcm2835/bcm2836_mp.h>6061#include "platform_if.h"6263#ifdef SOC_BCM283664static platform_devmap_init_t bcm2836_devmap_init;65#endif66static platform_late_init_t bcm2835_late_init;67static platform_cpu_reset_t bcm2835_cpu_reset;6869static void70bcm2835_late_init(platform_t plat)71{72phandle_t system;73pcell_t cells[2];74int len;7576system = OF_finddevice("/system");77if (system != -1) {78len = OF_getencprop(system, "linux,serial", cells,79sizeof(cells));80if (len > 0)81board_set_serial(((uint64_t)cells[0]) << 32 | cells[1]);8283len = OF_getencprop(system, "linux,revision", cells,84sizeof(cells));85if (len > 0)86board_set_revision(cells[0]);87}88}899091#ifdef SOC_BCM283692static int93bcm2836_devmap_init(platform_t plat)94{9596devmap_add_entry(0x3f000000, 0x01000000);97return (0);98}99#endif100101static void102bcm2835_cpu_reset(platform_t plat)103{104bcmwd_watchdog_reset();105}106107108#if defined(SOC_BCM2836) || defined(SOC_BRCM_BCM2837)109static platform_method_t bcm2836_methods[] = {110PLATFORMMETHOD(platform_devmap_init, bcm2836_devmap_init),111PLATFORMMETHOD(platform_late_init, bcm2835_late_init),112PLATFORMMETHOD(platform_cpu_reset, bcm2835_cpu_reset),113114#ifdef SMP115PLATFORMMETHOD(platform_mp_start_ap, bcm2836_mp_start_ap),116PLATFORMMETHOD(platform_mp_setmaxid, bcm2836_mp_setmaxid),117#endif118119PLATFORMMETHOD_END,120};121FDT_PLATFORM_DEF2(bcm2836, bcm2836_legacy, "bcm2836 (legacy)", 0, "brcm,bcm2709", 100);122FDT_PLATFORM_DEF2(bcm2836, bcm2836, "bcm2836", 0, "brcm,bcm2836", 100);123FDT_PLATFORM_DEF2(bcm2836, bcm2837, "bcm2837", 0, "brcm,bcm2837", 100);124#endif /* defined(SOC_BCM2836) || defined(SOC_BRCM_BCM2837) */125126127