xref: /freebsd/sys/arm/freescale/imx/imx6_pl310.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1034e9ed6SIan Lepore /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3af3dc4a7SPedro F. Giffuni  *
4034e9ed6SIan Lepore  * Copyright (c) 2012 Olivier Houchard.
5034e9ed6SIan Lepore  * All rights reserved.
6034e9ed6SIan Lepore  *
7034e9ed6SIan Lepore  * Redistribution and use in source and binary forms, with or without
8034e9ed6SIan Lepore  * modification, are permitted provided that the following conditions
9034e9ed6SIan Lepore  * are met:
10034e9ed6SIan Lepore  * 1. Redistributions of source code must retain the above copyright
11034e9ed6SIan Lepore  *    notice, this list of conditions and the following disclaimer.
12034e9ed6SIan Lepore  * 2. Redistributions in binary form must reproduce the above copyright
13034e9ed6SIan Lepore  *    notice, this list of conditions and the following disclaimer in the
14034e9ed6SIan Lepore  *    documentation and/or other materials provided with the distribution.
15034e9ed6SIan Lepore  *
16034e9ed6SIan Lepore  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17034e9ed6SIan Lepore  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18034e9ed6SIan Lepore  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19034e9ed6SIan Lepore  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20034e9ed6SIan Lepore  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21034e9ed6SIan Lepore  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22034e9ed6SIan Lepore  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23034e9ed6SIan Lepore  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24034e9ed6SIan Lepore  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25034e9ed6SIan Lepore  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26034e9ed6SIan Lepore  */
27034e9ed6SIan Lepore 
28034e9ed6SIan Lepore #include <sys/cdefs.h>
29034e9ed6SIan Lepore /*
30034e9ed6SIan Lepore  * The machine-dependent part of the arm/pl310 driver for imx6 SoCs.
31034e9ed6SIan Lepore  */
32034e9ed6SIan Lepore 
33034e9ed6SIan Lepore #include <sys/types.h>
34034e9ed6SIan Lepore #include <sys/param.h>
35034e9ed6SIan Lepore #include <sys/systm.h>
36034e9ed6SIan Lepore #include <sys/bus.h>
37034e9ed6SIan Lepore #include <sys/rman.h>
38034e9ed6SIan Lepore #include <sys/lock.h>
39034e9ed6SIan Lepore #include <sys/mutex.h>
40034e9ed6SIan Lepore 
41034e9ed6SIan Lepore #include <machine/bus.h>
42034e9ed6SIan Lepore #include <machine/pl310.h>
4375f48c23SAndrew Turner #include <machine/platformvar.h>
4475f48c23SAndrew Turner 
4575f48c23SAndrew Turner #include <arm/freescale/imx/imx6_machdep.h>
4675f48c23SAndrew Turner 
4775f48c23SAndrew Turner #include "platform_pl310_if.h"
48034e9ed6SIan Lepore 
49034e9ed6SIan Lepore void
imx6_pl310_init(platform_t plat,struct pl310_softc * sc)5075f48c23SAndrew Turner imx6_pl310_init(platform_t plat, struct pl310_softc *sc)
51034e9ed6SIan Lepore {
5295da6613SIan Lepore 	uint32_t reg;
5395da6613SIan Lepore 
5495da6613SIan Lepore 	/*
5595da6613SIan Lepore 	 * Enable power saving modes:
5695da6613SIan Lepore 	 *  - Dynamic Gating stops the clock when the controller is idle.
5795da6613SIan Lepore 	 *  - Standby stops the clock when the cores are in WFI mode.
5895da6613SIan Lepore 	 */
5995da6613SIan Lepore 	reg = pl310_read4(sc, PL310_POWER_CTRL);
6095da6613SIan Lepore 	reg |= POWER_CTRL_ENABLE_GATING | POWER_CTRL_ENABLE_STANDBY;
6195da6613SIan Lepore 	pl310_write4(sc, PL310_POWER_CTRL, reg);
6295da6613SIan Lepore 
6395da6613SIan Lepore 	pl310_set_ram_latency(sc, PL310_TAG_RAM_CTRL,  4, 2, 3);
6495da6613SIan Lepore 	pl310_set_ram_latency(sc, PL310_DATA_RAM_CTRL, 4, 2, 3);
65034e9ed6SIan Lepore }
66