1 1.1 brad /* $NetBSD: sc16is7xxvar.h,v 1.1 2025/10/24 23:16:11 brad Exp $ */ 2 1.1 brad 3 1.1 brad /* 4 1.1 brad * Copyright (c) 2025 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.1 brad #ifndef _DEV_IC_SC16IS7XXVAR_H_ 20 1.1 brad #define _DEV_IC_SC16IS7XXVAR_H_ 21 1.1 brad 22 1.1 brad #include <sys/tty.h> 23 1.1 brad #include <sys/bus.h> 24 1.1 brad #include <sys/pool.h> 25 1.1 brad 26 1.1 brad #include <sys/gpio.h> 27 1.1 brad #include <dev/gpio/gpiovar.h> 28 1.1 brad 29 1.1 brad #include <dev/ic/comreg.h> 30 1.1 brad #include <dev/ic/comvar.h> /* for com_regs */ 31 1.1 brad 32 1.1 brad #ifndef SC16IS7XX_DEFAULT_FREQUENCY 33 1.1 brad #define SC16IS7XX_DEFAULT_FREQUENCY 14745600 34 1.1 brad #endif 35 1.1 brad 36 1.1 brad #ifndef SC16IS7XX_DEFAULT_POLL 37 1.1 brad #define SC16IS7XX_DEFAULT_POLL 50 38 1.1 brad #endif 39 1.1 brad 40 1.1 brad #define SC16IS7XX_NPINS 8 41 1.1 brad 42 1.1 brad #define SC16IS7XX_TYPE_STRINGLEN 40 43 1.1 brad 44 1.1 brad struct sc16is7xx_sc; 45 1.1 brad 46 1.1 brad struct sc16is7xx_accessfuncs { 47 1.1 brad int (*read_reg)(struct sc16is7xx_sc *, uint8_t, int, uint8_t *, 48 1.1 brad size_t); 49 1.1 brad int (*write_reg)(struct sc16is7xx_sc *, uint8_t, int, uint8_t *, 50 1.1 brad size_t); 51 1.1 brad void (*copy_handles)(struct sc16is7xx_sc *, struct com_regs *); 52 1.1 brad uint8_t(*com_read_1)(struct com_regs *, u_int); 53 1.1 brad void (*com_write_1)(struct com_regs *, u_int, uint8_t); 54 1.1 brad void (*com_write_multi_1)(struct com_regs *, u_int, const uint8_t *, bus_size_t); 55 1.1 brad }; 56 1.1 brad 57 1.1 brad struct sc16is7xx_sc { 58 1.1 brad device_t sc_dev; 59 1.1 brad struct sysctllog *sc_sc16is7xx_log; 60 1.1 brad 61 1.1 brad int sc_num_channels; 62 1.1 brad 63 1.1 brad const struct sc16is7xx_accessfuncs *sc_funcs; 64 1.1 brad const struct sc16is7xx_accessfuncs *sc_com_funcs; 65 1.1 brad 66 1.1 brad device_t sc_ttydevchannel[2]; 67 1.1 brad device_t sc_gpio_dev; 68 1.1 brad struct gpio_chipset_tag sc_gpio_gc; 69 1.1 brad gpio_pin_t sc_gpio_pins[SC16IS7XX_NPINS]; 70 1.1 brad 71 1.1 brad int sc_frequency; 72 1.1 brad 73 1.1 brad bool sc_thread_run; 74 1.1 brad struct lwp *sc_thread; 75 1.1 brad int sc_poll; 76 1.1 brad 77 1.1 brad int sc_phandle; 78 1.1 brad struct workqueue *sc_wq; 79 1.1 brad pool_cache_t sc_wk_pool; 80 1.1 brad void *sc_ih; 81 1.1 brad void *sc_sih; 82 1.1 brad }; 83 1.1 brad 84 1.1 brad extern const struct device_compatible_entry sc16is7xx_compat_data[]; 85 1.1 brad 86 1.1 brad struct sc16is7xx_tty_attach_args { 87 1.1 brad int aa_channel; 88 1.1 brad }; 89 1.1 brad 90 1.1 brad void sc16is7xx_attach(struct sc16is7xx_sc *); 91 1.1 brad int sc16is7xx_detach(struct sc16is7xx_sc *, int); 92 1.1 brad 93 1.1 brad #endif 94