1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Samsung Electronics
8 #include <dwc3-uboot.h>
15 #include <samsung-usb-phy-uboot.h>
18 #include <video_bridge.h>
20 #include <asm/arch/cpu.h>
21 #include <asm/arch/dwmmc.h>
22 #include <asm/arch/mmc.h>
23 #include <asm/arch/pinmux.h>
24 #include <asm/arch/power.h>
25 #include <asm/arch/sromc.h>
26 #include <power/pmic.h>
27 #include <power/max77686_pmic.h>
28 #include <power/regulator.h>
29 #include <power/s2mps11.h>
30 #include <power/s5m8767.h>
31 #include <samsung/exynos5-dt-types.h>
32 #include <samsung/misc.h>
35 DECLARE_GLOBAL_DATA_PTR;
37 static void board_enable_audio_codec(void)
40 struct gpio_desc en_gpio;
42 node = fdtdec_next_compatible(gd->fdt_blob, 0,
43 COMPAT_SAMSUNG_EXYNOS5_SOUND);
47 ret = gpio_request_by_name_nodev(offset_to_ofnode(node),
48 "codec-enable-gpio", 0, &en_gpio,
49 GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE);
50 if (ret == -FDT_ERR_NOTFOUND)
53 /* Turn on the GPIO which connects to the codec's "enable" line. */
54 gpio_set_pull(gpio_get_number(&en_gpio), S5P_GPIO_PULL_NONE);
56 #ifdef CONFIG_SOUND_MAX98095
57 /* Enable MAX98095 Codec */
58 gpio_request(EXYNOS5_GPIO_X17, "max98095_enable");
59 gpio_direction_output(EXYNOS5_GPIO_X17, 1);
60 gpio_set_pull(EXYNOS5_GPIO_X17, S5P_GPIO_PULL_NONE);
66 board_enable_audio_codec();
71 static int exynos_set_regulator(const char *name, uint uv)
76 ret = regulator_get_by_platname(name, &dev);
78 debug("%s: Cannot find regulator %s\n", __func__, name);
81 ret = regulator_set_value(dev, uv);
83 debug("%s: Cannot set regulator %s\n", __func__, name);
90 int exynos_power_init(void)
95 #ifdef CONFIG_PMIC_S2MPS11
96 ret = pmic_get("s2mps11_pmic", &dev);
98 ret = pmic_get("max77686", &dev);
100 /* TODO(sjg@chromium.org): Move into the clock/pmic API */
101 ret = pmic_clrsetbits(dev, MAX77686_REG_PMIC_32KHZ, 0,
105 ret = pmic_clrsetbits(dev, MAX77686_REG_PMIC_BBAT, 0,
106 MAX77686_BBCHOSTEN | MAX77686_BBCVS_3_5V);
110 ret = pmic_get("s5m8767-pmic", &dev);
111 /* TODO(sjg@chromium.org): Use driver model to access clock */
112 #ifdef CONFIG_PMIC_S5M8767
114 s5m8767_enable_32khz_cp(dev);
117 #endif /* CONFIG_PMIC_S2MPS11 */
121 ret = regulators_enable_boot_on(false);
125 ret = exynos_set_regulator("vdd_mif", 1100000);
129 ret = exynos_set_regulator("vdd_arm", 1300000);
132 ret = exynos_set_regulator("vdd_int", 1012500);
135 ret = exynos_set_regulator("vdd_g3d", 1200000);
142 int board_get_revision(void)
147 #ifdef CONFIG_USB_DWC3
148 static struct dwc3_device dwc3_device_data = {
149 .maximum_speed = USB_SPEED_SUPER,
151 .dr_mode = USB_DR_MODE_PERIPHERAL,
155 int usb_gadget_handle_interrupts(void)
157 dwc3_uboot_handle_interrupt(0);
161 int board_usb_init(int index, enum usb_init_type init)
163 struct exynos_usb3_phy *phy = (struct exynos_usb3_phy *)
164 samsung_get_base_usb3_phy();
167 pr_err("usb3 phy not supported");
171 set_usbdrd_phy_ctrl(POWER_USB_DRD_PHY_CTRL_EN);
172 exynos5_usb3_phy_init(phy);
174 return dwc3_uboot_init(&dwc3_device_data);
177 #ifdef CONFIG_SET_DFU_ALT_INFO
178 char *get_dfu_alt_system(char *interface, char *devstr)
180 char *info = "Not supported!";
182 if (board_is_odroidxu4() || board_is_odroidhc1())
185 return env_get("dfu_alt_system");
188 char *get_dfu_alt_boot(char *interface, char *devstr)
190 char *info = "Not supported!";
195 if (board_is_odroidxu4() || board_is_odroidhc1())
198 dev_num = simple_strtoul(devstr, NULL, 10);
200 mmc = find_mmc_device(dev_num);
208 alt_boot = CONFIG_DFU_ALT_BOOT_SD;
210 alt_boot = CONFIG_DFU_ALT_BOOT_EMMC;