Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2011 Samsung Electronics |
| 4 | * Heungjun Kim <riverful.kim@samsung.com> |
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 6 | * Donghwa Lee <dh09.lee@samsung.com> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <common.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 10 | #include <env.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 11 | #include <log.h> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 12 | #include <asm/io.h> |
Simon Glass | 37f1162 | 2014-10-20 19:48:37 -0600 | [diff] [blame] | 13 | #include <asm/gpio.h> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 14 | #include <asm/arch/cpu.h> |
Piotr Wilczek | 3c8b71d | 2012-09-20 00:19:58 +0000 | [diff] [blame] | 15 | #include <asm/arch/pinmux.h> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 16 | #include <asm/arch/clock.h> |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 17 | #include <asm/arch/mipi_dsim.h> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 18 | #include <asm/arch/watchdog.h> |
| 19 | #include <asm/arch/power.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> |
Marek Vasut | f1be9cb | 2015-12-04 02:51:20 +0100 | [diff] [blame] | 22 | #include <usb/dwc2_udc.h> |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 23 | #include <power/max8997_pmic.h> |
Łukasz Majewski | 40e330a | 2012-11-13 03:22:06 +0000 | [diff] [blame] | 24 | #include <power/max8997_muic.h> |
Łukasz Majewski | e4a182a | 2012-11-13 03:22:08 +0000 | [diff] [blame] | 25 | #include <power/battery.h> |
Łukasz Majewski | 7aba6a1 | 2012-11-13 03:22:07 +0000 | [diff] [blame] | 26 | #include <power/max17042_fg.h> |
Jaehoon Chung | c43173c | 2017-03-30 21:29:59 +0900 | [diff] [blame] | 27 | #include <power/pmic.h> |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 28 | #include <libtizen.h> |
Mateusz Zalega | d862f89 | 2013-10-04 19:22:26 +0200 | [diff] [blame] | 29 | #include <usb.h> |
Lukasz Majewski | 0a4d8a9 | 2013-03-05 12:10:18 +0100 | [diff] [blame] | 30 | #include <usb_mass_storage.h> |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 31 | |
| 32 | #include "setup.h" |
| 33 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 34 | unsigned int board_rev; |
| 35 | |
| 36 | #ifdef CONFIG_REVISION_TAG |
| 37 | u32 get_board_rev(void) |
| 38 | { |
| 39 | return board_rev; |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | static void check_hw_revision(void); |
Marek Vasut | 6939aca | 2015-12-04 02:23:29 +0100 | [diff] [blame] | 44 | struct dwc2_plat_otg_data s5pc210_otg_data; |
Lukasz Majewski | 51de176 | 2012-08-06 14:41:10 +0200 | [diff] [blame] | 45 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 46 | int exynos_init(void) |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 47 | { |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 48 | check_hw_revision(); |
| 49 | printf("HW Revision:\t0x%x\n", board_rev); |
| 50 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 54 | #if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */ |
Łukasz Majewski | b6a3dc6 | 2012-11-13 03:22:10 +0000 | [diff] [blame] | 55 | static void trats_low_power_mode(void) |
| 56 | { |
| 57 | struct exynos4_clock *clk = |
| 58 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 59 | struct exynos4_power *pwr = |
| 60 | (struct exynos4_power *)samsung_get_base_power(); |
| 61 | |
| 62 | /* Power down CORE1 */ |
| 63 | /* LOCAL_PWR_CFG [1:0] 0x3 EN, 0x0 DIS */ |
| 64 | writel(0x0, &pwr->arm_core1_configuration); |
| 65 | |
| 66 | /* Change the APLL frequency */ |
| 67 | /* ENABLE (1 enable) | LOCKED (1 locked) */ |
| 68 | /* [31] | [29] */ |
| 69 | /* FSEL | MDIV | PDIV | SDIV */ |
| 70 | /* [27] | [25:16] | [13:8] | [2:0] */ |
| 71 | writel(0xa0c80604, &clk->apll_con0); |
| 72 | |
| 73 | /* Change CPU0 clock divider */ |
| 74 | /* CORE2_RATIO | APLL_RATIO | PCLK_DBG_RATIO | ATB_RATIO */ |
| 75 | /* [30:28] | [26:24] | [22:20] | [18:16] */ |
| 76 | /* PERIPH_RATIO | COREM1_RATIO | COREM0_RATIO | CORE_RATIO */ |
| 77 | /* [14:12] | [10:8] | [6:4] | [2:0] */ |
| 78 | writel(0x00000100, &clk->div_cpu0); |
| 79 | |
| 80 | /* CLK_DIV_STAT_CPU0 - wait until clock gets stable (0 = stable) */ |
| 81 | while (readl(&clk->div_stat_cpu0) & 0x1111111) |
| 82 | continue; |
| 83 | |
| 84 | /* Change clock divider ratio for DMC */ |
| 85 | /* DMCP_RATIO | DMCD_RATIO */ |
| 86 | /* [22:20] | [18:16] */ |
| 87 | /* DMC_RATIO | DPHY_RATIO | ACP_PCLK_RATIO | ACP_RATIO */ |
| 88 | /* [14:12] | [10:8] | [6:4] | [2:0] */ |
| 89 | writel(0x13113117, &clk->div_dmc0); |
| 90 | |
| 91 | /* CLK_DIV_STAT_DMC0 - wait until clock gets stable (0 = stable) */ |
| 92 | while (readl(&clk->div_stat_dmc0) & 0x11111111) |
| 93 | continue; |
| 94 | |
| 95 | /* Turn off unnecessary power domains */ |
| 96 | writel(0x0, &pwr->xxti_configuration); /* XXTI */ |
| 97 | writel(0x0, &pwr->cam_configuration); /* CAM */ |
| 98 | writel(0x0, &pwr->tv_configuration); /* TV */ |
| 99 | writel(0x0, &pwr->mfc_configuration); /* MFC */ |
| 100 | writel(0x0, &pwr->g3d_configuration); /* G3D */ |
| 101 | writel(0x0, &pwr->gps_configuration); /* GPS */ |
| 102 | writel(0x0, &pwr->gps_alive_configuration); /* GPS_ALIVE */ |
| 103 | |
| 104 | /* Turn off unnecessary clocks */ |
| 105 | writel(0x0, &clk->gate_ip_cam); /* CAM */ |
| 106 | writel(0x0, &clk->gate_ip_tv); /* TV */ |
| 107 | writel(0x0, &clk->gate_ip_mfc); /* MFC */ |
| 108 | writel(0x0, &clk->gate_ip_g3d); /* G3D */ |
| 109 | writel(0x0, &clk->gate_ip_image); /* IMAGE */ |
| 110 | writel(0x0, &clk->gate_ip_gps); /* GPS */ |
| 111 | } |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 112 | #endif |
Łukasz Majewski | d72e0ae | 2012-11-13 03:22:05 +0000 | [diff] [blame] | 113 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 114 | int exynos_power_init(void) |
Łukasz Majewski | fa62766 | 2012-11-13 03:21:57 +0000 | [diff] [blame] | 115 | { |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 116 | #if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */ |
Łukasz Majewski | fc2d44a | 2012-11-13 03:22:11 +0000 | [diff] [blame] | 117 | int chrg, ret; |
| 118 | struct power_battery *pb; |
| 119 | struct pmic *p_fg, *p_chrg, *p_muic, *p_bat; |
Łukasz Majewski | fa62766 | 2012-11-13 03:21:57 +0000 | [diff] [blame] | 120 | |
Łukasz Majewski | de55e75 | 2013-08-16 15:33:33 +0200 | [diff] [blame] | 121 | /* |
| 122 | * For PMIC/MUIC the I2C bus is named as I2C5, but it is connected |
| 123 | * to logical I2C adapter 0 |
| 124 | * |
| 125 | * The FUEL_GAUGE is marked as I2C9 on the schematic, but connected |
| 126 | * to logical I2C adapter 1 |
| 127 | */ |
Jaehoon Chung | c747570 | 2017-03-30 21:29:58 +0900 | [diff] [blame] | 128 | ret = power_fg_init(I2C_9); |
Piotr Wilczek | 58bbd2b | 2013-11-20 10:43:49 +0100 | [diff] [blame] | 129 | ret |= power_muic_init(I2C_5); |
Łukasz Majewski | e4a182a | 2012-11-13 03:22:08 +0000 | [diff] [blame] | 130 | ret |= power_bat_init(0); |
Łukasz Majewski | fa62766 | 2012-11-13 03:21:57 +0000 | [diff] [blame] | 131 | if (ret) |
| 132 | return ret; |
| 133 | |
Łukasz Majewski | fc2d44a | 2012-11-13 03:22:11 +0000 | [diff] [blame] | 134 | p_fg = pmic_get("MAX17042_FG"); |
| 135 | if (!p_fg) { |
| 136 | puts("MAX17042_FG: Not found\n"); |
| 137 | return -ENODEV; |
| 138 | } |
| 139 | |
| 140 | p_chrg = pmic_get("MAX8997_PMIC"); |
| 141 | if (!p_chrg) { |
| 142 | puts("MAX8997_PMIC: Not found\n"); |
| 143 | return -ENODEV; |
| 144 | } |
| 145 | |
| 146 | p_muic = pmic_get("MAX8997_MUIC"); |
| 147 | if (!p_muic) { |
| 148 | puts("MAX8997_MUIC: Not found\n"); |
| 149 | return -ENODEV; |
| 150 | } |
| 151 | |
| 152 | p_bat = pmic_get("BAT_TRATS"); |
| 153 | if (!p_bat) { |
| 154 | puts("BAT_TRATS: Not found\n"); |
| 155 | return -ENODEV; |
| 156 | } |
| 157 | |
| 158 | p_fg->parent = p_bat; |
| 159 | p_chrg->parent = p_bat; |
| 160 | p_muic->parent = p_bat; |
| 161 | |
| 162 | p_bat->low_power_mode = trats_low_power_mode; |
| 163 | p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic); |
| 164 | |
| 165 | pb = p_bat->pbat; |
| 166 | chrg = p_muic->chrg->chrg_type(p_muic); |
| 167 | debug("CHARGER TYPE: %d\n", chrg); |
| 168 | |
| 169 | if (!p_chrg->chrg->chrg_bat_present(p_chrg)) { |
| 170 | puts("No battery detected\n"); |
Przemyslaw Marczak | dd0c48e | 2014-06-10 16:55:08 +0200 | [diff] [blame] | 171 | return 0; |
Łukasz Majewski | fc2d44a | 2012-11-13 03:22:11 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | p_fg->fg->fg_battery_check(p_fg, p_bat); |
| 175 | |
| 176 | if (pb->bat->state == CHARGE && chrg == CHARGER_USB) |
| 177 | puts("CHARGE Battery !\n"); |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 178 | #endif |
Łukasz Majewski | fc2d44a | 2012-11-13 03:22:11 +0000 | [diff] [blame] | 179 | |
Łukasz Majewski | fa62766 | 2012-11-13 03:21:57 +0000 | [diff] [blame] | 180 | return 0; |
| 181 | } |
| 182 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 183 | static unsigned int get_hw_revision(void) |
| 184 | { |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 185 | int hwrev = 0; |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 186 | char str[10]; |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 187 | int i; |
| 188 | |
| 189 | /* hw_rev[3:0] == GPE1[3:0] */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 190 | for (i = 0; i < 4; i++) { |
| 191 | int pin = i + EXYNOS4_GPIO_E10; |
| 192 | |
| 193 | sprintf(str, "hw_rev%d", i); |
| 194 | gpio_request(pin, str); |
| 195 | gpio_cfg_pin(pin, S5P_GPIO_INPUT); |
| 196 | gpio_set_pull(pin, S5P_GPIO_PULL_NONE); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | udelay(1); |
| 200 | |
| 201 | for (i = 0; i < 4; i++) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 202 | hwrev |= (gpio_get_value(EXYNOS4_GPIO_E10 + i) << i); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 203 | |
| 204 | debug("hwrev 0x%x\n", hwrev); |
| 205 | |
| 206 | return hwrev; |
| 207 | } |
| 208 | |
| 209 | static void check_hw_revision(void) |
| 210 | { |
| 211 | int hwrev; |
| 212 | |
| 213 | hwrev = get_hw_revision(); |
| 214 | |
| 215 | board_rev |= hwrev; |
| 216 | } |
| 217 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 218 | |
| 219 | #ifdef CONFIG_USB_GADGET |
| 220 | static int s5pc210_phy_control(int on) |
| 221 | { |
Jaehoon Chung | c43173c | 2017-03-30 21:29:59 +0900 | [diff] [blame] | 222 | struct udevice *dev; |
| 223 | int reg, ret; |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 224 | |
Jaehoon Chung | c43173c | 2017-03-30 21:29:59 +0900 | [diff] [blame] | 225 | ret = pmic_get("max8997-pmic", &dev); |
| 226 | if (ret) |
| 227 | return ret; |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 228 | |
| 229 | if (on) { |
Jaehoon Chung | c43173c | 2017-03-30 21:29:59 +0900 | [diff] [blame] | 230 | reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL); |
| 231 | reg |= ENSAFEOUT1; |
| 232 | ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg); |
| 233 | if (ret) { |
| 234 | puts("MAX8997 setting error!\n"); |
| 235 | return ret; |
| 236 | } |
| 237 | reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL); |
| 238 | reg |= EN_LDO; |
| 239 | ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg); |
| 240 | if (ret) { |
| 241 | puts("MAX8997 setting error!\n"); |
| 242 | return ret; |
| 243 | } |
| 244 | reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL); |
| 245 | reg |= EN_LDO; |
| 246 | ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg); |
| 247 | if (ret) { |
| 248 | puts("MAX8997 setting error!\n"); |
| 249 | return ret; |
| 250 | } |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 251 | } else { |
Jaehoon Chung | c43173c | 2017-03-30 21:29:59 +0900 | [diff] [blame] | 252 | reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL); |
| 253 | reg &= DIS_LDO; |
| 254 | ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg); |
| 255 | if (ret) { |
| 256 | puts("MAX8997 setting error!\n"); |
| 257 | return ret; |
| 258 | } |
| 259 | reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL); |
| 260 | reg &= DIS_LDO; |
| 261 | ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg); |
| 262 | if (ret) { |
| 263 | puts("MAX8997 setting error!\n"); |
| 264 | return ret; |
| 265 | } |
| 266 | reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL); |
| 267 | reg &= ~ENSAFEOUT1; |
| 268 | ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg); |
| 269 | if (ret) { |
| 270 | puts("MAX8997 setting error!\n"); |
| 271 | return ret; |
| 272 | } |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 273 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 274 | } |
| 275 | |
| 276 | return 0; |
| 277 | } |
| 278 | |
Marek Vasut | 6939aca | 2015-12-04 02:23:29 +0100 | [diff] [blame] | 279 | struct dwc2_plat_otg_data s5pc210_otg_data = { |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 280 | .phy_control = s5pc210_phy_control, |
| 281 | .regs_phy = EXYNOS4_USBPHY_BASE, |
| 282 | .regs_otg = EXYNOS4_USBOTG_BASE, |
| 283 | .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL, |
| 284 | .usb_flags = PHY0_SLEEP, |
| 285 | }; |
Lukasz Majewski | 51de176 | 2012-08-06 14:41:10 +0200 | [diff] [blame] | 286 | |
Troy Kisky | de8ae7b | 2013-10-10 15:27:55 -0700 | [diff] [blame] | 287 | int board_usb_init(int index, enum usb_init_type init) |
Lukasz Majewski | 51de176 | 2012-08-06 14:41:10 +0200 | [diff] [blame] | 288 | { |
| 289 | debug("USB_udc_probe\n"); |
Marek Vasut | 01b61fa | 2015-12-04 02:26:33 +0100 | [diff] [blame] | 290 | return dwc2_udc_probe(&s5pc210_otg_data); |
Lukasz Majewski | 51de176 | 2012-08-06 14:41:10 +0200 | [diff] [blame] | 291 | } |
Przemyslaw Marczak | 99b0235 | 2013-12-02 13:54:01 +0100 | [diff] [blame] | 292 | |
Mateusz Zalega | 21fe3f7 | 2014-04-30 13:07:48 +0200 | [diff] [blame] | 293 | int g_dnl_board_usb_cable_connected(void) |
Przemyslaw Marczak | 99b0235 | 2013-12-02 13:54:01 +0100 | [diff] [blame] | 294 | { |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 295 | #if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */ |
Przemyslaw Marczak | 99b0235 | 2013-12-02 13:54:01 +0100 | [diff] [blame] | 296 | struct pmic *muic = pmic_get("MAX8997_MUIC"); |
| 297 | if (!muic) |
| 298 | return 0; |
| 299 | |
| 300 | return !!muic->chrg->chrg_type(muic); |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 301 | #else |
| 302 | return false; |
| 303 | #endif |
| 304 | |
Przemyslaw Marczak | 99b0235 | 2013-12-02 13:54:01 +0100 | [diff] [blame] | 305 | } |
| 306 | #endif |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 307 | |
| 308 | static void pmic_reset(void) |
| 309 | { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 310 | gpio_direction_output(EXYNOS4_GPIO_X07, 1); |
| 311 | gpio_set_pull(EXYNOS4_GPIO_X27, S5P_GPIO_PULL_NONE); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | static void board_clock_init(void) |
| 315 | { |
| 316 | struct exynos4_clock *clk = |
| 317 | (struct exynos4_clock *)samsung_get_base_clock(); |
| 318 | |
| 319 | writel(CLK_SRC_CPU_VAL, (unsigned int)&clk->src_cpu); |
| 320 | writel(CLK_SRC_TOP0_VAL, (unsigned int)&clk->src_top0); |
| 321 | writel(CLK_SRC_FSYS_VAL, (unsigned int)&clk->src_fsys); |
| 322 | writel(CLK_SRC_PERIL0_VAL, (unsigned int)&clk->src_peril0); |
| 323 | |
| 324 | writel(CLK_DIV_CPU0_VAL, (unsigned int)&clk->div_cpu0); |
| 325 | writel(CLK_DIV_CPU1_VAL, (unsigned int)&clk->div_cpu1); |
| 326 | writel(CLK_DIV_DMC0_VAL, (unsigned int)&clk->div_dmc0); |
| 327 | writel(CLK_DIV_DMC1_VAL, (unsigned int)&clk->div_dmc1); |
| 328 | writel(CLK_DIV_LEFTBUS_VAL, (unsigned int)&clk->div_leftbus); |
| 329 | writel(CLK_DIV_RIGHTBUS_VAL, (unsigned int)&clk->div_rightbus); |
| 330 | writel(CLK_DIV_TOP_VAL, (unsigned int)&clk->div_top); |
| 331 | writel(CLK_DIV_FSYS1_VAL, (unsigned int)&clk->div_fsys1); |
| 332 | writel(CLK_DIV_FSYS2_VAL, (unsigned int)&clk->div_fsys2); |
| 333 | writel(CLK_DIV_FSYS3_VAL, (unsigned int)&clk->div_fsys3); |
| 334 | writel(CLK_DIV_PERIL0_VAL, (unsigned int)&clk->div_peril0); |
| 335 | writel(CLK_DIV_PERIL3_VAL, (unsigned int)&clk->div_peril3); |
| 336 | |
| 337 | writel(PLL_LOCKTIME, (unsigned int)&clk->apll_lock); |
| 338 | writel(PLL_LOCKTIME, (unsigned int)&clk->mpll_lock); |
| 339 | writel(PLL_LOCKTIME, (unsigned int)&clk->epll_lock); |
| 340 | writel(PLL_LOCKTIME, (unsigned int)&clk->vpll_lock); |
| 341 | writel(APLL_CON1_VAL, (unsigned int)&clk->apll_con1); |
| 342 | writel(APLL_CON0_VAL, (unsigned int)&clk->apll_con0); |
| 343 | writel(MPLL_CON1_VAL, (unsigned int)&clk->mpll_con1); |
| 344 | writel(MPLL_CON0_VAL, (unsigned int)&clk->mpll_con0); |
| 345 | writel(EPLL_CON1_VAL, (unsigned int)&clk->epll_con1); |
| 346 | writel(EPLL_CON0_VAL, (unsigned int)&clk->epll_con0); |
| 347 | writel(VPLL_CON1_VAL, (unsigned int)&clk->vpll_con1); |
| 348 | writel(VPLL_CON0_VAL, (unsigned int)&clk->vpll_con0); |
| 349 | |
| 350 | writel(CLK_GATE_IP_CAM_VAL, (unsigned int)&clk->gate_ip_cam); |
| 351 | writel(CLK_GATE_IP_VP_VAL, (unsigned int)&clk->gate_ip_tv); |
| 352 | writel(CLK_GATE_IP_MFC_VAL, (unsigned int)&clk->gate_ip_mfc); |
| 353 | writel(CLK_GATE_IP_G3D_VAL, (unsigned int)&clk->gate_ip_g3d); |
| 354 | writel(CLK_GATE_IP_IMAGE_VAL, (unsigned int)&clk->gate_ip_image); |
| 355 | writel(CLK_GATE_IP_LCD0_VAL, (unsigned int)&clk->gate_ip_lcd0); |
| 356 | writel(CLK_GATE_IP_LCD1_VAL, (unsigned int)&clk->gate_ip_lcd1); |
| 357 | writel(CLK_GATE_IP_FSYS_VAL, (unsigned int)&clk->gate_ip_fsys); |
| 358 | writel(CLK_GATE_IP_GPS_VAL, (unsigned int)&clk->gate_ip_gps); |
| 359 | writel(CLK_GATE_IP_PERIL_VAL, (unsigned int)&clk->gate_ip_peril); |
| 360 | writel(CLK_GATE_IP_PERIR_VAL, (unsigned int)&clk->gate_ip_perir); |
| 361 | writel(CLK_GATE_BLOCK_VAL, (unsigned int)&clk->gate_block); |
| 362 | } |
| 363 | |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 364 | static void board_power_init(void) |
| 365 | { |
| 366 | struct exynos4_power *pwr = |
| 367 | (struct exynos4_power *)samsung_get_base_power(); |
| 368 | |
| 369 | /* PS HOLD */ |
| 370 | writel(EXYNOS4_PS_HOLD_CON_VAL, (unsigned int)&pwr->ps_hold_control); |
| 371 | |
| 372 | /* Set power down */ |
| 373 | writel(0, (unsigned int)&pwr->cam_configuration); |
| 374 | writel(0, (unsigned int)&pwr->tv_configuration); |
| 375 | writel(0, (unsigned int)&pwr->mfc_configuration); |
| 376 | writel(0, (unsigned int)&pwr->g3d_configuration); |
| 377 | writel(0, (unsigned int)&pwr->lcd1_configuration); |
| 378 | writel(0, (unsigned int)&pwr->gps_configuration); |
| 379 | writel(0, (unsigned int)&pwr->gps_alive_configuration); |
Piotr Wilczek | 9b4faf2 | 2012-10-08 20:45:42 +0000 | [diff] [blame] | 380 | |
| 381 | /* It is necessary to power down core 1 */ |
| 382 | /* to successfully boot CPU1 in kernel */ |
| 383 | writel(0, (unsigned int)&pwr->arm_core1_configuration); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 384 | } |
| 385 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 386 | static void exynos_uart_init(void) |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 387 | { |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 388 | /* UART_SEL GPY4[7] (part2) at EXYNOS4 */ |
Simon Glass | 4f83d3d | 2014-10-20 19:48:39 -0600 | [diff] [blame] | 389 | gpio_request(EXYNOS4_GPIO_Y47, "uart_sel"); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 390 | gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP); |
| 391 | gpio_direction_output(EXYNOS4_GPIO_Y47, 1); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 394 | int exynos_early_init_f(void) |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 395 | { |
Minkyu Kang | 5826990 | 2012-01-18 15:56:47 +0900 | [diff] [blame] | 396 | wdt_stop(); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 397 | pmic_reset(); |
| 398 | board_clock_init(); |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 399 | exynos_uart_init(); |
HeungJun, Kim | b4b5468 | 2012-01-16 21:13:05 +0000 | [diff] [blame] | 400 | board_power_init(); |
| 401 | |
| 402 | return 0; |
| 403 | } |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 404 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 405 | int lcd_power(void) |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 406 | { |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 407 | #if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */ |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 408 | int ret = 0; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 409 | struct pmic *p = pmic_get("MAX8997_PMIC"); |
| 410 | if (!p) |
| 411 | return -ENODEV; |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 412 | |
| 413 | if (pmic_probe(p)) |
| 414 | return 0; |
| 415 | |
| 416 | /* LDO15 voltage: 2.2v */ |
| 417 | ret |= pmic_reg_write(p, MAX8997_REG_LDO15CTRL, 0x1c | EN_LDO); |
| 418 | /* LDO13 voltage: 3.0v */ |
| 419 | ret |= pmic_reg_write(p, MAX8997_REG_LDO13CTRL, 0x2c | EN_LDO); |
| 420 | |
| 421 | if (ret) { |
| 422 | puts("MAX8997 LDO setting error!\n"); |
| 423 | return -1; |
| 424 | } |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 425 | #endif |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 426 | return 0; |
| 427 | } |
| 428 | |
Piotr Wilczek | 4efd33a | 2014-03-07 14:59:48 +0100 | [diff] [blame] | 429 | int mipi_power(void) |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 430 | { |
Igor Opaniuk | f7c9176 | 2021-02-09 13:52:45 +0200 | [diff] [blame] | 431 | #if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */ |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 432 | int ret = 0; |
Łukasz Majewski | 1c6dba1 | 2012-11-13 03:21:55 +0000 | [diff] [blame] | 433 | struct pmic *p = pmic_get("MAX8997_PMIC"); |
| 434 | if (!p) |
| 435 | return -ENODEV; |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 436 | |
| 437 | if (pmic_probe(p)) |
| 438 | return 0; |
| 439 | |
| 440 | /* LDO3 voltage: 1.1v */ |
| 441 | ret |= pmic_reg_write(p, MAX8997_REG_LDO3CTRL, 0x6 | EN_LDO); |
| 442 | /* LDO4 voltage: 1.8v */ |
| 443 | ret |= pmic_reg_write(p, MAX8997_REG_LDO4CTRL, 0x14 | EN_LDO); |
| 444 | |
| 445 | if (ret) { |
| 446 | puts("MAX8997 LDO setting error!\n"); |
| 447 | return -1; |
| 448 | } |
Simon Glass | 7bbb7d9 | 2016-11-23 06:34:40 -0700 | [diff] [blame] | 449 | #endif |
Donghwa Lee | 9ad0ddc | 2012-04-05 19:36:27 +0000 | [diff] [blame] | 450 | return 0; |
| 451 | } |