1 1.2 riastrad /* $NetBSD: umcpmio_subr.h,v 1.2 2025/03/17 18:24:08 riastradh Exp $ */ 2 1.1 brad 3 1.1 brad /* 4 1.1 brad * Copyright (c) 2024 Brad Spencer <brad (at) anduin.eldar.org> 5 1.1 brad * 6 1.1 brad * Permission to use, copy, modify, and distribute this software for any 7 1.1 brad * purpose with or without fee is hereby granted, provided that the above 8 1.1 brad * copyright notice and this permission notice appear in all copies. 9 1.1 brad * 10 1.1 brad * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 1.1 brad * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 1.1 brad * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 1.1 brad * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 1.1 brad * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 1.1 brad * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 1.1 brad * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 1.1 brad */ 18 1.1 brad 19 1.2 riastrad #ifndef _UMCPMIO_SUBR_H_ 20 1.2 riastrad #define _UMCPMIO_SUBR_H_ 21 1.1 brad 22 1.2 riastrad #include <sys/types.h> 23 1.1 brad 24 1.1 brad #include <dev/usb/umcpmio.h> 25 1.1 brad #include <dev/usb/umcpmio_hid_reports.h> 26 1.1 brad 27 1.1 brad struct umcpmio_mapping_put { 28 1.1 brad const char *tname; 29 1.1 brad const uint8_t mask; 30 1.1 brad }; 31 1.1 brad 32 1.2 riastrad int umcpmio_get_status(struct umcpmio_softc *, struct mcp2221_status_res *, 33 1.2 riastrad bool); 34 1.2 riastrad void umcpmio_set_i2c_speed(struct mcp2221_status_req *, int); 35 1.1 brad int umcpmio_set_i2c_speed_one(struct umcpmio_softc *, int, bool); 36 1.2 riastrad int umcpmio_put_status(struct umcpmio_softc *, struct mcp2221_status_req *, 37 1.2 riastrad struct mcp2221_status_res *, bool); 38 1.2 riastrad int umcpmio_get_sram(struct umcpmio_softc *, struct mcp2221_get_sram_res *, 39 1.2 riastrad bool); 40 1.2 riastrad int umcpmio_put_sram(struct umcpmio_softc *, struct mcp2221_set_sram_req *, 41 1.2 riastrad struct mcp2221_set_sram_res *, bool); 42 1.1 brad uint32_t umcpmio_sram_gpio_to_flags(uint8_t); 43 1.1 brad void umcpmio_set_gpio_value_sram(struct mcp2221_set_sram_req *, int, bool); 44 1.1 brad void umcpmio_set_gpio_dir_sram(struct mcp2221_set_sram_req *, int, int); 45 1.2 riastrad void umcpmio_set_gpio_designation_sram(struct mcp2221_set_sram_req *, int, 46 1.2 riastrad int); 47 1.1 brad void umcpmio_set_gpio_irq_sram(struct mcp2221_set_sram_req *, int); 48 1.1 brad void umcpmio_set_dac_vref(struct mcp2221_set_sram_req *, char *); 49 1.1 brad int umcpmio_set_dac_vref_one(struct umcpmio_softc *, char *, bool); 50 1.1 brad void umcpmio_set_dac_value(struct mcp2221_set_sram_req *, uint8_t); 51 1.1 brad int umcpmio_set_dac_value_one(struct umcpmio_softc *, uint8_t, bool); 52 1.1 brad void umcpmio_set_adc_vref(struct mcp2221_set_sram_req *, char *); 53 1.1 brad int umcpmio_set_adc_vref_one(struct umcpmio_softc *, char *, bool); 54 1.1 brad void umcpmio_set_gpioclock_dc(struct mcp2221_set_sram_req *, char *); 55 1.1 brad int umcpmio_set_gpioclock_dc_one(struct umcpmio_softc *, char *, bool); 56 1.1 brad void umcpmio_set_gpioclock_cd(struct mcp2221_set_sram_req *, char *); 57 1.1 brad int umcpmio_set_gpioclock_cd_one(struct umcpmio_softc *, char *, bool); 58 1.2 riastrad int umcpmio_get_gpio_cfg(struct umcpmio_softc *, 59 1.2 riastrad struct mcp2221_get_gpio_cfg_res *, bool); 60 1.2 riastrad int umcpmio_put_gpio_cfg(struct umcpmio_softc *, 61 1.2 riastrad struct mcp2221_set_gpio_cfg_req *, struct mcp2221_set_gpio_cfg_res *, 62 1.2 riastrad bool); 63 1.1 brad int umcpmio_get_gpio_value(struct umcpmio_softc *, int, bool); 64 1.1 brad void umcpmio_set_gpio_value(struct mcp2221_set_gpio_cfg_req *, int, bool); 65 1.1 brad int umcpmio_set_gpio_value_one(struct umcpmio_softc *, int, bool, bool); 66 1.2 riastrad int umcpmio_get_flash(struct umcpmio_softc *, uint8_t, 67 1.2 riastrad struct mcp2221_get_flash_res *, bool); 68 1.2 riastrad int umcpmio_put_flash(struct umcpmio_softc *, struct mcp2221_put_flash_req *, 69 1.2 riastrad struct mcp2221_put_flash_res *, bool); 70 1.1 brad 71 1.2 riastrad #endif /* _UMCPMIO_SUBR_H_ */ 72