static irqreturn_t buttons_irq(int irq, void *dev_id) { struct pin_desc * pindesc = (struct pin_desc *)dev_id; unsigned int pinval; //read the values of pins pinval = s3c2410_gpio_getpin(pindesc->pin); if(pinval) { /*released*/ key_val = 0x80 | pindesc->key_val; } else { /*pressed*/ key_val = pindesc->key_val; } ev_press = 1; wake_up_interruptible(&button_waitq); return IRQ_RETVAL(IRQ_HANDLED); }
static irqreturn_t buttons_irq(int irq, void *dev_id) { struct pin_desc *pindesc = (struct pin_desc *)dev_id; unsigned int pinval; //printk("pindesc->pin = %d\n", pindesc->pin); pinval = s3c2410_gpio_getpin(pindesc->pin); //printk("pinval = %d\n", pinval); //printk("pindesc->key_val = %x\n", pindesc->key_val); if(pinval) { /* key is not pressed down */ keyval = 0x80 | pindesc->key_val; }else { /* key is pressed down */ keyval = pindesc->key_val; } ev_press = 1; /* 表示中断发生了 */ wake_up_interruptible(&button_waitq); /* 唤醒休眠的进程 */ kill_fasync(&button_async_queue, SIGIO, POLL_IN); return IRQ_RETVAL(IRQ_HANDLED); }
static void buttons_timer(unsigned long arg) { //获取当前按键资源的索引 int key = arg; //获取当前按键引脚上的电平值来判断按键是按下还是抬起 int up = s3c2410_gpio_getpin(button_irqs[key].pin); if(!up)//低电平,按键按下 { if(key_status[key] == KEY_UNCERTAIN) { // 标识当前按键状态为按下 key_status[key] = KEY_DOWN; //标识当前按键已按下并唤醒等待队列 ev_press = 1; wake_up_interruptible(&button_waitq); } //设置当前按键抬起去抖定时器的延时并启动定时器 key_timers[key].expires = jiffies + KEY_TIMER_DELAY2; add_timer(&key_timers[key]); } else//高电平,按键抬起 { //标识当前按键状态为抬起 key_status[key] = KEY_UP; } }
// Step 4 part3 上报 input_event static void buttons_timer_function(unsigned long data) { struct pin_desc * pindesc = (struct pin_desc *) irq_pd; unsigned int pinval; if (!pindesc) return ; pinval = s3c2410_gpio_getpin(pindesc->pin); //读引脚值 if (pinval) { /* 松开 最后一个参数 0 表示松开,1表示按下*/ input_event(buttons_dev,EV_KEY, pindesc->key_val, 0); //上报事件 } else { /* 按下 */ input_event(buttons_dev,EV_KEY, pindesc->key_val, 1); } ev_press = 1; /* 表示中断发生了 */ wake_up_interruptible(&button_waitq); /* 唤醒休眠的进程 */ kill_fasync (&button_async, SIGIO, POLL_IN); }
irqreturn_t key_handler(int irq, void *dev_id) { unsigned int pinval; /* *读出引脚值,是按下或是松开,按下引脚是低电平,松开引脚是高电平 */ // printk("key pressed..irq:%d\n", irq); struct pin_des *ptr = (struct pin_des *)dev_id; pinval = s3c2410_gpio_getpin(ptr->pin); if(pinval) { /*松开,高电平*/ keyval = 0x80 | (ptr->pin_val); } else { /*按下,低电平*/ keyval = ptr->pin_val; } ev_press = 1; wake_up_interruptible(&key_waitirq); //唤醒去read--->wait_up_interruptible--->copy_to_user kill_fasync(&key_fasync, SIGIO, POLLIN); return IRQ_HANDLED; }
static irqreturn_t rebis_keyevent(int irq, void *dev_id, struct pt_regs *regs) { struct rebis_key_detection *gd = (struct rebis_key_detection *) dev_id; int state; state = 1; printk("gd= %x, keypad was pressed \n",(unsigned int)gd); if (!gd) return IRQ_HANDLED; #if 1 state = s3c2410_gpio_getpin(gd->pin); gd->last_state = state; gprintk("%s gd %s\n\n", gd->name, state ? "high" : "low"); #endif #if (EXAMPLE == 100) schedule_work(&gd->gdetect); #elif (EXAMPLE == 200) tasklet_schedule(&gd->gdetect); #endif flag = 1; wake_up_interruptible(&wq); return IRQ_HANDLED; }
static int glamo_irq_is_wired(void) { int rc; int count = 0; /* * GTA02 S-Media IRQs prior to A5 are broken due to a lack of * a pullup on the INT# line. Check for the bad behaviour. */ s3c2410_gpio_setpin(S3C2410_GPG4, 0); s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_OUTP); s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_INP); /* * we force it low ourselves for a moment and resume being input. * If there is a pullup, it won't stay low for long. But if the * level converter is there as on < A5 revision, the weak keeper * on the input of the LC will hold the line low indefinitiely */ do rc = s3c2410_gpio_getpin(S3C2410_GPG4); while ((!rc) && ((count++) < 10)); if (rc) { /* it got pulled back up, it's good */ printk(KERN_INFO "Detected S-Media IRQ# pullup, " "enabling interrupt\n"); return 0; } else /* Gah we can't work with this level converter */ printk(KERN_WARNING "** Detected bad IRQ# circuit found" " on pre-A5 GTA02: S-Media interrupt disabled **\n"); return -ENODEV; }
static void buttons_timer_function(unsigned long data) { struct pin_desc * pindesc = irq_pd; unsigned int pinval; if (!pindesc) return; //printk("%s, %d\n", __FUNCTION__, __LINE__); pinval = s3c2410_gpio_getpin(pindesc->pin); if (pinval) { /* 松开 : 最后一个参数: 0-松开, 1-按下 */ input_event(buttons_input_dev, EV_KEY, pindesc->key_val, 0); input_sync(buttons_input_dev); //printk("in if input sync ok\n"); } else { /* 按下 */ input_event(buttons_input_dev, EV_KEY, pindesc->key_val, 1); input_sync(buttons_input_dev); //printk("in else input sync ok\n"); } }
/* * 确定按键值 */ static irqreturn_t buttons_irq(int irq, void *dev_id) { struct pin_desc * pindesc = (struct pin_desc *)dev_id; unsigned int pinval; pinval = s3c2410_gpio_getpin(pindesc->pin); if (pinval) { /* 松开 */ key_val = 0x80 | pindesc->key_val; } else { /* 按下 */ key_val = pindesc->key_val; } ev_press = 1; /* 表示中断发生了 */ wake_up_interruptible(&button_waitq); /* 唤醒休眠的进程 */ kill_fasync (&button_async, SIGIO, POLL_IN); return IRQ_RETVAL(IRQ_HANDLED); }
static irqreturn_t buttons_irq(int irq, void *dev_id) { unsigned int value = 0; pin_desc *pin_desc_temp = (pin_desc *)dev_id; value = s3c2410_gpio_getpin(pin_desc_temp->pin); if(value) { // release key key_value = 0x80 | pin_desc_temp->key_val; } else { // press key key_value = pin_desc_temp->key_val; } ev_press = 1; /* 表示中断发生了 */ wake_up_interruptible(&button_waitq); /* 唤醒休眠的进程 */ //printk("buttons_irq \n"); return IRQ_HANDLED; }
static void buttons_timer_function(unsigned long data) { struct pin_desc * pindesc = irq_pd; unsigned int pinval; if (!pindesc) return; pinval = s3c2410_gpio_getpin(pindesc->pin); if (pinval) { /* 松开 */ key_val = 0x80 | pindesc->key_val; } else { /* 按下 */ key_val = pindesc->key_val; } ev_press = 1; /* 表示中断发生了 */ wake_up_interruptible(&button_waitq); /* 唤醒休眠的进程 */ kill_fasync (&button_async, SIGIO, POLL_IN); }
static int rx3000_serial_resume(struct platform_device *pdev) { enable_irq(IRQ_EINT6); if (s3c2410_gpio_getpin(S3C2410_GPF6)) rx3000_serial_power(1); return 0; }
static ssize_t bt_read(struct device *dev, struct device_attribute *attr, char *buf) { int ret = 0; if (!strcmp(attr->attr.name, "power_on")) { if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN)) ret = 1; } else if (!strcmp(attr->attr.name, "reset")) { if (s3c2410_gpio_getpin(GTA02_GPIO_BT_EN) == 0) ret = 1; } if (!ret) { return strlcpy(buf, "0\n", 3); } else { return strlcpy(buf, "1\n", 3); } }
static int scan_input(void) { if(((readl(S3C2410_GPFDAT) >> 3) & 0x1) != 0x1) { if(!s3c2410_gpio_getpin(S3C2410_GPF3)) return 2; } return 0; }
static int s3cmci_get_ro(struct mmc_host *mmc) { struct s3cmci_host *host = mmc_priv(mmc); if (host->pdata->gpio_wprotect == 0) return 0; return s3c2410_gpio_getpin(host->pdata->gpio_wprotect); }
static irqreturn_t rx3000_serial_cable(int irq, void *dev_id) { int status; status = s3c2410_gpio_getpin(S3C2410_GPF6); rx3000_serial_power(status); return IRQ_HANDLED; }
static int gta02_bt_suspend(struct platform_device *pdev, pm_message_t state) { struct gta02_pm_bt_data *bt_data = dev_get_drvdata(&pdev->dev); dev_dbg(&pdev->dev, DRVMSG ": suspending\n"); bt_data->pre_resume_state = s3c2410_gpio_getpin(GTA02_GPIO_BT_EN); __gta02_pm_bt_toggle_radio(&pdev->dev, 0); return 0; }
static int s3cmci_card_present(struct s3cmci_host *host) { struct s3c24xx_mci_pdata *pdata = host->pdata; int ret; if (pdata->gpio_detect == 0) return -ENOSYS; ret = s3c2410_gpio_getpin(pdata->gpio_detect) ? 0 : 1; return ret ^ pdata->detect_invert; }
static void _get_hw_version(void) { _hw_version = 0; // set version bit to input pullup s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_INP); s3c2410_gpio_pullup(S3C2410_GPE7, 2); s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_INP); s3c2410_gpio_pullup(S3C2410_GPE8, 2); s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_INP); s3c2410_gpio_pullup(S3C2410_GPE9, 2); s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE9_INP); s3c2410_gpio_pullup(S3C2410_GPE10, 2); s3c2410_gpio_cfgpin(S3C2410_GPH6, S3C2410_GPH6_INP); s3c2410_gpio_pullup(S3C2410_GPH6, 2); _hw_version += (s3c2410_gpio_getpin(S3C2410_GPE7) ? 1 << 0 : 0); _hw_version += (s3c2410_gpio_getpin(S3C2410_GPE8) ? 1 << 1 : 0); _hw_version += (s3c2410_gpio_getpin(S3C2410_GPE9) ? 1 << 2 : 0); _hw_version += (s3c2410_gpio_getpin(S3C2410_GPE10) ? 1 << 3 : 0); _hw_version += (s3c2410_gpio_getpin(S3C2410_GPH6) ? 1 << 4 : 0); // set version bit to disable pullup s3c2410_gpio_pullup(S3C2410_GPE7, 0); s3c2410_gpio_pullup(S3C2410_GPE8, 0); s3c2410_gpio_pullup(S3C2410_GPE9, 0); s3c2410_gpio_pullup(S3C2410_GPE10, 0); s3c2410_gpio_pullup(S3C2410_GPH6, 0); printk(KERN_INFO "CANOPUS H/W ver. 0x%x\n", _hw_version); /* proc */ _proc_dir = create_proc_entry("hwversion", 0, NULL); _proc_dir->read_proc = (read_proc_t *)_proc_hw_version; _proc_dir->data = NULL; }
static void button_timer_function(unsigned long dat) { unsigned int pinval; pinval = s3c2410_gpio_getpin(p_btn_desc->pin); if (!pinval){ input_report_key(button_dev, p_btn_desc->key_val, 1); input_sync(button_dev); }else{ input_report_key(button_dev, p_btn_desc->key_val, 0); input_sync(button_dev); //return; } }
static int gta02_gsm_resume(struct platform_device *pdev) { /* GPIO state is saved/restored by S3C2410 core GPIO driver, so we * don't need to do much here. */ /* Make sure that the kernel console on the serial port is still * disabled. FIXME: resume ordering race with serial driver! */ if (gta02_gsm.con && s3c2410_gpio_getpin(GTA02_GPIO_MODEM_ON)) console_stop(gta02_gsm.con); s3c2410_gpio_setpin(GTA02_GPIO_nDL_GSM, gta02_gsm.gpio_ndl_gsm); return 0; }
static irqreturn_t usb_simtec_ocirq(int irq, void *pw, struct pt_regs *regs) { struct s3c2410_hcd_info *info = (struct s3c2410_hcd_info *)pw; if (s3c2410_gpio_getpin(S3C2410_GPG10) == 0) { pr_debug("usb_simtec: over-current irq (oc detected)\n"); s3c2410_usb_report_oc(info, 3); } else { pr_debug("usb_simtec: over-current irq (oc cleared)\n"); s3c2410_usb_report_oc(info, 0); } return IRQ_HANDLED; }
static irqreturn_t buttons_interrupt(int irq, void *dev_id) { struct button_irq_desc *button_irq = (struct button_irq_desc *)dev_id; int down; down = !s3c2410_gpio_getpin(button_irq->pin); if (down != (key_values[button_irq->number] & 1)) { /* printk(KERN_ALERT "key_values[button_irq->number] & 1 = %d\n", key_values[button_irq->number] & 1); */ key_values[button_irq->number] = '0' + down; ev_press = 1; wake_up_interruptible(&button_waitq); } return IRQ_RETVAL(IRQ_HANDLED); }
static int s3cmci_get_ro(struct mmc_host *mmc) { struct s3cmci_host *host = mmc_priv(mmc); struct s3c24xx_mci_pdata *pdata = host->pdata; int ret; if (pdata->gpio_wprotect == 0) return 0; ret = s3c2410_gpio_getpin(pdata->gpio_wprotect); if (pdata->wprotect_invert) ret = !ret; return ret; }
static ssize_t gsm_read(struct device *dev, struct device_attribute *attr, char *buf) { if (!strcmp(attr->attr.name, "power_on")) { if (pcf50633_gpio_get(gta02_pcf, PCF50633_GPIO2)) goto out_1; } else if (!strcmp(attr->attr.name, "download")) { if (!s3c2410_gpio_getpin(GTA02_GPIO_nDL_GSM)) goto out_1; } else if (!strcmp(attr->attr.name, "flowcontrolled")) { if (s3c2410_gpio_getcfg(S3C2410_GPH1) == S3C2410_GPIO_OUTPUT) goto out_1; } return strlcpy(buf, "0\n", 3); out_1: return strlcpy(buf, "1\n", 3); }
int gta02_get_pcb_revision(void) { int n; int u = 0; static unsigned long pinlist[] = { GTA02_PCB_ID1_0, GTA02_PCB_ID1_1, GTA02_PCB_ID1_2, GTA02_PCB_ID2_0, GTA02_PCB_ID2_1, }; static int pin_offset[] = { 0, 1, 2, 8, 9 }; for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) { /* * set the PCB version GPIO to be pulled-down input * force low briefly first */ s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT); s3c2410_gpio_setpin(pinlist[n], 0); /* misnomer: it is a pullDOWN in 2442 */ s3c2410_gpio_pullup(pinlist[n], 1); s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT); udelay(10); if (s3c2410_gpio_getpin(pinlist[n])) u |= 1 << pin_offset[n]; /* * when not being interrogated, all of the revision GPIO * are set to output HIGH without pulldown so no current flows * if they are NC or pulled up. */ s3c2410_gpio_setpin(pinlist[n], 1); s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT); /* misnomer: it is a pullDOWN in 2442 */ s3c2410_gpio_pullup(pinlist[n], 0); } return u; }
/*本按键驱动的中断服务程序*/ static irqreturn_t buttons_interrupt(int irq, void* dev_id) { struct button_irq_desc* button_irqs = (struct button_irq_desc*)dev_id; int down; // udelay(0); /*获取被按下的按键状态*/ down = !s3c2410_gpio_getpin(button_irqs->pin); /*状态改变,按键被按下,从这句可以看出,当按键没有被按下的时候,寄存器的值为1(上拉),但按键被按下的时候,寄存器对应的值为0*/ if (down != (key_values[button_irqs->number] & 1)) { // Changed /*如果key1 被按下,则key_value[0]就变为’1’,对应的ASCII 码为31*/ key_values[button_irqs->number] = '0' + down; ev_press = 1; /*设置中断标志为1*/ wake_up_interruptible(&button_waitq); /*唤醒等待队列*/ } return IRQ_RETVAL(IRQ_HANDLED); }
static void h1940_lcd_power_set(struct plat_lcd_data *pd, unsigned int power) { int value; if (!power) { /* set to 3ec */ s3c2410_gpio_setpin(S3C2410_GPC(0), 0); /* wait for 3ac */ do { value = s3c2410_gpio_getpin(S3C2410_GPC(6)); } while (value); /* set to 38c */ s3c2410_gpio_setpin(S3C2410_GPC(5), 0); } else { /* Set to 3ac */ s3c2410_gpio_setpin(S3C2410_GPC(5), 1); /* Set to 3ad */ s3c2410_gpio_setpin(S3C2410_GPC(0), 1); } }
static irqreturn_t buttons_irq(int irq, void *dev_id) { struct pin_desc *pindesc = (struct pin_desc *)dev_id; unsigned int pinval; pinval = s3c2410_gpio_getpin(pindesc->pin); if (pinval) { key_val = 0x80 | pindesc->key_val; } else { key_val = pindesc->key_val; } ev_press = 1; wake_up_interruptible(&button_waitq); kill_fasync(&button_async, SIGIO, POLL_IN); return IRQ_HANDLED; }
/* * 确定按键值 */ static irqreturn_t buttons_irq(int irq, void *dev_id) { struct pin_desc * pindesc = (struct pin_desc *)dev_id; unsigned int pinval; pinval = s3c2410_gpio_getpin(pindesc->pin); if (pinval) { /* 松开 */ key_val = 0x80 | pindesc->key_val; } else { /* 按下 */ key_val = pindesc->key_val; } ev_press = 1; /* ±íʾÖжϷ¢ÉúÁË */ wake_up_interruptible(&button_waitq); /* »½ÐÑÐÝÃߵĽø³Ì */ return IRQ_HANDLED; }