1239922Sgonzo/*- 2239922Sgonzo * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org> 3239922Sgonzo * All rights reserved. 4239922Sgonzo * 5239922Sgonzo * Redistribution and use in source and binary forms, with or without 6239922Sgonzo * modification, are permitted provided that the following conditions 7239922Sgonzo * are met: 8239922Sgonzo * 1. Redistributions of source code must retain the above copyright 9239922Sgonzo * notice, this list of conditions and the following disclaimer. 10239922Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11239922Sgonzo * notice, this list of conditions and the following disclaimer in the 12239922Sgonzo * documentation and/or other materials provided with the distribution. 13239922Sgonzo * 14239922Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15239922Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16239922Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17239922Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18239922Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19239922Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20239922Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21239922Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22239922Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23239922Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24239922Sgonzo * SUCH DAMAGE. 25239922Sgonzo * 26239922Sgonzo * $FreeBSD: stable/10/sys/arm/broadcom/bcm2835/bcm2835_vcbus.h 322724 2017-08-20 16:52:27Z marius $ 27239922Sgonzo */ 28239922Sgonzo 29239922Sgonzo/* 30239922Sgonzo * Defines for converting physical address to VideoCore bus address and back 31239922Sgonzo */ 32239922Sgonzo 33239922Sgonzo#ifndef _BCM2835_VCBUS_H_ 34239922Sgonzo#define _BCM2835_VCBUS_H_ 35239922Sgonzo 36239922Sgonzo#define BCM2835_VCBUS_SDRAM_CACHED 0x40000000 37247204Sgonzo#define BCM2835_VCBUS_IO_BASE 0x7E000000 38239922Sgonzo#define BCM2835_VCBUS_SDRAM_UNCACHED 0xC0000000 39239922Sgonzo 40322724Smarius#ifdef SOC_BCM2836 41322724Smarius#define BCM2835_ARM_IO_BASE 0x3f000000 42322724Smarius#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_UNCACHED 43322724Smarius#else 44247204Sgonzo#define BCM2835_ARM_IO_BASE 0x20000000 45322724Smarius#define BCM2835_VCBUS_SDRAM_BASE BCM2835_VCBUS_SDRAM_CACHED 46322724Smarius#endif 47322724Smarius#define BCM2835_ARM_IO_SIZE 0x01000000 48247204Sgonzo 49239922Sgonzo/* 50239922Sgonzo * Convert physical address to VC bus address. Should be used 51239922Sgonzo * when submitting address over mailbox interface 52239922Sgonzo */ 53322724Smarius#define PHYS_TO_VCBUS(pa) ((pa) + BCM2835_VCBUS_SDRAM_BASE) 54239922Sgonzo 55247204Sgonzo/* Check whether pa bellong top IO window */ 56247204Sgonzo#define BCM2835_ARM_IS_IO(pa) (((pa) >= BCM2835_ARM_IO_BASE) && \ 57247204Sgonzo ((pa) < BCM2835_ARM_IO_BASE + BCM2835_ARM_IO_SIZE)) 58247204Sgonzo 59239922Sgonzo/* 60247204Sgonzo * Convert physical address in IO space to VC bus address. 61247204Sgonzo */ 62247204Sgonzo#define IO_TO_VCBUS(pa) ((pa - BCM2835_ARM_IO_BASE) + \ 63247204Sgonzo BCM2835_VCBUS_IO_BASE) 64247204Sgonzo 65247204Sgonzo/* 66239922Sgonzo * Convert address from VC bus space to physical. Should be used 67239922Sgonzo * when address is returned by VC over mailbox interface. e.g. 68239922Sgonzo * framebuffer base 69239922Sgonzo */ 70322724Smarius#define VCBUS_TO_PHYS(vca) ((vca) & ~(BCM2835_VCBUS_SDRAM_BASE)) 71239922Sgonzo 72239922Sgonzo#endif /* _BCM2835_VCBUS_H_ */ 73