Merge "[Bugfix][R306_MTN][bug-view-1474][USB] use usb detect pin for R306_MTN, to fix out of skbuff after usb plugin/plugout"
diff --git a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-cpe-devices.c b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-cpe-devices.c
index 100935c..17d941d 100755
--- a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-cpe-devices.c
+++ b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/arch/arm/mach-zx297520v3/zx297520v3-cpe-devices.c
@@ -1265,6 +1265,13 @@
};
#endif
+
+#ifdef CONFIG_DWC_DEVICE_GPIO_CHARGER
+static struct platform_device zx29_usb_detect_device = {
+ .name = "usb_detect",
+ .id = 0,
+};
+#endif
/* --------------------------------------------------------------------
* ---------- for solution integration department --------- end
* -------------------------------------------------------------------- */
@@ -1288,6 +1295,9 @@
#ifdef CONFIG_DWC_OTG_USB
&zx29_usb0_device,
#endif
+#ifdef CONFIG_DWC_DEVICE_GPIO_CHARGER
+ &zx29_usb_detect_device,
+#endif
#ifdef CONFIG_USB_DWC_OTG_HCD
&zx29_usb1_device,
#endif
diff --git a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c
index d3cc060..6ad2dd1 100755
--- a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c
+++ b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/power/aw3215_charger.c
@@ -847,14 +847,14 @@
#ifdef _CHARGER_UNNOTIFY_USB_
if(get_adc1_voltage()>USB_ENUM_MIN)
#endif
- dwc_otg_chg_inform(0);/*usb in*/
+ //dwc_otg_chg_inform(0);/*usb in*/
}
else {
bdi->chgin_type = USB_OUT;
bdi->chg_state=POWER_SUPPLY_STATUS_DISCHARGING;
printk(KERN_INFO"init usb out\n");
chgin_irq_type = IRQ_TYPE_LEVEL_LOW;
- dwc_otg_chg_inform(0);/*usb out*/
+ //dwc_otg_chg_inform(0);/*usb out*/
}
bdi->chgin_irq= gpio_to_irq(pdata->gpio_chgin);
diff --git a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
old mode 100644
new mode 100755
index 6d887bf..b16d616
--- a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
+++ b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/dwc_otg/dwc_otg_chg_identify.c
@@ -181,7 +181,7 @@
int detected_charger(void)
{
#ifdef CONFIG_DWC_DEVICE_GPIO_CHARGER
- return 1;
+ return usb_plugin;
#endif
if(detect_fn == NULL)
return 1;
@@ -1043,10 +1043,10 @@
/*GPIOºÍÍⲿÖжϺŸù¾ÝÏîĿʵ¼ÊÇé¿öÐÞ¸Ä
*´Ë´¦Îª²Î¿¼´úÂë
*/
-#define USB_GPIO ZX29_GPIO_52
-#define USB_GPIO_FUNC_GPIO GPIO52_GPIO52
-#define USB_GPIO_FUNC_EXT_INT GPIO52_EXT_INT5
-#define USB_DT_INT PCU_EX5_INT
+#define USB_GPIO ZX29_GPIO_125
+#define USB_GPIO_FUNC_GPIO GPIO125_GPIO125
+#define USB_GPIO_FUNC_EXT_INT GPIO125_EXT_INT14
+#define USB_DT_INT PCU_EX14_INT
int Usb_Detect_Val(void)
{
@@ -1072,6 +1072,8 @@
int irq_num;
int retval;
int value;
+ int cnt=0;
+ int last_val = -1;
unsigned int gpio_enable = 0;
struct sched_param param = { .sched_priority = 2 };
param.sched_priority= 33;
@@ -1085,8 +1087,19 @@
//5.23
zx29_gpio_config(USB_GPIO,USB_GPIO_FUNC_GPIO);
gpio_direction_input(USB_GPIO);
- msleep(5);
- value = gpio_get_value(USB_GPIO);
+
+ while (cnt < 10)
+ {
+ msleep(10);
+ value = gpio_get_value(USB_GPIO);
+ if (last_val != value)
+ {
+ last_val = value;
+ cnt = 0;
+ }
+ else
+ cnt++;
+ }
printk("%s,value:%d\n", __func__,value);
zx29_gpio_config(USB_GPIO,USB_GPIO_FUNC_EXT_INT);
@@ -1094,19 +1107,19 @@
{
zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_FALLING);
pcu_int_clear(USB_DT_INT);
- if(usb_plugin == 1){
- dwc_otg_disconnect();
- dwc_otg_usb_chg_remove(); //not plug in;
- usb_plugin = 0;
- }
+ if(usb_plugin == 0){
+ dwc_otg_usb_chg_detect(); //plug in;
+ usb_plugin = 1;
+ }
}
else
{
zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_RISING);
- pcu_int_clear(USB_DT_INT);
- if(usb_plugin == 0){
- dwc_otg_usb_chg_detect(); //plug in;
- usb_plugin = 1;
+ pcu_int_clear(USB_DT_INT);
+ if(usb_plugin == 1){
+ dwc_otg_disconnect();
+ dwc_otg_usb_chg_remove(); //not plug in;
+ usb_plugin = 0;
}
}
printk(KERN_INFO"%s,value:%d,end\n", __func__,value);
@@ -1144,13 +1157,13 @@
#if 1
if(value == 1)
{
- usb_plugin = 0;
+ dwc_otg_usb_chg_detect(); //plug in;
+ usb_plugin = 1;
zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_FALLING);
}
else
{
- dwc_otg_usb_chg_detect(); //plug in;
- usb_plugin = 1;
+ usb_plugin = 0;
zx29_gpio_set_inttype(USB_GPIO,IRQ_TYPE_EDGE_RISING);
}
#endif
diff --git a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
index 649d5ec..52683a3 100755
--- a/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
+++ b/lynq/R306_MTN/ap/os/linux/linux-3.4.x/drivers/usb/gadget/usb_netlink.c
@@ -35,7 +35,7 @@
unsigned int force_net = 0;
unsigned int set_panic = 0;
//for auto test,mdl dev with gpio detect usb plug in/out
-unsigned int usb_gpio_detect_enable = 0;
+unsigned int usb_gpio_detect_enable = 1;
//add by gsn, to avoid usb in vincPkt_list backlogged many Skb, set a limit
unsigned int rndis_vplist_max = 800;
diff --git a/lynq/R306_MTN/ap/project/zx297520v3/prj_cpe/config/normal/config.linux b/lynq/R306_MTN/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
index c138a41..5a60617 100755
--- a/lynq/R306_MTN/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
+++ b/lynq/R306_MTN/ap/project/zx297520v3/prj_cpe/config/normal/config.linux
@@ -1479,6 +1479,7 @@
# CONFIG_USB_OTG_BLACKLIST_HUB is not set
CONFIG_DWC_OTG_USB=y
CONFIG_DWC_DEVICE_ONLY=y
+CONFIG_DWC_DEVICE_GPIO_CHARGER=y
#
# NOTE: USB_STORAGE depends on SCSI but BLK_DEV_SD may