* Patch by Stefan Roese, 14 March 2005:
   Update for esd voh405 fpga image
 
+* INKA4x0: Allow initialization of LCD backlight dimming from
+  "brightness" environment variable.
+
 * Add port initialization for digital I/O on INKA4x0
 
 * Patch by Stefan Roese, 01 March 2005:
 
 
 int misc_init_f (void)
 {
+       uchar tmp[10];
+       int i, br;
+
+       i = getenv_r("brightness", tmp, sizeof(tmp));
+       br = (i > 0)
+               ? (int) simple_strtoul (tmp, NULL, 10)
+               : CFG_BRIGHTNESS;
+       if (br > 255)
+               br = 255;
+
        /* Initialize GPIO output pins.
         */
        /* Configure GPT as GPIO output */
        *(vu_long *)MPC5XXX_GPT4_ENABLE =
        *(vu_long *)MPC5XXX_GPT5_ENABLE = 0x24;
 
+       /* Configure GPT7 as PWM timer, 1kHz, no ints. */
+       *(vu_long *)MPC5XXX_GPT7_ENABLE = 0;/* Disable */
+       *(vu_long *)MPC5XXX_GPT7_COUNTER = 0x020000fe;
+       *(vu_long *)MPC5XXX_GPT7_PWMCFG = (br << 16);
+       *(vu_long *)MPC5XXX_GPT7_ENABLE = 0x3;/* Enable PWM mode and start */
 
        /* Configure PSC3_6,7 as GPIO output */
        *(vu_long *)MPC5XXX_GPIO_ENABLE |= 0x00003000;
 
 #define MPC5XXX_GPT7_ENABLE            (MPC5XXX_GPT + 0x70)
 #define MPC5XXX_GPT7_COUNTER           (MPC5XXX_GPT + 0x74)
 
+#define MPC5XXX_GPT7_PWMCFG            (MPC5XXX_GPT + 0x78)
 
 /* ATA registers */
 #define MPC5XXX_ATA_HOST_CONFIG         (MPC5XXX_ATA + 0x0000)