Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de> |
Kerry Sheh | c55f5a0 | 2012-02-07 20:32:37 +0800 | [diff] [blame] | 5 | * Copyright (C) 2012 Advanced Micro Devices, Inc. |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 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. |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 16 | */ |
| 17 | |
Kerry Sheh | c55f5a0 | 2012-02-07 20:32:37 +0800 | [diff] [blame] | 18 | #include <arch/io.h> |
Kerry Sheh | c55f5a0 | 2012-02-07 20:32:37 +0800 | [diff] [blame] | 19 | #include <device/pnp_def.h> |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | #include "w83627dhg.h" |
| 22 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 23 | void pnp_enter_ext_func_mode(pnp_devfn_t dev) |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 24 | { |
| 25 | u16 port = dev >> 8; |
| 26 | outb(0x87, port); |
| 27 | outb(0x87, port); |
| 28 | } |
| 29 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 30 | void pnp_exit_ext_func_mode(pnp_devfn_t dev) |
Uwe Hermann | 1ec5094 | 2008-11-11 21:10:07 +0000 | [diff] [blame] | 31 | { |
| 32 | u16 port = dev >> 8; |
| 33 | outb(0xaa, port); |
| 34 | } |
| 35 | |
Kerry Sheh | c55f5a0 | 2012-02-07 20:32:37 +0800 | [diff] [blame] | 36 | /** |
| 37 | * Select Pin 89, Pin 90 function as I2C interface SDA, SCL. |
| 38 | * {Pin 89, Pin 90} function can be selected as {GP33, GP32}, or |
| 39 | * {RSTOUT3#, RSTOUT2#} or {SDA, SCL} |
| 40 | */ |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 41 | void w83627dhg_enable_i2c(pnp_devfn_t dev) |
Kerry Sheh | c55f5a0 | 2012-02-07 20:32:37 +0800 | [diff] [blame] | 42 | { |
| 43 | u8 val; |
| 44 | |
| 45 | pnp_enter_ext_func_mode(dev); |
| 46 | pnp_set_logical_device(dev); |
| 47 | |
| 48 | val = pnp_read_config(dev, 0x2A); |
| 49 | val |= 1 << 1; |
| 50 | pnp_write_config(dev, 0x2A, val); |
| 51 | |
| 52 | pnp_exit_ext_func_mode(dev); |
| 53 | } |
| 54 | |
Edward O'Callaghan | 85836c2 | 2014-07-09 20:26:25 +1000 | [diff] [blame] | 55 | void w83627dhg_set_clksel_48(pnp_devfn_t dev) |
Siyuan Wang | cf8bcfc | 2012-09-07 19:18:16 +0800 | [diff] [blame] | 56 | { |
| 57 | u8 reg8; |
| 58 | |
| 59 | pnp_enter_ext_func_mode(dev); |
| 60 | reg8 = pnp_read_config(dev, 0x24); |
| 61 | reg8 |= (1 << 6); /* Set CLKSEL (clock input on pin 1) to 48MHz. */ |
| 62 | pnp_write_config(dev, 0x24, reg8); |
| 63 | pnp_exit_ext_func_mode(dev); |
| 64 | } |