rk: move usb_detect.c from mach-rk29 to plat-rk
author黄涛 <huangtao@rock-chips.com>
Wed, 1 Feb 2012 11:41:34 +0000 (19:41 +0800)
committer黄涛 <huangtao@rock-chips.com>
Wed, 1 Feb 2012 11:41:34 +0000 (19:41 +0800)
arch/arm/mach-rk29/Makefile
arch/arm/mach-rk29/usb_detect.c [deleted file]
arch/arm/plat-rk/Makefile
arch/arm/plat-rk/usb_detect.c [new file with mode: 0644]

index 65898f2e3bcd01b04dffe49ef34640799113dc1b..088080d559475f2c495b33e469fd914dd01e6c4a 100644 (file)
@@ -4,7 +4,6 @@ obj-y += early_printk.o
 ifndef CONFIG_DEBUG_LL
 obj-y += ../kernel/debug.o
 endif
-obj-$(CONFIG_USB_GADGET) += usb_detect.o
 obj-$(CONFIG_PM) += pm.o
 obj-$(CONFIG_CPU_FREQ) += cpufreq.o
 obj-$(CONFIG_DDR_FREQ) += ddrfreq.o
diff --git a/arch/arm/mach-rk29/usb_detect.c b/arch/arm/mach-rk29/usb_detect.c
deleted file mode 100644 (file)
index a71a60c..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <linux/wakelock.h>
-#include <linux/workqueue.h>
-#include <linux/interrupt.h>
-#include <linux/gpio.h>
-#include <mach/board.h>
-
-static irqreturn_t usb_detect_irq_handler(int irq, void *dev_id);
-static int detect_gpio = INVALID_GPIO;
-
-static void usb_detect_do_wakeup(struct work_struct *work)
-{
-       int ret;
-       int irq = gpio_to_irq(detect_gpio);
-       unsigned long flags;
-
-       rk28_send_wakeup_key();
-       free_irq(irq, NULL);
-       flags = gpio_get_value(detect_gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
-       ret = request_irq(irq, usb_detect_irq_handler, flags, "usb_detect", NULL);
-       if (ret < 0) {
-               pr_err("%s: request_irq(%d) failed\n", __func__, irq);
-       }
-}
-
-static DECLARE_DELAYED_WORK(wakeup_work, usb_detect_do_wakeup);
-static bool wakelock_inited;
-static struct wake_lock usb_wakelock;
-
-static irqreturn_t usb_detect_irq_handler(int irq, void *dev_id)
-{
-       wake_lock_timeout(&usb_wakelock, 10 * HZ);
-       schedule_delayed_work(&wakeup_work, HZ / 10);
-       return IRQ_HANDLED;
-}
-
-int board_usb_detect_init(unsigned gpio)
-{
-       int ret;
-       int irq = gpio_to_irq(gpio);
-       unsigned long flags;
-
-       if (detect_gpio != INVALID_GPIO) {
-               pr_err("only support call %s once\n", __func__);
-               return -EINVAL;
-       }
-
-       ret = gpio_request(gpio, "usb_detect");
-       if (ret < 0) {
-               pr_err("%s: gpio_request(%d) failed\n", __func__, gpio);
-               return ret;
-       }
-
-       if (!wakelock_inited) {
-               wake_lock_init(&usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect");
-               wakelock_inited = true;
-       }
-
-       gpio_direction_input(gpio);
-
-       detect_gpio = gpio;
-
-       flags = gpio_get_value(gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
-       ret = request_irq(irq, usb_detect_irq_handler, flags, "usb_detect", NULL);
-       if (ret < 0) {
-               pr_err("%s: request_irq(%d) failed\n", __func__, irq);
-               gpio_free(gpio);
-               detect_gpio = INVALID_GPIO;
-               return ret;
-       }
-       enable_irq_wake(irq);
-
-       return 0;
-}
-
index fd1f267c0c891e7be5e36aad6fc7cbe0e3775f57..4df221a38c8eb0f3aabeb80e77cc8fe93829f8df 100644 (file)
@@ -1 +1,2 @@
 obj-$(CONFIG_RK29_LAST_LOG) += last_log.o
+obj-$(CONFIG_USB_GADGET) += usb_detect.o
diff --git a/arch/arm/plat-rk/usb_detect.c b/arch/arm/plat-rk/usb_detect.c
new file mode 100644 (file)
index 0000000..a71a60c
--- /dev/null
@@ -0,0 +1,74 @@
+#include <linux/wakelock.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/gpio.h>
+#include <mach/board.h>
+
+static irqreturn_t usb_detect_irq_handler(int irq, void *dev_id);
+static int detect_gpio = INVALID_GPIO;
+
+static void usb_detect_do_wakeup(struct work_struct *work)
+{
+       int ret;
+       int irq = gpio_to_irq(detect_gpio);
+       unsigned long flags;
+
+       rk28_send_wakeup_key();
+       free_irq(irq, NULL);
+       flags = gpio_get_value(detect_gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
+       ret = request_irq(irq, usb_detect_irq_handler, flags, "usb_detect", NULL);
+       if (ret < 0) {
+               pr_err("%s: request_irq(%d) failed\n", __func__, irq);
+       }
+}
+
+static DECLARE_DELAYED_WORK(wakeup_work, usb_detect_do_wakeup);
+static bool wakelock_inited;
+static struct wake_lock usb_wakelock;
+
+static irqreturn_t usb_detect_irq_handler(int irq, void *dev_id)
+{
+       wake_lock_timeout(&usb_wakelock, 10 * HZ);
+       schedule_delayed_work(&wakeup_work, HZ / 10);
+       return IRQ_HANDLED;
+}
+
+int board_usb_detect_init(unsigned gpio)
+{
+       int ret;
+       int irq = gpio_to_irq(gpio);
+       unsigned long flags;
+
+       if (detect_gpio != INVALID_GPIO) {
+               pr_err("only support call %s once\n", __func__);
+               return -EINVAL;
+       }
+
+       ret = gpio_request(gpio, "usb_detect");
+       if (ret < 0) {
+               pr_err("%s: gpio_request(%d) failed\n", __func__, gpio);
+               return ret;
+       }
+
+       if (!wakelock_inited) {
+               wake_lock_init(&usb_wakelock, WAKE_LOCK_SUSPEND, "usb_detect");
+               wakelock_inited = true;
+       }
+
+       gpio_direction_input(gpio);
+
+       detect_gpio = gpio;
+
+       flags = gpio_get_value(gpio) ? IRQF_TRIGGER_FALLING : IRQF_TRIGGER_RISING;
+       ret = request_irq(irq, usb_detect_irq_handler, flags, "usb_detect", NULL);
+       if (ret < 0) {
+               pr_err("%s: request_irq(%d) failed\n", __func__, irq);
+               gpio_free(gpio);
+               detect_gpio = INVALID_GPIO;
+               return ret;
+       }
+       enable_irq_wake(irq);
+
+       return 0;
+}
+