]> oss.titaniummirror.com Git - cp210x.git/blobdiff - src/cp210x.h
Move userspace/kernel shared defs to cp210x.h; no new typedefs; other cleanups.
[cp210x.git] / src / cp210x.h
diff --git a/src/cp210x.h b/src/cp210x.h
new file mode 100644 (file)
index 0000000..9892464
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Silicon Laboratories CP210x USB to RS232 serial adaptor driver
+ *
+ * Copyright (C) 2005 Craig Shelley (craig@microtron.org.uk)
+ *
+ *     This program is free software; you can redistribute it and/or
+ *     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.
+ *
+ */
+
+#if !defined(CP210X_H)
+#define CP210X_H
+
+/* CP2103 GPIO ioctls */
+#define IOCTL_GPIOGET          0x8000  /* Get gpio bits */
+#define IOCTL_GPIOSET          0x8001  /* Set gpio bits */
+#define IOCTL_GPIOBIC          0x8002  /* Clear specific gpio bit(s) */
+#define IOCTL_GPIOBIS          0x8003  /* Set specific gpio bit(s) */
+
+/* CP210x ioctls principally used during initial device configuration */
+#define IOCTL_DEVICERESET      0x8004  /* Reset the cp210x */
+#define IOCTL_PORTCONFGET      0x8005  /* Get port configuration */
+#define IOCTL_PORTCONFSET      0x8006  /* Set port configuration */
+#define IOCTL_SETVID           0x8007  /* Set vendor id */
+#define IOCTL_SETPID           0x8008  /* Set product id */
+#define IOCTL_SETMFG           0x8009  /* Set manufacturer string */
+#define IOCTL_SETPRODUCT       0x800a  /* Set product string */
+#define IOCTL_SETSERIAL                0x800b  /* Set serial number string */
+#define IOCTL_SETDEVVER                0x800c  /* Set device version id */
+
+/* CP2103 GPIO bit positions */
+#define GPIO_0                 0x01
+#define GPIO_1                 0x02
+#define GPIO_2                 0x04
+#define GPIO_3                 0x08
+#define GPIO_MASK              (GPIO_0|GPIO_1|GPIO_2|GPIO_3)
+
+/* 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) */
+struct cp210x_buffer {
+       __u8 *buf;
+       __s32 len;
+} __attribute__((packed));
+
+/* Port config definitions */
+struct cp210x_port_state {
+       __u16 mode;             /* Push-pull = 1, Open-drain = 0 */
+       __u16 lowPower;
+       __u16 latch;            /* Logic high = 1, Logic low = 0 */
+} __attribute__((packed));
+
+struct cp210x_port_config {
+       struct cp210x_port_state reset;
+       struct cp210x_port_state suspend;
+       __u8 enhancedFxn;
+} __attribute__((packed));
+
+#endif /* CP210X_H */