Path: blob/main/sys/arm/mv/armada38x/armada38x_pl310.c
39536 views
/*-1* Copyright (c) 2017 Stormshield.2* 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* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR14* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES15* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,17* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT18* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,19* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY20* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT21* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF22* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.23*/2425#include <sys/cdefs.h>26/*27* The machine-dependent part of the arm/pl310 driver for Armada 38x SoCs.28*/2930#include <sys/types.h>31#include <sys/param.h>32#include <sys/systm.h>33#include <sys/bus.h>34#include <sys/rman.h>35#include <sys/lock.h>36#include <sys/mutex.h>3738#include <machine/bus.h>39#include <machine/pl310.h>40#include <machine/platform.h>41#include <machine/platformvar.h>4243#include "armada38x_pl310.h"44#include "platform_pl310_if.h"4546void47mv_a38x_platform_pl310_init(platform_t plat, struct pl310_softc *sc)48{49uint32_t reg;5051/*52* Enable power saving modes:53* - Dynamic Gating stops the clock when the controller is idle.54*/55reg = pl310_read4(sc, PL310_POWER_CTRL);56reg |= POWER_CTRL_ENABLE_GATING;57pl310_write4(sc, PL310_POWER_CTRL, reg);5859pl310_write4(sc, PL310_PREFETCH_CTRL, PREFETCH_CTRL_DL |60PREFETCH_CTRL_DATA_PREFETCH | PREFETCH_CTRL_INCR_DL |61PREFETCH_CTRL_DL_ON_WRAP);6263/* Disable L2 cache sync for IO coherent operation */64sc->sc_io_coherent = true;65}6667void68mv_a38x_platform_pl310_write_ctrl(platform_t plat, struct pl310_softc *sc, uint32_t val)69{7071pl310_write4(sc, PL310_CTRL, val);72}7374void75mv_a38x_platform_pl310_write_debug(platform_t plat, struct pl310_softc *sc, uint32_t val)76{7778pl310_write4(sc, PL310_DEBUG_CTRL, val);79}808182