blob: b5bc4eec12a6ad0accd536777ba27bcb1e762682 [file] [log] [blame]
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +10001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2011 The ChromiumOS Authors. All rights reserved.
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.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
Patrick Georgib890a122015-03-26 15:17:45 +010018 * Foundation, Inc.
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100019 */
20
21#include <arch/io.h>
22#include <device/pnp_def.h>
23
24#include "it8772f.h"
25
26/* NOTICE: This file is deprecated, use ite/common instead */
27
28/* RAMstage equiv */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100029/* u8 pnp_read_config(pnp_devfn_t dev, u8 reg) */
30u8 it8772f_sio_read(pnp_devfn_t dev, u8 reg)
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100031{
32 u16 port = dev >> 8;
33
34 outb(reg, port);
35 return inb(port + 1);
36}
37
38/* RAMstage equiv */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100039/* void pnp_write_config(pnp_devfn_t dev, u8 reg, u8 value) */
40void it8772f_sio_write(pnp_devfn_t dev, u8 reg, u8 value)
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100041{
42 u16 port = dev >> 8;
43
44 outb(reg, port);
45 outb(value, port + 1);
46}
47
Edward O'Callaghan85836c22014-07-09 20:26:25 +100048void it8772f_enter_conf(pnp_devfn_t dev)
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100049{
50 u16 port = dev >> 8;
51
52 outb(0x87, port);
53 outb(0x01, port);
54 outb(0x55, port);
55 outb((port == 0x4e) ? 0xaa : 0x55, port);
56}
57
Edward O'Callaghan85836c22014-07-09 20:26:25 +100058void it8772f_exit_conf(pnp_devfn_t dev)
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100059{
60 it8772f_sio_write(dev, IT8772F_CONFIG_REG_CC, 0x02);
61}
62
63/* Set AC resume to be up to the Southbridge */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100064void it8772f_ac_resume_southbridge(pnp_devfn_t dev)
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100065{
66 it8772f_enter_conf(dev);
67 it8772f_sio_write(dev, IT8772F_CONFIG_REG_LDN, IT8772F_EC);
68 it8772f_sio_write(dev, 0xf4, 0x60);
69 it8772f_exit_conf(dev);
70}
71
72/* Configure a set of GPIOs */
Edward O'Callaghan85836c22014-07-09 20:26:25 +100073void it8772f_gpio_setup(pnp_devfn_t dev, int set, u8 select, u8 polarity,
Edward O'Callaghan1f9653a2014-07-14 16:31:25 +100074 u8 pullup, u8 output, u8 enable)
75{
76 set--; /* Set 1 is offset 0 */
77 it8772f_enter_conf(dev);
78 it8772f_sio_write(dev, IT8772F_CONFIG_REG_LDN, IT8772F_GPIO);
79 if (set < 5) {
80 it8772f_sio_write(dev, GPIO_REG_SELECT(set), select);
81 it8772f_sio_write(dev, GPIO_REG_ENABLE(set), enable);
82 it8772f_sio_write(dev, GPIO_REG_POLARITY(set), polarity);
83 }
84 it8772f_sio_write(dev, GPIO_REG_OUTPUT(set), output);
85 it8772f_sio_write(dev, GPIO_REG_PULLUP(set), pullup);
86 it8772f_exit_conf(dev);
87}