blob: 1c8f8fdd3405221b2e1decc7053d943f06653b6c [file] [log] [blame]
efdesign98ee39ea72011-06-16 16:39:30 -07001/**
2 * @file
3 *
4 * Southbridge PMIO2 access common routine
5 *
6 */
7/*;********************************************************************************
8;
9; Copyright (c) 2011, Advanced Micro Devices, Inc.
10; All rights reserved.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100011;
efdesign98ee39ea72011-06-16 16:39:30 -070012; Redistribution and use in source and binary forms, with or without
13; modification, are permitted provided that the following conditions are met:
14; * Redistributions of source code must retain the above copyright
15; notice, this list of conditions and the following disclaimer.
16; * Redistributions in binary form must reproduce the above copyright
17; notice, this list of conditions and the following disclaimer in the
18; documentation and/or other materials provided with the distribution.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100019; * Neither the name of Advanced Micro Devices, Inc. nor the names of
20; its contributors may be used to endorse or promote products derived
efdesign98ee39ea72011-06-16 16:39:30 -070021; from this software without specific prior written permission.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100022;
efdesign98ee39ea72011-06-16 16:39:30 -070023; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26; DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
27; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
28; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Edward O'Callaghanef5981b2014-07-06 19:20:52 +100033;
efdesign98ee39ea72011-06-16 16:39:30 -070034;*********************************************************************************/
35
36#include "SbPlatform.h"
37#include "cbtypes.h"
38
39
40/*----------------------------------------------------------------------------------------*/
41/**
42 * Read PMIO2
43 *
44 *
45 *
46 * @param[in] Address - PMIO2 Offset value
47 * @param[in] OpFlag - Access sizes
48 * @param[in] Value - Read Data Buffer
49 *
50 */
51VOID
52ReadPMIO2 (
53 IN UINT8 Address,
54 IN UINT8 OpFlag,
55 IN VOID* Value
56 )
57{
58 UINT8 i;
59 OpFlag = OpFlag & 0x7f;
60
61 if ( OpFlag == 0x02 ) {
62 OpFlag = 0x03;
63 }
64 for ( i = 0; i <= OpFlag; i++ ) {
65 WriteIO (0xCD0, AccWidthUint8, &Address); // SB_IOMAP_REGCD0
66 Address++;
67 ReadIO (0xCD1, AccWidthUint8, (UINT8 *) Value + i); // SB_IOMAP_REGCD1
68 }
69}
70
71/*----------------------------------------------------------------------------------------*/
72/**
73 * Write PMIO 2
74 *
75 *
76 *
77 * @param[in] Address - PMIO2 Offset value
78 * @param[in] OpFlag - Access sizes
79 * @param[in] Value - Write Data Buffer
80 *
81 */
82VOID
83WritePMIO2 (
84 IN UINT8 Address,
85 IN UINT8 OpFlag,
86 IN VOID* Value
87 )
88{
89 UINT8 i;
90 OpFlag = OpFlag & 0x7f;
91
92 if ( OpFlag == 0x02 ) {
93 OpFlag = 0x03;
94 }
95 for ( i = 0; i <= OpFlag; i++ ) {
96 WriteIO (0xCD0, AccWidthUint8, &Address); // SB_IOMAP_REGCD0
97 Address++;
98 WriteIO (0xCD1, AccWidthUint8, (UINT8 *)Value + i); // SB_IOMAP_REGCD1
99 }
100}
101
102/*----------------------------------------------------------------------------------------*/
103/**
104 * RWPMIO2 - Read/Write PMIO2
105 *
106 *
107 *
108 * @param[in] Address - PMIO2 Offset value
109 * @param[in] OpFlag - Access sizes
110 * @param[in] AndMask - Data And Mask 32 bits
111 * @param[in] OrMask - Data OR Mask 32 bits
112 *
113 */
114VOID
115RWPMIO2 (
116 IN UINT8 Address,
117 IN UINT8 OpFlag,
118 IN UINT32 AndMask,
119 IN UINT32 OrMask
120 )
121{
122 UINT32 Result;
123 OpFlag = OpFlag & 0x7f;
124 ReadPMIO2 (Address, OpFlag, &Result);
125 Result = (Result & AndMask) | OrMask;
126 WritePMIO2 (Address, OpFlag, &Result);
127}