]> git.sur5r.net Git - u-boot/blob - board/samsung/smdk5420/smdk5420.c
smdk5420: board: add functions required to enable USB DWC3
[u-boot] / board / samsung / smdk5420 / smdk5420.c
1 /*
2  * Copyright (C) 2013 Samsung Electronics
3  *
4  * SPDX-License-Identifier:     GPL-2.0+
5  */
6
7 #include <common.h>
8 #include <fdtdec.h>
9 #include <errno.h>
10 #include <asm/io.h>
11 #include <asm/gpio.h>
12 #include <asm/arch/cpu.h>
13 #include <asm/arch/board.h>
14 #include <asm/arch/power.h>
15 #include <asm/arch/system.h>
16 #include <asm/arch/pinmux.h>
17 #include <asm/arch/dp_info.h>
18 #include <asm/arch/xhci-exynos.h>
19 #include <power/tps65090_pmic.h>
20 #include <i2c.h>
21 #include <lcd.h>
22 #include <parade.h>
23 #include <spi.h>
24 #include <usb.h>
25 #include <dwc3-uboot.h>
26 #include <samsung-usb-phy-uboot.h>
27
28 DECLARE_GLOBAL_DATA_PTR;
29
30 int exynos_init(void)
31 {
32         return 0;
33 }
34
35 #ifdef CONFIG_LCD
36 static int has_edp_bridge(void)
37 {
38         int node;
39
40         node = fdtdec_next_compatible(gd->fdt_blob, 0, COMPAT_PARADE_PS8625);
41
42         /* No node for bridge in device tree. */
43         if (node <= 0)
44                 return 0;
45
46         /* Default is with bridge ic */
47         return 1;
48 }
49
50 void exynos_lcd_power_on(void)
51 {
52         int ret;
53
54 #ifdef CONFIG_POWER_TPS65090
55         ret = tps65090_init();
56         if (ret < 0) {
57                 printf("%s: tps65090_init() failed\n", __func__);
58                 return;
59         }
60
61         tps65090_fet_enable(6);
62 #endif
63
64         mdelay(5);
65
66         if (has_edp_bridge())
67                 if (parade_init(gd->fdt_blob))
68                         printf("%s: ps8625_init() failed\n", __func__);
69 }
70
71 void exynos_backlight_on(unsigned int onoff)
72 {
73 #ifdef CONFIG_POWER_TPS65090
74         tps65090_fet_enable(1);
75 #endif
76 }
77 #endif
78
79 int board_get_revision(void)
80 {
81         return 0;
82 }
83
84 #ifdef CONFIG_USB_DWC3
85 static struct dwc3_device dwc3_device_data = {
86         .maximum_speed = USB_SPEED_SUPER,
87         .base = 0x12400000,
88         .dr_mode = USB_DR_MODE_PERIPHERAL,
89         .index = 0,
90 };
91
92 int usb_gadget_handle_interrupts(void)
93 {
94         dwc3_uboot_handle_interrupt(0);
95         return 0;
96 }
97
98 int board_usb_init(int index, enum usb_init_type init)
99 {
100         struct exynos_usb3_phy *phy = (struct exynos_usb3_phy *)
101                 samsung_get_base_usb3_phy();
102
103         if (!phy) {
104                 error("usb3 phy not supported");
105                 return -ENODEV;
106         }
107
108         set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_EN);
109         exynos5_usb3_phy_init(phy);
110
111         return dwc3_uboot_init(&dwc3_device_data);
112 }
113 #endif