Skip to content
Permalink
Browse files

Implement the usleep timer and use it.

Taken from http://lkml.org/lkml/2010/7/23/206
Ninpo pointed it out to me.  I changed some of the calls from udelay to usleep according to his changes here: http://github.com/Ninpo/kernel-hero/commit/f04a4510e3cd427df9e47533f9727bcef24cb644

Some fixes per kernelzilla
  • Loading branch information
kmobs committed Aug 25, 2010
1 parent 2d711e5 commit 4bff1546e90ebc7ca40e10f1eab5def4c6f01fb5
@@ -264,15 +264,15 @@ int mahimahi_wifi_power(int on)
if (on) {
config_gpio_table(wifi_on_gpio_table,
ARRAY_SIZE(wifi_on_gpio_table));
mdelay(50);
msleep(50);
} else {
config_gpio_table(wifi_off_gpio_table,
ARRAY_SIZE(wifi_off_gpio_table));
}

mdelay(100);
msleep(100);
gpio_set_value(MAHIMAHI_GPIO_WIFI_SHUTDOWN_N, on); /* WIFI_SHUTDOWN */
mdelay(200);
msleep(200);

mahimahi_wifi_power_state = on;
return 0;
@@ -61,7 +61,7 @@ static int qspi_send(uint32_t id, uint8_t data)
}
}
writel((0x7000 | (id << 9) | data) << 16, spi_base + SPI_OUTPUT_FIFO);
udelay(100);
usleep(100);

return 0;
}
@@ -79,7 +79,7 @@ static int qspi_send_9bit(uint32_t id, uint8_t data)
}
}
writel(((id << 8) | data) << 23, spi_base + SPI_OUTPUT_FIFO);
udelay(100);
usleep(100);

return 0;
}
@@ -502,9 +502,9 @@ static int samsung_oled_panel_unblank(struct msm_lcdc_panel_ops *ops)
mutex_lock(&panel_lock);

gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 1);
udelay(50);
usleep(50);
gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 0);
udelay(20);
usleep(20);
gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 1);
msleep(20);

@@ -679,7 +679,7 @@ static int sony_tft_panel_power(int on)
gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 1);
mdelay(10);
gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 0);
udelay(500);
usleep(500);
gpio_set_value(MAHIMAHI_GPIO_LCD_RST_N, 1);
mdelay(10);
sony_tft_panel_config_gpio_table(
@@ -372,7 +372,7 @@ static int mahimahi_ts_power(int on)
} else {
gpio_set_value(MAHIMAHI_GPIO_TP_LS_EN, 0);
gpio_set_value(MAHIMAHI_GPIO_TP_EN, 0);
udelay(50);
usleep(50);
}

return 0;
@@ -212,7 +212,7 @@ static int AKECS_SetMode(char mode)
}

/* wait at least 300us after changing mode */
mdelay(1);
usleep(500);
return ret;
}

@@ -45,6 +45,12 @@ extern unsigned long lpj_fine;
void calibrate_delay(void);
void msleep(unsigned int msecs);
unsigned long msleep_interruptible(unsigned int msecs);
void usleep_range(unsigned long min, unsigned long max);

static inline void usleep(unsigned long usecs)
{
usleep_range(usecs, usecs);
}

static inline void ssleep(unsigned int seconds)
{
@@ -1683,3 +1683,25 @@ unsigned long msleep_interruptible(unsigned int msecs)
}

EXPORT_SYMBOL(msleep_interruptible);

static int __sched do_usleep_range(unsigned long min, unsigned long max)
{
ktime_t kmin;
unsigned long delta;

kmin = ktime_set(0, min * NSEC_PER_USEC);
delta = max - min;
return schedule_hrtimeout_range(&kmin, delta, HRTIMER_MODE_REL);
}

/**
* usleep_range - Drop in replacement for udelay where wakeup is flexible
* @min: Minimum time in usecs to sleep
* @max: Maximum time in usecs to sleep
*/
void usleep_range(unsigned long min, unsigned long max)
{
__set_current_state(TASK_UNINTERRUPTIBLE);
do_usleep_range(min, max);
}
EXPORT_SYMBOL(usleep_range);

5 comments on commit 4bff154

@pershoot

This comment has been minimized.

Copy link
Member

@pershoot pershoot replied Aug 29, 2010

this doesn't work well for .35. causes general slowdown. please take note of this.

have not tested it against .34.

@kmobs

This comment has been minimized.

Copy link
Member Author

@kmobs kmobs replied Aug 29, 2010

Try removing the changes in board-mahimahi-panel.c and trying again.

@pershoot

This comment has been minimized.

Copy link
Member

@pershoot pershoot replied Aug 29, 2010

i'd rather not mix/match. ill revisit sometime in the future.

@kernelzilla

This comment has been minimized.

Copy link

@kernelzilla kernelzilla replied Aug 30, 2010

Yeah outside of the compass driver this may not be too beneficial.
It more than likely causes slowness because it's a high resolution timer and isn't using _range, so it has to ramp cpu to do more precise timing(nano vs microseconds).

@wesgarner

This comment has been minimized.

Copy link

@wesgarner wesgarner replied Aug 30, 2010

What I think he is trying to say is:
Score: -1, I would prefer that you did not submit this

Please sign in to comment.
You can’t perform that action at this time.