2005-04-16 22:20:36 +00:00
|
|
|
/* linux/arch/arm/mach-s3c2410/usb-simtec.c
|
|
|
|
*
|
2005-08-10 15:45:14 +00:00
|
|
|
* Copyright (c) 2004,2005 Simtec Electronics
|
2005-04-16 22:20:36 +00: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.
|
|
|
|
*
|
|
|
|
* Modifications:
|
|
|
|
* 14-Sep-2004 BJD Created
|
|
|
|
* 18-Oct-2004 BJD Cleanups, and added code to report OC cleared
|
2005-08-10 15:45:14 +00:00
|
|
|
* 09-Aug-2005 BJD Renamed s3c2410_report_oc to s3c2410_usb_report_oc
|
|
|
|
* 09-Aug-2005 BJD Ports powered only if both are enabled
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define DEBUG
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
|
|
|
|
#include <asm/arch/bast-map.h>
|
|
|
|
#include <asm/arch/bast-irq.h>
|
|
|
|
#include <asm/arch/usb-control.h>
|
|
|
|
#include <asm/arch/regs-gpio.h>
|
|
|
|
|
|
|
|
#include <asm/hardware.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/irq.h>
|
|
|
|
|
|
|
|
#include "devs.h"
|
|
|
|
#include "usb-simtec.h"
|
|
|
|
|
|
|
|
/* control power and monitor over-current events on various Simtec
|
|
|
|
* designed boards.
|
|
|
|
*/
|
|
|
|
|
2005-08-10 15:45:14 +00:00
|
|
|
static unsigned int power_state[2];
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static void
|
|
|
|
usb_simtec_powercontrol(int port, int to)
|
|
|
|
{
|
|
|
|
pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
|
|
|
|
|
2005-08-10 15:45:14 +00:00
|
|
|
power_state[port] = to;
|
|
|
|
|
|
|
|
if (power_state[0] && power_state[1])
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPB4, 0);
|
|
|
|
else
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPB4, 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
|
|
|
usb_simtec_ocirq(int irq, void *pw, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
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");
|
2005-08-10 15:45:14 +00:00
|
|
|
s3c2410_usb_report_oc(info, 3);
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
pr_debug("usb_simtec: over-current irq (oc cleared)\n");
|
2005-08-10 15:45:14 +00:00
|
|
|
s3c2410_usb_report_oc(info, 0);
|
2005-04-16 22:20:36 +00: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 09:02:07 +00:00
|
|
|
ret = request_irq(IRQ_USBOC, usb_simtec_ocirq,
|
|
|
|
SA_INTERRUPT | SA_TRIGGER_RISING |
|
|
|
|
SA_TRIGGER_FALLING,
|
2005-04-16 22:20:36 +00:00
|
|
|
"USB Over-current", info);
|
|
|
|
if (ret != 0) {
|
|
|
|
printk(KERN_ERR "failed to request usb oc irq\n");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
free_irq(IRQ_USBOC, info);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct s3c2410_hcd_info usb_simtec_info = {
|
|
|
|
.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)
|
|
|
|
{
|
|
|
|
printk("USB Power Control, (c) 2004 Simtec Electronics\n");
|
|
|
|
s3c_device_usb.dev.platform_data = &usb_simtec_info;
|
|
|
|
|
|
|
|
s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
|
|
|
|
s3c2410_gpio_setpin(S3C2410_GPB4, 1);
|
|
|
|
return 0;
|
|
|
|
}
|