Skip to contentSkip to conversation

driver:usb:s3c_udc: add support for Exynos4x12

PATCH Superseded Piotr Wilczek 4 participants 16 messages Nov 6, 2013 – Dec 2, 2013 USB

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 driver:usb:s3c_udc: add support for Exynos4x12

This patch add new defines for usb phy for Exynos4x12.

---
Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |   10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/gadget/regs-otg.h +5 -0
index 84bfcc5..ac5d112 100644
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +8 -2
index 7e20209..cecd280 100644
@@ -36,6 +36,7 @@
 #include "regs-otg.h"
 #include <usb/lin_gadget_compat.h>
 
+
 /***********************************************************/
 
 #define OTG_DMA_MODE		1
@@ -167,8 +168,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 2/2 trats2: enable ums support on Trats2

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
This patch depends on the lated u-boot-usb/master.

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
board/samsung/trats2/trats2.c +92 -0
index d44d825..41a7310 100644
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on)
+{
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data);
+}
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	int cable_connected = muic->chrg->chrg_type(muic);
+
+	return !!cable_connected;
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC");
include/configs/trats2.h +18 -0
index 0e93836..66b1c95 100644
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 2/2 trats2: enable ums support on Trats2

Quoted 170 lines · Piotr Wilczek

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
This patch depends on the lated u-boot-usb/master.

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
board/samsung/trats2/trats2.c +92 -0
index d44d825..41a7310 100644
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on)
+{
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data);
+}
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	int cable_connected = muic->chrg->chrg_type(muic);
+
+	return !!cable_connected;
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC");
include/configs/trats2.h +18 -0
index 0e93836..66b1c95 100644
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 
#3 lore raw

PATCH v2 1/2 driver:usb:s3c_udc: add support for Exynos4x12

In reply to Piotr Wilczek

Dear Piotr.

Quoted 34 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---
Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |   10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
drivers/usb/gadget/regs-otg.h +5 -0
index 84bfcc5..ac5d112 100644
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +0 -0
index 7e20209..cecd280 100644

drivers/usb/gadget/s3c_udc_otg.c line 39

Quoted 4 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -0
@@ -36,6 +36,7 @@
 #include "regs-otg.h"
 #include <usb/lin_gadget_compat.h>
 
+

remove white-space.

Quoted 20 lines
drivers/usb/gadget/s3c_udc_otg.c +7 -2
 /***********************************************************/
 
 #define OTG_DMA_MODE		1
@@ -167,8 +168,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);
#4 lore raw

PATCH v2 1/2 driver:usb:s3c_udc: add support for Exynos4x12

Dear Jaehoon,

Quoted 49 lines

-----Original Message-----
From: Jaehoon Chung [mailto:jh80.chung at samsung.com]
Sent: Thursday, November 07, 2013 5:49 AM
To: Piotr Wilczek; u-boot at lists.denx.de
Cc: Kyungmin Park
Subject: Re: [U-Boot] [PATCH V2 1/2] driver:usb:s3c_udc: add support for Exynos4x12

Dear Piotr.

Quoted 38 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---
Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |   10 ++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/usb/gadget/regs-otg.h index 84bfcc5..ac5d112 100644

drivers/usb/gadget/regs-otg.h +5 -0
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +0 -0
index 7e20209..cecd280 100644
@@ -36,6 +36,7 @@
 #include "regs-otg.h"
 #include <usb/lin_gadget_compat.h>
 
Quoted 2 lines

drivers/usb/gadget/s3c_udc_otg.c line 39

Quoted 1 line
drivers/usb/gadget/s3c_udc_otg.c +1 -0
+

remove white-space.

I will, thanks for review.

Quoted 7 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 168

Quoted 6 lines
drivers/usb/gadget/s3c_udc_otg.c +0 -0
 /***********************************************************/
 
 #define OTG_DMA_MODE		1
@@ -167,8 +168,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 |

ANALOG_PWRDOWN)

Quoted 7 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev)

Quoted 7 lines
drivers/usb/gadget/s3c_udc_otg.c +3 -2
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) |

EXYNOS4X12_CLK_SEL_24MHZ,

Quoted 9 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev)

Quoted 3 lines
drivers/usb/gadget/s3c_udc_otg.c +3 -0
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0))

|

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 180

Quoted 5 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -0
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);

Best regards,
Piotr Wilczek

#5 lore raw

PATCH v3 1/2 driver:usb:s3c_udc: add support for Exynos4x12

In reply to Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---

Chnages for v3:
- removed unnecessary empty line

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/usb/gadget/regs-otg.h +5 -0
index 84bfcc5..ac5d112 100644
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +7 -2
index 7e20209..ba17a04 100644
@@ -167,8 +167,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v3 2/2 trats2: enable ums support on Trats2

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
This patch depends on the lated u-boot-usb/master.

Changes for v3:
- no changes

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
board/samsung/trats2/trats2.c +92 -0
index d44d825..41a7310 100644
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on)
+{
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data);
+}
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	int cable_connected = muic->chrg->chrg_type(muic);
+
+	return !!cable_connected;
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC");
include/configs/trats2.h +18 -0
index 0e93836..66b1c95 100644
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH v3 2/2 trats2: enable ums support on Trats2

Dear Piotr Wilczek,

Quoted 89 lines · Piotr Wilczek

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
This patch depends on the lated u-boot-usb/master.

Changes for v3:
- no changes

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
board/samsung/trats2/trats2.c +53 -0
index d44d825..41a7310 100644
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on)
+{
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 373

Quoted 10 lines
board/samsung/trats2/trats2.c +10 -0
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+

please remove blank line.

Quoted 13 lines
board/samsung/trats2/trats2.c +13 -0
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init)

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 396

Quoted 10 lines
board/samsung/trats2/trats2.c +10 -0
+{
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data);
+}
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	int cable_connected = muic->chrg->chrg_type(muic);

Please check that muic is available.

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 398

Quoted 2 lines
board/samsung/trats2/trats2.c +2 -0
+
+	return !!cable_connected;

I think, cable_connected is unnecessary.

return !!muic->chrg->chrg_type(muic);

Quoted 42 lines
board/samsung/trats2/trats2.c +4 -0
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC");
include/configs/trats2.h +15 -0
index 0e93836..66b1c95 100644
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB

include/configs/trats2.h line 328

Quoted 9 lines
include/configs/trats2.h +3 -0
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 

Thanks,
Minkyu Kang.

#8 lore raw

PATCH v3 2/2 trats2: enable ums support on Trats2

Dear Minkyu Kang,

Quoted 104 lines

-----Original Message-----
From: Minkyu Kang [mailto:mk7.kang at samsung.com]
Sent: Thursday, November 21, 2013 9:24 AM
To: Piotr Wilczek
Cc: u-boot at lists.denx.de; Kyungmin Park
Subject: Re: [PATCH V3 2/2] trats2: enable ums support on Trats2

Dear Piotr Wilczek,

Quoted 1 line · Piotr Wilczek

This patch adds support for USB and enables 'ums' command on Trats2

board.

Quoted 9 lines

---
This patch depends on the lated u-boot-usb/master.

Quoted 8 lines

Changes for v3:
- no changes

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92

+++++++++++++++++++++++++++++++++++++++++

Quoted 74 lines
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
(quoted diff) +0 -0

b/board/samsung/trats2/trats2.c index d44d825..41a7310 100644

board/samsung/trats2/trats2.c +56 -0
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on) {
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
Quoted 8 lines

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 373

Quoted 6 lines
board/samsung/trats2/trats2.c +6 -0
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+

please remove blank line.

Ok

Quoted 16 lines
Quoted 16 lines
board/samsung/trats2/trats2.c +15 -0
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init) {
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data); }
Quoted 8 lines

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 396

Quoted 6 lines
board/samsung/trats2/trats2.c +6 -0
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	int cable_connected = muic->chrg->chrg_type(muic);

Please check that muic is available.

Ok

Quoted 8 lines

board/samsung/trats2/trats2.c int board_mmc_init(bd_t *bis) · line 395

Quoted 3 lines
board/samsung/trats2/trats2.c +2 -0
+
+	return !!cable_connected;

I think, cable_connected is unnecessary.

return !!muic->chrg->chrg_type(muic);

Ok

Quoted 43 lines
Quoted 43 lines
board/samsung/trats2/trats2.c +4 -0
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC"); diff --git

a/include/configs/trats2.h b/include/configs/trats2.h index 0e93836..66b1c95 100644

include/configs/trats2.h +14 -0
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */ #define
+CONFIG_USBDOWNLOAD_GADGET #define CONFIG_DFU_FUNCTION #define
+CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8 #define
+CONFIG_G_DNL_PRODUCT_NUM 0x6601 #define CONFIG_G_DNL_MANUFACTURER
+"Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG #define
+CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
Quoted 10 lines

include/configs/trats2.h line 328

Quoted 7 lines
include/configs/trats2.h +3 -0
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 

Thanks,
Minkyu Kang.

Best regards,
Piotr Wilczek

#9 lore raw

PATCH v3 1/2 driver:usb:s3c_udc: add support for Exynos4x12

In reply to Piotr Wilczek

Dear Piotr,

Quoted 38 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---

Chnages for v3:
- removed unnecessary empty line

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/usb/gadget/regs-otg.h +5 -0
index 84bfcc5..ac5d112 100644
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +0 -0
index 7e20209..ba17a04 100644

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 170

Quoted 6 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -2
@@ -167,8 +167,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)

proid_is_exynos4412()

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 179

Quoted 10 lines
drivers/usb/gadget/s3c_udc_otg.c +6 -0
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);

Thanks,
Minkyu Kang.

#10 lore raw

PATCH v3 1/2 driver:usb:s3c_udc: add support for Exynos4x12

Dear Minkyu Kang,

Quoted 52 lines

-----Original Message-----
From: Minkyu Kang [mailto:mk7.kang at samsung.com]
Sent: Thursday, November 21, 2013 9:10 AM
To: Piotr Wilczek
Cc: u-boot at lists.denx.de; Kyungmin Park
Subject: Re: [PATCH V3 1/2] driver:usb:s3c_udc: add support for Exynos4x12

Dear Piotr,

Quoted 39 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---

Chnages for v3:
- removed unnecessary empty line

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/usb/gadget/regs-otg.h index 84bfcc5..ac5d112 100644

drivers/usb/gadget/regs-otg.h +5 -0
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +0 -0
index 7e20209..ba17a04 100644

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 167

Quoted 1 line
drivers/usb/gadget/s3c_udc_otg.c +0 -0
@@ -167,8 +167,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 |

ANALOG_PWRDOWN)

Quoted 7 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 170

Quoted 5 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -2
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)

proid_is_exynos4412()

Ok but, proid_is_exynos4412() is not available for s5pc1**, ex the Goni board.

Quoted 3 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 172

Quoted 3 lines
drivers/usb/gadget/s3c_udc_otg.c +2 -0
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) |

EXYNOS4X12_CLK_SEL_24MHZ,

Quoted 4 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev)

Quoted 3 lines
drivers/usb/gadget/s3c_udc_otg.c +3 -0
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0))

|

Quoted 8 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 179

Quoted 5 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -0
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);

Thanks,
Minkyu Kang.

Best regards
Piotr Wilczek

#11 lore raw

PATCH v3 1/2 driver:usb:s3c_udc: add support for Exynos4x12

Quoted 56 lines · Piotr Wilczek

Dear Minkyu Kang,

Quoted 54 lines

-----Original Message-----
From: Minkyu Kang [mailto:mk7.kang at samsung.com]
Sent: Thursday, November 21, 2013 9:10 AM
To: Piotr Wilczek
Cc: u-boot at lists.denx.de; Kyungmin Park
Subject: Re: [PATCH V3 1/2] driver:usb:s3c_udc: add support for Exynos4x12

Dear Piotr,

Quoted 39 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---

Chnages for v3:
- removed unnecessary empty line

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/usb/gadget/regs-otg.h index 84bfcc5..ac5d112 100644

drivers/usb/gadget/regs-otg.h +5 -0
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +0 -0
index 7e20209..ba17a04 100644

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 167

Quoted 1 line
drivers/usb/gadget/s3c_udc_otg.c +0 -0
@@ -167,8 +167,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 |

ANALOG_PWRDOWN)

Quoted 2 lines
drivers/usb/gadget/s3c_udc_otg.c +0 -0
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
Quoted 7 lines
Quoted 5 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 170

Quoted 3 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -2
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)

proid_is_exynos4412()

Ok but, proid_is_exynos4412() is not available for s5pc1**, ex the Goni board.

Right..
just keep going.
I'll fix it later.

Quoted 18 lines
Quoted 4 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 172

Quoted 4 lines
drivers/usb/gadget/s3c_udc_otg.c +2 -0
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) |

EXYNOS4X12_CLK_SEL_24MHZ,

Quoted 4 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev)

Quoted 3 lines
drivers/usb/gadget/s3c_udc_otg.c +3 -0
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0))

|

Quoted 8 lines

drivers/usb/gadget/s3c_udc_otg.c void otg_phy_init(struct s3c_udc *dev) · line 179

Quoted 5 lines
drivers/usb/gadget/s3c_udc_otg.c +1 -0
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);

Thanks,
Minkyu Kang.

Quoted 6 lines

Best regards
Piotr Wilczek

Thanks,
Minkyu Kang.

#12 lore raw

PATCH v4 1/2 driver:usb:s3c_udc: add support for Exynos4x12

In reply to Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---
Chnages for v4:
- no changes

Chnages for v3:
- removed unnecessary empty line

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
drivers/usb/gadget/regs-otg.h +5 -0
index 84bfcc5..ac5d112 100644
@@ -226,6 +226,11 @@ struct s3c_usbotg_reg {
 #define CLK_SEL_12MHZ                   (0x2 << 0)
 #define CLK_SEL_48MHZ                   (0x0 << 0)
 
+#define EXYNOS4X12_ID_PULLUP0		(0x01 << 3)
+#define EXYNOS4X12_COMMON_ON_N0	(0x01 << 4)
+#define EXYNOS4X12_CLK_SEL_12MHZ	(0x02 << 0)
+#define EXYNOS4X12_CLK_SEL_24MHZ	(0x05 << 0)
+
 /* Device Configuration Register DCFG */
 #define DEV_SPEED_HIGH_SPEED_20         (0x0 << 0)
 #define DEV_SPEED_FULL_SPEED_20         (0x1 << 0)
drivers/usb/gadget/s3c_udc_otg.c +7 -2
index 7e20209..ba17a04 100644
@@ -167,8 +167,13 @@ void otg_phy_init(struct s3c_udc *dev)
 		writel((readl(&phy->phypwr) &~(OTG_DISABLE_0 | ANALOG_PWRDOWN)
 			&~FORCE_SUSPEND_0), &phy->phypwr);
 
-	writel((readl(&phy->phyclk) &~(ID_PULLUP0 | COMMON_ON_N0)) |
-	       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
+	if (s5p_cpu_id == 0x4412)
+		writel((readl(&phy->phyclk) & ~(EXYNOS4X12_ID_PULLUP0 |
+			EXYNOS4X12_COMMON_ON_N0)) | EXYNOS4X12_CLK_SEL_24MHZ,
+		       &phy->phyclk); /* PLL 24Mhz */
+	else
+		writel((readl(&phy->phyclk) & ~(ID_PULLUP0 | COMMON_ON_N0)) |
+		       CLK_SEL_24MHZ, &phy->phyclk); /* PLL 24Mhz */
 
 	writel((readl(&phy->rstcon) &~(LINK_SW_RST | PHYLNK_SW_RST))
 	       | PHY_SW_RST0, &phy->rstcon);
Signature · 1 line
1.7.9.5
#13 lore raw

PATCH v4 2/2 trats2: enable ums support on Trats2

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
Changes for v4:
- removed empty line
- added check if muic is available
- removed cable_connected

Changes for v3:
- no changes

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)
board/samsung/trats2/trats2.c +92 -0
index d44d825..b932a60 100644
@@ -25,6 +25,9 @@
 #include <power/max77693_fg.h>
 #include <libtizen.h>
 #include <errno.h>
+#include <usb.h>
+#include <usb/s3c_udc.h>
+#include <usb_mass_storage.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -308,6 +311,95 @@ int board_mmc_init(bd_t *bis)
 	return err0 & err2;
 }
 
+#ifdef CONFIG_USB_GADGET
+static int s5pc210_phy_control(int on)
+{
+	int ret = 0;
+	unsigned int val;
+	struct pmic *p, *p_pmic, *p_muic;
+
+	p_pmic = pmic_get("MAX77686_PMIC");
+	if (!p_pmic)
+		return -ENODEV;
+
+	if (pmic_probe(p_pmic))
+		return -1;
+
+	p_muic = pmic_get("MAX77693_MUIC");
+	if (!p_muic)
+		return -ENODEV;
+
+	if (pmic_probe(p_muic))
+		return -1;
+
+	if (on) {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_ON);
+		if (ret)
+			return -1;
+
+		p = pmic_get("MAX77693_PMIC");
+		if (!p)
+			return -ENODEV;
+
+		if (pmic_probe(p))
+			return -1;
+
+		/* SAFEOUT */
+		ret = pmic_reg_read(p, MAX77693_SAFEOUT, &val);
+		if (ret)
+			return -1;
+
+		val |= MAX77693_ENSAFEOUT1;
+		ret = pmic_reg_write(p, MAX77693_SAFEOUT, val);
+		if (ret)
+			return -1;
+
+		/* PATH: USB */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_DN1DP2);
+
+	} else {
+		ret = max77686_set_ldo_mode(p_pmic, 12, OPMODE_LPM);
+		if (ret)
+			return -1;
+
+		/* PATH: UART */
+		ret = pmic_reg_write(p_muic, MAX77693_MUIC_CONTROL1,
+			MAX77693_MUIC_CTRL1_UT1UR2);
+	}
+
+	if (ret)
+		return -1;
+
+	return 0;
+}
+
+struct s3c_plat_otg_data s5pc210_otg_data = {
+	.phy_control	= s5pc210_phy_control,
+	.regs_phy	= EXYNOS4X12_USBPHY_BASE,
+	.regs_otg	= EXYNOS4X12_USBOTG_BASE,
+	.usb_phy_ctrl	= EXYNOS4X12_USBPHY_CONTROL,
+	.usb_flags	= PHY0_SLEEP,
+};
+
+int board_usb_init(int index, enum usb_init_type init)
+{
+	debug("USB_udc_probe\n");
+	return s3c_udc_probe(&s5pc210_otg_data);
+}
+
+#ifdef CONFIG_USB_CABLE_CHECK
+int usb_cable_connected(void)
+{
+	struct pmic *muic = pmic_get("MAX77693_MUIC");
+	if (!muic)
+		return 0;
+
+	return !!muic->chrg->chrg_type(muic);
+}
+#endif
+#endif
+
 static int pmic_init_max77686(void)
 {
 	struct pmic *p = pmic_get("MAX77686_PMIC");
include/configs/trats2.h +18 -0
index 0e93836..66b1c95 100644
@@ -113,6 +113,16 @@
 #define CONFIG_CMD_EXT4
 #define CONFIG_CMD_EXT4_WRITE
 
+/* USB Composite download gadget - g_dnl */
+#define CONFIG_USBDOWNLOAD_GADGET
+#define CONFIG_DFU_FUNCTION
+#define CONFIG_DFU_MMC
+
+/* USB Samsung's IDs */
+#define CONFIG_G_DNL_VENDOR_NUM 0x04E8
+#define CONFIG_G_DNL_PRODUCT_NUM 0x6601
+#define CONFIG_G_DNL_MANUFACTURER "Samsung"
+
 /* To use the TFTPBOOT over USB, Please enable the CONFIG_CMD_NET */
 #undef CONFIG_CMD_NET
 
@@ -293,6 +303,11 @@
 #define CONFIG_POWER_MUIC_MAX77693
 #define CONFIG_POWER_FG_MAX77693
 #define CONFIG_POWER_BATTERY_TRATS2
+#define CONFIG_USB_GADGET
+#define CONFIG_USB_GADGET_S3C_UDC_OTG
+#define CONFIG_USB_GADGET_DUALSPEED
+#define CONFIG_USB_GADGET_VBUS_DRAW	2
+#define CONFIG_USB_CABLE_CHECK
 
 /* LCD */
 #define CONFIG_EXYNOS_FB
@@ -305,6 +320,9 @@
 #define CONFIG_VIDEO_BMP_GZIP
 #define CONFIG_SYS_VIDEO_LOGO_MAX_SIZE ((500 * 250 * 4) + (1 << 12))
 
+#define CONFIG_CMD_USB_MASS_STORAGE
+#define CONFIG_USB_GADGET_MASS_STORAGE
+
 /* Pass open firmware flat tree */
 #define CONFIG_OF_LIBFDT    1
 
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH v4 2/2 trats2: enable ums support on Trats2

Quoted 16 lines · Piotr Wilczek

This patch adds support for USB and enables 'ums' command on Trats2 board.

---
Changes for v4:
- removed empty line
- added check if muic is available
- removed cable_connected

Changes for v3:
- no changes

Quoted 8 lines

Changes for v2:
- rebased on current USB tree
- removed unnecessary pmic probing

 board/samsung/trats2/trats2.c |   92 +++++++++++++++++++++++++++++++++++++++++
 include/configs/trats2.h      |   18 ++++++++
 2 files changed, 110 insertions(+)

applied to u-boot-samsung.

Thanks,
Minkyu Kang.

#15 lore raw

PATCH v4 1/2 driver:usb:s3c_udc: add support for Exynos4x12

In reply to Piotr Wilczek
Quoted 12 lines · Piotr Wilczek

This patch add new defines for usb phy for Exynos4x12.

---
Chnages for v4:
- no changes

Chnages for v3:
- removed unnecessary empty line

Quoted 7 lines

Changes for v2:
- no changes

 drivers/usb/gadget/regs-otg.h    |    5 +++++
 drivers/usb/gadget/s3c_udc_otg.c |    9 +++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

applied to u-boot-samsung.

Thanks,
Minkyu Kang.