Path: blob/main/sys/powerpc/mikrotik/platform_rb.c
39535 views
/*-1* Copyright (c) 2015 Justin Hibbits2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7*8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10* 2. Redistributions in binary form must reproduce the above copyright11* notice, this list of conditions and the following disclaimer in the12* documentation and/or other materials provided with the distribution.13*14* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR15* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES16* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.17* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,18* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT19* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,20* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY21* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT22* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF23* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.24*/2526#include <sys/param.h>27#include <sys/systm.h>28#include <sys/kernel.h>29#include <sys/bus.h>30#include <sys/malloc.h>31#include <sys/smp.h>3233#include <machine/platform.h>34#include <machine/platformvar.h>3536#include <dev/ofw/openfirm.h>3738#include <powerpc/mpc85xx/mpc85xx.h>3940#include "platform_if.h"4142static int rb_probe(platform_t);43static int rb_attach(platform_t);4445static platform_method_t rb_methods[] = {46PLATFORMMETHOD(platform_probe, rb_probe),47PLATFORMMETHOD(platform_attach, rb_attach),48PLATFORMMETHOD_END49};5051DEFINE_CLASS_1(rb, rb_platform, rb_methods, 0, mpc85xx_platform);5253PLATFORM_DEF(rb_platform);5455static int56rb_probe(platform_t plat)57{58phandle_t rootnode;59char model[32];6061rootnode = OF_finddevice("/");6263if (OF_getprop(rootnode, "model", model, sizeof(model)) > 0) {64if (strcmp(model, "RB800") == 0)65return (BUS_PROBE_SPECIFIC);66}6768return (ENXIO);69}7071static int72rb_attach(platform_t plat)73{74int error;7576error = mpc85xx_attach(plat);77if (error)78return (error);7980return (0);81}828384