1213237Sgonzo#- 2213237Sgonzo# Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 3213237Sgonzo# All rights reserved. 4213237Sgonzo# 5213237Sgonzo# Redistribution and use in source and binary forms, with or without 6213237Sgonzo# modification, are permitted provided that the following conditions 7213237Sgonzo# are met: 8213237Sgonzo# 1. Redistributions of source code must retain the above copyright 9213237Sgonzo# notice, this list of conditions and the following disclaimer. 10213237Sgonzo# 2. Redistributions in binary form must reproduce the above copyright 11213237Sgonzo# notice, this list of conditions and the following disclaimer in the 12213237Sgonzo# documentation and/or other materials provided with the distribution. 13213237Sgonzo# 14213237Sgonzo# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15213237Sgonzo# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16213237Sgonzo# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17213237Sgonzo# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18213237Sgonzo# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19213237Sgonzo# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20213237Sgonzo# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21213237Sgonzo# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22213237Sgonzo# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23213237Sgonzo# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24213237Sgonzo# SUCH DAMAGE. 25213237Sgonzo# 26213237Sgonzo# $FreeBSD: releng/10.2/sys/dev/gpio/gpiobus_if.m 278783 2015-02-14 20:50:38Z loos $ 27213237Sgonzo# 28213237Sgonzo 29213237Sgonzo#include <sys/bus.h> 30213237Sgonzo#include <sys/gpio.h> 31213237Sgonzo 32213237SgonzoINTERFACE gpiobus; 33213237Sgonzo 34213237Sgonzo# 35213237Sgonzo# Dedicate the gpio bus control for a child 36213237Sgonzo# 37278783SloosMETHOD int acquire_bus { 38213237Sgonzo device_t busdev; 39213237Sgonzo device_t dev; 40278783Sloos int how; 41213237Sgonzo}; 42213237Sgonzo 43213237Sgonzo# 44213237Sgonzo# Release the bus 45213237Sgonzo# 46213237SgonzoMETHOD void release_bus { 47213237Sgonzo device_t busdev; 48213237Sgonzo device_t dev; 49213237Sgonzo}; 50213237Sgonzo 51213237Sgonzo# 52213237Sgonzo# Set value of pin specifed by pin_num 53213237Sgonzo# 54213237SgonzoMETHOD int pin_set { 55213237Sgonzo device_t dev; 56213237Sgonzo device_t child; 57213237Sgonzo uint32_t pin_num; 58213237Sgonzo uint32_t pin_value; 59213237Sgonzo}; 60213237Sgonzo 61213237Sgonzo# 62213237Sgonzo# Get value of pin specifed by pin_num 63213237Sgonzo# 64213237SgonzoMETHOD int pin_get { 65213237Sgonzo device_t dev; 66213237Sgonzo device_t child; 67213237Sgonzo uint32_t pin_num; 68213237Sgonzo uint32_t *pin_value; 69213237Sgonzo}; 70213237Sgonzo 71213237Sgonzo# 72213237Sgonzo# Toggle value of pin specifed by pin_num 73213237Sgonzo# 74213237SgonzoMETHOD int pin_toggle { 75213237Sgonzo device_t dev; 76213237Sgonzo device_t child; 77213237Sgonzo uint32_t pin_num; 78213237Sgonzo}; 79213237Sgonzo 80213237Sgonzo# 81213237Sgonzo# Get pin capabilities 82213237Sgonzo# 83213237SgonzoMETHOD int pin_getcaps { 84213237Sgonzo device_t dev; 85213237Sgonzo device_t child; 86213237Sgonzo uint32_t pin_num; 87213237Sgonzo uint32_t *caps; 88213237Sgonzo}; 89213237Sgonzo 90213237Sgonzo# 91213237Sgonzo# Get pin flags 92213237Sgonzo# 93213237SgonzoMETHOD int pin_getflags { 94213237Sgonzo device_t dev; 95213237Sgonzo device_t child; 96213237Sgonzo uint32_t pin_num; 97213237Sgonzo uint32_t *flags; 98213237Sgonzo}; 99213237Sgonzo 100213237Sgonzo# 101213237Sgonzo# Set current configuration and capabilities 102213237Sgonzo# 103213237SgonzoMETHOD int pin_setflags { 104213237Sgonzo device_t dev; 105213237Sgonzo device_t child; 106213237Sgonzo uint32_t pin_num; 107213237Sgonzo uint32_t flags; 108213237Sgonzo}; 109