Exemplo n.º 1
0
/**
 * Issues a reset bus sequence.
 *
 * @param  dev The bus master pointer
 * @return     0=Device present, 1=No device present or error
 */
static u8 w1_gpio_reset_bus(void *data)
{
	int result=1, i;
	struct w1_gpio_msm_platform_data *pdata = data;
	void	(*write_bit)(void *, u8);
	unsigned long irq_flags;
	int temp_read[MAX_SAMPLE]={'1',};
	int loop_cnt = 3;

	if (pdata->is_open_drain) {
		write_bit = w1_gpio_write_bit_val;
	} else {
		write_bit = w1_gpio_write_bit_dir;
	}

	spin_lock_irqsave(&w1_gpio_msm_lock, irq_flags);

	while (loop_cnt > 0) {
		write_bit(data, 0);
			/* minimum 48, max 80 us(In DS Documnet)
			 * be nice and sleep, except 18b20 spec lists 960us maximum,
			 * so until we can sleep with microsecond accuracy, spin.
			 * Feel free to come up with some other way to give up the
			 * cpu for such a short amount of time AND get it back in
			 * the maximum amount of time.
			 */
		(pdata->slave_speed == 0)? __const_udelay(500*UDELAY_MULT) : __const_udelay(50*UDELAY_MULT);
		write_bit(data, 1);

		(pdata->slave_speed == 0)? __const_udelay(60*UDELAY_MULT) : __const_udelay(1*UDELAY_MULT);

		for(i=0;i<MAX_SAMPLE;i++)
			temp_read[i] = gpio_get_value_msm(pdata->pin);

		for(i=0;i<MAX_SAMPLE;i++)
			result &= temp_read[i];

		/* minmum 70 (above) + 410 = 480 us
		 * There aren't any timing requirements between a reset and
		 * the following transactions.  Sleeping is safe here.
		 */
		/* w1_delay(410); min required time */
		(pdata->slave_speed == 0)? msleep(1) : __const_udelay(40*UDELAY_MULT);

		if (result)
			loop_cnt--;
		else
			break;
	}

	spin_unlock_irqrestore(&w1_gpio_msm_lock, irq_flags);

	return result;
}
Exemplo n.º 2
0
void __ndelay(unsigned long nsecs)
{
	__const_udelay(nsecs * 0x00005); /* 2**32 / 1000000000 (rounded up) */
}
Exemplo n.º 3
0
void __udelay(unsigned long usecs)
{
	__const_udelay(usecs * 0x000010c7); /* 2**32 / 1000000 (rounded up) */
}
Exemplo n.º 4
0
void __udelay(unsigned long usecs)
{
	__const_udelay(usecs * 0x000010c6);  /* 2**32 / 1000000 */
}
Exemplo n.º 5
0
void __ndelay(unsigned long nsecs)
{
	__const_udelay(nsecs * 0x00000005);
}
Exemplo n.º 6
0
void __ndelay(unsigned long n)
{
	__const_udelay(n * 0x5UL);
}
Exemplo n.º 7
0
void __udelay(unsigned long n)
{
	__const_udelay(n * 0x10c7UL);
}