Example #1
0
static int
fw_write (struct cdev *dev, struct uio *uio, int ioflag)
{
	int err = 0;
	int s, slept = 0;
	struct fw_drv1 *d;
	struct fw_pkt *fp;
	struct firewire_comm *fc;
	struct fw_xferq *it;

	if (DEV_FWMEM(dev))
		return (physio(dev, uio, ioflag));

	d = (struct fw_drv1 *)dev->si_drv1;
	fc = d->fc;
	it = d->it;

	if (it == NULL)
		return (fw_write_async(d, uio, ioflag));

	if (it->buf == NULL)
		return (EIO);

	FW_GLOCK(fc);
isoloop:
	if (it->stproc == NULL) {
		it->stproc = STAILQ_FIRST(&it->stfree);
		if (it->stproc != NULL) {
			s = splfw();
			STAILQ_REMOVE_HEAD(&it->stfree, link);
			splx(s);
			it->queued = 0;
		} else if (slept == 0) {
			slept = 1;
#if 0	/* XXX to avoid lock recursion */
			err = fc->itx_enable(fc, it->dmach);
			if (err)
				goto out;
#endif
			err = msleep(it, FW_GMTX(fc), FWPRI, "fw_write", hz);
			if (err)
				goto out;
			goto isoloop;
		} else {
			err = EIO;
			goto out;
		}
	}
	FW_GUNLOCK(fc);
	fp = (struct fw_pkt *)fwdma_v_addr(it->buf,
			it->stproc->poffset + it->queued);
	err = uiomove((caddr_t)fp, sizeof(struct fw_isohdr), uio);
	err = uiomove((caddr_t)fp->mode.stream.payload,
				fp->mode.stream.len, uio);
	it->queued ++;
	if (it->queued >= it->bnpacket) {
		s = splfw();
		STAILQ_INSERT_TAIL(&it->stvalid, it->stproc, link);
		splx(s);
		it->stproc = NULL;
		err = fc->itx_enable(fc, it->dmach);
	}
	if (uio->uio_resid >= sizeof(struct fw_isohdr)) {
		slept = 0;
		FW_GLOCK(fc);
		goto isoloop;
	}
	return err;

out:
	FW_GUNLOCK(fc);
	return err;
}
static int mipi_dsi_panel_power(int on)
{
	static struct regulator *reg_lvs7,*reg_l2; 
	static int pm_gpio42,pm_gpio14,pm_gpio26,gpio28;
	int rc;

	struct pm_gpio pm_gpio_param = {
		.direction = PM_GPIO_DIR_OUT,
		.output_buffer = PM_GPIO_OUT_BUF_CMOS,
		.output_value = 1,
		.pull = PM_GPIO_PULL_NO,
		.vin_sel = 2,
		.out_strength = PM_GPIO_STRENGTH_HIGH,
		.function = PM_GPIO_FUNC_NORMAL,
		.inv_int_pol = 0,
		.disable_pin = 0,
	};

	pr_debug("%s: state : %d\n", __func__, on);

	if (unlikely(!dsi_power_on)) {

		pm_gpio42 = PM8921_GPIO_PM_TO_SYS(42);

		rc = gpio_request(pm_gpio42, "mipi_dsi0_reset_n"); /* MIPI_DSI0_RESET_N */
		if (rc) {
			pr_err("request pm gpio 42 failed, rc=%d\n", rc);
			return -ENODEV;
		}

		pm_gpio14 = PM8921_GPIO_PM_TO_SYS(14);

		rc = gpio_request(pm_gpio14, "lcd_bl_en"); /* LCD_BL_EN */
		if (rc) {
			pr_err("request pm gpio 14 failed, rc=%d\n", rc);
			return -ENODEV;
		}

		pm_gpio26 = PM8921_GPIO_PM_TO_SYS(26);

		rc = gpio_request(pm_gpio26, "lcd_bl_ctl"); /* LCD_BL_CTL */
		if (rc) {
			pr_err("request pm gpio 26 failed, rc=%d\n", rc);
			return -ENODEV;
		}

		gpio28 = LCD_VCI_EN;

		rc = gpio_request(gpio28, "mipi_vci_en");
		if (rc) {
			pr_err("request gpio 28 failed, rc=%d\n", rc);
			return -ENODEV;
		}

		reg_lvs7 = regulator_get(&msm_mipi_dsi1_device.dev,
				"dsi1_vddio");
		if (IS_ERR_OR_NULL(reg_lvs7)) {
			pr_err("could not get 8921_lvs7, rc = %ld\n",
				PTR_ERR(reg_lvs7));
			return -ENODEV;
		}

		reg_l2 = regulator_get(&msm_mipi_dsi1_device.dev, "dsi1_pll_vdda"); /* 1.2v */
		if (IS_ERR(reg_l2)) {
			pr_err("could not get 8921_l2, rc = %ld\n",
				PTR_ERR(reg_l2));
			return -ENODEV;
		}

		rc = regulator_set_voltage(reg_l2, 1200000, 1200000); /* VDD_MIPI */
		if (rc) {
			pr_err("set_voltage l2 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		rc = pm8xxx_gpio_config(pm_gpio42,&pm_gpio_param); /* MIPI_DSI0_RESET_N */
		if (rc) {
			pr_err("pm gpio_config 42 failed (3), rc=%d\n", rc);
			return -EINVAL;
		}

		//pm_gpio_param.output_value = 1;
		rc = pm8xxx_gpio_config(pm_gpio14,&pm_gpio_param); /* LCD_BL_EN */
		if (rc) {
			pr_err("pm gpio_config 14 failed (3), rc=%d\n", rc);
			return -EINVAL;
		}

		//pm_gpio_param.output_value = 0;
		rc = pm8xxx_gpio_config(pm_gpio26,&pm_gpio_param); /* LCD_BL_CTL */
		if (rc) {
			pr_err("pm gpio_config 26 failed (3), rc=%d\n", rc);
			return -EINVAL;
		}

		dsi_power_on = true;
	}
	if (on) {

		rc = regulator_set_optimum_mode(reg_l2, 100000); 
		if (rc < 0) {
			pr_err("set_optimum_mode l8 failed, rc=%d\n", rc);
			return -EINVAL;
		}

		rc = regulator_enable(reg_lvs7);
		if (rc) {
			pr_err("enable lvs7 failed, rc=%d\n", rc);
			return -ENODEV;
		}
		msleep(10);

		/* Power for MIPI circuits (CSI & DSI) */
		rc = regulator_enable(reg_l2);  
		if (rc) {
			pr_err("enable l2 failed, rc=%d\n", rc);
			return -ENODEV;
		}

		msleep(10);

		gpio_set_value_cansleep(pm_gpio26, 1);
		/* tD Wait Min 300uS / tE VCI_5V rise Min 0 */
		msleep(2); /* tD Wait + tE VCI_5V rise */

		gpio_set_value_cansleep(pm_gpio42, 1);
		msleep(10);

		gpio_set_value(gpio28, 1); /* LCD_VCI_EN */
		msleep(10); /* tE VCI_5V rise + tF Wait + tG AVEE_-5V fall */

		if (mipi_dsi_splash_is_enabled() && !cont_splash_done) { /* for continue_splash_screen */
			cont_splash_done = 1;
			printk(KERN_INFO "%s : on completed (cont_splash)\n", __func__);
			return 0;
		}	
		
		gpio_set_value_cansleep(pm_gpio42, 0);
		udelay(100);
		gpio_set_value_cansleep(pm_gpio42, 1);
		msleep(5);

		printk(KERN_INFO "%s : on completed\n", __func__);

	} else {

		/* LCD RESET LOW */
		msleep(70);
		gpio_set_value_cansleep(pm_gpio42, 0);
		/* tQ Reset Low Hold Min 10mS */
		msleep(10); /* tQ Reset Low Hold */

		/* LCD BL EN LOW */
		gpio_set_value_cansleep(pm_gpio26, 0);
		
		//gpio_set_value_cansleep(pm_gpio14, 0);

		gpio_set_value(gpio28,0); /* LCD_VCI_EN */

		/* 
			tR AVEE_-5V rise Min 0S / tS Wait Min 4mS 
			tT VCI_5V fall 0S / tU Wait 300uS
		*/
		mdelay(5); /* tR + tS + tT + tU*/

		rc = regulator_disable(reg_l2);	
		if (rc) {
			pr_err("disable reg_l2  failed, rc=%d\n", rc);
			return -ENODEV;
		}

		rc = regulator_disable(reg_lvs7);	
		if (rc) {
			pr_err("disable lvs7  failed, rc=%d\n", rc);
			return -ENODEV;
		}

		printk(KERN_INFO "%s : off completed.\n", __func__);
	}

	return 0;

}

static struct mipi_dsi_platform_data mipi_dsi_pdata = {
	.dsi_power_save = mipi_dsi_panel_power,
	.splash_is_enabled = mipi_dsi_splash_is_enabled,
};

#ifdef CONFIG_FB_MSM_DTV

static int hdmi_panel_power(int on);

static struct msm_bus_vectors dtv_bus_init_vectors[] = {
	{
		.src = MSM_BUS_MASTER_MDP_PORT0,
		.dst = MSM_BUS_SLAVE_EBI_CH0,
		.ab = 0,
		.ib = 0,
	},
};
static kal_uint32 charging_set_ta_current_pattern(void *data)
{
	kal_uint32 status = STATUS_OK;
	kal_uint32 increase = *(kal_uint32*)(data);
	kal_uint32 debug_val = 0;
	U8 count = 0;

		pmic_set_register_value(PMIC_RG_CS_VTH,0xc);

	if(increase == KAL_TRUE) {
	    	/* Set communication mode high/low current */
		pmic_set_register_value(PMIC_RG_CM_CS_VTHH,0xa);/* 650mA */
		pmic_set_register_value(PMIC_RG_CM_CS_VTHL,0xf);/* 70mA */	
	        
		/* Set CM_VINC high period time (HPRD1, HPRD2) */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD1,9);/* 100ms */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD2,9);/* 100ms */			
		
		/* Set CM_VINC high period time (HPRD3, HPRD4) */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD3,29);/* 300ms */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD4,29);/* 300ms */			
		
		/* Set CM_VINC high period time (HPRD5, HPRD6) */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD5,29);/* 300ms */
		pmic_set_register_value(PMIC_RG_CM_VINC_HPRD6,49);/* 500ms */	
		
		/* Enable CM_VINC interrupt */
		//mt6325_upmu_set_rg_int_en_pchr_cm_vinc(0x1);
			   pmic_set_register_value(PMIC_RG_INT_EN_PCHR_CM_VINC,1);
		
		/* Select PCHR debug flag to monitor abnormal abort */
		pmic_set_register_value(PMIC_RG_PCHR_FLAG_SEL,0x2e);	
		
		/* Enable PCHR debug flag */
		pmic_set_register_value(PMIC_RG_PCHR_FLAG_EN,0x1);	
		
		/* Trigger CM VINC mode */
		pmic_set_register_value(PMIC_RG_CM_VINC_TRIG,0x1);	
		
		/* wait for interrupt */
		while(pmic_get_register_value(PMIC_PCHR_CM_VINC_STATUS) != 1) {
				msleep(50);
			count++;
				if (count > 42)
				break;
		}
	} else {
	    	/* Set communication mode high/low current */
		pmic_set_register_value(PMIC_RG_CM_CS_VTHH,0xa);/* 650mA */
		pmic_set_register_value(PMIC_RG_CM_CS_VTHL,0xf);/* 70mA */	
	        
		/* Set CM_VINC high period time (HPRD1, HPRD2) */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD1,29);/* 100ms */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD2,29);/* 100ms */			
		
		/* Set CM_VINC high period time (HPRD3, HPRD4) */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD3,29);/* 300ms */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD4,9);/* 300ms */			
		
		/* Set CM_VINC high period time (HPRD5, HPRD6) */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD5,9);/* 300ms */
			pmic_set_register_value(PMIC_RG_CM_VDEC_HPRD6,49);/* 500ms */	


		
		/* Enable CM_VINC interrupt */
		//mt6325_upmu_set_rg_int_en_pchr_cm_vinc(0x1);
			pmic_set_register_value(PMIC_RG_INT_EN_PCHR_CM_VDEC,1);
		
		/* Select PCHR debug flag to monitor abnormal abort */
		pmic_set_register_value(PMIC_RG_PCHR_FLAG_SEL,0x2e);
		
		/* Enable PCHR debug flag */
		pmic_set_register_value(PMIC_RG_PCHR_FLAG_EN,0x1);
		
		/* Trigger CM VINC mode */
		pmic_set_register_value(PMIC_RG_CM_VDEC_TRIG,0x1);

		/* wait for interrupt */
		while(pmic_get_register_value(PMIC_PCHR_CM_VDEC_STATUS) != 1) {
				msleep(50);
			count++;
				if (count > 42)
				break;
		}        
	}

	debug_val = pmic_get_register_value(PMIC_RGS_PCHR_FLAG_OUT);
	battery_xlog_printk(BAT_LOG_CRTI, "[charging_set_ta_current_pattern] debug_val=0x%x cnt=%d\n", debug_val,count);
	if (count > 10 || debug_val != 0) {
		status = STATUS_FAIL;
	}
	return status;
}
static int emi62_load_firmware (struct usb_device *dev)
{
	const struct firmware *loader_fw = NULL;
	const struct firmware *bitstream_fw = NULL;
	const struct firmware *firmware_fw = NULL;
	const struct ihex_binrec *rec;
	int err;
	int i;
	__u32 addr;	/* Address to write */
	__u8 *buf;

	dev_dbg(&dev->dev, "load_firmware\n");
	buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL);
	if (!buf) {
		err( "%s - error loading firmware: error = %d", __func__, -ENOMEM);
		err = -ENOMEM;
		goto wraperr;
	}

	err = request_ihex_firmware(&loader_fw, "emi62/loader.fw", &dev->dev);
	if (err)
		goto nofw;

	err = request_ihex_firmware(&bitstream_fw, "emi62/bitstream.fw",
				    &dev->dev);
	if (err)
		goto nofw;

	err = request_ihex_firmware(&firmware_fw, FIRMWARE_FW, &dev->dev);
	if (err) {
	nofw:
		err( "%s - request_firmware() failed", __func__);
		goto wraperr;
	}

	/* Assert reset (stop the CPU in the EMI) */
	err = emi62_set_reset(dev,1);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}

	rec = (const struct ihex_binrec *)loader_fw->data;

	/* 1. We need to put the loader for the FPGA into the EZ-USB */
	while (rec) {
		err = emi62_writememory(dev, be32_to_cpu(rec->addr),
					rec->data, be16_to_cpu(rec->len),
					ANCHOR_LOAD_INTERNAL);
		if (err < 0) {
			err("%s - error loading firmware: error = %d", __func__, err);
			goto wraperr;
		}
		rec = ihex_next_binrec(rec);
	}

	/* De-assert reset (let the CPU run) */
	err = emi62_set_reset(dev,0);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}
	msleep(250);	/* let device settle */

	/* 2. We upload the FPGA firmware into the EMI
	 * Note: collect up to 1023 (yes!) bytes and send them with
	 * a single request. This is _much_ faster! */
	rec = (const struct ihex_binrec *)bitstream_fw->data;
	do {
		i = 0;
		addr = be32_to_cpu(rec->addr);

		/* intel hex records are terminated with type 0 element */
		while (rec && (i + be16_to_cpu(rec->len) < FW_LOAD_SIZE)) {
			memcpy(buf + i, rec->data, be16_to_cpu(rec->len));
			i += be16_to_cpu(rec->len);
			rec = ihex_next_binrec(rec);
		}
		err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA);
		if (err < 0) {
			err("%s - error loading firmware: error = %d", __func__, err);
			goto wraperr;
		}
	} while (rec);

	/* Assert reset (stop the CPU in the EMI) */
	err = emi62_set_reset(dev,1);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}

	/* 3. We need to put the loader for the firmware into the EZ-USB (again...) */
	for (rec = (const struct ihex_binrec *)loader_fw->data;
	     rec; rec = ihex_next_binrec(rec)) {
		err = emi62_writememory(dev, be32_to_cpu(rec->addr),
					rec->data, be16_to_cpu(rec->len),
					ANCHOR_LOAD_INTERNAL);
		if (err < 0) {
			err("%s - error loading firmware: error = %d", __func__, err);
			goto wraperr;
		}
	}

	/* De-assert reset (let the CPU run) */
	err = emi62_set_reset(dev,0);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}
	msleep(250);	/* let device settle */

	/* 4. We put the part of the firmware that lies in the external RAM into the EZ-USB */

	for (rec = (const struct ihex_binrec *)firmware_fw->data;
	     rec; rec = ihex_next_binrec(rec)) {
		if (!INTERNAL_RAM(be32_to_cpu(rec->addr))) {
			err = emi62_writememory(dev, be32_to_cpu(rec->addr),
						rec->data, be16_to_cpu(rec->len),
						ANCHOR_LOAD_EXTERNAL);
			if (err < 0) {
				err("%s - error loading firmware: error = %d", __func__, err);
				goto wraperr;
			}
		}
	}

	/* Assert reset (stop the CPU in the EMI) */
	err = emi62_set_reset(dev,1);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}

	for (rec = (const struct ihex_binrec *)firmware_fw->data;
	     rec; rec = ihex_next_binrec(rec)) {
		if (INTERNAL_RAM(be32_to_cpu(rec->addr))) {
			err = emi62_writememory(dev, be32_to_cpu(rec->addr),
						rec->data, be16_to_cpu(rec->len),
						ANCHOR_LOAD_EXTERNAL);
			if (err < 0) {
				err("%s - error loading firmware: error = %d", __func__, err);
				goto wraperr;
			}
		}
	}

	/* De-assert reset (let the CPU run) */
	err = emi62_set_reset(dev,0);
	if (err < 0) {
		err("%s - error loading firmware: error = %d", __func__, err);
		goto wraperr;
	}
	msleep(250);	/* let device settle */

	release_firmware(loader_fw);
	release_firmware(bitstream_fw);
	release_firmware(firmware_fw);

	kfree(buf);

	/* return 1 to fail the driver inialization
	 * and give real driver change to load */
	return 1;

wraperr:
	release_firmware(loader_fw);
	release_firmware(bitstream_fw);
	release_firmware(firmware_fw);

	kfree(buf);
	dev_err(&dev->dev, "Error\n");
	return err;
}
Example #5
0
static int touch_event_handler(void *unused) {
    struct sched_param param = { .sched_priority = RTPM_PRIO_TPD };

    int index;
	uint8_t Firmware_version[3] = {0x20,0x00,0x00};

    sched_setscheduler(current, SCHED_RR, &param);
    do {
        set_current_state(TASK_INTERRUPTIBLE);
        if (!kthread_should_stop()) {
            TPD_DEBUG_CHECK_NO_RESPONSE;
            do {
				while (tpd_halt) {tpd_flag = 0;sinfo.TouchpointFlag=0; msleep(20);}
               		wait_event_interruptible(waiter,tpd_flag!=0);
					tpd_flag = 0;
            } while(0);

            TPD_DEBUG_SET_TIME;
        }
       		 set_current_state(TASK_RUNNING);
#if 0
			 if (tpd_show_version) {
	            tpd_show_version = 0;
			if(tpd_i2c_master_rs_send(i2c_client,Firmware_version,3<<8|1) < 0)
			{
					TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
			}
			else
			{
				TPD_DMESG(" mcs6024 Hardware version is %x\n",Firmware_version[0]);
				TPD_DMESG(" mcs6024 Firmware version is %x\n",Firmware_version[1]);
				TPD_DMESG(" mcs6024 Panel Type  is %x\n",Firmware_version[2]);
			}
		}
		
		 if((tpd_gettouchinfo(&cinfo)) 
            && (sinfo.TouchpointFlag==0) 
            && ((sinfo.VirtualKeyFlag & 0x03) == 0)) 
		 	continue; 
	
		TPD_DEBUG("sinfo.TouchpointFlag = %d\n",sinfo.TouchpointFlag);
		TPD_DEBUG("cinfo.TouchpointFlag = %d\n",cinfo.TouchpointFlag);
        TPD_DEBUG("sinfo.VirtualKeyFlag = %d\n",sinfo.VirtualKeyFlag);
		TPD_DEBUG("cinfo.VirtualKeyFlag = %d\n",cinfo.VirtualKeyFlag);

        #ifdef TPD_HAVE_BUTTON
        int index = (cinfo.VirtualKeyFlag >> 2) & 0x03;
        if (index >= TPD_KEY_COUNT)
            continue;
        
        if ((cinfo.VirtualKeyFlag & 0x03) == 1) {
            if ((sinfo.VirtualKeyFlag & 0x03) == 0) {
                tpd_down(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 128);
                if (boot_mode != NORMAL_BOOT) 
                    tpd_button(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 1);
            }
        } else {
            if ((sinfo.VirtualKeyFlag & 0x03) == 1) {
                tpd_up(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1]);
                if (boot_mode != NORMAL_BOOT) 
                    tpd_button(tpd_keys_dim_local[index][0],tpd_keys_dim_local[index][1], 0);
            }
        }
        #endif
		 
		 for(index = 0;index<MAX_POINT;index++)
		 	{
				if(cinfo.TouchpointFlag&(1<<index))
				{
					raw_x[index] = cinfo.x[index];
					raw_y[index] = cinfo.y[index];
					tpd_down(raw_x[index], raw_y[index], cinfo.x[index],cinfo.y[index], 128);
					sinfo.x[index] = cinfo.x[index];
					sinfo.y[index] = cinfo.y[index];
					sinfo.TouchpointFlag |=(1<<index);
				}
				else
				{
					if(sinfo.TouchpointFlag&(1<<index))
					{
						tpd_up(raw_x[index], raw_y[index], sinfo.x[index], sinfo.y[index]);
						sinfo.TouchpointFlag &=~(1<<index);
					}

				}
		 	}

		 input_sync(tpd->dev);

#endif

		 msg21xx_data_disposal();

		
    } while (!kthread_should_stop());
    return 0;
}
static int sony_blue_is_dric_det(void)
{
	int rc = 0;
	static int val = -ENODEV;

	if (val != -ENODEV)
		return val;

	if (!vreg_lcd_vci) {
		vreg_lcd_vci = regulator_get(NULL, "8921_l8");
		if (IS_ERR(vreg_lcd_vci)) {
			pr_err("%s: Unable to get 8921_l8\n", __func__);
			vreg_lcd_vci = NULL;
			return -ENODEV;
		}
	}

	if (!vreg_lcd_vddio) {
		vreg_lcd_vddio = regulator_get(NULL, "8921_l29");
		if (IS_ERR(vreg_lcd_vddio)) {
			pr_err("%s: Unable to get 8921_l29\n", __func__);
			vreg_lcd_vddio = NULL;
			goto out_put_l8;
		}
	}

	rc = regulator_set_voltage(vreg_lcd_vci, 2850000, 2850000);
	if (rc) {
		pr_err("%s:%d unable to set L8 voltage to 2.85V\n",
			__func__, rc);
		goto out_put_l29;
	}

	rc = regulator_set_voltage(vreg_lcd_vddio, 1800000, 1800000);
	if (rc) {
		pr_err("%s:%d unable to set L29 voltage to 1.8V\n",
			__func__, rc);
		goto out_put_l29;
	}

	rc = regulator_enable(vreg_lcd_vci);
	if (rc) {
		pr_err("%s: Enable regulator 8921_l8 failed\n",
			__func__);
		goto out_put_l29;
	}

	rc = regulator_enable(vreg_lcd_vddio);
	if (rc) {
		pr_err("%s: Enable regulator 8921_l29 failed\n",
			__func__);
		goto out_put_l29;
	}

	lcd_gpio_setup(true);

	msleep(LCD_VENDOR_DET_WAIT_MS);

	/* LCD_VENDOR_DET */
	rc = gpio_request(LCD_VENDOR_DET, "lcd vendor detect");
	if (rc) {
		pr_err("%s: GPIO %d: request failed. rc=%d\n",
			__func__, LCD_VENDOR_DET, rc);
		goto out_put_l29;
	}
	rc = gpio_direction_input(LCD_VENDOR_DET);
	if (rc) {
		pr_err("%s: GPIO %d: direction in failed. rc=%d\n",
			__func__, LCD_VENDOR_DET, rc);
		goto out_free;
	}

	val = gpio_get_value(LCD_VENDOR_DET);
	pr_info("%s: GPIO:%d\n", __func__, val);

	rc = regulator_disable(vreg_lcd_vddio);
	if (rc)
		pr_err("%s: Enable regulator 8921_l29 failed\n",
			__func__);
	rc = regulator_disable(vreg_lcd_vci);
	if (rc)
		pr_err("%s: Enable regulator 8921_l8 failed\n",
			__func__);

	lcd_gpio_setup(false);

out_free:
	gpio_free(LCD_VENDOR_DET);
out_put_l29:
	regulator_put(vreg_lcd_vddio);
	vreg_lcd_vddio = NULL;
out_put_l8:
	regulator_put(vreg_lcd_vci);
	vreg_lcd_vci = NULL;

	msleep(LCD_VENDOR_DISABLE_VREG_WAIT_MS);

	return val;
}
static int nt35565_vreg_power(int on)
{
	int rc = 0;

	if (!vreg_lcd_vci) {
		vreg_lcd_vci = regulator_get(&msm_mipi_dsi1_device.dev,
			"dsi_vci");
		if (IS_ERR(vreg_lcd_vci)) {
			pr_err("could not get dsi_vci, rc = %ld\n",
				PTR_ERR(vreg_lcd_vci));
			return -ENODEV;
		}
	}

	if (!vreg_lcd_vddio) {
		vreg_lcd_vddio = regulator_get(&msm_mipi_dsi1_device.dev,
			"dsi_vddio");
		if (IS_ERR(vreg_lcd_vddio)) {
			pr_err("%s: Unable to get dsi_vddio\n", __func__);
			vreg_lcd_vddio = NULL;
			goto out_put;
		}
	}

	if (on) {
		rc = regulator_set_voltage(vreg_lcd_vci, 2850000, 2850000);
		if (rc) {
			pr_err("%s:%d unable to set dsi_vci voltage to 2.8V\n",
				__func__, rc);
			goto out_put_all;
		}

		rc = regulator_enable(vreg_lcd_vci);
		if (rc) {
			pr_err("%s: Enable regulator dsi_vci failed\n",
				__func__);
			goto out_put_all;
		}

		rc = regulator_set_voltage(vreg_lcd_vddio, 1800000, 1800000);
		if (rc) {
			pr_err("%s:%d unable to set dsi_vddio voltage to 1.8V\n",
				__func__, rc);
			goto out_disable;
		}

		rc = regulator_enable(vreg_lcd_vddio);
		if (rc) {
			pr_err("%s: Enable regulator dsi_vddio failed\n",
				__func__);
			goto out_disable;
		}

		rc = lcd_gpio_setup(on);
		if (rc) {
			pr_err("gpio setup failed , rc=%d\n", rc);
			goto out_disable_all;
		}

		msleep(LCD_VREG_ON_WAIT_MS);

		gpio_set_value_cansleep(gpio_lcd_reset, 1);
		msleep(LCD_RESET_WAIT_MS);
		gpio_set_value_cansleep(gpio_lcd_reset, 0);
		msleep(LCD_RESET_WAIT_MS);
		gpio_set_value_cansleep(gpio_lcd_reset, 1);
		msleep(LCD_RESET_H_WAIT_MS_NT35565);
	} else {
		gpio_set_value_cansleep(gpio_lcd_reset, 0);

		rc = lcd_gpio_setup(on);
		if (rc) {
			pr_err("gpio setup failed , rc=%d\n", rc);
			return -EINVAL;
		}

		rc = regulator_disable(vreg_lcd_vci);
		if (rc)
			pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
				__func__, "dsi_vci", rc);
		rc = regulator_disable(vreg_lcd_vddio);
		if (rc)
			pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
				__func__, "dsi_vddio", rc);
	}

	return 0;
out_disable_all:
	regulator_disable(vreg_lcd_vddio);
out_disable:
	regulator_disable(vreg_lcd_vci);
out_put_all:
	regulator_put(vreg_lcd_vddio);
	vreg_lcd_vddio = NULL;
out_put:
	regulator_put(vreg_lcd_vci);
	vreg_lcd_vci = NULL;
	return rc;
}
Example #8
0
int32_t gc0339_power_up(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t rc = 0, index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;

	CDBG("%s:%d\n", __func__, __LINE__);
	power_setting_array = &s_ctrl->power_setting_array;

	if (data->gpio_conf->cam_gpiomux_conf_tbl != NULL) {
		pr_err("%s:%d mux install\n", __func__, __LINE__);
		msm_gpiomux_install(
			(struct msm_gpiomux_config *)
			data->gpio_conf->cam_gpiomux_conf_tbl,
			data->gpio_conf->cam_gpiomux_conf_tbl_size);
	}

	rc = msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 1);
	if (rc < 0) {
		pr_err("%s: request gpio failed\n", __func__);
		return rc;
	}
	for (index = 0; index < power_setting_array->size; index++) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			if (power_setting->seq_val >= s_ctrl->clk_info_size) {
				pr_err("%s clk index %d >= max %d\n", __func__,
					power_setting->seq_val,
					s_ctrl->clk_info_size);
				goto power_up_failed;
			}
			if (power_setting->config_val)
				s_ctrl->clk_info[power_setting->seq_val].
					clk_rate = power_setting->config_val;

			rc = msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				1);
			if (rc < 0) {
				pr_err("%s: clk enable failed\n",
					__func__);
				goto power_up_failed;
			}
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!data->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			pr_debug("%s:%d gpio set val %d\n", __func__, __LINE__,
				data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val]);
			if (data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					data->gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					power_setting->config_val);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				goto power_up_failed;
			}
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				1);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		rc = s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_INIT);
		if (rc < 0) {
			pr_err("%s cci_init failed\n", __func__);
			goto power_up_failed;
		}
	}

	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write(
		s_ctrl->sensor_i2c_client,
		0xfc,
		0x10, MSM_CAMERA_I2C_BYTE_DATA);

	if (s_ctrl->func_tbl->sensor_match_id)
		rc = s_ctrl->func_tbl->sensor_match_id(s_ctrl);
	else
		rc = msm_sensor_match_id(s_ctrl);
	if (rc < 0) {
		pr_err("%s:%d match id failed rc %d\n", __func__, __LINE__, rc);
		goto power_up_failed;
	}

	CDBG("%s exit\n", __func__);
	return 0;
power_up_failed:
	pr_err("%s:%d failed\n", __func__, __LINE__);
	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	for (index--; index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					data->gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 0);
	return rc;
}
Example #9
0
int32_t gc0339_power_down(struct msm_sensor_ctrl_t *s_ctrl)
{
	int32_t index = 0;
	struct msm_sensor_power_setting_array *power_setting_array = NULL;
	struct msm_sensor_power_setting *power_setting = NULL;
	struct msm_camera_sensor_board_info *data = s_ctrl->sensordata;

	CDBG("%s:%d\n", __func__, __LINE__);
	power_setting_array = &s_ctrl->power_setting_array;

	if (s_ctrl->sensor_device_type == MSM_CAMERA_PLATFORM_DEVICE) {
		s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_util(
			s_ctrl->sensor_i2c_client, MSM_CCI_RELEASE);
	}

	s_ctrl->sensor_i2c_client->i2c_func_tbl->i2c_write(
		s_ctrl->sensor_i2c_client,
		0xfc,
		0x01, MSM_CAMERA_I2C_BYTE_DATA);

	for (index = (power_setting_array->size - 1); index >= 0; index--) {
		CDBG("%s index %d\n", __func__, index);
		power_setting = &power_setting_array->power_setting[index];
		CDBG("%s type %d\n", __func__, power_setting->seq_type);
		switch (power_setting->seq_type) {
		case SENSOR_CLK:
			msm_cam_clk_enable(s_ctrl->dev,
				&s_ctrl->clk_info[0],
				(struct clk **)&power_setting->data[0],
				s_ctrl->clk_info_size,
				0);
			break;
		case SENSOR_GPIO:
			if (power_setting->seq_val >= SENSOR_GPIO_MAX ||
				!data->gpio_conf->gpio_num_info) {
				pr_err("%s gpio index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			if (data->gpio_conf->gpio_num_info->gpio_num
				[power_setting->seq_val])
				gpio_set_value_cansleep(
					data->gpio_conf->gpio_num_info->gpio_num
					[power_setting->seq_val],
					GPIOF_OUT_INIT_LOW);
			break;
		case SENSOR_VREG:
			if (power_setting->seq_val >= CAM_VREG_MAX) {
				pr_err("%s vreg index %d >= max %d\n", __func__,
					power_setting->seq_val,
					SENSOR_GPIO_MAX);
				continue;
			}
			msm_camera_config_single_vreg(s_ctrl->dev,
				&data->cam_vreg[power_setting->seq_val],
				(struct regulator **)&power_setting->data[0],
				0);
			break;
		default:
			pr_err("%s error power seq type %d\n", __func__,
				power_setting->seq_type);
			break;
		}
		if (power_setting->delay > 20) {
			msleep(power_setting->delay);
		} else if (power_setting->delay) {
			usleep_range(power_setting->delay * 1000,
				(power_setting->delay * 1000) + 1000);
		}
	}
	msm_camera_request_gpio_table(
		data->gpio_conf->cam_gpio_req_tbl,
		data->gpio_conf->cam_gpio_req_tbl_size, 0);
	CDBG("%s exit\n", __func__);
	return 0;
}
Example #10
0
int check_keyboard_dock(void)
{
    static bool dockconnected = false;
    static bool pre_connected =false;
    static bool pre_uart_path =false;
    static unsigned long disconnected_time=0;
    int try_cnt = 0;
    int error = 0;
    int max_cnt = 10;

    if(gpio_get_value(g_data->gpio))
    {
        dockconnected = false;
    }
    else
    {
        pre_connected = true;

        /*for checking handshake*/
        connected_time = jiffies;

        if((connected_time - disconnected_time) < HZ)
        {
            g_data->kl = pre_kl;
//            dockconnected = true;
            printk(KERN_DEBUG "[Keyboard] kl : %d\n", pre_kl);
       }
        else
        {
            pre_kl = UNKOWN_KEYLAYOUT;
        }

        set_uart_suspend(0);
        /* if the uart is set as cp path, the path should be switched to ap path.*/
        pre_uart_path = gpio_get_value(OMAP_GPIO_UART_SEL);
        if(!pre_uart_path)
        {
            gpio_set_value(OMAP_GPIO_UART_SEL, 1);
            printk(KERN_DEBUG "[Keyboard] console uart path is switched to AP.\n");
        }

        /* Set baud rate for the keyboard uart */
        error = change_console_baud_rate(9600);
        if(error<0)
        {
            printk(KERN_ERR "[Keyboard] Couldn't modify the baud rate.\n");
            goto con_err;
        }

        if(!keyboard_enable)
        {
	printk("[Keyboard] check_keyboard_dock 6");
           gpio_set_value(en_gpio, 1);
            keyboard_enable = true;
        }

        if(!dockconnected)
        {
            /* try to get handshake data */
            for(try_cnt=0; try_cnt<max_cnt; try_cnt++)
            {

                msleep(100);
                if(g_data->kl != UNKOWN_KEYLAYOUT)
                {
                    dockconnected = true;
                    break;
                }

                /* the accessory is dettached. */
                if(gpio_get_value(g_data->gpio))
                {
                    dockconnected = false;
                    break;
                }
            }
        }
    }

    if(dockconnected)
    {
        // if the led is on, the led should be off.
        g_data->led_on= false;
        if (!work_pending(&g_data->work_led))
        {
            schedule_work(&g_data->work_led);
        }
        return 1;
    }
    else
    {
        if(pre_connected)
        {
            gpio_set_value(en_gpio, 0);
            keyboard_enable = false;

            error = change_console_baud_rate(115200);
            if(error<0)
            {
                printk(KERN_ERR "[Keyboard] Couldn't modify the baud rate.\n");
            }
con_err:
            dockconnected = false;
            gpio_set_value(OMAP_GPIO_UART_SEL, pre_uart_path);

            g_data->kl = UNKOWN_KEYLAYOUT;
            pre_connected = false;
            handshaking = false;
            disconnected_time = jiffies;
            release_all_keys();
        }
        set_uart_suspend(1);
        return 0;
    }
}
Example #11
0
static void key_event_work(struct work_struct *work)
{
    bool press;
    static int release_cnt = 0;
    unsigned int keycode;
    unsigned char scan_code;
    struct dock_keyboard_data *data = container_of(work,
                struct dock_keyboard_data, work_msg);

    while(buf_front != buf_rear)
    {
        buf_front = (1+buf_front)%MAX_BUF;
        scan_code = key_buf[buf_front];

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

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

                default:
                    printk(KERN_DEBUG "[Keyboard] Unkown key layout : %x\n", scan_code);
                    break;
            }
        }
        else
        {
            /* Do not send the key_event durring the handshake time */
            if(handshaking)
            {
                /* Caps lock led on/off */
                if(scan_code == 0xca || scan_code == 0xcb)
                {
                    // Ignore
                    //dock_keyboard_tx(scan_code);
                }
                else if(scan_code == 0x0)
                {
                    release_all_keys();
                    release_cnt = 16;
                }
                else
                {
                    press = ((scan_code & 0x80) != 0x80);
                    keycode = (scan_code & 0x7f);

                    if(keycode >= KEYBOARD_MIN || keycode <= KEYBOARD_MAX)
                    {
                        if(press)
                        {
                            // workaround keyboard issue
                            if(dock_keycodes[keycode].pressed)
                            {
                                input_report_key(data->input_dev, dock_keycodes[keycode].keycode, 0);
                                msleep(1);
                            }
                            dock_keycodes[keycode].pressed = true;
#if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER)
                            printk(KERN_DEBUG "[Keyboard] %d key is pressed.\n", dock_keycodes[keycode].keycode);
#endif
                        }
                        else
                        {
                            dock_keycodes[keycode].pressed = false;
#if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER)
                            printk(KERN_DEBUG "[Keyboard] %d key is released.\n", dock_keycodes[keycode].keycode);
#endif
                        }

                        /* for the remap keys*/
                        if(keycode == 0x45 || keycode == 0x48)
                        {
                            if(press)
                            {
                                data->key_timer.data = (unsigned long) keycode;
                                mod_timer(&data->key_timer, jiffies + HZ/3);
                            }
                            else
                            {
                                if(remap_state == REMAPKEY_PRESSED)
                                {
                                    remap_state = REMAPKEY_RELEASED;
                                    input_report_key(data->input_dev, dock_keycodes[keycode].keycode, press);
                                    input_sync(data->input_dev);
                                }
                            }
                        }
                        else
                        {
                            input_report_key(data->input_dev, dock_keycodes[keycode].keycode, press);
                            input_sync(data->input_dev);
                        }
                    }
/* This is not working */
#if 0
                    else
                    {
                        /* request last scancode again*/
                        dock_keyboard_tx(0xaa);
                        printk(KERN_DEBUG "[Keyboard] wrong key_code : 0x%x\n", scan_code);
                    }
#endif
                    if(release_cnt >0)
                    {
                        if(press)
                        {
                            input_report_key(data->input_dev, dock_keycodes[keycode].keycode, 0);
#if defined(CONFIG_SAMSUNG_KERNEL_DEBUG_USER)
                            printk(KERN_DEBUG "[Keyboard] forced release %d key.\n", dock_keycodes[keycode].keycode);
#endif
                        }
                        release_cnt--;
                    }
                }
            }
            else
            {
                /* device don't send the key_event durring the handshaking */
                if((jiffies - connected_time) >= HZ/2)
                {
                    handshaking =true;
                }
            }
        }
    }

}
Example #12
0
GHTTPRequest ghttpPostExA
(
	const char * URL,
	const char * headers,
	GHTTPPost post,
	GHTTPBool throttle,
	GHTTPBool blocking,
	ghttpProgressCallback progressCallback,
	ghttpCompletedCallback completedCallback,
	void * param
)
{
	GHIConnection * connection;

	assert(URL && URL[0]);
	assert(post);

	// Check args.
	//////////////
	if(!URL || !URL[0])
		return GHTTPInvalidURL;
	if(!post)
		return GHTTPInvalidPost;

	// Startup if it hasn't been done.
	//////////////////////////////////
	if(!ghiReferenceCount)
		ghttpStartup();

	// Get a new connection object.
	///////////////////////////////
	connection = ghiNewConnection();
	if(!connection)
		return GHTTPInsufficientMemory;

	// Fill in the necessary info.
	//////////////////////////////
	connection->type = GHIPOST;
	connection->URL = goastrdup(URL);
	if(!connection->URL)
	{
		ghiFreeConnection(connection);
		return GHTTPInsufficientMemory;
	}
	if(headers && *headers)
	{
		connection->sendHeaders = goastrdup(headers);
		if(!connection->sendHeaders)
		{
			ghiFreeConnection(connection);
			return GHTTPInsufficientMemory;
		}
	}
	connection->post = post;
	connection->blocking = blocking;
	connection->progressCallback = progressCallback;
	connection->completedCallback = completedCallback;
	connection->callbackParam = param;
	connection->throttle = throttle;

	// Setup the post state if needed.
	//////////////////////////////////
	if(post && !ghiPostInitState(connection))
	{
		ghiFreeConnection(connection);
		return GHTTPInvalidPost;
	}

	// Check blocking.
	//////////////////
	if(blocking)
	{
		// Loop until completed.
		////////////////////////
		while(!ghiProcessConnection(connection))
			msleep(10);

		// Done.
		////////
		return 0;
	}

	return connection->request;
}
Example #13
0
static GHTTPRequest _ghttpSaveEx
(
	const char * URL,
	const gsi_char * filename,
	const char * headers,
	GHTTPPost post,
	GHTTPBool throttle,
	GHTTPBool blocking,
	ghttpProgressCallback progressCallback,
	ghttpCompletedCallback completedCallback,
	void * param
)
{
	GHIConnection * connection;

	assert(URL && URL[0]);
	assert(filename && filename[0]);

	// Check args.
	//////////////
	if(!URL || !URL[0])
		return GHTTPInvalidURL;
	if(!filename || !filename[0])
		return GHTTPInvalidFileName;

	// Startup if it hasn't been done.
	//////////////////////////////////
	if(!ghiReferenceCount)
		ghttpStartup();

	// Get a new connection object.
	///////////////////////////////
	connection = ghiNewConnection();
	if(!connection)
		return GHTTPInsufficientMemory;

	// Fill in the necessary info.
	//////////////////////////////
	connection->type = GHISAVE;
	connection->URL = goastrdup(URL);
	if(!connection->URL)
	{
		ghiFreeConnection(connection);
		return GHTTPInsufficientMemory;
	}
	if(headers && *headers)
	{
		connection->sendHeaders = goastrdup(headers);
		if(!connection->sendHeaders)
		{
			ghiFreeConnection(connection);
			return GHTTPInsufficientMemory;
		}
	}
	connection->post = post;
	connection->blocking = blocking;
	connection->progressCallback = progressCallback;
	connection->completedCallback = completedCallback;
	connection->callbackParam = param;
	connection->throttle = throttle;

	// Setup the post state if needed.
	//////////////////////////////////
	if(post && !ghiPostInitState(connection))
	{
		ghiFreeConnection(connection);
		return GHTTPInvalidPost;
	}

	// Open the file we're saving to.
	/////////////////////////////////
#ifdef NOFILE
	connection->saveFile = NULL;
#else
	connection->saveFile = _tfopen(filename, _T("wb"));
#endif
	if(!connection->saveFile)
	{
		ghiFreeConnection(connection);
		return GHTTPFailedToOpenFile;
	}

	// Check blocking.
	//////////////////
	if(blocking)
	{
		// Loop until completed.
		////////////////////////
		while(!ghiProcessConnection(connection))
			msleep(10);

		// Done.
		////////
		return 0;
	}

	return connection->request;
}
Example #14
0
GHTTPRequest ghttpGetExA
(
	const char * URL,
	const char * headers,
	char * buffer,
	int bufferSize,
	GHTTPPost post,
	GHTTPBool throttle,
	GHTTPBool blocking,
	ghttpProgressCallback progressCallback,
	ghttpCompletedCallback completedCallback,
	void * param
)
{
	GHTTPBool bResult;
	GHIConnection * connection;

	assert(URL && URL[0]);
	assert(bufferSize >= 0);
	assert(!buffer || bufferSize);

	// Check args.
	//////////////
	if(!URL || !URL[0])
		return GHTTPInvalidURL;
	if(bufferSize < 0)
		return GHTTPInvalidBufferSize;
	if(buffer && !bufferSize)
		return GHTTPInvalidBufferSize;

	// Startup if it hasn't been done.
	//////////////////////////////////
	if(!ghiReferenceCount)
		ghttpStartup();

	// Get a new connection object.
	///////////////////////////////
	connection = ghiNewConnection();
	if(!connection)
		return GHTTPInsufficientMemory;

	// Fill in the necessary info.
	//////////////////////////////
	connection->type = GHIGET;
	connection->URL = goastrdup(URL);
	if(!connection->URL)
	{
		ghiFreeConnection(connection);
		return GHTTPInsufficientMemory;
	}
	if(headers && *headers)
	{
		connection->sendHeaders = goastrdup(headers);
		if(!connection->sendHeaders)
		{
			ghiFreeConnection(connection);
			return GHTTPInsufficientMemory;
		}
	}
	connection->post = post;
	connection->blocking = blocking;
	connection->progressCallback = progressCallback;
	connection->completedCallback = completedCallback;
	connection->callbackParam = param;
	connection->throttle = throttle;
	connection->userBufferSupplied = (buffer != NULL)?GHTTPTrue:GHTTPFalse;
	if(connection->userBufferSupplied)
		bResult = ghiInitFixedBuffer(connection, &connection->getFileBuffer, buffer, bufferSize);
	else
		bResult = ghiInitBuffer(connection, &connection->getFileBuffer, GET_FILE_BUFFER_INITIAL_SIZE, GET_FILE_BUFFER_INCREMENT_SIZE);
	if(!bResult)
	{
		ghiFreeConnection(connection);
		return GHTTPUnspecifiedError;
	}

	// Setup the post state if needed.
	//////////////////////////////////
	if(post && !ghiPostInitState(connection))
	{
		ghiFreeConnection(connection);
		return GHTTPInvalidPost;
	}

	// Check blocking.
	//////////////////
	if(blocking)
	{
		// Loop until completed.
		////////////////////////
		while(!ghiProcessConnection(connection))
			msleep(10);

		// Done.
		////////
		return 0;
	}

	return connection->request;
}
/**
 *  ixgbe_reset_hw_X540 - Perform hardware reset
 *  @hw: pointer to hardware structure
 *
 *  Resets the hardware by resetting the transmit and receive units, masks
 *  and clears all interrupts, perform a PHY reset, and perform a link (MAC)
 *  reset.
 **/
static s32 ixgbe_reset_hw_X540(struct ixgbe_hw *hw)
{
	s32 status;
	u32 ctrl, i;

	/* Call adapter stop to disable tx/rx and clear interrupts */
	status = hw->mac.ops.stop_adapter(hw);
	if (status != 0)
		goto reset_hw_out;

	/* flush pending Tx transactions */
	ixgbe_clear_tx_pending(hw);

mac_reset_top:
	ctrl = IXGBE_CTRL_RST;
	ctrl |= IXGBE_READ_REG(hw, IXGBE_CTRL);
	IXGBE_WRITE_REG(hw, IXGBE_CTRL, ctrl);
	IXGBE_WRITE_FLUSH(hw);

	/* Poll for reset bit to self-clear indicating reset is complete */
	for (i = 0; i < 10; i++) {
		udelay(1);
		ctrl = IXGBE_READ_REG(hw, IXGBE_CTRL);
		if (!(ctrl & IXGBE_CTRL_RST_MASK))
			break;
	}

	if (ctrl & IXGBE_CTRL_RST_MASK) {
		status = IXGBE_ERR_RESET_FAILED;
		hw_dbg(hw, "Reset polling failed to complete.\n");
	}
	msleep(100);

	/*
	 * Double resets are required for recovery from certain error
	 * conditions.  Between resets, it is necessary to stall to allow time
	 * for any pending HW events to complete.
	 */
	if (hw->mac.flags & IXGBE_FLAGS_DOUBLE_RESET_REQUIRED) {
		hw->mac.flags &= ~IXGBE_FLAGS_DOUBLE_RESET_REQUIRED;
		goto mac_reset_top;
	}

	/* Set the Rx packet buffer size. */
	IXGBE_WRITE_REG(hw, IXGBE_RXPBSIZE(0), 384 << IXGBE_RXPBSIZE_SHIFT);

	/* Store the permanent mac address */
	hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);

	/*
	 * Store MAC address from RAR0, clear receive address registers, and
	 * clear the multicast table.  Also reset num_rar_entries to 128,
	 * since we modify this value when programming the SAN MAC address.
	 */
	hw->mac.num_rar_entries = IXGBE_X540_MAX_TX_QUEUES;
	hw->mac.ops.init_rx_addrs(hw);

	/* Store the permanent SAN mac address */
	hw->mac.ops.get_san_mac_addr(hw, hw->mac.san_addr);

	/* Add the SAN MAC address to the RAR only if it's a valid address */
	if (ixgbe_validate_mac_addr(hw->mac.san_addr) == 0) {
		hw->mac.ops.set_rar(hw, hw->mac.num_rar_entries - 1,
		                    hw->mac.san_addr, 0, IXGBE_RAH_AV);

		/* Save the SAN MAC RAR index */
		hw->mac.san_mac_rar_index = hw->mac.num_rar_entries - 1;

		/* Reserve the last RAR for the SAN MAC address */
		hw->mac.num_rar_entries--;
	}

	/* Store the alternative WWNN/WWPN prefix */
	hw->mac.ops.get_wwn_prefix(hw, &hw->mac.wwnn_prefix,
	                           &hw->mac.wwpn_prefix);

reset_hw_out:
	return status;
}
static int ali1535_transaction(struct i2c_adapter *adap)
{
	int temp;
	int result = 0;
	int timeout = 0;

	dev_dbg(&adap->dev, "Transaction (pre): STS=%02x, TYP=%02x, "
		"CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
		inb_p(SMBHSTSTS), inb_p(SMBHSTTYP), inb_p(SMBHSTCMD),
		inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));

	/* get status */
	temp = inb_p(SMBHSTSTS);

	/* Make sure the SMBus host is ready to start transmitting */
	/* Check the busy bit first */
	if (temp & ALI1535_STS_BUSY) {
		/* If the host controller is still busy, it may have timed out
		 * in the previous transaction, resulting in a "SMBus Timeout"
		 * printk.  I've tried the following to reset a stuck busy bit.
		 *   1. Reset the controller with an KILL command. (this
		 *      doesn't seem to clear the controller if an external
		 *      device is hung)
		 *   2. Reset the controller and the other SMBus devices with a
		 *      T_OUT command. (this clears the host busy bit if an
		 *      external device is hung, but it comes back upon a new
		 *      access to a device)
		 *   3. Disable and reenable the controller in SMBHSTCFG. Worst
		 *      case, nothing seems to work except power reset.
		 */

		/* Try resetting entire SMB bus, including other devices - This
		 * may not work either - it clears the BUSY bit but then the
		 * BUSY bit may come back on when you try and use the chip
		 * again.  If that's the case you are stuck.
		 */
		dev_info(&adap->dev,
			"Resetting entire SMB Bus to clear busy condition (%02x)\n",
			temp);
		outb_p(ALI1535_T_OUT, SMBHSTTYP);
		temp = inb_p(SMBHSTSTS);
	}

	/* now check the error bits and the busy bit */
	if (temp & (ALI1535_STS_ERR | ALI1535_STS_BUSY)) {
		/* do a clear-on-write */
		outb_p(0xFF, SMBHSTSTS);
		if ((temp = inb_p(SMBHSTSTS)) &
		    (ALI1535_STS_ERR | ALI1535_STS_BUSY)) {
			/* This is probably going to be correctable only by a
			 * power reset as one of the bits now appears to be
			 * stuck */
			/* This may be a bus or device with electrical problems. */
			dev_err(&adap->dev,
				"SMBus reset failed! (0x%02x) - controller or "
				"device on bus is probably hung\n", temp);
			return -EBUSY;
		}
	} else {
		/* check and clear done bit */
		if (temp & ALI1535_STS_DONE) {
			outb_p(temp, SMBHSTSTS);
		}
	}

	/* start the transaction by writing anything to the start register */
	outb_p(0xFF, SMBHSTPORT);

	/* We will always wait for a fraction of a second! */
	timeout = 0;
	do {
		msleep(1);
		temp = inb_p(SMBHSTSTS);
	} while (((temp & ALI1535_STS_BUSY) && !(temp & ALI1535_STS_IDLE))
		 && (timeout++ < MAX_TIMEOUT));

	/* If the SMBus is still busy, we give up */
	if (timeout >= MAX_TIMEOUT) {
		result = -ETIMEDOUT;
		dev_err(&adap->dev, "SMBus Timeout!\n");
	}

	if (temp & ALI1535_STS_FAIL) {
		result = -EIO;
		dev_dbg(&adap->dev, "Error: Failed bus transaction\n");
	}

	/* Unfortunately the ALI SMB controller maps "no response" and "bus
	 * collision" into a single bit. No reponse is the usual case so don't
	 * do a printk.  This means that bus collisions go unreported.
	 */
	if (temp & ALI1535_STS_BUSERR) {
		result = -ENXIO;
		dev_dbg(&adap->dev,
			"Error: no response or bus collision ADD=%02x\n",
			inb_p(SMBHSTADD));
	}

	/* haven't ever seen this */
	if (temp & ALI1535_STS_DEV) {
		result = -EIO;
		dev_err(&adap->dev, "Error: device error\n");
	}

	/* check to see if the "command complete" indication is set */
	if (!(temp & ALI1535_STS_DONE)) {
		result = -ETIMEDOUT;
		dev_err(&adap->dev, "Error: command never completed\n");
	}

	dev_dbg(&adap->dev, "Transaction (post): STS=%02x, TYP=%02x, "
		"CMD=%02x, ADD=%02x, DAT0=%02x, DAT1=%02x\n",
		inb_p(SMBHSTSTS), inb_p(SMBHSTTYP), inb_p(SMBHSTCMD),
		inb_p(SMBHSTADD), inb_p(SMBHSTDAT0), inb_p(SMBHSTDAT1));

	/* take consequent actions for error conditions */
	if (!(temp & ALI1535_STS_DONE)) {
		/* issue "kill" to reset host controller */
		outb_p(ALI1535_KILL,SMBHSTTYP);
		outb_p(0xFF,SMBHSTSTS);
	} else if (temp & ALI1535_STS_ERR) {
		/* issue "timeout" to reset all devices on bus */
		outb_p(ALI1535_T_OUT,SMBHSTTYP);
		outb_p(0xFF,SMBHSTSTS);
	}

	return result;
}
static
int axusbnet_stop (struct net_device *net)
{
	struct usbnet		*dev = netdev_priv(net);
	struct driver_info	*info = dev->driver_info;
	int			temp;
	int			retval;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
	DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
#else
	DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup);
#endif
	DECLARE_WAITQUEUE (wait, current);

	netif_stop_queue (net);

	if (netif_msg_ifdown (dev))
		devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
			dev->stats.rx_packets, dev->stats.tx_packets,
			dev->stats.rx_errors, dev->stats.tx_errors
			);

	/* allow minidriver to stop correctly (wireless devices to turn off
	 * radio etc) */
	if (info->stop) {
		retval = info->stop(dev);
		if (retval < 0 && netif_msg_ifdown(dev))
			devinfo(dev,
				"stop fail (%d) usbnet usb-%s-%s, %s",
				retval,
				dev->udev->bus->bus_name, dev->udev->devpath,
				info->description);
	}

	if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) {
		/* ensure there are no more active urbs */
		add_wait_queue(&unlink_wakeup, &wait);
		dev->wait = &unlink_wakeup;
		temp = unlink_urbs(dev, &dev->txq) +
			unlink_urbs(dev, &dev->rxq);

		/* maybe wait for deletions to finish. */
		while (!skb_queue_empty(&dev->rxq)
				&& !skb_queue_empty(&dev->txq)
				&& !skb_queue_empty(&dev->done)) {
			msleep(UNLINK_TIMEOUT_MS);
			if (netif_msg_ifdown(dev))
				devdbg(dev, "waited for %d urb completions",
					temp);
		}
		dev->wait = NULL;
		remove_wait_queue(&unlink_wakeup, &wait);
	}

	usb_kill_urb(dev->interrupt);

	/* deferred work (task, timer, softirq) must also stop.
	 * can't flush_scheduled_work() until we drop rtnl (later),
	 * else workers could deadlock; so make workers a NOP.
	 */
	dev->flags = 0;
	del_timer_sync (&dev->delay);
	tasklet_kill (&dev->bh);

	return 0;
}
/* Return negative errno on error. */
static s32 ali1535_access(struct i2c_adapter *adap, u16 addr,
			  unsigned short flags, char read_write, u8 command,
			  int size, union i2c_smbus_data *data)
{
	int i, len;
	int temp;
	int timeout;
	s32 result = 0;

	/* make sure SMBus is idle */
	temp = inb_p(SMBHSTSTS);
	for (timeout = 0;
	     (timeout < MAX_TIMEOUT) && !(temp & ALI1535_STS_IDLE);
	     timeout++) {
		msleep(1);
		temp = inb_p(SMBHSTSTS);
	}
	if (timeout >= MAX_TIMEOUT)
		dev_warn(&adap->dev, "Idle wait Timeout! STS=0x%02x\n", temp);

	/* clear status register (clear-on-write) */
	outb_p(0xFF, SMBHSTSTS);

	switch (size) {
	case I2C_SMBUS_QUICK:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
		size = ALI1535_QUICK;
		outb_p(size, SMBHSTTYP);	/* output command */
		break;
	case I2C_SMBUS_BYTE:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
		size = ALI1535_BYTE;
		outb_p(size, SMBHSTTYP);	/* output command */
		if (read_write == I2C_SMBUS_WRITE)
			outb_p(command, SMBHSTCMD);
		break;
	case I2C_SMBUS_BYTE_DATA:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
		size = ALI1535_BYTE_DATA;
		outb_p(size, SMBHSTTYP);	/* output command */
		outb_p(command, SMBHSTCMD);
		if (read_write == I2C_SMBUS_WRITE)
			outb_p(data->byte, SMBHSTDAT0);
		break;
	case I2C_SMBUS_WORD_DATA:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
		size = ALI1535_WORD_DATA;
		outb_p(size, SMBHSTTYP);	/* output command */
		outb_p(command, SMBHSTCMD);
		if (read_write == I2C_SMBUS_WRITE) {
			outb_p(data->word & 0xff, SMBHSTDAT0);
			outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1);
		}
		break;
	case I2C_SMBUS_BLOCK_DATA:
		outb_p(((addr & 0x7f) << 1) | (read_write & 0x01),
		       SMBHSTADD);
		size = ALI1535_BLOCK_DATA;
		outb_p(size, SMBHSTTYP);	/* output command */
		outb_p(command, SMBHSTCMD);
		if (read_write == I2C_SMBUS_WRITE) {
			len = data->block[0];
			if (len < 0) {
				len = 0;
				data->block[0] = len;
			}
			if (len > 32) {
				len = 32;
				data->block[0] = len;
			}
			outb_p(len, SMBHSTDAT0);
			/* Reset SMBBLKDAT */
			outb_p(inb_p(SMBHSTTYP) | ALI1535_BLOCK_CLR, SMBHSTTYP);
			for (i = 1; i <= len; i++)
				outb_p(data->block[i], SMBBLKDAT);
		}
		break;
	default:
		dev_warn(&adap->dev, "Unsupported transaction %d\n", size);
		result = -EOPNOTSUPP;
		goto EXIT;
	}
static int s6d6aa0_vreg_power(int on)
{
	int rc = 0;

	if (!vreg_lcd_vddio) {
		vreg_lcd_vddio = regulator_get(&msm_mipi_dsi1_device.dev,
			"dsi_vddio");
		if (IS_ERR(vreg_lcd_vddio)) {
			pr_err("%s: Unable to get 8921_l29\n", __func__);
			vreg_lcd_vddio = NULL;
			return -ENODEV;
		}
	}

	if (on) {
		rc = regulator_set_voltage(vreg_lcd_vddio, 1800000, 1800000);
		if (rc) {
			pr_err("%s:%d unable to set L29 voltage to 1.8V\n",
				__func__, rc);
			goto out_put;
		}

		rc = regulator_enable(vreg_lcd_vddio);
		if (rc) {
			pr_err("%s: Enable regulator 8921_l29 failed\n",
				__func__);
			goto out_put;
		}

		rc = lcd_gpio_setup(on);
		if (rc) {
			pr_err("gpio setup failed , rc=%d\n", rc);
			goto out_desable;
		}
		gpio_set_value(LCD_PWR_EN, 1);

		msleep(LCD_POWER_WAIT_MS);

		lcd_reset(on);
	} else {
		lcd_reset(on);

		gpio_set_value(LCD_PWR_EN, 0);
		rc = lcd_gpio_setup(on);
		if (rc) {
			pr_err("gpio setup failed , rc=%d\n", rc);
			return -EINVAL;
		}

		rc = regulator_disable(vreg_lcd_vddio);
		if (rc)
			pr_warning("%s: '%s' regulator disable failed, rc=%d\n",
				__func__, "8921_l29", rc);
		msleep(LCD_POWER_WAIT_MS);
	}

	return 0;
out_desable:
	regulator_disable(vreg_lcd_vddio);
out_put:
	regulator_put(vreg_lcd_vddio);
	vreg_lcd_vddio = NULL;
	return rc;
}
int msm_cam_clk_enable(struct device *dev, struct msm_cam_clk_info *clk_info,
		struct clk **clk_ptr, int num_clk, int enable)
{
	int i;
	int rc = 0;
	if (enable) {
		for (i = 0; i < num_clk; i++) {
			CDBG("%s enable %s\n", __func__,
				clk_info[i].clk_name);
			clk_ptr[i] = clk_get(dev, clk_info[i].clk_name);
			if (IS_ERR(clk_ptr[i])) {
				pr_err("%s get failed\n", clk_info[i].clk_name);
				rc = PTR_ERR(clk_ptr[i]);
				goto cam_clk_get_err;
			}
			if (clk_info[i].clk_rate > 0) {
				rc = clk_set_rate(clk_ptr[i],
							clk_info[i].clk_rate);
				if (rc < 0) {
					pr_err("%s set failed\n",
						   clk_info[i].clk_name);
					goto cam_clk_set_err;
				}
			}
			rc = clk_prepare(clk_ptr[i]);
			if (rc < 0) {
				pr_err("%s prepare failed\n",
					   clk_info[i].clk_name);
				goto cam_clk_prepare_err;
			}

			rc = clk_enable(clk_ptr[i]);
			if (rc < 0) {
				pr_err("%s enable failed\n",
					   clk_info[i].clk_name);
				goto cam_clk_enable_err;
			}
			if (clk_info[i].delay > 20) {
				msleep(clk_info[i].delay);
			} else if (clk_info[i].delay) {
				usleep_range(clk_info[i].delay * 1000,
					(clk_info[i].delay * 1000) + 1000);
			}
		}
	} else {
		for (i = num_clk - 1; i >= 0; i--) {
			if (clk_ptr[i] != NULL) {
				CDBG("%s disable %s\n", __func__,
					clk_info[i].clk_name);
				clk_disable(clk_ptr[i]);
				clk_unprepare(clk_ptr[i]);
				clk_put(clk_ptr[i]);
			}
		}
	}
	return rc;


cam_clk_enable_err:
	clk_unprepare(clk_ptr[i]);
cam_clk_prepare_err:
cam_clk_set_err:
	clk_put(clk_ptr[i]);
cam_clk_get_err:
	for (i--; i >= 0; i--) {
		if (clk_ptr[i] != NULL) {
			clk_disable(clk_ptr[i]);
			clk_unprepare(clk_ptr[i]);
			clk_put(clk_ptr[i]);
		}
	}
	return rc;
}
Example #21
0
static void
pmclog_loop(void *arg)
{
	int error;
	struct pmc_owner *po;
	struct pmclog_buffer *lb;
	struct proc *p;
	struct ucred *ownercred;
	struct ucred *mycred;
	struct thread *td;
	struct uio auio;
	struct iovec aiov;
	size_t nbytes;

	po = (struct pmc_owner *) arg;
	p = po->po_owner;
	td = curthread;
	mycred = td->td_ucred;

	PROC_LOCK(p);
	ownercred = crhold(p->p_ucred);
	PROC_UNLOCK(p);

	PMCDBG(LOG,INI,1, "po=%p kt=%p", po, po->po_kthread);
	KASSERT(po->po_kthread == curthread->td_proc,
	    ("[pmclog,%d] proc mismatch po=%p po/kt=%p curproc=%p", __LINE__,
		po, po->po_kthread, curthread->td_proc));

	lb = NULL;


	/*
	 * Loop waiting for I/O requests to be added to the owner
	 * struct's queue.  The loop is exited when the log file
	 * is deconfigured.
	 */

	mtx_lock(&pmc_kthread_mtx);

	for (;;) {

		/* check if we've been asked to exit */
		if ((po->po_flags & PMC_PO_OWNS_LOGFILE) == 0)
			break;

		if (lb == NULL) { /* look for a fresh buffer to write */
			mtx_lock_spin(&po->po_mtx);
			if ((lb = TAILQ_FIRST(&po->po_logbuffers)) == NULL) {
				mtx_unlock_spin(&po->po_mtx);

				/* No more buffers and shutdown required. */
				if (po->po_flags & PMC_PO_SHUTDOWN) {
					mtx_unlock(&pmc_kthread_mtx);
					/*
			 		 * Close the file to get PMCLOG_EOF
					 * error in pmclog(3).
					 */
					fo_close(po->po_file, curthread);
					mtx_lock(&pmc_kthread_mtx);
					break;
				}

				(void) msleep(po, &pmc_kthread_mtx, PWAIT,
				    "pmcloop", 0);
				continue;
			}

			TAILQ_REMOVE(&po->po_logbuffers, lb, plb_next);
			mtx_unlock_spin(&po->po_mtx);
		}

		mtx_unlock(&pmc_kthread_mtx);

		/* process the request */
		PMCDBG(LOG,WRI,2, "po=%p base=%p ptr=%p", po,
		    lb->plb_base, lb->plb_ptr);
		/* change our thread's credentials before issuing the I/O */

		aiov.iov_base = lb->plb_base;
		aiov.iov_len  = nbytes = lb->plb_ptr - lb->plb_base;

		auio.uio_iov    = &aiov;
		auio.uio_iovcnt = 1;
		auio.uio_offset = -1;
		auio.uio_resid  = nbytes;
		auio.uio_rw     = UIO_WRITE;
		auio.uio_segflg = UIO_SYSSPACE;
		auio.uio_td     = td;

		/* switch thread credentials -- see kern_ktrace.c */
		td->td_ucred = ownercred;
		error = fo_write(po->po_file, &auio, ownercred, 0, td);
		td->td_ucred = mycred;

		if (error) {
			/* XXX some errors are recoverable */
			/* send a SIGIO to the owner and exit */
			PROC_LOCK(p);
			kern_psignal(p, SIGIO);
			PROC_UNLOCK(p);

			mtx_lock(&pmc_kthread_mtx);

			po->po_error = error; /* save for flush log */

			PMCDBG(LOG,WRI,2, "po=%p error=%d", po, error);

			break;
		}

		mtx_lock(&pmc_kthread_mtx);

		/* put the used buffer back into the global pool */
		PMCLOG_INIT_BUFFER_DESCRIPTOR(lb);

		mtx_lock_spin(&pmc_bufferlist_mtx);
		TAILQ_INSERT_HEAD(&pmc_bufferlist, lb, plb_next);
		mtx_unlock_spin(&pmc_bufferlist_mtx);

		lb = NULL;
	}

	wakeup_one(po->po_kthread);
	po->po_kthread = NULL;

	mtx_unlock(&pmc_kthread_mtx);

	/* return the current I/O buffer to the global pool */
	if (lb) {
		PMCLOG_INIT_BUFFER_DESCRIPTOR(lb);

		mtx_lock_spin(&pmc_bufferlist_mtx);
		TAILQ_INSERT_HEAD(&pmc_bufferlist, lb, plb_next);
		mtx_unlock_spin(&pmc_bufferlist_mtx);
	}

	/*
	 * Exit this thread, signalling the waiter
	 */

	crfree(ownercred);

	kproc_exit(0);
}
int msm_camera_enable_vreg(struct device *dev, struct camera_vreg_t *cam_vreg,
		int num_vreg, enum msm_camera_vreg_name_t *vreg_seq,
		int num_vreg_seq, struct regulator **reg_ptr, int enable)
{
	int i = 0, j = 0, rc = 0;

	if (num_vreg_seq > num_vreg) {
		pr_err("%s:%d vreg sequence invalid\n", __func__, __LINE__);
		return -EINVAL;
	}
	if (!num_vreg_seq)
		num_vreg_seq = num_vreg;

	if (enable) {
		for (i = 0; i < num_vreg_seq; i++) {
			if (vreg_seq) {
				j = vreg_seq[i];
				if (j >= num_vreg)
					continue;
			} else
				j = i;
			if (IS_ERR(reg_ptr[j])) {
				pr_err("%s: %s null regulator\n",
					__func__, cam_vreg[j].reg_name);
				goto disable_vreg;
			}
			rc = regulator_enable(reg_ptr[j]);
			if (rc < 0) {
				pr_err("%s: %s enable failed\n",
					__func__, cam_vreg[j].reg_name);
				goto disable_vreg;
			}
			if (cam_vreg[j].delay > 20)
				msleep(cam_vreg[j].delay);
			else if (cam_vreg[j].delay)
				usleep_range(cam_vreg[j].delay * 1000,
					(cam_vreg[j].delay * 1000) + 1000);
		}
	} else {
		for (i = num_vreg_seq-1; i >= 0; i--) {
			if (vreg_seq) {
				j = vreg_seq[i];
				if (j >= num_vreg)
					continue;
			} else
				j = i;
			regulator_disable(reg_ptr[j]);
			if (cam_vreg[j].delay > 20)
				msleep(cam_vreg[j].delay);
			else if (cam_vreg[j].delay)
				usleep_range(cam_vreg[j].delay * 1000,
					(cam_vreg[j].delay * 1000) + 1000);
		}
	}
	return rc;
disable_vreg:
	for (i--; i >= 0; i--) {
		if (vreg_seq) {
			j = vreg_seq[i];
			if (j >= num_vreg)
				continue;
		} else
			j = i;
		regulator_disable(reg_ptr[j]);
		if (cam_vreg[j].delay > 20)
			msleep(cam_vreg[j].delay);
		else if (cam_vreg[j].delay)
			usleep_range(cam_vreg[j].delay * 1000,
				(cam_vreg[j].delay * 1000) + 1000);
	}
	return rc;
}
Example #23
0
static int tpd_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) {             
	int err = 0,i;
//	uint8_t Firmware_version[3] = {0x20,0x00,0x00};
	i2c_client = client;
       unsigned char tpd_buf[8] = {0};

//	#ifdef TPD_HAVE_POWER_ON_OFF
	//for power on sequence
	tpd_hw_enable();
	mt_set_gpio_mode(GPIO21, 0);
	mt_set_gpio_dir(GPIO21, GPIO_DIR_OUT);
	mt_set_gpio_out(GPIO21, GPIO_OUT_ONE);

    	mdelay(20);


//eint config to gpio
	    mt_set_gpio_mode(GPIO_CTP_EINT_PIN, GPIO_CTP_EINT_PIN_M_EINT);
	    mt_set_gpio_dir(GPIO_CTP_EINT_PIN, GPIO_DIR_IN);
	    mt_set_gpio_pull_enable(GPIO_CTP_EINT_PIN, GPIO_PULL_ENABLE);
	    mt_set_gpio_pull_select(GPIO_CTP_EINT_PIN, GPIO_PULL_UP);

	
//	#endif

	msleep(20);

	
	#if 0
	for(i = 0;i<5;i++)
	{
		if(tpd_i2c_master_rs_send(i2c_client,Firmware_version,3<<8|1) < 0)
		{
				TPD_DMESG("I2C transfer error, line: %d\n", __LINE__);
		}
		else
		{
			TPD_DMESG(" mcs6024 Hardware version is %x\n",Firmware_version[0]);
			TPD_DMESG(" mcs6024 Firmware version is %x\n",Firmware_version[1]);
			TPD_DMESG(" mcs6024 Panel Type  is %x\n",Firmware_version[2]);
			break;
		}
	}
	if(i == 5)
	{
		TPD_DMESG("mcs6024 tpd_i2c_probe fail\n");
		return -1;
	}
	#endif

	
		
	  thread = kthread_run(touch_event_handler, 0, TPD_DEVICE);
    if (IS_ERR(thread)) { 
        err = PTR_ERR(thread);
        TPD_DMESG(TPD_DEVICE " failed to create kernel thread: %d\n", err);
    }    
    

    mt65xx_eint_set_sens(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_SENSITIVE);
    mt65xx_eint_set_hw_debounce(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_CN);
    mt65xx_eint_registration(CUST_EINT_TOUCH_PANEL_NUM, CUST_EINT_TOUCH_PANEL_DEBOUNCE_EN, CUST_EINT_TOUCH_PANEL_POLARITY, tpd_eint_interrupt_handler, 1);
    mt65xx_eint_unmask(CUST_EINT_TOUCH_PANEL_NUM);
	
   tpd_load_status = 1;
    return 0;
}
Example #24
0
static int cyttsp5_hw_power(int on)
{
#ifdef MT04
	int ret;

	ret = gpio_direction_output(31, on);
	if (ret) {
		pr_err("[TKEY]%s: unable to set_direction for vdd_led [%d]\n",
			 __func__, 31);
		return -EINVAL;
	}
	ret = gpio_direction_output(45, on);
	if (ret) {
		pr_err("[TKEY]%s: unable to set_direction for vdd_led [%d]\n",
			 __func__, 45);
		return -EINVAL;
	}
	msleep(100);
#else
	struct regulator *regulator_vdd;
	struct regulator *regulator_avdd;

	if (enabled == on)
		return 0;

	regulator_vdd = regulator_get(NULL, "touch_1.8v");
	if (IS_ERR(regulator_vdd)) {
		printk(KERN_ERR "[TSP]ts_power_on : tsp_vdd regulator_get failed\n");
		return PTR_ERR(regulator_vdd);
	}

	regulator_avdd = regulator_get(NULL, "tsp_avdd");
	if (IS_ERR(regulator_avdd)) {
		printk(KERN_ERR "[TSP]ts_power_on : tsp_avdd regulator_get failed\n");
		regulator_put(regulator_vdd);
		return PTR_ERR(regulator_avdd);
	}

	printk(KERN_INFO "[TSP] %s %s\n", __func__, on ? "on" : "off");

	if (on) {
		if (!regulator_is_enabled(regulator_vdd))
			regulator_enable(regulator_vdd);
		if (!regulator_is_enabled(regulator_avdd))
			regulator_enable(regulator_avdd);

		s3c_gpio_cfgpin(GPIO_TSP_nINT_SECURE, S3C_GPIO_SFN(0xf));
		s3c_gpio_setpull(GPIO_TSP_nINT_SECURE, S3C_GPIO_PULL_NONE);
	} else {
		/*
		 * TODO: If there is a case the regulator must be disabled
		 * (e,g firmware update?), consider regulator_force_disable.
		 */
		if (regulator_is_enabled(regulator_vdd))
			regulator_disable(regulator_vdd);
		if (regulator_is_enabled(regulator_avdd))
			regulator_disable(regulator_avdd);

		s3c_gpio_cfgpin(GPIO_TSP_nINT_SECURE, S3C_GPIO_INPUT);
		s3c_gpio_setpull(GPIO_TSP_nINT_SECURE, S3C_GPIO_PULL_NONE);

		/* TODO: Delay time should be adjusted */
		msleep(10);
	}

	enabled = on;
	regulator_put(regulator_vdd);
	regulator_put(regulator_avdd);
#endif
	return 0;
}
Example #25
0
static int
Elsa_card_msg(struct IsdnCardState *cs, int mt, void *arg)
{
	int ret = 0;
	u_long flags;

	switch (mt) {
		case CARD_RESET:
			spin_lock_irqsave(&cs->lock, flags);
			reset_elsa(cs);
			spin_unlock_irqrestore(&cs->lock, flags);
			return(0);
		case CARD_RELEASE:
			release_io_elsa(cs);
			return(0);
		case CARD_INIT:
			spin_lock_irqsave(&cs->lock, flags);
			cs->debug |= L1_DEB_IPAC;
			reset_elsa(cs);
			inithscxisac(cs, 1);
			if ((cs->subtyp == ELSA_QS1000) ||
			    (cs->subtyp == ELSA_QS3000))
			{
				byteout(cs->hw.elsa.timer, 0);
			}
			if (cs->hw.elsa.trig)
				byteout(cs->hw.elsa.trig, 0xff);
			inithscxisac(cs, 2);
			spin_unlock_irqrestore(&cs->lock, flags);
			return(0);
		case CARD_TEST:
			if ((cs->subtyp == ELSA_PCMCIA) ||
				(cs->subtyp == ELSA_PCMCIA_IPAC) ||
				(cs->subtyp == ELSA_QS1000PCI)) {
				return(0);
			} else if (cs->subtyp == ELSA_QS3000PCI) {
				ret = 0;
			} else {
				spin_lock_irqsave(&cs->lock, flags);
				cs->hw.elsa.counter = 0;
				cs->hw.elsa.ctrl_reg |= ELSA_ENA_TIMER_INT;
				cs->hw.elsa.status |= ELIRQF_TIMER_AKTIV;
				byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
				byteout(cs->hw.elsa.timer, 0);
				spin_unlock_irqrestore(&cs->lock, flags);
				msleep(110);
				spin_lock_irqsave(&cs->lock, flags);
				cs->hw.elsa.ctrl_reg &= ~ELSA_ENA_TIMER_INT;
				byteout(cs->hw.elsa.ctrl, cs->hw.elsa.ctrl_reg);
				cs->hw.elsa.status &= ~ELIRQF_TIMER_AKTIV;
				spin_unlock_irqrestore(&cs->lock, flags);
				printk(KERN_INFO "Elsa: %d timer tics in 110 msek\n",
				       cs->hw.elsa.counter);
				if ((cs->hw.elsa.counter > 10) &&
					(cs->hw.elsa.counter < 16)) {
					printk(KERN_INFO "Elsa: timer and irq OK\n");
					ret = 0;
				} else {
					printk(KERN_WARNING
					       "Elsa: timer tic problem (%d/12) maybe an IRQ(%d) conflict\n",
					       cs->hw.elsa.counter, cs->irq);
					ret = 1;
				}
			}
#if ARCOFI_USE
			if (check_arcofi(cs)) {
				init_modem(cs);
			}
#endif
			elsa_led_handler(cs);
			return(ret);
		case (MDL_REMOVE | REQUEST):
			cs->hw.elsa.status &= 0;
			break;
		case (MDL_ASSIGN | REQUEST):
			cs->hw.elsa.status |= ELSA_ASSIGN;
			break;
		case MDL_INFO_SETUP:
			if ((long) arg)
				cs->hw.elsa.status |= 0x0200;
			else
				cs->hw.elsa.status |= 0x0100;
			break;
		case MDL_INFO_CONN:
			if ((long) arg)
				cs->hw.elsa.status |= 0x2000;
			else
				cs->hw.elsa.status |= 0x1000;
			break;
		case MDL_INFO_REL:
			if ((long) arg) {
				cs->hw.elsa.status &= ~0x2000;
				cs->hw.elsa.status &= ~0x0200;
			} else {
				cs->hw.elsa.status &= ~0x1000;
				cs->hw.elsa.status &= ~0x0100;
			}
			break;
#if ARCOFI_USE
		case CARD_AUX_IND:
			if (cs->hw.elsa.MFlag) {
				int len;
				u_char *msg;

				if (!arg)
					return(0);
				msg = arg;
				len = *msg;
				msg++;
				modem_write_cmd(cs, msg, len);
			}
			break;
#endif
	}
	if (cs->typ == ISDN_CTYPE_ELSA) {
		int pwr = bytein(cs->hw.elsa.ale);
		if (pwr & 0x08)
			cs->hw.elsa.status |= ELSA_BAD_PWR;
		else
			cs->hw.elsa.status &= ~ELSA_BAD_PWR;
	}
	elsa_led_handler(cs);
	return(ret);
}
Example #26
0
static int mipi_renesas_lcd_on(struct platform_device *pdev)
{
	struct msm_fb_data_type *mfd;

    ENTER_FUNC2();

	mfd = platform_get_drvdata(pdev);

	if (!mfd)
		return -ENODEV;
	if (mfd->key != MFD_KEY)
		return -EINVAL;

#ifndef SKY_LCD_SINGLE_WIRE_LB_CON
#ifdef CONFIG_F_SKYDISP_CHANGE_BL_TABLE_WHEN_OFFLINE_CHARGING
    if(is_offline_charging_mode == 1)
    {
        // Configure cabc_ctrl_con[1] to turn off CABC.
        cabc_ctrl_con[1] = 0; // CABC OFF
    }
#endif
#endif 
    
	if (!lcd_on_skip_during_bootup)
	{
		lcd_on_skip_during_bootup = true;
		renesas_state.disp_initialized = true;
		renesas_state.disp_on = true;

        goto out;
	}

	if (renesas_state.disp_initialized == false) {
#if defined(FEATURE_RENESAS_BL_ON_DEBUG)
#ifndef SKY_LCD_SINGLE_WIRE_LB_CON
		cabc_data_val[2] = bl_table[0];
#endif // SKY_LCD_SINGLE_WIRE_LB_CON
#endif 
		// vci enable 
		gpio_set_value(LCD_VCI_EN, GPIO_HIGH_VALUE);
		msleep(20);
		// reset low
		gpio_set_value_cansleep(gpio_lcd_mipi_reset, GPIO_LOW_VALUE); 
		msleep(10);
		// reset high
		gpio_set_value_cansleep(gpio_lcd_mipi_reset, GPIO_HIGH_VALUE);
		msleep(10);

		mutex_lock(&renesas_state.lcd_mutex);	
		mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_part1,
				ARRAY_SIZE(renesas_part1));
		mutex_unlock(&renesas_state.lcd_mutex);

		switch (renesas_state.test_control_flag) {
		case 0:  //default
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_1Column,
					ARRAY_SIZE(renesas_1Column));
			break;
		case 1:
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_1HDot,
					ARRAY_SIZE(renesas_1HDot));
			PRINT("[kkcho]renesas_1HDot bl_level\n");
			break;
		case 2:
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_2HDot,
					ARRAY_SIZE(renesas_2HDot));
			PRINT("[kkcho]renesas_2HDot bl_level\n");
			break;
		case 3:
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_3HDot,
					ARRAY_SIZE(renesas_3HDot));
			PRINT("[kkcho]renesas_3HDot bl_level\n");
			break;
		case 4:
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_3Column,
					ARRAY_SIZE(renesas_3Column));	
			PRINT("[kkcho]renesas_3Column bl_level\n");
			break;
		default:
			mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_1Column,
					ARRAY_SIZE(renesas_1Column));
			break;
		}

		mutex_lock(&renesas_state.lcd_mutex);	
		mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_part2,
				ARRAY_SIZE(renesas_part2));
		mutex_unlock(&renesas_state.lcd_mutex);

		renesas_state.disp_initialized = true;
	}

	mutex_lock(&renesas_state.lcd_mutex);
	mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_display_on_cmds,
		ARRAY_SIZE(renesas_display_on_cmds));

	mipi_dsi_cmds_tx(&renesas_tx_buf, renesas_sleep_out_cmds,
			ARRAY_SIZE(renesas_sleep_out_cmds));	
	mutex_unlock(&renesas_state.lcd_mutex);

//============================================
//	read test
//============================================
#ifdef SKY_LCD_MIPI_TEST_READ
	mipi_renesas_read_buf(pdev);
#endif 
//============================================
	renesas_state.disp_on = true;

out:
#ifdef CONFIG_F_SKYDISP_SILENT_BOOT
    // In case of reset when silentboot mode(doing boot), only when is_silent_boot_mode_n_bl_off == 0, do it.
    // If always do it, display silentboot image eventhough reset occur when backlight off.
    if(is_silent_boot_mode_n_bl_off == 0)
        sky_sys_rst_set_silent_boot_backlight(1);
#endif

	EXIT_FUNC2();
	return 0;
}
Example #27
0
static void start(struct work_struct *work)
{
	int err,size;
	rrep * tmp_rrep;
	int bufsize = 10;
        unsigned char buf[bufsize+1];
	mm_segment_t oldfs;
	//current->flags |= PF_NOFREEZE;
	//allow_signal(SIGKILL);
	my_work = (my_work_t *)work;
		if ( 
              (err = sock_create(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &my_work->sock_send)) < 0 )
        {
                printk(KERN_INFO MODULE_NAME": Could not create a datagram socket, error = %d\n", -ENXIO);
                return;
        }
	if((tmp_rrep = (rrep *) kmalloc(sizeof(rrep), GFP_ATOMIC)) == NULL)
	{
		printk(KERN_INFO MODULE_NAME": Could not create a datagram socket, error = %d\n", -ENXIO);
		return;
	}
        memset(&my_work->addr, 0, sizeof(struct sockaddr));
        memset(&my_work->addr_send, 0, sizeof(struct sockaddr));
        my_work->addr_send.sin_family = AF_INET;

        //my_work->addr_send.sin_addr.s_addr = htonl(INADDR_SEND);
	my_work->addr_send.sin_addr.s_addr = in_aton("192.168.123.3");
        my_work->addr_send.sin_port = htons(CONNECT_PORT);
	//sock_set_flag(my_work->sock_send,SOCK_BROADCAST);
	if ((err = my_work->sock_send->ops->bind(my_work->sock_send, (struct sockaddr *)&my_work->addr_send, sizeof(struct sockaddr)) < 0 ))
        {
                printk(KERN_INFO MODULE_NAME": Could not bind or connect to socket, error = %d\n", -err);
                goto close_and_out;
        }
	oldfs=get_fs();
	set_fs(KERNEL_DS);
	set_fs(oldfs);
	//printk(KERN_INFO MODULE_NAME": listening on port %d\n", DEFAULT_PORT);
	//for (;;)
        //{
		//printk(KERN_INFO MODULE_NAME"Inside for loop\n");
                //memset(&buf, 0, bufsize+1);
                //size = receive(my_work->sock, &my_work->addr, buf, bufsize);
		//if (signal_pending(current))
                  //      break;
		//printk("\nsize=%d",size);
                

                        

                        
                        
                        strcpy(tmp_rrep->type, "BROADCAST MESSAGE SENT");
			printk(KERN_INFO MODULE_NAME":String Value:%s",tmp_rrep->type);
                        send(my_work->sock_send, &my_work->addr_send, tmp_rrep, sizeof(rrep));
			kfree(tmp_rrep);
			msleep(500);
        //}

close_and_out:
        sock_release(my_work->sock_send);
        my_work->sock = NULL;
        my_work->sock_send = NULL;

}
Example #28
0
void TimeThread::stop()
{
    stopped = true;
    while(!finished)
        msleep(5);
}
Example #29
0
static int tegra_ehci_hub_control(
	struct usb_hcd	*hcd,
	u16		typeReq,
	u16		wValue,
	u16		wIndex,
	char		*buf,
	u16		wLength
)
{
	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
	struct tegra_ehci_hcd *tegra = (struct tegra_ehci_hcd *)ehci->priv;
	u32 __iomem	*status_reg;
	u32		temp;
	unsigned long	flags;
	int		retval = 0;

	status_reg = &ehci->regs->port_status[(wIndex & 0xff) - 1];

	spin_lock_irqsave(&ehci->lock, flags);

	if (typeReq == GetPortStatus) {
		temp = ehci_readl(ehci, status_reg);
		if (tegra->port_resuming && !(temp & PORT_SUSPEND)) {
			/* Resume completed, re-enable disconnect detection */
			tegra->port_resuming = 0;
			tegra_usb_phy_postresume(hcd->usb_phy);
		}
	}

	else if (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_SUSPEND) {
		temp = ehci_readl(ehci, status_reg);
		if ((temp & PORT_PE) == 0 || (temp & PORT_RESET) != 0) {
			retval = -EPIPE;
			goto done;
		}

		temp &= ~(PORT_RWC_BITS | PORT_WKCONN_E);
		temp |= PORT_WKDISC_E | PORT_WKOC_E;
		ehci_writel(ehci, temp | PORT_SUSPEND, status_reg);

		/*
		 * If a transaction is in progress, there may be a delay in
		 * suspending the port. Poll until the port is suspended.
		 */
		if (ehci_handshake(ehci, status_reg, PORT_SUSPEND,
						PORT_SUSPEND, 5000))
			pr_err("%s: timeout waiting for SUSPEND\n", __func__);

		set_bit((wIndex & 0xff) - 1, &ehci->suspended_ports);
		goto done;
	}

	/* For USB1 port we need to issue Port Reset twice internally */
	if (tegra->needs_double_reset &&
	   (typeReq == SetPortFeature && wValue == USB_PORT_FEAT_RESET)) {
		spin_unlock_irqrestore(&ehci->lock, flags);
		return tegra_ehci_internal_port_reset(ehci, status_reg);
	}

	/*
	 * Tegra host controller will time the resume operation to clear the bit
	 * when the port control state switches to HS or FS Idle. This behavior
	 * is different from EHCI where the host controller driver is required
	 * to set this bit to a zero after the resume duration is timed in the
	 * driver.
	 */
	else if (typeReq == ClearPortFeature &&
					wValue == USB_PORT_FEAT_SUSPEND) {
		temp = ehci_readl(ehci, status_reg);
		if ((temp & PORT_RESET) || !(temp & PORT_PE)) {
			retval = -EPIPE;
			goto done;
		}

		if (!(temp & PORT_SUSPEND))
			goto done;

		/* Disable disconnect detection during port resume */
		tegra_usb_phy_preresume(hcd->usb_phy);

		ehci->reset_done[wIndex-1] = jiffies + msecs_to_jiffies(25);

		temp &= ~(PORT_RWC_BITS | PORT_WAKE_BITS);
		/* start resume signalling */
		ehci_writel(ehci, temp | PORT_RESUME, status_reg);
		set_bit(wIndex-1, &ehci->resuming_ports);

		spin_unlock_irqrestore(&ehci->lock, flags);
		msleep(20);
		spin_lock_irqsave(&ehci->lock, flags);

		/* Poll until the controller clears RESUME and SUSPEND */
		if (ehci_handshake(ehci, status_reg, PORT_RESUME, 0, 2000))
			pr_err("%s: timeout waiting for RESUME\n", __func__);
		if (ehci_handshake(ehci, status_reg, PORT_SUSPEND, 0, 2000))
			pr_err("%s: timeout waiting for SUSPEND\n", __func__);

		ehci->reset_done[wIndex-1] = 0;
		clear_bit(wIndex-1, &ehci->resuming_ports);

		tegra->port_resuming = 1;
		goto done;
	}

	spin_unlock_irqrestore(&ehci->lock, flags);

	/* Handle the hub control events here */
	return orig_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength);

done:
	spin_unlock_irqrestore(&ehci->lock, flags);
	return retval;
}
Example #30
0
/*
 * read request.
 */
static int
fw_read (struct cdev *dev, struct uio *uio, int ioflag)
{
	struct fw_drv1 *d;
	struct fw_xferq *ir;
	struct firewire_comm *fc;
	int err = 0, s, slept = 0;
	struct fw_pkt *fp;

	if (DEV_FWMEM(dev))
		return (physio(dev, uio, ioflag));

	d = (struct fw_drv1 *)dev->si_drv1;
	fc = d->fc;
	ir = d->ir;

	if (ir == NULL)
		return (fw_read_async(d, uio, ioflag));

	if (ir->buf == NULL)
		return (EIO);

	FW_GLOCK(fc);
readloop:
	if (ir->stproc == NULL) {
		/* iso bulkxfer */
		ir->stproc = STAILQ_FIRST(&ir->stvalid);
		if (ir->stproc != NULL) {
			s = splfw();
			STAILQ_REMOVE_HEAD(&ir->stvalid, link);
			splx(s);
			ir->queued = 0;
		}
	}
	if (ir->stproc == NULL) {
		/* no data avaliable */
		if (slept == 0) {
			slept = 1;
			ir->flag |= FWXFERQ_WAKEUP;
			err = msleep(ir, FW_GMTX(fc), FWPRI, "fw_read", hz);
			ir->flag &= ~FWXFERQ_WAKEUP;
			if (err == 0)
				goto readloop;
		} else if (slept == 1)
			err = EIO;
		FW_GUNLOCK(fc);
		return err;
	} else if(ir->stproc != NULL) {
		/* iso bulkxfer */
		FW_GUNLOCK(fc);
		fp = (struct fw_pkt *)fwdma_v_addr(ir->buf, 
				ir->stproc->poffset + ir->queued);
		if(fc->irx_post != NULL)
			fc->irx_post(fc, fp->mode.ld);
		if(fp->mode.stream.len == 0){
			err = EIO;
			return err;
		}
		err = uiomove((caddr_t)fp,
			fp->mode.stream.len + sizeof(uint32_t), uio);
		ir->queued ++;
		if(ir->queued >= ir->bnpacket){
			s = splfw();
			STAILQ_INSERT_TAIL(&ir->stfree, ir->stproc, link);
			splx(s);
			fc->irx_enable(fc, ir->dmach);
			ir->stproc = NULL;
		}
		if (uio->uio_resid >= ir->psize) {
			slept = -1;
			FW_GLOCK(fc);
			goto readloop;
		}
	}
	return err;
}