1285009Sbr/* $NetBSD: voyagervar.h,v 1.7 2020/04/16 23:29:53 rin Exp $ */ 2285009Sbr 3285009Sbr/* 4285009Sbr * Copyright (c) 2011 Michael Lorenz 5285009Sbr * All rights reserved. 6285009Sbr * 7285009Sbr * Redistribution and use in source and binary forms, with or without 8285009Sbr * modification, are permitted provided that the following conditions 9285009Sbr * are met: 10285009Sbr * 1. Redistributions of source code must retain the above copyright 11285009Sbr * notice, this list of conditions and the following disclaimer. 12285009Sbr * 2. Redistributions in binary form must reproduce the above copyright 13285009Sbr * notice, this list of conditions and the following disclaimer in the 14285009Sbr * documentation and/or other materials provided with the distribution. 15285009Sbr * 16285009Sbr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17285009Sbr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18285009Sbr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19285009Sbr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20285009Sbr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21285009Sbr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22285009Sbr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23285009Sbr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24285009Sbr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25285009Sbr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26285009Sbr */ 27285009Sbr 28285009Sbr#include <sys/cdefs.h> 29285009Sbr__KERNEL_RCSID(0, "$NetBSD: voyagervar.h,v 1.7 2020/04/16 23:29:53 rin Exp $"); 30285009Sbr 31285009Sbr#ifndef VOYAGERVAR_H 32285009Sbr#define VOYAGERVAR_H 33285009Sbr 34285009Sbr#include <dev/pci/pcivar.h> 35285009Sbr#include <dev/pci/pcireg.h> 36285009Sbr 37285009Sbrstruct voyager_attach_args { 38285009Sbr pci_chipset_tag_t vaa_pc; 39285009Sbr pcitag_t vaa_pcitag; 40285009Sbr bus_space_tag_t vaa_tag; 41285009Sbr bus_space_handle_t vaa_regh; 42285009Sbr bus_space_handle_t vaa_memh; 43285009Sbr bus_addr_t vaa_reg_pa; 44285009Sbr bus_addr_t vaa_mem_pa; 45285009Sbr char vaa_name[32]; 46285009Sbr}; 47285009Sbr 48285009Sbrvoid voyager_twiddle_bits(void *, int, uint32_t, uint32_t); 49285009Sbr 50285009Sbr/* set gpio bits - (register & param1) | param2 */ 51285009Sbr#define voyager_write_gpio(cookie, m_and, m_or) \ 52298171Smarkj voyager_twiddle_bits(cookie, SM502_GPIO_DATA0, m_and, m_or) 53285009Sbr/* control gpio pin usage - 0 is gpio, 1 is other stuff ( like PWM ) */ 54285009Sbr#define voyager_control_gpio(cookie, m_and, m_or) \ 55285009Sbr voyager_twiddle_bits(cookie, SM502_GPIO0_CONTROL, m_and, m_or) 56285009Sbr/* gpio direction - 1 is output */ 57298171Smarkj#define voyager_gpio_dir(cookie, m_and, m_or) \ 58285009Sbr voyager_twiddle_bits(cookie, SM502_GPIO_DIR0, m_and, m_or) 59285009Sbr#define voyager_control_power_0(cookie, m_and, m_or) \ 60285009Sbr voyager_twiddle_bits(cookie, SM502_POWER_MODE0_GATE, m_and, m_or) 61285009Sbr 62285009Sbrvoid *voyager_establish_intr(device_t, int, int (*)(void *), void *); 63285009Sbrvoid voyager_disestablish_intr(device_t, void *); 64298171Smarkj 65285009Sbr/* frequency in Hz, duty cycle in 1000ths */ 66285009Sbruint32_t voyager_set_pwm(int, int); 67285009Sbr 68285009Sbr#endif 69285009Sbr