1256959Sloos/*- 2256959Sloos * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org> 3256959Sloos * Copyright (c) 2013 Luiz Otavio O Souza <loos@freebsd.org> 4256959Sloos * All rights reserved. 5256959Sloos * 6256959Sloos * Redistribution and use in source and binary forms, with or without 7256959Sloos * modification, are permitted provided that the following conditions 8256959Sloos * are met: 9256959Sloos * 1. Redistributions of source code must retain the above copyright 10256959Sloos * notice, this list of conditions and the following disclaimer. 11256959Sloos * 2. Redistributions in binary form must reproduce the above copyright 12256959Sloos * notice, this list of conditions and the following disclaimer in the 13256959Sloos * documentation and/or other materials provided with the distribution. 14256959Sloos * 15256959Sloos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16256959Sloos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17256959Sloos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18256959Sloos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19256959Sloos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20256959Sloos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21256959Sloos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22256959Sloos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23256959Sloos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24256959Sloos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25256959Sloos * SUCH DAMAGE. 26256959Sloos * 27256959Sloos * $FreeBSD$ 28256959Sloos */ 29256959Sloos 30256959Sloos#ifndef _BCM2835_BSCVAR_H 31256959Sloos#define _BCM2835_BSCVAR_H 32256959Sloos 33256959Sloosstruct { 34256959Sloos uint32_t sda; 35256959Sloos uint32_t scl; 36261078Sloos unsigned long start; 37256959Sloos} bcm_bsc_pins[] = { 38261078Sloos { 0, 1, 0x20205000 }, /* BSC0 GPIO pins and base address. */ 39261078Sloos { 2, 3, 0x20804000 } /* BSC1 GPIO pins and base address. */ 40256959Sloos}; 41256959Sloos 42256959Sloosstruct bcm_bsc_softc { 43256959Sloos device_t sc_dev; 44256959Sloos struct mtx sc_mtx; 45256959Sloos struct resource * sc_mem_res; 46256959Sloos struct resource * sc_irq_res; 47256959Sloos bus_space_tag_t sc_bst; 48256959Sloos bus_space_handle_t sc_bsh; 49256959Sloos uint16_t sc_resid; 50256959Sloos uint8_t *sc_data; 51256959Sloos uint8_t sc_flags; 52256959Sloos void * sc_intrhand; 53256959Sloos}; 54256959Sloos 55256959Sloos#define BCM_I2C_BUSY 0x01 56256959Sloos#define BCM_I2C_READ 0x02 57256959Sloos#define BCM_I2C_ERROR 0x04 58256959Sloos 59256959Sloos#define BCM_BSC_WRITE(_sc, _off, _val) \ 60256959Sloos bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val) 61256959Sloos#define BCM_BSC_READ(_sc, _off) \ 62256959Sloos bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off) 63256959Sloos 64256959Sloos#define BCM_BSC_LOCK(_sc) \ 65256959Sloos mtx_lock(&(_sc)->sc_mtx) 66256959Sloos#define BCM_BSC_UNLOCK(_sc) \ 67256959Sloos mtx_unlock(&(_sc)->sc_mtx) 68256959Sloos 69256959Sloos#endif /* _BCM2835_BSCVAR_H_ */ 70