blob: 6efc6f3831dfc84ac8b58c34dc31e0a2d789df0e [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
HeungJun, Kimb4b54682012-01-16 21:13:05 +00002/*
3 * Copyright (C) 2011 Samsung Electronics
4 * Heungjun Kim <riverful.kim@samsung.com>
5 * Kyungmin Park <kyungmin.park@samsung.com>
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +00006 * Donghwa Lee <dh09.lee@samsung.com>
HeungJun, Kimb4b54682012-01-16 21:13:05 +00007 */
8
Simon Glass5e6201b2019-08-01 09:46:51 -06009#include <env.h>
Simon Glass0f2af882020-05-10 11:40:05 -060010#include <log.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000011#include <asm/io.h>
Simon Glass37f11622014-10-20 19:48:37 -060012#include <asm/gpio.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000013#include <asm/arch/cpu.h>
Piotr Wilczek3c8b71d2012-09-20 00:19:58 +000014#include <asm/arch/pinmux.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000015#include <asm/arch/clock.h>
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +000016#include <asm/arch/mipi_dsim.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000017#include <asm/arch/watchdog.h>
18#include <asm/arch/power.h>
Simon Glassdbd79542020-05-10 11:40:11 -060019#include <linux/delay.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000020#include <power/pmic.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010021#include <usb/dwc2_udc.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000022#include <power/max8997_pmic.h>
Łukasz Majewski40e330a2012-11-13 03:22:06 +000023#include <power/max8997_muic.h>
Łukasz Majewskie4a182a2012-11-13 03:22:08 +000024#include <power/battery.h>
Łukasz Majewski7aba6a12012-11-13 03:22:07 +000025#include <power/max17042_fg.h>
Jaehoon Chungc43173c2017-03-30 21:29:59 +090026#include <power/pmic.h>
Piotr Wilczek4efd33a2014-03-07 14:59:48 +010027#include <libtizen.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020028#include <usb.h>
Lukasz Majewski0a4d8a92013-03-05 12:10:18 +010029#include <usb_mass_storage.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000030
31#include "setup.h"
32
HeungJun, Kimb4b54682012-01-16 21:13:05 +000033unsigned int board_rev;
34
35#ifdef CONFIG_REVISION_TAG
36u32 get_board_rev(void)
37{
38 return board_rev;
39}
40#endif
41
Marek Vasut6939aca2015-12-04 02:23:29 +010042struct dwc2_plat_otg_data s5pc210_otg_data;
Lukasz Majewski51de1762012-08-06 14:41:10 +020043
Igor Opaniukf7c91762021-02-09 13:52:45 +020044#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskib6a3dc62012-11-13 03:22:10 +000045static void trats_low_power_mode(void)
46{
47 struct exynos4_clock *clk =
48 (struct exynos4_clock *)samsung_get_base_clock();
49 struct exynos4_power *pwr =
50 (struct exynos4_power *)samsung_get_base_power();
51
52 /* Power down CORE1 */
53 /* LOCAL_PWR_CFG [1:0] 0x3 EN, 0x0 DIS */
54 writel(0x0, &pwr->arm_core1_configuration);
55
56 /* Change the APLL frequency */
57 /* ENABLE (1 enable) | LOCKED (1 locked) */
58 /* [31] | [29] */
59 /* FSEL | MDIV | PDIV | SDIV */
60 /* [27] | [25:16] | [13:8] | [2:0] */
61 writel(0xa0c80604, &clk->apll_con0);
62
63 /* Change CPU0 clock divider */
64 /* CORE2_RATIO | APLL_RATIO | PCLK_DBG_RATIO | ATB_RATIO */
65 /* [30:28] | [26:24] | [22:20] | [18:16] */
66 /* PERIPH_RATIO | COREM1_RATIO | COREM0_RATIO | CORE_RATIO */
67 /* [14:12] | [10:8] | [6:4] | [2:0] */
68 writel(0x00000100, &clk->div_cpu0);
69
70 /* CLK_DIV_STAT_CPU0 - wait until clock gets stable (0 = stable) */
71 while (readl(&clk->div_stat_cpu0) & 0x1111111)
72 continue;
73
74 /* Change clock divider ratio for DMC */
75 /* DMCP_RATIO | DMCD_RATIO */
76 /* [22:20] | [18:16] */
77 /* DMC_RATIO | DPHY_RATIO | ACP_PCLK_RATIO | ACP_RATIO */
78 /* [14:12] | [10:8] | [6:4] | [2:0] */
79 writel(0x13113117, &clk->div_dmc0);
80
81 /* CLK_DIV_STAT_DMC0 - wait until clock gets stable (0 = stable) */
82 while (readl(&clk->div_stat_dmc0) & 0x11111111)
83 continue;
84
85 /* Turn off unnecessary power domains */
86 writel(0x0, &pwr->xxti_configuration); /* XXTI */
87 writel(0x0, &pwr->cam_configuration); /* CAM */
88 writel(0x0, &pwr->tv_configuration); /* TV */
89 writel(0x0, &pwr->mfc_configuration); /* MFC */
90 writel(0x0, &pwr->g3d_configuration); /* G3D */
91 writel(0x0, &pwr->gps_configuration); /* GPS */
92 writel(0x0, &pwr->gps_alive_configuration); /* GPS_ALIVE */
93
94 /* Turn off unnecessary clocks */
95 writel(0x0, &clk->gate_ip_cam); /* CAM */
96 writel(0x0, &clk->gate_ip_tv); /* TV */
97 writel(0x0, &clk->gate_ip_mfc); /* MFC */
98 writel(0x0, &clk->gate_ip_g3d); /* G3D */
99 writel(0x0, &clk->gate_ip_image); /* IMAGE */
100 writel(0x0, &clk->gate_ip_gps); /* GPS */
101}
Simon Glass7bbb7d92016-11-23 06:34:40 -0700102#endif
Łukasz Majewskid72e0ae2012-11-13 03:22:05 +0000103
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100104int exynos_power_init(void)
Łukasz Majewskifa627662012-11-13 03:21:57 +0000105{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200106#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000107 int chrg, ret;
108 struct power_battery *pb;
109 struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
Łukasz Majewskifa627662012-11-13 03:21:57 +0000110
Łukasz Majewskide55e752013-08-16 15:33:33 +0200111 /*
112 * For PMIC/MUIC the I2C bus is named as I2C5, but it is connected
113 * to logical I2C adapter 0
114 *
115 * The FUEL_GAUGE is marked as I2C9 on the schematic, but connected
116 * to logical I2C adapter 1
117 */
Jaehoon Chungc7475702017-03-30 21:29:58 +0900118 ret = power_fg_init(I2C_9);
Piotr Wilczek58bbd2b2013-11-20 10:43:49 +0100119 ret |= power_muic_init(I2C_5);
Łukasz Majewskie4a182a2012-11-13 03:22:08 +0000120 ret |= power_bat_init(0);
Łukasz Majewskifa627662012-11-13 03:21:57 +0000121 if (ret)
122 return ret;
123
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000124 p_fg = pmic_get("MAX17042_FG");
125 if (!p_fg) {
126 puts("MAX17042_FG: Not found\n");
127 return -ENODEV;
128 }
129
130 p_chrg = pmic_get("MAX8997_PMIC");
131 if (!p_chrg) {
132 puts("MAX8997_PMIC: Not found\n");
133 return -ENODEV;
134 }
135
136 p_muic = pmic_get("MAX8997_MUIC");
137 if (!p_muic) {
138 puts("MAX8997_MUIC: Not found\n");
139 return -ENODEV;
140 }
141
142 p_bat = pmic_get("BAT_TRATS");
143 if (!p_bat) {
144 puts("BAT_TRATS: Not found\n");
145 return -ENODEV;
146 }
147
148 p_fg->parent = p_bat;
149 p_chrg->parent = p_bat;
150 p_muic->parent = p_bat;
151
152 p_bat->low_power_mode = trats_low_power_mode;
153 p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
154
155 pb = p_bat->pbat;
156 chrg = p_muic->chrg->chrg_type(p_muic);
157 debug("CHARGER TYPE: %d\n", chrg);
158
159 if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
160 puts("No battery detected\n");
Przemyslaw Marczakdd0c48e2014-06-10 16:55:08 +0200161 return 0;
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000162 }
163
164 p_fg->fg->fg_battery_check(p_fg, p_bat);
165
166 if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
167 puts("CHARGE Battery !\n");
Simon Glass7bbb7d92016-11-23 06:34:40 -0700168#endif
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000169
Łukasz Majewskifa627662012-11-13 03:21:57 +0000170 return 0;
171}
172
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000173static unsigned int get_hw_revision(void)
174{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000175 int hwrev = 0;
Simon Glass4f83d3d2014-10-20 19:48:39 -0600176 char str[10];
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000177 int i;
178
179 /* hw_rev[3:0] == GPE1[3:0] */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600180 for (i = 0; i < 4; i++) {
181 int pin = i + EXYNOS4_GPIO_E10;
182
183 sprintf(str, "hw_rev%d", i);
184 gpio_request(pin, str);
185 gpio_cfg_pin(pin, S5P_GPIO_INPUT);
186 gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000187 }
188
189 udelay(1);
190
191 for (i = 0; i < 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530192 hwrev |= (gpio_get_value(EXYNOS4_GPIO_E10 + i) << i);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000193
194 debug("hwrev 0x%x\n", hwrev);
195
196 return hwrev;
197}
198
199static void check_hw_revision(void)
200{
201 int hwrev;
202
203 hwrev = get_hw_revision();
204
205 board_rev |= hwrev;
206}
207
Tom Rini757dc982023-09-21 19:32:48 -0400208void exynos_init(void)
209{
210 check_hw_revision();
211 printf("HW Revision:\t0x%x\n", board_rev);
212}
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000213
214#ifdef CONFIG_USB_GADGET
215static int s5pc210_phy_control(int on)
216{
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900217 struct udevice *dev;
218 int reg, ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000219
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900220 ret = pmic_get("max8997-pmic", &dev);
221 if (ret)
222 return ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000223
224 if (on) {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900225 reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL);
226 reg |= ENSAFEOUT1;
227 ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg);
228 if (ret) {
229 puts("MAX8997 setting error!\n");
230 return ret;
231 }
232 reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL);
233 reg |= EN_LDO;
234 ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg);
235 if (ret) {
236 puts("MAX8997 setting error!\n");
237 return ret;
238 }
239 reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL);
240 reg |= EN_LDO;
241 ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg);
242 if (ret) {
243 puts("MAX8997 setting error!\n");
244 return ret;
245 }
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000246 } else {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900247 reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL);
248 reg &= DIS_LDO;
249 ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg);
250 if (ret) {
251 puts("MAX8997 setting error!\n");
252 return ret;
253 }
254 reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL);
255 reg &= DIS_LDO;
256 ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg);
257 if (ret) {
258 puts("MAX8997 setting error!\n");
259 return ret;
260 }
261 reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL);
262 reg &= ~ENSAFEOUT1;
263 ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg);
264 if (ret) {
265 puts("MAX8997 setting error!\n");
266 return ret;
267 }
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000268
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000269 }
270
271 return 0;
272}
273
Marek Vasut6939aca2015-12-04 02:23:29 +0100274struct dwc2_plat_otg_data s5pc210_otg_data = {
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000275 .phy_control = s5pc210_phy_control,
276 .regs_phy = EXYNOS4_USBPHY_BASE,
277 .regs_otg = EXYNOS4_USBOTG_BASE,
278 .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL,
279 .usb_flags = PHY0_SLEEP,
280};
Lukasz Majewski51de1762012-08-06 14:41:10 +0200281
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700282int board_usb_init(int index, enum usb_init_type init)
Lukasz Majewski51de1762012-08-06 14:41:10 +0200283{
284 debug("USB_udc_probe\n");
Marek Vasut01b61fa2015-12-04 02:26:33 +0100285 return dwc2_udc_probe(&s5pc210_otg_data);
Lukasz Majewski51de1762012-08-06 14:41:10 +0200286}
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100287
Mateusz Zalega21fe3f72014-04-30 13:07:48 +0200288int g_dnl_board_usb_cable_connected(void)
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100289{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200290#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100291 struct pmic *muic = pmic_get("MAX8997_MUIC");
292 if (!muic)
293 return 0;
294
295 return !!muic->chrg->chrg_type(muic);
Simon Glass7bbb7d92016-11-23 06:34:40 -0700296#else
297 return false;
298#endif
299
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100300}
301#endif
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000302
303static void pmic_reset(void)
304{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530305 gpio_direction_output(EXYNOS4_GPIO_X07, 1);
306 gpio_set_pull(EXYNOS4_GPIO_X27, S5P_GPIO_PULL_NONE);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000307}
308
309static void board_clock_init(void)
310{
311 struct exynos4_clock *clk =
312 (struct exynos4_clock *)samsung_get_base_clock();
313
314 writel(CLK_SRC_CPU_VAL, (unsigned int)&clk->src_cpu);
315 writel(CLK_SRC_TOP0_VAL, (unsigned int)&clk->src_top0);
316 writel(CLK_SRC_FSYS_VAL, (unsigned int)&clk->src_fsys);
317 writel(CLK_SRC_PERIL0_VAL, (unsigned int)&clk->src_peril0);
318
319 writel(CLK_DIV_CPU0_VAL, (unsigned int)&clk->div_cpu0);
320 writel(CLK_DIV_CPU1_VAL, (unsigned int)&clk->div_cpu1);
321 writel(CLK_DIV_DMC0_VAL, (unsigned int)&clk->div_dmc0);
322 writel(CLK_DIV_DMC1_VAL, (unsigned int)&clk->div_dmc1);
323 writel(CLK_DIV_LEFTBUS_VAL, (unsigned int)&clk->div_leftbus);
324 writel(CLK_DIV_RIGHTBUS_VAL, (unsigned int)&clk->div_rightbus);
325 writel(CLK_DIV_TOP_VAL, (unsigned int)&clk->div_top);
326 writel(CLK_DIV_FSYS1_VAL, (unsigned int)&clk->div_fsys1);
327 writel(CLK_DIV_FSYS2_VAL, (unsigned int)&clk->div_fsys2);
328 writel(CLK_DIV_FSYS3_VAL, (unsigned int)&clk->div_fsys3);
329 writel(CLK_DIV_PERIL0_VAL, (unsigned int)&clk->div_peril0);
330 writel(CLK_DIV_PERIL3_VAL, (unsigned int)&clk->div_peril3);
331
332 writel(PLL_LOCKTIME, (unsigned int)&clk->apll_lock);
333 writel(PLL_LOCKTIME, (unsigned int)&clk->mpll_lock);
334 writel(PLL_LOCKTIME, (unsigned int)&clk->epll_lock);
335 writel(PLL_LOCKTIME, (unsigned int)&clk->vpll_lock);
336 writel(APLL_CON1_VAL, (unsigned int)&clk->apll_con1);
337 writel(APLL_CON0_VAL, (unsigned int)&clk->apll_con0);
338 writel(MPLL_CON1_VAL, (unsigned int)&clk->mpll_con1);
339 writel(MPLL_CON0_VAL, (unsigned int)&clk->mpll_con0);
340 writel(EPLL_CON1_VAL, (unsigned int)&clk->epll_con1);
341 writel(EPLL_CON0_VAL, (unsigned int)&clk->epll_con0);
342 writel(VPLL_CON1_VAL, (unsigned int)&clk->vpll_con1);
343 writel(VPLL_CON0_VAL, (unsigned int)&clk->vpll_con0);
344
345 writel(CLK_GATE_IP_CAM_VAL, (unsigned int)&clk->gate_ip_cam);
346 writel(CLK_GATE_IP_VP_VAL, (unsigned int)&clk->gate_ip_tv);
347 writel(CLK_GATE_IP_MFC_VAL, (unsigned int)&clk->gate_ip_mfc);
348 writel(CLK_GATE_IP_G3D_VAL, (unsigned int)&clk->gate_ip_g3d);
349 writel(CLK_GATE_IP_IMAGE_VAL, (unsigned int)&clk->gate_ip_image);
350 writel(CLK_GATE_IP_LCD0_VAL, (unsigned int)&clk->gate_ip_lcd0);
351 writel(CLK_GATE_IP_LCD1_VAL, (unsigned int)&clk->gate_ip_lcd1);
352 writel(CLK_GATE_IP_FSYS_VAL, (unsigned int)&clk->gate_ip_fsys);
353 writel(CLK_GATE_IP_GPS_VAL, (unsigned int)&clk->gate_ip_gps);
354 writel(CLK_GATE_IP_PERIL_VAL, (unsigned int)&clk->gate_ip_peril);
355 writel(CLK_GATE_IP_PERIR_VAL, (unsigned int)&clk->gate_ip_perir);
356 writel(CLK_GATE_BLOCK_VAL, (unsigned int)&clk->gate_block);
357}
358
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000359static void board_power_init(void)
360{
361 struct exynos4_power *pwr =
362 (struct exynos4_power *)samsung_get_base_power();
363
364 /* PS HOLD */
365 writel(EXYNOS4_PS_HOLD_CON_VAL, (unsigned int)&pwr->ps_hold_control);
366
367 /* Set power down */
368 writel(0, (unsigned int)&pwr->cam_configuration);
369 writel(0, (unsigned int)&pwr->tv_configuration);
370 writel(0, (unsigned int)&pwr->mfc_configuration);
371 writel(0, (unsigned int)&pwr->g3d_configuration);
372 writel(0, (unsigned int)&pwr->lcd1_configuration);
373 writel(0, (unsigned int)&pwr->gps_configuration);
374 writel(0, (unsigned int)&pwr->gps_alive_configuration);
Piotr Wilczek9b4faf22012-10-08 20:45:42 +0000375
376 /* It is necessary to power down core 1 */
377 /* to successfully boot CPU1 in kernel */
378 writel(0, (unsigned int)&pwr->arm_core1_configuration);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000379}
380
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100381static void exynos_uart_init(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000382{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000383 /* UART_SEL GPY4[7] (part2) at EXYNOS4 */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600384 gpio_request(EXYNOS4_GPIO_Y47, "uart_sel");
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530385 gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP);
386 gpio_direction_output(EXYNOS4_GPIO_Y47, 1);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000387}
388
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100389int exynos_early_init_f(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000390{
Minkyu Kang58269902012-01-18 15:56:47 +0900391 wdt_stop();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000392 pmic_reset();
393 board_clock_init();
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100394 exynos_uart_init();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000395 board_power_init();
396
397 return 0;
398}
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000399
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100400int lcd_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000401{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200402#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000403 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000404 struct pmic *p = pmic_get("MAX8997_PMIC");
405 if (!p)
406 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000407
408 if (pmic_probe(p))
409 return 0;
410
411 /* LDO15 voltage: 2.2v */
412 ret |= pmic_reg_write(p, MAX8997_REG_LDO15CTRL, 0x1c | EN_LDO);
413 /* LDO13 voltage: 3.0v */
414 ret |= pmic_reg_write(p, MAX8997_REG_LDO13CTRL, 0x2c | EN_LDO);
415
416 if (ret) {
417 puts("MAX8997 LDO setting error!\n");
418 return -1;
419 }
Simon Glass7bbb7d92016-11-23 06:34:40 -0700420#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000421 return 0;
422}
423
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100424int mipi_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000425{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200426#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000427 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000428 struct pmic *p = pmic_get("MAX8997_PMIC");
429 if (!p)
430 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000431
432 if (pmic_probe(p))
433 return 0;
434
435 /* LDO3 voltage: 1.1v */
436 ret |= pmic_reg_write(p, MAX8997_REG_LDO3CTRL, 0x6 | EN_LDO);
437 /* LDO4 voltage: 1.8v */
438 ret |= pmic_reg_write(p, MAX8997_REG_LDO4CTRL, 0x14 | EN_LDO);
439
440 if (ret) {
441 puts("MAX8997 LDO setting error!\n");
442 return -1;
443 }
Simon Glass7bbb7d92016-11-23 06:34:40 -0700444#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000445 return 0;
446}