Nicola Corna | 2fca86f | 2017-03-02 08:08:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2014 Edward O'Callaghan <eocallaghan@alterapraxis.com> |
| 5 | * Copyright (C) 2017 Nicola Corna <nicola@corna.info> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | */ |
| 17 | |
| 18 | #include <arch/io.h> |
| 19 | #include <console/console.h> |
| 20 | #include <device/device.h> |
| 21 | #include <device/pnp.h> |
| 22 | #include "fintek_internal.h" |
| 23 | #include "chip.h" |
| 24 | |
| 25 | /* Intel Ibex Peak/PECI/AMD TSI */ |
| 26 | #define HWM_PECI_TSI_CTRL_REG 0x0a |
| 27 | #define HWM_TCC_TEMPERATURE_REG 0x0c |
| 28 | |
| 29 | /* Fan 1 control */ |
| 30 | #define HWM_FAN1_SEG1_SPEED_REG 0xaa |
| 31 | #define HWM_FAN1_SEG2_SPEED_REG 0xab |
| 32 | #define HWM_FAN1_SEG3_SPEED_REG 0xac |
| 33 | #define HWM_FAN1_SEG4_SPEED_REG 0xad |
| 34 | #define HWM_FAN1_SEG5_SPEED_REG 0xae |
| 35 | #define HWM_FAN1_TEMP_SRC_REG 0xaf |
| 36 | |
| 37 | /* Fan 2 control */ |
| 38 | #define HWM_FAN2_SEG1_SPEED_REG 0xba |
| 39 | #define HWM_FAN2_SEG2_SPEED_REG 0xbb |
| 40 | #define HWM_FAN2_SEG3_SPEED_REG 0xbc |
| 41 | #define HWM_FAN2_SEG4_SPEED_REG 0xbd |
| 42 | #define HWM_FAN2_SEG5_SPEED_REG 0xbe |
| 43 | #define HWM_FAN2_TEMP_SRC_REG 0xbf |
| 44 | |
| 45 | void f71808a_hwm_init(struct device *dev) |
| 46 | { |
| 47 | struct resource *res = find_resource(dev, PNP_IDX_IO0); |
| 48 | |
| 49 | if (!res) { |
| 50 | printk(BIOS_WARNING, "Super I/O HWM: No HWM resource found.\n"); |
| 51 | return; |
| 52 | } |
| 53 | |
| 54 | const struct superio_fintek_f71808a_config *reg = dev->chip_info; |
| 55 | u16 port = res->base; |
| 56 | |
| 57 | pnp_enter_conf_mode(dev); |
| 58 | |
| 59 | pnp_write_index(port, HWM_PECI_TSI_CTRL_REG, reg->hwm_peci_tsi_ctrl); |
| 60 | pnp_write_index(port, HWM_TCC_TEMPERATURE_REG, reg->hwm_tcc_temp); |
| 61 | |
| 62 | pnp_write_index(port, HWM_FAN1_SEG1_SPEED_REG, |
| 63 | reg->hwm_fan1_seg1_speed); |
| 64 | pnp_write_index(port, HWM_FAN1_SEG2_SPEED_REG, |
| 65 | reg->hwm_fan1_seg2_speed); |
| 66 | pnp_write_index(port, HWM_FAN1_SEG3_SPEED_REG, |
| 67 | reg->hwm_fan1_seg3_speed); |
| 68 | pnp_write_index(port, HWM_FAN1_SEG4_SPEED_REG, |
| 69 | reg->hwm_fan1_seg4_speed); |
| 70 | pnp_write_index(port, HWM_FAN1_SEG5_SPEED_REG, |
| 71 | reg->hwm_fan1_seg5_speed); |
| 72 | pnp_write_index(port, HWM_FAN1_TEMP_SRC_REG, reg->hwm_fan1_temp_src); |
| 73 | |
| 74 | pnp_write_index(port, HWM_FAN2_SEG1_SPEED_REG, |
| 75 | reg->hwm_fan2_seg1_speed); |
| 76 | pnp_write_index(port, HWM_FAN2_SEG2_SPEED_REG, |
| 77 | reg->hwm_fan2_seg2_speed); |
| 78 | pnp_write_index(port, HWM_FAN2_SEG3_SPEED_REG, |
| 79 | reg->hwm_fan2_seg3_speed); |
| 80 | pnp_write_index(port, HWM_FAN2_SEG4_SPEED_REG, |
| 81 | reg->hwm_fan2_seg4_speed); |
| 82 | pnp_write_index(port, HWM_FAN2_SEG5_SPEED_REG, |
| 83 | reg->hwm_fan2_seg5_speed); |
| 84 | pnp_write_index(port, HWM_FAN2_TEMP_SRC_REG, reg->hwm_fan2_temp_src); |
| 85 | |
| 86 | pnp_exit_conf_mode(dev); |
| 87 | } |