static void nct5572d_init(struct device *dev) { uint8_t byte; uint8_t power_status; uint8_t mouse_detected; if (!dev->enabled) return; switch (dev->path.pnp.device) { /* TODO: Might potentially need code for HWM or FDC etc. */ case NCT5572D_KBC: /* Enable mouse controller */ pnp_enter_conf_mode_8787(dev); byte = pnp_read_config(dev, 0x2a); byte &= ~(0x1 << 1); pnp_write_config(dev, 0x2a, byte); pnp_exit_conf_mode_aa(dev); mouse_detected = pc_keyboard_init(PROBE_AUX_DEVICE); if (!mouse_detected) { printk(BIOS_INFO, "%s: Disable mouse controller.", __func__); pnp_enter_conf_mode_8787(dev); byte = pnp_read_config(dev, 0x2a); byte |= 0x1 << 1; pnp_write_config(dev, 0x2a, byte); pnp_exit_conf_mode_aa(dev); } break; case NCT5572D_ACPI: /* Set power state after power fail */ power_status = CONFIG_MAINBOARD_POWER_ON_AFTER_POWER_FAIL; get_option(&power_status, "power_on_after_fail"); pnp_enter_conf_mode_8787(dev); pnp_set_logical_device(dev); byte = pnp_read_config(dev, 0xe4); byte &= ~0x60; if (power_status == 1) byte |= (0x1 << 5); /* Force power on */ else if (power_status == 2) byte |= (0x2 << 5); /* Use last power state */ pnp_write_config(dev, 0xe4, byte); pnp_exit_conf_mode_aa(dev); printk(BIOS_INFO, "set power %s after power fail\n", power_status ? "on" : "off"); break; } }
static void lpc47n217_pnp_set_enable(device_t dev, int enable) { u8 power_register = 0, power_mask = 0, current_power, new_power; switch(dev->path.pnp.device) { case LPC47N217_PP: power_register = 0x01; power_mask = 0x04; break; case LPC47N217_SP1: power_register = 0x02; power_mask = 0x08; break; case LPC47N217_SP2: power_register = 0x02; power_mask = 0x80; break; default: BUG(); return; } current_power = pnp_read_config(dev, power_register); new_power = current_power & ~power_mask; /* Disable by default. */ if (enable) { struct resource* ioport_resource; ioport_resource = find_resource(dev, PNP_IDX_IO0); lpc47n217_pnp_set_iobase(dev, ioport_resource->base); new_power |= power_mask; /* Enable. */ } else { lpc47n217_pnp_set_iobase(dev, 0); } pnp_write_config(dev, power_register, new_power); }
static void lpc47n217_pnp_set_irq(device_t dev, u8 irq) { u8 irq_config_register = 0, irq_config_mask = 0; u8 current_config, new_config; switch(dev->path.pnp.device) { case LPC47N217_PP: irq_config_register = 0x27; irq_config_mask = 0x0F; break; case LPC47N217_SP1: irq_config_register = 0x28; irq_config_mask = 0xF0; irq <<= 4; break; case LPC47N217_SP2: irq_config_register = 0x28; irq_config_mask = 0x0F; break; default: BUG(); return; } ASSERT(!(irq & ~irq_config_mask)); /* IRQ out of range? */ current_config = pnp_read_config(dev, irq_config_register); new_config = (current_config & ~irq_config_mask) | irq; pnp_write_config(dev, irq_config_register, new_config); }
static void route_pins_to_uart(struct device *dev, bool to_uart) { u8 reg; reg = pnp_read_config(dev, 0x1c); switch (dev->path.pnp.device) { case NCT5104D_SP3: case NCT5104D_GPIO0: /* Route pins 33 - 40. */ if (to_uart) reg |= (1 << 3); else reg &= ~(1 << 3); break; case NCT5104D_SP4: case NCT5104D_GPIO1: /* Route pins 41 - 48. */ if (to_uart) reg |= (1 << 2); else reg &= ~(1 << 2); break; default: break; } pnp_write_config(dev, 0x1c, reg); }
void lpc47n227_pnp_set_irq(struct device *dev, u8 irq) { u8 irq_config_register = 0, irq_config_mask = 0; u8 current_config, new_config; switch (dev->path.pnp.device) { case LPC47N227_PP: irq_config_register = 0x27; irq_config_mask = 0x0F; break; case LPC47N227_SP1: irq_config_register = 0x28; irq_config_mask = 0xF0; irq <<= 4; break; case LPC47N227_SP2: irq_config_register = 0x28; irq_config_mask = 0x0F; break; case LPC47N227_KBDC: break; default: BUG(); return; } current_config = pnp_read_config(dev, irq_config_register); new_config = (current_config & ~irq_config_mask) | irq; pnp_write_config(dev, irq_config_register, new_config); }
/** * Print the values of all of the LPC47M10X2's configuration registers. * * NOTE: The LPC47M10X2 must be in config mode when this function is called. * * @param dev Pointer to structure describing a Super I/O device. */ static void dump_pnp_device(device_t dev) { int i; print_debug("\n"); for (i = 0; i <= LPC47M10X2_MAX_CONFIG_REGISTER; i++) { u8 register_value; if ((i & 0x0f) == 0) { print_debug_hex8(i); print_debug_char(':'); } /* * Skip over 'register' that would cause exit from * configuration mode. */ if (i == 0xaa) register_value = 0xaa; else register_value = pnp_read_config(dev, i); print_debug_char(' '); print_debug_hex8(register_value); if ((i & 0x0f) == 0x0f) print_debug("\n"); } print_debug("\n"); }
static void enable_hwm_smbus(device_t dev) { /* Enable SensorBus register access. */ u8 reg8; reg8 = pnp_read_config(dev, 0xf0); reg8 |= (1 << 1); pnp_write_config(dev, 0xf0, reg8); }
static void enable_hwm_smbus(struct device *dev) { u8 reg8; /* Configure pins 91/92 as SDA/SCL (I2C bus). */ reg8 = pnp_read_config(dev, 0x2a); reg8 |= (1 << 1); pnp_write_config(dev, 0x2a, reg8); }
static void w83627dhg_enable_UR2(struct device *dev) { u8 reg8; pnp_enter_conf_mode(dev); reg8 = pnp_read_config(dev, 0x2c); reg8 |= (0x3); pnp_write_config(dev, 0x2c, reg8); // Set pins 78-85-> UART B pnp_exit_conf_mode(dev); }
static void sio_init(void) { u8 reg; pnp_enter_ext_func_mode(SERIAL_DEV); /* We have 24MHz input. */ reg = pnp_read_config(SERIAL_DEV, 0x24); pnp_write_config(SERIAL_DEV, 0x24, (reg & ~0x40)); /* We have GPIO for KB/MS pin. */ reg = pnp_read_config(SERIAL_DEV, 0x2a); pnp_write_config(SERIAL_DEV, 0x2a, (reg | 1)); /* We have all RESTOUT and even some reserved bits, too. */ reg = pnp_read_config(SERIAL_DEV, 0x2c); pnp_write_config(SERIAL_DEV, 0x2c, (reg | 0xf0)); pnp_exit_ext_func_mode(SERIAL_DEV); pnp_enter_ext_func_mode(ACPI_DEV); pnp_set_logical_device(ACPI_DEV); /* * Set the delay rising time from PWROK_LP to PWROK_ST to * 300 - 600ms, and 0 to vice versa. */ reg = pnp_read_config(ACPI_DEV, 0xe6); pnp_write_config(ACPI_DEV, 0xe6, (reg & 0xf0)); /* 1 Use external suspend clock source 32.768KHz. Undocumented?? */ reg = pnp_read_config(ACPI_DEV, 0xe4); pnp_write_config(ACPI_DEV, 0xe4, (reg | 0x10)); pnp_exit_ext_func_mode(ACPI_DEV); pnp_enter_ext_func_mode(GPIO_DEV); pnp_set_logical_device(GPIO_DEV); /* Set memory voltage to 2.75V, vcore offset + 100mV, 1.5V chipset voltage. */ pnp_write_config(GPIO_DEV, 0x30, 0x09); /* Enable GPIO 2 & GPIO 5. */ pnp_write_config(GPIO_DEV, 0xe2, 0x00); /* No inversion */ pnp_write_config(GPIO_DEV, 0xe5, 0x00); /* No inversion */ pnp_write_config(GPIO_DEV, 0xe3, 0x03); /* 0000 0011, 0=output 1=input */ pnp_write_config(GPIO_DEV, 0xe0, 0xde); /* 1101 1110, 0=output 1=input */ pnp_write_config(GPIO_DEV, 0xe1, 0x01); /* Set output val. */ pnp_write_config(GPIO_DEV, 0xe4, 0xb4); /* Set output val (1011 0100). */ pnp_exit_ext_func_mode(GPIO_DEV); }
/* * Set the UART clock source. * * Possible UART clock source speeds are: * * 0 = 1.8462 MHz (default) * 1 = 2 MHz * 2 = 24 MHz * 3 = 14.769 MHz * * The faster clocks allow for BAUD rates up to 2mbits. * * Warning: The kernel will need to be adjusted since it assumes * a 1.8462 MHz clock. */ static void set_uart_clock_source(struct device *dev, u8 uart_clock) { u8 value; pnp_enter_conf_mode(dev); pnp_set_logical_device(dev); value = pnp_read_config(dev, 0xf0); value &= ~0x03; value |= (uart_clock & 0x03); pnp_write_config(dev, 0xf0, value); pnp_exit_conf_mode(dev); }
/* * Set the UART clock source. * * Possible UART clock source speeds are: * * 0 = 1.8462 MHz (default) * 1 = 2 MHz * 2 = 24 MHz * 3 = 14.769 MHz * * The faster clocks allow for BAUD rates up to 2mbits. * * Warning: The kernel will need to be adjusted since it assumes * a 1.8462 MHz clock. */ static void set_uart_clock_source(device_t dev, u8 uart_clock) { u8 value; w83627uhg_enter_ext_func_mode(dev); pnp_set_logical_device(dev); value = pnp_read_config(dev, 0xf0); value &= ~0x03; value |= (uart_clock & 0x03); pnp_write_config(dev, 0xf0, value); w83627uhg_exit_ext_func_mode(dev); }
static void mainboard_set_e7520_pll(unsigned bits) { uint16_t gpio_index; uint8_t data; device_t dev; /* currently only handle the Jarrell/PC87427 case */ dev = PC87427_GPIO_DEV; pnp_set_logical_device(dev); gpio_index = pnp_read_iobase(dev, 0x60); /* select SIO GPIO port 4, pin 2 */ pnp_write_config(dev, PC87427_GPSEL, ((pnp_read_config(dev, PC87427_GPSEL) & 0x88) | 0x42)); /* set to push-pull, enable output */ pnp_write_config(dev, PC87427_GPCFG1, 0x03); /* select SIO GPIO port 4, pin 4 */ pnp_write_config(dev, PC87427_GPSEL, ((pnp_read_config(dev, PC87427_GPSEL) & 0x88) | 0x44)); /* set to push-pull, enable output */ pnp_write_config(dev, PC87427_GPCFG1, 0x03); /* set gpio 42,44 signal levels */ data = inb(gpio_index + PC87427_GPDO_4); if ((data & 0x14) == (0xff & (((bits&2)?0:1)<<4 | ((bits&1)?0:1)<<2))) { print_debug("set_pllsel: correct settings detected!\n"); return; /* settings already configured */ } else { outb((data & 0xeb) | ((bits&2)?0:1)<<4 | ((bits&1)?0:1)<<2, gpio_index + PC87427_GPDO_4); /* reset */ print_debug("set_pllsel: settings adjusted, now resetting...\n"); // hard_reset(); /* should activate a PCI_RST, which should reset MCH, but it doesn't seem to work ???? */ // mch_reset(); full_reset(); } return; }
static void sio_init(void) { u8 reg; pnp_enter_ext_func_mode(SERIAL_DEV); reg = pnp_read_config(SERIAL_DEV, 0x24); /* 4 Mbit flash */ reg = (reg & ~0x30) | 0x20; /* We have 24MHz input. */ reg &= ~0x40; /* enable MEMW#, so flash can be written */ reg |= 0x08; pnp_write_config(SERIAL_DEV, 0x24, reg); }
static void init_acpi(device_t dev) { u8 value = 0x20; /* TODO: 0x20 value here never used? */ int power_on = 1; get_option(&power_on, "power_on_after_fail"); pnp_enter_conf_mode(dev); pnp_set_logical_device(dev); value = pnp_read_config(dev, 0xe4); value &= ~(3 << 5); if (power_on) value |= (1 << 5); pnp_write_config(dev, 0xe4, value); pnp_exit_conf_mode(dev); }
void xbus_cfg(pnp_devfn_t dev) { u8 i; u16 xbus_index; pnp_set_logical_device(dev); /* Select proper BIOS size (4MB). */ pnp_write_config(dev, PC87417_XMEMCNF2, (pnp_read_config(dev, PC87417_XMEMCNF2)) | 0x04); xbus_index = pnp_read_iobase(dev, 0x60); /* Enable writes to devices attached to XCS0 (XBUS Chip Select 0). */ for (i = 0; i <= 0xf; i++) outb((i << 4), xbus_index + PC87417_HAP0); }
static void early_superio_config(void) { int timeout = 100000; pnp_devfn_t dev = PNP_DEV(0x2e, 3); pnp_write_config(dev, 0x29, 0x06); while (!(pnp_read_config(dev, 0x29) & 0x08) && timeout--) udelay(1000); /* Enable COM1 */ pnp_set_logical_device(dev); pnp_set_iobase(dev, PNP_IDX_IO0, 0x3f8); pnp_set_enable(dev, 1); }
static void init_acpi(struct device *dev) { u8 value; int power_on = 1; get_option(&power_on, "power_on_after_fail"); pnp_enter_conf_mode(dev); pnp_set_logical_device(dev); value = pnp_read_config(dev, 0xe4); value &= ~(3 << 5); if (power_on) value |= (1 << 5); pnp_write_config(dev, 0xe4, value); pnp_exit_conf_mode(dev); }
static void set_irq_trigger_type(struct device *dev, bool trig_level) { u8 reg10, reg11, reg26; //Before accessing CR10 OR CR11 Bit 4 in CR26 must be set to 1 reg26 = pnp_read_config(dev, GLOBAL_OPTION_CR26); reg26 |= CR26_LOCK_REG; pnp_write_config(dev, GLOBAL_OPTION_CR26, reg26); switch(dev->path.pnp.device) { //SP1 (UARTA) IRQ type selection (1:level,0:edge) is controlled by CR 10, bit 5 case NCT5104D_SP1: reg10 = pnp_read_config(dev, IRQ_TYPE_SEL_CR10); if (trig_level) reg10 |= (1 << 5); else reg10 &= ~(1 << 5); pnp_write_config(dev, IRQ_TYPE_SEL_CR10, reg10); break; //SP2 (UARTB) IRQ type selection (1:level,0:edge) is controlled by CR 10, bit 4 case NCT5104D_SP2: reg10 = pnp_read_config(dev, IRQ_TYPE_SEL_CR10); if (trig_level) reg10 |= (1 << 4); else reg10 &= ~(1 << 4); pnp_write_config(dev, IRQ_TYPE_SEL_CR10, reg10); break; //SP3 (UARTC) IRQ type selection (1:level,0:edge) is controlled by CR 11, bit 5 case NCT5104D_SP3: reg11 = pnp_read_config(dev,IRQ_TYPE_SEL_CR11); if (trig_level) reg11 |= (1 << 5); else reg11 &= ~(1 << 5); pnp_write_config(dev, IRQ_TYPE_SEL_CR11, reg11); break; //SP4 (UARTD) IRQ type selection (1:level,0:edge) is controlled by CR 11, bit 4 case NCT5104D_SP4: reg11 = pnp_read_config(dev,IRQ_TYPE_SEL_CR11); if (trig_level) reg11 |= (1 << 4); else reg11 &= ~(1 << 4); pnp_write_config(dev, IRQ_TYPE_SEL_CR11, reg11); break; default: break; } //Clear access control register reg26 = pnp_read_config(dev, GLOBAL_OPTION_CR26); reg26 &= ~CR26_LOCK_REG; pnp_write_config(dev, GLOBAL_OPTION_CR26, reg26); }
static void lpc47n217_pnp_set_drq(device_t dev, u8 drq) { const u8 PP_DMA_MASK = 0x0F; const u8 PP_DMA_SELECTION_REGISTER = 0x26; u8 current_config, new_config; if (dev->path.pnp.device == LPC47N217_PP) { current_config = pnp_read_config(dev, PP_DMA_SELECTION_REGISTER); ASSERT(!(drq & ~PP_DMA_MASK)); /* DRQ out of range? */ new_config = (current_config & ~PP_DMA_MASK) | drq; pnp_write_config(dev, PP_DMA_SELECTION_REGISTER, new_config); } else { BUG(); } }
void lpc47n227_pnp_set_drq(device_t dev, unsigned drq) { if (dev->path.pnp.device == LPC47N227_PP) { const uint8_t PP_DMA_MASK = 0x0F; const uint8_t PP_DMA_SELECTION_REGISTER = 0x26; uint8_t current_config = pnp_read_config(dev, PP_DMA_SELECTION_REGISTER); uint8_t new_config; ASSERT(!(drq & ~PP_DMA_MASK)); // DRQ out of range?? new_config = (current_config & ~PP_DMA_MASK) | drq; pnp_write_config(dev, PP_DMA_SELECTION_REGISTER, new_config); } else { BUG(); } }
int drivers_lenovo_is_wacom_present(void) { const char *pn; int i; static int result = -1; struct device *superio; u8 sioid; if (result != -1) return result; if (CONFIG(DIGITIZER_PRESENT)) { printk (BIOS_INFO, "Digitizer state forced as present\n"); return (result = 1); } if (CONFIG(DIGITIZER_ABSENT)) { printk (BIOS_INFO, "Digitizer state forced as absent\n"); return (result = 0); } superio = dev_find_slot_pnp (0x164e, 3); if (!superio) { printk (BIOS_INFO, "No Super I/O, skipping wacom\n"); return (result = 0); } /* Probe ID. */ sioid = pnp_read_config(superio, 0x20); if (sioid == 0xff) { printk (BIOS_INFO, "Super I/O probe failed, skipping wacom\n"); return (result = 0); } pn = lenovo_mainboard_partnumber(); if (!pn) return (result = 0); printk (BIOS_DEBUG, "Lenovo P/N is %s\n", pn); for (i = 0; i < ARRAY_SIZE (tablet_numbers); i++) if (memcmp (tablet_numbers[i], pn, 4) == 0) { printk (BIOS_DEBUG, "Lenovo P/N %s is a tablet\n", pn); return (result = 1); } printk (BIOS_DEBUG, "Lenovo P/N %s is not a tablet\n", pn); return (result = 0); }
static void sio_init(void) { u8 reg; pnp_enter_ext_func_mode(GPIO2345_DEV); pnp_set_logical_device(GPIO2345_DEV); /* Pin 119 ~ 120 GP21, GP20 */ reg = pnp_read_config(GPIO2345_DEV, 0x29); pnp_write_config(GPIO2345_DEV, 0x29, (reg | 2)); /* todo document this */ pnp_write_config(GPIO2345_DEV, 0x2c, 0x1); pnp_write_config(GPIO2345_DEV, 0x2d, 0x1); //idx 30 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 f0 f1 f2 f3 f4 f5 f6 f7 fe //val 07 XX XX XX f6 0e 00 00 00 00 ff d6 96 00 40 d0 83 00 00 07 //GPO20 - 1 = 1.82 0 = 1.92 sideport voltage //mGPUV GPO40 | GPO41 | GPIO23 - 000 - 1.45V step 0.05 -- 111 - 1.10V //DDR voltage 44 45 46 /* GPO20 - sideport voltage GPO23 - mgpuV */ pnp_write_config(GPIO2345_DEV, 0x30, 0x07); /* Enable GPIO 2,3,4. */ pnp_write_config(GPIO2345_DEV, 0xe3, 0xf6); /* dir of GPIO2 11110110*/ pnp_write_config(GPIO2345_DEV, 0xe4, 0x0e); /* data */ pnp_write_config(GPIO2345_DEV, 0xe5, 0x00); /* No inversion */ /* GPO30 GPO33 GPO35 */ //GPO35 - loadline control 0 - enabled //GPIO30 - unknown //GPIO33 - unknown pnp_write_config(GPIO2345_DEV, 0xf0, 0xd6); /* dir of GPIO3 11010110*/ pnp_write_config(GPIO2345_DEV, 0xf1, 0x96); /* data */ pnp_write_config(GPIO2345_DEV, 0xf2, 0x00); /* No inversion */ /* GPO40 GPO41 GPO42 GPO43 PO45 */ pnp_write_config(GPIO2345_DEV, 0xf4, 0xd0); /* dir of GPIO4 11010000 */ pnp_write_config(GPIO2345_DEV, 0xf5, 0x83); /* data */ pnp_write_config(GPIO2345_DEV, 0xf6, 0x00); /* No inversion */ pnp_write_config(GPIO2345_DEV, 0xf7, 0x00); /* MFC */ pnp_write_config(GPIO2345_DEV, 0xf8, 0x00); /* MFC */ pnp_write_config(GPIO2345_DEV, 0xfe, 0x07); /* trig type */ pnp_exit_ext_func_mode(GPIO2345_DEV); }
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) { static const uint16_t spd_addr [] = { // Node 0 DIMM0, DIMM2, 0, 0, DIMM1, DIMM3, 0, 0, // Node 1 DIMM4, DIMM6, 0, 0, DIMM5, DIMM7, 0, 0, }; struct sys_info *sysinfo = &sysinfo_car; int needs_reset = 0; unsigned bsp_apicid = 0; if (!cpu_init_detectedx && boot_cpu()) { /* Nothing special needs to be done to find bus 0 */ /* Allow the HT devices to be found */ enumerate_ht_chain(); sio_setup(); } if (bist == 0) bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo); #if 0 uint8_t tmp = 0; pnp_enter_ext_func_mode(SERIAL_DEV); /* The following line will set CLKIN to 24 MHz, external */ pnp_write_config(SERIAL_DEV, IT8716F_CONFIG_REG_CLOCKSEL, 0x11); tmp = pnp_read_config(SERIAL_DEV, IT8716F_CONFIG_REG_SWSUSP); /* Is serial flash enabled? Then enable writing to serial flash. */ if (tmp & 0x0e) { pnp_write_config(SERIAL_DEV, IT8716F_CONFIG_REG_SWSUSP, tmp | 0x10); pnp_set_logical_device(GPIO_DEV); /* Set Serial Flash interface to 0x0820 */ pnp_write_config(GPIO_DEV, 0x64, 0x08); pnp_write_config(GPIO_DEV, 0x65, 0x20); } it8716f_enable_dev(SERIAL_DEV, CONFIG_TTYS0_BASE); pnp_exit_ext_func_mode(SERIAL_DEV); #endif ite_conf_clkin(CLKIN_DEV, ITE_UART_CLK_PREDIVIDE_48); ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); setup_mb_resource_map(); console_init(); /* Halt if there was a built in self test failure */ report_bist_failure(bist); printk(BIOS_DEBUG, "*sysinfo range: [%p,%p]\n",sysinfo,sysinfo+1); print_debug("bsp_apicid="); print_debug_hex8(bsp_apicid); print_debug("\n"); set_sysinfo_in_ram(0); // in BSP so could hold all ap until sysinfo is in ram setup_coherent_ht_domain(); // routing table and start other core0 wait_all_core0_started(); #if CONFIG_LOGICAL_CPUS // It is said that we should start core1 after all core0 launched /* becase optimize_link_coherent_ht is moved out from setup_coherent_ht_domain, * So here need to make sure last core0 is started, esp for two way system, * (there may be apic id conflicts in that case) */ start_other_cores(); wait_all_other_cores_started(bsp_apicid); #endif /* it will set up chains and store link pair for optimization later */ ht_setup_chains_x(sysinfo); // it will init sblnk and sbbusn, nodes, sbdn #if CONFIG_SET_FIDVID { msr_t msr; msr=rdmsr(0xc0010042); print_debug("begin msr fid, vid "); print_debug_hex32( msr.hi ); print_debug_hex32(msr.lo); print_debug("\n"); } enable_fid_change(); enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn); init_fidvid_bsp(bsp_apicid); // show final fid and vid { msr_t msr; msr=rdmsr(0xc0010042); print_debug("end msr fid, vid "); print_debug_hex32( msr.hi ); print_debug_hex32(msr.lo); print_debug("\n"); } #endif init_timer(); // Need to use TMICT to synconize FID/VID needs_reset |= optimize_link_coherent_ht(); needs_reset |= optimize_link_incoherent_ht(sysinfo); needs_reset |= mcp55_early_setup_x(); // fidvid change will issue one LDTSTOP and the HT change will be effective too if (needs_reset) { print_info("ht reset -\n"); soft_reset(); } allow_all_aps_stop(bsp_apicid); //It's the time to set ctrl in sysinfo now; fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr); enable_smbus(); /* all ap stopped? */ sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo); post_cache_as_ram(); // bsp swtich stack to ram and copy sysinfo ram now }
static void nct5104d_init(device_t dev) { struct superio_nuvoton_nct5104d_config *conf = dev->chip_info; u8 reg10, reg11, reg26; if (!dev->enabled) return; pnp_enter_conf_mode(dev); //Before accessing CR10 OR CR11 Bit 4 in CR26 must be set to 1 reg26 = pnp_read_config(dev, GLOBAL_OPTION_CR26); reg26 |= CR26_LOCK_REG; pnp_write_config(dev, GLOBAL_OPTION_CR26, reg26); switch(dev->path.pnp.device) { //SP1 (UARTA) IRQ type selection (1:level,0:edge) is controlled by CR 10, bit 5 case NCT5104D_SP1: reg10 = pnp_read_config(dev, IRQ_TYPE_SEL_CR10); if (conf->irq_trigger_type) reg10 |= (1 << 5); else reg10 &= ~(1 << 5); pnp_write_config(dev, IRQ_TYPE_SEL_CR10, reg10); break; //SP2 (UARTB) IRQ type selection (1:level,0:edge) is controlled by CR 10, bit 4 case NCT5104D_SP2: reg10 = pnp_read_config(dev, IRQ_TYPE_SEL_CR10); if (conf->irq_trigger_type) reg10 |= (1 << 4); else reg10 &= ~(1 << 4); pnp_write_config(dev, IRQ_TYPE_SEL_CR10, reg10); break; //SP3 (UARTC) IRQ type selection (1:level,0:edge) is controlled by CR 11, bit 5 case NCT5104D_SP3: reg11 = pnp_read_config(dev,IRQ_TYPE_SEL_CR11); if (conf->irq_trigger_type) reg11 |= (1 << 5); else reg11 &= ~(1 << 5); pnp_write_config(dev, IRQ_TYPE_SEL_CR11, reg11); break; //SP4 (UARTD) IRQ type selection (1:level,0:edge) is controlled by CR 11, bit 4 case NCT5104D_SP4: reg11 = pnp_read_config(dev,IRQ_TYPE_SEL_CR11); if (conf->irq_trigger_type) reg11 |= (1 << 4); else reg11 &= ~(1 << 4); pnp_write_config(dev, IRQ_TYPE_SEL_CR11, reg11); break; default: break; } //Clear access control register reg26 = pnp_read_config(dev, GLOBAL_OPTION_CR26); reg26 &= ~CR26_LOCK_REG; pnp_write_config(dev, GLOBAL_OPTION_CR26, reg26); pnp_exit_conf_mode(dev); }
/** * Enable the logical devices of the Super I/O chip. * * TODO: Think about how to handle the case when a mainboard has multiple * Super I/O chips soldered on. * TODO: Can this code be simplified a bit? * * @param dev The device to use. */ static void enable_dev(device_t dev) { int i, j, fn; int tmp[MAX_LOGICAL_DEVICES]; u8 test7; if (first_time) { /* Read the device ID and revision of the Super I/O chip. */ smsc_pnp_enter_conf_state(dev); superio_id = pnp_read_config(dev, DEVICE_ID_REG); superio_rev = pnp_read_config(dev, DEVICE_REV_REG); smsc_pnp_exit_conf_state(dev); /* TODO: Error handling? */ printk(BIOS_INFO, "Found SMSC Super I/O (ID=0x%02x, " "rev=0x%02x)\n", superio_id, superio_rev); first_time = 0; if (superio_id == LPC47M172) { /* * Do not use the default logical device number but * instead the standard SMSC registers set. */ /* * TEST7 configuration register (0x29) * Bit 0: LD_NUM (0 = new, 1 = std SMSC) */ test7 = pnp_read_config(dev, DEVICE_TEST7_REG); test7 |= (1 << 0); pnp_write_config(dev, DEVICE_TEST7_REG, test7); } } /* Find the correct Super I/O. */ for (i = 0; i < ARRAY_SIZE(logical_device_table); i++) if (logical_device_table[i].superio_id == superio_id) break; /* If no Super I/O was found, return. */ if (i == ARRAY_SIZE(logical_device_table)) return; /* Temporarily save the LD_FOO values. */ for (j = 0; j < ARRAY_SIZE(pnp_dev_info); j++) tmp[j] = pnp_dev_info[j].function; /* * Replace the LD_FOO markers in pnp_dev_info[] with * the real logical device IDs of this Super I/O chip. */ for (j = 0; j < ARRAY_SIZE(pnp_dev_info); j++) { fn = pnp_dev_info[j].function; pnp_dev_info[j].function = logical_device_table[i].devs[fn]; } /* Enable the specified devices (if present on the chip). */ pnp_enable_devices(dev, &pnp_ops, ARRAY_SIZE(pnp_dev_info), &pnp_dev_info[0]); /* Restore LD_FOO values. */ for (j = 0; j < ARRAY_SIZE(pnp_dev_info); j++) pnp_dev_info[j].function = tmp[j]; }
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) { struct sys_info *sysinfo = &sysinfo_car; u32 bsp_apicid = 0, val, wants_reset; msr_t msr; timestamp_init(timestamp_get()); timestamp_add_now(TS_START_ROMSTAGE); if (!cpu_init_detectedx && boot_cpu()) { /* Nothing special needs to be done to find bus 0 */ /* Allow the HT devices to be found */ set_bsp_node_CHtExtNodeCfgEn(); enumerate_ht_chain(); sio_setup(); } post_code(0x30); if (bist == 0) bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo); post_code(0x32); winbond_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); console_init(); if (CONFIG_MAX_PHYSICAL_CPUS != 2) printk(BIOS_WARNING, "CONFIG_MAX_PHYSICAL_CPUS is %d, but this is a dual socket board!\n", CONFIG_MAX_PHYSICAL_CPUS); /* Halt if there was a built in self test failure */ report_bist_failure(bist); val = cpuid_eax(1); printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); printk(BIOS_DEBUG, "*sysinfo range: [%p,%p]\n",sysinfo,sysinfo+1); printk(BIOS_DEBUG, "bsp_apicid = %02x\n", bsp_apicid); printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); /* Setup sysinfo defaults */ set_sysinfo_in_ram(0); update_microcode(val); post_code(0x33); cpuSetAMDMSR(0); post_code(0x34); amd_ht_init(sysinfo); post_code(0x35); /* Setup nodes PCI space and start core 0 AP init. */ finalize_node_setup(sysinfo); /* Setup any mainboard PCI settings etc. */ setup_mb_resource_map(); post_code(0x36); /* wait for all the APs core0 started by finalize_node_setup. */ /* FIXME: A bunch of cores are going to start output to serial at once. * It would be nice to fix up prink spinlocks for ROM XIP mode. * I think it could be done by putting the spinlock flag in the cache * of the BSP located right after sysinfo. */ wait_all_core0_started(); if (IS_ENABLED(CONFIG_SET_FIDVID)) { msr = rdmsr(0xc0010071); printk(BIOS_DEBUG, "\nBegin FIDVID MSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo); post_code(0x39); if (!warm_reset_detect(0)) { // BSP is node 0 init_fidvid_bsp(bsp_apicid, sysinfo->nodes); } else { init_fidvid_stage2(bsp_apicid, 0); // BSP is node 0 } post_code(0x3A); /* show final fid and vid */ msr = rdmsr(0xc0010071); printk(BIOS_DEBUG, "End FIDVIDMSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo); } if (IS_ENABLED(CONFIG_LOGICAL_CPUS)) { /* Core0 on each node is configured. Now setup any additional cores. */ printk(BIOS_DEBUG, "start_other_cores()\n"); start_other_cores(bsp_apicid); post_code(0x37); wait_all_other_cores_started(bsp_apicid); } printk(BIOS_DEBUG, "set_ck804_base_unit_id()\n"); ck804_control(ctrl_conf_fix_pci_numbering, ARRAY_SIZE(ctrl_conf_fix_pci_numbering), CK804_BOARD_BOOT_BASE_UNIT_UID); post_code(0x38); init_timer(); // Need to use TMICT to synconize FID/VID wants_reset = ck804_early_setup_x(); /* Reset for HT, FIDVID, PLL and errata changes to take affect. */ if (!warm_reset_detect(0)) { printk(BIOS_INFO, "...WARM RESET...\n\n\n"); soft_reset(); die("After soft_reset_x - shouldn't see this message!!!\n"); } if (wants_reset) { printk(BIOS_DEBUG, "ck804_early_setup_x wanted additional reset!\n"); } post_code(0x3B); /* It's the time to set ctrl in sysinfo now; */ printk(BIOS_DEBUG, "fill_mem_ctrl()\n"); fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr); post_code(0x3D); printk(BIOS_DEBUG, "enable_smbus()\n"); enable_smbus(); #if 0 /* FIXME * After the AMD K10 code has been converted to use * IS_ENABLED(CONFIG_DEBUG_SMBUS) uncomment this block */ if (IS_ENABLED(CONFIG_DEBUG_SMBUS)) { dump_spd_registers(&cpu[0]); dump_smbus_registers(); } #endif post_code(0x40); timestamp_add_now(TS_BEFORE_INITRAM); printk(BIOS_DEBUG, "raminit_amdmct()\n"); raminit_amdmct(sysinfo); timestamp_add_now(TS_AFTER_INITRAM); cbmem_initialize_empty(); post_code(0x41); amdmct_cbmem_store_info(sysinfo); printk(BIOS_DEBUG, "disable_spd()\n"); ck804_control(ctrl_conf_disable_spd, ARRAY_SIZE(ctrl_conf_disable_spd), CK804_DEVN_BASE); printk(BIOS_DEBUG, "enable_msi_mapping()\n"); ck804_control(ctrl_conf_enable_msi_mapping, ARRAY_SIZE(ctrl_conf_enable_msi_mapping), CK804_DEVN_BASE); /* Initialize GPIO */ /* Access SuperIO GPI03 logical device */ uint16_t port = GPIO3_DEV >> 8; outb(0x87, port); outb(0x87, port); pnp_set_logical_device(GPIO3_DEV); /* Set GP37 (power LED) to output */ pnp_write_config(GPIO3_DEV, 0xf0, 0x7f); /* Set GP37 (power LED) on */ pnp_write_config(GPIO3_DEV, 0xf1, 0x80); /* Set pin 64 multiplex to GP37 */ uint8_t cr2c = pnp_read_config(GPIO3_DEV, 0x2c); pnp_write_config(GPIO3_DEV, 0x2c, (cr2c & 0xf3) | 0x04); /* Restore default SuperIO access */ outb(0xaa, port); post_cache_as_ram(); // BSP switch stack to ram, copy then execute LB. post_code(0x43); // Should never see this post code. }
void cache_as_ram_main(unsigned long bist, unsigned long cpu_init_detectedx) { struct sys_info *sysinfo = &sysinfo_car; u32 bsp_apicid = 0, val, wants_reset; u8 reg; msr_t msr; if (!cpu_init_detectedx && boot_cpu()) { /* Nothing special needs to be done to find bus 0 */ /* Allow the HT devices to be found */ set_bsp_node_CHtExtNodeCfgEn(); enumerate_ht_chain(); sio_setup(); } post_code(0x30); if (bist == 0) bsp_apicid = init_cpus(cpu_init_detectedx, sysinfo); post_code(0x32); pnp_enter_ext_func_mode(SERIAL_DEV); /* We have 24MHz input. */ reg = pnp_read_config(SERIAL_DEV, 0x24); pnp_write_config(SERIAL_DEV, 0x24, (reg & 0xbf)); pnp_exit_ext_func_mode(SERIAL_DEV); w83627ehg_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); console_init(); /* Halt if there was a built in self test failure */ report_bist_failure(bist); val = cpuid_eax(1); printk(BIOS_DEBUG, "BSP Family_Model: %08x\n", val); printk(BIOS_DEBUG, "*sysinfo range: [%p,%p]\n",sysinfo,sysinfo+1); printk(BIOS_DEBUG, "bsp_apicid = %02x\n", bsp_apicid); printk(BIOS_DEBUG, "cpu_init_detectedx = %08lx\n", cpu_init_detectedx); /* Setup sysinfo defaults */ set_sysinfo_in_ram(0); #if CONFIG_UPDATE_CPU_MICROCODE update_microcode(val); #endif post_code(0x33); cpuSetAMDMSR(); post_code(0x34); amd_ht_init(sysinfo); post_code(0x35); /* Setup nodes PCI space and start core 0 AP init. */ finalize_node_setup(sysinfo); printk(BIOS_DEBUG, "finalize_node_setup done\n"); /* Setup any mainboard PCI settings etc. */ printk(BIOS_DEBUG, "setup_mb_resource_map begin\n"); setup_mb_resource_map(); printk(BIOS_DEBUG, "setup_mb_resource_map end\n"); post_code(0x36); /* wait for all the APs core0 started by finalize_node_setup. */ /* FIXME: A bunch of cores are going to start output to serial at once. * It would be nice to fixup prink spinlocks for ROM XIP mode. * I think it could be done by putting the spinlock flag in the cache * of the BSP located right after sysinfo. */ wait_all_core0_started(); #if CONFIG_LOGICAL_CPUS /* Core0 on each node is configured. Now setup any additional cores. */ printk(BIOS_DEBUG, "start_other_cores()\n"); start_other_cores(); post_code(0x37); printk(BIOS_DEBUG, "wait_all_other_cores_started()\n"); wait_all_other_cores_started(bsp_apicid); #endif post_code(0x38); #if CONFIG_SET_FIDVID msr = rdmsr(0xc0010071); printk(BIOS_DEBUG, "\nBegin FIDVID MSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo); /* FIXME: The sb fid change may survive the warm reset and only * need to be done once.*/ enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn); post_code(0x39); if (!warm_reset_detect(0)) { // BSP is node 0 init_fidvid_bsp(bsp_apicid, sysinfo->nodes); } else { init_fidvid_stage2(bsp_apicid, 0); // BSP is node 0 } post_code(0x3A); /* show final fid and vid */ msr=rdmsr(0xc0010071); printk(BIOS_DEBUG, "End FIDVIDMSR 0xc0010071 0x%08x 0x%08x\n", msr.hi, msr.lo); #endif init_timer(); /* Need to use TMICT to synconize FID/VID. */ wants_reset = mcp55_early_setup_x(); /* Reset for HT, FIDVID, PLL and errata changes to take affect. */ if (!warm_reset_detect(0)) { print_info("...WARM RESET...\n\n\n"); soft_reset(); die("After soft_reset_x - shouldn't see this message!!!\n"); } if (wants_reset) printk(BIOS_DEBUG, "mcp55_early_setup_x wanted additional reset!\n"); post_code(0x3B); /* It's the time to set ctrl in sysinfo now; */ printk(BIOS_DEBUG, "fill_mem_ctrl()\n"); fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr); post_code(0x3D); printk(BIOS_DEBUG, "enable_smbus()\n"); enable_smbus(); post_code(0x40); printk(BIOS_DEBUG, "raminit_amdmct()\n"); raminit_amdmct(sysinfo); post_code(0x41); post_cache_as_ram(); // BSP switch stack to ram, copy then execute LB. post_code(0x43); // Should never see this post code. }
static void sio_init(void) { u8 reg; pnp_enter_ext_func_mode(GPIO2345_DEV); pnp_set_logical_device(GPIO2345_DEV); /* Pin 119 ~ 120 is GP21, GP20 */ reg = pnp_read_config(GPIO2345_DEV, 0x29); pnp_write_config(GPIO2345_DEV, 0x29, (reg | 2)); /* Turn on the Power LED ("Suspend LED" in Super I/O) */ reg = pnp_read_config(GPIO2345_DEV, 0xf3); pnp_write_config(GPIO2345_DEV, 0xf3, (reg | 0x40)); /* todo document this */ pnp_write_config(GPIO2345_DEV, 0x2c, 0x1); pnp_write_config(GPIO2345_DEV, 0x2d, 0x1); /* GPO20 - sideport voltage 1 = 1.82 0 = 1.92 GPI21 - unknown input (NC?) GPI22 - unknown input (NC?) GPO23 - mgpuV bit0 GP24-27 - PS/2 mouse/keyb (only keyb is connected use flip interface for mouse) */ pnp_write_config(GPIO2345_DEV, 0x30, 0x07); /* Enable GPIO 2,3,4. */ pnp_write_config(GPIO2345_DEV, 0xe3, 0xf6); /* dir of GPIO2 11110110*/ pnp_write_config(GPIO2345_DEV, 0xe4, 0x0e); /* data */ pnp_write_config(GPIO2345_DEV, 0xe5, 0x00); /* No inversion */ /* GPIO30 - unknown output, set to 0 GPI31 - unknown input NC? GPI32 - unknown input NC? GPIO33 - unknown output, set to 0. GPI34 - unknown input NC? GPO35 - loadline control 1 = enabled (2 phase clock) 0 = disabled 4 phase clock GPIO36 - input = HT voltage 1.30V output (low) = HT voltage 1.35V GP37 - unknown input NC? */ pnp_write_config(GPIO2345_DEV, 0xf0, 0xd6); /* dir of GPIO3 11010110*/ pnp_write_config(GPIO2345_DEV, 0xf1, 0x96); /* data */ pnp_write_config(GPIO2345_DEV, 0xf2, 0x00); /* No inversion */ /* GPO40 - mgpuV bit2 GPO41 - mgpuV bit1 GPO42 - IRTX GPO43 - IRRX GPIO44 - memory voltage bit2 (input/outputlow) GPIO45 - memory voltage bit1 (2.60 (000) - 2.95 (111)) GPIO46 - memory voltage bit0 GPIO47 - unknown input? */ pnp_write_config(GPIO2345_DEV, 0xf4, 0xd0); /* dir of GPIO4 11010000 */ pnp_write_config(GPIO2345_DEV, 0xf5, 0x83); /* data */ pnp_write_config(GPIO2345_DEV, 0xf6, 0x00); /* No inversion */ pnp_write_config(GPIO2345_DEV, 0xf7, 0x00); /* MFC */ pnp_write_config(GPIO2345_DEV, 0xf8, 0x00); /* MFC */ pnp_write_config(GPIO2345_DEV, 0xfe, 0x07); /* trig type */ pnp_exit_ext_func_mode(GPIO2345_DEV); }