static int gpio_keys_resume(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); int i; #if 0 int rc; if(camera_ctrl){ rc = gpio_request(GPIO_CAMERA_SNAPSHOT1, "gpio_keys"); if (rc < 0) { pr_err("%s: Fail request GPIO_CAMERA_SNAPSHOT1 pin r=%d\n", __func__, rc); } rc = gpio_request(GPIO_CAMERA_FOCUS1, "gpio_keys"); if (rc < 0) { pr_err("%s: Fail request GPIO_CAMERA_FOCUS1 pin r=%d\n", __func__, rc); } }else{ rc = gpio_request(GPIO_CAMERA_SNAPSHOT, "gpio_keys"); if (rc < 0) { pr_err("%s: Fail request GPIO_CAMERA_SNAPSHOT pin r=%d\n", __func__, rc); } rc = gpio_request(GPIO_CAMERA_FOCUS, "gpio_keys"); if (rc < 0) { pr_err("%s: Fail request GPIO_CAMERA_FOCUS pin r=%d\n", __func__, rc); } } #endif if(camera_ctrl){ for (i = 4; i < 8 ; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) disable_irq_wake(bdata->irq); #if 0 if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); #endif } }else{ for (i = 0; i < ddata->n_buttons-4; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) disable_irq_wake(bdata->irq); #if 0 if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); #endif } } //input_sync(ddata->input); return 0; }
static int gpio_keys_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; int wakeup_key = KEY_RESERVED; int i; if (pdata->wakeup_key) wakeup_key = pdata->wakeup_key(); if (wakeup_key != KEY_RESERVED) wake_lock_timeout(&pkw_wakelock, 5 * HZ); for (i = 0; i < ddata->n_buttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) { disable_irq_wake(bdata->irq); } if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } return 0; }
static int gpio_keys_resume(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); int i; for (i = 0; i < ddata->n_buttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) disable_irq_wake(bdata->irq); if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } #ifdef CONFIG_SENSORS_HALL if (device_may_wakeup(dev) && ddata->gpio_flip_cover != 0) { disable_irq_wake(ddata->irq_flip_cover); #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL if (ddata->cover_state && ddata->gsm_area) gpio_hall_irq_set(enable, false); #endif } #endif input_sync(ddata->input); return 0; }
static void gpio_keys_gpio_work_func(struct work_struct *work) { struct gpio_button_data *bdata = container_of(work, struct gpio_button_data, work); gpio_keys_gpio_report_event(bdata); }
static void gpio_keys_gpio_work_func(struct work_struct *work) { struct gpio_button_data *bdata = container_of(work, struct gpio_button_data, work); pr_debug("%s: @@@@@@@@@@ report keys\n", __func__); gpio_keys_gpio_report_event(bdata); }
static void gpio_keys_gpio_work_func(struct work_struct *work) { struct gpio_button_data *bdata = container_of(work, struct gpio_button_data, work.work); gpio_keys_gpio_report_event(bdata); if (bdata->button->wakeup) pm_relax(bdata->input->dev.parent); }
static void gpio_keys_report_state(struct gpio_keys_drvdata *ddata) { struct input_dev *input = ddata->input; int i; for (i = 0; i < ddata->pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); }
static void gpio_keys_gpio_work_func(struct work_struct *work) { struct gpio_button_data *bdata = container_of(work, struct gpio_button_data, work); const struct gpio_keys_button *button = bdata->button; int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; gpio_keys_gpio_report_event(bdata); #ifdef KEY_BOOSTER if (button->code == KEY_HOME) gpio_key_set_dvfs_lock(bdata, !!state); #endif }
static void gpio_keys_gpio_work_func(struct work_struct *work) { struct gpio_button_data *bdata = container_of(work, struct gpio_button_data, work); #ifdef CONFIG_MACH_ASUSTEK /* Valid keys were logged for debugging */ const struct gpio_keys_button *button = bdata->button; int state = (gpio_get_value_cansleep(button->gpio) ? 1 : 0) ^ button->active_low; if ((button->code <= KEY_POWER) && (button->code >= KEY_VOLUMEDOWN)) pr_info("gpio_keys: %s %s\n", state ? "Pressed" : "Released", key_descriptions[button->code - KEY_VOLUMEDOWN]); #endif gpio_keys_gpio_report_event(bdata); }
static int gpio_keys_resume(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); int i; for (i = 0; i < ddata->n_buttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) disable_irq_wake(bdata->irq); if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(ddata->input); return 0; }
static int gpio_keys_resume(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); int i; for (i = 0; i < ddata->n_buttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) { disable_irq_wake(bdata->irq); bdata->button->goog.last_suspend_cnt = get_suspend_cnt(); bdata->button->goog.synth_sent = 0; } if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata, GPIO_KEYS_RESUME); } input_sync(ddata->input); return 0; }
static int gpio_keys_resume(struct device *dev) { struct gpio_keys_drvdata *ddata = dev_get_drvdata(dev); int i; for (i = 0; i < ddata->n_buttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (bdata->button->wakeup && device_may_wakeup(dev)) disable_irq_wake(bdata->irq); if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(ddata->input); /*OPPO yuyi 2014-03-22 add begin for delay button_backlight*/ #ifdef VENDOR_EDIT button_backlight = 1; #endif /*OPPO yuyi 2014-03-22 add end for delay button_backlight*/ return 0; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { const struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); device_init_wakeup(&pdev->dev, wakeup); return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct gpio_keys_button *button = NULL; struct gpio_button_data *bdata = NULL; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; #ifdef CONFIG_SENSORS_HALL int ret; struct device *sec_key; #endif if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT) ret = gpio_request(pdata->gpio_flip_cover,"HALL"); if(ret) printk(KERN_CRIT "[HALL IC] gpio Request FAIL\n"); else { gpio_tlmm_config(GPIO_CFG(pdata->gpio_flip_cover,0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,GPIO_CFG_2MA),GPIO_CFG_DISABLE); } #endif ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover); wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND, "flip_wake_lock"); #endif mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL if(ddata->gpio_flip_cover != 0) { input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, SW_FLIP); } #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { button = &pdata->buttons[i]; bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); #ifdef CONFIG_SENSORS_HALL sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key"); if (IS_ERR(sec_key)) pr_err("Failed to create device(sec_key)!\n"); ret = device_create_file(sec_key, &dev_attr_sec_key_pressed); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed.attr.name); } #if defined(CONFIG_SENSORS_HALL) if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_detect); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_detect.attr.name, ret); } } #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT) if (!lvs1_1p8) { lvs1_1p8 = regulator_get(dev, "8226_lvs1"); if(!lvs1_1p8) printk(KERN_CRIT "%s: regulator_get for 8226_lvs1 failed\n", __func__); else { ret = regulator_enable(lvs1_1p8); if (ret){ regulator_put(lvs1_1p8); printk(KERN_CRIT "%s: Failed to enable regulator lvs1_1p8.\n",__func__); } } } #endif #endif ret = device_create_file(sec_key, &dev_attr_wakeup_keys); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_wakeup_keys.attr.name, ret); } dev_set_drvdata(sec_key, ddata); #endif device_init_wakeup(&pdev->dev, wakeup); return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); #ifdef CONFIG_SENSORS_HALL wake_lock_destroy(&ddata->flip_wake_lock); #endif fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct gpio_keys_button *button = NULL; struct gpio_button_data *bdata = NULL; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; int ret; struct device *sec_key; #ifdef CONFIG_SEC_PATEK_PROJECT struct device *sec_keypad; struct device *sec_flip; #endif if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL_DEBOUNCE ddata->debounce_set = pdata->debounce_set; #endif #ifdef CONFIG_SENSORS_HALL #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT)\ || defined (CONFIG_SEC_MATISSE_PROJECT) || defined (CONFIG_SEC_ATLANTIC_PROJECT)\ || defined (CONFIG_SEC_MEGA2_PROJECT) || defined (CONFIG_SEC_T8_PROJECT) || defined (CONFIG_SEC_T10_PROJECT) || defined(CONFIG_SEC_HESTIA_PROJECT) ret = gpio_request(pdata->gpio_flip_cover,"HALL"); if(ret) printk(KERN_CRIT "[HALL IC] gpio Request FAIL\n"); else { gpio_tlmm_config(GPIO_CFG(pdata->gpio_flip_cover,0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,GPIO_CFG_2MA),GPIO_CFG_DISABLE); } #endif ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->flip_code = pdata->flip_code; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover); wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND, "flip_wake_lock"); flip_status_before = -1; #endif mutex_init(&ddata->disable_lock); #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL mutex_init(&ddata->irq_lock); #endif platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL if(ddata->gpio_flip_cover != 0) { input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, ddata->flip_code); } #endif #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL ddata->gsm_area = false; ddata->cover_state = false; ddata->workaround_set = pdata->workaround_set; drv_data = ddata; #endif #ifdef CONFIG_SENSORS_HALL_DEBOUNCE ddata->debounce_set = false; #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { button = &pdata->buttons[i]; bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; #ifdef KEY_BOOSTER error = gpio_key_init_dvfs(bdata); if (error < 0) { dev_err(dev, "Fail get dvfs level for touch booster\n"); goto fail2; } #endif if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key"); if (IS_ERR(sec_key)) pr_err("Failed to create device(sec_key)!\n"); #ifdef CONFIG_SEC_PATEK_PROJECT sec_keypad=device_create(sec_class, NULL, 0, NULL, "sec_keypad"); if (device_create_file(sec_keypad, &dev_attr_brightness) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_brightness.attr.name); sec_flip = device_create(sec_class, NULL, 0, NULL, "sec_flip"); if (device_create_file(sec_flip, &dev_attr_flipStatus) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_flipStatus.attr.name); #endif ret = device_create_file(sec_key, &dev_attr_sec_key_pressed); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed.attr.name); } #if defined(CONFIG_SEC_S_PROJECT) ret = device_create_file(sec_key, &dev_attr_sec_key_pressed_code); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed_code.attr.name); } #endif #ifdef CONFIG_SENSORS_HALL_IRQ_CTRL if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_irq_ctrl.attr.name, ret); } } #endif #if defined(CONFIG_SENSORS_HALL) if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_detect); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_detect.attr.name, ret); } } #if defined(CONFIG_SENSORS_HALL_DEBOUNCE) if(ddata->gpio_flip_cover != 0) { ret = device_create_file(sec_key, &dev_attr_hall_irq_ctrl); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_irq_ctrl.attr.name, ret); } } #endif #if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_BERLUTI_PROJECT) || defined (CONFIG_SEC_T8_PROJECT) if (!lvs1_1p8) { lvs1_1p8 = regulator_get(dev, "8226_lvs1"); if(!lvs1_1p8) printk(KERN_CRIT "%s: regulator_get for 8226_lvs1 failed\n", __func__); else { ret = regulator_enable(lvs1_1p8); if (ret){ regulator_put(lvs1_1p8); printk(KERN_CRIT "%s: Failed to enable regulator lvs1_1p8.\n",__func__); } } } #endif #endif #ifdef CONFIG_USE_VM_KEYBOARD_REJECT reject_keyboard_specific_key = false; ret = device_create_file(sec_key, &dev_attr_reject_key_comb); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_reject_key_comb.attr.name, ret); } #endif ret = device_create_file(sec_key, &dev_attr_wakeup_keys); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_wakeup_keys.attr.name, ret); } dev_set_drvdata(sec_key, ddata); device_init_wakeup(&pdev->dev, wakeup); #if defined(CONFIG_SEC_PATEK_PROJECT) keypadled_powerset(&pdev->dev); dev_set_drvdata(sec_flip, ddata); #endif #ifdef PERIODIC_CHECK_GPIOS INIT_DELAYED_WORK_DEFERRABLE(&g_gpio_check_work, sec_gpiocheck_work); schedule_delayed_work(&g_gpio_check_work, msecs_to_jiffies(0)); #endif return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); #ifdef CONFIG_SENSORS_HALL wake_lock_destroy(&ddata->flip_wake_lock); #endif fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); #if 0 error = gpio_request(GPIO_CAMERA_CTRL, NULL); if (error < 0) { printk("[%s]Failed to request GPIO %d, error %d\n", __func__,GPIO_CAMERA_CTRL, error); //return error; } #endif Printlog("[%s]hw_id = %d \n",__func__,board_type_with_hw_id()); camera_ctrl= (board_type_with_hw_id() > DVT2_BOARD_HW_ID); Printlog("[%s] camera_ctrl :%d \n",__func__,camera_ctrl); // camera_ctrl = gpio_get_value(GPIO_CAMERA_CTRL); if(camera_ctrl){//for after DVT3 to cahnge camera gpio define for (i = 4; i <8; i++) { const struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } }else{ //for before DVT3. for (i = 0; i < pdata->nbuttons-4; i++) { const struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } } //PrintAA("[%s] GPIO_CAMERA_CTRL value:%d",__func__,camera_ctrl); error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } if(camera_ctrl){//for after DVT3 to cahnge camera gpio define /* get current state of buttons that are connected to GPIOs */ for (i = 4; i < 8; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } }else{//for before DVT3 /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons-4; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } } input_sync(input); device_init_wakeup(&pdev->dev, wakeup); return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: if(camera_ctrl) while (--i >= 4) gpio_remove_key(&ddata->data[i]); else{ while (--i >= 0) //for before DVT3. gpio_remove_key(&ddata->data[i]); } platform_set_drvdata(pdev, NULL); fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover);; wake_lock_init(&ddata->flip_wake_lock, WAKE_LOCK_SUSPEND, "flip wake lock"); #endif mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, SW_FLIP); #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; #ifdef KEY_BOOSTER if (button->code == KEY_HOMEPAGE) { error = gpio_key_init_dvfs(bdata); if (error < 0) { dev_err(dev, "Fail get dvfs level for touch booster\n"); goto fail2; } } #endif } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } ddata->sec_key = device_create(sec_class, NULL, 0, ddata, "sec_key"); if (IS_ERR(ddata->sec_key)) dev_err(dev, "Failed to create sec_key device\n"); error = sysfs_create_group(&ddata->sec_key->kobj, &sec_key_attr_group); if (error) { dev_err(dev, "Failed to create the test sysfs: %d\n", error); goto fail2; } #ifdef CONFIG_SENSORS_HALL init_hall_ic_irq(input); #endif error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons */ for (i = 0; i < pdata->nbuttons; i++) gpio_keys_gpio_report_event(&ddata->data[i]); input_sync(input); device_init_wakeup(&pdev->dev, wakeup); return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); sysfs_remove_group(&ddata->sec_key->kobj, &sec_key_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); #ifdef CONFIG_SENSORS_HALL wake_lock_destroy(&ddata->flip_wake_lock); #endif fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; int ret; struct device *sec_key; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; #ifdef CONFIG_SENSORS_HALL ddata->gpio_flip_cover = pdata->gpio_flip_cover; ddata->irq_flip_cover = gpio_to_irq(ddata->gpio_flip_cover); #endif mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; #ifdef CONFIG_SENSORS_HALL input->evbit[0] |= BIT_MASK(EV_SW); input_set_capability(input, EV_SW, SW_FLIP); #endif input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); sec_key = device_create(sec_class, NULL, 0, NULL, "sec_key"); if (IS_ERR(sec_key)) pr_err("Failed to create device(sec_key)!\n"); #if defined(CONFIG_SENSORS_HALL) ret = device_create_file(sec_key, &dev_attr_hall_detect); if (ret < 0) { pr_err("Failed to create device file(%s)!, error: %d\n", dev_attr_hall_detect.attr.name, ret); } #endif ret = device_create_file(sec_key, &dev_attr_sec_key_pressed); if (ret) { pr_err("Failed to create device file in sysfs entries(%s)!\n", dev_attr_sec_key_pressed.attr.name); } ret = device_create_file(sec_key, &dev_attr_wakeup_keys); if (ret < 0) { pr_err("Failed to create device file(%s), error: %d\n", dev_attr_wakeup_keys.attr.name, ret); } dev_set_drvdata(sec_key, ddata); device_init_wakeup(&pdev->dev, wakeup); return 0; fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }
static int __devinit gpio_keys_probe(struct platform_device *pdev) { const struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; struct gpio_keys_drvdata *ddata; struct device *dev = &pdev->dev; struct gpio_keys_platform_data alt_pdata; struct input_dev *input; int i, error; int wakeup = 0; if (!pdata) { error = gpio_keys_get_devtree_pdata(dev, &alt_pdata); if (error) return error; pdata = &alt_pdata; } ddata = kzalloc(sizeof(struct gpio_keys_drvdata) + pdata->nbuttons * sizeof(struct gpio_button_data), GFP_KERNEL); input = input_allocate_device(); if (!ddata || !input) { dev_err(dev, "failed to allocate state\n"); error = -ENOMEM; goto fail1; } ddata->input = input; ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdata->name ? : pdev->name; input->phys = "gpio-keys/input0"; input->dev.parent = &pdev->dev; input->open = gpio_keys_open; input->close = gpio_keys_close; input->id.bustype = BUS_HOST; input->id.vendor = 0x0001; input->id.product = 0x0001; input->id.version = 0x0100; /* Enable auto repeat feature of Linux input subsystem */ if (pdata->rep) __set_bit(EV_REP, input->evbit); for (i = 0; i < pdata->nbuttons; i++) { const struct gpio_keys_button *button = &pdata->buttons[i]; struct gpio_button_data *bdata = &ddata->data[i]; error = gpio_keys_setup_key(pdev, input, bdata, button); if (error) goto fail2; if (button->wakeup) wakeup = 1; } error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group); if (error) { dev_err(dev, "Unable to export keys/switches, error: %d\n", error); goto fail2; } error = input_register_device(input); if (error) { dev_err(dev, "Unable to register input device, error: %d\n", error); goto fail3; } //&*&*&*CT1_20120516, add GSesor lock switch pin detection ddata->lock_status= gpio_get_value(TEGRA_GPIO_PQ2); //get KB_COL2 pin status ddata->sdev.name = FUNCTION_NAME; ddata->sdev.print_name = print_switch_name; ddata->sdev.print_state = print_switch_state; ddata->sdev.state = 0; error = switch_dev_register(&ddata->sdev); if (error < 0) { printk("Error registering switch!\n"); goto fail4; } error = gpio_request(TEGRA_GPIO_PQ2, "glocksensor_irq"); if (error < 0) { dev_err(dev, "failed to request TEGRA_GPIO_PQ2 error %d\n", error); goto fail4; } error = gpio_direction_input(TEGRA_GPIO_PQ2); if (error < 0) { dev_err(dev, "failed to configure direction for TEGRA_GPIO_PQ2 error %d\n", error); goto fail4; } tegra_gpio_enable(TEGRA_GPIO_PQ2); ddata->lock_status= gpio_get_value(TEGRA_GPIO_PQ2); switch_set_state(&ddata->sdev, ddata->lock_status); error = request_threaded_irq(gpio_to_irq(TEGRA_GPIO_PQ2),NULL, process_interrupt, IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING, "glocksensor_irq", ddata); if( error ) { dev_err(dev, "Unable to register swith interrupt device, error: %d\n", error); goto fail5; } //&*&*&*CT2_20120516, add GSesor lock switch pin detection /* get current state of buttons that are connected to GPIOs */ for (i = 0; i < pdata->nbuttons; i++) { struct gpio_button_data *bdata = &ddata->data[i]; if (gpio_is_valid(bdata->button->gpio)) gpio_keys_gpio_report_event(bdata); } input_sync(input); //&*&*&*HC1_20120514 if (input != NULL) g_pwr_input = input; //&*&*&*HC2_20120514 device_init_wakeup(&pdev->dev, wakeup); return 0; //&*&*&*CT1_20120516, add GSesor lock switch pin detection fail5: switch_dev_unregister(&ddata->sdev); fail4: gpio_free(TEGRA_GPIO_PQ2); //&*&*&*CT2_20120516, add GSesor lock switch pin detection fail3: sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group); fail2: while (--i >= 0) gpio_remove_key(&ddata->data[i]); platform_set_drvdata(pdev, NULL); fail1: input_free_device(input); kfree(ddata); /* If we have no platform_data, we allocated buttons dynamically. */ if (!pdev->dev.platform_data) kfree(pdata->buttons); return error; }