blob: 54d87e793038254e2d2c2b50ae3f0d2b13ab5452 [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/**
2 * @file
3 *
4 * Southbridge EC IO access common routine
5 *
6 */
7/*
8 *****************************************************************************
9 *
10 * Copyright (c) 2011, Advanced Micro Devices, Inc.
11 * All rights reserved.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100012 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000013 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions are met:
15 * * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * * Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100020 * * Neither the name of Advanced Micro Devices, Inc. nor the names of
21 * its contributors may be used to endorse or promote products derived
Frank Vibrans2b4c8312011-02-14 18:30:54 +000022 * from this software without specific prior written permission.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100023 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
28 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100034 *
Frank Vibrans2b4c8312011-02-14 18:30:54 +000035 * ***************************************************************************
36 *
37 */
38
39#include "SBPLATFORM.h"
40#include "cbtypes.h"
41
42// #ifndef NO_EC_SUPPORT
43
44/*----------------------------------------------------------------------------------------*/
45/**
46 * EnterEcConfig - Force EC into Config mode
47 *
48 *
49 *
50 *
51 */
52VOID
53EnterEcConfig (
54 )
55{
56 UINT16 dwEcIndexPort;
57
58 ReadPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGA4, AccWidthUint16 | S3_SAVE, &dwEcIndexPort);
59 dwEcIndexPort &= ~(BIT0);
60 RWIO (dwEcIndexPort, AccWidthUint8, 0x00, 0x5A);
61}
62
63/*----------------------------------------------------------------------------------------*/
64/**
65 * ExitEcConfig - Force EC exit Config mode
66 *
67 *
68 *
69 *
70 */
71VOID
72ExitEcConfig (
73 )
74{
75 UINT16 dwEcIndexPort;
76
77 ReadPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGA4, AccWidthUint16 | S3_SAVE, &dwEcIndexPort);
78 dwEcIndexPort &= ~(BIT0);
79 RWIO (dwEcIndexPort, AccWidthUint8, 0x00, 0xA5);
80}
81
82/*----------------------------------------------------------------------------------------*/
83/**
84 * ReadEC8 - Read EC register data
85 *
86 *
87 *
88 * @param[in] Address - EC Register Offset Value
89 * @param[in] Value - Read Data Buffer
90 *
91 */
92VOID
93ReadEC8 (
94 IN UINT8 Address,
95 IN UINT8* Value
96 )
97{
98 UINT16 dwEcIndexPort;
99
100 ReadPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGA4, AccWidthUint16 | S3_SAVE, &dwEcIndexPort);
101 dwEcIndexPort &= ~(BIT0);
102 WriteIO (dwEcIndexPort, AccWidthUint8, &Address);
103 ReadIO (dwEcIndexPort + 1, AccWidthUint8, Value);
104}
105
106/*----------------------------------------------------------------------------------------*/
107/**
108 * WriteEC8 - Write date into EC register
109 *
110 *
111 *
112 * @param[in] Address - EC Register Offset Value
113 * @param[in] Value - Write Data Buffer
114 *
115 */
116VOID
117WriteEC8 (
118 IN UINT8 Address,
119 IN UINT8* Value
120 )
121{
122 UINT16 dwEcIndexPort;
123
124 ReadPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGA4, AccWidthUint16 | S3_SAVE, &dwEcIndexPort);
125 dwEcIndexPort &= ~(BIT0);
126
127 WriteIO (dwEcIndexPort, AccWidthUint8, &Address);
128 WriteIO (dwEcIndexPort + 1, AccWidthUint8, Value);
129}
130
131/*----------------------------------------------------------------------------------------*/
132/**
133 * RWEC8 - Read/Write EC register
134 *
135 *
136 *
137 * @param[in] Address - EC Register Offset Value
138 * @param[in] AndMask - Data And Mask 8 bits
139 * @param[in] OrMask - Data OR Mask 8 bits
140 *
141 */
142VOID
143RWEC8 (
144 IN UINT8 Address,
145 IN UINT8 AndMask,
146 IN UINT8 OrMask
147 )
148{
149 UINT8 Result;
150 ReadEC8 (Address, &Result);
151 Result = (Result & AndMask) | OrMask;
152 WriteEC8 (Address, &Result);
153}
154
155// #endif
156