X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=src%2Fcp210x.h;h=315e2039f9c7d8d1dc847fcfda6a6007900513e9;hb=62f7ab54a8973d9de7a76e79fed81347908505c4;hp=f3c96a801baa7a97e7221a227b549c1359fc4b3a;hpb=adcc360e576188af96b2dd22be2bed75e151d769;p=cp210x.git diff --git a/src/cp210x.h b/src/cp210x.h index f3c96a8..315e203 100644 --- a/src/cp210x.h +++ b/src/cp210x.h @@ -7,7 +7,7 @@ * modify it under the terms of the GNU General Public License version * 2 as published by the Free Software Foundation. * - * Definitions usable by both the cp210x kernel module and userspace. + * Header file shared by both the cp210x kernel module and userspace. * */ @@ -17,26 +17,25 @@ #if defined(__KERNEL__) #include #else -#include +#include #include #endif /* CP2103 GPIO ioctls */ -#define CP210x_IOCTL_GPIOGET (SIOCDEVPRIVATE + 0) /* Get gpio bits */ -#define CP210x_IOCTL_GPIOSET (SIOCDEVPRIVATE + 1) /* Set gpio bits */ -#define CP210x_IOCTL_GPIOBIC (SIOCDEVPRIVATE + 2) /* Clear specific gpio bit(s) */ -#define CP210x_IOCTL_GPIOBIS (SIOCDEVPRIVATE + 3) /* Set specific gpio bit(s) */ +#define CP210x_IOCTL_GPIOGET (SIOCDEVPRIVATE + 0) +#define CP210x_IOCTL_GPIOSET (SIOCDEVPRIVATE + 1) +#define CP210x_IOCTL_GPIOBIC (SIOCDEVPRIVATE + 2) +#define CP210x_IOCTL_GPIOBIS (SIOCDEVPRIVATE + 3) /* CP210x ioctls principally used during initial device configuration */ -#define CP210x_IOCTL_DEVICERESET (SIOCDEVPRIVATE + 4) /* Reset the cp210x */ -#define CP210x_IOCTL_PORTCONFGET (SIOCDEVPRIVATE + 5) /* Get port configuration */ -#define CP210x_IOCTL_PORTCONFSET (SIOCDEVPRIVATE + 6) /* Set port configuration */ -#define CP210x_IOCTL_SETVID (SIOCDEVPRIVATE + 7) /* Set vendor id */ -#define CP210x_IOCTL_SETPID (SIOCDEVPRIVATE + 8) /* Set product id */ -#define CP210x_IOCTL_SETMFG (SIOCDEVPRIVATE + 9) /* Set manufacturer string */ -#define CP210x_IOCTL_SETPRODUCT (SIOCDEVPRIVATE + 10) /* Set product string */ -#define CP210x_IOCTL_SETSERIAL (SIOCDEVPRIVATE + 11) /* Set serial number string */ -#define CP210x_IOCTL_SETDEVVER (SIOCDEVPRIVATE + 12) /* Set device version id */ +#define CP210x_IOCTL_DEVICERESET (SIOCDEVPRIVATE + 4) +#define CP210x_IOCTL_PORTCONFGET (SIOCDEVPRIVATE + 5) +#define CP210x_IOCTL_PORTCONFSET (SIOCDEVPRIVATE + 6) +#define CP210x_IOCTL_SETVID (SIOCDEVPRIVATE + 7) +#define CP210x_IOCTL_SETPID (SIOCDEVPRIVATE + 8) +#define CP210x_IOCTL_SETPRODUCT (SIOCDEVPRIVATE + 9) +#define CP210x_IOCTL_SETSERIAL (SIOCDEVPRIVATE + 10) +#define CP210x_IOCTL_SETDEVVER (SIOCDEVPRIVATE + 11) /* CP2103 GPIO bit positions */ #define GPIO_0 0x01 @@ -46,11 +45,83 @@ #define GPIO_MASK (GPIO_3|GPIO_2|GPIO_1|GPIO_0) /* USB descriptor sizes */ -#define CP210x_MAX_MFG_STRLEN 255 #define CP210x_MAX_PRODUCT_STRLEN 126 #define CP210x_MAX_SERIAL_STRLEN 63 -/* Used to pass variable sized buffers between user and kernel space (ioctls) */ +#if !defined(__KERNEL__) +/* Mode and latch bit to pin assignments. See AN223 from SiLabs: + * https://www.silabs.com/Support Documents/TechnicalDocs/an223.pdf + * + * 15 - /SUSPEND Can't configure latch + * 14 - SUSPEND Can't configure latch + * 13 - unused + * 12 - unused + * 11 - GPIO_3 + * 10 - GPIO_2 + * 9 - GPIO_1 + * 8 - GPIO_0 + * 7 - /CTS + * 6 - /RTS + * 5 - RXD Note: set latch value to '1' for proper operation. + * 4 - TXD + * 3 - /DSR + * 2 - /DTR + * 1 - /DCD + * 0 - /RI + * + * Mode bit values: + * 1 - A value of one in a bit places the corresponding IO pin in push- + * pull output mode. + * 0 - A value of zero in a bit places the corresponding IO pin in open- + * drain output mode. + * + * Latch bit values: + * 1 - A value of one in a bit sets the corresponding IO pin's value to + * output high. If the mode is push-pull, the pin sources current + * from VIO. If the mode is open-drain, the pin driver is in high + * impedance. + * 0 - A value of zero in a bit sets the corresponding IO pin's value to + * output low. In either mode, push-pull or open-drain, the pin + * driver sinks current to ground. + */ +#define CP210x_CFG_nSUSPEND 0x8000 +#define CP210x_CFG_SUSPEND 0x4000 +#define CP210x_CFG_UNUSED13 0x2000 +#define CP210x_CFG_UNUSED12 0x1000 +#define CP210x_CFG_GPIO_3 0x0800 +#define CP210x_CFG_GPIO_2 0x0400 +#define CP210x_CFG_GPIO_1 0x0200 +#define CP210x_CFG_GPIO_0 0x0100 +#define CP210x_CFG_nCTS 0x0080 +#define CP210x_CFG_nRTS 0x0040 +#define CP210x_CFG_RXD 0x0020 +#define CP210x_CFG_TXD 0x0010 +#define CP210x_CFG_nDSR 0x0008 +#define CP210x_CFG_nDTR 0x0004 +#define CP210x_CFG_nDCD 0x0002 +#define CP210x_CFG_nRI 0x0001 + +/* Enhanced function bits: + * 7 - GPIO dynamic suspend, for 4 GPIO signals + * 6 - Serial dynamic suspend, for 8 UART/Modem signals + * 5 - unused, leave zero + * 4 - Enable weak pull-ups + * 3 - unused, leave zero + * 2 - /RS485_TX on GPIO_2 + * 1 - /RXLED on GPIO_1 + * 0 - /TXLED on GPIO_0 +*/ +#define CP210x_ENH_GPIO_DYNSUSP 0x80 +#define CP210x_ENH_SERIAL_DYNSUSP 0x40 +#define CP210x_ENH_UNUSED5 0x20 +#define CP210x_ENH_PULLUPS 0x10 +#define CP210x_ENH_UNUSED3 0x08 +#define CP210x_ENH_nRS485_TX 0x04 +#define CP210x_ENH_nRXLED 0x02 +#define CP210x_ENH_nTXLED 0x01 +#endif /* __KERNEL__ */ + +/* Used to pass variable size buffers between user and kernel space (ioctls) */ struct cp210x_buffer { __u8 *buf; __s32 len;