1 /* 2 * Copyright (c) 2014 The DragonFly Project. All rights reserved. 3 * 4 * This code is derived from software contributed to The DragonFly Project 5 * by Matthew Dillon <dillon@backplane.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the 16 * distribution. 17 * 3. Neither the name of The DragonFly Project nor the names of its 18 * contributors may be used to endorse or promote products derived 19 * from this software without specific, prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ 34 35 #ifndef _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ 36 #define _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ 37 38 #define CYAPA_MAX_MT 5 39 40 /* 41 * Boot-time registers. This is the device map 42 * if (stat & CYAPA_STAT_RUNNING) is 0. 43 */ 44 struct cyapa_boot_regs { 45 uint8_t stat; /* CYAPA_STAT_xxx */ 46 uint8_t boot; /* CYAPA_BOOT_xxx */ 47 uint8_t error; 48 } __packed; 49 50 #define CYAPA_BOOT_BUSY 0x80 51 #define CYAPA_BOOT_RUNNING 0x10 52 #define CYAPA_BOOT_DATA_VALID 0x08 53 #define CYAPA_BOOT_CSUM_VALID 0x01 54 55 #define CYAPA_ERROR_INVALID 0x80 56 #define CYAPA_ERROR_INVALID_KEY 0x40 57 #define CYAPA_ERROR_BOOTLOADER 0x20 58 #define CYAPA_ERROR_CMD_CSUM 0x10 59 #define CYAPA_ERROR_FLASH_PROT 0x08 60 #define CYAPA_ERROR_FLASH_CSUM 0x04 61 62 struct cyapa_regs { 63 uint8_t stat; 64 uint8_t fngr; 65 66 struct { 67 uint8_t xy_high; /* 7:4 high 4 bits of x */ 68 uint8_t x_low; /* 3:0 high 4 bits of y */ 69 uint8_t y_low; 70 uint8_t pressure; 71 uint8_t id; /* 1-15 incremented each touch */ 72 } touch[CYAPA_MAX_MT]; 73 } __packed; 74 75 struct cyapa_cap { 76 uint8_t prod_ida[5]; /* 0x00 - 0x04 */ 77 uint8_t prod_idb[6]; /* 0x05 - 0x0A */ 78 uint8_t prod_idc[2]; /* 0x0B - 0x0C */ 79 uint8_t reserved[6]; /* 0x0D - 0x12 */ 80 uint8_t buttons; /* 0x13 */ 81 uint8_t gen; /* 0x14, low 4 bits */ 82 uint8_t max_abs_xy_high;/* 0x15 7:4 high x bits, 3:0 high y bits */ 83 uint8_t max_abs_x_low; /* 0x16 */ 84 uint8_t max_abs_y_low; /* 0x17 */ 85 uint8_t phy_siz_xy_high;/* 0x18 7:4 high x bits, 3:0 high y bits */ 86 uint8_t phy_siz_x_low; /* 0x19 */ 87 uint8_t phy_siz_y_low; /* 0x1A */ 88 } __packed; 89 90 #define CYAPA_STAT_RUNNING 0x80 91 #define CYAPA_STAT_PWR_MASK 0x0C 92 #define CYAPA_PWR_OFF 0x00 93 #define CYAPA_PWR_IDLE 0x08 94 #define CYAPA_PWR_ACTIVE 0x0C 95 96 #define CYAPA_STAT_DEV_MASK 0x03 97 #define CYAPA_DEV_NORMAL 0x03 98 #define CYAPA_DEV_BUSY 0x01 99 100 #define CYAPA_FNGR_DATA_VALID 0x08 101 #define CYAPA_FNGR_MIDDLE 0x04 102 #define CYAPA_FNGR_RIGHT 0x02 103 #define CYAPA_FNGR_LEFT 0x01 104 #define CYAPA_FNGR_NUMFINGERS(c) (((c) >> 4) & 0x0F) 105 106 #define CYAPA_TOUCH_X(regs, i) ((((regs)->touch[i].xy_high << 4) & 0x0F00) | \ 107 (regs)->touch[i].x_low) 108 #define CYAPA_TOUCH_Y(regs, i) ((((regs)->touch[i].xy_high << 8) & 0x0F00) | \ 109 (regs)->touch[i].y_low) 110 #define CYAPA_TOUCH_P(regs, i) ((regs)->touch[i].pressure) 111 112 #define CMD_BOOT_STATUS 0x00 /* only if in boot state */ 113 #define CMD_DEV_STATUS 0x00 /* only if in operational state */ 114 #define CMD_SOFT_RESET 0x28 115 #define CMD_POWER_MODE 0x29 116 #define CMD_POWER_MODE_OFF 0x00 117 #define CMD_POWER_MODE_IDLE 0x14 118 #define CMD_POWER_MODE_FULL 0xFC 119 #define CMD_QUERY_CAPABILITIES 0x2A 120 121 #endif 122