SC60模块使用的是高通MSM8953套片,对应使用的电源芯片是PM8953和PMI632。
其中PM8953包括如下功能:
◆ Input power management
◆ Output power management
◆ General HK
◆ Audio
◆ IC interfaces
◆ Configurable pins:either multipurpose pins (MPPs) or general-purpose input/output (GPIOs)
而PMI632主要包括了如下功能:
◆ Switching charger
◆ Qualcomm battery gauge
◆ Type-C and Micro USB connectors support
◆ Quick Charge 2.0 and Quick Charge 3.0 support
◆ Battery current limiting (BCL) module
◆ General housekeeping
◆ Analog to digital converter (ADC)
◆ Battery interface module (BIM)
◆ Red, green, blue (RGB) LED drivers, PBS pattern generator(PPG)
◆ Vibrator driver
◆ Qualcomm® camera flash
◆ LCD bias
◆ HR-LED
◆ GPIOs that can be configured to function within some of the other categories
在不使用充电、FG 电量计、充电指示、闪光灯驱动、背光驱动、马达驱动、电池 ID 和电池温度检测的前提下,可以去掉PMI芯片的。
这里主要的修改就是USB。默认有PMI的模块,vbus脚是连接在PMI侧的,现在需要连接到PM8953的GPIO-7作为vbus插入检测,使用MSM8953的GPIO_1作为USB ID检测。参考图如下:
Usb3.0的主从设备检测是通过CC1和CC2控制USB_ID,再通过USB_ID输出,通知GPIO_1来实现:当插入device时,USB_ID会输出低电平,GPIO_1收到后,通知模块进入host模式;如不需要OTG功能,USB¬_ID脚可悬空。
驱动修改主要是增加extcon1节点了。
//stone added for usb-detect
&soc {
usb_detect {
compatible = "linux,extcon-usb-gpio";
vbus-gpio = <&pm8953_gpios 7 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
pinctrl-0 = <&usb2_vbus_det_default>;
};
};
&pm8953_gpios {
//shiyan added for usb-detect
gpio@c600 {
qcom,mode = <0>;
qcom,vin-sel = <3>; /*reference voltage 1.8v*/
qcom,src-sel = <0>;
qcom,pull = <5>; /*no pull. */
qcom,master-en = <1>;
status = "okay";
};
usb2_vbus_det {
usb2_vbus_det_default: usb2_vbus_det_default {
pins = "gpio7";
function = "normal";
input-enable;
bias-pull-down;
power-source = <1>; /* VPH input supply */
};
};
};
+//stone added for usb-detect 3
+&soc {
+ usb_detect: usb_detect {
+ compatible = "linux,extcon-usb-gpio";
+ vbus-gpio = <&pm8953_gpios 7 GPIO_ACTIVE_HIGH>;
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&usb2_vbus_det_default>;
+ };
+};
+
+&soc {
+ id_detect: id_detect {
+ compatible = "linux,extcon-usb-gpio";
+ id-gpio = <&tlmm 1 GPIO_ACTIVE_HIGH>;
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&id_gpio_detect>;
+ };
+};
+
+//stone added for usb-detect 4
+&usb3 {
+ extcon1 = <&usb_detect>, <&id_detect>;
+ //if we only need support MicroUSB
+ //qcom,connector-type-uAB;
+};
+
对应的驱动在
kernel/msm-4.9/drivers/extcon/extcon-usb-gpio.c
kernel/msm-4.9/drivers/extcon/extcon.c
kernel/msm-4.9/drivers/usb/dwc3/dwc3-msm.c这里使用新的extcon1,也需要修改:
+#ifdef CONFIG_EXTCON_USB_GPIO
+ if (of_property_read_bool(node, "extcon1"))
+ {
+ if (of_count_phandle_with_args(node, "extcon1", NULL) > start_idx + 1) {
+ edev = extcon_get_edev_by_phandle(mdwc->dev, start_idx + 1);
+ if (IS_ERR(edev) && PTR_ERR(edev) != -ENODEV) {
+ ret = PTR_ERR(edev);
+ goto err;
+ }
+ }
+ }
+
+ else
+ {
+ if (of_count_phandle_with_args(node, "extcon", NULL) > start_idx + 1) {
+ edev = extcon_get_edev_by_phandle(mdwc->dev, start_idx + 1);
+ if (IS_ERR(edev) && PTR_ERR(edev) != -ENODEV) {
+ ret = PTR_ERR(edev);
+ goto err;
+ }
+ }
+ }
+#else
if (of_count_phandle_with_args(node, "extcon", NULL) > start_idx + 1) {
edev = extcon_get_edev_by_phandle(mdwc->dev, start_idx + 1);
if (IS_ERR(edev) && PTR_ERR(edev) != -ENODEV) {
@@ -3090,6 +3117,7 @@ static int dwc3_msm_extcon_register(struct dwc3_msm *mdwc, int start_idx)
goto err;
}
}
+#endif
如上配置后使用extcon驱动,是可以正常检测到vbus插入中断的,usb2.0以及type-C的device和otg模式都是正常的。