1257062Sloos/*- 2257062Sloos * Copyright (c) 2012 Oleksandr Tymoshenko <gonzo@freebsd.org> 3257062Sloos * Copyright (c) 2013 Luiz Otavio O Souza <loos@freebsd.org> 4257062Sloos * All rights reserved. 5257062Sloos * 6257062Sloos * Redistribution and use in source and binary forms, with or without 7257062Sloos * modification, are permitted provided that the following conditions 8257062Sloos * are met: 9257062Sloos * 1. Redistributions of source code must retain the above copyright 10257062Sloos * notice, this list of conditions and the following disclaimer. 11257062Sloos * 2. Redistributions in binary form must reproduce the above copyright 12257062Sloos * notice, this list of conditions and the following disclaimer in the 13257062Sloos * documentation and/or other materials provided with the distribution. 14257062Sloos * 15257062Sloos * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16257062Sloos * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17257062Sloos * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18257062Sloos * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19257062Sloos * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20257062Sloos * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21257062Sloos * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22257062Sloos * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23257062Sloos * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24257062Sloos * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25257062Sloos * SUCH DAMAGE. 26257062Sloos * 27257062Sloos * $FreeBSD$ 28257062Sloos */ 29257062Sloos 30257062Sloos#ifndef _BCM2835_SPIVAR_H_ 31257062Sloos#define _BCM2835_SPIVAR_H_ 32257062Sloos 33257062Sloos/* 34257062Sloos * Only the available pins are listed here. 35257062Sloos * i.e. CS2 isn't available. 36257062Sloos */ 37257062Sloosuint32_t bcm_spi_pins[] = { 38257062Sloos 7, /* CS1 */ 39257062Sloos 8, /* CS0 */ 40257062Sloos 9, /* MISO */ 41257062Sloos 10, /* MOSI */ 42257062Sloos 11 /* SCLK */ 43257062Sloos}; 44257062Sloos 45257062Sloosstruct bcm_spi_softc { 46257062Sloos device_t sc_dev; 47257062Sloos struct mtx sc_mtx; 48257062Sloos struct resource * sc_mem_res; 49257062Sloos struct resource * sc_irq_res; 50257062Sloos struct spi_command *sc_cmd; 51257062Sloos bus_space_tag_t sc_bst; 52257062Sloos bus_space_handle_t sc_bsh; 53257062Sloos uint32_t sc_len; 54257062Sloos uint32_t sc_read; 55257062Sloos uint32_t sc_flags; 56257062Sloos uint32_t sc_written; 57257062Sloos void * sc_intrhand; 58257062Sloos}; 59257062Sloos 60257062Sloos#define BCM_SPI_BUSY 0x1 61257062Sloos 62257062Sloos#define BCM_SPI_WRITE(_sc, _off, _val) \ 63257062Sloos bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val) 64257062Sloos#define BCM_SPI_READ(_sc, _off) \ 65257062Sloos bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off) 66257062Sloos 67257062Sloos#define BCM_SPI_LOCK(_sc) \ 68257062Sloos mtx_lock(&(_sc)->sc_mtx) 69257062Sloos#define BCM_SPI_UNLOCK(_sc) \ 70257062Sloos mtx_unlock(&(_sc)->sc_mtx) 71257062Sloos 72257062Sloos#endif /* _BCM2835_SPIVAR_H_ */ 73