16b34b16eSOleksandr Tymoshenko#- 26b34b16eSOleksandr Tymoshenko# Copyright (c) 2009 Oleksandr Tymoshenko <gonzo@freebsd.org> 36b34b16eSOleksandr Tymoshenko# All rights reserved. 46b34b16eSOleksandr Tymoshenko# 56b34b16eSOleksandr Tymoshenko# Redistribution and use in source and binary forms, with or without 66b34b16eSOleksandr Tymoshenko# modification, are permitted provided that the following conditions 76b34b16eSOleksandr Tymoshenko# are met: 86b34b16eSOleksandr Tymoshenko# 1. Redistributions of source code must retain the above copyright 96b34b16eSOleksandr Tymoshenko# notice, this list of conditions and the following disclaimer. 106b34b16eSOleksandr Tymoshenko# 2. Redistributions in binary form must reproduce the above copyright 116b34b16eSOleksandr Tymoshenko# notice, this list of conditions and the following disclaimer in the 126b34b16eSOleksandr Tymoshenko# documentation and/or other materials provided with the distribution. 136b34b16eSOleksandr Tymoshenko# 146b34b16eSOleksandr Tymoshenko# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 156b34b16eSOleksandr Tymoshenko# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 166b34b16eSOleksandr Tymoshenko# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 176b34b16eSOleksandr Tymoshenko# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 186b34b16eSOleksandr Tymoshenko# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 196b34b16eSOleksandr Tymoshenko# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 206b34b16eSOleksandr Tymoshenko# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 216b34b16eSOleksandr Tymoshenko# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 226b34b16eSOleksandr Tymoshenko# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 236b34b16eSOleksandr Tymoshenko# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 246b34b16eSOleksandr Tymoshenko# SUCH DAMAGE. 256b34b16eSOleksandr Tymoshenko# 266b34b16eSOleksandr Tymoshenko# 276b34b16eSOleksandr Tymoshenko 286b34b16eSOleksandr Tymoshenko#include <sys/bus.h> 296b34b16eSOleksandr Tymoshenko#include <sys/gpio.h> 306b34b16eSOleksandr Tymoshenko 316b34b16eSOleksandr TymoshenkoINTERFACE gpiobus; 326b34b16eSOleksandr Tymoshenko 336b34b16eSOleksandr Tymoshenko# 346b34b16eSOleksandr Tymoshenko# Dedicate the gpio bus control for a child 356b34b16eSOleksandr Tymoshenko# 369d35acacSLuiz Otavio O SouzaMETHOD int acquire_bus { 376b34b16eSOleksandr Tymoshenko device_t busdev; 386b34b16eSOleksandr Tymoshenko device_t dev; 399d35acacSLuiz Otavio O Souza int how; 406b34b16eSOleksandr Tymoshenko}; 416b34b16eSOleksandr Tymoshenko 426b34b16eSOleksandr Tymoshenko# 436b34b16eSOleksandr Tymoshenko# Release the bus 446b34b16eSOleksandr Tymoshenko# 456b34b16eSOleksandr TymoshenkoMETHOD void release_bus { 466b34b16eSOleksandr Tymoshenko device_t busdev; 476b34b16eSOleksandr Tymoshenko device_t dev; 486b34b16eSOleksandr Tymoshenko}; 496b34b16eSOleksandr Tymoshenko 506b34b16eSOleksandr Tymoshenko# 51*04389c85SGordon Bergling# Set value of pin specified by pin_num 526b34b16eSOleksandr Tymoshenko# 536b34b16eSOleksandr TymoshenkoMETHOD int pin_set { 546b34b16eSOleksandr Tymoshenko device_t dev; 556b34b16eSOleksandr Tymoshenko device_t child; 566b34b16eSOleksandr Tymoshenko uint32_t pin_num; 576b34b16eSOleksandr Tymoshenko uint32_t pin_value; 586b34b16eSOleksandr Tymoshenko}; 596b34b16eSOleksandr Tymoshenko 606b34b16eSOleksandr Tymoshenko# 61*04389c85SGordon Bergling# Get value of pin specified by pin_num 626b34b16eSOleksandr Tymoshenko# 636b34b16eSOleksandr TymoshenkoMETHOD int pin_get { 646b34b16eSOleksandr Tymoshenko device_t dev; 656b34b16eSOleksandr Tymoshenko device_t child; 666b34b16eSOleksandr Tymoshenko uint32_t pin_num; 676b34b16eSOleksandr Tymoshenko uint32_t *pin_value; 686b34b16eSOleksandr Tymoshenko}; 696b34b16eSOleksandr Tymoshenko 706b34b16eSOleksandr Tymoshenko# 71*04389c85SGordon Bergling# Toggle value of pin specified by pin_num 726b34b16eSOleksandr Tymoshenko# 736b34b16eSOleksandr TymoshenkoMETHOD int pin_toggle { 746b34b16eSOleksandr Tymoshenko device_t dev; 756b34b16eSOleksandr Tymoshenko device_t child; 766b34b16eSOleksandr Tymoshenko uint32_t pin_num; 776b34b16eSOleksandr Tymoshenko}; 786b34b16eSOleksandr Tymoshenko 796b34b16eSOleksandr Tymoshenko# 806b34b16eSOleksandr Tymoshenko# Get pin capabilities 816b34b16eSOleksandr Tymoshenko# 826b34b16eSOleksandr TymoshenkoMETHOD int pin_getcaps { 836b34b16eSOleksandr Tymoshenko device_t dev; 846b34b16eSOleksandr Tymoshenko device_t child; 856b34b16eSOleksandr Tymoshenko uint32_t pin_num; 866b34b16eSOleksandr Tymoshenko uint32_t *caps; 876b34b16eSOleksandr Tymoshenko}; 886b34b16eSOleksandr Tymoshenko 896b34b16eSOleksandr Tymoshenko# 906b34b16eSOleksandr Tymoshenko# Get pin flags 916b34b16eSOleksandr Tymoshenko# 926b34b16eSOleksandr TymoshenkoMETHOD int pin_getflags { 936b34b16eSOleksandr Tymoshenko device_t dev; 946b34b16eSOleksandr Tymoshenko device_t child; 956b34b16eSOleksandr Tymoshenko uint32_t pin_num; 966b34b16eSOleksandr Tymoshenko uint32_t *flags; 976b34b16eSOleksandr Tymoshenko}; 986b34b16eSOleksandr Tymoshenko 996b34b16eSOleksandr Tymoshenko# 1006b34b16eSOleksandr Tymoshenko# Set current configuration and capabilities 1016b34b16eSOleksandr Tymoshenko# 1026b34b16eSOleksandr TymoshenkoMETHOD int pin_setflags { 1036b34b16eSOleksandr Tymoshenko device_t dev; 1046b34b16eSOleksandr Tymoshenko device_t child; 1056b34b16eSOleksandr Tymoshenko uint32_t pin_num; 1066b34b16eSOleksandr Tymoshenko uint32_t flags; 1076b34b16eSOleksandr Tymoshenko}; 108d752f0f6SLuiz Otavio O Souza 109d752f0f6SLuiz Otavio O Souza# 110d752f0f6SLuiz Otavio O Souza# Get the pin name 111d752f0f6SLuiz Otavio O Souza# 112d752f0f6SLuiz Otavio O SouzaMETHOD int pin_getname { 113d752f0f6SLuiz Otavio O Souza device_t dev; 114d752f0f6SLuiz Otavio O Souza uint32_t pin_num; 115d752f0f6SLuiz Otavio O Souza char *name; 116d752f0f6SLuiz Otavio O Souza}; 117d752f0f6SLuiz Otavio O Souza 118d752f0f6SLuiz Otavio O Souza# 119d752f0f6SLuiz Otavio O Souza# Set the pin name 120d752f0f6SLuiz Otavio O Souza# 121d752f0f6SLuiz Otavio O SouzaMETHOD int pin_setname { 122d752f0f6SLuiz Otavio O Souza device_t dev; 123d752f0f6SLuiz Otavio O Souza uint32_t pin_num; 124d752f0f6SLuiz Otavio O Souza const char *name; 125d752f0f6SLuiz Otavio O Souza}; 126