2005-04-17 06:20:36 +08:00
|
|
|
/* linux/arch/arm/mach-s3c2410/usb-simtec.c
|
|
|
|
*
|
2009-11-14 06:54:13 +08:00
|
|
|
* Copyright 2004-2005 Simtec Electronics
|
2005-04-17 06:20:36 +08: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-14 05:52:24 +08:00
|
|
|
#include <linux/gpio.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/device.h>
|
2008-09-06 19:10:45 +08:00
|
|
|
#include <linux/io.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#include <asm/mach/arch.h>
|
|
|
|
#include <asm/mach/map.h>
|
|
|
|
#include <asm/mach/irq.h>
|
|
|
|
|
2008-08-05 23:14:15 +08:00
|
|
|
#include <mach/hardware.h>
|
2014-01-14 21:24:24 +08:00
|
|
|
#include <mach/gpio-samsung.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/irq.h>
|
|
|
|
|
2012-08-24 21:22:12 +08:00
|
|
|
#include <linux/platform_data/usb-ohci-s3c2410.h>
|
2008-10-08 05:26:09 +08:00
|
|
|
#include <plat/devs.h>
|
2009-03-07 19:44:21 +08:00
|
|
|
|
2013-01-02 11:56:20 +08:00
|
|
|
#include "bast.h"
|
2012-03-07 17:47:11 +08:00
|
|
|
#include "simtec.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* control power and monitor over-current events on various Simtec
|
|
|
|
* designed boards.
|
|
|
|
*/
|
|
|
|
|
2005-08-10 23:45:14 +08:00
|
|
|
static unsigned int power_state[2];
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
static void
|
|
|
|
usb_simtec_powercontrol(int port, int to)
|
|
|
|
{
|
|
|
|
pr_debug("usb_simtec_powercontrol(%d,%d)\n", port, to);
|
|
|
|
|
2005-08-10 23:45:14 +08:00
|
|
|
power_state[port] = to;
|
|
|
|
|
|
|
|
if (power_state[0] && power_state[1])
|
2009-05-19 03:15:01 +08:00
|
|
|
gpio_set_value(S3C2410_GPB(4), 0);
|
2005-08-10 23:45:14 +08:00
|
|
|
else
|
2009-05-19 03:15:01 +08:00
|
|
|
gpio_set_value(S3C2410_GPB(4), 1);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
2006-10-07 01:53:39 +08:00
|
|
|
usb_simtec_ocirq(int irq, void *pw)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-26 17:40:22 +08:00
|
|
|
struct s3c2410_hcd_info *info = pw;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-05-19 03:15:01 +08:00
|
|
|
if (gpio_get_value(S3C2410_GPG(10)) == 0) {
|
2005-04-17 06:20:36 +08:00
|
|
|
pr_debug("usb_simtec: over-current irq (oc detected)\n");
|
2005-08-10 23:45:14 +08:00
|
|
|
s3c2410_usb_report_oc(info, 3);
|
2005-04-17 06:20:36 +08:00
|
|
|
} else {
|
|
|
|
pr_debug("usb_simtec: over-current irq (oc cleared)\n");
|
2005-08-10 23:45:14 +08:00
|
|
|
s3c2410_usb_report_oc(info, 0);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_simtec_enableoc(struct s3c2410_hcd_info *info, int on)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (on) {
|
2013-01-02 11:56:20 +08:00
|
|
|
ret = request_irq(BAST_IRQ_USBOC, usb_simtec_ocirq,
|
2013-12-12 06:05:19 +08:00
|
|
|
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
|
2005-04-17 06:20:36 +08:00
|
|
|
"USB Over-current", info);
|
|
|
|
if (ret != 0) {
|
|
|
|
printk(KERN_ERR "failed to request usb oc irq\n");
|
|
|
|
}
|
|
|
|
} else {
|
2013-01-02 11:56:20 +08:00
|
|
|
free_irq(BAST_IRQ_USBOC, info);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-13 13:59:46 +08:00
|
|
|
static struct s3c2410_hcd_info usb_simtec_info __initdata = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.port[0] = {
|
|
|
|
.flags = S3C_HCDFLG_USED
|
|
|
|
},
|
|
|
|
.port[1] = {
|
|
|
|
.flags = S3C_HCDFLG_USED
|
|
|
|
},
|
|
|
|
|
|
|
|
.power_control = usb_simtec_powercontrol,
|
|
|
|
.enable_oc = usb_simtec_enableoc,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
ARM: s3c24xx: fix multiple section mismatch warnings
The *_irq_add function should not be marked __init because the driver
subsystem thinks they might be called at a later stage.
The usb_simtec_init function accesses initdata and should be marked
init. This is safe because the only caller is also an init function.
Without this patch, building s3c2410_defconfig results in:
WARNING: arch/arm/mach-s3c24xx/built-in.o(.data+0x1030): Section mismatch in reference from the variable s3c2416_irq_interface to the function .init.text:s3c2416_irq_add()
The variable s3c2416_irq_interface references
the function __init s3c2416_irq_add()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
WARNING: arch/arm/mach-s3c24xx/built-in.o(.data+0x1b08): Section mismatch in reference from the variable s3c2443_irq_interface to the function .init.text:s3c2443_irq_add()
The variable s3c2443_irq_interface references
the function __init s3c2443_irq_add()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
WARNING: arch/arm/mach-s3c24xx/built-in.o(.data+0xf44): Section mismatch in reference from the variable s3c2416_irq_interface to the function .init.text:s3c2416_irq_add()
The variable s3c2416_irq_interface references
the function __init s3c2416_irq_add()
If the reference is valid then annotate the
variable with __init* or __refdata (see linux/init.h) or name the variable:
*_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console
WARNING: arch/arm/mach-s3c24xx/built-in.o(.text+0x3f7c): Section mismatch in reference from the function usb_simtec_init() to the (unknown reference) .init.data:(unknown)
The function usb_simtec_init() references
the (unknown reference) __initdata (unknown).
This is often because usb_simtec_init lacks a __initdata
annotation or the annotation of (unknown) is wrong.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>
2012-05-27 10:42:12 +08:00
|
|
|
int __init usb_simtec_init(void)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2009-05-19 03:15:01 +08:00
|
|
|
int ret;
|
|
|
|
|
2009-11-14 06:54:12 +08:00
|
|
|
printk("USB Power Control, Copyright 2004 Simtec Electronics\n");
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2009-05-19 03:15:01 +08: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 13:59:46 +08:00
|
|
|
s3c_ohci_set_platdata(&usb_simtec_info);
|
2005-04-17 06:20:36 +08:00
|
|
|
return 0;
|
|
|
|
}
|