Skip to contentSkip to conversation

arm: mach-imx: Move anatop related from board file to anatop driver

PATCH New Peter Chen 2 participants 8 messages Aug 12, 2013 – Aug 14, 2013

Subsystems (3)
lore
Share & tools
lore

Peter Chen

author
#0 lore raw

PATCH 1/2 arm: mach-imx: Move anatop related from board file to anatop driver

Move anatop related (For USB) from board file to anatop driver

---
 arch/arm/mach-imx/anatop.c     |    4 +++-
 arch/arm/mach-imx/common.h     |    1 -
 arch/arm/mach-imx/mach-imx6q.c |    5 -----
 3 files changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-imx/anatop.c +3 -1
index f7efabe..71f1a08 100644
@@ -115,7 +115,7 @@ void imx_anatop_post_resume(void)
 	imx_anatop_enable_weak2p5(false);
 }
 
-void imx_anatop_usb_chrg_detect_disable(void)
+static void imx_anatop_usb_chrg_detect_disable(void)
 {
 	regmap_write(anatop, ANADIG_USB1_CHRG_DETECT,
 		BM_ANADIG_USB_CHRG_DETECT_EN_B
@@ -157,4 +157,6 @@ void __init imx_anatop_init(void)
 	 */
 	imx_anatop_pu_enable(true);
 	imx_gpc_xpu_enable();
+
+	imx_anatop_usb_chrg_detect_disable();
 }
arch/arm/mach-imx/common.h +0 -1
index 558e95f..df1d7b0 100644
@@ -136,7 +136,6 @@ extern void imx_gpc_xpu_enable(void);
 extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
-extern void imx_anatop_usb_chrg_detect_disable(void);
 extern u32 imx_anatop_get_digprog(void);
 extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
 extern void imx6q_set_chicken_bit(void);
arch/arm/mach-imx/mach-imx6q.c +0 -5
index e04abe9..846731d 100644
@@ -185,10 +185,6 @@ static void __init imx6q_1588_init(void)
 		pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n");
 
 }
-static void __init imx6q_usb_init(void)
-{
-	imx_anatop_usb_chrg_detect_disable();
-}
 
 static void __init imx6q_init_machine(void)
 {
@@ -198,7 +194,6 @@ static void __init imx6q_init_machine(void)
 
 	imx_anatop_init();
 	imx6q_pm_init();
-	imx6q_usb_init();
 	imx6q_1588_init();
 }
 
Signature · 1 line
1.7.1
author
#1 lore raw

PATCH 2/2 arm: mach-imx: anatop: add two APIs for USB driver

imx_anatop_usb1_disconnect_line is used to disconnect dp/dm between PHY and controller, after that, the controller always gets SE0 for the status of dp/dm, it is not any wakeup signal for controller. It is used to avoid unknown interrupt due to dp/dm is floading after the USB PHY is no powered when there is no vbus supplied.

imx_anatop_set_stop_mode_config is used to keep internal regualtor on when the system enters suspend mode, it will increase power consumption, we only enable it when the user enables USB wakeup (default is off).

---
 arch/arm/mach-imx/anatop.c |   22 ++++++++++++++++++++++
 arch/arm/mach-imx/common.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/mach-imx/anatop.c +22 -0
index 71f1a08..7f96bbc 100644
@@ -26,6 +26,7 @@
 #define ANADIG_ANA_MISC0	0x150
 #define ANADIG_ANA_MISC2	0x170
 #define ANADIG_USB1_CHRG_DETECT	0x1b0
+#define ANADIG_USB1_LOOPBACK	0x1e0
 #define ANADIG_USB2_CHRG_DETECT	0x210
 #define ANADIG_DIGPROG		0x260
 
@@ -34,6 +35,8 @@
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG	0x1000
 #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B	0x80000
 #define BM_ANADIG_USB_CHRG_DETECT_EN_B		0x100000
+#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1	0x00000004
+#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN	0x00000020
 
 #define ANADIG_ANA_MISC2_REG1_STEP_OFFSET	26
 #define ANADIG_ANA_MISC2_REG_STEP_MASK		0x3
@@ -142,6 +145,25 @@ u32 imx_anatop_get_digprog(void)
 	return digprog;
 }
 
+void imx_anatop_usb1_disconnect_line(bool enable)
+{
+	if (enable)
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK,
+			BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+	else
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK, 0);
+}
+EXPORT_SYMBOL(imx_anatop_usb1_disconnect_line);
+
+void imx_anatop_set_stop_mode_config(bool enable)
+{
+	regmap_write(anatop, ANADIG_ANA_MISC0 +
+		(enable ? REG_SET : REG_CLR),
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+}
+EXPORT_SYMBOL(imx_anatop_set_stop_mode_config);
+
 void __init imx_anatop_init(void)
 {
 	anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop");
arch/arm/mach-imx/common.h +2 -0
index df1d7b0..dcb3305 100644
@@ -137,6 +137,8 @@ extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
 extern u32 imx_anatop_get_digprog(void);
+extern void imx_anatop_usb1_disconnect_line(bool);
+extern void imx_anatop_set_stop_mode_config(bool);
 extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
 extern void imx6q_set_chicken_bit(void);
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/2 arm: mach-imx: anatop: add two APIs for USB driver

Quoted 50 lines · Peter Chen

imx_anatop_usb1_disconnect_line is used to disconnect dp/dm between PHY and controller, after that, the controller always gets SE0 for the status of dp/dm, it is not any wakeup signal for controller. It is used to avoid unknown interrupt due to dp/dm is floading after the USB PHY is no powered when there is no vbus supplied.

imx_anatop_set_stop_mode_config is used to keep internal regualtor on when the system enters suspend mode, it will increase power consumption, we only enable it when the user enables USB wakeup (default is off).

---
 arch/arm/mach-imx/anatop.c |   22 ++++++++++++++++++++++
 arch/arm/mach-imx/common.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/mach-imx/anatop.c +12 -0
index 71f1a08..7f96bbc 100644
@@ -26,6 +26,7 @@
 #define ANADIG_ANA_MISC0	0x150
 #define ANADIG_ANA_MISC2	0x170
 #define ANADIG_USB1_CHRG_DETECT	0x1b0
+#define ANADIG_USB1_LOOPBACK	0x1e0
 #define ANADIG_USB2_CHRG_DETECT	0x210
 #define ANADIG_DIGPROG		0x260
 
@@ -34,6 +35,8 @@
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG	0x1000
 #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B	0x80000
 #define BM_ANADIG_USB_CHRG_DETECT_EN_B		0x100000
+#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1	0x00000004
+#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN	0x00000020
 
 #define ANADIG_ANA_MISC2_REG1_STEP_OFFSET	26
 #define ANADIG_ANA_MISC2_REG_STEP_MASK		0x3
@@ -142,6 +145,25 @@ u32 imx_anatop_get_digprog(void)
 	return digprog;
 }
 
+void imx_anatop_usb1_disconnect_line(bool enable)
+{
+	if (enable)
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK,
+			BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+	else
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK, 0);
+}

arch/arm/mach-imx/anatop.c u32 imx_anatop_get_digprog(void) · line 166

Quoted 10 lines
arch/arm/mach-imx/anatop.c +10 -0
+EXPORT_SYMBOL(imx_anatop_usb1_disconnect_line);
+
+void imx_anatop_set_stop_mode_config(bool enable)
+{
+	regmap_write(anatop, ANADIG_ANA_MISC0 +
+		(enable ? REG_SET : REG_CLR),
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+}
+EXPORT_SYMBOL(imx_anatop_set_stop_mode_config);
+

Where do you want to call these two functions from?

Shawn

Quoted 20 lines
arch/arm/mach-imx/anatop.c +0 -0
 void __init imx_anatop_init(void)
 {
 	anatop = syscon_regmap_lookup_by_compatible("fsl,imx6q-anatop");
arch/arm/mach-imx/common.h +2 -0
index df1d7b0..dcb3305 100644
@@ -137,6 +137,8 @@ extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
 extern u32 imx_anatop_get_digprog(void);
+extern void imx_anatop_usb1_disconnect_line(bool);
+extern void imx_anatop_set_stop_mode_config(bool);
 extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
 extern void imx6q_set_chicken_bit(void);
 
Signature · 1 line
1.7.1
author
#3 lore raw

PATCH 2/2 arm: mach-imx: anatop: add two APIs for USB driver

Quoted 66 lines · Shawn Guo
Quoted 50 lines · Peter Chen

imx_anatop_usb1_disconnect_line is used to disconnect dp/dm between PHY and controller, after that, the controller always gets SE0 for the status of dp/dm, it is not any wakeup signal for controller. It is used to avoid unknown interrupt due to dp/dm is floading after the USB PHY is no powered when there is no vbus supplied.

imx_anatop_set_stop_mode_config is used to keep internal regualtor on when the system enters suspend mode, it will increase power consumption, we only enable it when the user enables USB wakeup (default is off).

---
 arch/arm/mach-imx/anatop.c |   22 ++++++++++++++++++++++
 arch/arm/mach-imx/common.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/mach-imx/anatop.c +12 -0
index 71f1a08..7f96bbc 100644
@@ -26,6 +26,7 @@
 #define ANADIG_ANA_MISC0	0x150
 #define ANADIG_ANA_MISC2	0x170
 #define ANADIG_USB1_CHRG_DETECT	0x1b0
+#define ANADIG_USB1_LOOPBACK	0x1e0
 #define ANADIG_USB2_CHRG_DETECT	0x210
 #define ANADIG_DIGPROG		0x260
 
@@ -34,6 +35,8 @@
 #define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG	0x1000
 #define BM_ANADIG_USB_CHRG_DETECT_CHK_CHRG_B	0x80000
 #define BM_ANADIG_USB_CHRG_DETECT_EN_B		0x100000
+#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1	0x00000004
+#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN	0x00000020
 
 #define ANADIG_ANA_MISC2_REG1_STEP_OFFSET	26
 #define ANADIG_ANA_MISC2_REG_STEP_MASK		0x3
@@ -142,6 +145,25 @@ u32 imx_anatop_get_digprog(void)
 	return digprog;
 }
 
+void imx_anatop_usb1_disconnect_line(bool enable)
+{
+	if (enable)
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK,
+			BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+	else
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK, 0);
+}

arch/arm/mach-imx/anatop.c u32 imx_anatop_get_digprog(void) · line 166

Quoted 10 lines
arch/arm/mach-imx/anatop.c +10 -0
+EXPORT_SYMBOL(imx_anatop_usb1_disconnect_line);
+
+void imx_anatop_set_stop_mode_config(bool enable)
+{
+	regmap_write(anatop, ANADIG_ANA_MISC0 +
+		(enable ? REG_SET : REG_CLR),
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+}
+EXPORT_SYMBOL(imx_anatop_set_stop_mode_config);
+

Where do you want to call these two functions from?

From USB driver, the usb driver is possible built as module.

Signature · 2 lines
Best Regards,
Peter Chen
#4 lore raw

PATCH 2/2 arm: mach-imx: anatop: add two APIs for USB driver

Quoted 23 lines · Peter Chen
Quoted 13 lines
Quoted 13 lines
arch/arm/mach-imx/anatop.c +13 -0
+void imx_anatop_usb1_disconnect_line(bool enable)
+{
+	if (enable)
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK,
+			BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+	else
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK, 0);
+}
+EXPORT_SYMBOL(imx_anatop_usb1_disconnect_line);
+
+void imx_anatop_set_stop_mode_config(bool enable)
+{
Quoted 9 lines

arch/arm/mach-imx/anatop.c u32 imx_anatop_get_digprog(void) · line 166

Quoted 6 lines
arch/arm/mach-imx/anatop.c +6 -0
+	regmap_write(anatop, ANADIG_ANA_MISC0 +
+		(enable ? REG_SET : REG_CLR),
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+}
+EXPORT_SYMBOL(imx_anatop_set_stop_mode_config);
+

Where do you want to call these two functions from?

Quoted 1 line

From USB driver, the usb driver is possible built as module.

I do not think it's appropriate have device driver directly call into platform level functions.

Shawn

author
#5 lore raw

PATCH 2/2 arm: mach-imx: anatop: add two APIs for USB driver

Quoted 24 lines · Shawn Guo
Quoted 23 lines · Peter Chen
Quoted 22 lines
Quoted 9 lines
arch/arm/mach-imx/anatop.c +9 -0
+void imx_anatop_usb1_disconnect_line(bool enable)
+{
+	if (enable)
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK,
+			BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+	else
+		regmap_write(anatop, ANADIG_USB1_LOOPBACK, 0);
+}

arch/arm/mach-imx/anatop.c u32 imx_anatop_get_digprog(void) · line 166

Quoted 10 lines
arch/arm/mach-imx/anatop.c +10 -0
+EXPORT_SYMBOL(imx_anatop_usb1_disconnect_line);
+
+void imx_anatop_set_stop_mode_config(bool enable)
+{
+	regmap_write(anatop, ANADIG_ANA_MISC0 +
+		(enable ? REG_SET : REG_CLR),
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+}
+EXPORT_SYMBOL(imx_anatop_set_stop_mode_config);
+

Where do you want to call these two functions from?

Quoted 4 lines
Quoted 1 line

From USB driver, the usb driver is possible built as module.

I do not think it's appropriate have device driver directly call into platform level functions.

Will do it like thermal and regulator driver, please forget it.

Signature · 2 lines
Best Regards,
Peter Chen
#6 lore raw

PATCH 1/2 arm: mach-imx: Move anatop related from board file to anatop driver

In reply to Peter Chen

I change the subject prefix to "ARM: imx: ".

Quoted 23 lines · Peter Chen

Move anatop related (For USB) from board file to anatop driver

---
 arch/arm/mach-imx/anatop.c     |    4 +++-
 arch/arm/mach-imx/common.h     |    1 -
 arch/arm/mach-imx/mach-imx6q.c |    5 -----
 3 files changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-imx/anatop.c +1 -1
index f7efabe..71f1a08 100644
@@ -115,7 +115,7 @@ void imx_anatop_post_resume(void)
 	imx_anatop_enable_weak2p5(false);
 }
 
-void imx_anatop_usb_chrg_detect_disable(void)
+static void imx_anatop_usb_chrg_detect_disable(void)
 {
 	regmap_write(anatop, ANADIG_USB1_CHRG_DETECT,
 		BM_ANADIG_USB_CHRG_DETECT_EN_B

arch/arm/mach-imx/anatop.c void __init imx_anatop_init(void) · line 161

Quoted 5 lines
arch/arm/mach-imx/anatop.c +2 -0
@@ -157,4 +157,6 @@ void __init imx_anatop_init(void)
 	 */
 	imx_anatop_pu_enable(true);
 	imx_gpc_xpu_enable();
+
+	imx_anatop_usb_chrg_detect_disable();

The patch was generated from vendor tree. I fixed it up and applied the patch. Please do not do this next time.

Shawn

Quoted 40 lines
arch/arm/mach-imx/anatop.c +0 -0
 }
arch/arm/mach-imx/common.h +0 -1
index 558e95f..df1d7b0 100644
@@ -136,7 +136,6 @@ extern void imx_gpc_xpu_enable(void);
 extern void imx_anatop_init(void);
 extern void imx_anatop_pre_suspend(void);
 extern void imx_anatop_post_resume(void);
-extern void imx_anatop_usb_chrg_detect_disable(void);
 extern u32 imx_anatop_get_digprog(void);
 extern int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode);
 extern void imx6q_set_chicken_bit(void);
arch/arm/mach-imx/mach-imx6q.c +0 -5
index e04abe9..846731d 100644
@@ -185,10 +185,6 @@ static void __init imx6q_1588_init(void)
 		pr_err("failed to find fsl,imx6q-iomux-gpr regmap\n");
 
 }
-static void __init imx6q_usb_init(void)
-{
-	imx_anatop_usb_chrg_detect_disable();
-}
 
 static void __init imx6q_init_machine(void)
 {
@@ -198,7 +194,6 @@ static void __init imx6q_init_machine(void)
 
 	imx_anatop_init();
 	imx6q_pm_init();
-	imx6q_usb_init();
 	imx6q_1588_init();
 }
 
Signature · 1 line
1.7.1
author
#7 lore raw

PATCH 1/2 arm: mach-imx: Move anatop related from board file to anatop driver

Quoted 20 lines · Shawn Guo

I change the subject prefix to "ARM: imx: ".

Quoted 17 lines · Peter Chen

Move anatop related (For USB) from board file to anatop driver

---
 arch/arm/mach-imx/anatop.c     |    4 +++-
 arch/arm/mach-imx/common.h     |    1 -
 arch/arm/mach-imx/mach-imx6q.c |    5 -----
 3 files changed, 3 insertions(+), 7 deletions(-)
arch/arm/mach-imx/anatop.c +0 -0
index f7efabe..71f1a08 100644
@@ -115,7 +115,7 @@ void imx_anatop_post_resume(void)
 	imx_anatop_enable_weak2p5(false);
 }
 
Quoted 15 lines

arch/arm/mach-imx/anatop.c void __init imx_anatop_init(void) · line 161

Quoted 11 lines
arch/arm/mach-imx/anatop.c +3 -1
-void imx_anatop_usb_chrg_detect_disable(void)
+static void imx_anatop_usb_chrg_detect_disable(void)
 {
 	regmap_write(anatop, ANADIG_USB1_CHRG_DETECT,
 		BM_ANADIG_USB_CHRG_DETECT_EN_B
@@ -157,4 +157,6 @@ void __init imx_anatop_init(void)
 	 */
 	imx_anatop_pu_enable(true);
 	imx_gpc_xpu_enable();
+
+	imx_anatop_usb_chrg_detect_disable();

The patch was generated from vendor tree. I fixed it up and applied the patch. Please do not do this next time.

I see. Thanks.

Signature · 2 lines
Best Regards,
Peter Chen