1*fd71220bSRobert Mustacchi /* 2*fd71220bSRobert Mustacchi * This file and its contents are supplied under the terms of the 3*fd71220bSRobert Mustacchi * Common Development and Distribution License ("CDDL"), version 1.0. 4*fd71220bSRobert Mustacchi * You may only use this file in accordance with the terms of version 5*fd71220bSRobert Mustacchi * 1.0 of the CDDL. 6*fd71220bSRobert Mustacchi * 7*fd71220bSRobert Mustacchi * A full copy of the text of the CDDL should have accompanied this 8*fd71220bSRobert Mustacchi * source. A copy of the CDDL is also available via the Internet at 9*fd71220bSRobert Mustacchi * http://www.illumos.org/license/CDDL. 10*fd71220bSRobert Mustacchi */ 11*fd71220bSRobert Mustacchi 12*fd71220bSRobert Mustacchi /* 13*fd71220bSRobert Mustacchi * Copyright 2022 Oxide Computer Company 14*fd71220bSRobert Mustacchi */ 15*fd71220bSRobert Mustacchi 16*fd71220bSRobert Mustacchi #ifndef _SYS_GPIO_KGPIO_ATTR_H 17*fd71220bSRobert Mustacchi #define _SYS_GPIO_KGPIO_ATTR_H 18*fd71220bSRobert Mustacchi 19*fd71220bSRobert Mustacchi /* 20*fd71220bSRobert Mustacchi * This file contains the shared definitions that are useful for understanding 21*fd71220bSRobert Mustacchi * attributes. This includes both the shared fields and required attributes as 22*fd71220bSRobert Mustacchi * well as more advanced error codes related to attributes. 23*fd71220bSRobert Mustacchi */ 24*fd71220bSRobert Mustacchi 25*fd71220bSRobert Mustacchi #ifdef __cplusplus 26*fd71220bSRobert Mustacchi extern "C" { 27*fd71220bSRobert Mustacchi #endif 28*fd71220bSRobert Mustacchi 29*fd71220bSRobert Mustacchi /* 30*fd71220bSRobert Mustacchi * GPIOs themselves are made up of several attributes that are communicated as 31*fd71220bSRobert Mustacchi * an nvlist_t. While most attributes are determined by the provider and are 32*fd71220bSRobert Mustacchi * required to be prefixed as such, a few are standardized across everything. 33*fd71220bSRobert Mustacchi * 34*fd71220bSRobert Mustacchi * Note: At this time, the possible information only allows for fully enumerated 35*fd71220bSRobert Mustacchi * lists of values. We should consider adding support for ranges ala mac. 36*fd71220bSRobert Mustacchi */ 37*fd71220bSRobert Mustacchi #define KGPIO_ATTR_NAME "name" 38*fd71220bSRobert Mustacchi #define KGPIO_ATTR_META "metadata" 39*fd71220bSRobert Mustacchi #define KGPIO_ATTR_PROT "protection" 40*fd71220bSRobert Mustacchi #define KGPIO_ATTR_POS "possible" 41*fd71220bSRobert Mustacchi 42*fd71220bSRobert Mustacchi typedef enum { 43*fd71220bSRobert Mustacchi KGPIO_PROT_RO, 44*fd71220bSRobert Mustacchi KGPIO_PROT_RW 45*fd71220bSRobert Mustacchi } kgpio_prot_t; 46*fd71220bSRobert Mustacchi 47*fd71220bSRobert Mustacchi /* 48*fd71220bSRobert Mustacchi * When setting attributes, these are valid reasons that an attribute may be 49*fd71220bSRobert Mustacchi * invalid or not settable. 50*fd71220bSRobert Mustacchi */ 51*fd71220bSRobert Mustacchi typedef enum { 52*fd71220bSRobert Mustacchi /* 53*fd71220bSRobert Mustacchi * Actually, no problem. 54*fd71220bSRobert Mustacchi */ 55*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_OK, 56*fd71220bSRobert Mustacchi /* 57*fd71220bSRobert Mustacchi * Indicates that an attempt was made to set a read-only attribute. 58*fd71220bSRobert Mustacchi */ 59*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_ATTR_RO, 60*fd71220bSRobert Mustacchi /* 61*fd71220bSRobert Mustacchi * Indicates that the requested attribute was not known to the provider. 62*fd71220bSRobert Mustacchi */ 63*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_UNKNOWN_ATTR, 64*fd71220bSRobert Mustacchi /* 65*fd71220bSRobert Mustacchi * Indicates that the attributes type is not correct. 66*fd71220bSRobert Mustacchi */ 67*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_BAD_TYPE, 68*fd71220bSRobert Mustacchi /* 69*fd71220bSRobert Mustacchi * Indicates that the attribute's value was unknown to the provider. 70*fd71220bSRobert Mustacchi */ 71*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_UNKNOWN_VAL, 72*fd71220bSRobert Mustacchi /* 73*fd71220bSRobert Mustacchi * Indicates that while the provider knows this value, it is not valid 74*fd71220bSRobert Mustacchi * for this GPIO or for the GPIO in its current configuration (e.g. 75*fd71220bSRobert Mustacchi * asking for a high push-pull output for an open-drain pin). 76*fd71220bSRobert Mustacchi */ 77*fd71220bSRobert Mustacchi KGPIO_ATTR_ERR_CANT_APPLY_VAL 78*fd71220bSRobert Mustacchi } kgpio_attr_err_t; 79*fd71220bSRobert Mustacchi 80*fd71220bSRobert Mustacchi #ifdef __cplusplus 81*fd71220bSRobert Mustacchi } 82*fd71220bSRobert Mustacchi #endif 83*fd71220bSRobert Mustacchi 84*fd71220bSRobert Mustacchi #endif /* _SYS_GPIO_KGPIO_ATTR_H */ 85