fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / arm / mach-s3c2410 / usb-simtec.c
index b8f8ded..22b0e1c 100644 (file)
@@ -1,6 +1,6 @@
 /* linux/arch/arm/mach-s3c2410/usb-simtec.c
  *
- * Copyright (c) 2004 Simtec Electronics
+ * Copyright (c) 2004,2005 Simtec Electronics
  *   Ben Dooks <ben@simtec.co.uk>
  *
  * http://www.simtec.co.uk/products/EB2410ITX/
@@ -10,9 +10,6 @@
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
- *
- * Modifications:
- *     14-Sep-2004 BJD  Created
 */
 
 #define DEBUG
@@ -37,7 +34,6 @@
 #include <asm/hardware.h>
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/mach-types.h>
 
 #include "devs.h"
 #include "usb-simtec.h"
  * designed boards.
 */
 
+static unsigned int power_state[2];
+
 static void
 usb_simtec_powercontrol(int port, int to)
 {
        pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
 
-       if (port == 1) {
-               s3c2410_gpio_setpin(S3C2410_GPB4, to ? 0:1);
-               pr_debug("GPBDAT now %08x\n", __raw_readl(S3C2410_GPBDAT));
-       }
+       power_state[port] = to;
+
+       if (power_state[0] && power_state[1])
+               s3c2410_gpio_setpin(S3C2410_GPB4, 0);
+       else
+               s3c2410_gpio_setpin(S3C2410_GPB4, 1);
 }
 
 static irqreturn_t
-usb_simtec_ocirq(int irq, void *pw, struct pt_regs *regs)
+usb_simtec_ocirq(int irq, void *pw)
 {
        struct s3c2410_hcd_info *info = (struct s3c2410_hcd_info *)pw;
 
        if (s3c2410_gpio_getpin(S3C2410_GPG10) == 0) {
                pr_debug("usb_simtec: over-current irq (oc detected)\n");
-               s3c2410_report_oc(info, 3);
+               s3c2410_usb_report_oc(info, 3);
        } else {
                pr_debug("usb_simtec: over-current irq (oc cleared)\n");
+               s3c2410_usb_report_oc(info, 0);
        }
 
        return IRQ_HANDLED;
@@ -77,16 +78,15 @@ static void usb_simtec_enableoc(struct s3c2410_hcd_info *info, int on)
        int ret;
 
        if (on) {
-               pr_debug("claiming usb overccurent\n");
-               ret = request_irq(IRQ_USBOC, usb_simtec_ocirq, SA_INTERRUPT,
-                                 "usb-oc", info);
+               ret = request_irq(IRQ_USBOC, usb_simtec_ocirq,
+                                 IRQF_DISABLED | IRQF_TRIGGER_RISING |
+                                  IRQF_TRIGGER_FALLING,
+                                 "USB Over-current", info);
                if (ret != 0) {
                        printk(KERN_ERR "failed to request usb oc irq\n");
                }
-
-               set_irq_type(IRQ_USBOC, IRQT_BOTHEDGE);
        } else {
-               free_irq(IRQ_USBOC, NULL);
+               free_irq(IRQ_USBOC, info);
        }
 }
 
@@ -110,14 +110,5 @@ int usb_simtec_init(void)
 
        s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
        s3c2410_gpio_setpin(S3C2410_GPB4, 1);
-
-       pr_debug("GPB: CON=%08x, DAT=%08x\n",
-                __raw_readl(S3C2410_GPBCON), __raw_readl(S3C2410_GPBDAT));
-
-       if (0) {
-               s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST,
-                                     S3C2410_MISCCR_USBDEV);
-       }
-
        return 0;
 }