Commit latest Qisda version and Bookeen's modification
This commit is contained in:
@@ -29,6 +29,16 @@ MODULE_LICENSE("GPL");
|
||||
|
||||
#define INPUT_DEVICES 256
|
||||
|
||||
/* Aaron, 20090122, add for CPU sleep prevention */
|
||||
/* prevent cpu from sleep when any event happens */
|
||||
#ifdef CONFIG_PM_PLATFORM_POWER_SAVING
|
||||
#define CPU_SLEEP_PREVENT
|
||||
#endif
|
||||
|
||||
#ifdef CPU_SLEEP_PREVENT
|
||||
extern unsigned int g_wakeup_event_occurs;
|
||||
#endif
|
||||
|
||||
static LIST_HEAD(input_dev_list);
|
||||
static LIST_HEAD(input_handler_list);
|
||||
|
||||
@@ -50,6 +60,10 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in
|
||||
|
||||
if (type > EV_MAX || !test_bit(type, dev->evbit))
|
||||
return;
|
||||
|
||||
#ifdef CPU_SLEEP_PREVENT
|
||||
g_wakeup_event_occurs = 1;
|
||||
#endif
|
||||
|
||||
add_input_randomness(type, code, value);
|
||||
|
||||
|
||||
@@ -229,6 +229,13 @@ config KEYBOARD_GPIO
|
||||
To compile this driver as a module, choose M here: the
|
||||
module will be called gpio-keys.
|
||||
|
||||
config CYBOOK_CYIO
|
||||
tristate "Cybook CyIO"
|
||||
# depends on MACH_CYBOOK_ORIZON
|
||||
default y
|
||||
help
|
||||
Say Y.
|
||||
|
||||
config KEYPAD_S3C
|
||||
tristate "S3C keypad support"
|
||||
depends on (CPU_S3C6400 || CPU_S3C6410)
|
||||
@@ -248,10 +255,4 @@ config KEYPAD_S3C_QISDA
|
||||
tony.yc.huang@qisda.com
|
||||
#Qisda Tony 090324, add keypad ]
|
||||
|
||||
config CYBOOK_CYIO
|
||||
tristate "CYBOOK buttons"
|
||||
default y
|
||||
help
|
||||
To compile this driver as a module, choose M here.
|
||||
|
||||
endif
|
||||
|
||||
@@ -23,4 +23,4 @@ obj-$(CONFIG_KEYPAD_S3C) += s3c-keypad.o
|
||||
#Qisda Tony 090324, add keypad [
|
||||
obj-$(CONFIG_KEYPAD_S3C_QISDA) += s3c-keypad-qisda.o
|
||||
#Qisda Tony 090324, add keypad ]
|
||||
obj-$(CONFIG_CYIO) += cyio.o
|
||||
obj-$(CONFIG_CYBOOK_CYIO) += cyio.o
|
||||
|
||||
@@ -12,21 +12,24 @@
|
||||
#include <linux/delay.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pm.h>
|
||||
#include <linux/proc_fs.h>
|
||||
|
||||
|
||||
#include <cybook.h>
|
||||
|
||||
#include "cyio.h"
|
||||
#include <linux/cyio.h>
|
||||
|
||||
//#define CYIO_TIMER
|
||||
#define CYIO_REPEAT
|
||||
#define CYIO_TIMER
|
||||
//#define CYIO_REPEAT
|
||||
//#define CYIO_POLLING
|
||||
|
||||
#define CYIO_ALTERNATE_KEY
|
||||
//#define CYIO_ALTERNATE_KEY
|
||||
|
||||
#define DEBUG_MESSAGES
|
||||
#define DBG_IRQ
|
||||
//#define DEBUG_MESSAGES
|
||||
//#define DBG_IRQ
|
||||
|
||||
#include <asm/hardware.h>
|
||||
#include <asm/delay.h>
|
||||
#include <asm/delay.h>
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm-arm/irq.h>
|
||||
#include <asm/arch/gpio.h>
|
||||
@@ -43,17 +46,38 @@ spinlock_t io_lock = SPIN_LOCK_UNLOCKED;
|
||||
static unsigned long io_status = 0;
|
||||
struct task_struct *ptsk = 0;
|
||||
|
||||
unsigned int platform_type = CYBOOK_GEN4;
|
||||
#ifdef CYIO_POLLING
|
||||
#define GPROCFS_ROOTFOLDER "cybook"
|
||||
#define GPROCFS_MODULEFOLDER "gsensor"
|
||||
#define GPROCFS_CALIBFILE "calibration"
|
||||
#define GPROCFS_IOFILE "io"
|
||||
#define GPROCFS_STATUSFILE "status"
|
||||
#define GPROCFS_AXISFILE "axis"
|
||||
#define GPROCFS_THDXFILE "thdx"
|
||||
#define GPROCFS_THDYFILE "thdy"
|
||||
#define GPROCFS_DIRECTIONFILE "direction"
|
||||
#define GPROCFS_DEBUGFILE "debug"
|
||||
|
||||
unsigned long tiltRotation;
|
||||
static struct proc_dir_entry *rootDir, *ioProcEntry;
|
||||
#endif
|
||||
|
||||
#ifdef CYIO_TIMER
|
||||
#define IO_TIMER_DELAY_1 ((HZ * 1) / 2) /* 500 ms */
|
||||
#define IO_TIMER_DELAY_2 ((HZ * 2) / 1) /* 2 s */
|
||||
#define IO_TIMER_DELAY_3 ((HZ * 1) / 1) /* 1 s */
|
||||
static struct timer_list io_timer;
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
static struct timer_list io_btn_timer;
|
||||
#endif
|
||||
|
||||
static int timer_inited = 0;
|
||||
static int timer_run = 0;
|
||||
#endif
|
||||
|
||||
static volatile int CyIO_Running = 0;
|
||||
|
||||
#define TRUE (1==1)
|
||||
#define FALSE (0==1)
|
||||
|
||||
@@ -72,14 +96,26 @@ typedef struct _cyIrq_
|
||||
char* sName;
|
||||
} cyIrq;
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
typedef struct _cyPoll_
|
||||
{
|
||||
u32 nGpio;
|
||||
u8 oldState;
|
||||
u8 nCodeActive;
|
||||
u8 nCodeInactive;
|
||||
char *sName;
|
||||
} cyPoll;
|
||||
#endif
|
||||
|
||||
typedef struct _cyEvent_
|
||||
{
|
||||
u8 nCode;
|
||||
u8 nKeyEvent;
|
||||
u8 bValid;
|
||||
void* pNext;
|
||||
} cyEvent;
|
||||
|
||||
static cyEvent s_nEvents[10];
|
||||
static cyEvent s_nEvents[20];
|
||||
static int s_nEventMax = sizeof(s_nEvents)/sizeof(s_nEvents[0]);
|
||||
static int s_nEventCnt = 0;
|
||||
static int s_nKeyLogMax = 1;
|
||||
@@ -119,31 +155,48 @@ static u8 s_altKeyPresent = FALSE; /* By default we don't have a Alt Key */
|
||||
#define GPIO_G8 S3C2410_GPG8
|
||||
#define GPIO_G9 S3C2410_GPG9
|
||||
|
||||
|
||||
#define GPIO_D10 S3C2410_GPD10
|
||||
#define GPIO_D11 S3C2410_GPD11
|
||||
#define GPIO_D14 S3C2410_GPD14
|
||||
|
||||
#define GPIO_H4 S3C2410_GPH4
|
||||
#define GPIO_H5 S3C2410_GPH5
|
||||
|
||||
static cyIrq *s_nIrq ;
|
||||
static int nCnt;
|
||||
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
static int nPCnt;
|
||||
static cyPoll *s_nPio;
|
||||
#endif
|
||||
|
||||
static cyIrq s_nIrq_GEN4[] =
|
||||
{ /* Event structure for the Cybook Gen3 (2440) */
|
||||
/* IRQ GPIO A B C Depress Event Release Event Alt Event Name Number */
|
||||
{ IRQ_EINT0, GPIO_F0, 0, 1, 0, CYEVENT_KEY_OFF, 0, 0, "PowerBtn" } //0
|
||||
//, { IRQ_EINT1, GPIO_F1, 0, 0, 0, CYEVENT_SD_IN, CYEVENT_SD_OUT, 0, "SD Card" } //1
|
||||
//, { IRQ_EINT2, GPIO_F2, 0, 0, 0, CYEVENT_TP_PRESS, CYEVENT_TP_REL, 0, "Touch Panel" } //2
|
||||
//
|
||||
/* EINT3 is not Wifi EINT */
|
||||
/* EINT4 is Headphone plug status */
|
||||
/* EINT5 is Touchpanel Enable */
|
||||
/* EINT6 is charger status */
|
||||
, { IRQ_EINT7, GPIO_F7, 0, 1, 0, CYEVENT_KEY_LEFT, 0, 0, "Left" } //3
|
||||
/* INT8 is Power Keey???? */
|
||||
//, { IRQ_EINT9, GPIO_G1, 0, 0, 0, CYEVENT_USB_IN, CYEVENT_USB_OUT, 0, "USB" } //4
|
||||
/* EINT10 is SD power enable */
|
||||
, { IRQ_EINT15, GPIO_G7, 0, 1, 0, CYEVENT_KEY_RIGHT, 0, 0, "Right" } //5
|
||||
/* IRQ GPIO A B C Depress Event Release Event Alt Event Name Number */
|
||||
/* A:Reserved (must be 0) - B: Is Keypress Event? (or Allow Repeat?) (1: Yes, 0: No) - C: Is Alt Key? (1: Yes 0: No) */
|
||||
, { IRQ_EINT7, GPIO_F7, 0, 1, 0, CYEVENT_KEY_DOWN, 0, 0, "Down" } //1
|
||||
, { IRQ_EINT15, GPIO_G7, 0, 1, 0, CYEVENT_KEY_UP, 0, 0, "Up" } //2
|
||||
, { IRQ_EINT8, GPIO_G0, 0, 1, 0, CYEVENT_KEY_LEFT, 0, 0, "Left" } //3
|
||||
, { IRQ_EINT10, GPIO_G2, 0, 1, 0, CYEVENT_KEY_RIGHT, 0, 0, "Right" } //4
|
||||
, { IRQ_EINT14, GPIO_G6, 0, 1, 0, CYEVENT_KEY_ENTER, 0, 0, "Center" } //5
|
||||
, { IRQ_EINT9, GPIO_G1, 0, 0, 0, CYEVENT_USB_OUT, CYEVENT_USB_IN, 0, "USB" } //6
|
||||
/* IRQ GPIO A B C Depress Event Release Event Alt Event Name Number */
|
||||
/* A:Reserved (must be 0) - B: Is Keypress Event? (or Allow Repeat?) (1: Yes, 0: No) - C: Is Alt Key? (1: Yes 0: No) */
|
||||
};
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
static cyPoll s_nPoll_GEN4[] =
|
||||
{
|
||||
/* GPIO, Must 0 Depress Event, Release Event Name */
|
||||
// { GPIO_H4, 0, CYEVENT_KEY_LEFT, 0, "Left" }
|
||||
//, { GPIO_H5, 0, CYEVENT_KEY_RIGHT, 0, "Right" }
|
||||
//, { GPIO_D14, 0, CYEVENT_KEY_ENTER, 0, "Enter" }
|
||||
/* GPIO, Must 0 Depress Event, Release Event, Name */
|
||||
};
|
||||
#endif
|
||||
|
||||
static u8* s_pbUsbPowered = NULL;
|
||||
static u8* s_pbAcPowered = NULL;
|
||||
static u8* s_pbPowerOff = NULL;
|
||||
static u8* s_pbVolMinus = NULL;
|
||||
|
||||
@@ -151,6 +204,16 @@ static irqreturn_t io_interrupt(int irq, void *dev_id);
|
||||
|
||||
#ifdef CYIO_TIMER
|
||||
static void io_timer_handler(unsigned long nData);
|
||||
#ifdef CYIO_POLLING
|
||||
static void io_btn_timer_handler(unsigned long nData);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
static int procReadIo (char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data);
|
||||
static int procWriteIo (struct file *file, const char *buffer,
|
||||
unsigned long count, void *data);
|
||||
#endif
|
||||
|
||||
#undef MSG
|
||||
@@ -159,8 +222,8 @@ static void io_timer_handler(unsigned long nData);
|
||||
#define MSG(str) { printk(KERN_ALERT str "\n"); }
|
||||
#define DBG(str, ...) { printk(KERN_ALERT str "\n", __VA_ARGS__); }
|
||||
#else
|
||||
#define MSG(str)
|
||||
#define DBG(str, ...)
|
||||
#define MSG(str)
|
||||
#define DBG(str, ...)
|
||||
#endif
|
||||
|
||||
//#define DEBUG_SPINLOCK
|
||||
@@ -186,35 +249,50 @@ static void io_timer_handler(unsigned long nData);
|
||||
#endif
|
||||
|
||||
/* Allow other modules/driver to push cyio event */
|
||||
void Cyio_PushEvent(char eventId, char unique)
|
||||
int Cyio_PushEvent(char eventId, char unique)
|
||||
{
|
||||
cyEvent *pEventC;
|
||||
|
||||
spinLock(&io_lock);
|
||||
int ret = 0;
|
||||
|
||||
spinLock(&io_lock);
|
||||
|
||||
/* CyIO is not running, ie no one take it, so don't accept events */
|
||||
if (CyIO_Running == 0)
|
||||
{
|
||||
spinUnlock(&io_lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unique != 0)
|
||||
{
|
||||
pEventC = s_pEventR;
|
||||
do
|
||||
{
|
||||
if (pEventC->nCode == eventId)
|
||||
goto exit;
|
||||
pEventC = pEventC->pNext;
|
||||
if (pEventC->nCode == eventId)
|
||||
{
|
||||
ret = -EEXIST;
|
||||
goto exit;
|
||||
}
|
||||
pEventC = pEventC->pNext;
|
||||
} while ((pEventC != s_pEventW) && (s_pEventR != s_pEventW));
|
||||
}
|
||||
DBG("New Pushed event '%c'\n", eventId);
|
||||
DBG("New Pushed event '%c'\n", eventId>8);
|
||||
|
||||
if (s_pEventW)
|
||||
{
|
||||
++s_nEventCnt;
|
||||
s_pEventW->nCode = eventId;
|
||||
s_pEventW->nCode = eventId;
|
||||
s_pEventW->nKeyEvent = 0;
|
||||
s_pEventW->bValid = 1;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
spinUnlock(&io_lock);
|
||||
|
||||
ret = 0;
|
||||
exit:
|
||||
if (ptsk)
|
||||
wake_up_process(ptsk);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(Cyio_PushEvent);
|
||||
|
||||
@@ -223,9 +301,9 @@ EXPORT_SYMBOL(Cyio_PushEvent);
|
||||
void Cyio_ResetTimer(void)
|
||||
{
|
||||
if (timer_inited == 0)
|
||||
return;
|
||||
return;
|
||||
if (timer_run == 0)
|
||||
return;
|
||||
return;
|
||||
#ifndef ALTERNATE_TIMER_CHANGE
|
||||
del_timer(&io_timer);
|
||||
if (io_timer.data == CYEVENT_SUSPEND_SCREEN)
|
||||
@@ -260,6 +338,7 @@ void io_initEventList(void)
|
||||
cyEvent* pEvent = &s_nEvents[i];
|
||||
pEvent->nCode = 0;
|
||||
pEvent->nKeyEvent = 0;
|
||||
pEvent->bValid = 0;
|
||||
if (s_pEventR)
|
||||
s_pEventR->pNext = pEvent;
|
||||
s_pEventR = pEvent;
|
||||
@@ -289,8 +368,28 @@ void io_initIrq(void)
|
||||
int i;
|
||||
cyIrq *pIrq, *pIrq0;
|
||||
int ret;
|
||||
#ifdef CYIO_POLLING
|
||||
cyPoll *pPoll, *pPoll0;
|
||||
pPoll0 = &s_nPio[0];
|
||||
#endif
|
||||
pIrq0 = &s_nIrq[0];
|
||||
|
||||
|
||||
DBG(">>%s()\n", __func__);
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
tiltRotation = 90;
|
||||
for (i=0, pPoll=pPoll0; i<nPCnt; ++i, ++pPoll)
|
||||
{
|
||||
s3c2410_gpio_cfgpin(pPoll->nGpio, 0);
|
||||
s3c2410_gpio_pullup(pPoll->nGpio, 0);
|
||||
}
|
||||
|
||||
s3c2410_gpio_cfgpin(GPIO_D10, 0);
|
||||
s3c2410_gpio_pullup(GPIO_D10, 0);
|
||||
s3c2410_gpio_cfgpin(GPIO_D11, 0);
|
||||
s3c2410_gpio_pullup(GPIO_D11, 0);
|
||||
#endif
|
||||
// Read state as fast as possible (important when resuming)
|
||||
for (i=0, pIrq=pIrq0; i<nCnt; ++i, ++pIrq)
|
||||
{
|
||||
@@ -311,8 +410,8 @@ void io_initIrq(void)
|
||||
switch (pIrq->nCodeActive)
|
||||
{
|
||||
case CYEVENT_USB_IN:
|
||||
case CYEVENT_USB_OUT:
|
||||
s_pbUsbPowered = &pIrq->bActive;
|
||||
s_pbAcPowered = &pIrq->bActive;
|
||||
break;
|
||||
case CYEVENT_AC_IN:
|
||||
break;
|
||||
@@ -326,9 +425,9 @@ void io_initIrq(void)
|
||||
#ifdef CYIO_ALTERNATE_KEY
|
||||
if (pIrq->bIsAltKey)
|
||||
{ /* If this event is configured as the Alt key, just fill the needed variables */
|
||||
DBG("Found Alt key as '%s'\n", pIrq->sName);
|
||||
s_altKeyPresent = TRUE;
|
||||
s_altKeyGpio = pIrq->nGpio;
|
||||
DBG("Found Alt key as '%s'\n", pIrq->sName);
|
||||
s_altKeyPresent = TRUE;
|
||||
s_altKeyGpio = pIrq->nGpio;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -342,6 +441,7 @@ void io_initIrq(void)
|
||||
++s_nKeyLogCnt;
|
||||
s_pEventW->nCode = CYEVENT_FACTORY_OFF;
|
||||
s_pEventW->nKeyEvent = 1;
|
||||
s_pEventW->bValid = 0;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
spinUnlock(&io_lock);
|
||||
@@ -361,7 +461,7 @@ void io_initIrq(void)
|
||||
// !!! BUGBUG (we might miss system events once a key event is queued)
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (s_pEventW)
|
||||
{
|
||||
++s_nEventCnt;
|
||||
@@ -369,6 +469,7 @@ void io_initIrq(void)
|
||||
++s_nKeyLogCnt;
|
||||
s_pEventW->nCode = pIrq->bActive ? pIrq->nCodeActive : pIrq->nCodeInactive;
|
||||
s_pEventW->nKeyEvent = pIrq->bKeyIrq;
|
||||
s_pEventW->bValid = 0;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
}
|
||||
@@ -379,9 +480,13 @@ void io_initIrq(void)
|
||||
{
|
||||
int nIrq = pIrq->nIrq;
|
||||
set_irq_type(nIrq, IRQT_BOTHEDGE);
|
||||
|
||||
|
||||
/* Set no Pullup and no Pulldown */
|
||||
s3c2410_gpio_pullup(pIrq->nGpio, 0);
|
||||
|
||||
DBG(".. io_initIrq [%s][%c] bActive[%d]", pIrq->sName, pIrq->bActive || !pIrq->nCodeInactive ? (char)pIrq->nCodeActive : (char)pIrq->nCodeInactive, pIrq->bActive);
|
||||
ret = request_irq(nIrq, io_interrupt, SA_INTERRUPT|SA_SHIRQ, "cyio", pIrq);
|
||||
ret = request_irq(nIrq, io_interrupt, SA_INTERRUPT|SA_SHIRQ, pIrq->sName, pIrq);
|
||||
enable_irq_wake(nIrq);
|
||||
if (ret != 0)
|
||||
{
|
||||
printk(KERN_ERR PFX "Error registering IRQ %d [%s]!\n", nIrq, pIrq->sName);
|
||||
@@ -393,7 +498,16 @@ void io_initIrq(void)
|
||||
timer_inited = 1;
|
||||
io_timer.function = io_timer_handler;
|
||||
io_timer.data = CYEVENT_SUSPEND_SCREEN;
|
||||
#ifdef CYIO_POLLING
|
||||
init_timer(&io_btn_timer);
|
||||
io_btn_timer.function = io_btn_timer_handler;
|
||||
io_btn_timer.expires = jiffies + HZ/8;
|
||||
add_timer(&io_btn_timer);
|
||||
#endif
|
||||
#endif
|
||||
spinLock(&io_lock);
|
||||
CyIO_Running = 1;
|
||||
spinUnlock(&io_lock);
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
void io_deinitIrq(void)
|
||||
@@ -401,18 +515,27 @@ void io_deinitIrq(void)
|
||||
int i;
|
||||
cyIrq *pIrq, *pIrq0;
|
||||
|
||||
spinLock(&io_lock);
|
||||
CyIO_Running = 0;
|
||||
spinUnlock(&io_lock);
|
||||
|
||||
#ifdef CYIO_TIMER
|
||||
del_timer(&io_timer);
|
||||
timer_run = 0;
|
||||
# ifdef CYIO_POLLING
|
||||
del_timer(&io_btn_timer);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//nCnt = sizeof(s_nIrq)/sizeof(s_nIrq[0]);
|
||||
pIrq0 = &s_nIrq[0];
|
||||
for (i=0, pIrq=pIrq0; i<nCnt; ++i, ++pIrq)
|
||||
{
|
||||
disable_irq_wake(pIrq->nIrq);
|
||||
free_irq(pIrq->nIrq, pIrq);
|
||||
}
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
//#define DBG_IRQ
|
||||
static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
cyIrq* pIrq = (cyIrq*)dev_id;
|
||||
@@ -445,16 +568,22 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
return IRQ_HANDLED;
|
||||
|
||||
#ifdef DBG_IRQ
|
||||
#ifdef CYIO_ALTERNATE_KEY
|
||||
DBG(".. io_irq #%d [%s][%c] alt[%d:%d] bActive[%d]", s_nIrq_dbg, pIrq->sName, bActive || !pIrq->nCodeInactive ? (char)pIrq->nCodeActive : (char)pIrq->nCodeInactive, (s_altKeyPress && pIrq->bKeyIrq) ? pIrq->nCodeAlternate : (bActive ? pIrq->nCodeActive : pIrq->nCodeInactive), s_altKeyPress, bActive);
|
||||
#else
|
||||
DBG(".. io_irq #%d [%s][%c] bActive[%d]", s_nIrq_dbg, pIrq->sName, bActive || !pIrq->nCodeInactive ? (char)pIrq->nCodeActive : (char)pIrq->nCodeInactive, (bActive ? pIrq->nCodeActive : pIrq->nCodeInactive), bActive);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
blCodeActive = (s_altKeyPress && pIrq->bKeyIrq) ? pIrq->nCodeAlternate : (bActive ? pIrq->nCodeActive : pIrq->nCodeInactive);
|
||||
#ifdef CYIO_ALTERNATE_KEY
|
||||
blCodeActive = (s_altKeyPress && pIrq->bKeyIrq) ? pIrq->nCodeAlternate : (bActive ? pIrq->nCodeActive : pIrq->nCodeInactive);
|
||||
if (s_altKeyPresent)
|
||||
{
|
||||
s_altKeyPress = !gpio_get_value(s_altKeyGpio);
|
||||
DBG("alt status: %d", s_altKeyPress);
|
||||
DBG("alt status: %d", s_altKeyPress);
|
||||
}
|
||||
#else
|
||||
blCodeActive = bActive ? pIrq->nCodeActive : pIrq->nCodeInactive;
|
||||
#endif
|
||||
|
||||
spinLock(&io_lock);
|
||||
@@ -475,13 +604,14 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
|
||||
if (s_bRepMode && !s_nPrevKey)
|
||||
{
|
||||
MSG("Exit repeat mode...");
|
||||
MSG("Exit repeat mode...");
|
||||
s_bRepMode = 0;
|
||||
if (s_pEventW)
|
||||
{ // NB: This is considered as a system event
|
||||
++s_nEventCnt;
|
||||
s_pEventW->nCode = CYEVENT_KEY_REPEAT_END;
|
||||
s_pEventW->nKeyEvent = 0;
|
||||
s_pEventW->bValid = 0;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
if (ptsk)
|
||||
@@ -520,6 +650,7 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
++s_nKeyLogCnt;
|
||||
s_pEventW->nCode = CYEVENT_FACTORY_OFF;
|
||||
s_pEventW->nKeyEvent = 1;
|
||||
s_pEventW->bValid = 0;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
spinUnlock(&io_lock);
|
||||
@@ -537,7 +668,7 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
}
|
||||
|
||||
#ifdef CYIO_ALTERNATE_KEY
|
||||
|
||||
|
||||
if (s_altKeyPresent && bAltKeyUsed && !s_altKeyPress && (pIrq->nGpio == s_altKeyGpio))
|
||||
{ /* If the released key is the Alt Key and it was used as the Alt Key, do not send an event */
|
||||
MSG("Alt Key released... Do Nothing");
|
||||
@@ -550,19 +681,19 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
{ /* If the altKey is pressed, we have to do a little trick: Inverse it's active state */
|
||||
MSG("Alt key event...");
|
||||
/* To be sure */
|
||||
s_nPrevKey = 0;
|
||||
s_nPrevKey = 0;
|
||||
s_bRepMode = 0;
|
||||
|
||||
bActive = !bActive;
|
||||
bActive = !bActive;
|
||||
}
|
||||
else if (s_altKeyPresent && s_altKeyPress && pIrq->bKeyIrq)
|
||||
{/* The event is a keypress and the AltKey is pressed, set our internal value to prevent Alt to send an event */
|
||||
MSG("Button press with Alt...");
|
||||
if (pIrq->nCodeAlternate != 0)
|
||||
bAltKeyUsed = TRUE;
|
||||
if (pIrq->nCodeAlternate != 0)
|
||||
bAltKeyUsed = TRUE;
|
||||
}
|
||||
MSG("Hum...");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (s_pEventW)
|
||||
{
|
||||
@@ -578,7 +709,8 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
#endif
|
||||
|
||||
s_pEventW->nKeyEvent = pIrq->bKeyIrq;
|
||||
|
||||
s_pEventW->bValid = 0;
|
||||
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
spinUnlock(&io_lock);
|
||||
@@ -593,23 +725,88 @@ static irqreturn_t io_interrupt(int irq, void *dev_id)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
#ifdef CYIO_TIMER
|
||||
#ifdef CYIO_POLLING
|
||||
static void io_btn_timer_handler(unsigned long nData)
|
||||
{
|
||||
/* read buttons */
|
||||
cyPoll *pPoll, *pPoll0;
|
||||
int i;
|
||||
int curState;
|
||||
int currentTilt, tE1, tE2;
|
||||
pPoll0 = &s_nPio[0];
|
||||
|
||||
DBG(">>%s()\n", __func__);
|
||||
|
||||
for (i=0, pPoll=pPoll0; i<nPCnt; ++i, ++pPoll)
|
||||
{
|
||||
curState = !gpio_get_value(pPoll->nGpio);
|
||||
DBG("|| Btn '%s' [current: %d, old: %d, gpio: %d]\n", pPoll->sName, curState, pPoll->oldState, pPoll->nGpio);
|
||||
/* If button found pressed, then push event 'bout them */
|
||||
if (pPoll->oldState != curState)
|
||||
{
|
||||
if (curState != 0)
|
||||
Cyio_PushEvent(pPoll->nCodeActive, 1);
|
||||
/*else
|
||||
Cyio_PushEvent(CYEVENT_KEY_REPEAT_END, 1);*/
|
||||
}
|
||||
else if (pPoll->oldState != 0)
|
||||
{
|
||||
/* Push event with repeat flag */
|
||||
//Cyio_PushEvent(pPoll->nCodeActive | CYEVENT_KEY_REPEAT_FLAG, 1);
|
||||
}
|
||||
|
||||
pPoll->oldState = curState;
|
||||
|
||||
}
|
||||
|
||||
/* special case, look at the tilt sensor */
|
||||
tE1 = !gpio_get_value(GPIO_D11);
|
||||
tE2 = !gpio_get_value(GPIO_D10);
|
||||
currentTilt = 0;
|
||||
if (!tE2)
|
||||
currentTilt |= 1 << 1;
|
||||
if (!tE1)
|
||||
currentTilt |= 1 << 0;
|
||||
|
||||
switch(currentTilt)
|
||||
{
|
||||
case 0x00: /* 90 */
|
||||
currentTilt = 90;
|
||||
break;
|
||||
|
||||
case 0x01: /* 0 */
|
||||
currentTilt = 0;
|
||||
break;
|
||||
|
||||
case 0x02: /* 180 */
|
||||
currentTilt = 180;
|
||||
break;
|
||||
|
||||
case 0x03: /* 270 */
|
||||
currentTilt = 270;
|
||||
break;
|
||||
}
|
||||
if (currentTilt != tiltRotation)
|
||||
{ /* We move */
|
||||
tiltRotation = currentTilt;
|
||||
printk("New tilt: %d\n", tiltRotation);
|
||||
Cyio_PushEvent(CYEVENT_ORIENTATIONCHANGED, 1);
|
||||
}
|
||||
|
||||
/* Update the timer */
|
||||
io_btn_timer.expires = jiffies + HZ/8;
|
||||
mod_timer(&io_btn_timer, io_btn_timer.expires);
|
||||
DBG("<<%s()\n", __func__);
|
||||
}
|
||||
#endif
|
||||
static void io_timer_handler(unsigned long nData)
|
||||
{
|
||||
/* YEP inside */
|
||||
#if 0
|
||||
//#ifdef G_SENSOR
|
||||
if (hold_wakeup==1) {
|
||||
del_timer(&io_timer);
|
||||
goto end_timer;
|
||||
}
|
||||
#endif
|
||||
/* end YEP inside */
|
||||
DBG("Timer [%ld] tick...\n", nData);
|
||||
|
||||
spin_lock_irq(&io_lock);
|
||||
|
||||
del_timer(&io_timer);
|
||||
timer_run = 0;
|
||||
timer_run = 0;
|
||||
if (s_nEventCnt < s_nEventMax)
|
||||
{
|
||||
if (s_pEventW)
|
||||
@@ -617,6 +814,7 @@ static void io_timer_handler(unsigned long nData)
|
||||
++s_nEventCnt;
|
||||
s_pEventW->nCode = (u8)nData;
|
||||
s_pEventW->nKeyEvent = 0;
|
||||
s_pEventW->bValid = 0;
|
||||
s_pEventW = s_pEventW->pNext;
|
||||
}
|
||||
}
|
||||
@@ -625,7 +823,7 @@ static void io_timer_handler(unsigned long nData)
|
||||
|
||||
if (ptsk)
|
||||
wake_up_process(ptsk);
|
||||
//end_timer:
|
||||
//end_timer:
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -670,7 +868,7 @@ static int io_release(struct inode *inode, struct file *file)
|
||||
// Only initialize the list when registering the driver and when closing it
|
||||
// This allows for a quicker opening of the driver
|
||||
io_initEventList();
|
||||
|
||||
|
||||
spin_unlock_irq(&io_lock);
|
||||
|
||||
MSG("<< io_release");
|
||||
@@ -682,7 +880,7 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
int nBytes = sizeof(unsigned long);
|
||||
unsigned long nData;
|
||||
ssize_t nRes = 0;
|
||||
|
||||
u8 bDataValid = 0;
|
||||
if (count < sizeof(unsigned long))
|
||||
return -EINVAL;
|
||||
|
||||
@@ -694,6 +892,7 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
if (s_nEventCnt)
|
||||
{
|
||||
nData = s_pEventR->nCode;
|
||||
bDataValid = s_pEventR->bValid;
|
||||
s_pEventR->nCode = 0;
|
||||
--s_nEventCnt;
|
||||
if (s_pEventR->nKeyEvent)
|
||||
@@ -702,7 +901,6 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
#ifdef CYIO_REPEAT
|
||||
if (nData != CYEVENT_KEY_OFF)
|
||||
{
|
||||
DBG("(line %d)Set s_nPrevKey", __LINE__);
|
||||
s_nPrevKey = nData;
|
||||
s_bRepMode = 0;
|
||||
}
|
||||
@@ -716,31 +914,26 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
int i;
|
||||
cyIrq *pIrq, *pIrq0;
|
||||
|
||||
pIrq0 = &s_nIrq[0];
|
||||
MSG("Will test key...");
|
||||
pIrq0 = &s_nIrq[0];
|
||||
for (i=0, pIrq=pIrq0; i<nCnt; ++i, ++pIrq)
|
||||
{
|
||||
#ifdef CYIO_ALTERNATE_KEY
|
||||
if ((pIrq->nCodeActive != s_nPrevKey) && (pIrq->nCodeAlternate != s_nPrevKey))
|
||||
#else
|
||||
if (pIrq->nCodeActive != s_nPrevKey)
|
||||
if (pIrq->nCodeActive != s_nPrevKey)
|
||||
#endif
|
||||
{
|
||||
MSG("!CodeActive and Alt+!AltCode");
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
MSG("May clear prevkey");
|
||||
}
|
||||
|
||||
if (!pIrq->bActive || gpio_get_value(pIrq->nGpio))
|
||||
{
|
||||
DBG("(line %d)Set s_nPrevKey", __LINE__);
|
||||
{
|
||||
s_nPrevKey = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (s_nPrevKey)
|
||||
{
|
||||
MSG("Will Set Repeat flag...");
|
||||
nData = s_nPrevKey | CYEVENT_KEY_REPEAT_FLAG;
|
||||
s_bRepMode = 1;
|
||||
}
|
||||
@@ -748,7 +941,7 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
#endif
|
||||
spinUnlock(&io_lock);
|
||||
|
||||
if (nData != 0)
|
||||
if ((nData != 0) | (bDataValid == 1))
|
||||
{
|
||||
#ifdef CYIO_TIMER
|
||||
del_timer(&io_timer);
|
||||
@@ -758,8 +951,8 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef CYIO_TIMER
|
||||
if (s_pbUsbPowered && s_pbAcPowered && !(*s_pbUsbPowered) && !(*s_pbAcPowered))
|
||||
#ifdef CYIO_TIMER
|
||||
if (s_pbUsbPowered && (*s_pbUsbPowered))
|
||||
{
|
||||
del_timer(&io_timer);
|
||||
timer_run = 0;
|
||||
@@ -791,8 +984,8 @@ ssize_t io_read(struct file *file, char *buf, size_t count, loff_t *ppos)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nData)
|
||||
|
||||
if ((nData != 0) | (bDataValid == 1))
|
||||
{
|
||||
nRes = copy_to_user(buf,&nData,nBytes);
|
||||
if (!nRes)
|
||||
@@ -835,7 +1028,7 @@ static int io_remove(struct platform_device *dev)
|
||||
misc_deregister(&s_io_dev);
|
||||
return 0;
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
// --------------------------------------------------------------------------
|
||||
static int io_resume(struct platform_device *dev)
|
||||
{
|
||||
//cyIrq *pIrq;
|
||||
@@ -847,7 +1040,7 @@ static int io_resume(struct platform_device *dev)
|
||||
pIrq = &s_nIrq[13];
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
pIrq = &s_nIrq[11];
|
||||
}
|
||||
|
||||
@@ -855,8 +1048,8 @@ static int io_resume(struct platform_device *dev)
|
||||
|
||||
//MSG(">>Resume() .......bSdCd 0x%x\n",bSdCd);
|
||||
if (pIrq->bActive == bSdCd)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
|
||||
spinLock(&io_lock);
|
||||
pIrq->bActive = bSdCd;
|
||||
if (s_pEventW)
|
||||
@@ -870,7 +1063,7 @@ static int io_resume(struct platform_device *dev)
|
||||
if (ptsk)
|
||||
wake_up_process(ptsk);
|
||||
#endif
|
||||
|
||||
|
||||
MSG("<<Resume() .......\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -892,24 +1085,34 @@ static struct platform_driver cyio_driver =
|
||||
static int __init cyIo_init(void)
|
||||
{
|
||||
#if 0
|
||||
if(platform_type == CYBOOK_OPUS)
|
||||
{
|
||||
s_nIrq = s_nIrq_OPUS;
|
||||
nCnt = sizeof(s_nIrq_OPUS)/sizeof(s_nIrq_OPUS[0]);
|
||||
}
|
||||
else if (/* GEN3 && GEN3GOLD */
|
||||
{
|
||||
s_nIrq = s_nIrq_GEN3;
|
||||
nCnt = sizeof(s_nIrq_GEN3)/sizeof(s_nIrq_GEN3[0]);
|
||||
}
|
||||
if(platform_type == CYBOOK_OPUS)
|
||||
{
|
||||
s_nIrq = s_nIrq_OPUS;
|
||||
nCnt = sizeof(s_nIrq_OPUS)/sizeof(s_nIrq_OPUS[0]);
|
||||
}
|
||||
else if (/* GEN3 && GEN3GOLD */
|
||||
{
|
||||
s_nIrq = s_nIrq_GEN3;
|
||||
nCnt = sizeof(s_nIrq_GEN3)/sizeof(s_nIrq_GEN3[0]);
|
||||
}
|
||||
#endif
|
||||
s_nIrq = s_nIrq_GEN4;
|
||||
nCnt = sizeof(s_nIrq_GEN4)/sizeof(s_nIrq_GEN4[0]);
|
||||
|
||||
DBG("s_nEventMax:%d, s_nEventCnt:%d, s_nKeyLogMax:%d, s_nKeyLogCnt:%d",s_nEventMax,s_nEventCnt,s_nKeyLogMax,s_nKeyLogCnt);
|
||||
s_nIrq = s_nIrq_GEN4;
|
||||
#ifdef CYIO_POLLING
|
||||
s_nPio = s_nPoll_GEN4;
|
||||
nPCnt = sizeof(s_nPoll_GEN4)/sizeof(s_nPoll_GEN4[0]);
|
||||
#endif
|
||||
nCnt = sizeof(s_nIrq_GEN4)/sizeof(s_nIrq_GEN4[0]);
|
||||
|
||||
|
||||
/* end YEP inside */
|
||||
DBG("s_nEventMax:%d, s_nEventCnt:%d, s_nKeyLogMax:%d, s_nKeyLogCnt:%d",s_nEventMax,s_nEventCnt,s_nKeyLogMax,s_nKeyLogCnt);
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
rootDir = proc_mkdir(GPROCFS_MODULEFOLDER, proc_root_driver);
|
||||
ioProcEntry = create_proc_entry(GPROCFS_IOFILE, 0644, rootDir);
|
||||
ioProcEntry->read_proc = procReadIo;
|
||||
ioProcEntry->write_proc = procWriteIo;
|
||||
ioProcEntry->owner = THIS_MODULE;
|
||||
#endif
|
||||
|
||||
io_initEventList();
|
||||
|
||||
@@ -929,6 +1132,57 @@ static void __exit cyIo_exit(void)
|
||||
|
||||
//MSG("<< cyIo_exit");
|
||||
}
|
||||
|
||||
#ifdef CYIO_POLLING
|
||||
static int procReadIo (char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data)
|
||||
{
|
||||
int len;
|
||||
char tmp = 0;
|
||||
//printk("Read IO Tilt [%d]", tiltRotation);
|
||||
switch (tiltRotation)
|
||||
{
|
||||
case 270:
|
||||
tmp++;
|
||||
case 180:
|
||||
tmp++;
|
||||
case 90:
|
||||
tmp++;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
len = sprintf (page, "%02X", tmp);
|
||||
DBG("io readed value: %02X", tmp);
|
||||
return len;
|
||||
}
|
||||
|
||||
static int procWriteIo (struct file *file, const char *buffer,
|
||||
unsigned long count, void *data)
|
||||
{
|
||||
char cmd;
|
||||
/* in case of... */
|
||||
if ( count < 1 )
|
||||
return 0;
|
||||
|
||||
cmd = buffer[0];
|
||||
switch(cmd)
|
||||
{
|
||||
case G_SENSOR_CAL:
|
||||
case G_SENSOR_ON:
|
||||
case G_SENSOR_OFF:
|
||||
case 254:
|
||||
break;
|
||||
|
||||
default:
|
||||
printk(KERN_ERR "ProcIO: Unknown command '%c'\n",cmd);
|
||||
break;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
module_init(cyIo_init);
|
||||
module_exit(cyIo_exit);
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
// ===========================================================================
|
||||
// cyio.h
|
||||
// Copyright (C) 2008-2009 Bookeen - All rights reserved
|
||||
// ===========================================================================
|
||||
// Key events
|
||||
#define CYEVENT_KEY_ENTER 'e'
|
||||
#define CYEVENT_KEY_RIGHT 'r'
|
||||
#define CYEVENT_KEY_DOWN 'd'
|
||||
#define CYEVENT_KEY_LEFT 'l'
|
||||
#define CYEVENT_KEY_UP 'u'
|
||||
#define CYEVENT_KEY_F1 '1'
|
||||
#define CYEVENT_KEY_F2 '2'
|
||||
#define CYEVENT_KEY_F3 '3'
|
||||
#define CYEVENT_KEY_F4 '4'
|
||||
#define CYEVENT_KEY_OFF 'o'
|
||||
#define CYEVENT_KEY_VOLP '+'
|
||||
#define CYEVENT_KEY_VOLN '-'
|
||||
#define CYEVENT_KEY_REPEAT_FLAG 0x80
|
||||
#define CYEVENT_KEY_REPEAT_END '0'
|
||||
// Physical events
|
||||
#define CYEVENT_USB_IN 'p'
|
||||
#define CYEVENT_USB_OUT 'q'
|
||||
#define CYEVENT_AC_IN 'a'
|
||||
#define CYEVENT_AC_OUT 'b'
|
||||
#define CYEVENT_ACN_IN 'j'
|
||||
#define CYEVENT_ACN_OUT 'k'
|
||||
#define CYEVENT_SD_IN 's'
|
||||
#define CYEVENT_SD_OUT 't'
|
||||
#define CYEVENT_SDN_IN 'u'
|
||||
#define CYEVENT_SDN_OUT 'v'
|
||||
|
||||
// G-Sensor events
|
||||
#define CYEVENT_ORIENTATIONCHANGED 'O'
|
||||
#define CYEVENT_G_ROT000 'A'
|
||||
#define CYEVENT_G_ROT090 'B'
|
||||
#define CYEVENT_G_ROT180 'C'
|
||||
#define CYEVENT_G_ROT270 'D'
|
||||
#define CYEVENT_TOGGLE_GSENSOR 'G'
|
||||
|
||||
// Logical events
|
||||
// CYEVENT_KEY_OFF + CYEVENT_KEY_VOLN
|
||||
#define CYEVENT_FACTORY_OFF 'x'
|
||||
#define CYEVENT_SUSPEND_SCREEN 'y'
|
||||
#define CYEVENT_SUSPEND_DEVICE 'z'
|
||||
// ===========================================================================
|
||||
/* YEP inside */
|
||||
#define CYIO_KERNEL_2_6 1
|
||||
|
||||
#define G_SENSOR_ON '1'
|
||||
#define G_SENSOR_OFF '0'
|
||||
#define G_SENSOR_CAL 'C'
|
||||
|
||||
/* end YEP inside */
|
||||
enum
|
||||
{
|
||||
CYGSENSOR_STATUS_ENABLED = 0,
|
||||
CYGSENSOR_STATUS_DISABLED = 1,
|
||||
CYGSENSOR_STATUS_NOTCALIB = 2, /* Not calibrated, or invalid calibration data */
|
||||
CYGSENSOR_STATUS_CALIBRATED = 3, /* This status should never been read, but it could help to debug */
|
||||
CYGSENSOR_STATUS_UNKNOWN = 4, /* This status should not been read too, but it could help to debug */
|
||||
};
|
||||
|
||||
/* Exported function of CyIO */
|
||||
void Cyio_ResetTimer(void);
|
||||
void Cyio_PushEvent(char eventId, char unique);
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <asm/irq.h>
|
||||
|
||||
#include <asm/arch/regs-gpio.h>
|
||||
/*Qisda , wenny cheng , 20091224 , board id info {*/
|
||||
#include <../include/asm-arm/plat-s3c24xx/common-smdk.h>
|
||||
/*Qisda , wenny cheng , 20091224 , board id info }*/
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/08/18, Detect insertion source {*/
|
||||
#include <asm/arch/regs-udc-hs.h>
|
||||
#include <asm/arch/regs-s3c2416-clock.h>
|
||||
@@ -45,8 +49,24 @@
|
||||
#define QISDA_TILT_180 3
|
||||
#define QISDA_TILT_270 2
|
||||
|
||||
/*Qisda , wenny cheng , 20091224 , board id info {*/
|
||||
//static int hw_version_for_keypad = 0;
|
||||
extern int board_id;
|
||||
/*Qisda , wenny cheng , 20091224 , board id info }*/
|
||||
|
||||
extern int average_adc_value_keep1; /*joey add to keep ADC will always return lower one 2009/12/28*/
|
||||
extern int average_adc_value_keep2; /*joey add to keep ADC will always return lower one 2009/12/28*/
|
||||
|
||||
// Qisda, 2010/02/18, TN Wei, sleep mode wakes up for usb event {
|
||||
int sleeping_cha_event = 0;
|
||||
// Qisda, 2010/02/18, TN Wei, sleep mode wakes up for usb event }
|
||||
|
||||
/*Qisda , howard hsu, 20100116 , op_mode-delay key event {*/
|
||||
#define OP_MODE_DELAY_REQUEST KEY_F9
|
||||
/*} Qisda , howard hsu, 20100116 , op_mode-delay key event*/
|
||||
|
||||
#if defined(CONFIG_QISDA_AS090B00_EVT1) || defined(CONFIG_QISDA_AS090B00_EVT1_1)
|
||||
#define MAX_KEYPAD_QISDA 22
|
||||
#define MAX_KEYPAD_QISDA 23 /*shiyong joey for asus 2009/12/15*/
|
||||
static int keypad_keycode_qisda[] = {
|
||||
KEY_PAGEDOWN, KEY_PAGEUP, KEY_VOLUMEDOWN, KEY_VOLUMEUP,
|
||||
KEY_F1, KEY_F2, KEY_F3, KEY_INSERT, KEY_ESC,
|
||||
@@ -54,9 +74,8 @@ static int keypad_keycode_qisda[] = {
|
||||
KEY_CHA_STA_WALL_CHARGER, KEY_CHA_STA_UNPLUG,
|
||||
KEY_CHA_STA_USB, KEY_BATTERY_FAIL,
|
||||
KEY_SLEEP, KEY_TIMER_TICK,
|
||||
/* } Qisda, ShiYong Lin, 2009/09/08, Implement for message for AP */
|
||||
KEY_F4, KEY_F5, KEY_F6, KEY_F7, KEY_F8, KEY_SOUND,
|
||||
KEY_SD_INSERT
|
||||
KEY_SD_INSERT, KEY_BATTERY /*shiyong joey for asus 2009/12/15*/
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -65,9 +84,10 @@ static int keypad_keycode_qisda[] = {
|
||||
|
||||
#define QISDA_E600
|
||||
//#define QISDA_L600
|
||||
//#define QISDA_BQ060B00_DVT
|
||||
|
||||
|
||||
#define MAX_KEYPAD_QISDA 27
|
||||
#define MAX_KEYPAD_QISDA 29
|
||||
static int keypad_keycode_qisda[] = {
|
||||
KEY_MENU, KEY_SEARCH, KEY_PAGEDOWN, KEY_PAGEUP,
|
||||
KEY_BACK, KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_WAKEUP,
|
||||
@@ -78,14 +98,17 @@ static int keypad_keycode_qisda[] = {
|
||||
/* Qisda, ShiYong Lin, 2009/09/08, Implement for message for AP {*/
|
||||
KEY_CLOSE, KEY_CHA_STA_WALL_CHARGER, KEY_CHA_STA_UNPLUG,
|
||||
KEY_CHA_STA_USB, KEY_BATTERY_FAIL,
|
||||
KEY_SLEEP, KEY_TIMER_TICK
|
||||
KEY_SLEEP, KEY_TIMER_TICK, KEY_BATTERY,
|
||||
/* } Qisda, ShiYong Lin, 2009/09/08, Implement for message for AP */
|
||||
/*Qisda , howard hsu, 20100116 , op_mode-delay key event {*/
|
||||
KEY_F9
|
||||
/*} Qisda , howard hsu, 20100116 , op_mode-delay key event*/
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CONFIG_QISDA_QD090B00
|
||||
#define MAX_KEYPAD_QISDA 25
|
||||
#define MAX_KEYPAD_QISDA 27
|
||||
static int keypad_keycode_qisda[] = {
|
||||
KEY_MENU, KEY_SEARCH, KEY_PAGEDOWN, KEY_PAGEUP,
|
||||
KEY_BACK, KEY_VOLUMEDOWN, KEY_VOLUMEUP, KEY_WAKEUP,
|
||||
@@ -95,8 +118,11 @@ static int keypad_keycode_qisda[] = {
|
||||
/* Qisda, ShiYong Lin, 2009/09/08, Implement for message for AP {*/
|
||||
KEY_CLOSE, KEY_CHA_STA_WALL_CHARGER, KEY_CHA_STA_UNPLUG,
|
||||
KEY_CHA_STA_USB, KEY_BATTERY_FAIL,
|
||||
KEY_SLEEP, KEY_TIMER_TICK
|
||||
KEY_SLEEP, KEY_TIMER_TICK, KEY_BATTERY,
|
||||
/* } Qisda, ShiYong Lin, 2009/09/08, Implement for message for AP */
|
||||
/*Qisda , howard hsu, 20100116 , op_mode-delay key event {*/
|
||||
KEY_F9
|
||||
/*} Qisda , howard hsu, 20100116 , op_mode-delay key event*/
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -114,6 +140,9 @@ static int keypad_set_irq = FALSE;
|
||||
/* Qisda, ShiYong Lin, 2009/11/11, Fix the trembling voice issue when plugging usb {*/
|
||||
static struct timer_list charger_source_timer;
|
||||
/* } Qisda, ShiYong Lin, 2009/11/11, Fix the trembling voice issue when plugging usb */
|
||||
/*joey add timer to avoid bouncing with usb in/out 20100127*/
|
||||
static struct timer_list battery_status_timer;
|
||||
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/11/11, Modify for pwr fail event occurring wrongly when heavy loading {*/
|
||||
static struct timer_list power_fail_timer;
|
||||
@@ -157,16 +186,38 @@ static void keypad_port_initialize(void)
|
||||
|
||||
|
||||
#ifdef CONFIG_QISDA_QD090B00
|
||||
|
||||
/*Qisda , wenny cheng , 20091224 , board id info {*/
|
||||
// hw_version_for_keypad = readl(S3C2416_GPKDAT) & (0x3<<3);
|
||||
printk("\nhw_version_for_keypad: %d\n", board_id);
|
||||
|
||||
//if(hw_version_for_keypad){
|
||||
if(board_id != QD090B00_S02){
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPC3, S3C2410_GPC3_OUTP); // Tilt_EN
|
||||
s3c2410_gpio_setpin(S3C2410_GPC3, 1);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG2, S3C2410_GPG2_EINT10); // Search
|
||||
s3c2410_gpio_pullup(S3C2410_GPG2, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_EINT11); // Return
|
||||
s3c2410_gpio_pullup(S3C2410_GPG3, 2);
|
||||
|
||||
|
||||
}
|
||||
else{
|
||||
//old
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_INP); // Search
|
||||
s3c2410_gpio_pullup(S3C2410_GPD14, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD15, S3C2410_GPD15_INP); // Return
|
||||
s3c2410_gpio_pullup(S3C2410_GPD15, 2);
|
||||
}
|
||||
/*Qisda , wenny cheng , 20091224 , board id info }*/
|
||||
|
||||
//Set gpio as input and pull-up enable
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_INP); //T_SENSOR2
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD11, S3C2410_GPD11_INP); //T_SENSOR1
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_INP); // Search
|
||||
s3c2410_gpio_pullup(S3C2410_GPD14, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD15, S3C2410_GPD15_INP); // Return
|
||||
s3c2410_gpio_pullup(S3C2410_GPD15, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_EINT0); // power
|
||||
s3c2410_gpio_pullup(S3C2410_GPF0, 2);
|
||||
|
||||
@@ -191,31 +242,62 @@ static void keypad_port_initialize(void)
|
||||
|
||||
|
||||
#ifdef CONFIG_QISDA_QD060B00
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPC3, S3C2410_GPC3_OUTP); // Tilt_EN
|
||||
s3c2410_gpio_setpin(S3C2410_GPC3, 1);
|
||||
|
||||
#ifdef CONFIG_QISDA_BK060B00
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_INP); //T_SENSOR2
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_INP); //T_SENSOR1
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG6, S3C2410_GPG6_INP); // Menu / Plato: Menu
|
||||
s3c2410_gpio_pullup(S3C2410_GPG6, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG0, S3C2410_GPG0_INP); // VOL-/LEFT
|
||||
s3c2410_gpio_pullup(S3C2410_GPG0, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG2, S3C2410_GPG2_INP); // VOL+/RIGHT
|
||||
s3c2410_gpio_pullup(S3C2410_GPG2, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPH5, S3C2410_GPH5_OUTP); // USB_SEL: DEVICE ONLY
|
||||
s3c2410_gpio_setpin(S3C2410_GPH5, 0);
|
||||
#else
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_INP); //T_SENSOR2
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD11, S3C2410_GPD11_INP); //T_SENSOR1
|
||||
|
||||
//Set gpio as input and pull-up enable
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_INP); // Menu
|
||||
// Qisda Jonas disable for keypad rework 20100104
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_INP); // Menu / Plato: Menu
|
||||
s3c2410_gpio_pullup(S3C2410_GPD14, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD15, S3C2410_GPD15_INP); // Page down / Back
|
||||
s3c2410_gpio_pullup(S3C2410_GPD15, 2);
|
||||
// Qisda Jonas disable for keypad rework
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_EINT0); // power
|
||||
s3c2410_gpio_pullup(S3C2410_GPF0, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_INP); // Back / Right
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPH5, S3C2410_GPH5_INP); // Search / UP / Plato: Vol up
|
||||
s3c2410_gpio_pullup(S3C2410_GPH5, 2);
|
||||
|
||||
// Qisda Jonas modify for keypad rework 20100104
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_EINT11); // Menu key
|
||||
s3c2410_gpio_pullup(S3C2410_GPG3, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_EINT12); // Page up, Plato: Back
|
||||
s3c2410_gpio_pullup(S3C2410_GPG4, 2);
|
||||
// Qisda Jonas modify for keypad rework
|
||||
#endif
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD15, S3C2410_GPD15_INP); // Page down / Back / Plato: Back
|
||||
s3c2410_gpio_pullup(S3C2410_GPD15, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_EINT7); // Back / Right / Plato: Page down
|
||||
s3c2410_gpio_pullup(S3C2410_GPF7, 2);
|
||||
|
||||
#ifdef QISDA_E600
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_INP); // Page up
|
||||
s3c2410_gpio_pullup(S3C2410_GPG4, 2);
|
||||
#endif
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG6, S3C2410_GPG6_INP); // VOL / Down
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG6, S3C2410_GPG6_EINT14); // VOL / Down / Plato: Search
|
||||
s3c2410_gpio_pullup(S3C2410_GPG6, 2);
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG7, S3C2410_GPG7_INP); // Refresh / Left
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG7, S3C2410_GPG7_EINT15); // Refresh / Left / Plato: Page up
|
||||
s3c2410_gpio_pullup(S3C2410_GPG7, 2);
|
||||
|
||||
#ifdef QISDA_L600
|
||||
@@ -223,24 +305,30 @@ static void keypad_port_initialize(void)
|
||||
s3c2410_gpio_pullup(S3C2410_GPH4, 2);
|
||||
#endif
|
||||
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPH5, S3C2410_GPH5_INP); // Search / UP
|
||||
s3c2410_gpio_pullup(S3C2410_GPH5, 2);
|
||||
#ifdef CONFIG_QISDA_BQ060B00_DVT
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPH4, S3C2410_GPH4_INP); // Plato: Vol down
|
||||
s3c2410_gpio_pullup(S3C2410_GPH4, 2);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/08/27, Implement for message for AP {*/
|
||||
// Power_Fail, GPG5, need to open when EVT2
|
||||
// Both edge triggered
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG5, S3C2410_GPG5_EINT13);
|
||||
s3c2410_gpio_pullup(S3C2410_GPG5, 2);
|
||||
writel((readl(S3C2410_EXTINT1) & ~(1<<23)), S3C2410_EXTINT1); /* EINT13 filter enable */
|
||||
writel(((readl(S3C2410_EXTINT1) & ~(7<<20))|(6<<20)), S3C2410_EXTINT1);
|
||||
// CHG_STA, GPF6, Both edge triggered /*shiyong joey for asus 2009/12/15*/
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_EINT6);
|
||||
s3c2410_gpio_pullup(S3C2410_GPF6, 0); /*joey modify 2->0 20100127*/
|
||||
writel((readl(S3C2410_EXTINT0) & ~(1<<27)), S3C2410_EXTINT0);
|
||||
writel(((readl(S3C2410_EXTINT0) & ~(7<<24))|(4<<24)), S3C2410_EXTINT0); /*joey modify (6<<24) to (4<<24)) 20100127*/ /*1:high 4:rise 6:both*/
|
||||
|
||||
// CHG_STA, GPG1, need to open when EVT2,
|
||||
// Both edge triggered
|
||||
// VBUS_IN_STA, GPG1, Both edge triggered /*shiyong joey for asus 2009/12/15*/
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG1, S3C2410_GPG1_EINT9);
|
||||
s3c2410_gpio_pullup(S3C2410_GPG1, 0);
|
||||
writel((readl(S3C2410_EXTINT1) & ~(1<<7)), S3C2410_EXTINT1); /* EINT9 filter enable */
|
||||
writel(((readl(S3C2410_EXTINT1) & ~(7<<4))|(6<<4)), S3C2410_EXTINT1);
|
||||
|
||||
// Power_Fail, GPG5, Both edge triggered /*shiyong joey for asus 2009/12/15*/
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG5, S3C2410_GPG5_EINT13);
|
||||
s3c2410_gpio_pullup(S3C2410_GPG5, 2);
|
||||
writel((readl(S3C2410_EXTINT1) & ~(1<<23)), S3C2410_EXTINT1);
|
||||
writel(((readl(S3C2410_EXTINT1) & ~(7<<20))|(6<<20)), S3C2410_EXTINT1);
|
||||
}
|
||||
|
||||
struct s3c_keypad_qisda *pdata;
|
||||
@@ -271,8 +359,8 @@ int IsWallCharger(void)
|
||||
if((readl(S3C2410_GPGDAT)&0x2)==0x2){
|
||||
s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2443_GPH14, 1); /* usb power enbale */
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPD13_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2410_GPD13,1); /* usb power enbale */
|
||||
// s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPD13_OUTP);
|
||||
// s3c2410_gpio_setpin(S3C2410_GPD13,1); /* usb power enbale */
|
||||
|
||||
/* if reset by sleep wakeup, control the retention I/O cell */
|
||||
if (__raw_readl(S3C_RSTSTAT) & 0x8)
|
||||
@@ -285,17 +373,21 @@ int IsWallCharger(void)
|
||||
udelay(1000);
|
||||
__raw_writel((1<<2)|(0<<0), S3C_URSTCON);
|
||||
__raw_writel((0<<2)|(0<<0), S3C_URSTCON);
|
||||
__raw_writel((0<<3)|(0<<2)|(0<<1)|(0<<0), S3C_PHYCTRL);
|
||||
__raw_writel((0<<3)|(0<<2)|(1<<1)|(0<<0), S3C_PHYCTRL);
|
||||
__raw_writel((1<<31)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0), S3C_PHYPWR);
|
||||
__raw_writel((0<<31)|(1<<2)|(1<<1)|(1<<0), S3C_UCLKCON);
|
||||
__raw_writel((1<<31)|(1<<2)|(1<<1)|(1<<0), S3C_UCLKCON);
|
||||
__raw_writel((1<<31)|(1<<4)|(1<<2)|(1<<1)|(1<<0), S3C_UCLKCON);
|
||||
}
|
||||
|
||||
for(i=0;i<10;i++) {
|
||||
read_pin = __raw_readl(S3C_UDC_SYS_STATUS_REG)&0x60;
|
||||
udelay(1000);
|
||||
}
|
||||
//Benq,Andy modify for wall charger recognize bugfix
|
||||
//if( (read_pin != 0x60) ){
|
||||
if( (read_pin != 0x60) && (read_pin != 0x0)){ //Benq, Andy add (read_pin != 0x0)
|
||||
|
||||
read_pin = __raw_readl(S3C_UDC_SYS_STATUS_REG)&0x60;
|
||||
if(read_pin !=0x60){
|
||||
|
||||
// printk("usb\n");
|
||||
printk("usb\n");
|
||||
#if defined(CONFIG_QISDA_E600_EVT2)|| defined(CONFIG_QISDA_QD060N00_DVT1_1)
|
||||
if((readl(S3C2410_GPGDAT) &(1<<1))==0)
|
||||
{
|
||||
@@ -321,11 +413,20 @@ int IsWallCharger(void)
|
||||
__raw_writel((0<<31)|(0<<2)|(1<<1)|(1<<0), S3C_UCLKCON);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_PLATFORM_POWER_SAVING
|
||||
//{Benq,Andy add for USB power disable
|
||||
printk("\nUSB_UDC_DEVICE_POWER_DOWN\n");
|
||||
s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2443_GPH14, 0); /* usb all power disable (USB_EN20)*/
|
||||
//}Benq,Andy add for USB power disable
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// printk("wall charger\n");
|
||||
printk("wall charger\n");
|
||||
#if defined(CONFIG_QISDA_E600_EVT2)||defined(CONFIG_QISDA_QD060N00_DVT1_1)
|
||||
if((readl(S3C2410_GPGDAT) &(1<<1))==0)
|
||||
{
|
||||
@@ -349,6 +450,15 @@ int IsWallCharger(void)
|
||||
__raw_writel((0<<31)|(0<<2)|(1<<1)|(1<<0), S3C_UCLKCON);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PM_PLATFORM_POWER_SAVING
|
||||
//{Benq,Andy add for USB power disable
|
||||
printk("\nUSB_UDC_DEVICE_POWER_DOWN\n");
|
||||
s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2443_GPH14, 0); /* usb all power disable (USB_EN20)*/
|
||||
//}Benq,Andy add for USB power disable
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -390,21 +500,87 @@ static irqreturn_t s3c_pwrbtn_close_irq(int irq, void *id)
|
||||
#else
|
||||
s3c_keypad_deal(dev, read_pin, 7);
|
||||
#endif
|
||||
//close system by letting P_KEEP low
|
||||
|
||||
#ifdef POWER_KEY_FOR_SYS_SHUTDOWN
|
||||
//close system by letting P_KEEP low
|
||||
#ifdef CONFIG_QISDA_BK060B00
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2410_GPD14, 0);
|
||||
|
||||
#else
|
||||
s3c2410_gpio_setpin(S3C2410_GPG0, 0);
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPG0, S3C2410_GPG0_OUTP);
|
||||
#endif
|
||||
#endif
|
||||
/* } Qisda, ShiYong Lin, 2009/08/27, Implementing power btn behavior */
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
static void battery_status_handler(unsigned long data)
|
||||
{
|
||||
//struct input_dev *dev = id;
|
||||
u32 read_pin;
|
||||
u32 i, j;
|
||||
|
||||
printk("battery_status_handler\n");
|
||||
|
||||
read_pin = readl(S3C2410_GPGDAT) & (1<<1); /*joey add condition with usb/charger 20100128*/
|
||||
if(read_pin!=0)
|
||||
{
|
||||
read_pin = readl(S3C2410_GPFDAT) & (0x01<<6);
|
||||
|
||||
#ifdef CONFIG_QISDA_QD090B00
|
||||
if(read_pin)
|
||||
{
|
||||
//s3c_keypad_deal(dev, 0 , 25);
|
||||
input_report_key(Message_dev,KEY_BATTERY,1);
|
||||
input_sync(Message_dev);
|
||||
printk("s3c_battery_status_irq, keypad_message_to_ap\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//s3c_keypad_deal(dev, 1 , 25);
|
||||
input_report_key(Message_dev,KEY_BATTERY,0);
|
||||
input_sync(Message_dev);
|
||||
}
|
||||
#else
|
||||
if(read_pin)
|
||||
{
|
||||
//s3c_keypad_deal(dev, 0 , 27);
|
||||
input_report_key(Message_dev,KEY_BATTERY,1);
|
||||
input_sync(Message_dev);
|
||||
printk("s3c_battery_status_irq, keypad_message_to_ap\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
//s3c_keypad_deal(dev, 1 , 27);
|
||||
input_report_key(Message_dev,KEY_BATTERY,0);
|
||||
input_sync(Message_dev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
enable_irq(IRQ_EINT6); /*joey add timer to avoid bouncing with usb in/out 20100127*/
|
||||
}
|
||||
|
||||
static irqreturn_t s3c_battery_status_irq(int irq, void *id) /*joey add timer to avoid bouncing with usb in/out 20100127*/
|
||||
{
|
||||
printk("s3c_battery_status_irq, detecting\n");
|
||||
disable_irq(IRQ_EINT6);
|
||||
battery_status_timer.expires = jiffies + (HZ);
|
||||
add_timer(&battery_status_timer);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/11/11, Fix the trembling voice issue when plugging usb {*/
|
||||
static irqreturn_t s3c_cha_sta_irq(int irq, void *id)
|
||||
{
|
||||
/* Qisda , howard hsu, 2010/01/16 , op_mode-delay key event {*/
|
||||
op_mode_delay_message_to_ap(0);//0:usb,1:sd
|
||||
/* } Qisda , howard hsu, 2010/01/16 , op_mode-delay key event */
|
||||
// Qisda, 2010/02/18, TN Wei, sleep mode wakes up for usb event {
|
||||
sleeping_cha_event = 1;
|
||||
// Qisda, 2010/02/18, TN Wei, sleep mode wakes up for usb event }
|
||||
printk("s3c_cha_sta_irq\n");
|
||||
disable_irq(IRQ_EINT9);
|
||||
charger_source_timer.expires = jiffies + (HZ);
|
||||
@@ -453,17 +629,57 @@ void USB_SaftRemove_keypad_message_to_ap(uint uiSleep)
|
||||
{
|
||||
input_report_key(Message_dev,KEY_F6,1);
|
||||
input_sync(Message_dev);
|
||||
printk("Key-USB_PlugIn\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
input_report_key(Message_dev,KEY_F6,0);
|
||||
input_sync(Message_dev);
|
||||
printk("USB_SaftRemove_keypad_message_to_ap, USB_SaftRemove_keypad_message_to_ap press\n");
|
||||
printk("Key-USB_PlugOut\n");
|
||||
//printk("USB_SaftRemove_keypad_message_to_ap, USB_SaftRemove_keypad_message_to_ap press\n");
|
||||
}
|
||||
}
|
||||
/*} Qisda, Leo SJ Yang, 2009/10/26*/
|
||||
|
||||
|
||||
/*Qisda , howard hsu, 20100116 , op_mode-delay key event {*/
|
||||
/* OP_MODE_DELAY_REQUEST is KEY_F9 */
|
||||
/* Qisda , howard hsu, 20100208 , add type, 0 for usb, 1 for sd */
|
||||
void op_mode_delay_message_to_ap(uint type)
|
||||
{
|
||||
static uint last_type=0;
|
||||
if (type == last_type)
|
||||
{
|
||||
if(pdata!=NULL)
|
||||
{
|
||||
change_bit(OP_MODE_DELAY_REQUEST,pdata->dev->key);
|
||||
}
|
||||
}
|
||||
last_type = type;
|
||||
input_report_key(Message_dev,OP_MODE_DELAY_REQUEST,type);
|
||||
input_sync(Message_dev);
|
||||
}
|
||||
/*} Qisda , howard hsu, 20100116 , op_mode-delay key event*/
|
||||
/* Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card { */
|
||||
// disable it first, wait integration test
|
||||
#ifdef CONFIG_SD_SW_DEBOUNCE
|
||||
void SD_Detect_keypad_message_to_ap(uint sd_on)
|
||||
{
|
||||
static uint last_sd_on=0;
|
||||
if (last_sd_on == sd_on)
|
||||
{
|
||||
printk("\nCC--Repeat SDKey(%d)\n",sd_on);
|
||||
if(pdata!=NULL)
|
||||
{
|
||||
change_bit(KEY_F5,pdata->dev->key);
|
||||
}
|
||||
}
|
||||
last_sd_on = sd_on;
|
||||
input_report_key(Message_dev,KEY_F5,sd_on);
|
||||
input_sync(Message_dev);
|
||||
printk("\nCC--SendSD Key(%d)\n",sd_on);
|
||||
}
|
||||
#endif /* CONFIG_SD_SW_DEBOUNCE */
|
||||
/* } Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card */
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/09/08, Implement sleep message to AP {*/
|
||||
void s3c_keypad_pm_sleep_message_to_ap (uint uiSleep)
|
||||
@@ -485,6 +701,10 @@ static void s3c_keypad_set_irq(struct input_dev *dev)
|
||||
request_irq(IRQ_EINT0, s3c_pwrbtn_close_irq,
|
||||
SA_INTERRUPT, DEVICE_NAME, dev);
|
||||
|
||||
set_irq_type(IRQ_EINT6, 0x3); /*shiyong joey for asus 2009/12/15*/
|
||||
request_irq(IRQ_EINT6, s3c_battery_status_irq,
|
||||
SA_INTERRUPT, "s3c2410-battery status", dev);
|
||||
|
||||
set_irq_type(IRQ_EINT9, 0x3);
|
||||
request_irq(IRQ_EINT9, s3c_cha_sta_irq,
|
||||
SA_INTERRUPT, "s3c2410-charging status", dev);
|
||||
@@ -509,6 +729,9 @@ static void charger_source_handler(unsigned long data)
|
||||
read_pin = readl(S3C2410_GPGDAT) & (1<<1);
|
||||
printk("GPG1 = %d\n", read_pin);
|
||||
if(read_pin != 0){
|
||||
//s3c2410_gpio_pullup(S3C2410_GPF6, 0); /*joey add to put floating GPF6 with usb 20100201*/
|
||||
average_adc_value_keep1=9999; /*joey add to keep ADC will always return lower one 2009/12/28*/
|
||||
average_adc_value_keep2=9999; /*joey add to keep ADC will always return lower one 2009/12/28*/
|
||||
input_report_key(Message_dev, KEY_CHA_STA_UNPLUG, 0);
|
||||
input_sync(Message_dev);
|
||||
printk("usb or wallchager\n");
|
||||
@@ -539,6 +762,7 @@ static void charger_source_handler(unsigned long data)
|
||||
}
|
||||
}
|
||||
else{
|
||||
//s3c2410_gpio_pullup(S3C2410_GPF6, 1); /*joey add to pull low GPF6 without usb 20100201*/
|
||||
printk("nothing\n");
|
||||
input_report_key(Message_dev, KEY_CHA_STA_UNPLUG, 1);
|
||||
input_sync(Message_dev);
|
||||
@@ -558,6 +782,14 @@ static void charger_source_handler(unsigned long data)
|
||||
//EN1
|
||||
s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2410_GPB4, 1);
|
||||
|
||||
#ifdef CONFIG_PM_PLATFORM_POWER_SAVING
|
||||
//{Benq,Andy add for disable USB power
|
||||
printk("\nUSB_UDC_DEVICE_POWER_DOWN\n");
|
||||
s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
|
||||
s3c2410_gpio_setpin(S3C2443_GPH14, 0); /* usb all power disable (USB33 & USB12)*/
|
||||
//}Benq,Andy add for disable USB power
|
||||
#endif
|
||||
}
|
||||
enable_irq(IRQ_EINT9);
|
||||
}
|
||||
@@ -627,6 +859,8 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
u32 read_tilt;
|
||||
static u32 tilt_status_previous;
|
||||
static int tilt_counter=3;
|
||||
static u32 mmc_status_previous = 0xF;
|
||||
static int mmc_counter=16;
|
||||
|
||||
//struct s3c_keypad_qisda *pdata = (struct s3c_keypad_qisda *)data;
|
||||
pdata = (struct s3c_keypad_qisda *)data;
|
||||
@@ -721,7 +955,24 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
#ifdef CONFIG_QISDA_QD090B00
|
||||
read_pin = readl(S3C2410_GPFDAT);
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 2); // Page down
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<1)), 16); // SD card
|
||||
/* Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card { */
|
||||
#ifndef CONFIG_SD_SW_DEBOUNCE
|
||||
if(mmc_status_previous != (read_pin & (0x1<<1))){
|
||||
if(mmc_counter != 0){
|
||||
mmc_counter--;
|
||||
}
|
||||
else{
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<1)), 16); // SD card
|
||||
mmc_status_previous = (read_pin & (0x1<<1));
|
||||
mmc_counter=16;
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
mmc_counter=16;
|
||||
}
|
||||
#endif /* CONFIG_SD_SW_DEBOUNCE */
|
||||
/* } Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card */
|
||||
|
||||
if(headphonr_insert != (read_pin & (1<<4))){ // Headphone
|
||||
if(headphonr_insert_counter != 0){
|
||||
@@ -752,13 +1003,31 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 0); // Menu
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 3); // Page up
|
||||
|
||||
/*Qisda , wenny cheng , 20091224 , board id info {*/
|
||||
//if(hw_version_for_keypad){
|
||||
if(board_id !=QD090B00_S02)
|
||||
{
|
||||
//new
|
||||
s3c_keypad_deal(dev, read_pin & 1<<2, 1); // Search
|
||||
s3c_keypad_deal(dev, read_pin & 1<<3, 4); // Return
|
||||
}
|
||||
/*Qisda , wenny cheng , 20091224 , board id info }*/
|
||||
|
||||
read_pin = readl(S3C2410_GPHDAT);
|
||||
s3c_keypad_deal(dev, read_pin & 1<<5, 5); // Volume down
|
||||
s3c_keypad_deal(dev, read_pin & 1<<4, 6); // Volume up
|
||||
|
||||
read_pin = readl(S3C2410_GPDDAT);
|
||||
s3c_keypad_deal(dev, read_pin & 1<<14, 1); // Search
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 4); // Return
|
||||
|
||||
/*Qisda , wenny cheng , 20091224 , board id info {*/
|
||||
//if(!hw_version_for_keypad){
|
||||
if(board_id ==QD090B00_S02)
|
||||
{
|
||||
//old
|
||||
s3c_keypad_deal(dev, read_pin & 1<<14, 1); // Search
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 4); // Return
|
||||
}
|
||||
/*Qisda , wenny cheng , 20091224 , board id info }*/
|
||||
|
||||
read_tilt = (read_pin & (0x3<<10)) >> 10;
|
||||
if(tilt_status_previous != read_tilt){
|
||||
@@ -807,13 +1076,34 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
#ifdef CONFIG_QISDA_QD060B00
|
||||
read_pin = readl(S3C2410_GPFDAT);
|
||||
#ifdef QISDA_E600
|
||||
#ifdef CONFIG_QISDA_BQ060B00_DVT
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 2); // Page down
|
||||
#else
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 4); // Back
|
||||
#endif
|
||||
#endif
|
||||
#ifdef QISDA_L600
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 13); // Right
|
||||
#endif
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<1)), 18); // SD card
|
||||
|
||||
/* Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card { */
|
||||
#ifndef CONFIG_SD_SW_DEBOUNCE
|
||||
if(mmc_status_previous != (read_pin & (0x1<<1))){
|
||||
if(mmc_counter != 0){
|
||||
mmc_counter--;
|
||||
}
|
||||
else{
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<1)), 18); // SD card
|
||||
mmc_status_previous = (read_pin & (0x1<<1));
|
||||
printk("Key-SD_CHANGE(%d)\n",mmc_status_previous);
|
||||
mmc_counter=16;
|
||||
}
|
||||
}
|
||||
else{
|
||||
mmc_counter=16;
|
||||
}
|
||||
#endif /* CONFIG_SD_SW_DEBOUNCE */
|
||||
/* } Qisda, howard hsu, 2010/01/21, SW_DEBOUNCE for sd card */
|
||||
|
||||
if(headphonr_insert != (read_pin & (1<<4))){ // Headphone
|
||||
if(headphonr_insert_counter != 0){
|
||||
@@ -841,19 +1131,53 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
|
||||
read_pin = readl(S3C2410_GPGDAT);
|
||||
#ifdef QISDA_E600
|
||||
#ifdef CONFIG_QISDA_BQ060B00_DVT
|
||||
//s3c_keypad_deal(dev, (read_pin & (0x1<<4)), 8); // Refresh
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 1); // Search
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 3); // Page up
|
||||
if(board_id ==BQ060B00_A02)
|
||||
{
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<3)), 0); // Menu
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<4)), 4); // Back
|
||||
}
|
||||
#else
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<4)), 3); // Page up
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 6); // Volume
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 8); // Refresh
|
||||
if(board_id ==QD060B00_A02) {
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<3)), 0); // Menu
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 2); // Page down
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 1); // Search
|
||||
|
||||
} else if(board_id == QD060B00_A01_And_Before){
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 6); // Volume
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 8); // Refresh
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef QISDA_L600
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<6)), 11); // Down
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<7)), 12); // Left
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_QISDA_BK060B00
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<0)), 12); // LEFT
|
||||
s3c_keypad_deal(dev, (read_pin & (0x1<<2)), 13); // RIGHT
|
||||
#endif
|
||||
|
||||
read_pin = readl(S3C2410_GPHDAT);
|
||||
#ifdef QISDA_E600
|
||||
s3c_keypad_deal(dev, read_pin & 1<<5, 1); // Search
|
||||
#ifdef CONFIG_QISDA_BQ060B00_DVT
|
||||
s3c_keypad_deal(dev, read_pin & 1<<4, 5); // Volume down
|
||||
s3c_keypad_deal(dev, read_pin & 1<<5, 6); // Volume up
|
||||
#else
|
||||
// Qisda Jonas modify for keypad rework 20100104
|
||||
if(board_id ==QD060B00_A02) {
|
||||
s3c_keypad_deal(dev, read_pin & 1<<5, 8); // Refresh
|
||||
} else if (board_id == QD060B00_A01_And_Before){
|
||||
s3c_keypad_deal(dev, read_pin & 1<<5, 1); // Search
|
||||
}
|
||||
// Qisda Jonas modify for keypad rework
|
||||
#endif
|
||||
#endif
|
||||
#ifdef QISDA_L600
|
||||
s3c_keypad_deal(dev, read_pin & 1<<4, 9); // OK
|
||||
@@ -862,16 +1186,40 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
|
||||
|
||||
read_pin = readl(S3C2410_GPDDAT);
|
||||
s3c_keypad_deal(dev, read_pin & 1<<14, 0); // Menu
|
||||
#ifdef QISDA_E600
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 2); // Page down
|
||||
#ifdef CONFIG_QISDA_BQ060B00_DVT
|
||||
// Qisda Jonas modify for keypad rework 20100103
|
||||
if(board_id ==BQ060B00_A01_And_Before)
|
||||
{
|
||||
s3c_keypad_deal(dev, read_pin & 1<<14, 0); // Menu
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 4); // Back
|
||||
}
|
||||
#else
|
||||
// Qisda Jonas modify for keypad rework
|
||||
if(board_id == QD060B00_A02) {
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 6); // Volumn
|
||||
} else if(board_id == QD060B00_A01_And_Before){
|
||||
s3c_keypad_deal(dev, read_pin & 1<<14, 0); // Menu
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 2); // Page down
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#ifdef QISDA_L600
|
||||
s3c_keypad_deal(dev, read_pin & 1<<15, 4); // Back
|
||||
#endif
|
||||
|
||||
//Benq,Aaron: no tilt sensor in Plato
|
||||
#ifndef CONFIG_QISDA_BQ060B00_DVT
|
||||
|
||||
#ifdef CONFIG_QISDA_BK060B00
|
||||
|
||||
read_pin = readl(S3C2410_GPGDAT);
|
||||
read_tilt = (read_pin & (0x3<<3)) >> 3;
|
||||
#else
|
||||
read_tilt = (read_pin & (0x3<<10)) >> 10;
|
||||
#endif
|
||||
|
||||
if(tilt_status_previous != read_tilt){
|
||||
if(tilt_counter != 0){
|
||||
tilt_counter--;
|
||||
@@ -912,6 +1260,7 @@ static void keypad_timer_handler_qisda(unsigned long data)
|
||||
s3c_keypad_deal(dev, 1, 16);
|
||||
s3c_keypad_deal(dev, 1, 17);
|
||||
}
|
||||
#endif // #ifndef CONFIG_QISDA_BQ060B00_DVT
|
||||
#endif
|
||||
|
||||
if (is_timer_on_qisda == FALSE) {
|
||||
@@ -994,6 +1343,9 @@ static int __init s3c_keypad_qisda_probe(struct platform_device *pdev)
|
||||
init_timer(&charger_source_timer);
|
||||
charger_source_timer.function = charger_source_handler;
|
||||
/* } Qisda, ShiYong Lin, 2009/11/11, Fix the trembling voice issue when plugging usb */
|
||||
/*joey add timer to avoid bouncing with usb in/out 20100127*/
|
||||
init_timer(&battery_status_timer);
|
||||
battery_status_timer.function = battery_status_handler;
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/11/11, Modify for pwr fail event occurring wrongly when heavy loading {*/
|
||||
init_timer(&power_fail_timer);
|
||||
@@ -1004,6 +1356,15 @@ static int __init s3c_keypad_qisda_probe(struct platform_device *pdev)
|
||||
//initial work queue
|
||||
//INIT_WORK(&wqReadData,s3c_keypad_qisda_workqueue);
|
||||
|
||||
//{Benq,Andy add for USB cable unplug bugfix
|
||||
//If boot up with USB cable, s3c_adc_init will set charging_source to 0, without sending input_report_key,
|
||||
//so recheck is needed when initializing keypad, setting KEY_CHA_STA_USB to 1
|
||||
if( charging_source == 0 ){
|
||||
if ( ((readl(S3C2410_GPGDAT) & (1<<1)) != 0) && (IsWallCharger() == 0) )
|
||||
input_report_key(s3c_keypad_qisda->dev, KEY_CHA_STA_USB, 1);
|
||||
}
|
||||
//}Benq,Andy add for USB cable unplug bugfix
|
||||
|
||||
DPRINTK("s3c_keypad_qisda_probe finished\n");
|
||||
|
||||
/* Qisda, ShiYong Lin, 2009/08/27, Implement for message for AP {*/
|
||||
|
||||
@@ -89,4 +89,11 @@ config HP_SDC_RTC
|
||||
Say Y here if you want to support the built-in real time clock
|
||||
of the HP SDC controller.
|
||||
|
||||
config CYBOOK_ORIZON_TILT
|
||||
tristate "Cybook Orizon Tilt Sensor"
|
||||
depends on MACH_CYBOOK_ORIZON && CYBOOK_CYIO
|
||||
default y
|
||||
help
|
||||
Say Y here ig you want to support the Cybook Orizon Tilt Sensor
|
||||
|
||||
endif
|
||||
|
||||
@@ -12,3 +12,4 @@ obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
|
||||
obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
|
||||
obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o
|
||||
obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o
|
||||
obj-$(CONFIG_CYBOOK_ORIZON_TILT) += orizon_tilt.o
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -404,7 +404,7 @@ extern void s3c_camif_set_polarity(camif_cfg_t *cfg);
|
||||
#define QISDA_IIC_ACTIVE_MODE (1<<3)
|
||||
#define QISDA_IIC_SLEEP_MODE (1<<4)
|
||||
#define QISDA_IIC_DEEPSLEEP_MODE (1<<5)
|
||||
|
||||
#define QISDA_IIC_READ_BUFFERED_POSITION (1<<6)
|
||||
|
||||
|
||||
extern int s3c_ts_iic_port_init(struct i2c_client *c);
|
||||
|
||||
Reference in New Issue
Block a user