blob: 6a3e5b29b9894c0f292ad3a44e6f845751106857 [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
9#include <common.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060010#include <env.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000012#include <asm/io.h>
Simon Glass37f11622014-10-20 19:48:37 -060013#include <asm/gpio.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000014#include <asm/arch/cpu.h>
Piotr Wilczek3c8b71d2012-09-20 00:19:58 +000015#include <asm/arch/pinmux.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000016#include <asm/arch/clock.h>
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +000017#include <asm/arch/mipi_dsim.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000018#include <asm/arch/watchdog.h>
19#include <asm/arch/power.h>
Simon Glassdbd79542020-05-10 11:40:11 -060020#include <linux/delay.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000021#include <power/pmic.h>
Marek Vasutf1be9cb2015-12-04 02:51:20 +010022#include <usb/dwc2_udc.h>
Łukasz Majewski1c6dba12012-11-13 03:21:55 +000023#include <power/max8997_pmic.h>
Łukasz Majewski40e330a2012-11-13 03:22:06 +000024#include <power/max8997_muic.h>
Łukasz Majewskie4a182a2012-11-13 03:22:08 +000025#include <power/battery.h>
Łukasz Majewski7aba6a12012-11-13 03:22:07 +000026#include <power/max17042_fg.h>
Jaehoon Chungc43173c2017-03-30 21:29:59 +090027#include <power/pmic.h>
Piotr Wilczek4efd33a2014-03-07 14:59:48 +010028#include <libtizen.h>
Mateusz Zalegad862f892013-10-04 19:22:26 +020029#include <usb.h>
Lukasz Majewski0a4d8a92013-03-05 12:10:18 +010030#include <usb_mass_storage.h>
HeungJun, Kimb4b54682012-01-16 21:13:05 +000031
32#include "setup.h"
33
HeungJun, Kimb4b54682012-01-16 21:13:05 +000034unsigned int board_rev;
35
36#ifdef CONFIG_REVISION_TAG
37u32 get_board_rev(void)
38{
39 return board_rev;
40}
41#endif
42
Marek Vasut6939aca2015-12-04 02:23:29 +010043struct dwc2_plat_otg_data s5pc210_otg_data;
Lukasz Majewski51de1762012-08-06 14:41:10 +020044
Igor Opaniukf7c91762021-02-09 13:52:45 +020045#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskib6a3dc62012-11-13 03:22:10 +000046static void trats_low_power_mode(void)
47{
48 struct exynos4_clock *clk =
49 (struct exynos4_clock *)samsung_get_base_clock();
50 struct exynos4_power *pwr =
51 (struct exynos4_power *)samsung_get_base_power();
52
53 /* Power down CORE1 */
54 /* LOCAL_PWR_CFG [1:0] 0x3 EN, 0x0 DIS */
55 writel(0x0, &pwr->arm_core1_configuration);
56
57 /* Change the APLL frequency */
58 /* ENABLE (1 enable) | LOCKED (1 locked) */
59 /* [31] | [29] */
60 /* FSEL | MDIV | PDIV | SDIV */
61 /* [27] | [25:16] | [13:8] | [2:0] */
62 writel(0xa0c80604, &clk->apll_con0);
63
64 /* Change CPU0 clock divider */
65 /* CORE2_RATIO | APLL_RATIO | PCLK_DBG_RATIO | ATB_RATIO */
66 /* [30:28] | [26:24] | [22:20] | [18:16] */
67 /* PERIPH_RATIO | COREM1_RATIO | COREM0_RATIO | CORE_RATIO */
68 /* [14:12] | [10:8] | [6:4] | [2:0] */
69 writel(0x00000100, &clk->div_cpu0);
70
71 /* CLK_DIV_STAT_CPU0 - wait until clock gets stable (0 = stable) */
72 while (readl(&clk->div_stat_cpu0) & 0x1111111)
73 continue;
74
75 /* Change clock divider ratio for DMC */
76 /* DMCP_RATIO | DMCD_RATIO */
77 /* [22:20] | [18:16] */
78 /* DMC_RATIO | DPHY_RATIO | ACP_PCLK_RATIO | ACP_RATIO */
79 /* [14:12] | [10:8] | [6:4] | [2:0] */
80 writel(0x13113117, &clk->div_dmc0);
81
82 /* CLK_DIV_STAT_DMC0 - wait until clock gets stable (0 = stable) */
83 while (readl(&clk->div_stat_dmc0) & 0x11111111)
84 continue;
85
86 /* Turn off unnecessary power domains */
87 writel(0x0, &pwr->xxti_configuration); /* XXTI */
88 writel(0x0, &pwr->cam_configuration); /* CAM */
89 writel(0x0, &pwr->tv_configuration); /* TV */
90 writel(0x0, &pwr->mfc_configuration); /* MFC */
91 writel(0x0, &pwr->g3d_configuration); /* G3D */
92 writel(0x0, &pwr->gps_configuration); /* GPS */
93 writel(0x0, &pwr->gps_alive_configuration); /* GPS_ALIVE */
94
95 /* Turn off unnecessary clocks */
96 writel(0x0, &clk->gate_ip_cam); /* CAM */
97 writel(0x0, &clk->gate_ip_tv); /* TV */
98 writel(0x0, &clk->gate_ip_mfc); /* MFC */
99 writel(0x0, &clk->gate_ip_g3d); /* G3D */
100 writel(0x0, &clk->gate_ip_image); /* IMAGE */
101 writel(0x0, &clk->gate_ip_gps); /* GPS */
102}
Simon Glass7bbb7d92016-11-23 06:34:40 -0700103#endif
Łukasz Majewskid72e0ae2012-11-13 03:22:05 +0000104
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100105int exynos_power_init(void)
Łukasz Majewskifa627662012-11-13 03:21:57 +0000106{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200107#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000108 int chrg, ret;
109 struct power_battery *pb;
110 struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
Łukasz Majewskifa627662012-11-13 03:21:57 +0000111
Łukasz Majewskide55e752013-08-16 15:33:33 +0200112 /*
113 * For PMIC/MUIC the I2C bus is named as I2C5, but it is connected
114 * to logical I2C adapter 0
115 *
116 * The FUEL_GAUGE is marked as I2C9 on the schematic, but connected
117 * to logical I2C adapter 1
118 */
Jaehoon Chungc7475702017-03-30 21:29:58 +0900119 ret = power_fg_init(I2C_9);
Piotr Wilczek58bbd2b2013-11-20 10:43:49 +0100120 ret |= power_muic_init(I2C_5);
Łukasz Majewskie4a182a2012-11-13 03:22:08 +0000121 ret |= power_bat_init(0);
Łukasz Majewskifa627662012-11-13 03:21:57 +0000122 if (ret)
123 return ret;
124
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000125 p_fg = pmic_get("MAX17042_FG");
126 if (!p_fg) {
127 puts("MAX17042_FG: Not found\n");
128 return -ENODEV;
129 }
130
131 p_chrg = pmic_get("MAX8997_PMIC");
132 if (!p_chrg) {
133 puts("MAX8997_PMIC: Not found\n");
134 return -ENODEV;
135 }
136
137 p_muic = pmic_get("MAX8997_MUIC");
138 if (!p_muic) {
139 puts("MAX8997_MUIC: Not found\n");
140 return -ENODEV;
141 }
142
143 p_bat = pmic_get("BAT_TRATS");
144 if (!p_bat) {
145 puts("BAT_TRATS: Not found\n");
146 return -ENODEV;
147 }
148
149 p_fg->parent = p_bat;
150 p_chrg->parent = p_bat;
151 p_muic->parent = p_bat;
152
153 p_bat->low_power_mode = trats_low_power_mode;
154 p_bat->pbat->battery_init(p_bat, p_fg, p_chrg, p_muic);
155
156 pb = p_bat->pbat;
157 chrg = p_muic->chrg->chrg_type(p_muic);
158 debug("CHARGER TYPE: %d\n", chrg);
159
160 if (!p_chrg->chrg->chrg_bat_present(p_chrg)) {
161 puts("No battery detected\n");
Przemyslaw Marczakdd0c48e2014-06-10 16:55:08 +0200162 return 0;
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000163 }
164
165 p_fg->fg->fg_battery_check(p_fg, p_bat);
166
167 if (pb->bat->state == CHARGE && chrg == CHARGER_USB)
168 puts("CHARGE Battery !\n");
Simon Glass7bbb7d92016-11-23 06:34:40 -0700169#endif
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000170
Łukasz Majewskifa627662012-11-13 03:21:57 +0000171 return 0;
172}
173
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000174static unsigned int get_hw_revision(void)
175{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000176 int hwrev = 0;
Simon Glass4f83d3d2014-10-20 19:48:39 -0600177 char str[10];
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000178 int i;
179
180 /* hw_rev[3:0] == GPE1[3:0] */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600181 for (i = 0; i < 4; i++) {
182 int pin = i + EXYNOS4_GPIO_E10;
183
184 sprintf(str, "hw_rev%d", i);
185 gpio_request(pin, str);
186 gpio_cfg_pin(pin, S5P_GPIO_INPUT);
187 gpio_set_pull(pin, S5P_GPIO_PULL_NONE);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000188 }
189
190 udelay(1);
191
192 for (i = 0; i < 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530193 hwrev |= (gpio_get_value(EXYNOS4_GPIO_E10 + i) << i);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000194
195 debug("hwrev 0x%x\n", hwrev);
196
197 return hwrev;
198}
199
200static void check_hw_revision(void)
201{
202 int hwrev;
203
204 hwrev = get_hw_revision();
205
206 board_rev |= hwrev;
207}
208
Tom Rini757dc982023-09-21 19:32:48 -0400209void exynos_init(void)
210{
211 check_hw_revision();
212 printf("HW Revision:\t0x%x\n", board_rev);
213}
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000214
215#ifdef CONFIG_USB_GADGET
216static int s5pc210_phy_control(int on)
217{
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900218 struct udevice *dev;
219 int reg, ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000220
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900221 ret = pmic_get("max8997-pmic", &dev);
222 if (ret)
223 return ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000224
225 if (on) {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900226 reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL);
227 reg |= ENSAFEOUT1;
228 ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg);
229 if (ret) {
230 puts("MAX8997 setting error!\n");
231 return ret;
232 }
233 reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL);
234 reg |= EN_LDO;
235 ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg);
236 if (ret) {
237 puts("MAX8997 setting error!\n");
238 return ret;
239 }
240 reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL);
241 reg |= EN_LDO;
242 ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg);
243 if (ret) {
244 puts("MAX8997 setting error!\n");
245 return ret;
246 }
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000247 } else {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900248 reg = pmic_reg_read(dev, MAX8997_REG_LDO8CTRL);
249 reg &= DIS_LDO;
250 ret = pmic_reg_write(dev, MAX8997_REG_LDO8CTRL, reg);
251 if (ret) {
252 puts("MAX8997 setting error!\n");
253 return ret;
254 }
255 reg = pmic_reg_read(dev, MAX8997_REG_LDO3CTRL);
256 reg &= DIS_LDO;
257 ret = pmic_reg_write(dev, MAX8997_REG_LDO3CTRL, reg);
258 if (ret) {
259 puts("MAX8997 setting error!\n");
260 return ret;
261 }
262 reg = pmic_reg_read(dev, MAX8997_REG_SAFEOUTCTRL);
263 reg &= ~ENSAFEOUT1;
264 ret = pmic_reg_write(dev, MAX8997_REG_SAFEOUTCTRL, reg);
265 if (ret) {
266 puts("MAX8997 setting error!\n");
267 return ret;
268 }
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000269
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000270 }
271
272 return 0;
273}
274
Marek Vasut6939aca2015-12-04 02:23:29 +0100275struct dwc2_plat_otg_data s5pc210_otg_data = {
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000276 .phy_control = s5pc210_phy_control,
277 .regs_phy = EXYNOS4_USBPHY_BASE,
278 .regs_otg = EXYNOS4_USBOTG_BASE,
279 .usb_phy_ctrl = EXYNOS4_USBPHY_CONTROL,
280 .usb_flags = PHY0_SLEEP,
281};
Lukasz Majewski51de1762012-08-06 14:41:10 +0200282
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700283int board_usb_init(int index, enum usb_init_type init)
Lukasz Majewski51de1762012-08-06 14:41:10 +0200284{
285 debug("USB_udc_probe\n");
Marek Vasut01b61fa2015-12-04 02:26:33 +0100286 return dwc2_udc_probe(&s5pc210_otg_data);
Lukasz Majewski51de1762012-08-06 14:41:10 +0200287}
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100288
Mateusz Zalega21fe3f72014-04-30 13:07:48 +0200289int g_dnl_board_usb_cable_connected(void)
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100290{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200291#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100292 struct pmic *muic = pmic_get("MAX8997_MUIC");
293 if (!muic)
294 return 0;
295
296 return !!muic->chrg->chrg_type(muic);
Simon Glass7bbb7d92016-11-23 06:34:40 -0700297#else
298 return false;
299#endif
300
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100301}
302#endif
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000303
304static void pmic_reset(void)
305{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530306 gpio_direction_output(EXYNOS4_GPIO_X07, 1);
307 gpio_set_pull(EXYNOS4_GPIO_X27, S5P_GPIO_PULL_NONE);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000308}
309
310static void board_clock_init(void)
311{
312 struct exynos4_clock *clk =
313 (struct exynos4_clock *)samsung_get_base_clock();
314
315 writel(CLK_SRC_CPU_VAL, (unsigned int)&clk->src_cpu);
316 writel(CLK_SRC_TOP0_VAL, (unsigned int)&clk->src_top0);
317 writel(CLK_SRC_FSYS_VAL, (unsigned int)&clk->src_fsys);
318 writel(CLK_SRC_PERIL0_VAL, (unsigned int)&clk->src_peril0);
319
320 writel(CLK_DIV_CPU0_VAL, (unsigned int)&clk->div_cpu0);
321 writel(CLK_DIV_CPU1_VAL, (unsigned int)&clk->div_cpu1);
322 writel(CLK_DIV_DMC0_VAL, (unsigned int)&clk->div_dmc0);
323 writel(CLK_DIV_DMC1_VAL, (unsigned int)&clk->div_dmc1);
324 writel(CLK_DIV_LEFTBUS_VAL, (unsigned int)&clk->div_leftbus);
325 writel(CLK_DIV_RIGHTBUS_VAL, (unsigned int)&clk->div_rightbus);
326 writel(CLK_DIV_TOP_VAL, (unsigned int)&clk->div_top);
327 writel(CLK_DIV_FSYS1_VAL, (unsigned int)&clk->div_fsys1);
328 writel(CLK_DIV_FSYS2_VAL, (unsigned int)&clk->div_fsys2);
329 writel(CLK_DIV_FSYS3_VAL, (unsigned int)&clk->div_fsys3);
330 writel(CLK_DIV_PERIL0_VAL, (unsigned int)&clk->div_peril0);
331 writel(CLK_DIV_PERIL3_VAL, (unsigned int)&clk->div_peril3);
332
333 writel(PLL_LOCKTIME, (unsigned int)&clk->apll_lock);
334 writel(PLL_LOCKTIME, (unsigned int)&clk->mpll_lock);
335 writel(PLL_LOCKTIME, (unsigned int)&clk->epll_lock);
336 writel(PLL_LOCKTIME, (unsigned int)&clk->vpll_lock);
337 writel(APLL_CON1_VAL, (unsigned int)&clk->apll_con1);
338 writel(APLL_CON0_VAL, (unsigned int)&clk->apll_con0);
339 writel(MPLL_CON1_VAL, (unsigned int)&clk->mpll_con1);
340 writel(MPLL_CON0_VAL, (unsigned int)&clk->mpll_con0);
341 writel(EPLL_CON1_VAL, (unsigned int)&clk->epll_con1);
342 writel(EPLL_CON0_VAL, (unsigned int)&clk->epll_con0);
343 writel(VPLL_CON1_VAL, (unsigned int)&clk->vpll_con1);
344 writel(VPLL_CON0_VAL, (unsigned int)&clk->vpll_con0);
345
346 writel(CLK_GATE_IP_CAM_VAL, (unsigned int)&clk->gate_ip_cam);
347 writel(CLK_GATE_IP_VP_VAL, (unsigned int)&clk->gate_ip_tv);
348 writel(CLK_GATE_IP_MFC_VAL, (unsigned int)&clk->gate_ip_mfc);
349 writel(CLK_GATE_IP_G3D_VAL, (unsigned int)&clk->gate_ip_g3d);
350 writel(CLK_GATE_IP_IMAGE_VAL, (unsigned int)&clk->gate_ip_image);
351 writel(CLK_GATE_IP_LCD0_VAL, (unsigned int)&clk->gate_ip_lcd0);
352 writel(CLK_GATE_IP_LCD1_VAL, (unsigned int)&clk->gate_ip_lcd1);
353 writel(CLK_GATE_IP_FSYS_VAL, (unsigned int)&clk->gate_ip_fsys);
354 writel(CLK_GATE_IP_GPS_VAL, (unsigned int)&clk->gate_ip_gps);
355 writel(CLK_GATE_IP_PERIL_VAL, (unsigned int)&clk->gate_ip_peril);
356 writel(CLK_GATE_IP_PERIR_VAL, (unsigned int)&clk->gate_ip_perir);
357 writel(CLK_GATE_BLOCK_VAL, (unsigned int)&clk->gate_block);
358}
359
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000360static void board_power_init(void)
361{
362 struct exynos4_power *pwr =
363 (struct exynos4_power *)samsung_get_base_power();
364
365 /* PS HOLD */
366 writel(EXYNOS4_PS_HOLD_CON_VAL, (unsigned int)&pwr->ps_hold_control);
367
368 /* Set power down */
369 writel(0, (unsigned int)&pwr->cam_configuration);
370 writel(0, (unsigned int)&pwr->tv_configuration);
371 writel(0, (unsigned int)&pwr->mfc_configuration);
372 writel(0, (unsigned int)&pwr->g3d_configuration);
373 writel(0, (unsigned int)&pwr->lcd1_configuration);
374 writel(0, (unsigned int)&pwr->gps_configuration);
375 writel(0, (unsigned int)&pwr->gps_alive_configuration);
Piotr Wilczek9b4faf22012-10-08 20:45:42 +0000376
377 /* It is necessary to power down core 1 */
378 /* to successfully boot CPU1 in kernel */
379 writel(0, (unsigned int)&pwr->arm_core1_configuration);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000380}
381
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100382static void exynos_uart_init(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000383{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000384 /* UART_SEL GPY4[7] (part2) at EXYNOS4 */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600385 gpio_request(EXYNOS4_GPIO_Y47, "uart_sel");
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530386 gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP);
387 gpio_direction_output(EXYNOS4_GPIO_Y47, 1);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000388}
389
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100390int exynos_early_init_f(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000391{
Minkyu Kang58269902012-01-18 15:56:47 +0900392 wdt_stop();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000393 pmic_reset();
394 board_clock_init();
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100395 exynos_uart_init();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000396 board_power_init();
397
398 return 0;
399}
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000400
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100401int lcd_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000402{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200403#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000404 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000405 struct pmic *p = pmic_get("MAX8997_PMIC");
406 if (!p)
407 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000408
409 if (pmic_probe(p))
410 return 0;
411
412 /* LDO15 voltage: 2.2v */
413 ret |= pmic_reg_write(p, MAX8997_REG_LDO15CTRL, 0x1c | EN_LDO);
414 /* LDO13 voltage: 3.0v */
415 ret |= pmic_reg_write(p, MAX8997_REG_LDO13CTRL, 0x2c | EN_LDO);
416
417 if (ret) {
418 puts("MAX8997 LDO setting error!\n");
419 return -1;
420 }
Simon Glass7bbb7d92016-11-23 06:34:40 -0700421#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000422 return 0;
423}
424
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100425int mipi_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000426{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200427#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000428 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000429 struct pmic *p = pmic_get("MAX8997_PMIC");
430 if (!p)
431 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000432
433 if (pmic_probe(p))
434 return 0;
435
436 /* LDO3 voltage: 1.1v */
437 ret |= pmic_reg_write(p, MAX8997_REG_LDO3CTRL, 0x6 | EN_LDO);
438 /* LDO4 voltage: 1.8v */
439 ret |= pmic_reg_write(p, MAX8997_REG_LDO4CTRL, 0x14 | EN_LDO);
440
441 if (ret) {
442 puts("MAX8997 LDO setting error!\n");
443 return -1;
444 }
Simon Glass7bbb7d92016-11-23 06:34:40 -0700445#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000446 return 0;
447}