blob: 82864e695a5b6cdf61c286e64668cafffc469d2b [file] [log] [blame]
Frank Vibrans2b4c8312011-02-14 18:30:54 +00001/**
2 * @file
3 *
4 * Southbridge PMIO2 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
43/*----------------------------------------------------------------------------------------*/
44/**
45 * Read PMIO2
46 *
47 *
48 *
49 * @param[in] Address - PMIO2 Offset value
50 * @param[in] OpFlag - Access sizes
51 * @param[in] Value - Read Data Buffer
52 *
53 */
54VOID
55ReadPMIO2 (
56 IN UINT8 Address,
57 IN UINT8 OpFlag,
58 IN VOID* Value
59 )
60{
61 UINT8 i;
62 OpFlag = OpFlag & 0x7f;
63
64 if ( OpFlag == 0x02 ) {
65 OpFlag = 0x03;
66 }
67 for ( i = 0; i <= OpFlag; i++ ) {
68 WriteIO (0xCD0, AccWidthUint8, &Address); // SB_IOMAP_REGCD0
69 Address++;
70 ReadIO (0xCD1, AccWidthUint8, (UINT8 *) Value + i); // SB_IOMAP_REGCD1
71 }
72}
73
74/*----------------------------------------------------------------------------------------*/
75/**
76 * Write PMIO 2
77 *
78 *
79 *
80 * @param[in] Address - PMIO2 Offset value
81 * @param[in] OpFlag - Access sizes
82 * @param[in] Value - Write Data Buffer
83 *
84 */
85VOID
86WritePMIO2 (
87 IN UINT8 Address,
88 IN UINT8 OpFlag,
89 IN VOID* Value
90 )
91{
92 UINT8 i;
93 OpFlag = OpFlag & 0x7f;
94
95 if ( OpFlag == 0x02 ) {
96 OpFlag = 0x03;
97 }
98 for ( i = 0; i <= OpFlag; i++ ) {
99 WriteIO (0xCD0, AccWidthUint8, &Address); // SB_IOMAP_REGCD0
100 Address++;
101 WriteIO (0xCD1, AccWidthUint8, (UINT8 *)Value + i); // SB_IOMAP_REGCD1
102 }
103}
104
105/*----------------------------------------------------------------------------------------*/
106/**
107 * RWPMIO2 - Read/Write PMIO2
108 *
109 *
110 *
111 * @param[in] Address - PMIO2 Offset value
112 * @param[in] OpFlag - Access sizes
113 * @param[in] AndMask - Data And Mask 32 bits
114 * @param[in] OrMask - Data OR Mask 32 bits
115 *
116 */
117VOID
118RWPMIO2 (
119 IN UINT8 Address,
120 IN UINT8 OpFlag,
121 IN UINT32 AndMask,
122 IN UINT32 OrMask
123 )
124{
125 UINT32 Result;
126 OpFlag = OpFlag & 0x7f;
127 ReadPMIO2 (Address, OpFlag, &Result);
128 Result = (Result & AndMask) | OrMask;
129 WritePMIO2 (Address, OpFlag, &Result);
130}