Exemplo n.º 1
0
unsigned char PROTONfp_RD(void)
{
	int i;
	unsigned char val = 0, data = 0;

	down_read(&vfd_rws);

	PROTONfp_Set_PIO_Mode(PIO_In);
	for (i = 0; i < 8; i++)
	{
		val >>= 1;
		stpio_set_pin(cfg.clk, 0);
		udelay(1);
		data = stpio_get_pin(cfg.data);
		stpio_set_pin(cfg.clk, 1);
		if(data)
			val |= 0x80;
		stpio_set_pin(cfg.clk, 1);
		udelay(1);
	}
	udelay(1);
	PROTONfp_Set_PIO_Mode(PIO_Out);
	up_read(&vfd_rws);

	return val;
}
Exemplo n.º 2
0
unsigned char PROTONfp_RD(void)
{
    int i;
    unsigned char val = 0, data = 0;

#ifdef VFD_RW_SEM
     down_read(&vfd_rws);
#endif

    PROTONfp_Set_PIO_Mode(PIO_In);
    for (i = 0; i < 8; i++)
    {
        val >>= 1;
		VFD_CLK_CLR();
        udelay(1);
        data = stpio_get_pin(cfg.data);
		VFD_CLK_SET();
        if(data)
        {
            val |= 0x80;
        }
		VFD_CLK_SET();
        udelay(1);
    }
    udelay(1);
    PROTONfp_Set_PIO_Mode(PIO_Out);

#ifdef VFD_RW_SEM
    up_read(&vfd_rws);
#endif

    return val;
}
/* Device ready functio, for boards where nand_rbn is available via GPIO pin */
static int nand_device_ready(struct mtd_info *mtd)
{
	struct nand_chip *this = mtd->priv;
	struct stm_nand_emi *data = this->priv;

	return stpio_get_pin(data->rbn);
}
Exemplo n.º 4
0
YW_ErrorType_T YWGPIO_Read(YWGPIO_Handle_T GpioHandle, U8 *pPioValue)
{
	struct stpio_pin *pPio = (struct stpio_pin *)GpioHandle;

	(*pPioValue) = stpio_get_pin(pPio);

	return YW_NO_ERROR;
}
static inline u32 getmiso(struct spi_device *dev)
{
	struct platform_device *pdev
		= container_of(dev->dev.parent, struct platform_device, dev);
	struct ssc_pio_t *pio_info =
		(struct ssc_pio_t *)pdev->dev.platform_data;
	return stpio_get_pin(pio_info->sdin) ? 1 : 0;
}
Exemplo n.º 6
0
static int tfswitch_read_proc(char *page, char **start, off_t off, int count,
                  int *eof, void *data_unused)
{
  int cnt = 0;

  if((page != NULL) && (count > 1))
  {
    page[0] = (char)stpio_get_pin(pPin) + 0x30;
    page[1] = '\n';
    cnt = 2;
  }

  return cnt;
}
Exemplo n.º 7
0
int proc_fan_read(char *page, char **start, off_t off, int count,
			  int *eof, void *data_unused)
{
	int len = 0;
//	printk("%s %d\n", __FUNCTION__, count);
        int rv = 0;
        if (fan_pin)
    		rv = stpio_get_pin(fan_pin);
	//printk("%s %d\n", __FUNCTION__, rv);	 

	if ( rv == 1  )
		len = sprintf(page, "1\n");
        else
		len = sprintf(page, "0\n");

        return len;
}
Exemplo n.º 8
0
static int ufs9xx_cic_writereg(struct ufs9xx_cic_state* state, int reg, int data)
{
	u8 buf[] = { reg, data };
	struct i2c_msg msg = { .addr = state->i2c_addr,
		.flags = 0, .buf = buf, .len = 2 };
	int err;

	if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) {
		printk("%s: writereg error(err == %i, reg == 0x%02x,"
			 " data == 0x%02x)\n", __FUNCTION__, err, reg, data);
		return -EREMOTEIO;
	}

	return 0;
}
#endif

static int ufs9xx_cic_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open)
{
	struct ufs9xx_cic_state *state = ca->data;
	int                     slot_status = 0;
	unsigned int            result;
#if defined(UFS922)
	u8                      buf[2];
#endif

	dprintk(150, "%s (%d; open = %d) >\n", __FUNCTION__, slot, open);

#if defined(UFS922)
/* hacky workaround for stmfb problem (yes I really mean stmfb ;-) ):
 * switching the hdmi output of my lcd to the ufs922 while running or
 * switching the resolution leads to a modification of register
 * 0x00 which disable the stream input for ci controller. it seems so
 * that the ci controller has no bypass in this (and in any) case.
 * so we poll it here and set it back.
 */ 
	buf[0] = 0x00;
	ufs9xx_cic_readN (state, buf, 1);

	if (buf[0] != 0x3f)
	{
		printk("ALERT: CI Controller loosing input %02x\n", buf[0]);
		
		ufs9xx_cic_writereg(state, 0x00, 0x3f);
	}	
#endif

	result = stpio_get_pin(state->slot_status[slot]);

	dprintk(120, "Slot %d Status = 0x%x\n", slot, result);

	if (result == 0x01)
		slot_status = 1;

	if (slot_status)
	{
		if (state->module_status[slot] & SLOTSTATUS_RESET)
		{
	/* the sequence from dvbapi is to reset the cam after a detection change,
	* so we save the state and check here if the module is ready. on ufs913/ufs922
	* we have a special ready pin, on ufs912 we read from attribute memory.
	*/

#if defined(UFS912)

#ifdef use_additional_waiting_period
			/* timeout in progress */
			if(time_after(jiffies, state->detection_timeout[slot]))
			{
#endif
				result = ufs9xx_cic_read_attribute_mem(ca, slot, 0); 

				dprintk(200, "result = 0x%02x\n", result);

				if (result == 0x1d)
					state->module_status[slot] = SLOTSTATUS_READY;
#ifdef use_additional_waiting_period
			}
#endif
#else

			result = stpio_get_pin(state->module_ready_pin[slot]);

			dprintk(200, "readyPin = %d\n", result);
			if (result)
				state->module_status[slot] = SLOTSTATUS_READY;
#endif
		}
		else if (state->module_status[slot] & SLOTSTATUS_NONE)
		{
#if !defined(UFS913)

			stpio_set_pin(state->slot_enable[slot], 0);
			mdelay(waitMS);
#else
			stpio_set_pin(state->slot_enable[slot], 1);
			mdelay(waitMS);
#endif

			dprintk(1, "Modul now present\n");
			state->module_status[slot] = SLOTSTATUS_PRESENT;
		}
	}
	else
	{
		if (!(state->module_status[slot] & SLOTSTATUS_NONE))
		{
#ifdef UFS913
			stpio_set_pin(state->slot_enable[slot], 0);
#else
			stpio_set_pin(state->slot_enable[slot], 1);
#endif
			dprintk(1, "Modul now not present\n");
			state->module_status[slot] = SLOTSTATUS_NONE;
		}
	}

	if (state->module_status[slot] != SLOTSTATUS_NONE)
		slot_status = DVB_CA_EN50221_POLL_CAM_PRESENT;
	else
		slot_status = 0;
   
	if (state->module_status[slot] & SLOTSTATUS_READY)
		slot_status |= DVB_CA_EN50221_POLL_CAM_READY;

	dprintk(120, "Module %c (%d): result = %d, status = %d\n",
				slot ? 'B' : 'A', slot, slot_status,
				state->module_status[slot]);

	return slot_status;
}

static int ufs9xx_cic_slot_reset(struct dvb_ca_en50221 *ca, int slot)
{
	struct ufs9xx_cic_state *state = ca->data;
	int aPresent, bPresent;

	dprintk(1, "%s >\n", __FUNCTION__);


	state->module_status[slot] = SLOTSTATUS_RESET;

#if defined(UFS922) || defined(UFS913) || defined(UFC960)
	aPresent = ((ci_state.module_status[0] & SLOTSTATUS_READY) || (ci_state.module_status[0] & SLOTSTATUS_PRESENT));
	bPresent = ((ci_state.module_status[1] & SLOTSTATUS_READY) || (ci_state.module_status[1] & SLOTSTATUS_PRESENT));

	if ((aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_VIEW);
		set_ts_path(TUNER_1_CAM_A_VIEW);
	} else
	if ((!aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_B_VIEW);
	} else
	if ((aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_A_CAM_B_VIEW);
	} else
	if ((!aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_VIEW);
		set_ts_path(TUNER_1_VIEW);
	}
#endif

#if defined(UFS912)
	stpio_set_pin(state->slot_enable[slot], 1);
	mdelay(50);
	stpio_set_pin(state->slot_enable[slot], 0);
	mdelay(50);
#endif
	stpio_set_pin(state->slot_reset[slot], 1);
	mdelay(waitMS);
	stpio_set_pin(state->slot_reset[slot], 0);
	mdelay(waitMS);

	state->detection_timeout[slot] = jiffies + HZ / 2;

	dprintk(1, "%s <\n", __FUNCTION__);
	return 0;
}

static int ufs9xx_cic_read_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address)
{
	struct ufs9xx_cic_state *state = ca->data;
	unsigned char res = 0;

	dprintk(100, "%s > slot = %d, address = 0x%.8lx\n", __FUNCTION__, slot, (unsigned long) state->slot_attribute_read[slot] + address);

	res = ufs9xx_read_register_u8(state->slot_attribute_read[slot] + address);

	if (address <= 2)
		dprintk (100, "address = %d: res = 0x%.x\n", address, res);
	else
	{
		if ((res > 31) && (res < 127))
			dprintk(100, "%c", res);
		else
			dprintk(150, ".");
	}

	return (int) res;
}

static int ufs9xx_cic_write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, int address, u8 value)
{
	struct ufs9xx_cic_state *state = ca->data;

	dprintk(100, "%s > slot = %d, address = 0x%.8lx, value = 0x%.x\n", __FUNCTION__, slot, (unsigned long) state->slot_attribute_write[slot] + address, value);
	ufs9xx_write_register_u8(state->slot_attribute_write[slot] + address, value);

	return 0;
}

static int ufs9xx_cic_read_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address)
{
	struct ufs9xx_cic_state *state = ca->data;
	unsigned char res = 0;
	
	res = ufs9xx_read_register_u8(state->slot_control_read[slot] + address);

	dprintk (100, "%s (%d): address = 0x%x: res = 0x%x (0x%x)\n", __func__, slot, address, res, (int) res);

	return (int) res;
}

static int ufs9xx_cic_write_cam_control(struct dvb_ca_en50221 *ca, int slot, u8 address, u8 value)
{
	struct ufs9xx_cic_state *state = ca->data;

	dprintk(100, "%s > slot = %d, address = 0x%.8lx, value = 0x%.x\n", __FUNCTION__, slot, (unsigned long) state->slot_control_write[slot] + address, value);

	ufs9xx_write_register_u8(state->slot_control_write[slot] + address, value);

	return 0;
}

static int ufs9xx_cic_slot_shutdown(struct dvb_ca_en50221 *ca, int slot)
{
	struct ufs9xx_cic_state *state = ca->data;
	int aPresent, bPresent;

	dprintk(1, "%s > slot = %d\n", __FUNCTION__, slot);
    
#if defined(UFS913)
	stpio_set_pin(state->slot_enable[slot], 0);
#else
	stpio_set_pin(state->slot_enable[slot], 1);
#endif

#if defined(UFS922) || defined(UFS913) || defined(UFC960)
	aPresent = ((ci_state.module_status[0] & SLOTSTATUS_READY) || (ci_state.module_status[0] & SLOTSTATUS_PRESENT));
	bPresent = ((ci_state.module_status[1] & SLOTSTATUS_READY) || (ci_state.module_status[1] & SLOTSTATUS_PRESENT));

	if ((aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_VIEW);
		set_ts_path(TUNER_1_CAM_A_VIEW);
	} else
	if ((!aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_B_VIEW);
	} else
	if ((aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_A_CAM_B_VIEW);
	} else
	if ((!aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_VIEW);
		set_ts_path(TUNER_1_VIEW);
	}
#endif
	return 0;
}

static int ufs9xx_cic_slot_ts_enable(struct dvb_ca_en50221 *ca, int slot)
{
//	struct ufs9xx_cic_state *state = ca->data;
	int aPresent, bPresent;

	dprintk(20, "%s > slot = %d\n", __FUNCTION__, slot);

#if defined(UFS922) || defined(UFS913) || defined(UFC960)
	aPresent = ((ci_state.module_status[0] & SLOTSTATUS_READY) || (ci_state.module_status[0] & SLOTSTATUS_PRESENT));
	bPresent = ((ci_state.module_status[1] & SLOTSTATUS_READY) || (ci_state.module_status[1] & SLOTSTATUS_PRESENT));

	if ((aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_VIEW);
		set_ts_path(TUNER_1_CAM_A_VIEW);
	} else
	if ((!aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_B_VIEW);
	} else
	if ((aPresent) && (bPresent))
	{
		set_cam_path(TUNER_1_CAM_A_CAM_B_VIEW);
		set_ts_path(TUNER_1_CAM_A_CAM_B_VIEW);
	} else
	if ((!aPresent) && (!bPresent))
	{
		set_cam_path(TUNER_1_VIEW);
		set_ts_path(TUNER_1_VIEW);
	}
#endif

	return 0;
}
Exemplo n.º 9
0
void scan_key(void)
{
	int i, j;
	u32 key_data = 0;
	unsigned char key_buf[5];

	memset(key_buf, 0, sizeof(key_buf));

	command(0x42);                  /*command2 read key data to Display increment mode*/

	stpio_set_pin(kfront->data, 1);

	for (i = 0; i < 5; i++)
	{
		for (j = 0; j < 8; j++)
		{
			stpio_set_pin(kfront->clk, 1);
			delay(1);
			stpio_set_pin(kfront->clk, 0);
			delay(1);
			if (stpio_get_pin(kfront->data))
			{
				key_buf[i] |= (1 << j);
			}
		}
	}

#if 0
	for (i = 0; i < 5; i++)
	{
		for (j = 0; j < 8; j++)
		{
			dprintk("%d ", (key_buf[i] >> j) & 0x01);
		}
		dprintk("\n");
	}
	dprintk("\n");
#endif

	stpio_set_pin(kfront->clk, 1);

	/*	parse key	*/
	if (key_buf[0] & 0x01)			/*	exit		*/
		key_data = FRONT_EXIT;
	else if (key_buf[0] & 0x08)		/*	ok		*/
		key_data = FRONT_OK;
	else if (key_buf[1] & 0x01)		/*	vol+		*/
		key_data = FRONT_VolUp;
	else if (key_buf[1] & 0x08)		/*	vol-		*/
		key_data = FRONT_VolDn;
	else if (key_buf[2] & 0x01)		/*	power	*/
		key_data = FRONT_STBY;
	else if (key_buf[2] & 0x08)		/*	ch-		*/
		key_data = FRONT_PgDn;
	else if (key_buf[3] & 0x01)		/*	menu	*/
		key_data = FRONT_Menu;
	else if (key_buf[3] & 0x08)		/*	ch+		*/
		key_data = FRONT_PgUp;

	if (key_data)
	{
		int key;
#ifdef REPEAT_KEY_SUPPORT
#ifdef REPEAT_DEACCEL_SUPPORT
		if (prev_key_data != key_data)
			repeat_key_count = 0;

		repeat_key_count++;
#endif
		if (is_repeat_key(key_data))
		{
#ifdef REPEAT_DEACCEL_SUPPORT
			if (repeat_key_count > 1 && repeat_key_count <= MSEC_TO_LOOP_CNT(500))
				return;
#endif
		}
		else
		{
			if (prev_key_data == key_data)
				return;
		}

		prev_key_data = key_data;
		prev_loop_count = cur_loop_count;
#endif

		// event subsystem passing
		key = translate_fp_key(key_data, 5);
		if (key)
		{
			input_report_key(fp_button_dev, key, 1);
			input_sync(fp_button_dev);
			msleep(100);
			input_report_key(fp_button_dev, key, 0);
			input_sync(fp_button_dev);
			//FIXME: Add delay to not report one key press ducplicated
		}

		DVB_RINGBUFFER_WRITE_BYTE(&ci_rbuffer, key_data);
		wake_up_interruptible(&ci_rbuffer.queue);
	}
	else
	{
#ifdef REPEAT_KEY_SUPPORT
		/*	delete chattering	*/
		if ((prev_loop_count + MSEC_TO_LOOP_CNT(200)) <= cur_loop_count)
		{
			prev_key_data = 0;
#ifdef REPEAT_DEACCEL_SUPPORT
			repeat_key_count = 0;
#endif
		}
#endif
	}
}