Path: blob/main/sys/arm/broadcom/bcm2835/bcm2835_spivar.h
39566 views
/*-1* SPDX-License-Identifier: BSD-2-Clause2*3* Copyright (c) 2012 Oleksandr Tymoshenko <[email protected]>4* Copyright (c) 2013 Luiz Otavio O Souza <[email protected]>5* All rights reserved.6*7* Redistribution and use in source and binary forms, with or without8* modification, are permitted provided that the following conditions9* are met:10* 1. Redistributions of source code must retain the above copyright11* notice, this list of conditions and the following disclaimer.12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND17* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE18* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE19* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE20* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL21* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS22* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)23* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT24* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY25* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF26* SUCH DAMAGE.27*/2829#ifndef _BCM2835_SPIVAR_H_30#define _BCM2835_SPIVAR_H_3132struct bcm_spi_softc {33device_t sc_dev;34struct mtx sc_mtx;35struct resource * sc_mem_res;36struct resource * sc_irq_res;37struct spi_command *sc_cmd;38struct thread *sc_thread;39bus_space_tag_t sc_bst;40bus_space_handle_t sc_bsh;41uint32_t sc_len;42uint32_t sc_read;43uint32_t sc_flags;44uint32_t sc_written;45void * sc_intrhand;46};4748#define BCM_SPI_BUSY 0x149#define BCM_SPI_KEEP_CS 0x25051#define BCM_SPI_WRITE(_sc, _off, _val) \52bus_space_write_4(_sc->sc_bst, _sc->sc_bsh, _off, _val)53#define BCM_SPI_READ(_sc, _off) \54bus_space_read_4(_sc->sc_bst, _sc->sc_bsh, _off)5556#define BCM_SPI_LOCK(_sc) \57mtx_lock(&(_sc)->sc_mtx)58#define BCM_SPI_UNLOCK(_sc) \59mtx_unlock(&(_sc)->sc_mtx)6061#endif /* _BCM2835_SPIVAR_H_ */626364