X60/T60: reset baudrate loglevel to sane values
[coreboot.git] / src / mainboard / lenovo / x60 / mainboard.c
index 6606a876958a4b35f9f99b222d8ba7e6fa901f49..ee6ac144fc3dae38fa27675daa6ff93d61b55f02 100644 (file)
 #include <arch/io.h>
 #include <ec/lenovo/pmh7/pmh7.h>
 #include <ec/acpi/ec.h>
+#include <ec/lenovo/h8/h8.h>
+#include <northbridge/intel/i945/i945.h>
+#include <pc80/mc146818rtc.h>
+#include "dock.h"
+#include <arch/x86/include/arch/acpigen.h>
 
-static void backlight_enable(void)
-{
-       pmh7_register_set_bit(0x50, 5);
-}
-
-static void trackpoint_enable(void)
-{
-       ec_write(0x0b, 0x03);
-}
+static struct cst_entry cst_entries[] = {
+       { 0x7f, 1, 2, 0, 1, 1, 1, 1000 },
+       { 0x01, 8, 0, 0, DEFAULT_PMBASE + LV2, 2, 1, 500 },
+       { 0x01, 8, 0, 0, DEFAULT_PMBASE + LV3, 2, 17, 250 },
+};
 
-static void wlan_enable(void)
+int get_cst_entries(struct cst_entry **entries)
 {
-       ec_write(0x3a, 0x20);
+       *entries = cst_entries;
+       return ARRAY_SIZE(cst_entries);
 }
 
 static void mainboard_enable(device_t dev)
 {
-       backlight_enable();
-       trackpoint_enable();
-       /* FIXME: this should be ACPI's task
-        * but for now, enable it here */
-       wlan_enable();
-
-       /* enable ACPI events */
-       ec_write(0x00, 0xa6);
-       ec_write(0x01, 0x05);
+       device_t dev0, idedev;
+       u8 defaults_loaded = 0;
 
-       ec_write(0x02, 0xa0);
-       ec_write(0x03, 0x05);
+       ec_clr_bit(0x03, 2);
 
-       /* set mask of enabled beeps */
-       ec_write(0x04, 0xfe);
-       ec_write(0x05, 0x96);
+       if (inb(0x164c) & 0x08) {
+               ec_set_bit(0x03, 2);
+               ec_write(0x0c, 0x88);
+       }
+       /* If we're resuming from suspend, blink suspend LED */
+       dev0 = dev_find_slot(0, PCI_DEVFN(0,0));
+       if (dev0 && pci_read_config32(dev0, SKPAD) == SKPAD_ACPI_S3_MAGIC)
+               ec_write(0x0c, 0xc7);
 
-       /* Unknown, but required for hotkeys
-          Maybe a mask for enabled keys? */
+       idedev = dev_find_slot(0, PCI_DEVFN(0x1f,1));
+       if (idedev && idedev->chip_info && dock_ultrabay_device_present()) {
+               struct southbridge_intel_i82801gx_config *config = idedev->chip_info;
+               config->ide_enable_primary = 1;
+               /* enable Ultrabay power */
+               outb(inb(0x1628) | 0x01, 0x1628);
+               ec_write(0x0c, 0x84);
+       } else {
+               /* disable Ultrabay power */
+               outb(inb(0x1628) & ~0x01, 0x1628);
+               ec_write(0x0c, 0x04);
+       }
 
-       ec_write(0x12, 0xff);
-       ec_write(0x13, 0xff);
-       ec_write(0x14, 0xf4);
-       ec_write(0x15, 0x3c);
+       if (get_option(&defaults_loaded, "cmos_defaults_loaded") < 0) {
+               printk(BIOS_INFO, "failed to get cmos_defaults_loaded");
+               defaults_loaded = 0;
+       }
 
-       /* enable Audio */
-       ec_clr_bit(0x3a, 0);
+       if (!defaults_loaded) {
+               printk(BIOS_INFO, "Restoring CMOS defaults\n");
+               set_option("tft_brightness", &(u8[]){ 0xff });
+               set_option("volume", &(u8[]){ 0x03 });
+               /* set baudrate to 115200 baud */
+               set_option("baud_rate", &(u8[]){ 0x05 });
+               /* set default debug_level (DEFAULT_CONSOLE_LOGLEVEL starts at 1) */
+               set_option("debug_level", &(u8[]) { CONFIG_DEFAULT_CONSOLE_LOGLEVEL+1 });
+               set_option("cmos_defaults_loaded", &(u8[]){ 0x01 });
+       }
 }
 
 struct chip_operations mainboard_ops = {