1 /* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at 9 * http://www.illumos.org/license/CDDL. 10 */ 11 12 /* 13 * Copyright 2022 Oxide Computer Company 14 */ 15 16 #ifndef _SYS_GPIO_GPIO_SIM_H 17 #define _SYS_GPIO_GPIO_SIM_H 18 19 /* 20 * GPIO Simulator Driver attribute definitions. 21 * 22 * This driver is purely synthetic, it exists for testing. 23 */ 24 25 #ifdef __cplusplus 26 extern "C" { 27 #endif 28 29 /* 30 * KGPIO_ATTR_NAME -- ro 31 * string 32 * 33 * This contains the GPIO's name. These names are semantic things that we use to 34 * make understanding testing easier. 35 */ 36 37 /* 38 * GPIO_SIM_ATTR_OUTPUT -- rw 39 * uint32_t -- gpio_sim_output_t 40 * 41 * GPIO_SIM_ATTR_INPUT -- ro 42 * uint32_t -- gpio_sim_input_t 43 * 44 * This pair allows you to set the GPIO's output and then see what the input 45 * value is. 46 */ 47 #define GPIO_SIM_ATTR_OUTPUT "sim:output" 48 typedef enum { 49 GPIO_SIM_OUTPUT_DISABLED, 50 GPIO_SIM_OUTPUT_LOW, 51 GPIO_SIM_OUTPUT_HIGH 52 } gpio_sim_output_t; 53 54 #define GPIO_SIM_ATTR_INPUT "sim:input" 55 typedef enum { 56 GPIO_SIM_INPUT_LOW, 57 GPIO_SIM_INPUT_HIGH 58 } gpio_sim_input_t; 59 60 /* 61 * To make this somewhat usable, we define an additional three properties that 62 * are used to describe information about a GPIO. 63 * 64 * GPIO_SIM_ATTR_PULL -- rw 65 * uint32_t -- gpio_sim_pull_t 66 * 67 * This is a synthetic version of the pull-up/down control. 68 * 69 * GPIO_SIM_ATTR_VOLTAGE -- ro 70 * uint32_t -- gpio_sim_voltage_t 71 * 72 * This is a synthetic read-only value that we use as part of our testing. 73 * 74 * GPIO_SIM_ATTR_SPEED -- rw 75 * uint32_t -- gpio_sim_speed_t 76 * 77 * This would control something like the various rise times exist on a GPIO and 78 * is an homage to the fact that everyone wants to set the fastest, but 79 * generally you actually want the slowest! 80 */ 81 #define GPIO_SIM_ATTR_PULL "sim:pull" 82 typedef enum { 83 GPIO_SIM_PULL_DISABLED, 84 GPIO_SIM_PULL_DOWN, 85 GPIO_SIM_PULL_DOWN_23K, 86 GPIO_SIM_PULL_UP, 87 GPIO_SIM_PULL_UP_5K, 88 GPIO_SIM_PULL_UP_40K, 89 GPIO_SIM_PULL_BOTH 90 } gpio_sim_pull_t; 91 92 #define GPIO_SIM_ATTR_VOLTAGE "sim:voltage" 93 typedef enum { 94 GPIO_SIM_VOLTAGE_1P8, 95 GPIO_SIM_VOLTAGE_3P3, 96 GPIO_SIM_VOLTAGE_12P0, 97 GPIO_SIM_VOLTAGE_54P5 98 } gpio_sim_voltage_t; 99 100 #define GPIO_SIM_ATTR_SPEED "sim:speed" 101 typedef enum { 102 GPIO_SIM_SPEED_LOW, 103 GPIO_SIM_SPEED_MEDIUM, 104 GPIO_SIM_SPEED_HIGH, 105 GPIO_SIM_SPEED_VERY_HIGH 106 } gpio_sim_speed_t; 107 108 #ifdef __cplusplus 109 } 110 #endif 111 112 #endif /* _SYS_GPIO_GPIO_SIM_H */ 113