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