2005-04-17 00:20:36 +02:00
|
|
|
/* linux/arch/arm/mach-s3c2410/usb-simtec.c
|
|
|
|
*
|
2009-11-13 23:54:13 +01:00
|
|
|
* Copyright 2004-2005 Simtec Electronics
|
2005-04-17 00:20:36 +02:00
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
|
|
|
* http://www.simtec.co.uk/products/EB2410ITX/
|
|
|
|
*
|
|
|
|
* Simtec BAST and Thorcom VR1000 USB port support functions
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
2009-05-13 23:52:24 +02:00
|
|
|
#include <linux/gpio.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
2008-09-06 13:10:45 +02:00
|
|
|
#include <linux/io.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
|
2008-08-05 17:14:15 +02:00
|
|
|
#include <mach/bast-map.h>
|
|
|
|
#include <mach/bast-irq.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-08-05 17:14:15 +02:00
|
|
|
#include <mach/hardware.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <asm/irq.h>
|
|
|
|
|
2009-03-07 12:44:21 +01:00
|
|
|
#include <plat/usb-control.h>
|
2008-10-07 23:26:09 +02:00
|
|
|
#include <plat/devs.h>
|
2009-03-07 12:44:21 +01:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
#include "usb-simtec.h"
|
|
|
|
|
|
|
|
/* control power and monitor over-current events on various Simtec
|
|
|
|
* designed boards.
|
|
|
|
*/
|
|
|
|
|
2005-08-10 17:45:14 +02:00
|
|
|
static unsigned int power_state[2];
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static void
|
|
|
|
usb_simtec_powercontrol(int port, int to)
|
|
|
|
{
|
|
|
|
pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
|
|
|
|
|
2005-08-10 17:45:14 +02:00
|
|
|
power_state[port] = to;
|
|
|
|
|
|
|
|
if (power_state[0] && power_state[1])
|
2009-05-18 21:15:01 +02:00
|
|
|
gpio_set_value(S3C2410_GPB(4), 0);
|
2005-08-10 17:45:14 +02:00
|
|
|
else
|
2009-05-18 21:15:01 +02:00
|
|
|
gpio_set_value(S3C2410_GPB(4), 1);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
2006-10-06 19:53:39 +02:00
|
|
|
usb_simtec_ocirq(int irq, void *pw)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2007-10-26 11:40:22 +02:00
|
|
|
struct s3c2410_hcd_info *info = pw;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-05-18 21:15:01 +02:00
|
|
|
if (gpio_get_value(S3C2410_GPG(10)) == 0) {
|
2005-04-17 00:20:36 +02:00
|
|
|
pr_debug("usb_simtec: over-current irq (oc detected)\n");
|
2005-08-10 17:45:14 +02:00
|
|
|
s3c2410_usb_report_oc(info, 3);
|
2005-04-17 00:20:36 +02:00
|
|
|
} else {
|
|
|
|
pr_debug("usb_simtec: over-current irq (oc cleared)\n");
|
2005-08-10 17:45:14 +02:00
|
|
|
s3c2410_usb_report_oc(info, 0);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_simtec_enableoc(struct s3c2410_hcd_info *info, int on)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (on) {
|
[PATCH] IRQ type flags
Some ARM platforms have the ability to program the interrupt controller to
detect various interrupt edges and/or levels. For some platforms, this is
critical to setup correctly, particularly those which the setting is dependent
on the device.
Currently, ARM drivers do (eg) the following:
err = request_irq(irq, ...);
set_irq_type(irq, IRQT_RISING);
However, if the interrupt has previously been programmed to be level sensitive
(for whatever reason) then this will cause an interrupt storm.
Hence, if we combine set_irq_type() with request_irq(), we can then safely set
the type prior to unmasking the interrupt. The unfortunate problem is that in
order to support this, these flags need to be visible outside of the ARM
architecture - drivers such as smc91x need these flags and they're
cross-architecture.
Finally, the SA_TRIGGER_* flag passed to request_irq() should reflect the
property that the device would like. The IRQ controller code should do its
best to select the most appropriate supported mode.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-01-08 10:02:07 +01:00
|
|
|
ret = request_irq(IRQ_USBOC, usb_simtec_ocirq,
|
2006-07-03 02:20:05 +02:00
|
|
|
IRQF_DISABLED | IRQF_TRIGGER_RISING |
|
|
|
|
IRQF_TRIGGER_FALLING,
|
2005-04-17 00:20:36 +02:00
|
|
|
"USB Over-current", info);
|
|
|
|
if (ret != 0) {
|
|
|
|
printk(KERN_ERR "failed to request usb oc irq\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
free_irq(IRQ_USBOC, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-13 06:59:46 +01:00
|
|
|
static struct s3c2410_hcd_info usb_simtec_info __initdata = {
|
2005-04-17 00:20:36 +02:00
|
|
|
.port[0] = {
|
|
|
|
.flags = S3C_HCDFLG_USED
|
|
|
|
},
|
|
|
|
.port[1] = {
|
|
|
|
.flags = S3C_HCDFLG_USED
|
|
|
|
},
|
|
|
|
|
|
|
|
.power_control = usb_simtec_powercontrol,
|
|
|
|
.enable_oc = usb_simtec_enableoc,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int usb_simtec_init(void)
|
|
|
|
{
|
2009-05-18 21:15:01 +02:00
|
|
|
int ret;
|
|
|
|
|
2009-11-13 23:54:12 +01:00
|
|
|
printk("USB Power Control, Copyright 2004 Simtec Electronics\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2009-05-18 21:15:01 +02:00
|
|
|
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));
|
|
|
|
|
2010-01-13 06:59:46 +01:00
|
|
|
s3c_ohci_set_platdata(&usb_simtec_info);
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|