Пример #1
0
static ssize_t apds990x_store_enable_ps_sensor(struct device *dev,
				struct device_attribute *attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct apds990x_data *data = i2c_get_clientdata(client);
	unsigned long val = simple_strtoul(buf, NULL, 10);
 	unsigned long flags;
	
	printk("%s: enable ps senosr ( %ld)\n", __func__, val);
	
	if ((val != 0) && (val != 1)) {
		printk("%s:store unvalid value=%ld\n", __func__, val);
		return count;
	}
	
	if(val == 1) {
		//turn on p sensor
		if (data->enable_ps_sensor==0) {

			data->enable_ps_sensor= 1;
		
			apds990x_set_enable(client,0); /* Power Off */
			apds990x_set_atime(client, 0xf6); /* 27.2ms */
			apds990x_set_ptime(client, 0xff); /* 2.72ms */
		
			apds990x_set_ppcount(client, 8); /* 8-pulse */
			apds990x_set_control(client, data->control); /* 100mA, IR-diode, 1X PGAIN, 1X AGAIN */
		
			apds990x_set_pilt(client, 0);		// init threshold for proximity
			apds990x_set_piht(client, APDS990x_PS_DETECTION_THRESHOLD);

			data->ps_threshold = APDS990x_PS_DETECTION_THRESHOLD;
			data->ps_hysteresis_threshold = APDS990x_PS_HSYTERESIS_THRESHOLD;
		
			apds990x_set_ailt( client, 0);
			apds990x_set_aiht( client, 0xffff);
		
			apds990x_set_pers(client, 0x33); /* 3 persistence */
		
			if (data->enable_als_sensor==0) {

				/* we need this polling timer routine for sunlight canellation */
				spin_lock_irqsave(&data->update_lock.wait_lock, flags); 
			
				/*
				 * If work is already scheduled then subsequent schedules will not
				 * change the scheduled time that's why we have to cancel it first.
				 */
				__cancel_delayed_work(&data->als_dwork);
				schedule_delayed_work(&data->als_dwork, msecs_to_jiffies(data->als_poll_delay));	// 100ms
			
				spin_unlock_irqrestore(&data->update_lock.wait_lock, flags);	
			}

			apds990x_set_enable(client, 0x27);	 /* only enable PS interrupt */
		}
	} 
	else {
		//turn off p sensor - kk 25 Apr 2011 we can't turn off the entire sensor, the light sensor may be needed by HAL
		data->enable_ps_sensor = 0;
		if (data->enable_als_sensor) {
			
			// reconfigute light sensor setting			
			apds990x_set_enable(client,0); /* Power Off */
			
			apds990x_set_atime(client, data->als_atime);  /* previous als poll delay */
			
			apds990x_set_ailt( client, 0);
			apds990x_set_aiht( client, 0xffff);
			
			apds990x_set_control(client, data->control); /* 100mA, IR-diode, 1X PGAIN, 1X AGAIN */
			apds990x_set_pers(client, 0x33); /* 3 persistence */
			
			apds990x_set_enable(client, 0x3);	 /* only enable light sensor */
			
			spin_lock_irqsave(&data->update_lock.wait_lock, flags); 
			
			/*
			 * If work is already scheduled then subsequent schedules will not
			 * change the scheduled time that's why we have to cancel it first.
			 */
			__cancel_delayed_work(&data->als_dwork);
			schedule_delayed_work(&data->als_dwork, msecs_to_jiffies(data->als_poll_delay));	// 100ms
			
			spin_unlock_irqrestore(&data->update_lock.wait_lock, flags);	
			
		}
		else {
			apds990x_set_enable(client, 0);

			spin_lock_irqsave(&data->update_lock.wait_lock, flags); 
			
			/*
			 * If work is already scheduled then subsequent schedules will not
			 * change the scheduled time that's why we have to cancel it first.
			 */
			__cancel_delayed_work(&data->als_dwork);
		
			spin_unlock_irqrestore(&data->update_lock.wait_lock, flags); 
		}
	}
	
	
	return count;
}
Пример #2
0
static int omapbmi_slot_probe(struct platform_device *pdev)
{
	struct bmi_slot *slot;
	struct resource *irq_pres, *irq_stat;
  	struct omap_bmi_platform_data* slot_pdata;
  	int ret;

  
  	printk(KERN_INFO "Buglabs 2.0 BUG Slots Driver...\n"); 
  	irq_pres = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  	if (!irq_pres) {
    		dev_err(&pdev->dev, "No presence irq resource...\n");
    		return -ENODEV;
  	}
  	irq_stat = platform_get_resource(pdev, IORESOURCE_IRQ, 1);
  	if (!irq_stat) {
    		dev_err(&pdev->dev, "No status irq resource...\n");
    		return -ENODEV;
  	}

  	slot = kzalloc(sizeof(struct bmi_slot), GFP_KERNEL);
  	if (!slot) {
    	ret = -ENOMEM;
    	goto err_release;
  	}
  
  	//Request slot enable gpios
  	ret = gpio_request(IOEXP_START + 15, "slot0 buf");
  	ret = gpio_request(IOEXP_START + 16, "slot0 en");
  	ret = gpio_request(IOEXP_START + 22, "slot1 buf");
  	ret = gpio_request(IOEXP_START + 17, "slot1 en");
  	ret = gpio_request(IOEXP_START + 6,  "slot2 buf");
  	ret = gpio_request(IOEXP_START + 18, "slot2 en");
  	ret = gpio_request(IOEXP_START + 7,  "slot3 buf");
  	ret = gpio_request(IOEXP_START + 19, "slot3 en");
  	ret = gpio_request(irq_stat->start, "BMI SINT");
  	if (ret) {
    		printk(KERN_ERR "slots_bug: GPIO %d request failed...\n",irq_stat->start);
    		goto err_release;
  	}
	ret = gpio_request(irq_pres->start, "BMI PINT");
	if (ret) {
	  	gpio_free(irq_stat->start);
		printk(KERN_ERR "slots_bug: GPIO %d request failed...\n",irq_pres->start);
    		goto err_release;
  	}
  
	ret = gpio_direction_input(irq_pres->start);
  	gpio_set_debounce(irq_pres->start, 7936);
	slot_pdata = pdev->dev.platform_data;

  	omapbmi_slot_gpio_req(slot_pdata->gpios);
  
  
  	slot->slot_data = (void*)slot_pdata->gpios;
  	slot->present_irq = gpio_to_irq(irq_pres->start);
  	slot->status_irq = gpio_to_irq(irq_stat->start);
  	slot->owner = THIS_MODULE;
  	slot->name = "omap_bug_slot";
  	slot->slotdev.parent = &pdev->dev;
  	slot->actions = &bl_actions;
  	slot->spi_bus_num = 1;
  	slot->spi_cs = slot_pdata->spi_cs;
  	slot->adap = i2c_get_adapter(slot_pdata->i2c_bus_no);
	if (!slot->adap) {
		printk(KERN_ERR "slots_bug: i2c adapter NULL...\n");
		goto gpio_release;
	}
			
  	ret = bmi_add_slot(slot);
  	if (ret) {
    		printk(KERN_ERR "slots_bug: Trouble instantiating slot...%d\n", ret);
    	goto gpio_release;
  	}
  
  	//  disable_irq_nosync(slot->present_irq);
  	schedule_delayed_work(&slot->work, msecs_to_jiffies(1000));
  	return 0;
 gpio_release:
 	gpio_free(irq_stat->start);
 	gpio_free(irq_pres->start);
 err_release:
  	kfree(slot->slot_data);
  	kfree(slot);
  	return ret;
}
Пример #3
0
// Pantech Earjack Probe Function
static int __devinit pantech_earjack_probe(struct platform_device *pdev)
{
	int rc = 0;
	int err = 0;
	struct input_dev *ipdev;

	dbg_func_in();

	irq_state = 0;

	// Alloc Devices
	earjack = kzalloc(sizeof(struct pantech_earjack), GFP_KERNEL);
	if (!earjack)
		return -ENOMEM;

	earjack->sdev.name	= "h2w";   
  
	earjack->sdev.print_name = msm_headset_print_name;
	rc = switch_dev_register(&earjack->sdev);
	if (rc)
		goto err_switch_dev_register;

	ipdev = input_allocate_device();
	if (!ipdev) {
		rc = -ENOMEM;
		goto err_alloc_input_dev;
	}
	input_set_drvdata(ipdev, earjack);


	// Init Status Flags
	earjack->ipdev = ipdev;
	earjack->car_kit = 0;
	earjack->type=EARJACK_STATE_OFF;
	earjack->remotekey_pressed = 0;
	earjack->remotekey_index = 0;

	// Initialize Work Queue
	INIT_DELAYED_WORK(&earjack_work,earjack_detect_func);          // INIT WORK
	INIT_DELAYED_WORK(&remotekey_work,remotekey_detect_func);

	// Get Power Source
#if defined(CONFIG_MIC_BIAS_1_8V)
	err = 0;
#else
	hs_jack_l8 = regulator_get(NULL, "8058_l8");
	regulator_set_voltage(hs_jack_l8,2700000,2700000);

	dbg("regulator_enable hs_jack_l8 value => %d\n",err);
#endif

	// Initialize Wakelocks
	wake_lock_init(&earjack_wake_lock, WAKE_LOCK_SUSPEND, "earjack_wake_lock_init");
	wake_lock_init(&remotekey_wake_lock, WAKE_LOCK_SUSPEND, "remotekey_wake_lock_init");

	// Setup GPIO's
	gpio_request(EARJACK_DET, "earjack_det");
	gpio_request(REMOTEKEY_DET, "remotekey_det");
	gpio_tlmm_config(GPIO_CFG(EARJACK_DET, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	rc = request_irq(gpio_to_irq(EARJACK_DET), Earjack_Det_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "earjack_det-irq", earjack);

	// Warning: REMOTEKEY_DET using default gpio config.
	//gpio_tlmm_config(GPIO_CFG(REMOTEKEY_DET, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	
	irq_set_irq_wake(gpio_to_irq(EARJACK_DET), 1);
	irq_set_irq_wake(gpio_to_irq(REMOTEKEY_DET), 1);

	// Init Input Device
//pz1946 merge for wired long key
#ifdef CONFIG_MACH_MSM8X60_PRESTO
	ipdev->name	= DRIVER_NAME;
	ipdev->id.vendor    = 0;
	ipdev->id.product   = 0;
	ipdev->id.version   = 0;
#else	
	ipdev->id.vendor    = 0x0001;
	ipdev->id.product   = 1;
	ipdev->id.version   = 1;
#endif

	input_set_capability(ipdev, EV_KEY, KEY_MEDIA);
	input_set_capability(ipdev, EV_KEY, KEY_VOLUMEUP);
	input_set_capability(ipdev, EV_KEY, KEY_VOLUMEDOWN);
	input_set_capability(ipdev, EV_KEY, KEY_POWER);    
	input_set_capability(ipdev, EV_KEY, KEY_END);
	input_set_capability(ipdev, EV_SW,  SW_HEADPHONE_INSERT);
	input_set_capability(ipdev, EV_SW,  SW_MICROPHONE_INSERT);

	rc = input_register_device(ipdev);
	if (rc) {
		dev_err(&ipdev->dev,
				"hs_probe: input_register_device rc=%d\n", rc);
		goto err_reg_input_dev;
	}
	platform_set_drvdata(pdev, earjack);

	rc = sysfs_create_group(&pdev->dev.kobj, &dev_attr_grp);
	if (rc) {
		dev_err(&ipdev->dev,
				"hs_probe: sysfs_create_group rc=%d\n", rc);
		goto err_earjack_init;
	}

	// Scehdule earjack_detect_func for initial detect
	disable_irq_detect(); //disable_irq_nosync(gpio_to_irq(EARJACK_DET));
	
	wake_lock(&earjack_wake_lock);
	disable_irq_nosync(gpio_to_irq(REMOTEKEY_DET));

	schedule_delayed_work(&earjack_work,10);    // after 100ms
	
	dbg_func_out();
	return 0;

err_earjack_init:

err_reg_input_dev:
	input_unregister_device(ipdev);
	ipdev = NULL;
err_alloc_input_dev:
	input_free_device(ipdev);
err_switch_dev_register:
	kfree(earjack);
	return 0;
}
Пример #4
0
static int my3126_interrupt_enable(struct cphy *cphy)
{
	schedule_delayed_work(&cphy->phy_update, HZ/30);
	t1_tpi_read(cphy->adapter, A_ELMER0_GPO, &cphy->elmer_gpo);
	return 0;
}
Пример #5
0
static int fsa9480_codec_probe(struct i2c_client *client, const struct i2c_device_id *id)
{
	struct fsa9480_state *state;
	struct device *dev = &client->dev;
	u8 pData;

	DEBUG_FSA9480("[FSA9480] %s\n", __func__);

	s3c_gpio_cfgpin(GPIO_USB_SCL_28V, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SCL_28V, S3C_GPIO_PULL_NONE);

	s3c_gpio_cfgpin(GPIO_USB_SDA_28V, S3C_GPIO_OUTPUT);
	s3c_gpio_setpull(GPIO_USB_SDA_28V, S3C_GPIO_PULL_NONE);

	s3c_gpio_cfgpin(GPIO_UART_SEL, S3C_GPIO_OUTPUT );
	s3c_gpio_setpull(GPIO_UART_SEL, S3C_GPIO_PULL_NONE);

	if (device_create_file(switch_dev, &dev_attr_uart_sel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_uart_sel.attr.name);
	 
	if (device_create_file(switch_dev, &dev_attr_usb_sel) < 0)
		DEBUG_FSA9480("[FSA9480]Failed to create device file(%s)!\n", dev_attr_usb_sel.attr.name);

	if (device_create_file(switch_dev, &dev_attr_usb_state) < 0)
		DEBUG_FSA9480("[FSA9480]Failed to create device file(%s)!\n", dev_attr_usb_state.attr.name);
	
#if 1
	if (device_create_file(switch_dev, &dev_attr_DMport) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_DMport.attr.name);

	if (device_create_file(switch_dev, &dev_attr_DMlog) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_DMlog.attr.name);
#endif

	if (device_create_file(switch_dev, &dev_attr_UsbMenuSel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_UsbMenuSel.attr.name);
	 
	if (device_create_file(switch_dev, &dev_attr_AskOnMenuSel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_AskOnMenuSel.attr.name);

	if (device_create_file(switch_dev, &dev_attr_Mtp) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_Mtp.attr.name);

	if (device_create_file(switch_dev, &dev_attr_SwitchingInitValue) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_SwitchingInitValue.attr.name);		

	if (device_create_file(switch_dev, &dev_attr_FactoryResetValue) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_FactoryResetValue.attr.name);		
	
	if (device_create_file(switch_dev, &dev_attr_AskOnStatus) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_AskOnStatus.attr.name);			
	
	if (device_create_file(switch_dev, &dev_attr_MtpInitStatusSel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_MtpInitStatusSel.attr.name);			
	
	if (device_create_file(switch_dev, &dev_attr_AskInitStatusSel) < 0)
		pr_err("Failed to create device file(%s)!\n", dev_attr_AskInitStatusSel.attr.name);	
	
	if (device_create_file(switch_dev, &dev_attr_tethering) < 0)		
		pr_err("Failed to create device file(%s)!\n", dev_attr_tethering.attr.name);

	if (device_create_file(switch_dev, &dev_attr_dock) < 0)		
		pr_err("Failed to create device file(%s)!\n", dev_attr_dock.attr.name);

	 
	 init_waitqueue_head(&usb_detect_waitq); 
	 INIT_WORK(&fsa9480_work, FSA9480_ReadIntRegister);
	 fsa9480_workqueue = create_singlethread_workqueue("fsa9480_workqueue");

	 state = kzalloc(sizeof(struct fsa9480_state), GFP_KERNEL);
	 if(!state) {
		 dev_err(dev, "%s: failed to create fsa9480_state\n", __func__);
		 return -ENOMEM;
	 }

	indicator_dev.name = DRIVER_NAME;
	indicator_dev.print_name = print_switch_name;
	indicator_dev.print_state = print_switch_state;
	switch_dev_register(&indicator_dev);

	state->client = client;
	fsa9480_i2c_client = client;

	i2c_set_clientdata(client, state);
	if(!fsa9480_i2c_client)
	{
		dev_err(dev, "%s: failed to create fsa9480_i2c_client\n", __func__);
		return -ENODEV;
	}

	 /*clear interrupt mask register*/
	fsa9480_read(fsa9480_i2c_client, REGISTER_CONTROL, &pData);
	fsa9480_write(fsa9480_i2c_client, REGISTER_CONTROL, pData & ~INT_MASK);

	 fsa9480_interrupt_init();

	 fsa9480_chip_init();

	INIT_DELAYED_WORK(&micorusb_init_work, connectivity_switching_init);
	schedule_delayed_work(&micorusb_init_work, msecs_to_jiffies(200));

	 return 0;
}
DECLARE_DVFS_WORK_FUNC(SET, PEN)
{
	struct input_booster *data = (struct input_booster *)booster_data;
	struct booster_dvfs *dvfs = data->dvfses[BOOSTER_DEVICE_PEN];

	if (!dvfs || !dvfs->initialized) {
		dev_err(data->dev, "%s: Dvfs is not initialized\n",	__func__);
		return;
	}

	mutex_lock(&dvfs->lock);

	if (!dvfs->level) {
		dev_err(data->dev, "%s : Skip to set booster due to level 0\n", __func__);
		goto out;
	}

	switch (booster_mode) {
	case BOOSTER_MODE_ON:
		cancel_delayed_work(&dvfs->dvfs_off_work);
		cancel_delayed_work(&dvfs->dvfs_chg_work);
		switch (dvfs->level) {
		case BOOSTER_LEVEL1:
		case BOOSTER_LEVEL2:
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL1].cpu_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL1].mif_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL1].int_freq);
		break;
		case BOOSTER_LEVEL3:
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL3].cpu_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL3].mif_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL3].int_freq);
		break;
		case BOOSTER_LEVEL9:
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL9].cpu_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9].mif_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9].int_freq);
		break;
		default:
			dev_err(data->dev, "%s : Undefined type passed[%d]\n", __func__, dvfs->level);
		break;
		}
		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS ON [level %d]\n",	__func__, dvfs->level);

		if (dvfs->level == BOOSTER_LEVEL9)
			schedule_delayed_work(&dvfs->dvfs_chg_work,
							msecs_to_jiffies(BOOSTER_DEBUG_HEAD_TIME));
		else
			schedule_delayed_work(&dvfs->dvfs_chg_work,
							msecs_to_jiffies(dvfs->times[dvfs->level].head_time));
		dvfs->lock_status = true;
	break;
	case BOOSTER_MODE_OFF:
		if (dvfs->lock_status)
			schedule_delayed_work(&dvfs->dvfs_off_work,
					msecs_to_jiffies(dvfs->times[dvfs->level].tail_time));
	break;
	case BOOSTER_MODE_FORCE_OFF:
		if (dvfs->lock_status) {
			cancel_delayed_work(&dvfs->dvfs_chg_work);
			cancel_delayed_work(&dvfs->dvfs_off_work);
			schedule_work(&dvfs->dvfs_off_work.work);
		}
	break;
	default:
	break;
	}

out:
	mutex_unlock(&dvfs->lock);
	return;
}
Пример #7
0
static void
micveth_clientpoll(struct work_struct *work)
{
    micveth_info_t *veth_info;
    uint32_t transRingHi;
    uint32_t transRingLo;
    uint32_t scratch14 = 0;
    uint32_t scratch15 = 0;
    int bd;
    static int enter = 0;

    if (enter == 0)
    {
        printk("micveth is polling\n");
        enter = 1;
    }

    mutex_lock(&micveth.lv_state_mutex);
    if (micveth.lv_pollstate == CLIENT_POLL_STOPPING) {
        micveth.lv_pollstate = CLIENT_POLL_STOPPED;
        mutex_unlock(&micveth.lv_state_mutex);
        wake_up(&micveth.lv_wq);
        return;
    }

    // Check for state changes for each board in the system
    for (bd = 0; bd < micveth.lv_num_clients; bd++) {
        veth_info = &micveth.lv_info[bd];

        // Do not poll boards that have not had the interface started.
        if (veth_info->vi_state == VETH_STATE_INITIALIZED) {
            break;
        }

#ifdef NO_SRATCHREGREAD_AFTER_CONNECT
        if(veth_info->vi_state != VETH_STATE_LINKUP) {
#endif
            scratch14 = readl(veth_info->vi_scratch14);
            scratch15 = readl(veth_info->vi_scratch15);
#ifdef NO_SRATCHREGREAD_AFTER_CONNECT
        }
#endif

        if (veth_info->vi_state == VETH_STATE_LINKUP) {
            if (scratch14 == MICVETH_LINK_DOWN_MAGIC) {
                veth_info->vi_state = VETH_STATE_LINKDOWN;
            }
        } else if (veth_info->vi_state == VETH_STATE_LINKDOWN) {
            if (scratch14 == MICVETH_LINK_UP_MAGIC) {
                // Write the transfer ring address.
                transRingHi = (uint32_t)(veth_info->vi_ring.phys >> 32);
                transRingLo = (uint32_t)(veth_info->vi_ring.phys & 0xffffffff);

                writel(transRingLo, veth_info->vi_scratch14);
                writel(transRingHi, veth_info->vi_scratch15);

                veth_info->vi_state = VETH_STATE_LINKUP;
                printk("MIC virtual ethernet up for board %d\n", bd);
#ifdef MIC_IS_EMULATION
                printk("Card wrote Magic: It must be UP!\n");
#endif

                if (mic_vnet_mode == VNET_MODE_POLL) {
                    schedule_delayed_work(&veth_info->vi_poll,
                                          msecs_to_jiffies(MICVETH_POLL_TIMER_DELAY));
                }

                micveth.lv_num_links_remaining--;
            }
#ifdef MIC_IS_EMULATION
            else if (scratch14) {
                printk("---> 0x%x \n", scratch14);
                writel(0x0, veth_info->vi_scratch14);
            }
#endif
        }
Пример #8
0
long mdm_modem_ioctl(struct file *filp, unsigned int cmd,
				unsigned long arg)
{
	int status, ret = 0;

	if (_IOC_TYPE(cmd) != CHARM_CODE) {
		pr_err("%s: invalid ioctl code\n", __func__);
		return -EINVAL;
	}

	pr_debug("%s: Entering ioctl cmd = %d\n", __func__, _IOC_NR(cmd));
	switch (cmd) {
	case WAKE_CHARM:
		pr_info("%s: Powering on mdm\n", __func__);
		mdm_drv->ops->power_on_mdm_cb(mdm_drv);
		break;
	case CHECK_FOR_BOOT:
		if (gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0)
			put_user(1, (unsigned long __user *) arg);
		else
			put_user(0, (unsigned long __user *) arg);
		break;
	case NORMAL_BOOT_DONE:
		pr_debug("%s: check if mdm is booted up\n", __func__);
		get_user(status, (unsigned long __user *) arg);
		if (status) {
			pr_debug("%s: normal boot failed\n", __func__);
			mdm_drv->mdm_boot_status = -EIO;
		} else {
			pr_info("%s: normal boot done\n", __func__);
			mdm_drv->mdm_boot_status = 0;
		}
		mdm_drv->mdm_ready = 1;

		if (mdm_drv->ops->normal_boot_done_cb != NULL)
			mdm_drv->ops->normal_boot_done_cb(mdm_drv);

		if (!first_boot)
			complete(&mdm_boot);
		else
			first_boot = 0;

		/* If successful, start a timer to check that the mdm2ap_status
		 * gpio goes high.
		 */
		if (!status && gpio_get_value(mdm_drv->mdm2ap_status_gpio) == 0)
			schedule_delayed_work(&mdm2ap_status_check_work,
				msecs_to_jiffies(MDM2AP_STATUS_TIMEOUT_MS));
		break;
	case RAM_DUMP_DONE:
		pr_debug("%s: mdm done collecting RAM dumps\n", __func__);
		get_user(status, (unsigned long __user *) arg);
		if (status)
			mdm_drv->mdm_ram_dump_status = -EIO;
		else {
			pr_info("%s: ramdump collection completed\n", __func__);
			mdm_drv->mdm_ram_dump_status = 0;
		}
		complete(&mdm_ram_dumps);
		break;
	case WAIT_FOR_RESTART:
		pr_debug("%s: wait for mdm to need images reloaded\n",
				__func__);
		ret = wait_for_completion_interruptible(&mdm_needs_reload);
		if (!ret)
			put_user(mdm_drv->boot_type,
					 (unsigned long __user *) arg);
		INIT_COMPLETION(mdm_needs_reload);
		break;
	case GET_DLOAD_STATUS:
		pr_debug("getting status of mdm2ap_errfatal_gpio\n");
		if (gpio_get_value(mdm_drv->mdm2ap_errfatal_gpio) == 1 &&
			!mdm_drv->mdm_ready)
			put_user(1, (unsigned long __user *) arg);
		else
			put_user(0, (unsigned long __user *) arg);
		break;
	case IMAGE_UPGRADE:
		pr_debug("%s Image upgrade ioctl recieved\n", __func__);
		if (mdm_drv->pdata->image_upgrade_supported &&
				mdm_drv->ops->image_upgrade_cb) {
			get_user(status, (unsigned long __user *) arg);
			mdm_drv->ops->image_upgrade_cb(mdm_drv, status);
		} else
			pr_debug("%s Image upgrade not supported\n", __func__);
		break;
	case SHUTDOWN_CHARM:
		if (!mdm_drv->pdata->send_shdn)
			break;
		mdm_drv->mdm_ready = 0;
		if (mdm_debug_mask & MDM_DEBUG_MASK_SHDN_LOG)
			pr_info("Sending shutdown request to mdm\n");
		ret = sysmon_send_shutdown(SYSMON_SS_EXT_MODEM);
		if (ret)
			pr_err("%s: Graceful shutdown of the external modem failed, ret = %d\n",
				   __func__, ret);
		break;
	default:
		pr_err("%s: invalid ioctl cmd = %d\n", __func__, _IOC_NR(cmd));
		ret = -EINVAL;
		break;
	}

	return ret;
}
Пример #9
0
void musb_port_reset(struct musb *musb, bool do_reset)
{
	u8		power;
	void __iomem	*mbase = musb->mregs;

	if (musb->xceiv->otg->state == OTG_STATE_B_IDLE) {
		musb_dbg(musb, "HNP: Returning from HNP; no hub reset from b_idle");
		musb->port1_status &= ~USB_PORT_STAT_RESET;
		return;
	}

	if (!is_host_active(musb))
		return;

	/* NOTE:  caller guarantees it will turn off the reset when
	 * the appropriate amount of time has passed
	 */
	power = musb_readb(mbase, MUSB_POWER);
	if (do_reset) {
		/*
		 * If RESUME is set, we must make sure it stays minimum 20 ms.
		 * Then we must clear RESUME and wait a bit to let musb start
		 * generating SOFs. If we don't do this, OPT HS A 6.8 tests
		 * fail with "Error! Did not receive an SOF before suspend
		 * detected".
		 */
		if (power &  MUSB_POWER_RESUME) {
			long remain = (unsigned long) musb->rh_timer - jiffies;

			if (musb->rh_timer > 0 && remain > 0) {
				/* take into account the minimum delay after resume */
				schedule_delayed_work(
					&musb->deassert_reset_work, remain);
				return;
			}

			musb_writeb(mbase, MUSB_POWER,
				    power & ~MUSB_POWER_RESUME);

			/* Give the core 1 ms to clear MUSB_POWER_RESUME */
			schedule_delayed_work(&musb->deassert_reset_work,
					      msecs_to_jiffies(1));
			return;
		}

		power &= 0xf0;
		musb_writeb(mbase, MUSB_POWER,
				power | MUSB_POWER_RESET);

		musb->port1_status |= USB_PORT_STAT_RESET;
		musb->port1_status &= ~USB_PORT_STAT_ENABLE;
		schedule_delayed_work(&musb->deassert_reset_work,
				      msecs_to_jiffies(50));
	} else {
		musb_dbg(musb, "root port reset stopped");
		musb_platform_pre_root_reset_end(musb);
		musb_writeb(mbase, MUSB_POWER,
				power & ~MUSB_POWER_RESET);
		musb_platform_post_root_reset_end(musb);

		power = musb_readb(mbase, MUSB_POWER);
		if (power & MUSB_POWER_HSMODE) {
			musb_dbg(musb, "high-speed device connected");
			musb->port1_status |= USB_PORT_STAT_HIGH_SPEED;
		}

		musb->port1_status &= ~USB_PORT_STAT_RESET;
		musb->port1_status |= USB_PORT_STAT_ENABLE
					| (USB_PORT_STAT_C_RESET << 16)
					| (USB_PORT_STAT_C_ENABLE << 16);
		usb_hcd_poll_rh_status(musb->hcd);

		musb->vbuserr_retry = VBUSERR_RETRY_COUNT;
	}
}
void tsensor_late_init(void)
{
    int i = 0,ret=0;
    efuse_trim_init();

    for(i=0; i<gstTempPrtInfo.num; i++)
    {
        printk(KERN_INFO "sensor%d type : %d.\n",i,gstTempPrtInfo.sensor_config[i].sensor_type);
        printk(KERN_INFO "sensor%d sel : %d.\n",i,gstTempPrtInfo.sensor_config[i].sel);
        printk(KERN_INFO "sensor%d lag_value : %d.\n",i,gstTempPrtInfo.sensor_config[i].lag_value);
        gstTempPrtInfo.sensor_config[i].lag_cfg_value= (gstTempPrtInfo.sensor_config[i].lag_value*255/200);
        printk(KERN_INFO "sensor%d thres_value : %d.\n",i,gstTempPrtInfo.sensor_config[i].thres_value);
        printk(KERN_INFO "sensor%d reset_value : %d.\n",i,gstTempPrtInfo.sensor_config[i].reset_value);
        printk(KERN_INFO "sensor%d alarm_cnt : %d.\n",i,gstTempPrtInfo.sensor_config[i].alarm_cnt);
        printk(KERN_INFO "sensor%d recover_cnt : %d.\n",i,gstTempPrtInfo.sensor_config[i].recover_cnt);
        switch(gstTempPrtInfo.sensor_config[i].sensor_type)
        {
            case TSENSOR_TYPE_ACPU_CLUSTER0:
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].thres_value + 60 + efuse_trim_data.remote_acpu_c0)*255/200);
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].thres_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].thres_cfg_value;
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].reset_value + 60 + efuse_trim_data.remote_acpu_c0)*255/200);
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].reset_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].reset_cfg_value;
                break;
            case TSENSOR_TYPE_ACPU_CLUSTER1:
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].thres_value + 60 + efuse_trim_data.remote_acpu_c1)*255/200);
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].thres_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].thres_cfg_value;
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].reset_value + 60 + efuse_trim_data.remote_acpu_c1)*255/200);
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].reset_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].reset_cfg_value;
                break;
            case TSENSOR_TYPE_GPU:
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].thres_value + 60 + efuse_trim_data.remote_gpu)*255/200);
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].thres_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].thres_cfg_value;
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].reset_value + 60 + efuse_trim_data.remote_gpu)*255/200);
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].reset_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].reset_cfg_value;
                break;
            case TSENSOR_TYPE_LOCAL:
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].thres_value + 60 + efuse_trim_data.local)*255/200);
                gstTempPrtInfo.sensor_config[i].thres_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].thres_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].thres_cfg_value;
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    ((gstTempPrtInfo.sensor_config[i].reset_value + 60 + efuse_trim_data.local)*255/200);
                gstTempPrtInfo.sensor_config[i].reset_cfg_value = \
                    (gstTempPrtInfo.sensor_config[i].reset_cfg_value>254)?254:gstTempPrtInfo.sensor_config[i].reset_cfg_value;
                break;
            default:
                break;
        }

          gstTempPrtInfo.sensor_config[i].thres_cfg_value |= 0x0FFFFFF00; 
          gstTempPrtInfo.sensor_config[i].temp_t0 = gstTempPrtInfo.sensor_config[i].thres_value; 
    }

    
    ret = request_irq(IRQ_TSENSOR0,tsensor_irq, IRQF_DISABLED,"Tsensor-irq",(void*)&gstTempPrtInfo);
    if (ret) {
        pr_err("%s,%d request_irq  failed!\n", __func__, __LINE__);
        return;
    }

    /*hw init*/
    tsensor_config_set(tsensor_get_index_by_type(TSENSOR_TYPE_LOCAL));

    /*Tsensor0温度检测中断清除寄存器。clr irq*/
    TSENSOR_REG_WRITE(SOC_PERI_SCTRL_SC_TEMP0_INT_CLR_ADDR(0),
            SOC_PERI_SCTRL_SC_TEMP0_INT_CLR_temp0_int_clr_START,
            SOC_PERI_SCTRL_SC_TEMP0_INT_CLR_temp0_int_clr_END,
            0x01);


    /*Tsensor0温度检测中断屏蔽寄存器。enable irq*/
    TSENSOR_REG_WRITE(SOC_PERI_SCTRL_SC_TEMP0_INT_EN_ADDR(0),
            SOC_PERI_SCTRL_SC_TEMP0_INT_EN_temp0_int_en_START,
            SOC_PERI_SCTRL_SC_TEMP0_INT_EN_temp0_int_en_END,
            0x01);

    gstTempPrtInfo.init_flag = TSENSOR_INIT_OK;
    pr_info("Tsensor late init ok.\n");



    /* HKADC BUSINESS -s */
    INIT_DELAYED_WORK(&tsensor_debug_work,
                      hw_tsensor_debug_work);
    schedule_delayed_work(&tsensor_debug_work,
                        msecs_to_jiffies(60*1000));// 60s
    /* HKADC BUSINESS -e */
                        
    return;
}
Пример #11
0
static int lge_hsd_probe(struct platform_device *pdev)
{
	int ret = 0;
	struct fsa8008_platform_data *pdata = pdev->dev.platform_data;

	struct hsd_info *hi;

	HSD_DBG("lge_hsd_probe");

	hi = kzalloc(sizeof(struct hsd_info), GFP_KERNEL);

	if (NULL == hi) {
		HSD_ERR("Failed to allloate headset per device info\n");
		return -ENOMEM;
	}

	hi->key_code = pdata->key_code;

	platform_set_drvdata(pdev, hi);

	atomic_set(&hi->btn_state, 0);
	atomic_set(&hi->is_3_pole_or_not, 1);

	hi->gpio_detect = pdata->gpio_detect;
	hi->gpio_mic_en = pdata->gpio_mic_en;
	hi->gpio_jpole = pdata->gpio_jpole;
	hi->gpio_key = pdata->gpio_key;
	hi->set_headset_mic_bias = pdata->set_headset_mic_bias;

	hi->latency_for_detection = pdata->latency_for_detection;
#ifdef CONFIG_LGE_AUDIO_FSA8008_MODIFY
	hi->latency_for_key = FSA8008_KEY_PRESS_DLY_MS;
	hi->gpio_key_cnt = 0;
	INIT_DELAYED_WORK(&hi->work_for_insert, insert_headset);
	INIT_DELAYED_WORK(&hi->work_for_remove, remove_headset);
	INIT_DELAYED_WORK(&hi->work_for_key_det_enable, button_enable);
#else
	hi->latency_for_key = 200 /* milli */ * HZ / 1000; /* convert milli to jiffies */
	INIT_DELAYED_WORK(&hi->work, detect_work);
#endif
	mutex_init(&hi->mutex_lock);
	INIT_DELAYED_WORK(&hi->work_for_key_pressed, button_pressed);
	INIT_DELAYED_WORK(&hi->work_for_key_released, button_released);

	/* initialize gpio_detect */
	ret = gpio_request(hi->gpio_detect, "gpio_detect");
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_detect) gpio_request\n", hi->gpio_detect);
		goto error_01;
	}

	ret = gpio_direction_input(hi->gpio_detect);
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_detect) gpio_direction_input\n", hi->gpio_detect);
		goto error_02;
	}

	/* initialize gpio_jpole */
	ret = gpio_request(hi->gpio_jpole, "gpio_jpole");
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_jpole) gpio_request\n", hi->gpio_jpole);
		goto error_02;
	}

	ret = gpio_direction_input(hi->gpio_jpole);
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_jpole) gpio_direction_input\n", hi->gpio_jpole);
		goto error_03;
	}
	
	/* initialize gpio_key */
	ret = gpio_request(hi->gpio_key, "gpio_key");
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_key) gpio_request\n", hi->gpio_key);
		goto error_03;
	}

	ret = gpio_direction_input(hi->gpio_key);
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_key) gpio_direction_input\n", hi->gpio_key);
		goto error_04;
	}

	/* initialize gpio_mic_en */
	ret = gpio_request(hi->gpio_mic_en, "gpio_mic_en");
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_mic_en) gpio_request\n", hi->gpio_mic_en);
		goto error_04;
	}

	ret = gpio_direction_output(hi->gpio_mic_en, 0);
	if (ret < 0) {
		HSD_ERR("Failed to configure gpio%d (gpio_mic_en) gpio_direction_output\n", hi->gpio_mic_en);
		goto error_05;
	}

	/* initialize irq of gpio_jpole */
	hi->irq_detect = gpio_to_irq(hi->gpio_detect);

	HSD_DBG("hi->irq_detect = %d\n", hi->irq_detect);

	if (hi->irq_detect < 0) {
		HSD_ERR("Failed to get interrupt number\n");
		ret = hi->irq_detect;
		goto error_05;
	}

//LGE_START, MYUNGWON.KIM, When Sleep IRQ Doesn't work
	ret = request_threaded_irq(hi->irq_detect, NULL, gpio_irq_handler,
					IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING|IRQF_NO_SUSPEND, pdev->name, hi);
//LGE_END, MYUNGWON.KIM

	if (ret) {
		HSD_ERR("failed to request button irq");
		goto error_05;
	}

	ret = irq_set_irq_wake(hi->irq_detect, 1);
	if (ret < 0) {
		HSD_ERR("Failed to set irq_detect interrupt wake\n");
		goto error_06;
	}

	/* initialize irq of gpio_key */
	hi->irq_key = gpio_to_irq(hi->gpio_key);

	HSD_DBG("hi->irq_key = %d\n", hi->irq_key);

	if (hi->irq_key < 0) {
		HSD_ERR("Failed to get interrupt number\n");
		ret = hi->irq_key;
		goto error_06;
	}

//LGE_START, MYUNGWON.KIM, When Sleep IRQ Doesn't work
	ret = request_threaded_irq(hi->irq_key, NULL, button_irq_handler,
					IRQF_TRIGGER_RISING|IRQF_TRIGGER_FALLING|IRQF_NO_SUSPEND, pdev->name, hi);
//LGE_END, MYUNGWON.KIM

	if (ret) {
		HSD_ERR("failed to request button irq");
		goto error_06;
	}

	disable_irq(hi->irq_key);

	ret = irq_set_irq_wake(hi->irq_key, 1);
	if (ret < 0) {
		HSD_ERR("Failed to set irq_key interrupt wake\n");
		goto error_07;
	}

	/* initialize switch device */
	hi->sdev.name = pdata->switch_name;
	hi->sdev.print_state = lge_hsd_print_state;
	hi->sdev.print_name = lge_hsd_print_name;

	ret = switch_dev_register(&hi->sdev);
	if (ret < 0) {
		HSD_ERR("Failed to register switch device\n");
		goto error_07;
	}

	/* initialize input device */
	hi->input = input_allocate_device();
	if (!hi->input) {
		HSD_ERR("Failed to allocate input device\n");
		ret = -ENOMEM;
		goto error_08;
	}

	hi->input->name = pdata->keypad_name;

	hi->input->id.vendor    = 0x0001;
	hi->input->id.product   = 1;
	hi->input->id.version   = 1;

	/*input_set_capability(hi->input, EV_SW, SW_HEADPHONE_INSERT);*/
	set_bit(EV_SYN, hi->input->evbit);
	set_bit(EV_KEY, hi->input->evbit);
	set_bit(EV_SW, hi->input->evbit);
	set_bit(hi->key_code, hi->input->keybit);
	set_bit(SW_HEADPHONE_INSERT, hi->input->swbit);
	set_bit(SW_MICROPHONE_INSERT, hi->input->swbit);

	ret = input_register_device(hi->input);
	if (ret) {
		HSD_ERR("Failed to register input device\n");
		goto error_09;
	}
#ifdef CONFIG_LGE_AUDIO_FSA8008_MODIFY
	if (gpio_get_value_cansleep(hi->gpio_detect) == EARJACK_INSERTED) {
		queue_delayed_work(local_fsa8008_workqueue, &(hi->work_for_insert), 0); /* to detect in initialization with eacjack insertion */
	}
#else
	if (!gpio_get_value_cansleep(hi->gpio_detect))
#ifdef CONFIG_FSA8008_USE_LOCAL_WORK_QUEUE
		queue_delayed_work(local_fsa8008_workqueue, &(hi->work), 0); /* to detect in initialization with eacjack insertion */
#else
		schedule_delayed_work(&(hi->work), 0); /* to detect in initialization with eacjack insertion */
#endif
#endif

#ifdef AT_TEST_GPKD
	err = device_create_file(&pdev->dev, &dev_attr_hookkeylog);
#endif

	return ret;

error_09:
	input_free_device(hi->input);
error_08:
	switch_dev_unregister(&hi->sdev);

error_07:
	free_irq(hi->irq_key, 0);
error_06:
	free_irq(hi->irq_detect, 0);

error_05:
	gpio_free(hi->gpio_mic_en);
error_04:
	gpio_free(hi->gpio_key);
error_03:
	gpio_free(hi->gpio_jpole);
error_02:
	gpio_free(hi->gpio_detect);

error_01:
	mutex_destroy(&hi->mutex_lock);
	kfree(hi);

	return ret;
}
static void hw_tsensor_debug_work(void)
{
   hkadc_tsensor_debug_show();
   schedule_delayed_work(&tsensor_debug_work,
                        msecs_to_jiffies(60*1000));// 60s
}
/*****************************************************************************
 函 数 名  : tsensor_temp_check
 功能描述  : tsensor温度检测保护函数
 输入参数  : 无
 输出参数  : 无
 返 回 值  : 无
 调用函数  :
 被调函数  :

 修改历史      :
  1.日    期   : 2013年5月6日
    作    者   : 刘龙 00217270
    修改内容   : 新生成函数 修改历史      :
 1.日    期   : 2014年5月26日
   作    者   : 王欢 w00251051
   修改内容   : V8R1修改
*****************************************************************************/
void tsensor_monitor_work_fn(struct work_struct *work)
{
    int tempvalue = 0;
    int ret = TSENSOR_ERR;
    unsigned int index = 0;

    index = tsensor_get_index_by_type(TSENSOR_TYPE_LOCAL);
    ret = tsensor_temp_read_by_index(index, &tempvalue);
    if(TSENSOR_OK != ret)
    {
        pr_err("%s,%d tsensor_temp_read_by_index err\n", __func__, __LINE__);
        schedule_delayed_work(&tsensor_gov->tsensor_monitor_work,0);
        return;
    }

    pr_err("%s,%d temp_t0:%d tempvalue: %d\n", __func__, __LINE__,
        gstTempPrtInfo.sensor_config[index].temp_t0,tempvalue);

    if(tempvalue >= gstTempPrtInfo.sensor_config[index].thres_value)
    {
        gstTempPrtInfo.temp_prt_vote |= BIT(TSENSOR_TYPE_LOCAL);
        tsensor_gov->warning_count++;
        if(gstTempPrtInfo.temp_offset_benchmark<=(tempvalue-gstTempPrtInfo.sensor_config[index].temp_t0))
        {
          acpufreq_limit_level_regulator(&gstTempPrtInfo,FREQ_DOWN);
          gstTempPrtInfo.sensor_config[index].temp_t0 = tempvalue;
          pr_err("acpufreq regulator FREQ_DOWN.\n");
        }
    }
    else if (tempvalue >= (gstTempPrtInfo.sensor_config[index].thres_value -
        gstTempPrtInfo.sensor_config[index].lag_value))
    {
        if(gstTempPrtInfo.temp_offset_benchmark<=(gstTempPrtInfo.sensor_config[index].temp_t0 - tempvalue))
        {
          acpufreq_limit_level_regulator(&gstTempPrtInfo,FREQ_UP);
          gstTempPrtInfo.temp_prt_vote |= BIT(TSENSOR_TYPE_LOCAL);
          gstTempPrtInfo.sensor_config[index].temp_t0 = tempvalue;
          pr_err("acpufreq regulator FREQ_UP.\n");
        }
    }
    else 
    {
        pwrctrl_acpu_freq_limit_max(gstTempPrtInfo.acpu_freq_limit_table[0], LOCK_FREQ_OFF);
        gstTempPrtInfo.cur_acpu_freq_index = 0;
        gstTempPrtInfo.sensor_config[index].temp_t0 = tempvalue;
        gstTempPrtInfo.temp_prt_vote &= ~(BIT(TSENSOR_TYPE_LOCAL));
        pr_err("acpu acpufreq_limit OFF.\n");
    }


    index = tsensor_get_index_by_type(TSENSOR_TYPE_GPU);

    if(tempvalue>= gstTempPrtInfo.sensor_config[index].thres_value)
    {
        unsigned int  cur_gpu_freq_index =  gstTempPrtInfo.cur_gpu_freq_index;
        cur_gpu_freq_index++;
        if(cur_gpu_freq_index < gstTempPrtInfo.gpu_freq_limit_num)
        {
           gstTempPrtInfo.cur_gpu_freq_index = cur_gpu_freq_index;
        }
        
        pmqos_gpu_dfs_limit_max(LOCK_FREQ_ON,gstTempPrtInfo.gpu_freq_limit_table[gstTempPrtInfo.cur_gpu_freq_index]);
        gstTempPrtInfo.temp_prt_vote |= BIT(TSENSOR_TYPE_GPU);
        pr_err("gpufreq limit ON: %dM.\n", gstTempPrtInfo.gpu_freq_limit_table[gstTempPrtInfo.cur_gpu_freq_index]);

    }
    else if (tempvalue < gstTempPrtInfo.sensor_config[index].thres_value - gstTempPrtInfo.sensor_config[index].lag_value)
    {
        pmqos_gpu_dfs_limit_max(LOCK_FREQ_OFF, gstTempPrtInfo.gpu_freq_limit_table[0]);
        gstTempPrtInfo.cur_gpu_freq_index = 0;
        gstTempPrtInfo.temp_prt_vote &= ~(BIT(TSENSOR_TYPE_GPU));
        pr_err("gpufreq limit OFF .\n");
   }

    if(gstTempPrtInfo.temp_prt_vote)
    {
        schedule_delayed_work(&tsensor_gov->tsensor_monitor_work,msecs_to_jiffies(tsensor_gov->average_period));
    }
    else
    {
        /*Tsensor0温度检测中断屏蔽寄存器。*/
        TSENSOR_REG_WRITE(SOC_PERI_SCTRL_SC_TEMP0_INT_EN_ADDR(0),
            SOC_PERI_SCTRL_SC_TEMP0_INT_EN_temp0_int_en_START,
            SOC_PERI_SCTRL_SC_TEMP0_INT_EN_temp0_int_en_END,
            0x01);
    }

}
Пример #14
0
static ssize_t apds990x_store_enable_als_sensor(struct device *dev,
				struct device_attribute *attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct apds990x_data *data = i2c_get_clientdata(client);
	unsigned long val = simple_strtoul(buf, NULL, 10);
 	unsigned long flags;
	
	printk("%s: enable als sensor ( %ld)\n", __func__, val);
	
	if ((val != 0) && (val != 1))
	{
		printk("%s: enable als sensor=%ld\n", __func__, val);
		return count;
	}
	
	if(val == 1) {
		//turn on light  sensor
		if (data->enable_als_sensor==0) {

			data->enable_als_sensor = 1;
		
			apds990x_set_enable(client,0); /* Power Off */
		
			apds990x_set_atime(client, data->als_atime);  /* 100.64ms */
		
			apds990x_set_ailt( client, 0);
			apds990x_set_aiht( client, 0xffff);
		
			apds990x_set_control(client, data->control); /* 100mA, IR-diode, 1X PGAIN, 1X AGAIN */
			apds990x_set_pers(client, 0x33); /* 3 persistence */
		
			if (data->enable_ps_sensor) {
				apds990x_set_ptime(client, 0xff); /* 2.72ms */
			
				apds990x_set_ppcount(client, 8); /* 8-pulse */
				apds990x_set_enable(client, 0x27);	 /* if prox sensor was activated previously */
			}
			else {
				apds990x_set_enable(client, 0x3);	 /* only enable light sensor */
			}
		
			spin_lock_irqsave(&data->update_lock.wait_lock, flags); 
		
			/*
			 * If work is already scheduled then subsequent schedules will not
			 * change the scheduled time that's why we have to cancel it first.
			 */
			__cancel_delayed_work(&data->als_dwork);
			schedule_delayed_work(&data->als_dwork, msecs_to_jiffies(data->als_poll_delay));
		
			spin_unlock_irqrestore(&data->update_lock.wait_lock, flags);
		}
	}
	else {
		//turn off light sensor
		// what if the p sensor is active?
		data->enable_als_sensor = 0;
		if (data->enable_ps_sensor) {
			apds990x_set_enable(client,0); /* Power Off */
			apds990x_set_atime(client, 0xf6);  /* 27.2ms */
			apds990x_set_ptime(client, 0xff); /* 2.72ms */
			apds990x_set_ppcount(client, 8); /* 8-pulse */
			apds990x_set_control(client, data->control); /* 100mA, IR-diode, 1X PGAIN, 1X AGAIN */
			
			//apds990x_set_piht(client, 0);
			//apds990x_set_piht(client, APDS990x_PS_DETECTION_THRESHOLD);
			
			apds990x_set_ailt( client, 0);
			apds990x_set_aiht( client, 0xffff);
			
			apds990x_set_pers(client, 0x33); /* 3 persistence */
			apds990x_set_enable(client, 0x27);	 /* only enable prox sensor with interrupt */			
		}
		else {
			apds990x_set_enable(client, 0);
		}
		
		
		spin_lock_irqsave(&data->update_lock.wait_lock, flags); 
		
		/*
		 * If work is already scheduled then subsequent schedules will not
		 * change the scheduled time that's why we have to cancel it first.
		 */
		__cancel_delayed_work(&data->als_dwork);
		
		spin_unlock_irqrestore(&data->update_lock.wait_lock, flags); 
	}
	
	return count;
}
static void flip_cover_work(struct work_struct *work)
{
	struct gpio_keys_drvdata *ddata =
		container_of(work, struct gpio_keys_drvdata,
				flip_cover_dwork.work);
#if !defined (CONFIG_SEC_MILLET_PROJECT) || !defined (CONFIG_SEC_T8_PROJECT)
	int comp_val[2]={0};
#else
	int comp_val[3]={0};
#endif

	comp_val[0] = gpio_get_value(ddata->gpio_flip_cover);
#if !defined (CONFIG_SEC_MILLET_PROJECT) || !defined (CONFIG_SEC_T8_PROJECT)
	mdelay(30);
#else
	mdelay(10);
#endif
	comp_val[1] = gpio_get_value(ddata->gpio_flip_cover);
#if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_T8_PROJECT)
	mdelay(10);
	comp_val[2] = gpio_get_value(ddata->gpio_flip_cover);
#endif

#if !defined (CONFIG_SEC_MILLET_PROJECT) || !defined (CONFIG_SEC_T8_PROJECT)
	if (comp_val[0] == comp_val[1]) {
#else
	if ((comp_val[0] == comp_val[1]) && (comp_val[0] == comp_val[2])) {
#endif
		if (ddata->flip_code == SW_LID)
			ddata->flip_cover = !gpio_get_value(ddata->gpio_flip_cover);
		else
			ddata->flip_cover = gpio_get_value(ddata->gpio_flip_cover);

		printk(KERN_DEBUG "[keys] %s : %d code 0x%x\n",
			__func__, ddata->flip_cover, ddata->flip_code);

		input_report_switch(ddata->input,
			ddata->flip_code, ddata->flip_cover);
		input_sync(ddata->input);

		if (ddata->flip_cover != flip_status_before) {
#if defined(CONFIG_DUAL_LCD)
			samsung_switching_lcd(ddata->flip_cover);
			samsung_switching_tsp(ddata->flip_cover);
			samsung_switching_tkey(ddata->flip_cover);
			samsung_switching_ssp(ddata->flip_cover);
#endif
		}

		flip_status_before = ddata->flip_cover;
	} else {
		printk(KERN_DEBUG "%s : Value is not same!\n", __func__);
	}
}
#else // CONFIG_SEC_FACTORY
static void flip_cover_work(struct work_struct *work)
{
	struct gpio_keys_drvdata *ddata =
		container_of(work, struct gpio_keys_drvdata,
				flip_cover_dwork.work);

	if (ddata->flip_code == SW_LID)
		ddata->flip_cover = !gpio_get_value(ddata->gpio_flip_cover);
	else
		ddata->flip_cover = gpio_get_value(ddata->gpio_flip_cover);

	printk(KERN_DEBUG "[keys] %s : %d code 0x%x\n",
		__func__, ddata->flip_cover, ddata->flip_code);

	input_report_switch(ddata->input,
			ddata->flip_code, ddata->flip_cover);
	input_sync(ddata->input);

	if (ddata->flip_cover != flip_status_before) {
#if defined(CONFIG_DUAL_LCD)
		samsung_switching_lcd(ddata->flip_cover);
		samsung_switching_tsp(ddata->flip_cover);
		samsung_switching_tkey(ddata->flip_cover);
		samsung_switching_ssp(ddata->flip_cover);
#endif
	}

	flip_status_before = ddata->flip_cover;
}
#endif // CONFIG_SEC_FACTORY

#if defined (CONFIG_SEC_MILLET_PROJECT) || defined (CONFIG_SEC_T8_PROJECT)
static irqreturn_t flip_cover_detect(int irq, void *dev_id)
{
	struct gpio_keys_drvdata *ddata = dev_id;
#define HALL_COMPARISONS 6
	int comp_val[HALL_COMPARISONS]={0};
	int i;

	comp_val[0] = gpio_get_value(ddata->gpio_flip_cover);

	if(comp_val[0]) {
		wake_lock_timeout(&ddata->flip_wake_lock, HZ * 5 / 100); /* 50ms */
	} else {
		wake_unlock(&ddata->flip_wake_lock);
	}

	pr_info("[keys] %s flip_status : %d (%s)\n",
		__func__, comp_val[0], comp_val[0]?"on":"off");

	for(i=1;i<HALL_COMPARISONS;i++){
		mdelay(6);
		comp_val[i] = gpio_get_value(ddata->gpio_flip_cover);
		if(comp_val[i]!=comp_val[0]){
			pr_err("%s : Value is not same!\n", __func__);
			goto out;
		}
	}

	ddata->flip_cover = comp_val[0];
	pr_info("[keys] hall ic reported value: %d (%s)\n",
		ddata->flip_cover, ddata->flip_cover?"on":"off");

	input_report_switch(ddata->input,
		SW_FLIP, ddata->flip_cover);
	input_sync(ddata->input);
out:
	return IRQ_HANDLED;
}
#else
static irqreturn_t flip_cover_detect(int irq, void *dev_id)
{
	bool flip_status;
	struct gpio_keys_drvdata *ddata = dev_id;
#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	bool debounce_status;
#endif
#ifdef CONFIG_SENSORS_HALL_DEBOUNCE
	int DTIME_IRQ, DTIME_WAKE;

	/* Set Debounce time for HALL IC IRQ(wake_lock / IRQ recheck)
	 * ON : 140ms / 70ms
	 * OFF : 50ms / 10ms
	 */
	DTIME_IRQ = ddata->debounce_set ? (HZ*7/100) : (HZ*1/100);
	DTIME_WAKE = ddata->debounce_set ? (HZ*14/100) : (HZ*5/100);
#endif

	if (ddata->flip_code == SW_LID)
		flip_status = !gpio_get_value(ddata->gpio_flip_cover);
	else
		flip_status = gpio_get_value(ddata->gpio_flip_cover);

	cancel_delayed_work_sync(&ddata->flip_cover_dwork);
#ifdef CONFIG_SENSORS_HALL_DEBOUNCE
	printk(KERN_DEBUG "[keys] %s flip_satatus : %d, IRQt : %d, WAKEt : %d\n",
		__func__, flip_status, DTIME_IRQ, DTIME_WAKE);

	if(flip_status) {
		wake_lock_timeout(&ddata->flip_wake_lock, HZ * DTIME_WAKE);
		schedule_delayed_work(&ddata->flip_cover_dwork, DTIME_IRQ);
	} else {
		wake_unlock(&ddata->flip_wake_lock);
		wake_lock_timeout(&ddata->flip_wake_lock, HZ * DTIME_WAKE);
		schedule_delayed_work(&ddata->flip_cover_dwork, DTIME_IRQ);
	}
#else /* CONFIG_SENSORS_HALL_DEBOUNCE */
	printk(KERN_DEBUG "[keys] %s flip_satatus : %d\n",
		__func__, flip_status);

	if(flip_status) {
		wake_lock_timeout(&ddata->flip_wake_lock, HZ * 5 / 100); /* 50ms */
		schedule_delayed_work(&ddata->flip_cover_dwork, HZ * 1 / 100); /* 10ms */
	} else {
#ifdef CONFIG_SENSORS_HALL_IRQ_CTRL
	if (ddata->gsm_area) {
		mdelay(7);
		debounce_status = gpio_get_value(ddata->gpio_flip_cover);
		if (debounce_status != flip_status) {
			printk(KERN_DEBUG "[keys] %s filp ignore IRQ\n",
				__func__);
			return IRQ_HANDLED;
		}
	}
#endif /* CONFIG_SENSORS_HALL_IRQ_CTRL */
		wake_unlock(&ddata->flip_wake_lock);
		schedule_delayed_work(&ddata->flip_cover_dwork, 0);
	}
#endif /* CONFIG_SENSORS_HALL_DEBOUNCE */
	return IRQ_HANDLED;
}
Пример #16
0
int musb_port_suspend(struct musb *musb, bool do_suspend)
{
	struct usb_otg	*otg = musb->xceiv->otg;
	u8		power;
	void __iomem	*mbase = musb->mregs;

	if (!is_host_active(musb))
		return 0;

	/* NOTE:  this doesn't necessarily put PHY into low power mode,
	 * turning off its clock; that's a function of PHY integration and
	 * MUSB_POWER_ENSUSPEND.  PHY may need a clock (sigh) to detect
	 * SE0 changing to connect (J) or wakeup (K) states.
	 */
	power = musb_readb(mbase, MUSB_POWER);
	if (do_suspend) {
		int retries = 10000;

		if (power & MUSB_POWER_RESUME)
			return -EBUSY;

		if (!(power & MUSB_POWER_SUSPENDM)) {
			power |= MUSB_POWER_SUSPENDM;
			musb_writeb(mbase, MUSB_POWER, power);

			/* Needed for OPT A tests */
			power = musb_readb(mbase, MUSB_POWER);
			while (power & MUSB_POWER_SUSPENDM) {
				power = musb_readb(mbase, MUSB_POWER);
				if (retries-- < 1)
					break;
			}
		}

		musb_dbg(musb, "Root port suspended, power %02x", power);

		musb->port1_status |= USB_PORT_STAT_SUSPEND;
		switch (musb->xceiv->otg->state) {
		case OTG_STATE_A_HOST:
			musb->xceiv->otg->state = OTG_STATE_A_SUSPEND;
			musb->is_active = otg->host->b_hnp_enable;
			if (musb->is_active)
				mod_timer(&musb->otg_timer, jiffies
					+ msecs_to_jiffies(
						OTG_TIME_A_AIDL_BDIS));
			musb_platform_try_idle(musb, 0);
			break;
		case OTG_STATE_B_HOST:
			musb->xceiv->otg->state = OTG_STATE_B_WAIT_ACON;
			musb->is_active = otg->host->b_hnp_enable;
			musb_platform_try_idle(musb, 0);
			break;
		default:
			musb_dbg(musb, "bogus rh suspend? %s",
				usb_otg_state_string(musb->xceiv->otg->state));
		}
	} else if (power & MUSB_POWER_SUSPENDM) {
		power &= ~MUSB_POWER_SUSPENDM;
		power |= MUSB_POWER_RESUME;
		musb_writeb(mbase, MUSB_POWER, power);

		musb_dbg(musb, "Root port resuming, power %02x", power);

		musb->port1_status |= MUSB_PORT_STAT_RESUME;
		schedule_delayed_work(&musb->finish_resume_work,
				      msecs_to_jiffies(USB_RESUME_TIMEOUT));
	}
	return 0;
}
DECLARE_DVFS_WORK_FUNC(SET, TOUCH)
{
	struct input_booster *data = (struct input_booster *)booster_data;
	struct booster_dvfs *dvfs = data->dvfses[BOOSTER_DEVICE_TOUCH];

	if (!dvfs || !dvfs->initialized) {
		dev_err(data->dev, "%s: Dvfs is not initialized\n",	__func__);
		return;
	}

	mutex_lock(&dvfs->lock);

	if (!dvfs->level) {
		dev_err(data->dev, "%s : Skip to set booster due to level 0\n", __func__);
		goto out;
	}

	switch (booster_mode) {
	case BOOSTER_MODE_ON:
		cancel_delayed_work(&dvfs->dvfs_off_work);
		cancel_delayed_work(&dvfs->dvfs_chg_work);
		switch (dvfs->level) {
		case BOOSTER_LEVEL1:
		case BOOSTER_LEVEL2:
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL1].hmp_boost);
			set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL1].kfc_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL1].int_freq);
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL1].cpu_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL1].mif_freq);
		break;
		case BOOSTER_LEVEL3:
			set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL3].kfc_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL3].int_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL3].mif_freq);
			remove_qos(&dvfs->cpu_qos);
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL3].hmp_boost);
		break;
		case BOOSTER_LEVEL4:
			set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL4].kfc_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL4].int_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL4].mif_freq);
			remove_qos(&dvfs->cpu_qos);
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL4].hmp_boost);
		break;
		case BOOSTER_LEVEL5:
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL5].hmp_boost);
			set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL5].kfc_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL5].int_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL5].mif_freq);
		break;
		case BOOSTER_LEVEL9:
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL9].hmp_boost);
			set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL9].kfc_freq);
			set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9].int_freq);
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL9].cpu_freq);
			set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9].mif_freq);
		break;
		default:
			dev_err(data->dev, "%s : Undefined type passed[%d]\n", __func__, dvfs->level);
		break;
		}

		if (dvfs->times[dvfs->level].phase_time) {
			schedule_delayed_work(&dvfs->dvfs_chg_work,
								msecs_to_jiffies(dvfs->times[dvfs->level].phase_time));
			if (dvfs->phase_excuted)
				dvfs->phase_excuted = false;
		} else {
			schedule_delayed_work(&dvfs->dvfs_chg_work,
								msecs_to_jiffies(dvfs->times[dvfs->level].head_time));
		}
		dvfs->lock_status = true;

		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS ON [level %d][start time [%d]]\n",
			__func__, dvfs->level, dvfs->times[dvfs->level].phase_time ?: dvfs->times[dvfs->level].head_time);

	break;
	case BOOSTER_MODE_OFF:
		if (dvfs->lock_status)
			schedule_delayed_work(&dvfs->dvfs_off_work,
						msecs_to_jiffies(dvfs->times[dvfs->level].tail_time));
	break;
	case BOOSTER_MODE_FORCE_OFF:
		if (dvfs->lock_status) {
			cancel_delayed_work(&dvfs->dvfs_chg_work);
			cancel_delayed_work(&dvfs->dvfs_off_work);
			schedule_work(&dvfs->dvfs_off_work.work);
		}
	break;
	default:
	break;
	}

out:
	mutex_unlock(&dvfs->lock);
	return;
}
static int check_keyboard_dock(struct sec_keyboard_callbacks *cb, bool val)
{
	struct sec_keyboard_drvdata *data =
		container_of(cb, struct sec_keyboard_drvdata, callbacks);
	int try_cnt = 0;
	int max_cnt = 14;

	if (NULL == data->serio)
		return 0;

	if (!val)
		data->dockconnected = false;
	else {
		cancel_delayed_work_sync(&data->power_dwork);
		/* wakeup by keyboard dock */
		if (data->pre_connected) {
			if (UNKOWN_KEYLAYOUT != data->pre_kl) {
				data->kl = data->pre_kl;
				data->acc_power(3, true);
				printk(KERN_DEBUG "[Keyboard] kl : %d\n",
					data->pre_kl);
				return 1;
			}
		} else
			data->pre_kl = UNKOWN_KEYLAYOUT;

		data->pre_connected = true;

		/* to prevent the over current issue */
		data->acc_power(0, false);

		if (data->check_uart_path)
			data->check_uart_path(true);

		msleep(200);
		data->acc_power(3, true);

		/* try to get handshake data */
		for (try_cnt = 0; try_cnt < max_cnt; try_cnt++) {
			msleep(50);
			if (data->kl != UNKOWN_KEYLAYOUT) {
				data->dockconnected = true;
				break;
			}
			if (gpio_get_value(data->acc_int_gpio)) {
				printk(KERN_DEBUG "[Keyboard] acc is disconnected.\n");
				break;
			}
		}
	}

	if (data->dockconnected)
		return 1;
	else	{
		if (data->pre_connected) {
			data->dockconnected = false;
			schedule_delayed_work(&data->power_dwork, HZ/2);

			data->kl = UNKOWN_KEYLAYOUT;
			release_all_keys(data);
		}
		return 0;
	}
}
/* Touch */
DECLARE_DVFS_DELAYED_WORK_FUNC(CHG, TOUCH)
{
	struct booster_dvfs *dvfs =
		container_of(work, struct booster_dvfs, dvfs_chg_work.work);
	struct input_booster *data = dev_get_drvdata(dvfs->parent_dev);

	mutex_lock(&dvfs->lock);

	if (!dvfs->times[dvfs->level].phase_time)
		dvfs->phase_excuted = false;

	switch (dvfs->level) {
	case BOOSTER_LEVEL0:
	case BOOSTER_LEVEL1:
	case BOOSTER_LEVEL3:
		remove_qos(&dvfs->cpu_qos);
		remove_qos(&dvfs->kfc_qos);
		remove_qos(&dvfs->mif_qos);
		remove_qos(&dvfs->int_qos);
		SET_HMP(data, BOOSTER_DEVICE_TOUCH, false);
		dvfs->lock_status = false;

		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS OFF\n", __func__);
	break;
	case BOOSTER_LEVEL2:
		set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL2].kfc_freq);
		set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL2].int_freq);
		set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL2].mif_freq);
		remove_qos(&dvfs->cpu_qos);
		SET_HMP(data, BOOSTER_DEVICE_TOUCH, false);

		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS CHANGED [level %d]\n", __func__, dvfs->level);
	break;
	case BOOSTER_LEVEL4:
		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS CHANGED [level %d]\n", __func__, dvfs->level);
	break;
	case BOOSTER_LEVEL5:
		if (dvfs->phase_excuted) {
			remove_qos(&dvfs->cpu_qos);
			remove_qos(&dvfs->kfc_qos);
			remove_qos(&dvfs->mif_qos);
			remove_qos(&dvfs->int_qos);
			SET_HMP(data, BOOSTER_DEVICE_TOUCH, false);
			dvfs->lock_status = false;
			dvfs->phase_excuted = false;

			DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS OFF\n", __func__);
		} else {
			set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL5].cpu_freq);
			schedule_delayed_work(&dvfs->dvfs_chg_work,
				msecs_to_jiffies(dvfs->times[BOOSTER_LEVEL5].head_time - dvfs->times[BOOSTER_LEVEL5].phase_time));
			dvfs->phase_excuted = true;
			DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS CHANGED [level %d, start time[%d]]\n",
				__func__, dvfs->level, dvfs->times[BOOSTER_LEVEL5].head_time - dvfs->times[BOOSTER_LEVEL5].phase_time);
		}
	break;
	case BOOSTER_LEVEL9:
		SET_HMP(data, BOOSTER_DEVICE_TOUCH, dvfs->freqs[BOOSTER_LEVEL9_CHG].hmp_boost);
		set_qos(&dvfs->kfc_qos, PM_QOS_KFC_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL9_CHG].kfc_freq);
		set_qos(&dvfs->int_qos, PM_QOS_DEVICE_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9_CHG].int_freq);
		set_qos(&dvfs->cpu_qos, PM_QOS_CPU_FREQ_MIN, dvfs->freqs[BOOSTER_LEVEL9_CHG].cpu_freq);
		set_qos(&dvfs->mif_qos, PM_QOS_BUS_THROUGHPUT, dvfs->freqs[BOOSTER_LEVEL9_CHG].mif_freq);

		DVFS_DEV_DBG(DBG_DVFS, data->dev, "%s : DVFS CHANGED [level %d]\n", __func__, dvfs->level);
	break;
	default:
		dev_err(data->dev, "%s : Undefined type passed[%d]\n", __func__, dvfs->level);
	break;
	}

	if (!dvfs->lock_status)
		dvfs->phase_excuted = false;

	mutex_unlock(&dvfs->lock);
}
static void sec_keyboard_process_data(struct work_struct *work)
{
	struct sec_keyboard_drvdata *data = container_of(work,
			struct sec_keyboard_drvdata, handledata_dwork.work);
	bool press;
	unsigned int keycode;
	unsigned char scan_code = data->scan_code;

	/* keyboard driver need the contry code*/
	if (data->kl == UNKOWN_KEYLAYOUT) {
		switch (scan_code) {
		case US_KEYBOARD:
			data->kl = US_KEYLAYOUT;
			data->keycode[49] = KEY_BACKSLASH;
			/* for the wakeup state*/
			data->pre_kl = data->kl;
			printk(KERN_DEBUG "[Keyboard] US keyboard is attacted.\n");
			break;

		case UK_KEYBOARD:
			data->kl = UK_KEYLAYOUT;
			data->keycode[49] = KEY_NUMERIC_POUND;
			/* for the wakeup state*/
			data->pre_kl = data->kl;
			printk(KERN_DEBUG "[Keyboard] UK keyboard is attacted.\n");
			break;

		default:
			printk(KERN_DEBUG "[Keyboard] Unkown layout : %x\n",
				scan_code);
			break;
		}
	} else {
		switch (scan_code) {
		case 0x0:
			release_all_keys(data);
			break;

		case 0xca: /* Caps lock on */
		case 0xcb: /* Caps lock off */
		case 0xeb: /* US keyboard */
		case 0xec: /* UK keyboard */
			break; /* Ignore */

		case 0x45:
		case 0x48:
			data->remap_key = scan_code;
			data->pressed[scan_code] = true;
			schedule_delayed_work(&data->remap_dwork, HZ/3);
			break;

		case 0xc5:
		case 0xc8:
			keycode = (scan_code & 0x7f);
			data->pressed[keycode] = false;
			if (0 == data->remap_key) {
				input_report_key(data->input_dev,
					data->keycode[keycode], 0);
				input_sync(data->input_dev);
			} else {
				cancel_delayed_work_sync(&data->remap_dwork);
				if (0x48 == keycode)
					keycode = KEY_NEXTSONG;
				else
					keycode = KEY_PREVIOUSSONG;

				input_report_key(data->input_dev,
					keycode, 1);
				input_report_key(data->input_dev,
					keycode, 0);
				input_sync(data->input_dev);
			}
			break;

		default:
			keycode = (scan_code & 0x7f);
			press = ((scan_code & 0x80) != 0x80);

			if (keycode >= KEYBOARD_MIN
				|| keycode <= KEYBOARD_MAX) {
				data->pressed[keycode] = press;
				input_report_key(data->input_dev,
					data->keycode[keycode], press);
				input_sync(data->input_dev);
			}
			break;
		}
	}
}
/* boost switching logic:
 * - boost_working means that freq is already set to high value
 * - boost_scheduled means that job is scheduled to turn boost either on or off
 * - boost_required is a flag for scheduled job telling it what to do with boost
 *
 * if we are in APE_50_OPP, skip boost
 * if we are in APE_100_OPP and util>boost_up_thresh, shedule boost if its not on or - if its on and scheduled to be turned off -  cancel that schedule
 * if boost is scheduled and not yet working and util < util_high_to_low, then cancel scheduled boost
 * if boost is on and util < boost_down_thresh, schedule boost to be turned off
 */
void mali_utilization_function(struct work_struct *ptr)
{
	/*By default, platform start with 50% APE OPP and 25% DDR OPP*/
	static u32 has_requested_low = 1;

	MALI_DEBUG_PRINT(5, ("MALI GPU utilization: %u\n", mali_last_utilization));

	mutex_lock(&mali_boost_lock);
	if ((!boost_required && !boost_working && !boost_scheduled) || !boost_enable) {
		// consider power saving mode (APE_50_OPP) only if we're not on boost
		if (mali_last_utilization > mali_utilization_low_to_high) {
			if (has_requested_low) {
				MALI_DEBUG_PRINT(5, ("MALI GPU utilization: %u SIGNAL_HIGH\n", mali_last_utilization));
				/*Request 100% APE_OPP.*/
				prcmu_qos_update_requirement(PRCMU_QOS_APE_OPP, "mali", PRCMU_QOS_MAX_VALUE);
				/*
				* Since the utilization values will be reported higher
				* if DDR_OPP is lowered, we also request 100% DDR_OPP.
				*/
				prcmu_qos_update_requirement(PRCMU_QOS_DDR_OPP, "mali", PRCMU_QOS_MAX_VALUE);
				has_requested_low = 0;
				mutex_unlock(&mali_boost_lock);
				return;		//After we switch to APE_100_OPP we want to measure utilization once again before entering boost logic
			}
		} else {
			if (mali_last_utilization < mali_utilization_high_to_low) {
				if (!has_requested_low) {
					/*Remove APE_OPP and DDR_OPP requests*/
					prcmu_qos_update_requirement(PRCMU_QOS_DDR_OPP, "mali", PRCMU_QOS_DEFAULT_VALUE);
					prcmu_qos_update_requirement(PRCMU_QOS_APE_OPP, "mali", PRCMU_QOS_DEFAULT_VALUE);
					MALI_DEBUG_PRINT(5, ("MALI GPU utilization: %u SIGNAL_LOW\n", mali_last_utilization));
					has_requested_low = 1;
				}
			}
		}
	}

	if (!has_requested_low && boost_enable) {
		// consider boost only if we are in APE_100_OPP mode
		if (!boost_required && mali_last_utilization > boost_upthreshold) {
			boost_required = true;
			if (!boost_scheduled) {
				//schedule job to turn boost on
				boost_scheduled = true;
				schedule_delayed_work(&mali_boost_delayedwork, msecs_to_jiffies(boost_delay));
			} else {
				//cancel job meant to turn boost off
				boost_scheduled = false;
				cancel_delayed_work(&mali_boost_delayedwork);
			}
		} else if (boost_required && !boost_working && mali_last_utilization < boost_downthreshold) {
			boost_required = false;
			if (boost_scheduled) {
				//if it's not working yet, but is scheduled to be turned on, than cancel scheduled job
				cancel_delayed_work(&mali_boost_delayedwork);
				boost_scheduled = false;
			}
		} else if (boost_working && mali_last_utilization < boost_downthreshold) {
			boost_required = false;
			if (!boost_scheduled) {
				// if boost is on and isn't yet scheduled to be turned off then schedule it
				boost_scheduled = true;
				schedule_delayed_work(&mali_boost_delayedwork, msecs_to_jiffies(boost_delay));
			}
		}
	}
	mutex_unlock(&mali_boost_lock);

}
Пример #22
0
static int netvsc_probe(struct hv_device *dev,
			const struct hv_vmbus_device_id *dev_id)
{
	struct net_device *net = NULL;
	struct net_device_context *net_device_ctx;
	struct netvsc_device_info device_info;
	struct netvsc_device *nvdev;
	int ret;
	u32 max_needed_headroom;

	net = alloc_etherdev_mq(sizeof(struct net_device_context),
				num_online_cpus());
	if (!net)
		return -ENOMEM;

	max_needed_headroom = sizeof(struct hv_netvsc_packet) +
			      RNDIS_AND_PPI_SIZE;

	netif_carrier_off(net);

	net_device_ctx = netdev_priv(net);
	net_device_ctx->device_ctx = dev;
	hv_set_drvdata(dev, net);
	INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_link_change);
	INIT_WORK(&net_device_ctx->work, do_set_multicast);

	net->netdev_ops = &device_ops;

	net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG | NETIF_F_IP_CSUM |
				NETIF_F_TSO;
	net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM |
			NETIF_F_IP_CSUM | NETIF_F_TSO;

	net->ethtool_ops = &ethtool_ops;
	SET_NETDEV_DEV(net, &dev->device);

	/*
	 * Request additional head room in the skb.
	 * We will use this space to build the rndis
	 * heaser and other state we need to maintain.
	 */
	net->needed_headroom = max_needed_headroom;

	/* Notify the netvsc driver of the new device */
	device_info.ring_size = ring_size;
	ret = rndis_filter_device_add(dev, &device_info);
	if (ret != 0) {
		netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
		free_netdev(net);
		hv_set_drvdata(dev, NULL);
		return ret;
	}
	memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);

	nvdev = hv_get_drvdata(dev);
	netif_set_real_num_tx_queues(net, nvdev->num_chn);
	netif_set_real_num_rx_queues(net, nvdev->num_chn);

	ret = register_netdev(net);
	if (ret != 0) {
		pr_err("Unable to register netdev.\n");
		rndis_filter_device_remove(dev);
		free_netdev(net);
	} else {
		schedule_delayed_work(&net_device_ctx->dwork, 0);
	}

	return ret;
}
Пример #23
0
void connectivity_switching_init(struct work_struct *ignored)
{
	int usb_sel,uart_sel,samsung_kies_sel,ums_sel,mtp_sel,vtp_sel,askon_sel;
	int lpm_mode_check = charging_mode_get();

	if (sec_get_param_value){
		sec_get_param_value(__SWITCH_SEL, &switch_sel);
		cancel_delayed_work(&micorusb_init_work);
	}
	else{
		schedule_delayed_work(&micorusb_init_work, msecs_to_jiffies(200));		
		return;
	}

	if(BOOTUP){
		BOOTUP = 0; 
		otg_phy_init(); //USB Power on after boot up.
	}

	printk("[FSA9480]connectivity_switching_init = switch_sel : 0x%x\n",switch_sel);

	usb_sel = switch_sel & (int)(USB_SEL_MASK);
	uart_sel = (switch_sel & (int)(UART_SEL_MASK)) >> 1;
	samsung_kies_sel = (switch_sel & (int)(USB_SAMSUNG_KIES_MASK)) >> 2;
	ums_sel = (switch_sel & (int)(USB_UMS_MASK)) >> 3;
	mtp_sel = (switch_sel & (int)(USB_MTP_MASK)) >> 4;
#if !defined(CONFIG_ARIES_NTT) // disable tethering xmoondash
	vtp_sel = (switch_sel & (int)(USB_VTP_MASK)) >> 5;
#endif
	askon_sel = (switch_sel & (int)(USB_ASKON_MASK)) >> 6;

	if((switch_sel == 0x1) || (factoryresetstatus == 0xAE)){
		PathSelStore(AP_USB_MODE);
		Ap_Cp_Switch_Config(AP_USB_MODE);	
		usb_switching_value_update(SWITCH_PDA);

		PathSelStore(CP_UART_MODE);
		Ap_Cp_Switch_Config(CP_UART_MODE);	
		uart_switching_value_update(SWITCH_MODEM);
	}
	else{
	    if(usb_sel) {
		    Ap_Cp_Switch_Config(AP_USB_MODE);
		    usb_switching_value_update(SWITCH_PDA);
	    }
	    else {
			if(MicroJigUARTOffStatus){
			    Ap_Cp_Switch_Config(AP_USB_MODE);
			}
		    else {
			    Ap_Cp_Switch_Config(CP_USB_MODE);
			    usb_switching_value_update(SWITCH_MODEM);
		    }
	    }

	    if(uart_sel) {
		    Ap_Cp_Switch_Config(AP_UART_MODE);
		    uart_switching_value_update(SWITCH_PDA);
	    }
	    else {
		    Ap_Cp_Switch_Config(CP_UART_MODE);
		    uart_switching_value_update(SWITCH_MODEM);
	    }
	}

	/*Turn off usb power when LPM mode*/
	if(lpm_mode_check)
		otg_phy_off();
			
		switching_value_update();	

	if((switch_sel == 1) || (factoryresetstatus == 0xAE)){
		usb_switch_select(USBSTATUS_SAMSUNG_KIES);
		mtp_mode_on = 0;
//		ap_usb_power_on(0);
		UsbMenuSelStore(0);	
	}
	else{
		if(usb_sel){
			if(samsung_kies_sel){
				usb_switch_select(USBSTATUS_SAMSUNG_KIES);
				/*USB Power off till MTP Appl launching*/				
				mtp_mode_on = 0;
//				ap_usb_power_on(0);
			}
			else if(mtp_sel){
				usb_switch_select(USBSTATUS_MTPONLY);
				/*USB Power off till MTP Appl launching*/				
				mtp_mode_on = 1;
				ap_usb_power_on(0);
			}
			else if(ums_sel){
				usb_switch_select(USBSTATUS_UMS);
			}
#if !defined(CONFIG_ARIES_NTT) // disable tethering xmoondash
			else if(vtp_sel){
				usb_switch_select(USBSTATUS_VTP);
			}
#endif
			else if(askon_sel){
				usb_switch_select(USBSTATUS_ASKON);
			}			
		}
	}

	if(!FSA9480_Get_USB_Status()) {
		s3c_usb_cable(1);
		mdelay(5);
		s3c_usb_cable(0);
	}

	printk("[FSA9480]connectivity_switching_init = switch_sel : 0x%x\n",switch_sel);
	microusb_uart_status(1);

	connectivity_switching_init_state=1;
}
Пример #24
0
static int compass_akm_set_mode(struct i2c_client *client, char mode)
{
	struct sensor_private_data* sensor = (struct sensor_private_data *)i2c_get_clientdata(this_client); 
	int result = 0;	

	switch(mode)
	{
		case AK8975_MODE_SNG_MEASURE:
		case AK8975_MODE_SELF_TEST: 	
		case AK8975_MODE_FUSE_ACCESS:			
			if(sensor->status_cur == SENSOR_OFF)
			{
				if(sensor->pdata->irq_enable)
				{
					//DBG("%s:enable irq=%d\n",__func__,client->irq);
					//enable_irq(client->irq);
				}	
				else
				{
					schedule_delayed_work(&sensor->delaywork, msecs_to_jiffies(sensor->pdata->poll_delay_ms));
				}
				
				sensor->status_cur = SENSOR_ON;
			}

			break;

		case AK8975_MODE_POWERDOWN: 	
			if(sensor->status_cur == SENSOR_ON)
			{
				if(sensor->pdata->irq_enable)
				{	
					//DBG("%s:disable irq=%d\n",__func__,client->irq);
					//disable_irq_nosync(client->irq);//disable irq
				}
				else
				cancel_delayed_work_sync(&sensor->delaywork);	

				sensor->status_cur = SENSOR_OFF;
			}
			break;

	}
	
	switch(mode)
	{
		case AK8975_MODE_SNG_MEASURE:		
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_SNG_MEASURE);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);				
			break;
		case AK8975_MODE_SELF_TEST:			
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_SELF_TEST);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			break;
		case AK8975_MODE_FUSE_ACCESS:
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_FUSE_ACCESS);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			break;
		case AK8975_MODE_POWERDOWN:
			/* Set powerdown mode */
			result = sensor_write_reg(client, sensor->ops->ctrl_reg, AK8975_MODE_POWERDOWN);
			if(result)
			printk("%s:i2c error,mode=%d\n",__func__,mode);
			udelay(100);
			break;
		default:
			printk("%s: Unknown mode(%d)", __func__, mode);
			result = -EINVAL;
			break;
	}
	DBG("%s:mode=%d\n",__func__,mode);
	return result;

}
Пример #25
0
/*
 * Check if the die sensor is cooling down. If it's higher than
 * t_hot since the last throttle then throttle it again.
 * OMAP junction temperature could stay for a long time in an
 * unacceptable temperature range. The idea here is to check after
 * t_hot->throttle the system really came below t_hot else re-throttle
 * and keep doing till it's under t_hot temp range.
 */
static void throttle_delayed_work_fn(struct work_struct *work)
{
    int curr;
    struct omap_temp_sensor *temp_sensor =
        container_of(work, struct omap_temp_sensor,
                     throttle_work.work);
    curr = omap_read_current_temp(temp_sensor);

#ifdef CONFIG_OMAP_TEMP_CONTROL
    if (curr >= temp_limit || curr < 0) {
#else
    if (curr >= BGAP_THRESHOLD_T_HOT || curr < 0) {
#endif
        pr_warn("%s: OMAP temp read %d exceeds the threshold\n",
                __func__, curr);
        omap_thermal_throttle();
        schedule_delayed_work(&temp_sensor->throttle_work,
                              msecs_to_jiffies(THROTTLE_DELAY_MS));
    } else {
        schedule_delayed_work(&temp_sensor->throttle_work,
                              msecs_to_jiffies(THROTTLE_DELAY_MS));
    }
}

static irqreturn_t omap_tshut_irq_handler(int irq, void *data)
{
    struct omap_temp_sensor *temp_sensor = (struct omap_temp_sensor *)data;

    /* Need to handle thermal mgmt in bootloader
     * to avoid restart again at kernel level
     */
    if (temp_sensor->is_efuse_valid) {
        pr_emerg("%s: Thermal shutdown reached rebooting device\n",
                 __func__);
        kernel_restart(NULL);
    } else {
        pr_err("%s:Invalid EFUSE, Non-trimmed BGAP\n", __func__);
    }

    return IRQ_HANDLED;
}

static irqreturn_t omap_talert_irq_handler(int irq, void *data)
{
    struct omap_temp_sensor *temp_sensor = (struct omap_temp_sensor *)data;
    int t_hot, t_cold, temp_offset;

    t_hot = omap_temp_sensor_readl(temp_sensor, BGAP_STATUS_OFFSET)
            & OMAP4_HOT_FLAG_MASK;
    t_cold = omap_temp_sensor_readl(temp_sensor, BGAP_STATUS_OFFSET)
             & OMAP4_COLD_FLAG_MASK;
    temp_offset = omap_temp_sensor_readl(temp_sensor, BGAP_CTRL_OFFSET);
    if (t_hot) {
        omap_thermal_throttle();
        schedule_delayed_work(&temp_sensor->throttle_work,
                              msecs_to_jiffies(THROTTLE_DELAY_MS));
        temp_offset &= ~(OMAP4_MASK_HOT_MASK);
        temp_offset |= OMAP4_MASK_COLD_MASK;
    } else if (t_cold) {
        cancel_delayed_work_sync(&temp_sensor->throttle_work);
        omap_thermal_unthrottle();
        temp_offset &= ~(OMAP4_MASK_COLD_MASK);
        temp_offset |= OMAP4_MASK_HOT_MASK;
    }

    omap_temp_sensor_writel(temp_sensor, temp_offset, BGAP_CTRL_OFFSET);

    return IRQ_HANDLED;
}

static int __devinit omap_temp_sensor_probe(struct platform_device *pdev)
{
    struct device *dev = &pdev->dev;
    struct omap_temp_sensor_pdata *pdata = pdev->dev.platform_data;
    struct omap_temp_sensor *temp_sensor;
    struct resource *mem;
    int ret = 0, val;

    if (!pdata) {
        dev_err(dev, "%s: platform data missing\n", __func__);
        return -EINVAL;
    }

    temp_sensor = kzalloc(sizeof(struct omap_temp_sensor), GFP_KERNEL);
    if (!temp_sensor)
        return -ENOMEM;

    spin_lock_init(&temp_sensor->lock);

    mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
    if (!mem) {
        dev_err(dev, "%s:no mem resource\n", __func__);
        ret = -EINVAL;
        goto plat_res_err;
    }

    temp_sensor->irq = platform_get_irq_byname(pdev, "thermal_alert");
    if (temp_sensor->irq < 0) {
        dev_err(dev, "%s:Cannot get thermal alert irq\n",
                __func__);
        ret = -EINVAL;
        goto get_irq_err;
    }

    ret = gpio_request_one(OMAP_TSHUT_GPIO, GPIOF_DIR_IN,
                           "thermal_shutdown");
    if (ret) {
        dev_err(dev, "%s: Could not get tshut_gpio\n",
                __func__);
        goto tshut_gpio_req_err;
    }

    temp_sensor->tshut_irq = gpio_to_irq(OMAP_TSHUT_GPIO);
    if (temp_sensor->tshut_irq < 0) {
        dev_err(dev, "%s:Cannot get thermal shutdown irq\n",
                __func__);
        ret = -EINVAL;
        goto get_tshut_irq_err;
    }

    temp_sensor->phy_base = pdata->offset;
    temp_sensor->pdev = pdev;
    temp_sensor->dev = dev;

    pm_runtime_enable(dev);
    pm_runtime_irq_safe(dev);

    /*
     * check if the efuse has a non-zero value if not
     * it is an untrimmed sample and the temperatures
     * may not be accurate */
    if (omap_readl(OMAP4_CTRL_MODULE_CORE +
                   OMAP4_CTRL_MODULE_CORE_STD_FUSE_OPP_BGAP))
        temp_sensor->is_efuse_valid = 1;

    temp_sensor->clock = clk_get(&temp_sensor->pdev->dev, "fck");
    if (IS_ERR(temp_sensor->clock)) {
        ret = PTR_ERR(temp_sensor->clock);
        pr_err("%s:Unable to get fclk: %d\n", __func__, ret);
        ret = -EINVAL;
        goto clk_get_err;
    }

    /* Init delayed work for throttle decision */
    INIT_DELAYED_WORK(&temp_sensor->throttle_work,
                      throttle_delayed_work_fn);

    platform_set_drvdata(pdev, temp_sensor);

    ret = omap_temp_sensor_enable(temp_sensor);
    if (ret) {
        dev_err(dev, "%s:Cannot enable temp sensor\n", __func__);
        goto sensor_enable_err;
    }

    omap_enable_continuous_mode(temp_sensor);
    omap_configure_temp_sensor_thresholds(temp_sensor);
    /* 1 ms */
    omap_configure_temp_sensor_counter(temp_sensor, 1);

    /* Wait till the first conversion is done wait for at least 1ms */
    mdelay(2);

    /* Read the temperature once due to hw issue*/
    omap_read_current_temp(temp_sensor);

    /* Set 2 seconds time as default counter */
    omap_configure_temp_sensor_counter(temp_sensor,
                                       temp_sensor->clk_rate * 2);
    ret = request_threaded_irq(temp_sensor->irq, NULL,
                               omap_talert_irq_handler,
                               IRQF_TRIGGER_RISING | IRQF_ONESHOT,
                               "temp_sensor", (void *)temp_sensor);
    if (ret) {
        dev_err(dev, "Request threaded irq failed.\n");
        goto req_irq_err;
    }

    ret = request_threaded_irq(temp_sensor->tshut_irq, NULL,
                               omap_tshut_irq_handler,
                               IRQF_TRIGGER_RISING | IRQF_ONESHOT,
                               "tshut", (void *)temp_sensor);
    if (ret) {
        dev_err(dev, "Request threaded irq failed for TSHUT.\n");
        goto tshut_irq_req_err;
    }

    ret = sysfs_create_group(&pdev->dev.kobj, &omap_temp_sensor_group);
    if (ret) {
        dev_err(&pdev->dev, "could not create sysfs files\n");
        goto sysfs_create_err;
    }

    /* unmask the T_COLD and unmask T_HOT at init */
    val = omap_temp_sensor_readl(temp_sensor, BGAP_CTRL_OFFSET);
    val |= OMAP4_MASK_COLD_MASK;
    val |= OMAP4_MASK_HOT_MASK;
    omap_temp_sensor_writel(temp_sensor, val, BGAP_CTRL_OFFSET);

    dev_info(dev, "%s probed", pdata->name);

    temp_sensor_pm = temp_sensor;

#ifdef CONFIG_OMAP_TEMP_CONTROL
    ctrl_sensor = temp_sensor;
    tempcontrol_registerlimit(temp_limit);
#endif

    return 0;

sysfs_create_err:
    free_irq(temp_sensor->tshut_irq, temp_sensor);
    cancel_delayed_work_sync(&temp_sensor->throttle_work);
tshut_irq_req_err:
    free_irq(temp_sensor->irq, temp_sensor);
req_irq_err:
    platform_set_drvdata(pdev, NULL);
    omap_temp_sensor_disable(temp_sensor);
sensor_enable_err:
    clk_put(temp_sensor->clock);
clk_get_err:
    pm_runtime_disable(dev);
get_tshut_irq_err:
    gpio_free(OMAP_TSHUT_GPIO);
tshut_gpio_req_err:
get_irq_err:
plat_res_err:
    kfree(temp_sensor);
    return ret;
}

static int __devexit omap_temp_sensor_remove(struct platform_device *pdev)
{
    struct omap_temp_sensor *temp_sensor = platform_get_drvdata(pdev);

    sysfs_remove_group(&pdev->dev.kobj, &omap_temp_sensor_group);
    cancel_delayed_work_sync(&temp_sensor->throttle_work);
    omap_temp_sensor_disable(temp_sensor);
    clk_put(temp_sensor->clock);
    platform_set_drvdata(pdev, NULL);
    if (temp_sensor->irq)
        free_irq(temp_sensor->irq, temp_sensor);
    if (temp_sensor->tshut_irq)
        free_irq(temp_sensor->tshut_irq, temp_sensor);
    kfree(temp_sensor);

    return 0;
}

#ifdef CONFIG_PM
static void omap_temp_sensor_save_ctxt(struct omap_temp_sensor *temp_sensor)
{
    temp_sensor_context.temp_sensor_ctrl =
        omap_temp_sensor_readl(temp_sensor, TEMP_SENSOR_CTRL_OFFSET);
    temp_sensor_context.bg_ctrl =
        omap_temp_sensor_readl(temp_sensor, BGAP_CTRL_OFFSET);
    temp_sensor_context.bg_counter =
        omap_temp_sensor_readl(temp_sensor, BGAP_COUNTER_OFFSET);
    temp_sensor_context.bg_threshold =
        omap_temp_sensor_readl(temp_sensor, BGAP_THRESHOLD_OFFSET);
    temp_sensor_context.temp_sensor_tshut_threshold =
        omap_temp_sensor_readl(temp_sensor, BGAP_TSHUT_OFFSET);
}
Пример #26
0
/* Remote-control poll function - called every dib->rc_query_interval ms to see
 * whether the remote control has received anything.
 *
 * TODO: Fix the repeat rate of the input device.
 */
static void dvb_usb_read_remote_control(struct work_struct *work)
{
	struct dvb_usb_device *d =
		container_of(work, struct dvb_usb_device, rc_query_work.work);
	u32 event;
	int state;

	/* TODO: need a lock here.  We can simply skip checking for the remote control
	   if we're busy. */

	/* when the parameter has been set to 1 via sysfs while the driver was running */
	if (dvb_usb_disable_rc_polling)
		return;

	if (d->props.rc_query(d,&event,&state)) {
		err("error while querying for an remote control event.");
		goto schedule;
	}


	switch (state) {
		case REMOTE_NO_KEY_PRESSED:
			break;
		case REMOTE_KEY_PRESSED:
			deb_rc("key pressed\n");
			d->last_event = event;
		case REMOTE_KEY_REPEAT:
			deb_rc("key repeated\n");
			input_event(d->rc_input_dev, EV_KEY, event, 1);
			input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
			input_sync(d->rc_input_dev);
			break;
		default:
			break;
	}

/* improved repeat handling ???
	switch (state) {
		case REMOTE_NO_KEY_PRESSED:
			deb_rc("NO KEY PRESSED\n");
			if (d->last_state != REMOTE_NO_KEY_PRESSED) {
				deb_rc("releasing event %d\n",d->last_event);
				input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
				input_sync(d->rc_input_dev);
			}
			d->last_state = REMOTE_NO_KEY_PRESSED;
			d->last_event = 0;
			break;
		case REMOTE_KEY_PRESSED:
			deb_rc("KEY PRESSED\n");
			deb_rc("pressing event %d\n",event);

			input_event(d->rc_input_dev, EV_KEY, event, 1);
			input_sync(d->rc_input_dev);

			d->last_event = event;
			d->last_state = REMOTE_KEY_PRESSED;
			break;
		case REMOTE_KEY_REPEAT:
			deb_rc("KEY_REPEAT\n");
			if (d->last_state != REMOTE_NO_KEY_PRESSED) {
				deb_rc("repeating event %d\n",d->last_event);
				input_event(d->rc_input_dev, EV_KEY, d->last_event, 2);
				input_sync(d->rc_input_dev);
				d->last_state = REMOTE_KEY_REPEAT;
			}
		default:
			break;
	}
*/

schedule:
	schedule_delayed_work(&d->rc_query_work,msecs_to_jiffies(d->props.rc_interval));
}
Пример #27
0
static void pil_proxy_unvote(struct pil_device *pil, unsigned long timeout)
{
	if (pil->desc->ops->proxy_unvote)
		schedule_delayed_work(&pil->proxy, msecs_to_jiffies(timeout));
}
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;
}
Пример #29
0
static void earjack_detect_func( struct work_struct *test_earjack)         
{
	int err;

	struct pm8xxx_mpp_config_data pantech_presto_earjack_adc = {
        	.type   = PM8XXX_MPP_TYPE_D_INPUT,
        	.level  = PM8058_MPP_DIG_LEVEL_S3,
        	.control = PM8XXX_MPP_DIN_TO_INT,
	};

	dbg_func_in();
	dbg("currnet earjack->type: ");
	switch(earjack->type){
		case    EARJACK_STATE_OFF : 
			{
				dbg_without_label("EARJACK_STATE_OFF\n");
				if(EARJACK_INSERTED){
					earjack->type = EARJACK_STATE_CHECK;
#if defined(CONFIG_MIC_BIAS_1_8V)
#else
					err=regulator_is_enabled(hs_jack_l8);
					if(err<=0)  err = regulator_enable(hs_jack_l8);
#endif //defined(CONFIG_MACH_MSM8X60_PRESTO)
                			pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(2), &pantech_presto_earjack_adc);
					//pm8058_mpp_config_digital_in(XOADC_MPP_3,PM8058_MPP_DIG_LEVEL_S3, PM_MPP_DIN_TO_INT);
					schedule_delayed_work(&earjack_work, 5); //50ms
					// return without enable IRQ, wake_unlock.
					return;
				}
				break;
			}
		case    EARJACK_STATE_CHECK  :   
			{
				dbg_without_label("EARJACK_STATE_CHECK\n");   
				if(EARJACK_INSERTED)
				{
					// 3pole
					if(!is_4pole_earjack()){
						dbg("3pole headset inserted.\n");
						earjack->type= EARJACK_STATE_ON_3POLE_CHECK;
						earjack->mic_on = 0;
						earjack->hs_on = 1;
						input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on);
						switch_set_state(&earjack->sdev, switch_state());
						schedule_delayed_work(&earjack_work, 60);   // check if 4pole 600ms
						// return without enable IRQ, wake_unlock.
						return;
					}
					//4pole
					else {
						dbg("4pole headset inserted.\n");
						earjack->type= EARJACK_STATE_ON;
						err=request_threaded_irq(gpio_to_irq(REMOTEKEY_DET),NULL,Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", earjack);
						if(err) 
							dbg("request_threaded_irq failed\n");
						earjack->mic_on = 1;
						earjack->hs_on = 1;
						input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on); //TODO: NO USE?
						input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on);
						switch_set_state(&earjack->sdev, switch_state());
					}
				}
				else // if EARJACK_RELEASED
				{
					earjack->type = EARJACK_STATE_OFF;                
					dbg("earjack_type: -> EARJACK_STATE_OFF");
				}

				break; // case EARJACK_STATE_CHECK 
			}

		case    EARJACK_STATE_ON_3POLE_CHECK  :   
			{                        
				// CHECKING IF 4POLE EARJACK IS INSERTIND?
				dbg_without_label("EARJACK_STATE_ON_3POLE_CHECK\n");   
				if(EARJACK_INSERTED){
					earjack->type= EARJACK_STATE_ON;                   
					if(!is_4pole_earjack()){
						dbg("3pole earjack insert.\n");
#if defined(CONFIG_MIC_BIAS_1_8V)
#else
            err=regulator_is_enabled(hs_jack_l8);
						dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err);
						if(err>0) regulator_disable(hs_jack_l8);
#endif //defined(CONFIG_MACH_MSM8X60_PRESTO)
					}
					else {
						dbg("4pole earjack insert.\n");
						earjack->mic_on =1;
						input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on);
    						switch_set_state(&earjack->sdev, switch_state());
						err=request_threaded_irq(gpio_to_irq(REMOTEKEY_DET),NULL,Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", earjack);
						if(err) dbg("request_threaded_irq failed\n");
					}                 
				}
				else{
#if defined(CONFIG_MIC_BIAS_1_8V)
#else          
					err=regulator_is_enabled(hs_jack_l8);
					dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err);
					if(err>0) regulator_disable(hs_jack_l8);
#endif// defined(CONFIG_MACH_MSM8X60_PRESTO)
					earjack->type = EARJACK_STATE_OFF; 
					earjack->hs_on=0;
					input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on);
    					switch_set_state(&earjack->sdev, switch_state());
				}
				break;   
			}

		case EARJACK_STATE_ON:   
			{
				dbg_without_label("EARJACK_STATE_ON\n");
				if(EARJACK_RELEASED){
					earjack->type = EARJACK_STATE_OFF;
					// if 4pole
					if (earjack->mic_on) {
						earjack->mic_on = 0;
						input_report_switch(earjack->ipdev, SW_MICROPHONE_INSERT,earjack->mic_on);
						// free remote key irq and turn off mic power.
						free_irq(gpio_to_irq(REMOTEKEY_DET), earjack);
#if defined(CONFIG_MIC_BIAS_1_8V)
#else
            err=regulator_is_enabled(hs_jack_l8);
						dbg("regulator_is_enabled(hs_jack_l8) value => %d\n",err);
						if(err>0){
							regulator_disable(hs_jack_l8);
						}
#endif //defined(CONFIG_MACH_MSM8X60_PRESTO)

						// release remote key if pressed	
						if(earjack->remotekey_pressed){
							earjack->remotekey_pressed = 0;
							if (earjack->remotekey_index != 0) 
								input_report_key(earjack->ipdev, remotekey_type[earjack->remotekey_index].key_index, earjack->remotekey_pressed);
							dbg("remote key: %s : %d->%d \n", remotekey_type[earjack->remotekey_index].key_name, !earjack->remotekey_pressed, earjack->remotekey_pressed);
							input_sync(earjack->ipdev);
						}                            
						dbg("earjack_release \n");

					}
					earjack->hs_on = 0;
					input_report_switch(earjack->ipdev, SW_HEADPHONE_INSERT,earjack->hs_on);
    					switch_set_state(&earjack->sdev, switch_state());
				}

				break;
			}                    
		default :   
			dbg("earjack_detect_func default.\n");
	}
	enable_irq_detect(); //enable_irq(gpio_to_irq(EARJACK_DET));
	wake_unlock(&earjack_wake_lock);
	dbg_func_out();
	return;
}
Пример #30
0
void hv_kvp_onchannelcallback(void *context)
{
	struct vmbus_channel *channel = context;
	u32 recvlen;
	u64 requestid;

	struct hv_kvp_msg *kvp_msg;

	struct icmsg_hdr *icmsghdrp;
	struct icmsg_negotiate *negop = NULL;
	int util_fw_version;
	int kvp_srv_version;

	if (kvp_transaction.state > HVUTIL_READY)
		return;

	vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen,
			 &requestid);

	if (recvlen > 0) {
		icmsghdrp = (struct icmsg_hdr *)&recv_buffer[
			sizeof(struct vmbuspipe_hdr)];

		if (icmsghdrp->icmsgtype == ICMSGTYPE_NEGOTIATE) {
			/*
			 * Based on the host, select appropriate
			 * framework and service versions we will
			 * negotiate.
			 */
			switch (vmbus_proto_version) {
			case (VERSION_WS2008):
				util_fw_version = UTIL_WS2K8_FW_VERSION;
				kvp_srv_version = WS2008_SRV_VERSION;
				break;
			case (VERSION_WIN7):
				util_fw_version = UTIL_FW_VERSION;
				kvp_srv_version = WIN7_SRV_VERSION;
				break;
			default:
				util_fw_version = UTIL_FW_VERSION;
				kvp_srv_version = WIN8_SRV_VERSION;
			}
			vmbus_prep_negotiate_resp(icmsghdrp, negop,
				 recv_buffer, util_fw_version,
				 kvp_srv_version);

		} else {
			kvp_msg = (struct hv_kvp_msg *)&recv_buffer[
				sizeof(struct vmbuspipe_hdr) +
				sizeof(struct icmsg_hdr)];

			/*
			 * Stash away this global state for completing the
			 * transaction; note transactions are serialized.
			 */

			kvp_transaction.recv_len = recvlen;
			kvp_transaction.recv_channel = channel;
			kvp_transaction.recv_req_id = requestid;
			kvp_transaction.kvp_msg = kvp_msg;

			if (kvp_transaction.state < HVUTIL_READY) {
				/* Userspace is not registered yet */
				kvp_respond_to_host(NULL, HV_E_FAIL);
				return;
			}
			kvp_transaction.state = HVUTIL_HOSTMSG_RECEIVED;

			/*
			 * Get the information from the
			 * user-mode component.
			 * component. This transaction will be
			 * completed when we get the value from
			 * the user-mode component.
			 * Set a timeout to deal with
			 * user-mode not responding.
			 */
			schedule_work(&kvp_sendkey_work);
			schedule_delayed_work(&kvp_timeout_work,
					      HV_UTIL_TIMEOUT * HZ);

			return;

		}

		icmsghdrp->icflags = ICMSGHDRFLAG_TRANSACTION
			| ICMSGHDRFLAG_RESPONSE;

		vmbus_sendpacket(channel, recv_buffer,
				       recvlen, requestid,
				       VM_PKT_DATA_INBAND, 0);
	}

}