Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <arch/io.h> |
| 18 | #include <console/console.h> |
| 19 | #include <device/device.h> |
| 20 | #include <device/pnp.h> |
| 21 | #include "chip.h" |
Rudolf Marek | 4405b06 | 2014-05-13 16:46:21 +0200 | [diff] [blame] | 22 | #include "it8728f_internal.h" |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 23 | |
| 24 | /* |
| 25 | * FAN controller configuration register index's |
| 26 | */ |
| 27 | #define HWM_MAIN_CTL_REG 0x13 /* default 0x07 */ |
Rudolf Marek | 4405b06 | 2014-05-13 16:46:21 +0200 | [diff] [blame] | 28 | #define HWM_CTL_REG 0x14 /* default 0x40 */ |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 29 | #define HWM_FAN1_CTL_PWM 0x15 /* default 0x00 */ |
| 30 | #define HWM_FAN2_CTL_PWM 0x16 /* default 0x00 */ |
| 31 | #define HWM_FAN3_CTL_PWM 0x17 /* default 0x00 */ |
| 32 | #define HWM_ADC_TEMP_CHAN_EN_REG 0x51 /* default 0x00 */ |
| 33 | |
Edward O'Callaghan | 2c9d2cf | 2014-10-27 23:29:29 +1100 | [diff] [blame] | 34 | void it8728f_hwm_ec_init(struct device *dev) |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 35 | { |
| 36 | struct superio_ite_it8728f_config *conf = dev->chip_info; |
| 37 | struct resource *res = find_resource(dev, PNP_IDX_IO0); |
| 38 | |
| 39 | if (!res) { |
| 40 | printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); |
| 41 | return; |
| 42 | } |
Rudolf Marek | 4405b06 | 2014-05-13 16:46:21 +0200 | [diff] [blame] | 43 | /* I/O port for HWM is at base + 5 */ |
| 44 | u16 port = res->base + 5; |
Edward O'Callaghan | 946bee1 | 2014-05-06 18:00:07 +1000 | [diff] [blame] | 45 | |
| 46 | printk(BIOS_INFO, |
| 47 | "ITE IT8728F Super I/O HWM: Initializing Hardware Monitor..\n"); |
| 48 | printk(BIOS_DEBUG, |
| 49 | "ITE IT8728F Super I/O HWM: Base Address at 0x%x\n", port); |
| 50 | |
| 51 | pnp_enter_conf_mode(dev); |
| 52 | pnp_set_logical_device(dev); |
| 53 | |
| 54 | /* ITE IT8728F HWM (ordered) programming sequence. */ |
| 55 | |
| 56 | /* configure fan polarity */ |
| 57 | pnp_write_index(port, HWM_CTL_REG, conf->hwm_ctl_register); |
| 58 | |
| 59 | /* enable fans 1-3 */ |
| 60 | pnp_write_index(port, HWM_MAIN_CTL_REG, conf->hwm_main_ctl_register); |
| 61 | |
| 62 | /* enable termistor temps for temp1-temp3 */ |
| 63 | pnp_write_index(port, HWM_ADC_TEMP_CHAN_EN_REG, conf->hwm_adc_temp_chan_en_reg); |
| 64 | |
| 65 | /* configure which fanX uses which tempY */ |
| 66 | pnp_write_index(port, HWM_FAN1_CTL_PWM, conf->hwm_fan1_ctl_pwm); |
| 67 | pnp_write_index(port, HWM_FAN2_CTL_PWM, conf->hwm_fan2_ctl_pwm); |
| 68 | pnp_write_index(port, HWM_FAN3_CTL_PWM, conf->hwm_fan3_ctl_pwm); |
| 69 | |
| 70 | pnp_exit_conf_mode(dev); |
| 71 | } |