blob: 88f4044d63bd49dc0640bd45952cd6a0093d12ee [file] [log] [blame]
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +05301/*
2 * Copyright (C) 2013 Samsung Electronics
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <fdtdec.h>
Ajay Kumar222e1442014-09-05 16:53:36 +05309#include <errno.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020010#include <asm/io.h>
Simon Glass37f11622014-10-20 19:48:37 -060011#include <asm/gpio.h>
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053012#include <asm/arch/cpu.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020013#include <asm/arch/board.h>
14#include <asm/arch/power.h>
Ajay Kumar222e1442014-09-05 16:53:36 +053015#include <asm/arch/system.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020016#include <asm/arch/pinmux.h>
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053017#include <asm/arch/dp_info.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020018#include <asm/arch/xhci-exynos.h>
Ajay Kumar222e1442014-09-05 16:53:36 +053019#include <power/tps65090_pmic.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020020#include <i2c.h>
21#include <lcd.h>
Inha Song44164812015-05-22 18:14:25 +020022#include <mmc.h>
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020023#include <parade.h>
24#include <spi.h>
25#include <usb.h>
26#include <dwc3-uboot.h>
27#include <samsung-usb-phy-uboot.h>
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053028
29DECLARE_GLOBAL_DATA_PTR;
30
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053031int exynos_init(void)
32{
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053033 return 0;
34}
35
36#ifdef CONFIG_LCD
Ajay Kumar222e1442014-09-05 16:53:36 +053037static int has_edp_bridge(void)
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053038{
Ajay Kumar222e1442014-09-05 16:53:36 +053039 int node;
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053040
Ajay Kumar222e1442014-09-05 16:53:36 +053041 node = fdtdec_next_compatible(gd->fdt_blob, 0, COMPAT_PARADE_PS8625);
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053042
Ajay Kumar222e1442014-09-05 16:53:36 +053043 /* No node for bridge in device tree. */
44 if (node <= 0)
45 return 0;
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053046
Ajay Kumar222e1442014-09-05 16:53:36 +053047 /* Default is with bridge ic */
48 return 1;
49}
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053050
Ajay Kumar222e1442014-09-05 16:53:36 +053051void exynos_lcd_power_on(void)
52{
53 int ret;
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053054
Ajay Kumar222e1442014-09-05 16:53:36 +053055#ifdef CONFIG_POWER_TPS65090
56 ret = tps65090_init();
57 if (ret < 0) {
58 printf("%s: tps65090_init() failed\n", __func__);
59 return;
60 }
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053061
Ajay Kumar222e1442014-09-05 16:53:36 +053062 tps65090_fet_enable(6);
63#endif
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053064
Ajay Kumar222e1442014-09-05 16:53:36 +053065 mdelay(5);
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053066
Ajay Kumar222e1442014-09-05 16:53:36 +053067 if (has_edp_bridge())
68 if (parade_init(gd->fdt_blob))
69 printf("%s: ps8625_init() failed\n", __func__);
70}
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053071
Ajay Kumar222e1442014-09-05 16:53:36 +053072void exynos_backlight_on(unsigned int onoff)
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053073{
Ajay Kumar222e1442014-09-05 16:53:36 +053074#ifdef CONFIG_POWER_TPS65090
75 tps65090_fet_enable(1);
76#endif
Rajeshwari Birje5b475ae2013-12-26 09:44:24 +053077}
78#endif
79
80int board_get_revision(void)
81{
82 return 0;
83}
Joonyoung Shim95d3a1d2015-05-22 18:14:24 +020084
85#ifdef CONFIG_USB_DWC3
86static struct dwc3_device dwc3_device_data = {
87 .maximum_speed = USB_SPEED_SUPER,
88 .base = 0x12400000,
89 .dr_mode = USB_DR_MODE_PERIPHERAL,
90 .index = 0,
91};
92
93int usb_gadget_handle_interrupts(void)
94{
95 dwc3_uboot_handle_interrupt(0);
96 return 0;
97}
98
99int board_usb_init(int index, enum usb_init_type init)
100{
101 struct exynos_usb3_phy *phy = (struct exynos_usb3_phy *)
102 samsung_get_base_usb3_phy();
103
104 if (!phy) {
105 error("usb3 phy not supported");
106 return -ENODEV;
107 }
108
109 set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_EN);
110 exynos5_usb3_phy_init(phy);
111
112 return dwc3_uboot_init(&dwc3_device_data);
113}
114#endif
Inha Song44164812015-05-22 18:14:25 +0200115#ifdef CONFIG_SET_DFU_ALT_INFO
116char *get_dfu_alt_system(char *interface, char *devstr)
117{
118 return getenv("dfu_alt_system");
119}
120
121char *get_dfu_alt_boot(char *interface, char *devstr)
122{
123 struct mmc *mmc;
124 char *alt_boot;
125 int dev_num;
126
127 dev_num = simple_strtoul(devstr, NULL, 10);
128
129 mmc = find_mmc_device(dev_num);
130 if (!mmc)
131 return NULL;
132
133 if (mmc_init(mmc))
134 return NULL;
135
136 if (IS_SD(mmc))
137 alt_boot = CONFIG_DFU_ALT_BOOT_SD;
138 else
139 alt_boot = CONFIG_DFU_ALT_BOOT_EMMC;
140
141 return alt_boot;
142}
143#endif