1 1.6 rin /* $NetBSD: voyagervar.h,v 1.7 2020/04/16 23:29:53 rin Exp $ */ 2 1.1 macallan 3 1.1 macallan /* 4 1.2 macallan * Copyright (c) 2011 Michael Lorenz 5 1.1 macallan * All rights reserved. 6 1.1 macallan * 7 1.1 macallan * Redistribution and use in source and binary forms, with or without 8 1.1 macallan * modification, are permitted provided that the following conditions 9 1.1 macallan * are met: 10 1.1 macallan * 1. Redistributions of source code must retain the above copyright 11 1.1 macallan * notice, this list of conditions and the following disclaimer. 12 1.1 macallan * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 macallan * notice, this list of conditions and the following disclaimer in the 14 1.1 macallan * documentation and/or other materials provided with the distribution. 15 1.1 macallan * 16 1.1 macallan * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 1.1 macallan * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 1.1 macallan * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 1.1 macallan * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 1.1 macallan * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 1.1 macallan * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 1.1 macallan * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 1.1 macallan * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 1.1 macallan * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 1.1 macallan * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 1.1 macallan */ 27 1.1 macallan 28 1.7 rin #include <sys/cdefs.h> 29 1.7 rin __KERNEL_RCSID(0, "$NetBSD: voyagervar.h,v 1.7 2020/04/16 23:29:53 rin Exp $"); 30 1.7 rin 31 1.1 macallan #ifndef VOYAGERVAR_H 32 1.1 macallan #define VOYAGERVAR_H 33 1.1 macallan 34 1.3 macallan #include <dev/pci/pcivar.h> 35 1.3 macallan #include <dev/pci/pcireg.h> 36 1.3 macallan 37 1.1 macallan struct voyager_attach_args { 38 1.1 macallan pci_chipset_tag_t vaa_pc; 39 1.1 macallan pcitag_t vaa_pcitag; 40 1.1 macallan bus_space_tag_t vaa_tag; 41 1.1 macallan bus_space_handle_t vaa_regh; 42 1.1 macallan bus_space_handle_t vaa_memh; 43 1.1 macallan bus_addr_t vaa_reg_pa; 44 1.1 macallan bus_addr_t vaa_mem_pa; 45 1.1 macallan char vaa_name[32]; 46 1.1 macallan }; 47 1.1 macallan 48 1.4 macallan void voyager_twiddle_bits(void *, int, uint32_t, uint32_t); 49 1.4 macallan 50 1.3 macallan /* set gpio bits - (register & param1) | param2 */ 51 1.4 macallan #define voyager_write_gpio(cookie, m_and, m_or) \ 52 1.4 macallan voyager_twiddle_bits(cookie, SM502_GPIO_DATA0, m_and, m_or) 53 1.3 macallan /* control gpio pin usage - 0 is gpio, 1 is other stuff ( like PWM ) */ 54 1.4 macallan #define voyager_control_gpio(cookie, m_and, m_or) \ 55 1.4 macallan voyager_twiddle_bits(cookie, SM502_GPIO0_CONTROL, m_and, m_or) 56 1.4 macallan /* gpio direction - 1 is output */ 57 1.4 macallan #define voyager_gpio_dir(cookie, m_and, m_or) \ 58 1.4 macallan voyager_twiddle_bits(cookie, SM502_GPIO_DIR0, m_and, m_or) 59 1.4 macallan #define voyager_control_power_0(cookie, m_and, m_or) \ 60 1.4 macallan voyager_twiddle_bits(cookie, SM502_POWER_MODE0_GATE, m_and, m_or) 61 1.3 macallan 62 1.3 macallan void *voyager_establish_intr(device_t, int, int (*)(void *), void *); 63 1.3 macallan void voyager_disestablish_intr(device_t, void *); 64 1.3 macallan 65 1.3 macallan /* frequency in Hz, duty cycle in 1000ths */ 66 1.3 macallan uint32_t voyager_set_pwm(int, int); 67 1.2 macallan 68 1.5 christos #endif 69