]> git.sur5r.net Git - u-boot/commitdiff
board/BuR/tseries: Add simplefb support
authorHannes Petermaier <oe5hpm@oevsv.at>
Fri, 24 Apr 2015 12:49:37 +0000 (14:49 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 8 May 2015 21:24:17 +0000 (17:24 -0400)
Since the used AM3352 SoC doesn't have GPU it isn't allways necessary to build
in complete drm-stuff into linux kernel. In very small applications only we use
the simple-framebuffer.

So we have 2 use-cases:
- device operating on drm-driver (let simplefb node disabled)
- device operating on simplefb-driver (activate simplefb node and reserve mem)

The decision is made by means of "simplefb" environment variable.

simplefb = 0
we don't enable the (maybe) existing simplefb node and all the rest around
display is up to the linux-kernel. We just disable the backlight, beceause we
do not want see the flicker during take over of drm-driver.

simplefb = 1
we enable the (maybe) existing simplefb node and reserve framebuffers size
in memory.

Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
board/BuR/common/common.c
include/configs/tseries.h

index 3036f86781c3783f47b0bfe19264ca05a1010f90..5b356fbbbdf6da1b5174e27250301706fe6777bc 100644 (file)
@@ -34,6 +34,7 @@
 #include "bur_common.h"
 #include "../../../drivers/video/am335x-fb.h"
 #include <nand.h>
+#include <fdt_simplefb.h>
 
 static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;
 
@@ -47,6 +48,64 @@ DECLARE_GLOBAL_DATA_PTR;
 /* --------------------------------------------------------------------------*/
 #if defined(CONFIG_LCD) && defined(CONFIG_AM335X_LCD) && \
        !defined(CONFIG_SPL_BUILD)
+void lcdbacklight(int on)
+{
+#ifdef CONFIG_USE_FDT
+       if (gd->fdt_blob == NULL) {
+               printf("%s: don't have a valid gd->fdt_blob!\n", __func__);
+               return;
+       }
+       unsigned int driver = FDTPROP(PATHINF, "brightdrv");
+       unsigned int bright = FDTPROP(PATHINF, "brightdef");
+       unsigned int pwmfrq = FDTPROP(PATHINF, "brightfdim");
+#else
+       unsigned int driver = getenv_ulong("ds1_bright_drv", 16, 0UL);
+       unsigned int bright = getenv_ulong("ds1_bright_def", 10, 50);
+       unsigned int pwmfrq = getenv_ulong("ds1_pwmfreq", 10, ~0UL);
+#endif
+       unsigned int tmp;
+
+       struct gptimer *const timerhw = (struct gptimer *)DM_TIMER6_BASE;
+
+       if (on)
+               bright = bright != ~0UL ? bright : 50;
+       else
+               bright = 0;
+
+       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: /* PWM using timer6 */
+               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;
+       }
+}
+
 int load_lcdtiming(struct am335x_lcdpanel *panel)
 {
        struct am335x_lcdpanel pnltmp;
@@ -304,6 +363,32 @@ int ft_board_setup(void *blob, bd_t *bd)
                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 (getenv_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;
 }
 #else
@@ -412,55 +497,8 @@ void lcd_ctrl_init(void *lcdbase)
 
 void lcd_enable(void)
 {
-#ifdef CONFIG_USE_FDT
-       if (gd->fdt_blob == NULL) {
-               printf("%s: don't have a valid gd->fdt_blob!\n", __func__);
-               return;
-       }
-       unsigned int driver = FDTPROP(PATHINF, "brightdrv");
-       unsigned int bright = FDTPROP(PATHINF, "brightdef");
-       unsigned int pwmfrq = FDTPROP(PATHINF, "brightfdim");
-#else
-       unsigned int driver = getenv_ulong("ds1_bright_drv", 16, 0UL);
-       unsigned int bright = getenv_ulong("ds1_bright_def", 10, 50);
-       unsigned int pwmfrq = getenv_ulong("ds1_pwmfreq", 10, ~0UL);
-#endif
-       unsigned int tmp;
-       struct gptimer *const timerhw = (struct gptimer *)DM_TIMER6_BASE;
-
-       bright = bright != ~0UL ? bright : 50;
-
-       switch (driver) {
-       case 0: /* PMIC LED-Driver */
-               /* brightness level */
-               tps65217_reg_write(TPS65217_PROT_LEVEL_NONE,
-                                  TPS65217_WLEDCTRL2, bright, 0xFF);
-               /* turn on light */
-               tps65217_reg_write(TPS65217_PROT_LEVEL_NONE,
-                                  TPS65217_WLEDCTRL1, 0x0A, 0xFF);
-               break;
-       case 1: /* PWM using timer6 */
-               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;
-       }
        br_summaryscreen();
+       lcdbacklight(1);
 }
 #elif CONFIG_SPL_BUILD
 #else
index f2df35834fa2c6b73693ba54d7490bc1bc2aa5ff..c58403fe1dfa3d4bf8c2715224a482279542c4f0 100644 (file)
@@ -17,6 +17,7 @@
 #define CONFIG_AM335X_LCD
 #define CONFIG_LCD
 #define CONFIG_LCD_ROTATION
+#define CONFIG_LCD_DT_SIMPLEFB
 #define CONFIG_SYS_WHITE_ON_BLACK
 #define LCD_BPP                                LCD_COLOR32
 
                "bootz ${loadaddr} - ${dtbaddr}\0" \
        "defboot=run nandboot\0" \
        "bootlimit=1\0" \
+       "simplefb=1\0 " \
        "altbootcmd=run usbscript\0"
 #else
 #define NANDARGS ""
 "mmcroot1=setenv bootargs ${optargs_rot} ${optargs} console=${console} " \
        "root=/dev/mmcblk0p2 rootfstype=ext4\0" \
 "mmcboot0=echo booting Updatesystem from mmc (ext4-fs) ...; " \
+       "setenv simplefb 1; " \
        "ext4load mmc 0:1 ${loadaddr} /${kernel}; " \
        "ext4load mmc 0:1 ${ramaddr} /${ramdisk}; " \
        "run mmcroot0; bootz ${loadaddr} ${ramaddr} ${dtbaddr};\0" \
 "mmcboot1=echo booting PPT-OS from mmc (ext4-fs) ...; " \
+       "setenv simplefb 0; " \
        "ext4load mmc 0:2 ${loadaddr} /boot/${kernel}; " \
        "run mmcroot1; bootz ${loadaddr} - ${dtbaddr};\0" \
 "defboot=run logo0 || run logo1; " \