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