Path: blob/main/sys/arm/freescale/vybrid/vf_mscm.c
39536 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2013 Ruslan Bukin <[email protected]>4* All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25* SUCH DAMAGE.26*/2728/*29* Vybrid Family Miscellaneous System Control Module (MSCM)30* Chapter 66, Vybrid Reference Manual, Rev. 5, 07/201331*/3233#include <sys/param.h>34#include <sys/systm.h>35#include <sys/bus.h>36#include <sys/kernel.h>37#include <sys/module.h>38#include <sys/malloc.h>39#include <sys/rman.h>40#include <sys/timeet.h>41#include <sys/timetc.h>42#include <sys/watchdog.h>4344#include <dev/ofw/openfirm.h>45#include <dev/ofw/ofw_bus.h>46#include <dev/ofw/ofw_bus_subr.h>4748#include <machine/bus.h>49#include <machine/cpu.h>50#include <machine/intr.h>5152#include <arm/freescale/vybrid/vf_common.h>5354#define VF_NINT 112 /* Total number of interrupts */5556/* Int Router Shared Peripheral Routing Control */57#define MSCM_IRSPRC(n) (0x880 + 2 * n)5859struct mscm_softc {60struct resource *res[1];61bus_space_tag_t bst;62bus_space_handle_t bsh;63};6465static struct resource_spec mscm_spec[] = {66{ SYS_RES_MEMORY, 0, RF_ACTIVE },67{ -1, 0 }68};6970static int71mscm_probe(device_t dev)72{7374if (!ofw_bus_status_okay(dev))75return (ENXIO);7677if (!ofw_bus_is_compatible(dev, "fsl,mvf600-mscm"))78return (ENXIO);7980device_set_desc(dev, "Vybrid Family Miscellaneous System Control Module");81return (BUS_PROBE_DEFAULT);82}8384static int85mscm_attach(device_t dev)86{87struct mscm_softc *sc;88int i;8990sc = device_get_softc(dev);9192if (bus_alloc_resources(dev, mscm_spec, sc->res)) {93device_printf(dev, "could not allocate resources\n");94return (ENXIO);95}9697/* Memory interface */98sc->bst = rman_get_bustag(sc->res[0]);99sc->bsh = rman_get_bushandle(sc->res[0]);100101/* Route all the interrupts to CP0 */102for (i = 0; i < VF_NINT; i++)103WRITE2(sc, MSCM_IRSPRC(i), 1);104105return (0);106}107108static device_method_t mscm_methods[] = {109DEVMETHOD(device_probe, mscm_probe),110DEVMETHOD(device_attach, mscm_attach),111{ 0, 0 }112};113114static driver_t mscm_driver = {115"mscm",116mscm_methods,117sizeof(struct mscm_softc),118};119120DRIVER_MODULE(mscm, simplebus, mscm_driver, 0, 0);121122123