void lcdbacklight(int on) { unsigned int driver = env_get_ulong("ds1_bright_drv", 16, 0UL); unsigned int bright = env_get_ulong("ds1_bright_def", 10, 50); unsigned int pwmfrq = env_get_ulong("ds1_pwmfreq", 10, ~0UL); unsigned int tmp; struct gptimer *timerhw; if (on) bright = bright != ~0UL ? bright : 50; else bright = 0; switch (driver) { case 2: timerhw = (struct gptimer *)DM_TIMER5_BASE; break; default: timerhw = (struct gptimer *)DM_TIMER6_BASE; } switch (driver) { case 0: /* PMIC LED-Driver */ /* brightness level */ tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL2, bright, 0xFF); /* current sink */ tps65217_reg_write(TPS65217_PROT_LEVEL_NONE, TPS65217_WLEDCTRL1, bright != 0 ? 0x0A : 0x02, 0xFF); break; case 1: case 2: /* PWM using timer */ if (pwmfrq != ~0UL) { timerhw->tiocp_cfg = TCFG_RESET; udelay(10); while (timerhw->tiocp_cfg & TCFG_RESET) ; tmp = ~0UL-(V_OSCK/pwmfrq); /* bottom value */ timerhw->tldr = tmp; timerhw->tcrr = tmp; tmp = tmp + ((V_OSCK/pwmfrq)/100) * bright; timerhw->tmar = tmp; timerhw->tclr = (TCLR_PT | (2 << TCLR_TRG_SHIFT) | TCLR_CE | TCLR_AR | TCLR_ST); } else { puts("invalid pwmfrq in env/dtb! skip PWM-setup.\n"); } break; default: puts("no suitable backlightdriver in env/dtb!\n"); break; } }
void lcdpower(int on) { u32 pin, swval, i; #ifdef CONFIG_USE_FDT if (gd->fdt_blob == NULL) { printf("%s: don't have a valid gd->fdt_blob!\n", __func__); return; } pin = FDTPROP(PATHINF, "pwrpin"); #else pin = env_get_ulong("ds1_pwr", 16, ~0UL); #endif if (pin == ~0UL) { puts("no pwrpin in dtb/env, cannot powerup display!\n"); return; } for (i = 0; i < 3; i++) { if (pin != 0) { swval = pin & 0x80 ? 0 : 1; if (on) gpio_direction_output(pin & 0x7F, swval); else gpio_direction_output(pin & 0x7F, !swval); debug("switched pin %d to %d\n", pin & 0x7F, swval); } pin >>= 8; } }
void lcdpower(int on) { u32 pin, swval, i; char buf[16] = { 0 }; pin = env_get_ulong("ds1_pwr", 16, ~0UL); if (pin == ~0UL) { puts("no pwrpin in dtb/env, cannot powerup display!\n"); return; } for (i = 0; i < 3; i++) { if (pin != 0) { snprintf(buf, sizeof(buf), "ds1_pwr#%d", i); if (gpio_request(pin & 0x7F, buf) != 0) { printf("%s: not able to request gpio %s", __func__, buf); continue; } swval = pin & 0x80 ? 0 : 1; if (on) gpio_direction_output(pin & 0x7F, swval); else gpio_direction_output(pin & 0x7F, !swval); debug("switched pin %d to %d\n", pin & 0x7F, swval); } pin >>= 8; } }
int fdtdec_setup(void) { #if CONFIG_IS_ENABLED(OF_CONTROL) # if CONFIG_IS_ENABLED(MULTI_DTB_FIT) void *fdt_blob; # endif # ifdef CONFIG_OF_EMBED /* Get a pointer to the FDT */ # ifdef CONFIG_SPL_BUILD gd->fdt_blob = __dtb_dt_spl_begin; # else gd->fdt_blob = __dtb_dt_begin; # endif # elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE) /* Allow the board to override the fdt address. */ gd->fdt_blob = board_fdt_blob_setup(); # elif defined(CONFIG_OF_HOSTFILE) if (sandbox_read_fdt_from_file()) { puts("Failed to read control FDT\n"); return -1; } # endif # ifndef CONFIG_SPL_BUILD /* Allow the early environment to override the fdt address */ # if CONFIG_IS_ENABLED(OF_PRIOR_STAGE) gd->fdt_blob = (void *)prior_stage_fdt_address; # else gd->fdt_blob = map_sysmem (env_get_ulong("fdtcontroladdr", 16, (unsigned long)map_to_sysmem(gd->fdt_blob)), 0); # endif # endif # if CONFIG_IS_ENABLED(MULTI_DTB_FIT) /* * Try and uncompress the blob. * Unfortunately there is no way to know how big the input blob really * is. So let us set the maximum input size arbitrarily high. 16MB * ought to be more than enough for packed DTBs. */ if (uncompress_blob(gd->fdt_blob, 0x1000000, &fdt_blob) == 0) gd->fdt_blob = fdt_blob; /* * Check if blob is a FIT images containings DTBs. * If so, pick the most relevant */ fdt_blob = locate_dtb_in_fit(gd->fdt_blob); if (fdt_blob) { gd->multi_dtb_fit = gd->fdt_blob; gd->fdt_blob = fdt_blob; } # endif #endif return fdtdec_prepare_fdt(); }
/* reserve protected RAM */ static int reserve_pram(void) { ulong reg; reg = env_get_ulong("pram", 10, CONFIG_PRAM); gd->relocaddr -= (reg << 10); /* size is in kB */ debug("Reserving %ldk for protected RAM at %08lx\n", reg, gd->relocaddr); return 0; }
/* * Export available size of memory for Linux, taking into account the * protected RAM at top of memory */ int initr_mem(void) { ulong pram = 0; char memsz[32]; pram = env_get_ulong("pram", 10, CONFIG_PRAM); sprintf(memsz, "%ldk", (long int)((gd->ram_size / 1024) - pram)); env_set("mem", memsz); return 0; }
void board_pmmc_image_process(ulong pmmc_image, size_t pmmc_size) { int id = env_get_ulong("dev_pmmc", 10, 0); int ret; if (!rproc_is_initialized()) rproc_init(); ret = rproc_load(id, pmmc_image, pmmc_size); printf("Load Remote Processor %d with data@addr=0x%08lx %u bytes:%s\n", id, pmmc_image, pmmc_size, ret ? " Failed!" : " Success!"); if (!ret) rproc_start(id); }
static int initr_env(void) { /* initialize environment */ if (should_load_env()) env_relocate(); else set_default_env(NULL); #ifdef CONFIG_OF_CONTROL env_set_addr("fdtcontroladdr", gd->fdt_blob); #endif /* Initialize from environment */ load_addr = env_get_ulong("loadaddr", 16, load_addr); return 0; }
int ft_board_setup(void *blob, bd_t *bd) { int nodeoffset; nodeoffset = fdt_path_offset(blob, "/factory-settings"); if (nodeoffset < 0) { puts("set bootloader version 'factory-settings' not in dtb!\n"); return -1; } if (fdt_setprop(blob, nodeoffset, "bl-version", PLAIN_VERSION, strlen(PLAIN_VERSION)) != 0) { puts("set bootloader version 'bl-version' prop. not in dtb!\n"); return -1; } /* * if no simplefb is requested through environment, we don't set up * one, instead we turn off backlight. */ if (env_get_ulong("simplefb", 10, 0) == 0) { lcdbacklight(0); return 0; } /* Setup simplefb devicetree node, also adapt memory-node, * upper limit for kernel e.g. linux is memtop-framebuffer alligned * to a full megabyte. */ u64 start = gd->bd->bi_dram[0].start; u64 size = (gd->fb_base - start) & ~0xFFFFF; int rc = fdt_fixup_memory_banks(blob, &start, &size, 1); if (rc) { puts("cannot setup simplefb: Error reserving memory!\n"); return rc; } rc = lcd_dt_simplefb_enable_existing_node(blob); if (rc) { puts("cannot setup simplefb: error enabling simplefb node!\n"); return rc; } return 0; }
static int load_devicetree(void) { int rc; loff_t dtbsize; u32 dtbaddr = env_get_ulong("dtbaddr", 16, 0UL); if (dtbaddr == 0) { printf("%s: don't have a valid <dtbaddr> in env!\n", __func__); return -1; } #ifdef CONFIG_NAND dtbsize = 0x20000; rc = nand_read_skip_bad(get_nand_dev_by_index(0), 0x40000, (size_t *)&dtbsize, NULL, 0x20000, (u_char *)dtbaddr); #else char *dtbname = env_get("dtb"); char *dtbdev = env_get("dtbdev"); char *dtbpart = env_get("dtbpart"); if (!dtbdev || !dtbpart || !dtbname) { printf("%s: <dtbdev>/<dtbpart>/<dtb> missing.\n", __func__); return -1; } if (fs_set_blk_dev(dtbdev, dtbpart, FS_TYPE_EXT)) { puts("load_devicetree: set_blk_dev failed.\n"); return -1; } rc = fs_read(dtbname, (u32)dtbaddr, 0, 0, &dtbsize); #endif if (rc == 0) { gd->fdt_blob = (void *)dtbaddr; gd->fdt_size = dtbsize; debug("loaded %d bytes of dtb onto 0x%08x\n", (u32)dtbsize, (u32)gd->fdt_blob); return dtbsize; } printf("%s: load dtb failed!\n", __func__); return -1; }
void lcdpower(int on) { u32 pin, swval, i; pin = env_get_ulong("ds1_pwr", 16, ~0UL); if (pin == ~0UL) { puts("no pwrpin in dtb/env, cannot powerup display!\n"); return; } for (i = 0; i < 3; i++) { if (pin != 0) { swval = pin & 0x80 ? 0 : 1; if (on) gpio_direction_output(pin & 0x7F, swval); else gpio_direction_output(pin & 0x7F, !swval); debug("switched pin %d to %d\n", pin & 0x7F, swval); } pin >>= 8; } }
int load_lcdtiming(struct am335x_lcdpanel *panel) { struct am335x_lcdpanel pnltmp; #ifdef CONFIG_USE_FDT u32 dtbprop; char buf[32]; const char *nodep = 0; int nodeoff; if (gd->fdt_blob == NULL) { printf("%s: don't have a valid gd->fdt_blob!\n", __func__); return -1; } memcpy(&pnltmp, (void *)panel, sizeof(struct am335x_lcdpanel)); pnltmp.hactive = FDTPROP(PATHTIM, "hactive"); pnltmp.vactive = FDTPROP(PATHTIM, "vactive"); pnltmp.bpp = FDTPROP(PATHINF, "bpp"); pnltmp.hfp = FDTPROP(PATHTIM, "hfront-porch"); pnltmp.hbp = FDTPROP(PATHTIM, "hback-porch"); pnltmp.hsw = FDTPROP(PATHTIM, "hsync-len"); pnltmp.vfp = FDTPROP(PATHTIM, "vfront-porch"); pnltmp.vbp = FDTPROP(PATHTIM, "vback-porch"); pnltmp.vsw = FDTPROP(PATHTIM, "vsync-len"); pnltmp.pup_delay = FDTPROP(PATHTIM, "pupdelay"); pnltmp.pon_delay = FDTPROP(PATHTIM, "pondelay"); /* calc. proper clk-divisor */ dtbprop = FDTPROP(PATHTIM, "clock-frequency"); if (dtbprop != ~0UL) pnltmp.pxl_clk_div = 192000000 / dtbprop; else pnltmp.pxl_clk_div = ~0UL; /* check polarity of control-signals */ dtbprop = FDTPROP(PATHTIM, "hsync-active"); if (dtbprop == 0) pnltmp.pol |= HSYNC_INVERT; dtbprop = FDTPROP(PATHTIM, "vsync-active"); if (dtbprop == 0) pnltmp.pol |= VSYNC_INVERT; dtbprop = FDTPROP(PATHINF, "sync-ctrl"); if (dtbprop == 1) pnltmp.pol |= HSVS_CONTROL; dtbprop = FDTPROP(PATHINF, "sync-edge"); if (dtbprop == 1) pnltmp.pol |= HSVS_RISEFALL; dtbprop = FDTPROP(PATHTIM, "pixelclk-active"); if (dtbprop == 0) pnltmp.pol |= PXCLK_INVERT; dtbprop = FDTPROP(PATHTIM, "de-active"); if (dtbprop == 0) pnltmp.pol |= DE_INVERT; nodeoff = fdt_path_offset(gd->fdt_blob, "/factory-settings"); if (nodeoff >= 0) { nodep = fdt_getprop(gd->fdt_blob, nodeoff, "rotation", NULL); if (nodep != 0) { if (strcmp(nodep, "cw") == 0) panel_info.vl_rot = 1; else if (strcmp(nodep, "ud") == 0) panel_info.vl_rot = 2; else if (strcmp(nodep, "ccw") == 0) panel_info.vl_rot = 3; else panel_info.vl_rot = 0; } } else { puts("no 'factory-settings / rotation' in dtb!\n"); } snprintf(buf, sizeof(buf), "fbcon=rotate:%d", panel_info.vl_rot); env_set("optargs_rot", buf); #else pnltmp.hactive = env_get_ulong("ds1_hactive", 10, ~0UL); pnltmp.vactive = env_get_ulong("ds1_vactive", 10, ~0UL); pnltmp.bpp = env_get_ulong("ds1_bpp", 10, ~0UL); pnltmp.hfp = env_get_ulong("ds1_hfp", 10, ~0UL); pnltmp.hbp = env_get_ulong("ds1_hbp", 10, ~0UL); pnltmp.hsw = env_get_ulong("ds1_hsw", 10, ~0UL); pnltmp.vfp = env_get_ulong("ds1_vfp", 10, ~0UL); pnltmp.vbp = env_get_ulong("ds1_vbp", 10, ~0UL); pnltmp.vsw = env_get_ulong("ds1_vsw", 10, ~0UL); pnltmp.pxl_clk_div = env_get_ulong("ds1_pxlclkdiv", 10, ~0UL); pnltmp.pol = env_get_ulong("ds1_pol", 16, ~0UL); pnltmp.pup_delay = env_get_ulong("ds1_pupdelay", 10, ~0UL); pnltmp.pon_delay = env_get_ulong("ds1_tondelay", 10, ~0UL); panel_info.vl_rot = env_get_ulong("ds1_rotation", 10, 0); #endif if ( ~0UL == (pnltmp.hactive) || ~0UL == (pnltmp.vactive) || ~0UL == (pnltmp.bpp) || ~0UL == (pnltmp.hfp) || ~0UL == (pnltmp.hbp) || ~0UL == (pnltmp.hsw) || ~0UL == (pnltmp.vfp) || ~0UL == (pnltmp.vbp) || ~0UL == (pnltmp.vsw) || ~0UL == (pnltmp.pxl_clk_div) || ~0UL == (pnltmp.pol) || ~0UL == (pnltmp.pup_delay) || ~0UL == (pnltmp.pon_delay) ) { puts("lcd-settings in env/dtb incomplete!\n"); printf("display-timings:\n" "================\n" "hactive: %d\n" "vactive: %d\n" "bpp : %d\n" "hfp : %d\n" "hbp : %d\n" "hsw : %d\n" "vfp : %d\n" "vbp : %d\n" "vsw : %d\n" "pxlclk : %d\n" "pol : 0x%08x\n" "pondly : %d\n", pnltmp.hactive, pnltmp.vactive, pnltmp.bpp, pnltmp.hfp, pnltmp.hbp, pnltmp.hsw, pnltmp.vfp, pnltmp.vbp, pnltmp.vsw, pnltmp.pxl_clk_div, pnltmp.pol, pnltmp.pon_delay); return -1; } debug("lcd-settings in env complete, taking over.\n"); memcpy((void *)panel, (void *)&pnltmp, sizeof(struct am335x_lcdpanel)); return 0; }
int board_late_init(void) { const unsigned int toff = 1000; unsigned int cnt = 3; unsigned short buf = 0xAAAA; unsigned char scratchreg = 0; unsigned int oldspeed; /* try to read out some boot-instruction from resetcontroller */ oldspeed = i2c_get_bus_speed(); if (i2c_set_bus_speed(CONFIG_SYS_OMAP24_I2C_SPEED_PSOC) >= 0) { i2c_read(RSTCTRL_ADDR, RSTCTRL_SCRATCHREG, 1, &scratchreg, sizeof(scratchreg)); i2c_set_bus_speed(oldspeed); } else { puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n"); } if (gpio_get_value(ESC_KEY)) { do { lcd_position_cursor(1, 8); switch (cnt) { case 3: lcd_puts( "release ESC-KEY to enter SERVICE-mode."); break; case 2: lcd_puts( "release ESC-KEY to enter DIAGNOSE-mode."); break; case 1: lcd_puts( "release ESC-KEY to enter BOOT-mode. "); break; } mdelay(toff); cnt--; if (!gpio_get_value(ESC_KEY) && gpio_get_value(PUSH_KEY) && 2 == cnt) { lcd_position_cursor(1, 8); lcd_puts( "switching to network-console ... "); env_set("bootcmd", "run netconsole"); cnt = 4; break; } else if (!gpio_get_value(ESC_KEY) && gpio_get_value(PUSH_KEY) && 1 == cnt) { lcd_position_cursor(1, 8); lcd_puts( "starting u-boot script from USB ... "); env_set("bootcmd", "run usbscript"); cnt = 4; break; } else if ((!gpio_get_value(ESC_KEY) && gpio_get_value(PUSH_KEY) && cnt == 0) || (gpio_get_value(ESC_KEY) && gpio_get_value(PUSH_KEY) && cnt == 0)) { lcd_position_cursor(1, 8); lcd_puts( "starting script from network ... "); env_set("bootcmd", "run netscript"); cnt = 4; break; } else if (!gpio_get_value(ESC_KEY)) { break; } } while (cnt); } else if (scratchreg == 0xCC) { lcd_position_cursor(1, 8); lcd_puts( "starting vxworks from network ... "); env_set("bootcmd", "run netboot"); cnt = 4; } else if (scratchreg == 0xCD) { lcd_position_cursor(1, 8); lcd_puts( "starting script from network ... "); env_set("bootcmd", "run netscript"); cnt = 4; } else if (scratchreg == 0xCE) { lcd_position_cursor(1, 8); lcd_puts( "starting AR from eMMC ... "); env_set("bootcmd", "run mmcboot"); cnt = 4; } lcd_position_cursor(1, 8); switch (cnt) { case 0: lcd_puts("entering BOOT-mode. "); env_set("bootcmd", "run defaultAR"); buf = 0x0000; break; case 1: lcd_puts("entering DIAGNOSE-mode. "); buf = 0x0F0F; break; case 2: lcd_puts("entering SERVICE mode. "); buf = 0xB4B4; break; case 3: lcd_puts("loading OS... "); buf = 0x0404; break; } /* write bootinfo into scratchregister of resetcontroller */ oldspeed = i2c_get_bus_speed(); if (i2c_set_bus_speed(CONFIG_SYS_OMAP24_I2C_SPEED_PSOC) >= 0) { i2c_write(RSTCTRL_ADDR, RSTCTRL_SCRATCHREG, 1, (uint8_t *)&buf, sizeof(buf)); i2c_set_bus_speed(oldspeed); } else { puts("ERROR: i2c_set_bus_speed failed! (scratchregister)\n"); } /* setup othbootargs for bootvx-command (vxWorks bootline) */ char othbootargs[128]; snprintf(othbootargs, sizeof(othbootargs), "u=vxWorksFTP pw=vxWorks o=0x%08x;0x%08x;0x%08x;0x%08x", (unsigned int) gd->fb_base-0x20, (u32)env_get_ulong("vx_memtop", 16, gd->fb_base-0x20), (u32)env_get_ulong("vx_romfsbase", 16, 0), (u32)env_get_ulong("vx_romfssize", 16, 0)); env_set("othbootargs", othbootargs); /* * reset VBAR registers to its reset location, VxWorks 6.9.3.2 does * expect that vectors are there, original u-boot moves them to _start */ __asm__("ldr r0,=0x20000"); __asm__("mcr p15, 0, r0, c12, c0, 0"); /* Set VBAR */ return 0; }
int load_lcdtiming(struct am335x_lcdpanel *panel) { struct am335x_lcdpanel pnltmp; pnltmp.hactive = env_get_ulong("ds1_hactive", 10, ~0UL); pnltmp.vactive = env_get_ulong("ds1_vactive", 10, ~0UL); pnltmp.bpp = env_get_ulong("ds1_bpp", 10, ~0UL); pnltmp.hfp = env_get_ulong("ds1_hfp", 10, ~0UL); pnltmp.hbp = env_get_ulong("ds1_hbp", 10, ~0UL); pnltmp.hsw = env_get_ulong("ds1_hsw", 10, ~0UL); pnltmp.vfp = env_get_ulong("ds1_vfp", 10, ~0UL); pnltmp.vbp = env_get_ulong("ds1_vbp", 10, ~0UL); pnltmp.vsw = env_get_ulong("ds1_vsw", 10, ~0UL); pnltmp.pxl_clk = env_get_ulong("ds1_pxlclk", 10, ~0UL); pnltmp.pol = env_get_ulong("ds1_pol", 16, ~0UL); pnltmp.pup_delay = env_get_ulong("ds1_pupdelay", 10, ~0UL); pnltmp.pon_delay = env_get_ulong("ds1_tondelay", 10, ~0UL); panel_info.vl_rot = env_get_ulong("ds1_rotation", 10, 0); if ( ~0UL == (pnltmp.hactive) || ~0UL == (pnltmp.vactive) || ~0UL == (pnltmp.bpp) || ~0UL == (pnltmp.hfp) || ~0UL == (pnltmp.hbp) || ~0UL == (pnltmp.hsw) || ~0UL == (pnltmp.vfp) || ~0UL == (pnltmp.vbp) || ~0UL == (pnltmp.vsw) || ~0UL == (pnltmp.pxl_clk) || ~0UL == (pnltmp.pol) || ~0UL == (pnltmp.pup_delay) || ~0UL == (pnltmp.pon_delay) ) { puts("lcd-settings in env/dtb incomplete!\n"); printf("display-timings:\n" "================\n" "hactive: %d\n" "vactive: %d\n" "bpp : %d\n" "hfp : %d\n" "hbp : %d\n" "hsw : %d\n" "vfp : %d\n" "vbp : %d\n" "vsw : %d\n" "pxlclk : %d\n" "pol : 0x%08x\n" "pondly : %d\n", pnltmp.hactive, pnltmp.vactive, pnltmp.bpp, pnltmp.hfp, pnltmp.hbp, pnltmp.hsw, pnltmp.vfp, pnltmp.vbp, pnltmp.vsw, pnltmp.pxl_clk, pnltmp.pol, pnltmp.pon_delay); return -1; } debug("lcd-settings in env complete, taking over.\n"); memcpy((void *)panel, (void *)&pnltmp, sizeof(struct am335x_lcdpanel)); return 0; }
static int init_baud_rate(void) { gd->baudrate = env_get_ulong("baudrate", 10, CONFIG_BAUDRATE); return 0; }