&i2c0 {
status = "okay";
tsc2007: tsc2007@48 {
compatible = "ti,tsc2007";
reg = <0x48>;
gpios = ;
ti,x-plate-ohms = <500>;
status = "okay";
};
rtc@51 {
compatible = "nxp,pcf8563";
reg = <0x51>;
};
};
tsc2007_core.c:
/*
* drivers/input/touchscreen/tsc2007.c
*
* Copyright (c) 2008 MtekVision Co., Ltd.
*Kwangwoo Lee
*
* Using code from:
* - ads7846.c
*Copyright (c) 2005 David Brownell
*Copyright (c) 2006 Nokia Corporation
* - corgi_ts.c
*Copyright (C) 2004-2005 Richard Purdie
* - omap_ts.[hc], ads7846.h, ts_osk.c
*Copyright (C) 2002 MontaVista Software
*Copyright (C) 2004 Texas Instruments
*Copyright (C) 2005 Dirk Behme
*
* 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.
*/
#include
#include
#include
#include
#include
#include "tsc2007.h"
#include
#include
#include
#include
#define TSC2007_MEASURE_TEMP0(0x0 << 4)
#define TSC2007_MEASURE_AUX(0x2 << 4)
#define TSC2007_MEASURE_TEMP1(0x4 << 4)
#define TSC2007_ACTIVATE_XN(0x8 << 4)
#define TSC2007_ACTIVATE_YN(0x9 << 4)
#define TSC2007_ACTIVATE_YP_XN(0xa << 4)
#define TSC2007_SETUP(0xb << 4)
#define TSC2007_MEASURE_X(0xc << 4)
#define TSC2007_MEASURE_Y(0xd << 4)
#define TSC2007_MEASURE_Z1(0xe << 4)
#define TSC2007_MEASURE_Z2(0xf << 4)
#define TSC2007_POWER_OFF_IRQ_EN(0x0 << 2)
#define TSC2007_ADC_ON_IRQ_DIS0(0x1 << 2)
#define TSC2007_ADC_OFF_IRQ_EN(0x2 << 2)
#define TSC2007_ADC_ON_IRQ_DIS1(0x3 << 2)
#define TSC2007_12BIT(0x0 << 1)
#define TSC2007_8BIT(0x1 << 1)
#defineMAX_12BIT((1 << 12) - 1)
#define ADC_ON_12BIT(TSC2007_12BIT | TSC2007_ADC_ON_IRQ_DIS0)
#define READ_Y(ADC_ON_12BIT | TSC2007_MEASURE_Y)
#define READ_Z1(ADC_ON_12BIT | TSC2007_MEASURE_Z1)
#define READ_Z2(ADC_ON_12BIT | TSC2007_MEASURE_Z2)
#define READ_X(ADC_ON_12BIT | TSC2007_MEASURE_X)
#define PWRDOWN(TSC2007_12BIT | TSC2007_POWER_OFF_IRQ_EN)
/*
* This define forces debug prints during development
*/
#define DEBUG_PRINT(1)
#if(DEBUG_PRINT == 1)
#define SR_DEBUGdev_err
#else
#define SR_DEBUGdev_dbg
#endif
static inline int tsc2007_xfer(struct tsc2007 *tsc, u8 cmd)
{
s32 data;
u16 val;
data = i2c_smbus_read_word_data(tsc->client, cmd);
if (data < 0) {
dev_err(&tsc->client->dev, "i2c io error: %d\n", data);
return data;
}
/* The protocol and raw data format from i2c interface:
* S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
* Where DataLow has [D11-D4], DataHigh has [D3-D0 << 4 | Dummy 4bit].
*/
val = swab16(data) >> 4;
dev_dbg(&tsc->client->dev, "data: 0x%x, val: 0x%x\n", data, val);
return val;
}
static void tsc2007_read_values(struct tsc2007 *tsc, struct ts_event *tc)
{
/* y- still on