Jonathan A. Kollasch | d9628ec | 2015-06-14 13:13:52 -0500 | [diff] [blame^] | 1 | #include <arch/io.h> |
| 2 | #include <console/console.h> |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 3 | #include <device/device.h> |
Jonathan A. Kollasch | d9628ec | 2015-06-14 13:13:52 -0500 | [diff] [blame^] | 4 | #include <device/pnp_def.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <superio/winbond/w83627thg/w83627thg.h> |
| 7 | |
| 8 | static void hwm_write(u16 base, u8 bank, u8 reg, u8 value) |
| 9 | { |
| 10 | outb(0x4e, base + 0x05); |
| 11 | outb(bank, base + 0x06); |
| 12 | outb(reg, base + 0x05); |
| 13 | outb(value, base + 0x06); |
| 14 | } |
| 15 | |
| 16 | static void mb6047_hwm_init(void) |
| 17 | { |
| 18 | device_t dev; |
| 19 | struct resource *res; |
| 20 | size_t i; |
| 21 | |
| 22 | static const struct { u8 bnk; u8 idx; u8 dat; } hwmtab[] = { |
| 23 | { 0x00, 0x5d, 0x05 }, /* CPUTIN diode */ |
| 24 | { 0x04, 0x55, 0x32 }, /* CPUTIN offset */ |
| 25 | { 0x00, 0x4e, 0x00 }, /* reset bank */ |
| 26 | }; |
| 27 | |
| 28 | dev = dev_find_slot_pnp(0x2e, W83627THG_HWM); |
| 29 | if (dev == NULL) |
| 30 | return; |
| 31 | |
| 32 | res = find_resource(dev, PNP_IDX_IO0); |
| 33 | if (res == NULL) |
| 34 | return; |
| 35 | |
| 36 | printk(BIOS_INFO, "setting up hardware monitor at 0x%04x\n", (unsigned int)res->base); |
| 37 | |
| 38 | /* Init hardware monitor. */ |
| 39 | for (i = 0; i < ARRAY_SIZE(hwmtab); i++) { |
| 40 | hwm_write(res->base, hwmtab[i].bnk, hwmtab[i].idx, hwmtab[i].dat); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | static void mb6047_mainboard_init(device_t dev) |
| 45 | { |
| 46 | mb6047_hwm_init(); |
| 47 | } |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 48 | |
| 49 | static void mainboard_enable(device_t dev) |
| 50 | { |
Jonathan A. Kollasch | d9628ec | 2015-06-14 13:13:52 -0500 | [diff] [blame^] | 51 | dev->ops->init = mb6047_mainboard_init; |
Vladimir Serbinenko | 6985d4e | 2014-09-21 14:31:19 +0200 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | struct chip_operations mainboard_ops = { |
| 55 | .enable_dev = mainboard_enable, |
| 56 | }; |