1e53470feSOleksandr Tymoshenko /*-
2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause
3af3dc4a7SPedro F. Giffuni *
4e53470feSOleksandr Tymoshenko * Copyright (c) 2012 Olivier Houchard. All rights reserved.
5e53470feSOleksandr Tymoshenko *
6e53470feSOleksandr Tymoshenko * Redistribution and use in source and binary forms, with or without
7e53470feSOleksandr Tymoshenko * modification, are permitted provided that the following conditions
8e53470feSOleksandr Tymoshenko * are met:
9e53470feSOleksandr Tymoshenko * 1. Redistributions of source code must retain the above copyright
10e53470feSOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer.
11e53470feSOleksandr Tymoshenko * 2. Redistributions in binary form must reproduce the above copyright
12e53470feSOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer in the
13e53470feSOleksandr Tymoshenko * documentation and/or other materials provided with the distribution.
14e53470feSOleksandr Tymoshenko *
15e53470feSOleksandr Tymoshenko * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16e53470feSOleksandr Tymoshenko * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17e53470feSOleksandr Tymoshenko * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18e53470feSOleksandr Tymoshenko * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19e53470feSOleksandr Tymoshenko * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20e53470feSOleksandr Tymoshenko * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21e53470feSOleksandr Tymoshenko * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22e53470feSOleksandr Tymoshenko * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23e53470feSOleksandr Tymoshenko * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24e53470feSOleksandr Tymoshenko * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25e53470feSOleksandr Tymoshenko */
26e53470feSOleksandr Tymoshenko
27e53470feSOleksandr Tymoshenko #include <sys/types.h>
28e53470feSOleksandr Tymoshenko #include <sys/param.h>
29e53470feSOleksandr Tymoshenko #include <sys/systm.h>
307c5338d7SOleksandr Tymoshenko #include <sys/bus.h>
317c5338d7SOleksandr Tymoshenko #include <sys/rman.h>
327c5338d7SOleksandr Tymoshenko #include <sys/lock.h>
337c5338d7SOleksandr Tymoshenko #include <sys/mutex.h>
347c5338d7SOleksandr Tymoshenko
357c5338d7SOleksandr Tymoshenko #include <machine/bus.h>
36e53470feSOleksandr Tymoshenko #include <machine/pl310.h>
3775f48c23SAndrew Turner #include <machine/platformvar.h>
3875f48c23SAndrew Turner
3975f48c23SAndrew Turner #include <arm/ti/ti_smc.h>
4075f48c23SAndrew Turner #include <arm/ti/omap4/omap4_machdep.h>
4175f48c23SAndrew Turner #include <arm/ti/omap4/omap4_smc.h>
4275f48c23SAndrew Turner
4375f48c23SAndrew Turner #include "platform_pl310_if.h"
44e53470feSOleksandr Tymoshenko
45e53470feSOleksandr Tymoshenko void
omap4_pl310_init(platform_t plat,struct pl310_softc * sc)4675f48c23SAndrew Turner omap4_pl310_init(platform_t plat, struct pl310_softc *sc)
47e53470feSOleksandr Tymoshenko {
487c5338d7SOleksandr Tymoshenko uint32_t aux, prefetch;
497c5338d7SOleksandr Tymoshenko
507c5338d7SOleksandr Tymoshenko aux = pl310_read4(sc, PL310_AUX_CTRL);
517c5338d7SOleksandr Tymoshenko prefetch = pl310_read4(sc, PL310_PREFETCH_CTRL);
527c5338d7SOleksandr Tymoshenko
537c5338d7SOleksandr Tymoshenko /*
547c5338d7SOleksandr Tymoshenko * Disable instruction prefetch
557c5338d7SOleksandr Tymoshenko */
567c5338d7SOleksandr Tymoshenko prefetch &= ~PREFETCH_CTRL_INSTR_PREFETCH;
577c5338d7SOleksandr Tymoshenko aux &= ~AUX_CTRL_INSTR_PREFETCH;
587c5338d7SOleksandr Tymoshenko
597c5338d7SOleksandr Tymoshenko // prefetch &= ~PREFETCH_CTRL_DATA_PREFETCH;
607c5338d7SOleksandr Tymoshenko // aux &= ~AUX_CTRL_DATA_PREFETCH;
617c5338d7SOleksandr Tymoshenko
627c5338d7SOleksandr Tymoshenko /*
637c5338d7SOleksandr Tymoshenko * Make sure data prefetch is on
647c5338d7SOleksandr Tymoshenko */
657c5338d7SOleksandr Tymoshenko prefetch |= PREFETCH_CTRL_DATA_PREFETCH;
667c5338d7SOleksandr Tymoshenko aux |= AUX_CTRL_DATA_PREFETCH;
677c5338d7SOleksandr Tymoshenko
687c5338d7SOleksandr Tymoshenko /*
697c5338d7SOleksandr Tymoshenko * TODO: add tunable for prefetch offset
707c5338d7SOleksandr Tymoshenko * and experiment with performance
717c5338d7SOleksandr Tymoshenko */
727c5338d7SOleksandr Tymoshenko
737c5338d7SOleksandr Tymoshenko ti_smc0(aux, 0, WRITE_AUXCTRL_REG);
747c5338d7SOleksandr Tymoshenko ti_smc0(prefetch, 0, WRITE_PREFETCH_CTRL_REG);
757c5338d7SOleksandr Tymoshenko }
767c5338d7SOleksandr Tymoshenko
777c5338d7SOleksandr Tymoshenko void
omap4_pl310_write_ctrl(platform_t plat,struct pl310_softc * sc,uint32_t val)7875f48c23SAndrew Turner omap4_pl310_write_ctrl(platform_t plat, struct pl310_softc *sc, uint32_t val)
797c5338d7SOleksandr Tymoshenko {
8075f48c23SAndrew Turner
817c5338d7SOleksandr Tymoshenko ti_smc0(val, 0, L2CACHE_WRITE_CTRL_REG);
827c5338d7SOleksandr Tymoshenko }
837c5338d7SOleksandr Tymoshenko
847c5338d7SOleksandr Tymoshenko void
omap4_pl310_write_debug(platform_t plat,struct pl310_softc * sc,uint32_t val)8575f48c23SAndrew Turner omap4_pl310_write_debug(platform_t plat, struct pl310_softc *sc, uint32_t val)
867c5338d7SOleksandr Tymoshenko {
8775f48c23SAndrew Turner
887c5338d7SOleksandr Tymoshenko ti_smc0(val, 0, L2CACHE_WRITE_DEBUG_REG);
897c5338d7SOleksandr Tymoshenko }
90