static void epen_checksum_read_atBoot(struct wacom_i2c *wac_i2c) { int ret; int val; int i,j; int retry = 3; unsigned char data[6] = {0,}; { disable_irq(wac_i2c->client->irq); data[0] = COM_CHECKSUM; while( retry-- ) { ret = i2c_master_send(wac_i2c->client, &data[0], 1); if( ret < 0 ){ printk(KERN_DEBUG "[E-PEN] i2c fail, retry, %d\n", __LINE__); continue; } msleep(200); ret = i2c_master_recv(wac_i2c->client, data, 5); if( ret < 0 ){ printk(KERN_DEBUG "[E-PEN] i2c fail, retry, %d\n", __LINE__); continue; } else if( data[0] == 0x1f ) break; printk(KERN_DEBUG "[E-PEN] checksum retry\n"); } if (ret >= 0) { printk(KERN_DEBUG "[E-PEN] received checksum %x, %x, %x, %x, %x\n", data[0], data[1], data[2], data[3], data[4]); for( j = 0 ; j < 5; j++ ){ Firmware_checksum_backup[j] = data[j]; } } for( i = 0 ; i < 5; ++i ) { if( data[i] != Firmware_checksum[i] ){ printk(KERN_DEBUG "[E-PEN] checksum fail %dth %d %d\n", i, data[i], Firmware_checksum[i]); break; } } if( i == 5 ) epen_checksum_result = true; else epen_checksum_result = false; enable_irq(wac_i2c->client->irq); printk(KERN_DEBUG "[E-PEN] %s, result %d\n", __func__, epen_checksum_result); } }
static int mipi_lg4573b_lcd_off(struct platform_device *pdev) { struct msm_fb_data_type *mfd; /* LGE_CHANGE_S : LCD ESD Protection * 2012-01-30, [email protected] * LCD ESD Protection */ #ifdef CONFIG_LGE_LCD_ESD_DETECTION bool int_en_wq_ret; bool panel_power_on_wq_ret; if ( (!local_pdev_for_pwm) && (pdev) ) { local_pdev_for_pwm = pdev; } #endif /* LGE_CHANGE_E : LCD ESD Protection*/ mfd = platform_get_drvdata(pdev); if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; printk(KERN_INFO "mipi_lg4573b_chip_lcd_off START\n"); /* LGE_CHANGE_S : LCD ESD Protection * 2012-01-30, [email protected] * LCD ESD Protection */ #ifdef CONFIG_LGE_LCD_ESD_DETECTION /*Set panel power off state to TRUE & flush the INTR EN Work queue*/ /*Don't enable esd irq in wq handler as we are powering off panel */ if( 0 == atomic_read(&lcd_esd->panel_poweroff) ) { atomic_set(&lcd_esd->panel_poweroff,1); } int_en_wq_ret = flush_delayed_work_sync(&lcd_esd->esd_int_en_work); if ( true == int_en_wq_ret ) printk("Waited for intr work to finish \n"); panel_power_on_wq_ret = flush_delayed_work_sync(&lcd_esd->esd_dsi_panel_on); if( true == panel_power_on_wq_ret ) printk("Waited for Panel On work to finish \n"); /*Disable ESD interrupt while powering off*/ if( 1 == atomic_read(&lcd_esd->esd_irq_state)) { disable_irq(lcd_esd->esd_irq); printk("ESD irq Disabled \n"); atomic_set(&lcd_esd->esd_irq_state,0); } #endif /* LGE_CHANGE_E : LCD ESD Protection*/ //LGE_CHANGE_S [Kiran] Change LCD sleep sequence //display off #ifdef CONFIG_LGE_LCD_ESD_DETECTION if(false == is_esd_occured) #endif { mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_disp_off_cmds, ARRAY_SIZE(lg4573b_disp_off_cmds)); msleep(40); } //LGE_CHANGE_E [Kiran] Change LCD sleep sequence /*LGE_CHANGE_S: [email protected] 05-03-2012*/ /*LCD Reset After data pulled Down*/ #if 0 mipi_ldp_lcd_panel_poweroff(); #endif /*LGE_CHANGE_E LCD Reset After Data Pulled Down*/ #ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO lglogo_firstboot = FALSE; #endif /*LCD off end Log added 27-01-2012*/ printk("End %s \n",__func__); return 0; }
/** * @Copyright (C) Anyka 2012 * @brief probe battery * @author Gao wangsheng * @email [email protected] * @date 2012-11-2 * @param[out] void * @param[in] *dev * @return fail or not */ static int __devinit ak_battery_probe(struct platform_device *dev) { int ret = 0; struct ak_bat_mach_info *info; info = (struct ak_bat_mach_info *)dev->dev.platform_data; if (!info) { printk(KERN_ERR "%s:no platform data for battery\n",__func__); ret = -EINVAL; goto nodata_out; } /* initialize hardware */ mutex_init(&bat_device.bat_lock); bat_device.rd_voltage.sample = info->bat_mach_info.voltage_sample; bat_device.rd_voltage.design_max = info->bat_mach_info.max_voltage; init_timer(&bat_device.timer); bat_device.timer.function = bat_charge_full_timer; bat_device.timer.data = (unsigned long) &bat_device; INIT_DELAYED_WORK(&charge_work,bat_charge_work); INIT_DELAYED_WORK(&discharge_work,bat_discharge_work); INIT_DELAYED_WORK(&voltage_work,bat_voltage_work); INIT_DELAYED_WORK(&usbirq_work,bat_usbirq_work); INIT_DELAYED_WORK(&pdown_work,bat_pdown_work); INIT_DELAYED_WORK(&resume_work,bat_resume_work); ret = power_supply_register(&dev->dev, &bat_device.bat_ps); if (ret != 0) { goto cancel_out; } ret = power_supply_register(&dev->dev,&bat_device.usb_ps); if (ret != 0) { goto free_bat_ps_out; } ret = power_supply_register(&dev->dev,&bat_device.ac_ps); if (ret != 0) { goto free_usb_ps_out; } // use for charge full state if (info->full_gpio.pindata.pin >= 0) { info->gpio_init(&info->full_gpio.pindata); } if (info->ac_gpio.is_detect_mode == BAT_CHARGE_GPIO_DETECT) { INIT_DELAYED_WORK(&acirq_work,bat_acirq_work); // use for ac charge in irq if (info->ac_gpio.irq >= 0) { info->gpio_init(&info->ac_gpio.pindata); bat_set_int_inverse(info->ac_gpio.pindata.pin); if (request_irq(info->ac_gpio.irq,akbat_ac_irqhandler,0,"ac_charge",&bat_device)) { printk(KERN_ERR "%s:Could not allocate IRQ %d\n", __func__,info->ac_gpio.irq); ret = -EIO; goto free_ac_ps_out; } } } else if (info->ac_gpio.is_detect_mode == BAT_CHARGE_ADC_DETECT) { memset(&ac_detect_nb, 0, sizeof(ac_detect_nb)); ac_detect_nb.notifier_call = ac_detect_plugin; addetect_register_client(&ac_detect_nb); } // use for usb charge in irq if (info->usb_gpio.irq >= 0) { info->gpio_init(&info->usb_gpio.pindata); mdelay(100); bat_set_int_inverse(info->usb_gpio.pindata.pin); if (request_irq(info->usb_gpio.irq,akbat_usb_irqhandler,0,"usb_charge",&bat_device)) { printk(KERN_ERR "%s:Could not allocate IRQ %d\n", __func__,info->usb_gpio.irq); ret = -EIO; goto free_acirq_out; } } ak_bat_update(&bat_device); schedule_delayed_work(&voltage_work,UPDATE_VOLTAGE_DELAY); register_reboot_notifier(&battery_reboot_nb); bat_print_battery_info(&bat_device); printk("AK Battery initialized\n"); return ret; free_acirq_out: if (info->ac_gpio.irq > 0) { disable_irq(info->ac_gpio.irq); free_irq(info->ac_gpio.irq, dev); } free_ac_ps_out: power_supply_unregister(&bat_device.ac_ps); free_usb_ps_out: power_supply_unregister(&bat_device.usb_ps); free_bat_ps_out: power_supply_unregister(&bat_device.bat_ps); cancel_out: del_timer_sync(&bat_device.timer); cancel_delayed_work_sync(&charge_work); cancel_delayed_work_sync(&discharge_work); cancel_delayed_work_sync(&voltage_work); cancel_delayed_work_sync(&usbirq_work); cancel_delayed_work_sync(&acirq_work); cancel_delayed_work_sync(&pdown_work); cancel_delayed_work_sync(&resume_work); nodata_out: printk(KERN_ERR "###########%s:ERR out##########\n",__func__); return ret; }
static int htc_headset_pmic_probe(struct platform_device *pdev) { int ret = 0; struct htc_headset_pmic_platform_data *pdata = pdev->dev.platform_data; #ifdef HTC_HEADSET_CONFIG_MSM_RPC uint32_t vers = 0; #endif HS_LOG("++++++++++++++++++++"); hi = kzalloc(sizeof(struct htc_35mm_pmic_info), GFP_KERNEL); if (!hi) return -ENOMEM; hi->pdata.driver_flag = pdata->driver_flag; hi->pdata.hpin_gpio = pdata->hpin_gpio; hi->pdata.hpin_irq = pdata->hpin_irq; hi->pdata.key_gpio = pdata->key_gpio; hi->pdata.key_irq = pdata->key_irq; hi->pdata.key_enable_gpio = pdata->key_enable_gpio; hi->pdata.adc_mpp = pdata->adc_mpp; hi->pdata.adc_amux = pdata->adc_amux; hi->pdata.hs_controller = pdata->hs_controller; hi->pdata.hs_switch = pdata->hs_switch; hi->pdata.adc_mic = pdata->adc_mic; hi->htc_accessory_class = hs_get_attribute_class(); register_attributes(); if (!hi->pdata.adc_mic) hi->pdata.adc_mic = HS_DEF_MIC_ADC_16_BIT_MIN; if (pdata->adc_mic_bias[0] && pdata->adc_mic_bias[1]) { memcpy(hi->pdata.adc_mic_bias, pdata->adc_mic_bias, sizeof(hi->pdata.adc_mic_bias)); hi->pdata.adc_mic = hi->pdata.adc_mic_bias[0]; } else { hi->pdata.adc_mic_bias[0] = hi->pdata.adc_mic; hi->pdata.adc_mic_bias[1] = HS_DEF_MIC_ADC_16_BIT_MAX; } if (pdata->adc_remote[5]) memcpy(hi->pdata.adc_remote, pdata->adc_remote, sizeof(hi->pdata.adc_remote)); if (pdata->adc_metrico[0] && pdata->adc_metrico[1]) memcpy(hi->pdata.adc_metrico, pdata->adc_metrico, sizeof(hi->pdata.adc_metrico)); hi->hpin_irq_type = IRQF_TRIGGER_NONE; hi->hpin_debounce = HS_JIFFIES_ZERO; hi->key_irq_type = IRQF_TRIGGER_NONE; wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME); detect_wq = create_workqueue("HS_PMIC_DETECT"); if (detect_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create detect workqueue"); goto err_create_detect_work_queue; } button_wq = create_workqueue("HS_PMIC_BUTTON"); if (button_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create button workqueue"); goto err_create_button_work_queue; } if (hi->pdata.hpin_gpio) { ret = hs_pmic_request_irq(hi->pdata.hpin_gpio, &hi->pdata.hpin_irq, detect_irq_handler, hi->hpin_irq_type, "HS_PMIC_DETECT", 1); if (ret < 0) { HS_ERR("Failed to request PMIC HPIN IRQ (0x%X)", ret); goto err_request_detect_irq; } disable_irq(hi->pdata.hpin_irq); } if (hi->pdata.key_gpio) { ret = hs_pmic_request_irq(hi->pdata.key_gpio, &hi->pdata.key_irq, button_irq_handler, hi->key_irq_type, "HS_PMIC_BUTTON", 1); if (ret < 0) { HS_ERR("Failed to request PMIC button IRQ (0x%X)", ret); goto err_request_button_irq; } disable_irq(hi->pdata.key_irq); } #ifdef HTC_HEADSET_CONFIG_MSM_RPC if (hi->pdata.driver_flag & DRIVER_HS_PMIC_RPC_KEY) { /* Register ADC RPC client */ endpoint_adc = msm_rpc_connect(HS_RPC_CLIENT_PROG, HS_RPC_CLIENT_VERS, 0); if (IS_ERR(endpoint_adc)) { hi->pdata.driver_flag &= ~DRIVER_HS_PMIC_RPC_KEY; HS_LOG("Failed to register ADC RPC client"); } else HS_LOG("Register ADC RPC client successfully"); } if (hi->pdata.driver_flag & DRIVER_HS_PMIC_DYNAMIC_THRESHOLD) { /* Register threshold RPC client */ vers = HS_PMIC_RPC_CLIENT_VERS_3_1; endpoint_current = msm_rpc_connect_compatible( HS_PMIC_RPC_CLIENT_PROG, vers, 0); if (!endpoint_current) { vers = HS_PMIC_RPC_CLIENT_VERS_2_1; endpoint_current = msm_rpc_connect( HS_PMIC_RPC_CLIENT_PROG, vers, 0); } if (!endpoint_current) { vers = HS_PMIC_RPC_CLIENT_VERS_1_1; endpoint_current = msm_rpc_connect( HS_PMIC_RPC_CLIENT_PROG, vers, 0); } if (!endpoint_current) { vers = HS_PMIC_RPC_CLIENT_VERS; endpoint_current = msm_rpc_connect( HS_PMIC_RPC_CLIENT_PROG, vers, 0); } if (IS_ERR(endpoint_current)) { hi->pdata.driver_flag &= ~DRIVER_HS_PMIC_DYNAMIC_THRESHOLD; HS_LOG("Failed to register threshold RPC client"); } else HS_LOG("Register threshold RPC client successfully" " (0x%X)", vers); } #else hi->pdata.driver_flag &= ~DRIVER_HS_PMIC_RPC_KEY; hi->pdata.driver_flag &= ~DRIVER_HS_PMIC_DYNAMIC_THRESHOLD; #endif queue_delayed_work(detect_wq, &irq_init_work, HS_JIFFIES_IRQ_INIT); hs_pmic_register(); hs_notify_driver_ready(DRIVER_NAME); HS_LOG("--------------------"); return 0; err_request_button_irq: if (hi->pdata.hpin_gpio) { free_irq(hi->pdata.hpin_irq, 0); gpio_free(hi->pdata.hpin_gpio); } err_request_detect_irq: destroy_workqueue(button_wq); err_create_button_work_queue: destroy_workqueue(detect_wq); err_create_detect_work_queue: wake_lock_destroy(&hi->hs_wake_lock); kfree(hi); HS_ERR("Failed to register %s driver", DRIVER_NAME); return ret; }
static int __devinit csid_probe(struct platform_device *pdev) { struct csid_device *new_csid_dev; uint32_t csi_vdd_voltage = 0; int rc = 0; new_csid_dev = kzalloc(sizeof(struct csid_device), GFP_KERNEL); if (!new_csid_dev) { pr_err("%s: no enough memory\n", __func__); return -ENOMEM; } v4l2_subdev_init(&new_csid_dev->msm_sd.sd, &msm_csid_subdev_ops); v4l2_set_subdevdata(&new_csid_dev->msm_sd.sd, new_csid_dev); platform_set_drvdata(pdev, &new_csid_dev->msm_sd.sd); mutex_init(&new_csid_dev->mutex); if (pdev->dev.of_node) { rc = of_property_read_u32((&pdev->dev)->of_node, "cell-index", &pdev->id); if (rc < 0) { pr_err("%s:%d failed to read cell-index\n", __func__, __LINE__); goto csid_no_resource; } CDBG("%s device id %d\n", __func__, pdev->id); rc = of_property_read_u32((&pdev->dev)->of_node, "qcom,csi-vdd-voltage", &csi_vdd_voltage); if (rc < 0) { pr_err("%s:%d failed to read qcom,csi-vdd-voltage\n", __func__, __LINE__); goto csid_no_resource; } CDBG("%s:%d reading mipi_csi_vdd is %d\n", __func__, __LINE__, csi_vdd_voltage); csid_vreg_info[0].min_voltage = csi_vdd_voltage; csid_vreg_info[0].max_voltage = csi_vdd_voltage; } new_csid_dev->mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "csid"); if (!new_csid_dev->mem) { pr_err("%s: no mem resource?\n", __func__); rc = -ENODEV; goto csid_no_resource; } new_csid_dev->irq = platform_get_resource_byname(pdev, IORESOURCE_IRQ, "csid"); if (!new_csid_dev->irq) { pr_err("%s: no irq resource?\n", __func__); rc = -ENODEV; goto csid_no_resource; } new_csid_dev->io = request_mem_region(new_csid_dev->mem->start, resource_size(new_csid_dev->mem), pdev->name); if (!new_csid_dev->io) { pr_err("%s: no valid mem region\n", __func__); rc = -EBUSY; goto csid_no_resource; } new_csid_dev->pdev = pdev; new_csid_dev->msm_sd.sd.internal_ops = &msm_csid_internal_ops; new_csid_dev->msm_sd.sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; snprintf(new_csid_dev->msm_sd.sd.name, ARRAY_SIZE(new_csid_dev->msm_sd.sd.name), "msm_csid"); media_entity_init(&new_csid_dev->msm_sd.sd.entity, 0, NULL, 0); new_csid_dev->msm_sd.sd.entity.type = MEDIA_ENT_T_V4L2_SUBDEV; new_csid_dev->msm_sd.sd.entity.group_id = MSM_CAMERA_SUBDEV_CSID; new_csid_dev->msm_sd.close_seq = MSM_SD_CLOSE_2ND_CATEGORY | 0x5; msm_sd_register(&new_csid_dev->msm_sd); rc = request_irq(new_csid_dev->irq->start, msm_csid_irq, IRQF_TRIGGER_RISING, "csid", new_csid_dev); if (rc < 0) { release_mem_region(new_csid_dev->mem->start, resource_size(new_csid_dev->mem)); pr_err("%s: irq request fail\n", __func__); rc = -EBUSY; goto csid_no_resource; } disable_irq(new_csid_dev->irq->start); if (rc < 0) { release_mem_region(new_csid_dev->mem->start, resource_size(new_csid_dev->mem)); pr_err("%s Error registering irq ", __func__); goto csid_no_resource; } new_csid_dev->csid_state = CSID_POWER_DOWN; return 0; csid_no_resource: mutex_destroy(&new_csid_dev->mutex); kfree(new_csid_dev); return 0; }
static void arc_disable_irq(struct parport *p) { disable_irq(p->irq); }
static int __devinit wl1251_spi_probe(struct spi_device *spi) { struct wl12xx_platform_data *pdata; struct ieee80211_hw *hw; struct wl1251 *wl; int ret; pdata = spi->dev.platform_data; if (!pdata) { wl1251_error("no platform data"); return -ENODEV; } hw = wl1251_alloc_hw(); if (IS_ERR(hw)) return PTR_ERR(hw); wl = hw->priv; SET_IEEE80211_DEV(hw, &spi->dev); dev_set_drvdata(&spi->dev, wl); wl->if_priv = spi; wl->if_ops = &wl1251_spi_ops; /* This is the only SPI value that we need to set here, the rest * comes from the board-peripherals file */ spi->bits_per_word = 32; ret = spi_setup(spi); if (ret < 0) { wl1251_error("spi_setup failed"); goto out_free; } wl->set_power = pdata->set_power; if (!wl->set_power) { wl1251_error("set power function missing in platform data"); return -ENODEV; } wl->irq = spi->irq; if (wl->irq < 0) { wl1251_error("irq missing in platform data"); return -ENODEV; } wl->use_eeprom = pdata->use_eeprom; ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); if (ret < 0) { wl1251_error("request_irq() failed: %d", ret); goto out_free; } set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); disable_irq(wl->irq); ret = wl1251_init_ieee80211(wl); if (ret) goto out_irq; return 0; out_irq: free_irq(wl->irq, wl); out_free: ieee80211_free_hw(hw); return ret; }
static void Q7x27_kybd_volkey2(struct work_struct *work) { struct Q7x27_kybd_record *kbdrec= container_of(work, struct Q7x27_kybd_record, kybd_volkey2); struct input_dev *idev = kbdrec->Q7x27_kybd_idev; bool debounceDelay = false; bool voldn_val = (bool)gpio_get_value(kbdrec->voldn_pin); //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++misty suspend_state_t SuspendState = PM_SUSPEND_ON;//0 //-----------------------------------------------------------------misty /* FIH, PeterKCTseng, @20090520 { */ /* The active type of input pin */ #if ACTIVE_MODE_ENABLE // Peter, Debug bool state; #endif /* } FIH, PeterKCTseng, @20090520 */ //fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"[Misty]VOL DN <%d>\n", voldn_val); //printk(KERN_INFO "VOL DN <%d>\n", voldn_val); disable_irq(MSM_GPIO_TO_INT(kbdrec->voldn_pin)); //+++++++++++++++++++++++++++++++FIH_F0X_misty if(EnableKeyInt) { SuspendState = get_suspend_state(); if(SuspendState == PM_SUSPEND_MEM) { if(idev) { input_report_key(idev, KEY_VOLUMEDOWN, KBD_IN_KEYPRESS); //printk(KERN_INFO "FIH: keypress KEY_VOLUMEDOWN\n"); fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"FIH: keypress KEY_VOLUMEDOWNP\n"); input_report_key(idev, KEY_VOLUMEDOWN, KBD_IN_KEYRELEASE); //printk(KERN_INFO "FIH: keyrelease KEY_VOLUMEDOWN\n"); fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"FIH: keyrelease KEY_VOLUMEDOWN\n"); input_sync(idev); } } //-------------------------------FIH_F0X_misty else { /* FIH, PeterKCTseng, @20090520 { */ /* The active type of input pin */ #if ACTIVE_MODE_ENABLE // Peter, Debug state = (kbdrec->active.voldn_pin_actype == ACTIVE_HIGH) ? voldn_val : !voldn_val; //printk(KERN_INFO "active type= %d \n", state); #endif /* } FIH, PeterKCTseng, @20090520 */ if(idev) { if (state) { input_report_key(idev, KEY_VOLUMEDOWN, KBD_IN_KEYPRESS); //printk(KERN_INFO "FIH: keypress KEY_VOLUMEDOWN\n"); fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"FIH: keypress KEY_VOLUMEDOWN\n"); // FIH, WillChen, 2009/08/14 ++ //Press VolumeUp+VolumeDown+End key to force panic and dump log #ifdef CONFIG_FIH_FXX_FORCEPANIC VDN_Key = true; if (VUP_Key && VDN_Key && END_key) { printk(KERN_ERR "KPD: Three key panic!!\n"); flag = 1; wake_up(&wq); msleep(5000); panic("Three key panic"); } #endif // FIH, WillChen, 2009/08/14 -- } else { input_report_key(idev, KEY_VOLUMEDOWN, KBD_IN_KEYRELEASE); //printk(KERN_INFO "FIH: keyrelease KEY_VOLUMEDOWN\n"); fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"FIH: keyrelease KEY_VOLUMEDOWN\n"); debounceDelay = true; // FIH, WillChen, 2009/08/14 ++ //Press VolumeUp+VolumeDown+End key to force panic and dump log #ifdef CONFIG_FIH_FXX_FORCEPANIC VDN_Key = false; #endif // FIH, WillChen, 2009/08/14 -- } input_sync(idev); //printk(KERN_INFO "FIH: keypress KEY_VOLUMEDOWN\n"); fih_printk(Q7x27_kybd_debug_mask, FIH_DEBUG_ZONE_G0,"FIH: keypress KEY_VOLUMEDOWN\n"); } if (debounceDelay) { mdelay(KBD_DEBOUNCE_TIME); //Debounce } } }//if(EnableKeyInt) enable_irq(MSM_GPIO_TO_INT(kbdrec->voldn_pin)); }
static int msm_i2c_recover_bus_busy(struct msm_i2c_dev *dev, struct i2c_adapter *adap) { int i; int gpio_clk; int gpio_dat; uint32_t status = readl(dev->base + I2C_STATUS); bool gpio_clk_status = false; if (!(status & (I2C_STATUS_BUS_ACTIVE | I2C_STATUS_WR_BUFFER_FULL))) return 0; dev->pdata->msm_i2c_config_gpio(adap->nr, 0); /* Even adapter is primary and Odd adapter is AUX */ if (adap->nr % 2) { gpio_clk = dev->pdata->aux_clk; gpio_dat = dev->pdata->aux_dat; } else { gpio_clk = dev->pdata->pri_clk; gpio_dat = dev->pdata->pri_dat; } disable_irq(dev->irq); if (status & I2C_STATUS_RD_BUFFER_FULL) { dev_warn(dev->dev, "Read buffer full, status %x, intf %x\n", status, readl(dev->base + I2C_INTERFACE_SELECT)); writel(I2C_WRITE_DATA_LAST_BYTE, dev->base + I2C_WRITE_DATA); readl(dev->base + I2C_READ_DATA); } else if (status & I2C_STATUS_BUS_MASTER) { dev_warn(dev->dev, "Still the bus master, status %x, intf %x\n", status, readl(dev->base + I2C_INTERFACE_SELECT)); writel(I2C_WRITE_DATA_LAST_BYTE | 0xff, dev->base + I2C_WRITE_DATA); } for (i = 0; i < 9; i++) { if (gpio_get_value(gpio_dat) && gpio_clk_status) break; gpio_direction_output(gpio_clk, 0); udelay(5); gpio_direction_output(gpio_dat, 0); udelay(5); gpio_direction_input(gpio_clk); udelay(5); if (!gpio_get_value(gpio_clk)) udelay(20); if (!gpio_get_value(gpio_clk)) msleep(10); gpio_clk_status = gpio_get_value(gpio_clk); gpio_direction_input(gpio_dat); udelay(5); } dev->pdata->msm_i2c_config_gpio(adap->nr, 1); udelay(10); status = readl(dev->base + I2C_STATUS); if (!(status & I2C_STATUS_BUS_ACTIVE)) { dev_info(dev->dev, "Bus busy cleared after %d clock cycles, " "status %x, intf %x\n", i, status, readl(dev->base + I2C_INTERFACE_SELECT)); enable_irq(dev->irq); return 0; } dev_err(dev->dev, "Bus still busy, status %x, intf %x\n", status, readl(dev->base + I2C_INTERFACE_SELECT)); enable_irq(dev->irq); return -EBUSY; }
static void dma_ints_off(struct NCR_ESP *esp) { disable_irq(esp->irq); }
static int msm_hsic_suspend(struct msm_hsic_hcd *mehci) { struct usb_hcd *hcd = hsic_to_hcd(mehci); int cnt = 0, ret; u32 val; int none_vol, max_vol; if (atomic_read(&mehci->in_lpm)) { dev_dbg(mehci->dev, "%s called in lpm\n", __func__); return 0; } disable_irq(hcd->irq); /* make sure we don't race against a remote wakeup */ if (test_bit(HCD_FLAG_WAKEUP_PENDING, &hcd->flags) || readl_relaxed(USB_PORTSC) & PORT_RESUME) { dev_dbg(mehci->dev, "wakeup pending, aborting suspend\n"); enable_irq(hcd->irq); return -EBUSY; } /* * PHY may take some time or even fail to enter into low power * mode (LPM). Hence poll for 500 msec and reset the PHY and link * in failure case. */ val = readl_relaxed(USB_PORTSC); val &= ~PORT_RWC_BITS; val |= PORTSC_PHCD; writel_relaxed(val, USB_PORTSC); while (cnt < PHY_SUSPEND_TIMEOUT_USEC) { if (readl_relaxed(USB_PORTSC) & PORTSC_PHCD) break; udelay(1); cnt++; } if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) { dev_err(mehci->dev, "Unable to suspend PHY\n"); msm_hsic_config_gpios(mehci, 0); msm_hsic_reset(mehci); } /* * PHY has capability to generate interrupt asynchronously in low * power mode (LPM). This interrupt is level triggered. So USB IRQ * line must be disabled till async interrupt enable bit is cleared * in USBCMD register. Assert STP (ULPI interface STOP signal) to * block data communication from PHY. */ writel_relaxed(readl_relaxed(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD); /* * Ensure that hardware is put in low power mode before * clocks are turned OFF and VDD is allowed to minimize. */ mb(); clk_disable_unprepare(mehci->core_clk); clk_disable_unprepare(mehci->phy_clk); clk_disable_unprepare(mehci->cal_clk); clk_disable_unprepare(mehci->ahb_clk); none_vol = vdd_val[mehci->vdd_type][VDD_NONE]; max_vol = vdd_val[mehci->vdd_type][VDD_MAX]; ret = regulator_set_voltage(mehci->hsic_vddcx, none_vol, max_vol); if (ret < 0) dev_err(mehci->dev, "unable to set vddcx voltage for VDD MIN\n"); if (mehci->bus_perf_client && debug_bus_voting_enabled) { mehci->bus_vote = false; queue_work(ehci_wq, &mehci->bus_vote_w); } atomic_set(&mehci->in_lpm, 1); enable_irq(hcd->irq); mehci->wakeup_irq_enabled = 1; enable_irq_wake(mehci->wakeup_irq); enable_irq(mehci->wakeup_irq); wake_unlock(&mehci->wlock); dev_dbg(mehci->dev, "HSIC-USB in low power mode\n");//ztebsp zhangjing---yuanjinxing 20130221 return 0; }
static void exynos4_handler_tmu_state(struct work_struct *work) { struct delayed_work *delayed_work = to_delayed_work(work); struct s5p_tmu_info *info = container_of(delayed_work, struct s5p_tmu_info, polling); struct s5p_platform_tmu *data = info->dev->platform_data; unsigned int cur_temp; static int auto_refresh_changed; static int check_handle; int trend = 0; mutex_lock(&tmu_lock); cur_temp = get_curr_temp(info); trend = cur_temp - info->last_temperature; pr_debug("curr_temp = %d, temp_diff = %d\n", cur_temp, trend); switch (info->tmu_state) { case TMU_STATUS_NORMAL: /* 1. change state: 1st-throttling */ if (cur_temp >= data->ts.start_1st_throttle) { info->tmu_state = TMU_STATUS_THROTTLED; pr_info("change state: normal->throttle.\n"); /* 2. polling end and uevent */ } else if ((cur_temp <= data->ts.stop_1st_throttle) && (trend < 0) && (cur_temp <= data->ts.stop_mem_throttle)) { if (check_handle & THROTTLE_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(THROTTLE_FLAG); } pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); pr_info("normal: free cpufreq_limit & interrupt enable.\n"); /* clear to prevent from interfupt by peindig bit */ __raw_writel(INTCLEARALL, info->tmu_base + EXYNOS4_TMU_INTCLEAR); enable_irq(info->irq); mutex_unlock(&tmu_lock); return; } break; case TMU_STATUS_THROTTLED: /* 1. change state: 2nd-throttling or warning */ if (cur_temp >= data->ts.start_2nd_throttle) { info->tmu_state = TMU_STATUS_WARNING; pr_info("change state: 1st throttle->2nd throttle.\n"); /* 2. cpufreq limitation and uevent */ } else if ((cur_temp >= data->ts.start_1st_throttle) && (trend > 0) && !(check_handle & THROTTLE_FLAG)) { if (check_handle & WARNING_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(WARNING_FLAG); } exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->cpufreq_level_1st_throttle); check_handle |= THROTTLE_FLAG; pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); pr_info("throttling: set cpufreq upper limit.\n"); /* 3. change state: normal */ } else if ((cur_temp <= data->ts.stop_1st_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_NORMAL; pr_info("change state: 1st throttle->normal.\n"); } break; case TMU_STATUS_WARNING: /* 1. change state: tripping */ if (cur_temp >= data->ts.start_tripping) { info->tmu_state = TMU_STATUS_TRIPPED; pr_info("change state: 2nd throttle->trip\n"); /* 2. cpufreq limitation and uevent */ } else if ((cur_temp >= data->ts.start_2nd_throttle) && (trend > 0) && !(check_handle & WARNING_FLAG)) { if (check_handle & THROTTLE_FLAG) { exynos_cpufreq_upper_limit_free(DVFS_LOCK_ID_TMU); check_handle &= ~(THROTTLE_FLAG); } exynos_cpufreq_upper_limit(DVFS_LOCK_ID_TMU, info->cpufreq_level_2nd_throttle); check_handle |= WARNING_FLAG; pr_debug("check_handle = %d\n", check_handle); notify_change_of_tmu_state(info); pr_info("2nd throttle: cpufreq is limited.\n"); /* 3. change state: 1st-throttling */ } else if ((cur_temp <= data->ts.stop_2nd_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_THROTTLED; pr_info("change state: 2nd throttle->1st throttle, " "and release cpufreq upper limit.\n"); } break; case TMU_STATUS_TRIPPED: /* 1. call uevent to shut-down */ if ((cur_temp >= data->ts.start_tripping) && (trend > 0) && !(check_handle & TRIPPING_FLAG)) { notify_change_of_tmu_state(info); pr_info("tripping: on waiting shutdown.\n"); check_handle |= TRIPPING_FLAG; pr_debug("check_handle = %d\n", check_handle); /* 2. change state: 2nd-throttling or warning */ } else if ((cur_temp <= data->ts.stop_2nd_throttle) && (trend < 0)) { info->tmu_state = TMU_STATUS_WARNING; pr_info("change state: trip->2nd throttle, " "Check! occured only test mode.\n"); } /* 3. chip protection: kernel panic as SW workaround */ if ((cur_temp >= data->ts.start_emergency) && (trend > 0)) { panic("Emergency!!!! tripping is not treated!\n"); /* clear to prevent from interfupt by peindig bit */ __raw_writel(INTCLEARALL, info->tmu_state + EXYNOS4_TMU_INTCLEAR); enable_irq(info->irq); mutex_unlock(&tmu_lock); return; } break; case TMU_STATUS_INIT: /* sned tmu initial status to platform */ disable_irq(info->irq); if (cur_temp >= data->ts.start_tripping) info->tmu_state = TMU_STATUS_TRIPPED; else if (cur_temp >= data->ts.start_2nd_throttle) info->tmu_state = TMU_STATUS_WARNING; else if (cur_temp >= data->ts.start_1st_throttle) info->tmu_state = TMU_STATUS_THROTTLED; else if (cur_temp <= data->ts.stop_1st_throttle) info->tmu_state = TMU_STATUS_NORMAL; notify_change_of_tmu_state(info); pr_info("%s: inform to init state to platform.\n", __func__); break; default: pr_warn("Bug: checked tmu_state.\n"); if (cur_temp >= data->ts.start_tripping) info->tmu_state = TMU_STATUS_TRIPPED; else info->tmu_state = TMU_STATUS_WARNING; break; } /* end */ /* memory throttling */ if (cur_temp >= data->ts.start_mem_throttle) { if (!(auto_refresh_changed) && (trend > 0)) { pr_info("set auto_refresh 1.95us\n"); set_refresh_rate(info->auto_refresh_tq0); auto_refresh_changed = 1; } } else if (cur_temp <= (data->ts.stop_mem_throttle)) { if ((auto_refresh_changed) && (trend < 0)) { pr_info("set auto_refresh 3.9us\n"); set_refresh_rate(info->auto_refresh_normal); auto_refresh_changed = 0; } } info->last_temperature = cur_temp; /* reschedule the next work */ queue_delayed_work_on(0, tmu_monitor_wq, &info->polling, info->sampling_rate); mutex_unlock(&tmu_lock); return; }
static void amiga_disable_irq(struct parport *p) { disable_irq(IRQ_AMIGA_CIAA_FLG); }
static int wacom_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct wacom_i2c *wac_i2c; struct wacom_g5_platform_data *pdata = client->dev.platform_data; int i, ret; i = ret = 0; printk(KERN_DEBUG "[E-PEN]:%s:\n", __func__); /*Check I2C functionality*/ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) goto err3; /*Obtain kernel memory space for wacom i2c*/ wac_i2c = kzalloc(sizeof(struct wacom_i2c), GFP_KERNEL); if (wac_i2c == NULL) goto fail; wac_i2c->wac_feature = &wacom_feature_EMR; pdata->init_platform_hw(); /*Initializing for semaphor*/ mutex_init(&wac_i2c->lock); /*Register platform data*/ wac_i2c->wac_pdata = client->dev.platform_data; /*Register callbacks*/ wac_i2c->callbacks.check_prox = wacom_check_emr_prox; if (wac_i2c->wac_pdata->register_cb) wac_i2c->wac_pdata->register_cb(&wac_i2c->callbacks); /*Register wacom i2c to input device*/ wac_i2c->input_dev = input_allocate_device(); if (wac_i2c == NULL || wac_i2c->input_dev == NULL) goto fail; wacom_i2c_set_input_values(client, wac_i2c, wac_i2c->input_dev); wac_i2c->client = client; wac_i2c->irq = client->irq; /*Change below if irq is needed*/ wac_i2c->irq_flag = 1; #ifdef CONFIG_HAS_EARLYSUSPEND wac_i2c->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; wac_i2c->early_suspend.suspend = wacom_i2c_early_suspend; wac_i2c->early_suspend.resume = wacom_i2c_late_resume; register_early_suspend(&wac_i2c->early_suspend); #endif /*Init Featreus by hw rev*/ #if defined(CONFIG_USA_MODEL_SGH_I717) if( get_hw_rev() == 0x01 ) { printk("[E-PEN] Wacom driver is working for 4.4mm pitch pad.\n"); /* Firmware Feature */ Firmware_version_of_file = 0x340; Binary = Binary_44; } else if( get_hw_rev() >= HWREV_PEN_PITCH4P4 ) { printk("[E-PEN] Wacom driver is working for 4.4mm pitch pad.\n"); /* Firmware Feature */ Firmware_version_of_file = Firmware_version_of_file_44; Binary = Binary_44; } #else if( get_hw_rev() >= HWREV_PEN_PITCH4P4 ) { printk("[E-PEN] Wacom driver is working for 4.4mm pitch pad.\n"); /* Firmware Feature */ Firmware_version_of_file = Firmware_version_of_file_44; Binary = Binary_44; } else { printk("[E-PEN] Wacom driver is working for 4.8mm pitch pad.\n"); /* Firmware Feature */ Firmware_version_of_file = Firmware_version_of_file_48; Binary = Binary_48; } #endif init_offset_tables(); INIT_WORK(&wac_i2c->update_work, update_work_func); INIT_DELAYED_WORK(&wac_i2c->resume_work, wacom_i2c_resume_work); /* Reset IC */ #if defined(CONFIG_USA_MODEL_SGH_I717) gpio_set_value(GPIO_PEN_RESET, 0); msleep(200); gpio_set_value(GPIO_PEN_RESET, 1); msleep(200); #else gpio_set_value(GPIO_PEN_RESET, 0); msleep(120); gpio_set_value(GPIO_PEN_RESET, 1); msleep(15); #endif ret = wacom_i2c_query(wac_i2c); if( ret < 0 ) epen_reset_result = false; else epen_reset_result = true; input_set_abs_params(wac_i2c->input_dev, ABS_X, pdata->min_x, pdata->max_x, 4, 0); input_set_abs_params(wac_i2c->input_dev, ABS_Y, pdata->min_y, pdata->max_y, 4, 0); input_set_abs_params(wac_i2c->input_dev, ABS_PRESSURE, pdata->min_pressure, pdata->max_pressure, 0, 0); input_set_drvdata(wac_i2c->input_dev, wac_i2c); /*Set client data*/ i2c_set_clientdata(client, wac_i2c); /*Before registering input device, data in each input_dev must be set*/ if (input_register_device(wac_i2c->input_dev)) goto err2; g_client = client; /* if(wac_i2c->irq_flag) */ /* disable_irq(wac_i2c->irq); */ sec_epen= device_create(sec_class, NULL, 0, NULL, "sec_epen"); dev_set_drvdata(sec_epen, wac_i2c); if (IS_ERR(sec_epen)) printk(KERN_ERR "Failed to create device(sec_epen)!\n"); if (device_create_file(sec_epen, &dev_attr_epen_firm_update)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_firm_update.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_firm_update_status)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_firm_update_status.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_firm_version)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_firm_version.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_rotation)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_rotation.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_hand)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_hand.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_reset)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_reset.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_reset_result)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_reset_result.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_checksum)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_checksum.attr.name); if (device_create_file(sec_epen, &dev_attr_epen_checksum_result)< 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_epen_checksum_result.attr.name); if (device_create_file(sec_epen, &dev_attr_set_epen_module_off) < 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_set_epen_module_off.attr.name); if (device_create_file(sec_epen, &dev_attr_set_epen_module_on) < 0) printk(KERN_ERR "Failed to create device file(%s)!\n", dev_attr_set_epen_module_on.attr.name); /*Request IRQ*/ if (wac_i2c->irq_flag) { ret = request_threaded_irq(wac_i2c->irq, NULL, wacom_interrupt, IRQF_DISABLED|IRQF_TRIGGER_RISING|IRQF_ONESHOT, wac_i2c->name, wac_i2c); if (ret < 0) goto err1; } /* firmware update */ printk(KERN_NOTICE "[E-PEN] wacom fw ver : 0x%x, new fw ver : 0x%x\n", wac_i2c->wac_feature->fw_version, Firmware_version_of_file); if( wac_i2c->wac_feature->fw_version < Firmware_version_of_file ) { #if defined(CONFIG_KOR_MODEL_SHV_E160S) || defined(CONFIG_KOR_MODEL_SHV_E160K) || defined(CONFIG_KOR_MODEL_SHV_E160L) printk("[E-PEN] %s\n", __func__); disable_irq(wac_i2c->irq); printk(KERN_NOTICE "[E-PEN]: INIT_FIRMWARE_FLASH is enabled.\n"); ret = wacom_i2c_flash(wac_i2c); msleep(800); printk(KERN_ERR "[E-PEN]: flashed.(%d)\n", ret); wacom_i2c_query(wac_i2c); enable_irq(wac_i2c->irq); #else schedule_work(&wac_i2c->update_work); #endif } /* To send exact checksum data at sleep state ... Xtopher */ printk(KERN_ERR"[E-PEN]: Verify CHECKSUM.\n"); epen_checksum_read_atBoot(wac_i2c); msleep(20); return 0; err3: printk(KERN_ERR "[E-PEN]: No I2C functionality found\n"); return -ENODEV; err2: printk(KERN_ERR "[E-PEN]: err2 occured\n"); input_free_device(wac_i2c->input_dev); return -EIO; err1: printk(KERN_ERR "[E-PEN]: err1 occured(num:%d)\n", ret); input_free_device(wac_i2c->input_dev); wac_i2c->input_dev = NULL; return -EIO; fail: printk(KERN_ERR "[E-PEN]: fail occured\n"); return -ENOMEM; }
void disable_timer() { disable_irq(TIMER_IRQ); }
static int msm_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) { DECLARE_COMPLETION_ONSTACK(complete); struct msm_i2c_dev *dev = i2c_get_adapdata(adap); int ret; int rem = num; uint16_t addr; long timeout; unsigned long flags; int check_busy = 1; mutex_lock(&dev->mlock); if (dev->suspended) { mutex_unlock(&dev->mlock); return -EIO; } /* Don't allow power collapse until we release remote spinlock */ pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY, "msm_i2c", dev->pdata->pm_lat); msm_i2c_rmutex_lock(dev); if (adap == &dev->adap_pri) writel(0, dev->base + I2C_INTERFACE_SELECT); else writel(I2C_INTERFACE_SELECT_INTF_SELECT, dev->base + I2C_INTERFACE_SELECT); enable_irq(dev->irq); while (rem) { addr = msgs->addr << 1; if (msgs->flags & I2C_M_RD) addr |= 1; spin_lock_irqsave(&dev->lock, flags); dev->msg = msgs; dev->rem = rem; dev->pos = 0; dev->err = 0; dev->flush_cnt = 0; dev->cnt = msgs->len; dev->complete = &complete; spin_unlock_irqrestore(&dev->lock, flags); if (check_busy) { ret = msm_i2c_poll_notbusy(dev); if (ret) ret = msm_i2c_recover_bus_busy(dev, adap); if (ret) { dev_err(dev->dev, "Error waiting for notbusy\n"); goto out_err; } check_busy = 0; } if (rem == 1 && msgs->len == 0) addr |= I2C_WRITE_DATA_LAST_BYTE; /* Wait for WR buffer not full */ ret = msm_i2c_poll_writeready(dev); if (ret) { ret = msm_i2c_recover_bus_busy(dev, adap); if (ret) { dev_err(dev->dev, "Error waiting for write ready before addr\n"); goto out_err; } } /* special case for doing 1 byte read. * There should be no scheduling between I2C controller becoming * ready to read and writing LAST-BYTE to I2C controller * This will avoid potential of I2C controller starting to latch * another extra byte. */ if ((msgs->len == 1) && (msgs->flags & I2C_M_RD)) { uint32_t retries = 0; spin_lock_irqsave(&dev->lock, flags); writel(I2C_WRITE_DATA_ADDR_BYTE | addr, dev->base + I2C_WRITE_DATA); /* Poll for I2C controller going into RX_DATA mode to * ensure controller goes into receive mode. * Just checking write_buffer_full may not work since * there is delay between the write-buffer becoming * empty and the slave sending ACK to ensure I2C * controller goes in receive mode to receive data. */ while (retries != 2000) { uint32_t status = readl(dev->base + I2C_STATUS); if ((status & I2C_STATUS_RX_DATA_STATE) == I2C_STATUS_RX_DATA_STATE) break; retries++; } if (retries >= 2000) { dev->rd_acked = 0; spin_unlock_irqrestore(&dev->lock, flags); /* 1-byte-reads from slow devices in interrupt * context */ goto wait_for_int; } dev->rd_acked = 1; writel(I2C_WRITE_DATA_LAST_BYTE, dev->base + I2C_WRITE_DATA); spin_unlock_irqrestore(&dev->lock, flags); } else { writel(I2C_WRITE_DATA_ADDR_BYTE | addr, dev->base + I2C_WRITE_DATA); } /* Polling and waiting for write_buffer_empty is not necessary. * Even worse, if we do, it can result in invalid status and * error if interrupt(s) occur while polling. */ /* * Now that we've setup the xfer, the ISR will transfer the data * and wake us up with dev->err set if there was an error */ wait_for_int: timeout = wait_for_completion_timeout(&complete, HZ); if (!timeout) { dev_err(dev->dev, "Transaction timed out\n"); writel(I2C_WRITE_DATA_LAST_BYTE, dev->base + I2C_WRITE_DATA); msleep(100); /* FLUSH */ readl(dev->base + I2C_READ_DATA); readl(dev->base + I2C_STATUS); ret = -ETIMEDOUT; goto out_err; } if (dev->err) { dev_err(dev->dev, "Error during data xfer (%d)\n", dev->err); ret = dev->err; goto out_err; } if (msgs->flags & I2C_M_RD) check_busy = 1; msgs++; rem--; } ret = num; out_err: spin_lock_irqsave(&dev->lock, flags); dev->complete = NULL; dev->msg = NULL; dev->rem = 0; dev->pos = 0; dev->err = 0; dev->flush_cnt = 0; dev->cnt = 0; spin_unlock_irqrestore(&dev->lock, flags); disable_irq(dev->irq); msm_i2c_rmutex_unlock(dev); pm_qos_update_requirement(PM_QOS_CPU_DMA_LATENCY, "msm_i2c", PM_QOS_DEFAULT_VALUE); mutex_unlock(&dev->mlock); return ret; }
static void insert_headset(void) { #ifdef FEATURE_AUD_HOOK_BTN unsigned long irq_flags; #endif int voltage = 0; /* FIH-SW2-MM-AY-hsed_type-00 */ H2W_DBG(""); input_sync(hi->hs_input); msleep(100); #ifdef FEATURE_AUD_HOOK_BTN /* On some non-standard headset adapters (usually those without a * button) the btn line is pulled down at the same time as the detect * line. We can check here by sampling the button line, if it is * low then it is probably a bad adapter so ignore the button. * If the button is released then we stop ignoring the button, so that * the user can recover from the situation where a headset is plugged * in with button held down. */ hi->ignore_btn = 1; /* FIH-SW2-MM-AY-TAP_Tapioca-00746_00 */ if (bn_irq_enable==0) { /* Enable button irq */ local_irq_save(irq_flags); enable_irq(hi->irq_btn); local_irq_restore(irq_flags); bn_irq_enable=1; irq_set_irq_wake(hi->irq_btn, 1); } #endif /* FIH-SW2-MM-AY-hsed_type-00 [ */ if (isCTIAheadset) { /* FIH-SW2-MM-AY-hsed_type-03 */ pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_ALWAYS); msleep(130); proc_comm_get_hsed_voltage(2, &voltage, 0); //it will get the prior value, not the current value. Should not omit. msleep(70); proc_comm_get_hsed_voltage(2, &voltage, 0); H2W_DBG("aud_hs: voltage is %d\n ", voltage); /* FIH-SW2-MM-AY-hsed_type-01 [ */ if (voltage > 1700) { //do not change state to issue an UEVENT. //it is a earphone jack plug. mHeadphone = false; hi->ignore_btn = 1; pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF); /* MM-RC-HEADSET-MULTIBUTTON-DETECT[* */ #ifdef FEATURE_AUD_HOOK_BTN if (bn_irq_enable) { local_irq_save(irq_flags); disable_irq(hi->irq_btn); local_irq_restore(irq_flags); bn_irq_enable=0; irq_set_irq_wake(hi->irq_btn, 0); } #endif /* MM-RC-HEADSET-MULTIBUTTON-DETECT]* */ switch_set_state(&hi->sdev, UNKNOWN_DEVICE); /* FIH-SW2-MM-AY-hsed_type-02 */ } else if (voltage > 700 || voltage < 400) { /* FIH-SW2-MM-AY-hsed_type-01 ] *//* SW-MM-RC-CTIA-TTY* */ if (gpio_get_value(hi->cable_in1) == HS_PLUG_IN) { if (gpio_get_value(hi->cable_in2) == BTN_STATE_PRESSED) { switch_set_state(&hi->sdev, NOMIC_HEADSET); mHeadphone=true; hi->ignore_btn = 1; pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF); H2W_DBG("aud_hs:HEADPHONE is plugging\n "); } else { switch_set_state(&hi->sdev, HEADSET); mHeadphone=false; #ifdef FEATURE_AUD_HOOK_BTN irq_set_irq_type(hi->irq_btn, IRQF_TRIGGER_BTN_PRESSED); #endif msleep(300); hi->ignore_btn = 0; H2W_DBG("aud_hs:HEADSET is plugging\n "); } } } else { mHeadphone = false; hi->ignore_btn = 1; pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_OFF); switch_set_state(&hi->sdev, NOT_SUPPORT); } H2W_DBG("switch_get_state= %d ",switch_get_state(&hi->sdev)); } else { /* FIH-SW2-MM-AY-TAP-ControlHSED_BIAS1-01 [ */ pmic_hsed_enable(PM_HSED_CONTROLLER_0, PM_HSED_ENABLE_ALWAYS); msleep(130); /* FIH-SW2-MM-AY-Tapioca_SS-00467-00 */ /* FIH-SW2-MM-AY-TAP-ControlHSED_BIAS1-01 ] */ if (gpio_get_value(hi->cable_in1) == HS_PLUG_IN) { /* FIH-SW2-MM-AY-TAP_headset_00 */ if (gpio_get_value(hi->cable_in2) == BTN_STATE_PRESSED) { /* FIH-SW2-MM-AY-TAP_headset_00 */ switch_set_state(&hi->sdev, NOMIC_HEADSET); mHeadphone=true; hi->ignore_btn = 1; /* FIH-SW2-MM-AY-TAP_Tapioca-00746_00 */ H2W_DBG("aud_hs:HEADPHONE is plugging\n "); } else { switch_set_state(&hi->sdev, HEADSET); mHeadphone=false; #ifdef FEATURE_AUD_HOOK_BTN irq_set_irq_type(hi->irq_btn, IRQF_TRIGGER_BTN_PRESSED); #endif msleep(300); /* FIH-SW2-MM-AY-TAP_Tapioca-00746_00 */ hi->ignore_btn = 0; /* FIH-SW2-MM-AY-TAP_Tapioca-00746_00 */ H2W_DBG("aud_hs:HEADSET is plugging\n "); } H2W_DBG("switch_get_state= %d ",switch_get_state(&hi->sdev)); } } /* FIH-SW2-MM-AY-hsed_type-00 ] */ }
static int msm_i2c_probe(struct platform_device *pdev) { struct msm_i2c_dev *dev; struct resource *mem, *irq, *ioarea; int ret; int fs_div; int hs_div; int i2c_clk; int clk_ctl; struct clk *clk; struct msm_i2c_platform_data *pdata; printk(KERN_INFO "msm_i2c_probe\n"); /* NOTE: driver uses the static register mapping */ mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!mem) { dev_err(&pdev->dev, "no mem resource?\n"); return -ENODEV; } irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!irq) { dev_err(&pdev->dev, "no irq resource?\n"); return -ENODEV; } ioarea = request_mem_region(mem->start, (mem->end - mem->start) + 1, pdev->name); if (!ioarea) { dev_err(&pdev->dev, "I2C region already claimed\n"); return -EBUSY; } clk = clk_get(&pdev->dev, "i2c_clk"); if (IS_ERR(clk)) { dev_err(&pdev->dev, "Could not get clock\n"); ret = PTR_ERR(clk); goto err_clk_get_failed; } pdata = pdev->dev.platform_data; if (!pdata) { dev_err(&pdev->dev, "platform data not initialized\n"); ret = -ENOSYS; goto err_clk_get_failed; } if (!pdata->msm_i2c_config_gpio) { dev_err(&pdev->dev, "config_gpio function not initialized\n"); ret = -ENOSYS; goto err_clk_get_failed; } /* We support frequencies upto FAST Mode(400KHz) */ if (pdata->clk_freq <= 0 || pdata->clk_freq > 400000) { dev_err(&pdev->dev, "clock frequency not supported\n"); ret = -EIO; goto err_clk_get_failed; } dev = kzalloc(sizeof(struct msm_i2c_dev), GFP_KERNEL); if (!dev) { ret = -ENOMEM; goto err_alloc_dev_failed; } dev->dev = &pdev->dev; dev->irq = irq->start; dev->clk = clk; dev->pdata = pdata; dev->base = ioremap(mem->start, (mem->end - mem->start) + 1); if (!dev->base) { ret = -ENOMEM; goto err_ioremap_failed; } dev->one_bit_t = USEC_PER_SEC/pdata->clk_freq; spin_lock_init(&dev->lock); platform_set_drvdata(pdev, dev); clk_enable(clk); if (pdata->rmutex != NULL) remote_spin_lock_init(&dev->rspin_lock, pdata->rsl_id); /* I2C_HS_CLK = I2C_CLK/(3*(HS_DIVIDER_VALUE+1) */ /* I2C_FS_CLK = I2C_CLK/(2*(FS_DIVIDER_VALUE+3) */ /* FS_DIVIDER_VALUE = ((I2C_CLK / I2C_FS_CLK) / 2) - 3 */ i2c_clk = 19200000; /* input clock */ fs_div = ((i2c_clk / pdata->clk_freq) / 2) - 3; hs_div = 3; clk_ctl = ((hs_div & 0x7) << 8) | (fs_div & 0xff); writel(clk_ctl, dev->base + I2C_CLK_CTL); printk(KERN_INFO "msm_i2c_probe: clk_ctl %x, %d Hz\n", clk_ctl, i2c_clk / (2 * ((clk_ctl & 0xff) + 3))); i2c_set_adapdata(&dev->adap_pri, dev); dev->adap_pri.algo = &msm_i2c_algo; strlcpy(dev->adap_pri.name, "MSM I2C adapter-PRI", sizeof(dev->adap_pri.name)); dev->adap_pri.nr = pdev->id; ret = i2c_add_numbered_adapter(&dev->adap_pri); if (ret) { dev_err(&pdev->dev, "Primary i2c_add_adapter failed\n"); goto err_i2c_add_adapter_failed; } i2c_set_adapdata(&dev->adap_aux, dev); dev->adap_aux.algo = &msm_i2c_algo; strlcpy(dev->adap_aux.name, "MSM I2C adapter-AUX", sizeof(dev->adap_aux.name)); dev->adap_aux.nr = pdev->id + 1; ret = i2c_add_numbered_adapter(&dev->adap_aux); if (ret) { dev_err(&pdev->dev, "auxiliary i2c_add_adapter failed\n"); i2c_del_adapter(&dev->adap_pri); goto err_i2c_add_adapter_failed; } ret = request_irq(dev->irq, msm_i2c_interrupt, IRQF_TRIGGER_RISING, pdev->name, dev); if (ret) { dev_err(&pdev->dev, "request_irq failed\n"); goto err_request_irq_failed; } pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, "msm_i2c", PM_QOS_DEFAULT_VALUE); disable_irq(dev->irq); dev->suspended = 0; mutex_init(&dev->mlock); /* Config GPIOs for primary and secondary lines */ pdata->msm_i2c_config_gpio(dev->adap_pri.nr, 1); pdata->msm_i2c_config_gpio(dev->adap_aux.nr, 1); return 0; /* free_irq(dev->irq, dev); */ err_request_irq_failed: i2c_del_adapter(&dev->adap_pri); i2c_del_adapter(&dev->adap_aux); err_i2c_add_adapter_failed: clk_disable(clk); iounmap(dev->base); err_ioremap_failed: kfree(dev); err_alloc_dev_failed: clk_put(clk); err_clk_get_failed: release_mem_region(mem->start, (mem->end - mem->start) + 1); return ret; }
static void wl1251_spi_disable_irq(struct wl1251 *wl) { return disable_irq(wl->irq); }
static ssize_t epen_connection_show(struct device *dev, struct device_attribute *attr, char *buff) { struct wacom_i2c *wac_i2c = dev_get_drvdata(dev); u8 cmd = 0; u8 buf[2] = {0,}; int ret = 0, cnt = 10; disable_irq(wac_i2c->client->irq); cmd = WACOM_I2C_STOP; ret = wacom_i2c_send(wac_i2c, &cmd, 1, false); if (ret <= 0) { dev_err(&wac_i2c->client->dev, "%s: failed to send stop command\n", __func__); goto grid_check_error; } cmd = WACOM_I2C_GRID_CHECK; ret = wacom_i2c_send(wac_i2c, &cmd, 1, false); if (ret <= 0) { dev_err(&wac_i2c->client->dev, "%s: failed to send stop command\n", __func__); goto grid_check_error; } cmd = WACOM_STATUS; do { msleep(50); if (1 == wacom_i2c_send(wac_i2c, &cmd, 1, false)) { if (2 == wacom_i2c_recv(wac_i2c, buf, 2, false)) { switch (buf[0]) { /* * status value * 0 : data is not ready * 1 : PASS * 2 : Fail (coil function error) * 3 : Fail (All coil function error) */ case 1: case 2: case 3: cnt = 0; break; default: break; } } } } while (cnt--); dev_info(&wac_i2c->client->dev, "%s : status: %x, error code: %x\n", __func__, buf[0], buf[1]); grid_check_error: cmd = WACOM_I2C_STOP; ret = wacom_i2c_send(wac_i2c, &cmd, 1, false); if (ret <= 0) dev_err(&wac_i2c->client->dev, "%s: failed to send stop command\n", __func__); cmd = WACOM_I2C_START; wacom_i2c_send(wac_i2c, &cmd, 1, false); if (ret <= 0) dev_err(&wac_i2c->client->dev, "%s: failed to send stop command\n", __func__); enable_irq(wac_i2c->client->irq); if ((buf[0] == 0x1) && (buf[1] == 0)) return sprintf(buff, "%s\n", "OK"); else return sprintf(buff, "%s\n", "NG"); }
static void earjack_debugger_shutdown(struct platform_device *pdev) { struct earjack_debugger_device *adev = platform_get_drvdata(pdev); disable_irq(adev->irq); }
static int gp2a_opt_probe(struct platform_device *pdev) { struct gp2a_data *gp2a; u8 value; int err = 0; int wakeup = 0; struct opt_gp2a_platform_data *pdata = pdev->dev.platform_data; /* allocate driver_data */ gp2a = kzalloc(sizeof(struct gp2a_data), GFP_KERNEL); if (!gp2a) { pr_err("kzalloc error\n"); return -ENOMEM; } gp2a->enabled = 0; gp2a->delay = SENSOR_DEFAULT_DELAY; if (pdata) { if (pdata->power_on) gp2a->power_on = pdata->power_on; if (pdata->gp2a_led_on) gp2a->gp2a_led_on = pdata->gp2a_led_on; if (pdata->irq) gp2a->irq = pdata->irq; if (pdata->ps_status) gp2a->ps_status = pdata->ps_status; } if (gp2a->power_on) gp2a->power_on(1); mutex_init(&gp2a->enable_mutex); mutex_init(&gp2a->data_mutex); wakeup = 1; err = proximity_input_init(gp2a); if (err < 0) goto error_setup_reg; err = sysfs_create_group(&gp2a->input_dev->dev.kobj, &proximity_attribute_group); if (err < 0) goto err_sysfs_create_group_proximity; /* set platdata */ platform_set_drvdata(pdev, gp2a); gp2a->uevent_kobj = &pdev->dev.kobj; spin_lock_init(&gp2a->prox_lock); /* init i2c */ opt_i2c_init(); if (opt_i2c_client == NULL) { pr_err("opt_probe failed : i2c_client is NULL\n"); return -ENODEV; } else printk(KERN_ERR "opt_i2c_client : (0x%p)\n", opt_i2c_client); /* GP2A Regs INIT SETTINGS */ #ifdef PROX_MODE_A value = 0x00; #else value = 0x02; #endif opt_i2c_write((u8)(REGS_OPMOD), &value); /* INT Settings */ err = request_threaded_irq(gp2a->irq, NULL, gp2a_irq_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "proximity_int", gp2a); if (err < 0) { printk(KERN_ERR "failed to request proximity_irq\n"); goto error_setup_reg; } disable_irq(gp2a->irq); /* set sysfs for proximity sensor */ err = sensors_register(proximity_sensor_device, gp2a, prox_sensor_attrs, "proximity_sensor"); if (err) { printk(KERN_ERR "%s: cound not register barometer_sensor(%d).\n", __func__, err); goto err_sysfs_create_group_proximity; } device_init_wakeup(&pdev->dev, wakeup); return 0; dev_set_drvdata(gp2a->proximity_dev, gp2a); err_sysfs_create_group_proximity: input_unregister_device(gp2a->input_dev); input_free_device(gp2a->input_dev); error_setup_reg: if (gp2a->power_on) gp2a->power_on(0); kfree(gp2a); return err; }
static void fs_enet_netpoll(struct net_device *dev) { disable_irq(dev->irq); fs_enet_interrupt(dev->irq, dev); enable_irq(dev->irq); }
static void build_bad_blk_list(void) { UINT32 bank, num_entries, result, vblk_offset; scan_list_t* scan_list = (scan_list_t*) TEMP_BUF_ADDR; mem_set_dram(BAD_BLK_BMP_ADDR, NULL, BAD_BLK_BMP_BYTES); disable_irq(); flash_clear_irq(); for (bank = 0; bank < NUM_BANKS; bank++) { SETREG(FCP_CMD, FC_COL_ROW_READ_OUT); SETREG(FCP_BANK, REAL_BANK(bank)); SETREG(FCP_OPTION, FO_E); SETREG(FCP_DMA_ADDR, (UINT32) scan_list); SETREG(FCP_DMA_CNT, SCAN_LIST_SIZE); SETREG(FCP_COL, 0); SETREG(FCP_ROW_L(bank), SCAN_LIST_PAGE_OFFSET); SETREG(FCP_ROW_H(bank), SCAN_LIST_PAGE_OFFSET); SETREG(FCP_ISSUE, NULL); while ((GETREG(WR_STAT) & 0x00000001) != 0); while (BSP_FSM(bank) != BANK_IDLE); num_entries = NULL; result = OK; if (BSP_INTR(bank) & FIRQ_DATA_CORRUPT) { result = FAIL; } else { UINT32 i; num_entries = read_dram_16(&(scan_list->num_entries)); if (num_entries > SCAN_LIST_ITEMS) { result = FAIL; } else { for (i = 0; i < num_entries; i++) { UINT16 entry = read_dram_16(scan_list->list + i); UINT16 pblk_offset = entry & 0x7FFF; if (pblk_offset == 0 || pblk_offset >= PBLKS_PER_BANK) { #if OPTION_REDUCED_CAPACITY == FALSE result = FAIL; #endif } else { write_dram_16(scan_list->list + i, pblk_offset); } } } } if (result == FAIL) { num_entries = 0; // We cannot trust this scan list. Perhaps a software bug. } else { write_dram_16(&(scan_list->num_entries), 0); } g_bad_blk_count[bank] = 0; for (vblk_offset = 1; vblk_offset < VBLKS_PER_BANK; vblk_offset++) { BOOL32 bad = FALSE; #if OPTION_2_PLANE { UINT32 pblk_offset; pblk_offset = vblk_offset * NUM_PLANES; // fix bug@jasmine v.1.1.0 if (mem_search_equ_dram(scan_list, sizeof(UINT16), num_entries + 1, pblk_offset) < num_entries + 1) { bad = TRUE; } pblk_offset = vblk_offset * NUM_PLANES + 1; // fix bug@jasmine v.1.1.0 if (mem_search_equ_dram(scan_list, sizeof(UINT16), num_entries + 1, pblk_offset) < num_entries + 1) { bad = TRUE; } } #else { // fix bug@jasmine v.1.1.0 if (mem_search_equ_dram(scan_list, sizeof(UINT16), num_entries + 1, vblk_offset) < num_entries + 1) { bad = TRUE; } } #endif if (bad) { g_bad_blk_count[bank]++; set_bit_dram(BAD_BLK_BMP_ADDR + bank*(VBLKS_PER_BANK/8 + 1), vblk_offset); } } } }
/* LGE_CHANGE_E : LCD ESD Protection*/ static int mipi_lg4573b_lcd_on(struct platform_device *pdev) { struct msm_fb_data_type *mfd; struct mipi_panel_info *mipi; int result=0; /* LGE_CHANGE_S : LCD ESD Protection * 2012-01-30, [email protected] * LCD ESD Protection */ #ifdef CONFIG_LGE_LCD_ESD_DETECTION bool int_en_wq_ret; if ( (!local_pdev_for_pwm) && (pdev) ) { local_pdev_for_pwm = pdev; } #endif /* LGE_CHANGE_E : LCD ESD Protection*/ mfd = platform_get_drvdata(pdev); mipi = &mfd->panel_info.mipi; if (!mfd) return -ENODEV; if (mfd->key != MFD_KEY) return -EINVAL; #ifdef CONFIG_FB_MSM_MIPI_DSI_LG4573B_BOOT_LOGO if(!lglogo_firstboot) #endif { printk( "mipi_lg4573b_lcd_on START\n"); #if 1//LGE_CHANGE_S [changbum.lee] 20120128 //jangsu.lee udelay(500);//mdelay(1);//1 gpio_set_value(GPIO_U0_LCD_RESET, 1); msleep(10); //10 #endif//LGE_CHANGE_E [changbum.lee] 20120128 /* LGE_CHANGE_S : LCD ESD Protection * 2012-01-30, [email protected] * LCD ESD Protection */ #ifdef CONFIG_LGE_LCD_ESD_DETECTION /*If any work pending flush it & disable irq */ int_en_wq_ret = flush_delayed_work_sync(&lcd_esd->esd_int_en_work); if( true == int_en_wq_ret) { printk("Pending INTR EN work Finished \n"); } if( 1 == atomic_read(&lcd_esd->esd_irq_state)) { disable_irq(lcd_esd->esd_irq); printk("ESD irq Disabled \n"); atomic_set(&lcd_esd->esd_irq_state,0); } #endif /* LGE_CHANGE_E : LCD ESD Protection*/ mipi_set_tx_power_mode(1); result=mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_init_on_cmds, ARRAY_SIZE(lg4573b_init_on_cmds)); mdelay(10); result=mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_sleep_out_cmds, ARRAY_SIZE(lg4573b_sleep_out_cmds)); //LGE_CHANGE_S [jangsu.lee] 20120130 : remove delay //mdelay(120); result=mipi_dsi_cmds_tx(mfd, &lg4573b_tx_buf, lg4573b_disp_on_cmds, ARRAY_SIZE(lg4573b_disp_on_cmds)); mipi_set_tx_power_mode(0); #ifdef CONFIG_LGE_LCD_ESD_DETECTION is_esd_occured = false; #endif /* LGE_CHANGE_S : LCD ESD Protection * 2012-01-30, [email protected] * LCD ESD Protection */ #ifdef CONFIG_LGE_LCD_ESD_DETECTION /*Make Panel power off state to ZERO. So that esd irq can be enabled in int wq handler*/ if(1 == atomic_read(&lcd_esd->panel_poweroff)) { atomic_set(&lcd_esd->panel_poweroff,0); } /*Schedule work after 1 sec to enable ESD interrupt*/ schedule_delayed_work(&lcd_esd->esd_int_en_work,ESD_INT_EN_DELAY); #endif /* LGE_CHANGE_E : LCD ESD Protection*/ printk( "mipi_lg4573b_lcd_on FINISH\n"); } return 0; }
static long evtchn_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { int rc; struct per_user_data *u = file->private_data; void __user *uarg = (void __user *) arg; /* Prevent bind from racing with unbind */ mutex_lock(&u->bind_mutex); switch (cmd) { case IOCTL_EVTCHN_BIND_VIRQ: { struct ioctl_evtchn_bind_virq bind; struct evtchn_bind_virq bind_virq; rc = -EFAULT; if (copy_from_user(&bind, uarg, sizeof(bind))) break; bind_virq.virq = bind.virq; bind_virq.vcpu = 0; rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, &bind_virq); if (rc != 0) break; rc = evtchn_bind_to_user(u, bind_virq.port); if (rc == 0) rc = bind_virq.port; break; } case IOCTL_EVTCHN_BIND_INTERDOMAIN: { struct ioctl_evtchn_bind_interdomain bind; struct evtchn_bind_interdomain bind_interdomain; rc = -EFAULT; if (copy_from_user(&bind, uarg, sizeof(bind))) break; bind_interdomain.remote_dom = bind.remote_domain; bind_interdomain.remote_port = bind.remote_port; rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_interdomain, &bind_interdomain); if (rc != 0) break; rc = evtchn_bind_to_user(u, bind_interdomain.local_port); if (rc == 0) rc = bind_interdomain.local_port; break; } case IOCTL_EVTCHN_BIND_UNBOUND_PORT: { struct ioctl_evtchn_bind_unbound_port bind; struct evtchn_alloc_unbound alloc_unbound; rc = -EFAULT; if (copy_from_user(&bind, uarg, sizeof(bind))) break; alloc_unbound.dom = DOMID_SELF; alloc_unbound.remote_dom = bind.remote_domain; rc = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &alloc_unbound); if (rc != 0) break; rc = evtchn_bind_to_user(u, alloc_unbound.port); if (rc == 0) rc = alloc_unbound.port; break; } case IOCTL_EVTCHN_UNBIND: { struct ioctl_evtchn_unbind unbind; rc = -EFAULT; if (copy_from_user(&unbind, uarg, sizeof(unbind))) break; rc = -EINVAL; if (unbind.port >= NR_EVENT_CHANNELS) break; spin_lock_irq(&port_user_lock); rc = -ENOTCONN; if (get_port_user(unbind.port) != u) { spin_unlock_irq(&port_user_lock); break; } disable_irq(irq_from_evtchn(unbind.port)); spin_unlock_irq(&port_user_lock); evtchn_unbind_from_user(u, unbind.port); rc = 0; break; } case IOCTL_EVTCHN_NOTIFY: { struct ioctl_evtchn_notify notify; rc = -EFAULT; if (copy_from_user(¬ify, uarg, sizeof(notify))) break; if (notify.port >= NR_EVENT_CHANNELS) { rc = -EINVAL; } else if (get_port_user(notify.port) != u) { rc = -ENOTCONN; } else { notify_remote_via_evtchn(notify.port); rc = 0; } break; } case IOCTL_EVTCHN_RESET: { /* Initialise the ring to empty. Clear errors. */ mutex_lock(&u->ring_cons_mutex); spin_lock_irq(&port_user_lock); u->ring_cons = u->ring_prod = u->ring_overflow = 0; spin_unlock_irq(&port_user_lock); mutex_unlock(&u->ring_cons_mutex); rc = 0; break; } default: rc = -ENOSYS; break; } mutex_unlock(&u->bind_mutex); return rc; }
static void eeti_ts_stop(struct eeti_ts_priv *priv) { disable_irq(priv->irq); cancel_work_sync(&priv->work); }
static int ads7846_read12_ser(struct device *dev, unsigned command) { struct spi_device *spi = to_spi_device(dev); struct ads7846 *ts = dev_get_drvdata(dev); struct ser_req *req = kzalloc(sizeof *req, GFP_KERNEL); int status; int use_internal; if (!req) return -ENOMEM; spi_message_init(&req->msg); /* FIXME boards with ads7846 might use external vref instead ... */ use_internal = (ts->model == 7846); /* maybe turn on internal vREF, and let it settle */ if (use_internal) { req->ref_on = REF_ON; req->xfer[0].tx_buf = &req->ref_on; req->xfer[0].len = 1; spi_message_add_tail(&req->xfer[0], &req->msg); req->xfer[1].rx_buf = &req->scratch; req->xfer[1].len = 2; /* for 1uF, settle for 800 usec; no cap, 100 usec. */ req->xfer[1].delay_usecs = ts->vref_delay_usecs; spi_message_add_tail(&req->xfer[1], &req->msg); } /* take sample */ req->command = (u8) command; req->xfer[2].tx_buf = &req->command; req->xfer[2].len = 1; spi_message_add_tail(&req->xfer[2], &req->msg); req->xfer[3].rx_buf = &req->sample; req->xfer[3].len = 2; spi_message_add_tail(&req->xfer[3], &req->msg); /* REVISIT: take a few more samples, and compare ... */ /* converter in low power mode & enable PENIRQ */ req->ref_off = PWRDOWN; req->xfer[4].tx_buf = &req->ref_off; req->xfer[4].len = 1; spi_message_add_tail(&req->xfer[4], &req->msg); req->xfer[5].rx_buf = &req->scratch; req->xfer[5].len = 2; CS_CHANGE(req->xfer[5]); spi_message_add_tail(&req->xfer[5], &req->msg); ts->irq_disabled = 1; disable_irq(spi->irq); status = spi_sync(spi, &req->msg); ts->irq_disabled = 0; enable_irq(spi->irq); if (status == 0) { /* on-wire is a must-ignore bit, a BE12 value, then padding */ status = be16_to_cpu(req->sample); status = status >> 3; status &= 0x0fff; }
void put_irq_handler(int irq, IrqHandler handler) { disable_irq(irq); irq_table[irq] = handler; }
static void ipu_disable_vblank(struct drm_crtc *crtc) { struct ipu_crtc *ipu_crtc = to_ipu_crtc(crtc); disable_irq(ipu_crtc->irq); }