]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkNorthCluster/MemoryInit/Pei/io.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkNorthCluster / MemoryInit / Pei / io.h
CommitLineData
9b6bbcdb
MK
1/** @file\r
2Declaration of IO handling routines.\r
3\r
4Copyright (c) 2013-2015 Intel Corporation.\r
5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions of the BSD License\r
8which accompanies this distribution. The full text of the license may be found at\r
9http://opensource.org/licenses/bsd-license.php\r
10\r
11THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15#ifndef __IO_H\r
16#define __IO_H\r
17\r
18#include "core_types.h"\r
19\r
20#include "general_definitions.h"\r
21#include "gen5_iosf_sb_definitions.h"\r
22\r
23// Instruction not present on Quark\r
24#define SFENCE()\r
25\r
26#define DEAD_LOOP() for(;;);\r
27\r
28////\r
29// Define each of the IOSF_SB ports used by MRC\r
30//\r
31\r
32//\r
33// Has to be 0 because of emulation static data\r
34// initialisation:\r
35// Space_t EmuSpace[ SPACE_COUNT] = {0};\r
36//\r
37#define FREE 0x000\r
38\r
39// Pseudo side-band ports for access abstraction\r
40// See Wr32/Rd32 functions\r
41#define MEM 0x101\r
42#define MMIO 0x102\r
43#define DCMD 0x0A0\r
44\r
45// Real side-band ports\r
46// See Wr32/Rd32 functions\r
47#define MCU 0x001\r
48#define HOST_BRIDGE 0x003\r
49#define MEMORY_MANAGER 0x005\r
50#define HTE 0x011\r
51#define DDRPHY 0x012\r
52#define FUSE 0x033\r
53\r
54// End of IOSF_SB ports\r
55////\r
56\r
57// Pciexbar address\r
58#define EC_BASE 0xE0000000\r
59\r
60#define PCIADDR(bus,dev,fn,reg) ( \\r
61 (EC_BASE) + \\r
62 ((bus) << 20) + \\r
63 ((dev) << 15) + \\r
64 ((fn) << 12) + \\r
65 (reg))\r
66\r
67// Various offsets used in the building sideband commands.\r
68#define SB_OPCODE_OFFSET 24\r
69#define SB_PORT_OFFSET 16\r
70#define SB_REG_OFFEST 8\r
71\r
72// Sideband opcodes\r
73#define SB_REG_READ_OPCODE 0x10\r
74#define SB_REG_WRITE_OPCODE 0x11\r
75\r
76#define SB_FUSE_REG_READ_OPCODE 0x06\r
77#define SB_FUSE_REG_WRITE_OPCODE 0x07\r
78\r
79#define SB_DDRIO_REG_READ_OPCODE 0x06\r
80#define SB_DDRIO_REG_WRITE_OPCODE 0x07\r
81\r
82#define SB_DRAM_CMND_OPCODE 0x68\r
83#define SB_WAKE_CMND_OPCODE 0xCA\r
84#define SB_SUSPEND_CMND_OPCODE 0xCC\r
85\r
86// Register addresses for sideband command and data.\r
87#define SB_PACKET_REG 0x00D0\r
88#define SB_DATA_REG 0x00D4\r
89#define SB_HADR_REG 0x00D8\r
90\r
91// We always flag all 4 bytes in the register reads/writes as required.\r
92#define SB_ALL_BYTES_ENABLED 0xF0\r
93\r
94#define SB_COMMAND(Opcode, Port, Reg) \\r
95 ((Opcode << SB_OPCODE_OFFSET) | \\r
96 (Port << SB_PORT_OFFSET) | \\r
97 (Reg << SB_REG_OFFEST) | \\r
98 SB_ALL_BYTES_ENABLED)\r
99\r
100// iosf\r
101#define isbM32m WrMask32\r
102#define isbW32m Wr32\r
103#define isbR32m Rd32\r
104\r
105// pci\r
106\r
107void pciwrite32(\r
108 uint32_t bus,\r
109 uint32_t dev,\r
110 uint32_t fn,\r
111 uint32_t reg,\r
112 uint32_t data);\r
113\r
114uint32_t pciread32(\r
115 uint32_t bus,\r
116 uint32_t dev,\r
117 uint32_t fn,\r
118 uint32_t reg);\r
119\r
120// general\r
121\r
122uint32_t Rd32(\r
123 uint32_t unit,\r
124 uint32_t addr);\r
125\r
126void Wr32(\r
127 uint32_t unit,\r
128 uint32_t addr,\r
129 uint32_t data);\r
130\r
131void WrMask32(\r
132 uint32_t unit,\r
133 uint32_t addr,\r
134 uint32_t data,\r
135 uint32_t mask);\r
136\r
137\r
138#endif\r