blob: 1608d60dd8db2f4614dded0b9eb80cfa4b2adc97 [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
43static void check_hw_revision(void);
Marek Vasut6939aca2015-12-04 02:23:29 +010044struct dwc2_plat_otg_data s5pc210_otg_data;
Lukasz Majewski51de1762012-08-06 14:41:10 +020045
Piotr Wilczek4efd33a2014-03-07 14:59:48 +010046int exynos_init(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +000047{
HeungJun, Kimb4b54682012-01-16 21:13:05 +000048 check_hw_revision();
49 printf("HW Revision:\t0x%x\n", board_rev);
50
HeungJun, Kimb4b54682012-01-16 21:13:05 +000051 return 0;
52}
53
Igor Opaniukf7c91762021-02-09 13:52:45 +020054#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskib6a3dc62012-11-13 03:22:10 +000055static 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 Glass7bbb7d92016-11-23 06:34:40 -0700112#endif
Łukasz Majewskid72e0ae2012-11-13 03:22:05 +0000113
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100114int exynos_power_init(void)
Łukasz Majewskifa627662012-11-13 03:21:57 +0000115{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200116#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000117 int chrg, ret;
118 struct power_battery *pb;
119 struct pmic *p_fg, *p_chrg, *p_muic, *p_bat;
Łukasz Majewskifa627662012-11-13 03:21:57 +0000120
Łukasz Majewskide55e752013-08-16 15:33:33 +0200121 /*
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 Chungc7475702017-03-30 21:29:58 +0900128 ret = power_fg_init(I2C_9);
Piotr Wilczek58bbd2b2013-11-20 10:43:49 +0100129 ret |= power_muic_init(I2C_5);
Łukasz Majewskie4a182a2012-11-13 03:22:08 +0000130 ret |= power_bat_init(0);
Łukasz Majewskifa627662012-11-13 03:21:57 +0000131 if (ret)
132 return ret;
133
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000134 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 Marczakdd0c48e2014-06-10 16:55:08 +0200171 return 0;
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000172 }
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 Glass7bbb7d92016-11-23 06:34:40 -0700178#endif
Łukasz Majewskifc2d44a2012-11-13 03:22:11 +0000179
Łukasz Majewskifa627662012-11-13 03:21:57 +0000180 return 0;
181}
182
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000183static unsigned int get_hw_revision(void)
184{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000185 int hwrev = 0;
Simon Glass4f83d3d2014-10-20 19:48:39 -0600186 char str[10];
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000187 int i;
188
189 /* hw_rev[3:0] == GPE1[3:0] */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600190 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, Kimb4b54682012-01-16 21:13:05 +0000197 }
198
199 udelay(1);
200
201 for (i = 0; i < 4; i++)
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530202 hwrev |= (gpio_get_value(EXYNOS4_GPIO_E10 + i) << i);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000203
204 debug("hwrev 0x%x\n", hwrev);
205
206 return hwrev;
207}
208
209static void check_hw_revision(void)
210{
211 int hwrev;
212
213 hwrev = get_hw_revision();
214
215 board_rev |= hwrev;
216}
217
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000218
219#ifdef CONFIG_USB_GADGET
220static int s5pc210_phy_control(int on)
221{
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900222 struct udevice *dev;
223 int reg, ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000224
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900225 ret = pmic_get("max8997-pmic", &dev);
226 if (ret)
227 return ret;
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000228
229 if (on) {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900230 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, Kimb4b54682012-01-16 21:13:05 +0000251 } else {
Jaehoon Chungc43173c2017-03-30 21:29:59 +0900252 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, Kimb4b54682012-01-16 21:13:05 +0000273
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000274 }
275
276 return 0;
277}
278
Marek Vasut6939aca2015-12-04 02:23:29 +0100279struct dwc2_plat_otg_data s5pc210_otg_data = {
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000280 .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 Majewski51de1762012-08-06 14:41:10 +0200286
Troy Kiskyde8ae7b2013-10-10 15:27:55 -0700287int board_usb_init(int index, enum usb_init_type init)
Lukasz Majewski51de1762012-08-06 14:41:10 +0200288{
289 debug("USB_udc_probe\n");
Marek Vasut01b61fa2015-12-04 02:26:33 +0100290 return dwc2_udc_probe(&s5pc210_otg_data);
Lukasz Majewski51de1762012-08-06 14:41:10 +0200291}
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100292
Mateusz Zalega21fe3f72014-04-30 13:07:48 +0200293int g_dnl_board_usb_cable_connected(void)
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100294{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200295#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100296 struct pmic *muic = pmic_get("MAX8997_MUIC");
297 if (!muic)
298 return 0;
299
300 return !!muic->chrg->chrg_type(muic);
Simon Glass7bbb7d92016-11-23 06:34:40 -0700301#else
302 return false;
303#endif
304
Przemyslaw Marczak99b02352013-12-02 13:54:01 +0100305}
306#endif
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000307
308static void pmic_reset(void)
309{
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530310 gpio_direction_output(EXYNOS4_GPIO_X07, 1);
311 gpio_set_pull(EXYNOS4_GPIO_X27, S5P_GPIO_PULL_NONE);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000312}
313
314static 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, Kimb4b54682012-01-16 21:13:05 +0000364static 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 Wilczek9b4faf22012-10-08 20:45:42 +0000380
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, Kimb4b54682012-01-16 21:13:05 +0000384}
385
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100386static void exynos_uart_init(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000387{
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000388 /* UART_SEL GPY4[7] (part2) at EXYNOS4 */
Simon Glass4f83d3d2014-10-20 19:48:39 -0600389 gpio_request(EXYNOS4_GPIO_Y47, "uart_sel");
Akshay Saraswat1376cdd2014-05-13 10:30:14 +0530390 gpio_set_pull(EXYNOS4_GPIO_Y47, S5P_GPIO_PULL_UP);
391 gpio_direction_output(EXYNOS4_GPIO_Y47, 1);
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000392}
393
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100394int exynos_early_init_f(void)
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000395{
Minkyu Kang58269902012-01-18 15:56:47 +0900396 wdt_stop();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000397 pmic_reset();
398 board_clock_init();
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100399 exynos_uart_init();
HeungJun, Kimb4b54682012-01-16 21:13:05 +0000400 board_power_init();
401
402 return 0;
403}
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000404
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100405int lcd_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000406{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200407#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000408 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000409 struct pmic *p = pmic_get("MAX8997_PMIC");
410 if (!p)
411 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000412
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 Glass7bbb7d92016-11-23 06:34:40 -0700425#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000426 return 0;
427}
428
Piotr Wilczek4efd33a2014-03-07 14:59:48 +0100429int mipi_power(void)
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000430{
Igor Opaniukf7c91762021-02-09 13:52:45 +0200431#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000432 int ret = 0;
Łukasz Majewski1c6dba12012-11-13 03:21:55 +0000433 struct pmic *p = pmic_get("MAX8997_PMIC");
434 if (!p)
435 return -ENODEV;
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000436
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 Glass7bbb7d92016-11-23 06:34:40 -0700449#endif
Donghwa Lee9ad0ddc2012-04-05 19:36:27 +0000450 return 0;
451}