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_RK29_VPU) += vpu.o vpu_mem.o
#ifndef __ASM_ARCH_RK29_BOARD_H
#define __ASM_ARCH_RK29_BOARD_H
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <linux/i2c.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/notifier.h>
-/* platform device data structures */
-struct platform_device;
-struct i2c_client;
-
/*spi*/
struct spi_cs_gpio {
const char *name;
#define BOOT_MODE_OFFMODE_CHARGING 5
int board_boot_mode(void);
+/* for USB detection */
+#ifdef CONFIG_USB_GADGET
+int board_usb_detect_init(unsigned gpio, unsigned long flags);
+#else
+static int inline board_usb_detect_init(unsigned, unsigned long) { return 0; }
+#endif
+
+/* for wakeup Android */
+void rk28_send_wakeup_key(void);
+
#endif
--- /dev/null
+#include <linux/wakelock.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/gpio.h>
+#include <mach/board.h>
+
+static void do_wakeup(struct work_struct *work)
+{
+ rk28_send_wakeup_key();
+}
+
+static DECLARE_DELAYED_WORK(wakeup_work, do_wakeup);
+static bool wakelock_inited;
+static struct wake_lock usb_wakelock;
+
+static irqreturn_t 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, unsigned long flags)
+{
+ int ret;
+ int irq = gpio_to_irq(gpio);
+
+ 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");
+
+ gpio_direction_input(gpio);
+ ret = request_irq(irq, detect_irq_handler, flags, "usb_detect", NULL);
+ if (ret < 0) {
+ pr_err("%s: request_irq(%d) failed\n", __func__, irq);
+ gpio_free(gpio);
+ return ret;
+ }
+ enable_irq_wake(irq);
+
+ return 0;
+}
+
struct rk29_button_data data[0];
};
+static struct input_dev *input_dev;
+
+void rk28_send_wakeup_key(void)
+{
+ if (!input_dev)
+ return;
+
+ input_report_key(input_dev, KEY_WAKEUP, 1);
+ input_sync(input_dev);
+ input_report_key(input_dev, KEY_WAKEUP, 0);
+ input_sync(input_dev);
+}
+
static void keys_long_press_timer(unsigned long _data)
{
int state;
input_set_capability(input, type, button->code);
}
+ input_set_capability(input, EV_KEY, KEY_WAKEUP);
+
error = input_register_device(input);
if (error) {
pr_err("gpio-keys: Unable to register input device, "
device_init_wakeup(&pdev->dev, wakeup);
error = device_create_file(&pdev->dev, &dev_attr_get_adc_value);
+
+ input_dev = input;
return error;
fail2:
struct input_dev *input = ddata->input;
int i;
+ input_dev = NULL;
device_init_wakeup(&pdev->dev, 0);
for (i = 0; i < pdata->nbuttons; i++) {