From: Piotr Wilczek
Date: Thu, 21 Nov 2013 14:46:45 +0000 (+0100)
Subject: trats2: enable ums support on Trats2
X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=ab8efbb283a6c9cf8cb1d4a26e040c924417e7c7;p=u-boot.git
trats2: enable ums support on Trats2
This patch adds support for USB and enables 'ums' command on Trats2 board.
Signed-off-by: Piotr Wilczek
Signed-off-by: Kyungmin Park
Acked-by: Jaehoon Chung
Signed-off-by: Minkyu Kang
---
diff --git a/board/samsung/trats2/trats2.c b/board/samsung/trats2/trats2.c
index d44d825e80..b932a60a80 100644
--- a/board/samsung/trats2/trats2.c
+++ b/board/samsung/trats2/trats2.c
@@ -25,6 +25,9 @@
#include
#include
#include
+#include
+#include
+#include
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");
diff --git a/include/configs/trats2.h b/include/configs/trats2.h
index 0e93836c0c..66b1c95b4a 100644
--- a/include/configs/trats2.h
+++ b/include/configs/trats2.h
@@ -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