USB: msm_otg: Add HTC variant of msm_otg

HTC kernel version: villeu-jb-crc-3.4.10-ae8b65e

Change-Id: I1058d5704ceba3e723ffc7a20f13bff6909e643b
diff --git a/include/linux/usb/htc_info.h b/include/linux/usb/htc_info.h
new file mode 100644
index 0000000..5646aa6
--- /dev/null
+++ b/include/linux/usb/htc_info.h
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2011 HTC, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#ifndef __HTC_INFO__
+#define __HTC_INFO__
+
+#include <mach/board.h>
+struct usb_info {
+	int *phy_init_seq;
+	void (*phy_reset)(void);
+	void (*hw_reset)(bool en);
+	void (*usb_uart_switch)(int);
+	void (*serial_debug_gpios)(int);
+	void (*usb_hub_enable)(bool);
+	int (*china_ac_detect)(void);
+	void (*disable_usb_charger)(void);
+	void (*change_phy_voltage)(int);
+	int (*ldo_init) (int init);
+	int (*ldo_enable) (int enable);
+	void (*usb_mhl_switch)(bool);
+
+	
+	int connect_type_ready;
+	void (*usb_connected)(int);
+
+	enum usb_connect_type connect_type;
+	struct delayed_work chg_stop;
+};
+
+extern ssize_t otg_show_usb_phy_setting(char *buf);
+extern ssize_t otg_store_usb_phy_setting(const char *buf, size_t count);
+
+extern int usb_get_connect_type(void);
+extern int android_switch_function(unsigned func);
+extern int android_show_function(char *buf);
+extern void android_set_serialno(char *serialno);
+extern void android_force_reset(void);
+extern int htc_usb_enable_function(char *name, int ebl);
+
+extern void htc_mode_enable(int enable);
+extern int check_htc_mode_status(void);
+extern void android_switch_default(void);
+extern void android_switch_htc_mode(void);
+
+#ifdef err
+#undef err
+#endif
+#ifdef warn
+#undef warn
+#endif
+#ifdef info
+#undef info
+#endif
+
+#define USB_ERR(fmt, args...) \
+	printk(KERN_ERR "[USB:ERR] " fmt, ## args)
+#define USB_WARNING(fmt, args...) \
+	printk(KERN_WARNING "[USB] " fmt, ## args)
+#define USB_INFO(fmt, args...) \
+	printk(KERN_INFO "[USB] " fmt, ## args)
+#define USB_DEBUG(fmt, args...) \
+	printk(KERN_DEBUG "[USB] " fmt, ## args)
+
+#define USBH_ERR(fmt, args...) \
+	printk(KERN_ERR "[USBH:ERR] " fmt, ## args)
+#define USBH_WARNING(fmt, args...) \
+	printk(KERN_WARNING "[USBH] " fmt, ## args)
+#define USBH_INFO(fmt, args...) \
+	printk(KERN_INFO "[USBH] " fmt, ## args)
+#define USBH_DEBUG(fmt, args...) \
+	printk(KERN_DEBUG "[USBH] " fmt, ## args)
+
+#ifdef dev_err
+#undef dev_err
+#endif
+#define dev_err(dev, fmt, args...) \
+	printk(KERN_ERR "[USB] " pr_fmt(fmt), ## args)
+
+#ifdef dev_dbg
+#undef dev_dbg
+#endif
+#define dev_dbg(dev, fmt, args...) \
+	printk(KERN_INFO "[USB] " pr_fmt(fmt), ## args)
+
+#ifdef dev_info
+#undef dev_info
+#endif
+#define dev_info(dev, fmt, args...) \
+	printk(KERN_INFO "[USB] " pr_fmt(fmt), ## args)
+
+#ifdef pr_debug
+#undef pr_debug
+#endif
+#define pr_debug(fmt, args...) \
+	printk(KERN_INFO "[USB] " pr_fmt(fmt), ## args)
+
+#ifdef pr_err
+#undef pr_err
+#endif
+#define pr_err(fmt, args...) \
+	printk(KERN_ERR "[USB] " pr_fmt(fmt), ## args)
+
+#ifdef pr_info
+#undef pr_info
+#endif
+#define pr_info(fmt, args...) \
+	printk(KERN_INFO "[USB] " pr_fmt(fmt), ## args)
+
+#endif 
+
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 61c9460..aaf0a05 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -23,6 +23,9 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
 #include <linux/wakelock.h>
+#ifdef CONFIG_MACH_HTC
+#include <mach/board.h>
+#endif
 #include <linux/pm_qos.h>
 #include <linux/hrtimer.h>
 
@@ -174,6 +177,9 @@
 	VDD_VAL_MAX,
 };
 
+#define POWER_COLLAPSE_LDO3V3	(1 << 0) /* Regulator L3 */
+#define POWER_COLLAPSE_LDO1V8	(1 << 1) /* Regulator L4 */
+
 /**
  * struct msm_otg_platform_data - platform device data
  *              for msm_otg driver.
@@ -213,10 +219,19 @@
 	unsigned int mpm_otgsessvld_int;
 	bool mhl_enable;
 	bool disable_reset_on_disconnect;
+#ifdef CONFIG_MACH_HTC
+        bool enable_dcd;
+#endif
 	bool enable_lpm_on_dev_suspend;
 	bool core_clk_always_on_workaround;
 	struct msm_bus_scale_pdata *bus_scale_table;
+#ifdef CONFIG_MACH_HTC
+	int reset_phy_before_lpm;
+	void (*usb_uart_switch)(int uart);
+	int ldo_power_collapse;
+#else
 	const char *mhl_dev_name;
+#endif
 };
 
 /* Timeout (in msec) values (min - max) associated with OTG timers */
@@ -295,7 +310,9 @@
 	struct usb_phy phy;
 	struct msm_otg_platform_data *pdata;
 	int irq;
+#ifndef CONFIG_MACH_HTC
 	int async_irq;
+#endif
 	struct clk *clk;
 	struct clk *pclk;
 	struct clk *phy_reset_clk;
@@ -318,7 +335,9 @@
 #define A_BUS_SUSPEND	14
 #define A_CONN		15
 #define B_BUS_REQ	16
+#ifndef CONFIG_MACH_HTC
 #define MHL	        17
+#endif
 	unsigned long inputs;
 	struct work_struct sm_work;
 	bool sm_work_pending;
@@ -328,18 +347,26 @@
 	unsigned cur_power;
 	struct delayed_work chg_work;
 	struct delayed_work pmic_id_status_work;
+#ifndef CONFIG_MACH_HTC
 	struct delayed_work check_ta_work;
+#endif
 	enum usb_chg_state chg_state;
 	enum usb_chg_type chg_type;
 	unsigned dcd_time;
 	struct wake_lock wlock;
+#ifdef CONFIG_MACH_HTC
+	struct wake_lock usb_otg_wlock;
+	struct wake_lock cable_detect_wlock;
+#endif
 	struct notifier_block usbdev_nb;
 	unsigned mA_port;
 	struct timer_list id_timer;
 	unsigned long caps;
 	struct msm_xo_voter *xo_handle;
 	uint32_t bus_perf_client;
+#ifndef CONFIG_MACH_HTC
 	bool mhl_enabled;
+#endif
 	/*
 	 * Allowing PHY power collpase turns off the HSUSB 3.3v and 1.8v
 	 * analog regulators while going to low power mode.
@@ -362,7 +389,18 @@
 #define PHY_PWR_COLLAPSED		BIT(0)
 #define PHY_RETENTIONED			BIT(1)
 #define XO_SHUTDOWN			BIT(2)
+#ifndef CONFIG_MACH_HTC
 #define CLOCKS_DOWN			BIT(3)
+#endif
+#ifdef CONFIG_MACH_HTC
+	struct work_struct notifier_work;
+	enum usb_connect_type connect_type;
+	int connect_type_ready;
+	struct workqueue_struct *usb_wq;
+	struct delayed_work ac_detect_work;
+	int ac_detect_count;
+	int reset_phy_before_lpm;
+#endif
 	int reset_counter;
 	unsigned long b_last_se0_sess;
 	unsigned long tmouts;
diff --git a/include/linux/usb/otg.h b/include/linux/usb/otg.h
index ae3ffe4..a584d24 100644
--- a/include/linux/usb/otg.h
+++ b/include/linux/usb/otg.h
@@ -61,6 +61,12 @@
 	 * within TB_SRP_FAIL time.
 	 */
 	OTG_EVENT_NO_RESP_FOR_SRP,
+#ifdef CONFIG_MACH_HTC
+	/* broadcast uevent when device vbus ouput is
+	    lower than the repuirement of otg device.
+	*/
+	OTG_EVENT_INSUFFICIENT_POWER,
+#endif
 };
 
 enum usb_phy_events {
@@ -149,6 +155,13 @@
 	int	(*set_suspend)(struct usb_phy *x,
 				int suspend);
 
+#ifdef CONFIG_MACH_HTC
+	/* send events to user space */
+	int	(*send_event)(struct usb_phy *phy,
+			enum usb_otg_event event);
+
+	void	(*notify_usb_attached)(void);
+#endif
 };