ar71xx_gpiovar.h revision 296373
150476Speter/*- 27629Sjkh * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 37629Sjkh * Copyright (c) 2009, Luiz Otavio O Souza. 47629Sjkh * All rights reserved. 57305Sjkh * 67305Sjkh * Redistribution and use in source and binary forms, with or without 7270098Sse * modification, are permitted provided that the following conditions 8117260Sache * are met: 97629Sjkh * 1. Redistributions of source code must retain the above copyright 107629Sjkh * notice unmodified, this list of conditions, and the following 117629Sjkh * disclaimer. 127629Sjkh * 2. Redistributions in binary form must reproduce the above copyright 137305Sjkh * notice, this list of conditions and the following disclaimer in the 147629Sjkh * documentation and/or other materials provided with the distribution. 157629Sjkh * 167305Sjkh * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 177629Sjkh * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 187629Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 197305Sjkh * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 207629Sjkh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 217629Sjkh * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 227629Sjkh * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2317279Swosch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2417359Swosch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2553868Syokota * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 267629Sjkh * SUCH DAMAGE. 2729726Swosch * 2833274Syokota * $FreeBSD: releng/10.3/sys/mips/atheros/ar71xx_gpiovar.h 255335 2013-09-06 23:47:50Z loos $ 2957693Sjmas * 30270098Sse */ 3175597Ssobomax 3286694Sache#ifndef __AR71XX_GPIOVAR_H__ 33117260Sache#define __AR71XX_GPIOVAR_H__ 347629Sjkh 357629Sjkh#define GPIO_LOCK(_sc) mtx_lock(&(_sc)->gpio_mtx) 3642799Syokota#define GPIO_UNLOCK(_sc) mtx_unlock(&(_sc)->gpio_mtx) 377629Sjkh#define GPIO_LOCK_ASSERT(_sc) mtx_assert(&(_sc)->gpio_mtx, MA_OWNED) 3829726Swosch 39270098Sse/* 4075597Ssobomax * register space access macros 4186694Sache */ 42117260Sache#define GPIO_WRITE(sc, reg, val) do { \ 437629Sjkh bus_write_4(sc->gpio_mem_res, (reg), (val)); \ 4417695Swosch } while (0) 4517695Swosch 46194055Sedwin#define GPIO_READ(sc, reg) bus_read_4(sc->gpio_mem_res, (reg)) 4742799Syokota 4817359Swosch#define GPIO_SET_BITS(sc, reg, bits) \ 4948663Syokota GPIO_WRITE(sc, reg, GPIO_READ(sc, (reg)) | (bits)) 5053868Syokota 51194055Sedwin#define GPIO_CLEAR_BITS(sc, reg, bits) \ 5257693Sjmas GPIO_WRITE(sc, reg, GPIO_READ(sc, (reg)) & ~(bits)) 5357693Sjmas 5448663Syokota#define AR71XX_GPIO_PINS 12 55270098Sse#define AR724X_GPIO_PINS 18 56270098Sse#define AR91XX_GPIO_PINS 22 57270098Sse 58270098Ssestruct ar71xx_gpio_softc { 5959158Sache device_t dev; 6033407Syokota struct mtx gpio_mtx; 6153868Syokota struct resource *gpio_mem_res; 62194055Sedwin int gpio_mem_rid; 6333407Syokota struct resource *gpio_irq_res; 6442799Syokota int gpio_irq_rid; 6517359Swosch void *gpio_ih; 6633407Syokota int gpio_npins; 6753868Syokota struct gpio_pin *gpio_pins; 68194055Sedwin}; 6933407Syokota 7042799Syokota#endif /* __AR71XX_GPIOVAR_H__ */ 7133274Syokota