usb眼圖測試

Question:How to change QUSB(HS USB) PHY tune registers dynamically?
Answer:
For platforms using QUSB(HS USB) PHY, we have USB tune register setting in platform dtsi
like below.
//arch/arm/boot/dts/qcom/**.dtsi
qusb_phy0: qusb@7411000 {
compatible = "qcom,qusb2phy";
......
qcom,qusb-phy-init-seq = <0xF8 0x80
0xB3 0x84
0x83 0x88
0xC0 0x8C
0x30 0x08
0x79 0x0C
0x21 0x10
0x14 0x9C
0x9F 0x1C
0x00 0x18>;
But when we tuning device eye diagram, we hope to have oppertunities to change USB tune
register settings with out reset phone or reflash images.
By default the setting the setting can override tune2 is in:
/sys/module/phy_msm_qusb/parameters/tune2
We can add below change in phy-msm-qusb.c to add tune1/tune3/tune4/tune5 override setting.
#define QUSB2PHY_PORT_TUNE1 0x80
#define QUSB2PHY_PORT_TUNE2 0x84
#define QUSB2PHY_PORT_TUNE3 0x88
#define QUSB2PHY_PORT_TUNE4 0x8C
+#define QUSB2PHY_PORT_TUNE5 0x90
......
unsigned int tune2;
+unsigned int tune1;
+unsigned int tune3;
+unsigned int tune4;
+unsigned int tune5;
module_param(tune2, uint, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(tune2, "QUSB PHY TUNE2");
+module_param(tune1, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(tune1, "QUSB PHY TUNE1");
+module_param(tune3, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(tune3, "QUSB PHY TUNE3");+module_param(tune4, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(tune4, "QUSB PHY TUNE4");
+module_param(tune5, uint, S_IRUGO | S_IWUSR);
+MODULE_PARM_DESC(tune5, "QUSB PHY TUNE5");
......
/* If tune2 modparam set, override tune2 value */
if (tune2) {
pr_debug("%s(): (modparam) TUNE2 val:0x%02x\n",
__func__, tune2);
writel_relaxed(tune2,
qphy->base + QUSB2PHY_PORT_TUNE2);
}
+ /* If tune1 modparam set, override tune1 value */
+ if (tune1) {
+ pr_debug("%s(): (modparam) TUNE1 val:0x%02x\n",
+ __func__, tune1);
+ writel_relaxed(tune1,
+ qphy->base + QUSB2PHY_PORT_TUNE1);
+ }
+ /* If tune3 modparam set, override tune3 value */
+ if (tune3) {
+ pr_debug("%s(): (modparam) TUNE3 val:0x%02x\n",
+ __func__, tune3);
+ writel_relaxed(tune3,
+ qphy->base + QUSB2PHY_PORT_TUNE3);
+ }
+ /* If tune2 modparam set, override tune2 value */
+ if (tune4) {
+ pr_debug("%s(): (modparam) TUNE4 val:0x%02x\n",
+ __func__, tune4);
+ writel_relaxed(tune4,
+ qphy->base + QUSB2PHY_PORT_TUNE4);
+ }
+ /* If tune2 modparam set, override tune2 value */
+ if (tune5) {
+ pr_debug("%s(): (modparam) TUNE5 val:0x%02x\n",
+ __func__, tune5);
+ writel_relaxed(tune5,
+ qphy->base + QUSB2PHY_PORT_TUNE5);
+ }
+ pr_err("tune1 0x%x, 2 0x%x, 3 0x%x, 4 0x%x, 5 0x%x",readl_relaxed(qphy->base +
QUSB2PHY_PORT_TUNE1),+ readl_relaxed(qphy->base + QUSB2PHY_PORT_TUNE2),
+ readl_relaxed(qphy->base + QUSB2PHY_PORT_TUNE3),
+ readl_relaxed(qphy->base + QUSB2PHY_PORT_TUNE4),
+ readl_relaxed(qphy->base + QUSB2PHY_PORT_TUNE5));
Sample operation to change tune parameters by adb shell:
adb shell
su
cd /sys/module/phy_msm_qusb/parameters
echo 0x84 > tune2
cat tune2
132
Please note it will no take effect anymore if phone reset, the change will not save only if we change
platform dtsi.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章