Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 2 | /* |
| 3 | * common.c |
| 4 | * |
| 5 | * common board functions for B&R boards |
| 6 | * |
Hannes Schmelzer | 7935f03 | 2015-05-28 15:41:12 +0200 | [diff] [blame] | 7 | * Copyright (C) 2013 Hannes Schmelzer <oe5hpm@oevsv.at> |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 8 | * Bernecker & Rainer Industrieelektronik GmbH - http://www.br-automation.com |
| 9 | * |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 10 | */ |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 11 | #include <version.h> |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 12 | #include <common.h> |
Simon Glass | 313112a | 2019-08-01 09:46:46 -0600 | [diff] [blame] | 13 | #include <env.h> |
Hannes Schmelzer | 1386d41 | 2019-04-10 14:13:11 +0200 | [diff] [blame] | 14 | #include <fdtdec.h> |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 15 | #include <i2c.h> |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 16 | #include <lcd.h> |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 17 | #include "bur_common.h" |
| 18 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 21 | /* --------------------------------------------------------------------------*/ |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 22 | #if defined(CONFIG_LCD) && defined(CONFIG_AM335X_LCD) && \ |
| 23 | !defined(CONFIG_SPL_BUILD) |
Hannes Schmelzer | 1386d41 | 2019-04-10 14:13:11 +0200 | [diff] [blame] | 24 | #include <asm/arch/hardware.h> |
| 25 | #include <asm/arch/cpu.h> |
| 26 | #include <asm/gpio.h> |
| 27 | #include <power/tps65217.h> |
| 28 | #include "../../../drivers/video/am335x-fb.h" |
| 29 | |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 30 | void lcdbacklight(int on) |
| 31 | { |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 32 | unsigned int driver = env_get_ulong("ds1_bright_drv", 16, 0UL); |
| 33 | unsigned int bright = env_get_ulong("ds1_bright_def", 10, 50); |
| 34 | unsigned int pwmfrq = env_get_ulong("ds1_pwmfreq", 10, ~0UL); |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 35 | unsigned int tmp; |
Hannes Petermaier | 129fe97 | 2015-06-11 12:25:43 +0200 | [diff] [blame] | 36 | struct gptimer *timerhw; |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 37 | |
| 38 | if (on) |
| 39 | bright = bright != ~0UL ? bright : 50; |
| 40 | else |
| 41 | bright = 0; |
| 42 | |
| 43 | switch (driver) { |
Hannes Petermaier | 129fe97 | 2015-06-11 12:25:43 +0200 | [diff] [blame] | 44 | case 2: |
| 45 | timerhw = (struct gptimer *)DM_TIMER5_BASE; |
| 46 | break; |
| 47 | default: |
| 48 | timerhw = (struct gptimer *)DM_TIMER6_BASE; |
| 49 | } |
| 50 | |
| 51 | switch (driver) { |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 52 | case 0: /* PMIC LED-Driver */ |
| 53 | /* brightness level */ |
| 54 | tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
| 55 | TPS65217_WLEDCTRL2, bright, 0xFF); |
| 56 | /* current sink */ |
| 57 | tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
| 58 | TPS65217_WLEDCTRL1, |
| 59 | bright != 0 ? 0x0A : 0x02, |
| 60 | 0xFF); |
| 61 | break; |
Hannes Petermaier | 129fe97 | 2015-06-11 12:25:43 +0200 | [diff] [blame] | 62 | case 1: |
| 63 | case 2: /* PWM using timer */ |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 64 | if (pwmfrq != ~0UL) { |
| 65 | timerhw->tiocp_cfg = TCFG_RESET; |
| 66 | udelay(10); |
| 67 | while (timerhw->tiocp_cfg & TCFG_RESET) |
| 68 | ; |
| 69 | tmp = ~0UL-(V_OSCK/pwmfrq); /* bottom value */ |
| 70 | timerhw->tldr = tmp; |
| 71 | timerhw->tcrr = tmp; |
| 72 | tmp = tmp + ((V_OSCK/pwmfrq)/100) * bright; |
| 73 | timerhw->tmar = tmp; |
| 74 | timerhw->tclr = (TCLR_PT | (2 << TCLR_TRG_SHIFT) | |
| 75 | TCLR_CE | TCLR_AR | TCLR_ST); |
| 76 | } else { |
| 77 | puts("invalid pwmfrq in env/dtb! skip PWM-setup.\n"); |
| 78 | } |
| 79 | break; |
| 80 | default: |
| 81 | puts("no suitable backlightdriver in env/dtb!\n"); |
| 82 | break; |
| 83 | } |
| 84 | } |
| 85 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 86 | int load_lcdtiming(struct am335x_lcdpanel *panel) |
| 87 | { |
| 88 | struct am335x_lcdpanel pnltmp; |
Hannes Petermaier | d35cb79 | 2015-04-24 14:49:35 +0200 | [diff] [blame] | 89 | |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 90 | pnltmp.hactive = env_get_ulong("ds1_hactive", 10, ~0UL); |
| 91 | pnltmp.vactive = env_get_ulong("ds1_vactive", 10, ~0UL); |
| 92 | pnltmp.bpp = env_get_ulong("ds1_bpp", 10, ~0UL); |
| 93 | pnltmp.hfp = env_get_ulong("ds1_hfp", 10, ~0UL); |
| 94 | pnltmp.hbp = env_get_ulong("ds1_hbp", 10, ~0UL); |
| 95 | pnltmp.hsw = env_get_ulong("ds1_hsw", 10, ~0UL); |
| 96 | pnltmp.vfp = env_get_ulong("ds1_vfp", 10, ~0UL); |
| 97 | pnltmp.vbp = env_get_ulong("ds1_vbp", 10, ~0UL); |
| 98 | pnltmp.vsw = env_get_ulong("ds1_vsw", 10, ~0UL); |
Hannes Schmelzer | d6ace8e | 2018-01-09 19:01:35 +0100 | [diff] [blame] | 99 | pnltmp.pxl_clk = env_get_ulong("ds1_pxlclk", 10, ~0UL); |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 100 | pnltmp.pol = env_get_ulong("ds1_pol", 16, ~0UL); |
| 101 | pnltmp.pup_delay = env_get_ulong("ds1_pupdelay", 10, ~0UL); |
| 102 | pnltmp.pon_delay = env_get_ulong("ds1_tondelay", 10, ~0UL); |
| 103 | panel_info.vl_rot = env_get_ulong("ds1_rotation", 10, 0); |
Hannes Schmelzer | 90168e8 | 2018-07-06 15:41:18 +0200 | [diff] [blame] | 104 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 105 | if ( |
| 106 | ~0UL == (pnltmp.hactive) || |
| 107 | ~0UL == (pnltmp.vactive) || |
| 108 | ~0UL == (pnltmp.bpp) || |
| 109 | ~0UL == (pnltmp.hfp) || |
| 110 | ~0UL == (pnltmp.hbp) || |
| 111 | ~0UL == (pnltmp.hsw) || |
| 112 | ~0UL == (pnltmp.vfp) || |
| 113 | ~0UL == (pnltmp.vbp) || |
| 114 | ~0UL == (pnltmp.vsw) || |
Hannes Schmelzer | d6ace8e | 2018-01-09 19:01:35 +0100 | [diff] [blame] | 115 | ~0UL == (pnltmp.pxl_clk) || |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 116 | ~0UL == (pnltmp.pol) || |
| 117 | ~0UL == (pnltmp.pup_delay) || |
| 118 | ~0UL == (pnltmp.pon_delay) |
| 119 | ) { |
| 120 | puts("lcd-settings in env/dtb incomplete!\n"); |
| 121 | printf("display-timings:\n" |
| 122 | "================\n" |
| 123 | "hactive: %d\n" |
| 124 | "vactive: %d\n" |
| 125 | "bpp : %d\n" |
| 126 | "hfp : %d\n" |
| 127 | "hbp : %d\n" |
| 128 | "hsw : %d\n" |
| 129 | "vfp : %d\n" |
| 130 | "vbp : %d\n" |
| 131 | "vsw : %d\n" |
| 132 | "pxlclk : %d\n" |
| 133 | "pol : 0x%08x\n" |
| 134 | "pondly : %d\n", |
| 135 | pnltmp.hactive, pnltmp.vactive, pnltmp.bpp, |
| 136 | pnltmp.hfp, pnltmp.hbp, pnltmp.hsw, |
| 137 | pnltmp.vfp, pnltmp.vbp, pnltmp.vsw, |
Hannes Schmelzer | d6ace8e | 2018-01-09 19:01:35 +0100 | [diff] [blame] | 138 | pnltmp.pxl_clk, pnltmp.pol, pnltmp.pon_delay); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 139 | |
| 140 | return -1; |
| 141 | } |
| 142 | debug("lcd-settings in env complete, taking over.\n"); |
| 143 | memcpy((void *)panel, |
| 144 | (void *)&pnltmp, |
| 145 | sizeof(struct am335x_lcdpanel)); |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 150 | static void br_summaryscreen_printenv(char *prefix, |
| 151 | char *name, char *altname, |
| 152 | char *suffix) |
| 153 | { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 154 | char *envval = env_get(name); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 155 | if (0 != envval) { |
| 156 | lcd_printf("%s %s %s", prefix, envval, suffix); |
| 157 | } else if (0 != altname) { |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 158 | envval = env_get(altname); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 159 | if (0 != envval) |
| 160 | lcd_printf("%s %s %s", prefix, envval, suffix); |
| 161 | } else { |
| 162 | lcd_printf("\n"); |
| 163 | } |
| 164 | } |
Hannes Schmelzer | 90168e8 | 2018-07-06 15:41:18 +0200 | [diff] [blame] | 165 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 166 | void br_summaryscreen(void) |
| 167 | { |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 168 | br_summaryscreen_printenv(" - B&R -", "br_orderno", 0, "-\n"); |
| 169 | br_summaryscreen_printenv(" Serial/Rev :", "br_serial", 0, "\n"); |
Hannes Schmelzer | 7d35231 | 2018-07-06 15:41:22 +0200 | [diff] [blame] | 170 | br_summaryscreen_printenv(" MAC1 :", "br_mac1", "ethaddr", "\n"); |
| 171 | br_summaryscreen_printenv(" MAC2 :", "br_mac2", 0, "\n"); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 172 | lcd_puts(" Bootloader : " PLAIN_VERSION "\n"); |
| 173 | lcd_puts("\n"); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | void lcdpower(int on) |
| 177 | { |
| 178 | u32 pin, swval, i; |
Hannes Schmelzer | 008c6b5 | 2019-02-06 13:25:59 +0100 | [diff] [blame] | 179 | char buf[16] = { 0 }; |
Hannes Schmelzer | 90168e8 | 2018-07-06 15:41:18 +0200 | [diff] [blame] | 180 | |
Simon Glass | 22c34c2 | 2017-08-03 12:22:13 -0600 | [diff] [blame] | 181 | pin = env_get_ulong("ds1_pwr", 16, ~0UL); |
Hannes Schmelzer | 90168e8 | 2018-07-06 15:41:18 +0200 | [diff] [blame] | 182 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 183 | if (pin == ~0UL) { |
| 184 | puts("no pwrpin in dtb/env, cannot powerup display!\n"); |
| 185 | return; |
| 186 | } |
| 187 | |
| 188 | for (i = 0; i < 3; i++) { |
| 189 | if (pin != 0) { |
Hannes Schmelzer | 008c6b5 | 2019-02-06 13:25:59 +0100 | [diff] [blame] | 190 | snprintf(buf, sizeof(buf), "ds1_pwr#%d", i); |
| 191 | if (gpio_request(pin & 0x7F, buf) != 0) { |
| 192 | printf("%s: not able to request gpio %s", |
| 193 | __func__, buf); |
| 194 | continue; |
| 195 | } |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 196 | swval = pin & 0x80 ? 0 : 1; |
| 197 | if (on) |
| 198 | gpio_direction_output(pin & 0x7F, swval); |
| 199 | else |
| 200 | gpio_direction_output(pin & 0x7F, !swval); |
| 201 | |
| 202 | debug("switched pin %d to %d\n", pin & 0x7F, swval); |
| 203 | } |
| 204 | pin >>= 8; |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | vidinfo_t panel_info = { |
| 209 | .vl_col = 1366, /* |
| 210 | * give full resolution for allocating enough |
| 211 | * memory |
| 212 | */ |
| 213 | .vl_row = 768, |
| 214 | .vl_bpix = 5, |
| 215 | .priv = 0 |
| 216 | }; |
| 217 | |
| 218 | void lcd_ctrl_init(void *lcdbase) |
| 219 | { |
| 220 | struct am335x_lcdpanel lcd_panel; |
Hannes Schmelzer | 90168e8 | 2018-07-06 15:41:18 +0200 | [diff] [blame] | 221 | |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 222 | memset(&lcd_panel, 0, sizeof(struct am335x_lcdpanel)); |
| 223 | if (load_lcdtiming(&lcd_panel) != 0) |
| 224 | return; |
| 225 | |
| 226 | lcd_panel.panel_power_ctrl = &lcdpower; |
| 227 | |
| 228 | if (0 != am335xfb_init(&lcd_panel)) |
| 229 | printf("ERROR: failed to initialize video!"); |
| 230 | /* |
| 231 | * modifiy panel info to 'real' resolution, to operate correct with |
| 232 | * lcd-framework. |
| 233 | */ |
| 234 | panel_info.vl_col = lcd_panel.hactive; |
| 235 | panel_info.vl_row = lcd_panel.vactive; |
| 236 | |
| 237 | lcd_set_flush_dcache(1); |
| 238 | } |
| 239 | |
| 240 | void lcd_enable(void) |
| 241 | { |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 242 | br_summaryscreen(); |
Hannes Petermaier | 1df983f | 2015-04-24 14:49:37 +0200 | [diff] [blame] | 243 | lcdbacklight(1); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 244 | } |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 245 | #endif /* CONFIG_LCD */ |
| 246 | |
Hannes Schmelzer | a21ed27 | 2018-07-06 15:41:20 +0200 | [diff] [blame] | 247 | int ft_board_setup(void *blob, bd_t *bd) |
| 248 | { |
| 249 | int nodeoffset; |
| 250 | |
| 251 | nodeoffset = fdt_path_offset(blob, "/factory-settings"); |
| 252 | if (nodeoffset < 0) { |
Hannes Schmelzer | de4225b | 2018-07-06 15:41:25 +0200 | [diff] [blame] | 253 | printf("%s: cannot find /factory-settings, trying /fset\n", |
| 254 | __func__); |
| 255 | nodeoffset = fdt_path_offset(blob, "/fset"); |
| 256 | if (nodeoffset < 0) { |
| 257 | printf("%s: cannot find /fset.\n", __func__); |
| 258 | return 0; |
| 259 | } |
Hannes Schmelzer | a21ed27 | 2018-07-06 15:41:20 +0200 | [diff] [blame] | 260 | } |
Hannes Schmelzer | de4225b | 2018-07-06 15:41:25 +0200 | [diff] [blame] | 261 | |
Hannes Schmelzer | a21ed27 | 2018-07-06 15:41:20 +0200 | [diff] [blame] | 262 | if (fdt_setprop(blob, nodeoffset, "bl-version", |
| 263 | PLAIN_VERSION, strlen(PLAIN_VERSION)) != 0) { |
Hannes Schmelzer | de4225b | 2018-07-06 15:41:25 +0200 | [diff] [blame] | 264 | printf("%s: no 'bl-version' prop in fdt!\n", __func__); |
| 265 | return 0; |
Hannes Schmelzer | a21ed27 | 2018-07-06 15:41:20 +0200 | [diff] [blame] | 266 | } |
Hannes Schmelzer | a21ed27 | 2018-07-06 15:41:20 +0200 | [diff] [blame] | 267 | return 0; |
| 268 | } |
| 269 | |
Hannes Schmelzer | 6cd12ce | 2019-04-10 14:13:13 +0200 | [diff] [blame] | 270 | int brdefaultip_setup(int bus, int chip) |
| 271 | { |
| 272 | int rc; |
| 273 | struct udevice *i2cdev; |
| 274 | u8 u8buf = 0; |
| 275 | char defip[256] = { 0 }; |
| 276 | |
| 277 | rc = i2c_get_chip_for_busnum(bus, chip, 2, &i2cdev); |
| 278 | if (rc != 0) { |
| 279 | printf("WARN: cannot probe baseboard EEPROM!\n"); |
| 280 | return -1; |
| 281 | } |
| 282 | |
| 283 | rc = dm_i2c_read(i2cdev, 0, &u8buf, 1); |
| 284 | if (rc != 0) { |
| 285 | printf("WARN: cannot read baseboard EEPROM!\n"); |
| 286 | return -1; |
| 287 | } |
| 288 | |
| 289 | if (u8buf != 0xFF) |
| 290 | snprintf(defip, sizeof(defip), |
| 291 | "if test -r ${ipaddr}; then; else setenv ipaddr 192.168.60.%d; setenv serverip 192.168.60.254; setenv gatewayip 192.168.60.254; setenv netmask 255.255.255.0; fi;", |
| 292 | u8buf); |
| 293 | else |
| 294 | strncpy(defip, |
| 295 | "if test -r ${ipaddr}; then; else setenv ipaddr 192.168.60.1; setenv serverip 192.168.60.254; setenv gatewayip 192.168.60.254; setenv netmask 255.255.255.0; fi;", |
| 296 | sizeof(defip)); |
| 297 | |
| 298 | env_set("brdefaultip", defip); |
| 299 | env_set_hex("board_id", u8buf); |
| 300 | |
| 301 | return 0; |
| 302 | } |
| 303 | |
Hannes Schmelzer | 9df7d73 | 2019-04-10 14:13:12 +0200 | [diff] [blame] | 304 | int overwrite_console(void) |
| 305 | { |
| 306 | return 1; |
| 307 | } |
| 308 | |
Hannes Schmelzer | 1386d41 | 2019-04-10 14:13:11 +0200 | [diff] [blame] | 309 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_AM33XX) |
| 310 | #include <asm/arch/hardware.h> |
| 311 | #include <asm/arch/omap.h> |
| 312 | #include <asm/arch/clock.h> |
| 313 | #include <asm/arch/sys_proto.h> |
| 314 | #include <power/tps65217.h> |
Hannes Schmelzer | 5639eeb | 2018-07-06 15:41:28 +0200 | [diff] [blame] | 315 | |
| 316 | static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE; |
| 317 | |
Hannes Schmelzer | 717ee36 | 2019-01-31 09:24:45 +0100 | [diff] [blame] | 318 | void pmicsetup(u32 mpupll, unsigned int bus) |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 319 | { |
| 320 | int mpu_vdd; |
| 321 | int usb_cur_lim; |
| 322 | |
Hannes Schmelzer | 717ee36 | 2019-01-31 09:24:45 +0100 | [diff] [blame] | 323 | if (power_tps65217_init(bus)) { |
| 324 | printf("WARN: cannot setup PMIC 0x24 @ bus #%d, not found!.\n", |
| 325 | bus); |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 326 | return; |
| 327 | } |
| 328 | |
| 329 | /* Get the frequency which is defined by device fuses */ |
| 330 | dpll_mpu_opp100.m = am335x_get_efuse_mpu_max_freq(cdev); |
| 331 | printf("detected max. frequency: %d - ", dpll_mpu_opp100.m); |
| 332 | |
| 333 | if (0 != mpupll) { |
Hannes Schmelzer | 29bea94 | 2018-07-06 15:41:23 +0200 | [diff] [blame] | 334 | dpll_mpu_opp100.m = mpupll; |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 335 | printf("retuning MPU-PLL to: %d MHz.\n", dpll_mpu_opp100.m); |
| 336 | } else { |
| 337 | puts("ok.\n"); |
| 338 | } |
| 339 | /* |
| 340 | * Increase USB current limit to 1300mA or 1800mA and set |
| 341 | * the MPU voltage controller as needed. |
| 342 | */ |
| 343 | if (dpll_mpu_opp100.m == MPUPLL_M_1000) { |
| 344 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1800MA; |
| 345 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1325MV; |
| 346 | } else { |
| 347 | usb_cur_lim = TPS65217_USB_INPUT_CUR_LIMIT_1300MA; |
| 348 | mpu_vdd = TPS65217_DCDC_VOLT_SEL_1275MV; |
| 349 | } |
| 350 | |
| 351 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_POWER_PATH, |
| 352 | usb_cur_lim, TPS65217_USB_INPUT_CUR_LIMIT_MASK)) |
| 353 | puts("tps65217_reg_write failure\n"); |
| 354 | |
| 355 | /* Set DCDC3 (CORE) voltage to 1.125V */ |
| 356 | if (tps65217_voltage_update(TPS65217_DEFDCDC3, |
| 357 | TPS65217_DCDC_VOLT_SEL_1125MV)) { |
| 358 | puts("tps65217_voltage_update failure\n"); |
| 359 | return; |
| 360 | } |
| 361 | |
| 362 | /* Set CORE Frequencies to OPP100 */ |
| 363 | do_setup_dpll(&dpll_core_regs, &dpll_core_opp100); |
| 364 | |
| 365 | /* Set DCDC2 (MPU) voltage */ |
| 366 | if (tps65217_voltage_update(TPS65217_DEFDCDC2, mpu_vdd)) { |
| 367 | puts("tps65217_voltage_update failure\n"); |
| 368 | return; |
| 369 | } |
| 370 | |
| 371 | /* Set LDO3 to 1.8V */ |
| 372 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
| 373 | TPS65217_DEFLS1, |
| 374 | TPS65217_LDO_VOLTAGE_OUT_1_8, |
| 375 | TPS65217_LDO_MASK)) |
| 376 | puts("tps65217_reg_write failure\n"); |
| 377 | /* Set LDO4 to 3.3V */ |
| 378 | if (tps65217_reg_write(TPS65217_PROT_LEVEL_2, |
| 379 | TPS65217_DEFLS2, |
| 380 | TPS65217_LDO_VOLTAGE_OUT_3_3, |
| 381 | TPS65217_LDO_MASK)) |
| 382 | puts("tps65217_reg_write failure\n"); |
| 383 | |
| 384 | /* Set MPU Frequency to what we detected now that voltages are set */ |
| 385 | do_setup_dpll(&dpll_mpu_regs, &dpll_mpu_opp100); |
Hannes Petermaier | 69d0d7d | 2015-02-03 13:22:26 +0100 | [diff] [blame] | 386 | /* Set PWR_EN bit in Status Register */ |
| 387 | tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, |
| 388 | TPS65217_STATUS, TPS65217_PWR_OFF, TPS65217_PWR_OFF); |
Hannes Petermaier | fb00366 | 2014-02-07 08:07:36 +0100 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | void set_uart_mux_conf(void) |
| 392 | { |
| 393 | enable_uart0_pin_mux(); |
| 394 | } |
| 395 | |
| 396 | void set_mux_conf_regs(void) |
| 397 | { |
| 398 | enable_board_pin_mux(); |
| 399 | } |
| 400 | |
Hannes Schmelzer | 1386d41 | 2019-04-10 14:13:11 +0200 | [diff] [blame] | 401 | #endif /* CONFIG_SPL_BUILD && CONFIG_AM33XX */ |