blob: 078bee20f3b7798bda7e235be032036122f849a7 [file] [log] [blame]
Uwe Hermann1ec50942008-11-11 21:10:07 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2008 Uwe Hermann <uwe@hermann-uwe.de>
Kerry Shehc55f5a02012-02-07 20:32:37 +08005 * Copyright (C) 2012 Advanced Micro Devices, Inc.
Uwe Hermann1ec50942008-11-11 21:10:07 +00006 *
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 Hermann1ec50942008-11-11 21:10:07 +000016 */
17
Kerry Shehc55f5a02012-02-07 20:32:37 +080018#include <arch/io.h>
Kerry Shehc55f5a02012-02-07 20:32:37 +080019#include <device/pnp_def.h>
Uwe Hermann1ec50942008-11-11 21:10:07 +000020#include <stdint.h>
21#include "w83627dhg.h"
22
Edward O'Callaghan85836c22014-07-09 20:26:25 +100023void pnp_enter_ext_func_mode(pnp_devfn_t dev)
Uwe Hermann1ec50942008-11-11 21:10:07 +000024{
25 u16 port = dev >> 8;
26 outb(0x87, port);
27 outb(0x87, port);
28}
29
Edward O'Callaghan85836c22014-07-09 20:26:25 +100030void pnp_exit_ext_func_mode(pnp_devfn_t dev)
Uwe Hermann1ec50942008-11-11 21:10:07 +000031{
32 u16 port = dev >> 8;
33 outb(0xaa, port);
34}
35
Kerry Shehc55f5a02012-02-07 20:32:37 +080036/**
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'Callaghan85836c22014-07-09 20:26:25 +100041void w83627dhg_enable_i2c(pnp_devfn_t dev)
Kerry Shehc55f5a02012-02-07 20:32:37 +080042{
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'Callaghan85836c22014-07-09 20:26:25 +100055void w83627dhg_set_clksel_48(pnp_devfn_t dev)
Siyuan Wangcf8bcfc2012-09-07 19:18:16 +080056{
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}