Skip to content

Commit

Permalink
[ARM] S3C24XX: GPIO: Change usb-simtec.c to use gpiolib.
Browse files Browse the repository at this point in the history
Make arch/arm/mach-s3c2410/usb-simtec.c use gpiolib to
manage gpio access.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
  • Loading branch information
Ben Dooks committed May 18, 2009
1 parent 5233c17 commit 7a05a2c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
3 changes: 1 addition & 2 deletions arch/arm/mach-s3c2410/mach-bast.c
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,6 @@ static void __init bast_map_io(void)
s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
s3c24xx_init_clocks(0);
s3c24xx_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));

usb_simtec_init();
}

static void __init bast_init(void)
Expand All @@ -609,6 +607,7 @@ static void __init bast_init(void)
i2c_register_board_info(0, bast_i2c_devs,
ARRAY_SIZE(bast_i2c_devs));

usb_simtec_init();
nor_simtec_init();
}

Expand Down
31 changes: 24 additions & 7 deletions arch/arm/mach-s3c2410/usb-simtec.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/timer.h>
#include <linux/init.h>
#include <linux/device.h>
#include <linux/gpio.h>
#include <linux/io.h>

#include <asm/mach/arch.h>
Expand All @@ -30,7 +31,6 @@

#include <mach/bast-map.h>
#include <mach/bast-irq.h>
#include <mach/regs-gpio.h>

#include <mach/hardware.h>
#include <asm/irq.h>
Expand All @@ -54,17 +54,17 @@ usb_simtec_powercontrol(int port, int to)
power_state[port] = to;

if (power_state[0] && power_state[1])
s3c2410_gpio_setpin(S3C2410_GPB(4), 0);
gpio_set_value(S3C2410_GPB(4), 0);
else
s3c2410_gpio_setpin(S3C2410_GPB(4), 1);
gpio_set_value(S3C2410_GPB(4), 1);
}

static irqreturn_t
usb_simtec_ocirq(int irq, void *pw)
{
struct s3c2410_hcd_info *info = pw;

if (s3c2410_gpio_getpin(S3C2410_GPG(10)) == 0) {
if (gpio_get_value(S3C2410_GPG(10)) == 0) {
pr_debug("usb_simtec: over-current irq (oc detected)\n");
s3c2410_usb_report_oc(info, 3);
} else {
Expand Down Expand Up @@ -107,10 +107,27 @@ static struct s3c2410_hcd_info usb_simtec_info = {

int usb_simtec_init(void)
{
int ret;

printk("USB Power Control, (c) 2004 Simtec Electronics\n");
s3c_device_usb.dev.platform_data = &usb_simtec_info;

s3c2410_gpio_cfgpin(S3C2410_GPB(4), S3C2410_GPIO_OUTPUT);
s3c2410_gpio_setpin(S3C2410_GPB(4), 1);
ret = gpio_request(S3C2410_GPB(4), "USB power control");
if (ret < 0) {
pr_err("%s: failed to get GPB4\n", __func__);
return ret;
}

ret = gpio_request(S3C2410_GPG(10), "USB overcurrent");
if (ret < 0) {
pr_err("%s: failed to get GPG10\n", __func__);
gpio_free(S3C2410_GPB(4));
return ret;
}

/* turn power on */
gpio_direction_output(S3C2410_GPB(4), 1);
gpio_direction_input(S3C2410_GPG(10));

s3c_device_usb.dev.platform_data = &usb_simtec_info;
return 0;
}

0 comments on commit 7a05a2c

Please sign in to comment.