s5pc110: universal: change board name from "Neptune" to "Limo SDK"
[kernel/u-boot.git] / board / samsung / universal / universal.c
index 3bbbfb6..b1c23b2 100644 (file)
@@ -239,6 +239,11 @@ static int board_is_limo_real(void)
        return mach_is_aquila() && (board_rev & LIMO_REAL_BOARD);
 }
 
+static int board_is_bamboo(void)
+{
+       return mach_is_aquila() && (board_rev & BAMBOO_BOARD);
+}
+
 static int board_is_media(void)
 {
        return mach_is_aquila() && (board_rev & MEDIA_BOARD);
@@ -260,6 +265,11 @@ static int board_is_neptune(void)
        return mach_is_kessler() && (board_rev & NEPTUNE_BOARD);
 }
 
+static int board_is_s1(void)
+{
+       return mach_is_kessler() && (board_rev & S1_BOARD);
+}
+
 /* DLNA Dongle */
 static int mach_is_wmg160(void)
 {
@@ -267,6 +277,7 @@ static int mach_is_wmg160(void)
 }
 
 static void check_battery(int mode);
+static void check_micro_usb(int intr);
 
 void i2c_init_board(void)
 {
@@ -300,6 +311,8 @@ void i2c_init_board(void)
 
        i2c_gpio_init(i2c_gpio, num_bus, I2C_PMIC);
 
+       /* Reset on fsa9480 early */
+       check_micro_usb(1);
        /* Reset on max17040 early */
        if (battery_soc == 0)
                check_battery(1);
@@ -361,7 +374,7 @@ static const char *board_name[] = {
        "P1P2",         /* Don't remove it */
        "Geminus",
        "Cypress",
-       "Neptune",
+       "Limo SDK",
 };
 
 enum {
@@ -395,7 +408,7 @@ static char *display_features(int board, int board_rev)
                        name = "Bamboo";
        } else if (board == MACH_KESSLER) {
                if (board_rev & NEPTUNE_BOARD)
-                       name = "Neptune";
+                       name = "Limo SDK";
                if (board_rev & S1_BOARD)
                        name = "S1";
        }
@@ -677,8 +690,13 @@ static void show_hw_revision(void)
                        if ((board_rev & 0xf) < 8)
                                s5pc1xx_set_cpu_rev(0);
                }
+               else if (board_is_bamboo())
+                       s5pc1xx_set_cpu_rev(0);
        } else if (mach_is_kessler()) {
-               s5pc1xx_set_cpu_rev(1);
+               if (board_is_neptune() && hwrevision(2))
+                       s5pc1xx_set_cpu_rev(2); /* EVT1-Fused */
+               else
+                       s5pc1xx_set_cpu_rev(1);
        } else if (mach_is_geminus()) {
                if ((board_rev & 0xf) < 1)
                        s5pc1xx_set_cpu_rev(0);
@@ -688,6 +706,10 @@ static void show_hw_revision(void)
                s5pc1xx_set_cpu_rev(0);
        }
 
+       if (cpu_is_s5pc110())
+               writel(0xc1100000 | (0xffff & (s5pc1xx_get_cpu_rev() ? 1 : 0)),
+                               S5PC110_INFORM3);
+
        empty_device_info_buffer();
        dprintf("HW Revision:\t%x (%s%s) %s\n",
                board_rev, get_board_name(board),
@@ -702,11 +724,11 @@ static void check_auto_burn(void)
        char buf[64];
 
        if (readl(magic_base) == 0x426f6f74) {  /* ASICC: Boot */
-               printf("Auto burning bootloader\n");
+               puts("Auto burning bootloader\n");
                count += sprintf(buf + count, "run updateb; ");
        }
        if (readl(magic_base + 0x04) == 0x4b65726e) {   /* ASICC: Kern */
-               printf("Auto burning kernel\n");
+               puts("Auto burning kernel\n");
                count += sprintf(buf + count, "run updatek; ");
        }
 
@@ -885,10 +907,14 @@ static void check_keypad(void)
                /* volume down */
                if (row_state[1] & 0x2)
                        display_info = 1;
-               if (board_is_neptune()) {
+               if (board_is_neptune() && hwrevision(0)) {
                        /* home & volume down */
                        if ((row_state[1] & 0x1) && (row_state[1] & 0x2))
                                auto_download = 1;
+               } else if (board_is_neptune() && hwrevision(2)) {
+                       /* cam full shot & volume down */
+                       if ((row_state[1] & 0x6) && (row_state[2] & 0x4))
+                               auto_download = 1;
                } else {
                        /* cam full shot & volume down */
                        if ((row_state[0] & 0x1) && (row_state[1] & 0x2))
@@ -924,7 +950,7 @@ static void check_battery(int mode)
                return;
 
        if (i2c_probe(addr)) {
-               printf("Can't found max17040 fuel gauge\n");
+               puts("Can't found max17040 fuel gauge\n");
                return;
        }
 
@@ -962,7 +988,7 @@ static void check_mhl(void)
 
        /* set usb path */
        if (i2c_probe(addr)) {
-               printf("Can't found MHL Chip\n");
+               puts("Can't found MHL Chip\n");
                return;
        }
 
@@ -992,7 +1018,7 @@ static int max8998_probe(void)
        i2c_set_bus_num(I2C_PMIC);
 
        if (i2c_probe(addr)) {
-               printf("Can't found max8998\n");
+               puts("Can't found max8998\n");
                return 1;
        }
 
@@ -1157,7 +1183,7 @@ static unsigned short get_adc_value(int channel)
        do {
                udelay(1);
                reg = readl(&adc->adccon);
-       } while (!reg & (1 << 15) && loop++ < 1000);
+       } while (!(reg & (1 << 15)) && (loop++ < 1000));
 
        ret = readl(&adc->adcdat0) & 0xFFF;
        sprintf(buf, "pmic ldo %d off", ldonum);
@@ -1236,7 +1262,7 @@ static void charger_en(int enable)
                return;
 
        if (!enable) {
-               printf("Disable the charger.\n");
+               puts("Disable the charger.\n");
                i2c_read(addr, 0x0D, 1, val, 1);
                val[0] &= ~(0x1);
                val[0] |= 0x1;
@@ -1278,7 +1304,7 @@ static void into_charge_mode(void)
 
        max8998_clear_interrupt();
 
-       printf("Charge Mode\n");
+       puts("Charge Mode\n");
        charger_en(charger_speed);
 
 #ifdef CONFIG_S5PC1XXFB
@@ -1316,10 +1342,11 @@ static void into_charge_mode(void)
                }
        }
        exit_font();
-#endif
+
        /* Disable the display to prevent flickering */
        /* TODO: how to reenable the display later? */
        lcd_power_on(0);
+#endif
 
        do {
                struct s5pc110_rtc *rtc = (struct s5pc110_rtc *)S5PC110_RTC_BASE;
@@ -1372,7 +1399,7 @@ static void into_charge_mode(void)
                                wakeup_stat = do_sleep(&ctt, 0, 1, argv);
                        }
                } else {
-                       printf("\n\n\nERROR: this is not S5PC110.\n\n\n");
+                       puts("\n\n\nERROR: this is not S5PC110.\n\n\n");
                        return;
                }
 
@@ -1413,10 +1440,24 @@ static void into_charge_mode(void)
 
        } while (wakeup_stat == 0x04); /* RTC TICK */
 
+#ifdef CONFIG_S5PC1XXFB
 restore_screen:
        /* TODO: Reenable logo display (not working yet) */
        lcd_power_on(1);
        drv_lcd_init_resume();
+#endif
+}
+
+#define S5PC110_RST_STAT       0xE010A000
+
+#define SWRESET                        (1 << 3)
+#define WDTRESET               (1 << 2)
+#define WARMRESET              (1 << 1)
+#define EXTRESET               (1 << 0)
+
+static int get_reset_status(void)
+{
+       return readl(S5PC110_RST_STAT) & 0xf;
 }
 
 static int fsa9480_probe(void)
@@ -1445,7 +1486,7 @@ static int fsa9480_probe(void)
        }
 
        if (i2c_probe(addr)) {
-               printf("Can't found fsa9480\n");
+               puts("Can't found fsa9480\n");
                return 1;
        }
 
@@ -1467,7 +1508,7 @@ static void check_micro_usb(int intr)
        /* Clear Interrupt */
        if (intr) {
                i2c_read(addr, 0x03, 1, val, 2);
-               udelay(500 * 1000);
+               return;
        }
 
        /* Read Device Type 1 */
@@ -1498,15 +1539,19 @@ static void check_micro_usb(int intr)
                        charger_en(0);
        }
 
-       /* If Factory Mode is Boot ON-USB, go to download mode */
-       i2c_read(addr, 0x07, 1, val, 1);
+       /* If reset status is watchdog reset then skip it */
+       if (!(get_reset_status() & WDTRESET)) {
+               /* If Factory Mode is Boot ON-USB, go to download mode */
+               i2c_read(addr, 0x07, 1, val, 1);
 
 #define FSA_ADC_FAC_USB_OFF    0x18
 #define FSA_ADC_FAC_USB_ON     0x19
 #define FSA_ADC_FAC_UART       0x1d
 
-       if (val[0] == FSA_ADC_FAC_USB_ON || val[0] == FSA_ADC_FAC_USB_OFF)
-               setenv("bootcmd", "usbdown");
+               if (val[0] == FSA_ADC_FAC_USB_ON ||
+                       val[0] == FSA_ADC_FAC_USB_OFF)
+                       setenv("bootcmd", "usbdown");
+       }
 
        path = getenv("usb");
 
@@ -1771,7 +1816,7 @@ void lcd_cfg_gpio(void)
        /* LCD_BACKLIGHT_EN */
        if (mach_is_geminus())
                gpio_cfg_pin(&gpio_base->gpio_mp0_5, 0, GPIO_OUTPUT);
-       if (board_is_neptune()) {
+       if (board_is_neptune() && hwrevision(0)) {
                gpio_cfg_pin(&gpio_base->gpio_mp0_4, 4, GPIO_OUTPUT);
                gpio_direction_output(&gpio_base->gpio_mp0_4, 4, 0);
        }
@@ -1795,7 +1840,7 @@ void lcd_cfg_gpio(void)
                spi_pd.so_bank = &gpio_base->gpio_mp0_4;
                spi_pd.so_num = 2;
 
-               if (board_is_neptune())
+               if (board_is_neptune() && hwrevision(0))
                        s6d16a0x_set_platform_data(&spi_pd);
                else {
                        s6e63m0_set_platform_data(&spi_pd);
@@ -1863,7 +1908,7 @@ void backlight_on(unsigned int onoff)
                        gpio_set_value(&gpio->gpio_mp0_5, 0, 0);
        }
 
-       if (mach_is_kessler() && board_is_neptune()) {
+       if (mach_is_kessler() && board_is_neptune() && hwrevision(0)) {
                gpio_set_value(&gpio->gpio_mp0_4, 4, 1);
                udelay(6);
 
@@ -1872,7 +1917,7 @@ void backlight_on(unsigned int onoff)
                addr = 0x76;
                if (i2c_probe(addr)) {
                        if (i2c_probe(addr)) {
-                               printf("Can't found s6d16a0x backlight i2c\n");
+                               puts("Can't found s6d16a0x backlight i2c\n");
                                return;
                        }
                }
@@ -2040,7 +2085,7 @@ void init_panel_info(vidinfo_t *vid)
                vid->reset_delay = 120000;
        }
 
-       if (board_is_neptune()) {
+       if (board_is_neptune() && hwrevision(0)) {
                vid->vl_freq    = 100;
                vid->vl_col     = 320;
                vid->vl_row     = 480;
@@ -2178,7 +2223,7 @@ int misc_init_r(void)
        lcd_is_enabled = 0;
 
        if (mach_is_aquila() || mach_is_kessler()) {
-               if (board_is_neptune())
+               if (board_is_neptune() && hwrevision(0))
                        setenv("lcdinfo", "lcd=s6d16a0x");
                else if (board_is_media())
                        setenv("lcdinfo", "lcd=s6e63m0");
@@ -2228,7 +2273,7 @@ int misc_init_r(void)
        check_battery(0);
 
        /* check fsa9480 */
-       check_micro_usb(1);
+       check_micro_usb(0);
 
        return 0;
 }
@@ -2242,6 +2287,17 @@ int board_init(void)
        gd->bd->bi_arch_number = MACH_TYPE_AQUILA;
        gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
 
+#ifdef CONFIG_LCD
+       /* 
+        * set reserved memory region for framebuffer.
+        *
+        * this region wouldn't be rewrited by kernel so
+        * could avoid nosie screen filled by garbages
+        * after hibernation resume has been completed.
+        */
+       gd->fb_base = CONFIG_FB_RESERVED_MEM;
+#endif
+
        /* Check H/W Revision */
        check_hw_revision();
 
@@ -2282,16 +2338,21 @@ int dram_init(void)
                 * Aquila Rev0.5 4G3G1G
                 * Aquila Rev0.8 4G3G1G
                 * Aquila Rev0.9 4G3G1G
+                * Neptune Rev 0.2 4G3G1G
                 */
-               if (mach_is_aquila() || mach_is_kessler())
-                       if (hwrevision(5) || hwrevision(8) || hwrevision(9)) {
+               if (mach_is_aquila() || mach_is_kessler()) {
+                       if ((!board_is_neptune() && (hwrevision(5) ||
+                               hwrevision(8) || hwrevision(9))) ||
+                               (board_is_neptune() && hwrevision(2))) {
                                memconfig1 = readl(base + MEMCONFIG1_OFFSET);
 
                                sz = (memconfig1 >> 16) & 0xFF;
                                sz = ((unsigned char) ~sz) + 1;
                                sz = sz << 4;
                        }
-
+                       if (mach_is_kessler() && board_is_s1())
+                               sz = 0;
+               }
        }
        /*
         * bi_dram[1].size contains all DMC1 memory size
@@ -2432,13 +2493,13 @@ void board_sleep_resume(void)
        /* Set ONOFF4 */
        i2c_write(addr, MAX8998_REG_ONOFF3+1, 1, saved_val[3], 1);
        i2c_read(addr, MAX8998_REG_ONOFF3+1, 1, val, 1);
-       printf("Waked up.\n");
+       puts("Waked up.\n");
 
        /* check max17040 */
        check_battery(0);
 
        /* check fsa9480 */
-       check_micro_usb(1);
+       check_micro_usb(0);
 }
 
 #if defined(CONFIG_USB_GADGET_S3C_UDC_OTG)
@@ -2511,7 +2572,7 @@ int usb_board_init(void)
 
                /* PMIC */
                if (i2c_read(0x66, 0, 1, val, 2)) {
-                       printf("i2c_read error\n");
+                       puts("i2c_read error\n");
                        return 1;
                }
 
@@ -2519,7 +2580,7 @@ int usb_board_init(void)
                val[1] |= (1 << 5);
 
                if (i2c_write(0x66, 0, 1, val, 2)) {
-                       printf("i2c_write error\n");
+                       puts("i2c_write error\n");
                        return 1;
                }
                i2c_read(0x66, 0, 1, val, 2);