Angel Pons | 08da24e | 2020-04-03 01:21:24 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 2 | |
| 3 | #include <amdblocks/acpimmio.h> |
| 4 | #include <bootblock_common.h> |
Elyes HAOUAS | e1b1bc9 | 2020-08-26 19:59:16 +0200 | [diff] [blame] | 5 | #include <device/pnp_def.h> |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 6 | #include <device/pnp_ops.h> |
| 7 | #include <superio/ite/common/ite.h> |
| 8 | #include <superio/ite/it8728f/it8728f.h> |
| 9 | |
| 10 | #define SERIAL_DEV PNP_DEV(0x2e, IT8728F_SP1) |
| 11 | #define GPIO_DEV PNP_DEV(0x2e, IT8728F_GPIO) |
| 12 | #define ENVC_DEV PNP_DEV(0x2e, IT8728F_EC) |
| 13 | |
| 14 | static void ite_evc_conf(pnp_devfn_t dev) |
| 15 | { |
| 16 | pnp_enter_conf_state(dev); |
| 17 | pnp_set_logical_device(dev); |
Elyes HAOUAS | e1b1bc9 | 2020-08-26 19:59:16 +0200 | [diff] [blame] | 18 | pnp_write_config(dev, PNP_IDX_MSC1, 0x40); |
| 19 | pnp_write_config(dev, PNP_IDX_MSC4, 0x80); |
| 20 | pnp_write_config(dev, PNP_IDX_MSC5, 0x00); |
| 21 | pnp_write_config(dev, PNP_IDX_MSC6, 0xf0); |
| 22 | pnp_write_config(dev, PNP_IDX_MSC9, 0x48); |
| 23 | pnp_write_config(dev, PNP_IDX_MSCA, 0x00); |
| 24 | pnp_write_config(dev, PNP_IDX_MSCB, 0x00); |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 25 | pnp_exit_conf_state(dev); |
| 26 | } |
| 27 | |
| 28 | static void ite_gpio_conf(pnp_devfn_t dev) |
| 29 | { |
| 30 | pnp_enter_conf_state(dev); |
| 31 | pnp_set_logical_device(dev); |
| 32 | pnp_write_config(dev, 0x25, 0x80); |
| 33 | pnp_write_config(dev, 0x26, 0x07); |
| 34 | pnp_write_config(dev, 0x28, 0x81); |
| 35 | pnp_write_config(dev, 0x2c, 0x06); |
Elyes HAOUAS | e1b1bc9 | 2020-08-26 19:59:16 +0200 | [diff] [blame] | 36 | pnp_write_config(dev, PNP_IDX_IRQ1, 0x00); |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 37 | pnp_write_config(dev, 0x73, 0x00); |
| 38 | pnp_write_config(dev, 0xb3, 0x01); |
| 39 | pnp_write_config(dev, 0xb8, 0x00); |
| 40 | pnp_write_config(dev, 0xc0, 0x00); |
| 41 | pnp_write_config(dev, 0xc3, 0x00); |
| 42 | pnp_write_config(dev, 0xc8, 0x00); |
| 43 | pnp_write_config(dev, 0xc9, 0x07); |
| 44 | pnp_write_config(dev, 0xcb, 0x01); |
Elyes HAOUAS | e1b1bc9 | 2020-08-26 19:59:16 +0200 | [diff] [blame] | 45 | pnp_write_config(dev, PNP_IDX_MSC0, 0x10); |
| 46 | pnp_write_config(dev, PNP_IDX_MSC4, 0x27); |
| 47 | pnp_write_config(dev, PNP_IDX_MSC8, 0x20); |
| 48 | pnp_write_config(dev, PNP_IDX_MSC9, 0x01); |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 49 | pnp_exit_conf_state(dev); |
| 50 | } |
| 51 | |
| 52 | void bootblock_mainboard_early_init(void) |
| 53 | { |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 54 | /* Disable PCI-PCI bridge and release GPIO32/33 for other uses. */ |
| 55 | pm_write8(0xea, 0x1); |
| 56 | |
| 57 | /* Set auxiliary output clock frequency on OSCOUT1 pin to be 48MHz */ |
Michał Żygowski | af258cc | 2019-12-01 17:42:04 +0100 | [diff] [blame] | 58 | misc_write32(0x28, misc_read32(0x28) & 0xfff8ffff); |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 59 | |
| 60 | /* Enable Auxiliary Clock1, disable FCH 14 MHz OscClk */ |
Michał Żygowski | af258cc | 2019-12-01 17:42:04 +0100 | [diff] [blame] | 61 | misc_write32(0x40, misc_read32(0x40) & 0xffffbffb); |
Sergej Ivanov | fc749b23 | 2019-12-13 23:04:47 +0000 | [diff] [blame] | 62 | |
| 63 | /* Configure SIO as made under vendor BIOS */ |
| 64 | ite_evc_conf(ENVC_DEV); |
| 65 | ite_gpio_conf(GPIO_DEV); |
| 66 | |
| 67 | /* Enable serial output on it8728f */ |
| 68 | ite_kill_watchdog(GPIO_DEV); |
| 69 | ite_enable_serial(SERIAL_DEV, CONFIG_TTYS0_BASE); |
| 70 | } |