Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2010 Samsung Electronics |
| 4 | * Minkyu Kang <mk7.kang@samsung.com> |
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 9 | #include <spi.h> |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 10 | #include <lcd.h> |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 11 | #include <asm/io.h> |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 12 | #include <asm/gpio.h> |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 13 | #include <asm/arch/adc.h> |
Piotr Wilczek | 3b17914 | 2012-09-20 00:19:59 +0000 | [diff] [blame] | 14 | #include <asm/arch/pinmux.h> |
Piotr Wilczek | 6ce94c3 | 2012-09-20 00:20:00 +0000 | [diff] [blame] | 15 | #include <asm/arch/watchdog.h> |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 16 | #include <ld9040.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 17 | #include <power/pmic.h> |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 18 | #include <usb.h> |
Marek Vasut | f1be9cb | 2015-12-04 02:51:20 +0100 | [diff] [blame] | 19 | #include <usb/dwc2_udc.h> |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 20 | #include <asm/arch/cpu.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 21 | #include <power/max8998_pmic.h> |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 22 | #include <libtizen.h> |
Przemyslaw Marczak | 94df801 | 2014-01-22 11:24:20 +0100 | [diff] [blame] | 23 | #include <samsung/misc.h> |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 24 | #include <usb_mass_storage.h> |
Simon Glass | 0ffb9d6 | 2017-05-31 19:47:48 -0600 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 26 | |
| 27 | DECLARE_GLOBAL_DATA_PTR; |
| 28 | |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 29 | unsigned int board_rev; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 30 | static int init_pmic_lcd(void); |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 31 | |
| 32 | u32 get_board_rev(void) |
| 33 | { |
| 34 | return board_rev; |
| 35 | } |
| 36 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 37 | int exynos_power_init(void) |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 38 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 39 | return init_pmic_lcd(); |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 40 | } |
| 41 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 42 | static int get_hwrev(void) |
Łukasz Majewski | 11be283 | 2012-11-13 03:22:17 +0000 | [diff] [blame] | 43 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 44 | return board_rev & 0xFF; |
Łukasz Majewski | 11be283 | 2012-11-13 03:22:17 +0000 | [diff] [blame] | 45 | } |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 46 | |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 47 | static unsigned short get_adc_value(int channel) |
| 48 | { |
| 49 | struct s5p_adc *adc = (struct s5p_adc *)samsung_get_base_adc(); |
| 50 | unsigned short ret = 0; |
| 51 | unsigned int reg; |
| 52 | unsigned int loop = 0; |
| 53 | |
| 54 | writel(channel & 0xF, &adc->adcmux); |
| 55 | writel((1 << 14) | (49 << 6), &adc->adccon); |
| 56 | writel(1000 & 0xffff, &adc->adcdly); |
| 57 | writel(readl(&adc->adccon) | (1 << 16), &adc->adccon); /* 12 bit */ |
| 58 | udelay(10); |
| 59 | writel(readl(&adc->adccon) | (1 << 0), &adc->adccon); /* Enable */ |
| 60 | udelay(10); |
| 61 | |
| 62 | do { |
| 63 | udelay(1); |
| 64 | reg = readl(&adc->adccon); |
| 65 | } while (!(reg & (1 << 15)) && (loop++ < 1000)); |
| 66 | |
| 67 | ret = readl(&adc->adcdat0) & 0xFFF; |
| 68 | |
| 69 | return ret; |
| 70 | } |
| 71 | |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 72 | static int adc_power_control(int on) |
| 73 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 74 | struct udevice *dev; |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 75 | int ret; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 76 | u8 reg; |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 77 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 78 | ret = pmic_get("max8998-pmic", &dev); |
| 79 | if (ret) { |
| 80 | puts("Failed to get MAX8998!\n"); |
| 81 | return ret; |
| 82 | } |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 83 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 84 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); |
| 85 | if (on) |
| 86 | reg |= MAX8998_LDO4; |
| 87 | else |
| 88 | reg &= ~MAX8998_LDO4; |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 89 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 90 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); |
| 91 | if (ret) { |
| 92 | puts("MAX8998 LDO setting error\n"); |
| 93 | return -EINVAL; |
| 94 | } |
| 95 | |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 96 | return 0; |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 97 | } |
| 98 | |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 99 | static unsigned int get_hw_revision(void) |
| 100 | { |
| 101 | int hwrev, mode0, mode1; |
| 102 | |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 103 | adc_power_control(1); |
| 104 | |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 105 | mode0 = get_adc_value(1); /* HWREV_MODE0 */ |
| 106 | mode1 = get_adc_value(2); /* HWREV_MODE1 */ |
| 107 | |
| 108 | /* |
| 109 | * XXX Always set the default hwrev as the latest board |
| 110 | * ADC = (voltage) / 3.3 * 4096 |
| 111 | */ |
| 112 | hwrev = 3; |
| 113 | |
| 114 | #define IS_RANGE(x, min, max) ((x) > (min) && (x) < (max)) |
| 115 | if (IS_RANGE(mode0, 80, 200) && IS_RANGE(mode1, 80, 200)) |
| 116 | hwrev = 0x0; /* 0.01V 0.01V */ |
| 117 | if (IS_RANGE(mode0, 750, 1000) && IS_RANGE(mode1, 80, 200)) |
| 118 | hwrev = 0x1; /* 610mV 0.01V */ |
| 119 | if (IS_RANGE(mode0, 1300, 1700) && IS_RANGE(mode1, 80, 200)) |
| 120 | hwrev = 0x2; /* 1.16V 0.01V */ |
| 121 | if (IS_RANGE(mode0, 2000, 2400) && IS_RANGE(mode1, 80, 200)) |
| 122 | hwrev = 0x3; /* 1.79V 0.01V */ |
| 123 | #undef IS_RANGE |
| 124 | |
| 125 | debug("mode0: %d, mode1: %d, hwrev 0x%x\n", mode0, mode1, hwrev); |
| 126 | |
Łukasz Majewski | 61f8b40 | 2012-03-26 21:53:48 +0000 | [diff] [blame] | 127 | adc_power_control(0); |
| 128 | |
Minkyu Kang | 0aa1a6b | 2011-01-24 15:33:50 +0900 | [diff] [blame] | 129 | return hwrev; |
| 130 | } |
| 131 | |
| 132 | static void check_hw_revision(void) |
| 133 | { |
| 134 | int hwrev; |
| 135 | |
| 136 | hwrev = get_hw_revision(); |
| 137 | |
| 138 | board_rev |= hwrev; |
| 139 | } |
| 140 | |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 141 | #ifdef CONFIG_USB_GADGET |
| 142 | static int s5pc210_phy_control(int on) |
| 143 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 144 | struct udevice *dev; |
| 145 | int ret; |
| 146 | u8 reg; |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 147 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 148 | ret = pmic_get("max8998-pmic", &dev); |
| 149 | if (ret) { |
| 150 | puts("Failed to get MAX8998!\n"); |
| 151 | return ret; |
| 152 | } |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 153 | |
| 154 | if (on) { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 155 | reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3); |
| 156 | reg |= MAX8998_SAFEOUT1; |
| 157 | ret |= pmic_reg_write(dev, |
| 158 | MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg); |
| 159 | |
| 160 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); |
| 161 | reg |= MAX8998_LDO3; |
| 162 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); |
| 163 | |
| 164 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); |
| 165 | reg |= MAX8998_LDO8; |
| 166 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 167 | |
| 168 | } else { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 169 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); |
| 170 | reg &= ~MAX8998_LDO8; |
| 171 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); |
| 172 | |
| 173 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF1); |
| 174 | reg &= ~MAX8998_LDO3; |
| 175 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, reg); |
| 176 | |
| 177 | reg = pmic_reg_read(dev, MAX8998_REG_BUCK_ACTIVE_DISCHARGE3); |
| 178 | reg &= ~MAX8998_SAFEOUT1; |
| 179 | ret |= pmic_reg_write(dev, |
| 180 | MAX8998_REG_BUCK_ACTIVE_DISCHARGE3, reg); |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | if (ret) { |
| 184 | puts("MAX8998 LDO setting error!\n"); |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 185 | return -EINVAL; |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 186 | } |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 187 | |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 188 | return 0; |
| 189 | } |
| 190 | |
Marek Vasut | 6939aca | 2015-12-04 02:23:29 +0100 | [diff] [blame] | 191 | struct dwc2_plat_otg_data s5pc210_otg_data = { |
Lukasz Majewski | bf73126 | 2011-12-15 10:32:12 +0100 | [diff] [blame] | 192 | .phy_control = s5pc210_phy_control, |
| 193 | .regs_phy = EXYNOS4_USBPHY_BASE, |
| 194 | .regs_otg = EXYNOS4_USBOTG_BASE, |
| 195 | .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL, |
| 196 | .usb_flags = PHY0_SLEEP, |
| 197 | }; |
| 198 | #endif |
Piotr Wilczek | 6ce94c3 | 2012-09-20 00:20:00 +0000 | [diff] [blame] | 199 | |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 200 | int board_usb_init(int index, enum usb_init_type init) |
| 201 | { |
| 202 | debug("USB_udc_probe\n"); |
Marek Vasut | 01b61fa | 2015-12-04 02:26:33 +0100 | [diff] [blame] | 203 | return dwc2_udc_probe(&s5pc210_otg_data); |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 204 | } |
| 205 | |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 206 | int exynos_early_init_f(void) |
Piotr Wilczek | 6ce94c3 | 2012-09-20 00:20:00 +0000 | [diff] [blame] | 207 | { |
| 208 | wdt_stop(); |
| 209 | |
| 210 | return 0; |
| 211 | } |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 212 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 213 | static int init_pmic_lcd(void) |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 214 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 215 | struct udevice *dev; |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 216 | unsigned char val; |
| 217 | int ret = 0; |
| 218 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 219 | ret = pmic_get("max8998-pmic", &dev); |
| 220 | if (ret) { |
| 221 | puts("Failed to get MAX8998 for init_pmic_lcd()!\n"); |
| 222 | return ret; |
| 223 | } |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 224 | |
| 225 | /* LDO7 1.8V */ |
| 226 | val = 0x02; /* (1800 - 1600) / 100; */ |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 227 | ret |= pmic_reg_write(dev, MAX8998_REG_LDO7, val); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 228 | |
| 229 | /* LDO17 3.0V */ |
| 230 | val = 0xe; /* (3000 - 1600) / 100; */ |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 231 | ret |= pmic_reg_write(dev, MAX8998_REG_LDO17, val); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 232 | |
| 233 | /* Disable unneeded regulators */ |
| 234 | /* |
| 235 | * ONOFF1 |
| 236 | * Buck1 ON, Buck2 OFF, Buck3 ON, Buck4 ON |
| 237 | * LDO2 ON, LDO3 OFF, LDO4 OFF, LDO5 ON |
| 238 | */ |
| 239 | val = 0xB9; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 240 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF1, val); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 241 | |
| 242 | /* ONOFF2 |
| 243 | * LDO6 OFF, LDO7 ON, LDO8 OFF, LDO9 ON, |
| 244 | * LDO10 OFF, LDO11 OFF, LDO12 OFF, LDO13 OFF |
| 245 | */ |
| 246 | val = 0x50; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 247 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF2, val); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 248 | |
| 249 | /* ONOFF3 |
| 250 | * LDO14 OFF, LDO15 OFF, LGO16 OFF, LDO17 OFF |
| 251 | * EPWRHOLD OFF, EBATTMON OFF, ELBCNFG2 OFF, ELBCNFG1 OFF |
| 252 | */ |
| 253 | val = 0x00; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 254 | ret |= pmic_reg_write(dev, MAX8998_REG_ONOFF3, val); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 255 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 256 | if (ret) { |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 257 | puts("LCD pmic initialisation error!\n"); |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 258 | return -EINVAL; |
| 259 | } |
| 260 | |
| 261 | return 0; |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 262 | } |
| 263 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 264 | void exynos_cfg_lcd_gpio(void) |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 265 | { |
| 266 | unsigned int i, f3_end = 4; |
| 267 | |
| 268 | for (i = 0; i < 8; i++) { |
| 269 | /* set GPF0,1,2[0:7] for RGB Interface and Data lines (32bit) */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 270 | gpio_cfg_pin(EXYNOS4_GPIO_F00 + i, S5P_GPIO_FUNC(2)); |
| 271 | gpio_cfg_pin(EXYNOS4_GPIO_F10 + i, S5P_GPIO_FUNC(2)); |
| 272 | gpio_cfg_pin(EXYNOS4_GPIO_F20 + i, S5P_GPIO_FUNC(2)); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 273 | /* pull-up/down disable */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 274 | gpio_set_pull(EXYNOS4_GPIO_F00 + i, S5P_GPIO_PULL_NONE); |
| 275 | gpio_set_pull(EXYNOS4_GPIO_F10 + i, S5P_GPIO_PULL_NONE); |
| 276 | gpio_set_pull(EXYNOS4_GPIO_F20 + i, S5P_GPIO_PULL_NONE); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 277 | |
| 278 | /* drive strength to max (24bit) */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 279 | gpio_set_drv(EXYNOS4_GPIO_F00 + i, S5P_GPIO_DRV_4X); |
| 280 | gpio_set_rate(EXYNOS4_GPIO_F00 + i, S5P_GPIO_DRV_SLOW); |
| 281 | gpio_set_drv(EXYNOS4_GPIO_F10 + i, S5P_GPIO_DRV_4X); |
| 282 | gpio_set_rate(EXYNOS4_GPIO_F10 + i, S5P_GPIO_DRV_SLOW); |
| 283 | gpio_set_drv(EXYNOS4_GPIO_F20 + i, S5P_GPIO_DRV_4X); |
| 284 | gpio_set_rate(EXYNOS4_GPIO_F00 + i, S5P_GPIO_DRV_SLOW); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 285 | } |
| 286 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 287 | for (i = EXYNOS4_GPIO_F30; i < (EXYNOS4_GPIO_F30 + f3_end); i++) { |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 288 | /* set GPF3[0:3] for RGB Interface and Data lines (32bit) */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 289 | gpio_cfg_pin(i, S5P_GPIO_FUNC(2)); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 290 | /* pull-up/down disable */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 291 | gpio_set_pull(i, S5P_GPIO_PULL_NONE); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 292 | /* drive strength to max (24bit) */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 293 | gpio_set_drv(i, S5P_GPIO_DRV_4X); |
| 294 | gpio_set_rate(i, S5P_GPIO_DRV_SLOW); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /* gpio pad configuration for LCD reset. */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 298 | gpio_request(EXYNOS4_GPIO_Y45, "lcd_reset"); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 299 | gpio_cfg_pin(EXYNOS4_GPIO_Y45, S5P_GPIO_OUTPUT); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 302 | int mipi_power(void) |
| 303 | { |
| 304 | return 0; |
| 305 | } |
| 306 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 307 | void exynos_reset_lcd(void) |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 308 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 309 | gpio_set_value(EXYNOS4_GPIO_Y45, 1); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 310 | udelay(10000); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 311 | gpio_set_value(EXYNOS4_GPIO_Y45, 0); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 312 | udelay(10000); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 313 | gpio_set_value(EXYNOS4_GPIO_Y45, 1); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 314 | udelay(100); |
| 315 | } |
| 316 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 317 | void exynos_lcd_power_on(void) |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 318 | { |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 319 | struct udevice *dev; |
| 320 | int ret; |
| 321 | u8 reg; |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 322 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 323 | ret = pmic_get("max8998-pmic", &dev); |
| 324 | if (ret) { |
| 325 | puts("Failed to get MAX8998!\n"); |
Minkyu Kang | 538f26b | 2012-12-10 22:43:57 +0900 | [diff] [blame] | 326 | return; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 327 | } |
Minkyu Kang | 538f26b | 2012-12-10 22:43:57 +0900 | [diff] [blame] | 328 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 329 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF3); |
| 330 | reg |= MAX8998_LDO17; |
| 331 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF3, reg); |
| 332 | if (ret) { |
| 333 | puts("MAX8998 LDO setting error\n"); |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 334 | return; |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 335 | } |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 336 | |
Jaehoon Chung | 40195a2 | 2017-01-09 14:47:50 +0900 | [diff] [blame] | 337 | reg = pmic_reg_read(dev, MAX8998_REG_ONOFF2); |
| 338 | reg |= MAX8998_LDO7; |
| 339 | ret = pmic_reg_write(dev, MAX8998_REG_ONOFF2, reg); |
| 340 | if (ret) { |
| 341 | puts("MAX8998 LDO setting error\n"); |
| 342 | return; |
| 343 | } |
Piotr Wilczek | 461c5e5 | 2012-10-19 05:34:07 +0000 | [diff] [blame] | 344 | } |
| 345 | |
Ajay Kumar | 41022a1 | 2013-02-21 23:52:57 +0000 | [diff] [blame] | 346 | void exynos_cfg_ldo(void) |
| 347 | { |
| 348 | ld9040_cfg_ldo(); |
| 349 | } |
| 350 | |
| 351 | void exynos_enable_ldo(unsigned int onoff) |
| 352 | { |
| 353 | ld9040_enable_ldo(onoff); |
| 354 | } |
| 355 | |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 356 | int exynos_init(void) |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 357 | { |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 358 | gd->bd->bi_arch_number = MACH_TYPE_UNIVERSAL_C210; |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 359 | |
| 360 | switch (get_hwrev()) { |
| 361 | case 0: |
| 362 | /* |
| 363 | * Set the low to enable LDO_EN |
| 364 | * But when you use the test board for eMMC booting |
| 365 | * you should set it HIGH since it removes the inverter |
| 366 | */ |
| 367 | /* MASSMEMORY_EN: XMDMDATA_6: GPE3[6] */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 368 | gpio_request(EXYNOS4_GPIO_E36, "ldo_en"); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 369 | gpio_direction_output(EXYNOS4_GPIO_E36, 0); |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 370 | break; |
| 371 | default: |
| 372 | /* |
| 373 | * Default reset state is High and there's no inverter |
| 374 | * But set it as HIGH to ensure |
| 375 | */ |
| 376 | /* MASSMEMORY_EN: XMDMADDR_3: GPE1[3] */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 377 | gpio_request(EXYNOS4_GPIO_E13, "massmemory_en"); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 378 | gpio_direction_output(EXYNOS4_GPIO_E13, 1); |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 379 | break; |
| 380 | } |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 381 | |
Piotr Wilczek | e372b55 | 2012-10-19 05:34:03 +0000 | [diff] [blame] | 382 | check_hw_revision(); |
| 383 | printf("HW Revision:\t0x%x\n", board_rev); |
| 384 | |
| 385 | return 0; |
| 386 | } |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 387 | |
Simon Glass | b4a967e | 2016-02-21 21:08:54 -0700 | [diff] [blame] | 388 | #ifdef CONFIG_LCD |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 389 | void exynos_lcd_misc_init(vidinfo_t *vid) |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 390 | { |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 391 | #ifdef CONFIG_TIZEN |
| 392 | get_tizen_logo_info(vid); |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 393 | #endif |
Piotr Wilczek | 0ada4ad | 2014-03-07 14:59:47 +0100 | [diff] [blame] | 394 | |
| 395 | /* for LD9040. */ |
| 396 | vid->pclk_name = 1; /* MPLL */ |
| 397 | vid->sclk_div = 1; |
| 398 | |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 399 | env_set("lcdinfo", "lcd=ld9040"); |
Przemyslaw Marczak | 283a320 | 2014-01-22 11:24:12 +0100 | [diff] [blame] | 400 | } |
Simon Glass | b4a967e | 2016-02-21 21:08:54 -0700 | [diff] [blame] | 401 | #endif |