ssize_t _write(struct file *mfile, const char *gdata, size_t length, loff_t *off_what){ int ret; if(interruptCount == 0){ ret = request_irq(gpio_to_irq(S5PV310_GPX2(0)), &StartButton, IRQF_TRIGGER_RISING, "X2.0", NULL); ret = request_irq(gpio_to_irq(S5PV310_GPX2(1)), &PauseButton, IRQF_TRIGGER_RISING, "X2.1", NULL); ret = request_irq(gpio_to_irq(S5PV310_GPX2(2)), &ResetButton, IRQF_TRIGGER_RISING, "X2.2", NULL); ret = request_irq(gpio_to_irq(S5PV310_GPX2(4)), &ExitButton, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "X2.4", NULL); Reset(&my_stopwatch); timer_init(&my_stopwatch); printk("SleepStart!\n"); while(true){ gpio_fnd_write(my_gpio_fnd(1, my_stopwatch.min / 10)); msleep(5); gpio_fnd_write(my_gpio_fnd(2, my_stopwatch.min % 10)); msleep(5); gpio_fnd_write(my_gpio_fnd(3, my_stopwatch.sec / 10)); msleep(5); gpio_fnd_write(my_gpio_fnd(4, my_stopwatch.sec % 10)); msleep(5); if(shutdown_timer_start){ if(!shutdown_timer_watch_start){ // timer start. shutdown_timer_watch_start = true; time = get_jiffies_64(); printk("add timer %u\n", time); }else{ ; // ignore. } }else{ if(shutdown_timer_watch_start){ shutdown_timer_watch_start = false; unsigned int now = get_jiffies_64(); printk("get timer %u\n", now); if(now - time >= 3*HZ) break; } } } gpio_fnd_write(0xFF); timer_exit(); free_irq(gpio_to_irq(S5PV310_GPX2(0)), NULL); free_irq(gpio_to_irq(S5PV310_GPX2(1)), NULL); free_irq(gpio_to_irq(S5PV310_GPX2(2)), NULL); free_irq(gpio_to_irq(S5PV310_GPX2(4)), NULL); } return 0; }
static int s5pv310_gpio2int(struct gpio_chip *chip, unsigned pin) { int ret = 0; int base = chip->base; switch (base) { case S5PV310_GPX0(0): ret = IRQ_EINT(0) + pin; break; case S5PV310_GPX1(0): ret = IRQ_EINT(8) + pin; break; case S5PV310_GPX2(0): ret = IRQ_EINT(16) + pin; break; case S5PV310_GPX3(0): ret = IRQ_EINT(24) + pin; break; } return ret; }
.to_irq = s5pv310_gpio2int, }, }, { .base = (S5PV310_VA_GPIO2 + 0xC20), .config = &gpio_cfg_noint, .chip = { .base = S5PV310_GPX1(0), .ngpio = S5PV310_GPIO_X1_NR, .label = "GPX1", .to_irq = s5pv310_gpio2int, }, }, { .base = (S5PV310_VA_GPIO2 + 0xC40), .config = &gpio_cfg_noint, .chip = { .base = S5PV310_GPX2(0), .ngpio = S5PV310_GPIO_X2_NR, .label = "GPX2", .to_irq = s5pv310_gpio2int, }, }, { .base = (S5PV310_VA_GPIO2 + 0xC60), .config = &gpio_cfg_noint, .chip = { .base = S5PV310_GPX3(0), .ngpio = S5PV310_GPIO_X3_NR, .label = "GPX3", .to_irq = s5pv310_gpio2int, }, }, { .base = (S5PV310_VA_GPIO2 + 0x120),