1285876Sgrembo/* 2285876Sgrembo * Copyright (c) 2014 The DragonFly Project. All rights reserved. 3285876Sgrembo * 4285876Sgrembo * This code is derived from software contributed to The DragonFly Project 5285876Sgrembo * by Matthew Dillon <dillon@backplane.com> and was subsequently ported 6285876Sgrembo * to FreeBSD by Michael Gmelin <freebsd@grem.de> 7285876Sgrembo * 8285876Sgrembo * Redistribution and use in source and binary forms, with or without 9285876Sgrembo * modification, are permitted provided that the following conditions 10285876Sgrembo * are met: 11285876Sgrembo * 12285876Sgrembo * 1. Redistributions of source code must retain the above copyright 13285876Sgrembo * notice, this list of conditions and the following disclaimer. 14285876Sgrembo * 2. Redistributions in binary form must reproduce the above copyright 15285876Sgrembo * notice, this list of conditions and the following disclaimer in 16285876Sgrembo * the documentation and/or other materials provided with the 17285876Sgrembo * distribution. 18285876Sgrembo * 3. Neither the name of The DragonFly Project nor the names of its 19285876Sgrembo * contributors may be used to endorse or promote products derived 20285876Sgrembo * from this software without specific, prior written permission. 21285876Sgrembo * 22285876Sgrembo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23285876Sgrembo * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24285876Sgrembo * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25285876Sgrembo * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26285876Sgrembo * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27285876Sgrembo * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 28285876Sgrembo * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29285876Sgrembo * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30285876Sgrembo * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 31285876Sgrembo * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 32285876Sgrembo * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33285876Sgrembo * SUCH DAMAGE. 34285876Sgrembo * 35285876Sgrembo * $FreeBSD: releng/11.0/sys/dev/cyapa/cyapa.h 285876 2015-07-25 18:14:35Z grembo $ 36285876Sgrembo */ 37285876Sgrembo 38285876Sgrembo#ifndef _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ 39285876Sgrembo#define _SYS_DEV_SMBUS_CYAPA_CYAPA_H_ 40285876Sgrembo 41285876Sgrembo#define CYAPA_MAX_MT 5 42285876Sgrembo 43285876Sgrembo/* 44285876Sgrembo * Boot-time registers. This is the device map 45285876Sgrembo * if (stat & CYAPA_STAT_RUNNING) is 0. 46285876Sgrembo */ 47285876Sgrembostruct cyapa_boot_regs { 48285876Sgrembo uint8_t stat; /* CYAPA_STAT_xxx */ 49285876Sgrembo uint8_t boot; /* CYAPA_BOOT_xxx */ 50285876Sgrembo uint8_t error; 51285876Sgrembo} __packed; 52285876Sgrembo 53285876Sgrembo#define CYAPA_BOOT_BUSY 0x80 54285876Sgrembo#define CYAPA_BOOT_RUNNING 0x10 55285876Sgrembo#define CYAPA_BOOT_DATA_VALID 0x08 56285876Sgrembo#define CYAPA_BOOT_CSUM_VALID 0x01 57285876Sgrembo 58285876Sgrembo#define CYAPA_ERROR_INVALID 0x80 59285876Sgrembo#define CYAPA_ERROR_INVALID_KEY 0x40 60285876Sgrembo#define CYAPA_ERROR_BOOTLOADER 0x20 61285876Sgrembo#define CYAPA_ERROR_CMD_CSUM 0x10 62285876Sgrembo#define CYAPA_ERROR_FLASH_PROT 0x08 63285876Sgrembo#define CYAPA_ERROR_FLASH_CSUM 0x04 64285876Sgrembo 65285876Sgrembostruct cyapa_regs { 66285876Sgrembo uint8_t stat; 67285876Sgrembo uint8_t fngr; 68285876Sgrembo 69285876Sgrembo struct { 70285876Sgrembo uint8_t xy_high; /* 7:4 high 4 bits of x */ 71285876Sgrembo uint8_t x_low; /* 3:0 high 4 bits of y */ 72285876Sgrembo uint8_t y_low; 73285876Sgrembo uint8_t pressure; 74285876Sgrembo uint8_t id; /* 1-15 incremented each touch */ 75285876Sgrembo } touch[CYAPA_MAX_MT]; 76285876Sgrembo} __packed; 77285876Sgrembo 78285876Sgrembostruct cyapa_cap { 79285876Sgrembo uint8_t prod_ida[5]; /* 0x00 - 0x04 */ 80285876Sgrembo uint8_t prod_idb[6]; /* 0x05 - 0x0A */ 81285876Sgrembo uint8_t prod_idc[2]; /* 0x0B - 0x0C */ 82285876Sgrembo uint8_t reserved[6]; /* 0x0D - 0x12 */ 83285876Sgrembo uint8_t buttons; /* 0x13 */ 84285876Sgrembo uint8_t gen; /* 0x14, low 4 bits */ 85285876Sgrembo uint8_t max_abs_xy_high;/* 0x15 7:4 high x bits, 3:0 high y bits */ 86285876Sgrembo uint8_t max_abs_x_low; /* 0x16 */ 87285876Sgrembo uint8_t max_abs_y_low; /* 0x17 */ 88285876Sgrembo uint8_t phy_siz_xy_high;/* 0x18 7:4 high x bits, 3:0 high y bits */ 89285876Sgrembo uint8_t phy_siz_x_low; /* 0x19 */ 90285876Sgrembo uint8_t phy_siz_y_low; /* 0x1A */ 91285876Sgrembo} __packed; 92285876Sgrembo 93285876Sgrembo#define CYAPA_STAT_RUNNING 0x80 94285876Sgrembo#define CYAPA_STAT_PWR_MASK 0x0C 95285876Sgrembo#define CYAPA_PWR_OFF 0x00 96285876Sgrembo#define CYAPA_PWR_IDLE 0x08 97285876Sgrembo#define CYAPA_PWR_ACTIVE 0x0C 98285876Sgrembo 99285876Sgrembo#define CYAPA_STAT_DEV_MASK 0x03 100285876Sgrembo#define CYAPA_DEV_NORMAL 0x03 101285876Sgrembo#define CYAPA_DEV_BUSY 0x01 102285876Sgrembo 103285876Sgrembo#define CYAPA_FNGR_DATA_VALID 0x08 104285876Sgrembo#define CYAPA_FNGR_MIDDLE 0x04 105285876Sgrembo#define CYAPA_FNGR_RIGHT 0x02 106285876Sgrembo#define CYAPA_FNGR_LEFT 0x01 107285876Sgrembo#define CYAPA_FNGR_NUMFINGERS(c) (((c) >> 4) & 0x0F) 108285876Sgrembo 109285876Sgrembo#define CYAPA_TOUCH_X(regs, i) ((((regs)->touch[i].xy_high << 4) & 0x0F00) | \ 110285876Sgrembo (regs)->touch[i].x_low) 111285876Sgrembo#define CYAPA_TOUCH_Y(regs, i) ((((regs)->touch[i].xy_high << 8) & 0x0F00) | \ 112285876Sgrembo (regs)->touch[i].y_low) 113285876Sgrembo#define CYAPA_TOUCH_P(regs, i) ((regs)->touch[i].pressure) 114285876Sgrembo 115285876Sgrembo#define CMD_BOOT_STATUS 0x00 /* only if in boot state */ 116285876Sgrembo#define CMD_DEV_STATUS 0x00 /* only if in operational state */ 117285876Sgrembo#define CMD_SOFT_RESET 0x28 118285876Sgrembo#define CMD_POWER_MODE 0x29 119285876Sgrembo#define CMD_POWER_MODE_OFF 0x00 120285876Sgrembo#define CMD_POWER_MODE_IDLE 0x14 121285876Sgrembo#define CMD_POWER_MODE_FULL 0xFC 122285876Sgrembo#define CMD_QUERY_CAPABILITIES 0x2A 123285876Sgrembo 124285876Sgrembo#endif 125