Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame^] | 1 | /** |
| 2 | * @file |
| 3 | * |
| 4 | * Southbridge PMIO access common routine |
| 5 | * |
| 6 | */ |
| 7 | /* |
| 8 | ***************************************************************************** |
| 9 | * |
| 10 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 11 | * All rights reserved. |
| 12 | * |
| 13 | * 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. |
| 20 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 21 | * its contributors may be used to endorse or promote products derived |
| 22 | * from this software without specific prior written permission. |
| 23 | * |
| 24 | * 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. |
| 34 | * |
| 35 | * *************************************************************************** |
| 36 | * |
| 37 | */ |
| 38 | |
| 39 | #include "SBPLATFORM.h" |
| 40 | #include "cbtypes.h" |
| 41 | |
| 42 | /*----------------------------------------------------------------------------------------*/ |
| 43 | /** |
| 44 | * Read PMIO |
| 45 | * |
| 46 | * |
| 47 | * |
| 48 | * @param[in] Address - PMIO Offset value |
| 49 | * @param[in] OpFlag - Access sizes |
| 50 | * @param[in] Value - Read Data Buffer |
| 51 | * |
| 52 | */ |
| 53 | VOID |
| 54 | ReadPMIO ( |
| 55 | IN UINT8 Address, |
| 56 | IN UINT8 OpFlag, |
| 57 | IN VOID* Value |
| 58 | ) |
| 59 | { |
| 60 | UINT8 i; |
| 61 | OpFlag = OpFlag & 0x7f; |
| 62 | |
| 63 | if ( OpFlag == 0x02 ) { |
| 64 | OpFlag = 0x03; |
| 65 | } |
| 66 | for ( i = 0; i <= OpFlag; i++ ) { |
| 67 | WriteIO (0xCD6, AccWidthUint8, &Address); // SB_IOMAP_REGCD6 |
| 68 | Address++; |
| 69 | ReadIO (0xCD7, AccWidthUint8, (UINT8 *)Value + i); // SB_IOMAP_REGCD7 |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | /*----------------------------------------------------------------------------------------*/ |
| 74 | /** |
| 75 | * Write PMIO |
| 76 | * |
| 77 | * |
| 78 | * |
| 79 | * @param[in] Address - PMIO Offset value |
| 80 | * @param[in] OpFlag - Access sizes |
| 81 | * @param[in] Value - Write Data Buffer |
| 82 | * |
| 83 | */ |
| 84 | VOID |
| 85 | WritePMIO ( |
| 86 | IN UINT8 Address, |
| 87 | IN UINT8 OpFlag, |
| 88 | IN VOID* Value |
| 89 | ) |
| 90 | { |
| 91 | UINT8 i; |
| 92 | OpFlag = OpFlag & 0x7f; |
| 93 | |
| 94 | if ( OpFlag == 0x02 ) { |
| 95 | OpFlag = 0x03; |
| 96 | } |
| 97 | for ( i = 0; i <= OpFlag; i++ ) { |
| 98 | WriteIO (0xCD6, AccWidthUint8, &Address); // SB_IOMAP_REGCD6 |
| 99 | Address++; |
| 100 | WriteIO (0xCD7, AccWidthUint8, (UINT8 *)Value + i); // SB_IOMAP_REGCD7 |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /*----------------------------------------------------------------------------------------*/ |
| 105 | /** |
| 106 | * RWPMIO - Read/Write PMIO |
| 107 | * |
| 108 | * |
| 109 | * |
| 110 | * @param[in] Address - PMIO Offset value |
| 111 | * @param[in] OpFlag - Access sizes |
| 112 | * @param[in] AndMask - Data And Mask 32 bits |
| 113 | * @param[in] OrMask - Data OR Mask 32 bits |
| 114 | * |
| 115 | */ |
| 116 | VOID |
| 117 | RWPMIO ( |
| 118 | IN UINT8 Address, |
| 119 | IN UINT8 OpFlag, |
| 120 | IN UINT32 AndMask, |
| 121 | IN UINT32 OrMask |
| 122 | ) |
| 123 | { |
| 124 | UINT32 Result; |
| 125 | OpFlag = OpFlag & 0x7f; |
| 126 | ReadPMIO (Address, OpFlag, &Result); |
| 127 | Result = (Result & AndMask) | OrMask; |
| 128 | WritePMIO (Address, OpFlag, &Result); |
| 129 | } |