1/* SPDX-License-Identifier: GPL-2.0-only */ 2 3#include <soc/pcr_ids.h> 4 5Scope (\_SB.PCI0) { 6 7 /* 8 * Clear register 0x1C20/0x4820 9 * Arg0 - PCR Port ID 10 */ 11 Method(SCSC, 1, Serialized) 12 { 13 PCRA (Arg0, 0x1C20, 0x0) 14 PCRA (Arg0, 0x4820, 0x0) 15 } 16 17 /* EMMC */ 18 Device(EMMC) { 19 Name(_ADR, 0x001A0000) 20 Name (_DDN, "eMMC Controller") 21 Name (TEMP, 0) 22 23 OperationRegion(SCSR, PCI_Config, 0x00, 0x100) 24 Field(SCSR, WordAcc, NoLock, Preserve) { 25 Offset (0x84), /* PMECTRLSTATUS */ 26 PMCR, 16, 27 Offset (0xA2), /* PG_CONFIG */ 28 , 2, 29 PGEN, 1, /* PG_ENABLE */ 30 } 31 32 Method(_INI) { 33 /* Clear register 0x1C20/0x4820 */ 34 SCSC (PID_EMMC) 35 } 36 37 Method(_PS0, 0, Serialized) { 38 Stall (50) // Sleep 50 us 39 40 PGEN = 0 // Disable PG 41 42 /* Clear register 0x1C20/0x4820 */ 43 SCSC (PID_EMMC) 44 45 /* Set Power State to D0 */ 46 PMCR = PMCR & 0xFFFC 47 TEMP = PMCR 48 } 49 50 Method(_PS3, 0, Serialized) { 51 PGEN = 1 // Enable PG 52 53 /* Set Power State to D3 */ 54 PMCR = PMCR | 0x0003 55 TEMP = PMCR 56 } 57 58 Device (CARD) 59 { 60 Name (_ADR, 0x00000008) 61 Method (_RMV, 0, NotSerialized) 62 { 63 Return (0) 64 } 65 } 66 } 67 68 /* SD CARD */ 69 Device (SDXC) 70 { 71 Name (_ADR, 0x001A0001) 72 Name (_DDN, "SD Controller") 73 Name (TEMP, 0) 74 Name (DSUU, ToUUID("f6c13ea5-65cd-461f-ab7a-29f7e8d5bd61")) 75 76 OperationRegion (SDPC, PCI_Config, 0x00, 0x100) 77 Field (SDPC, WordAcc, NoLock, Preserve) 78 { 79 Offset (0x84), /* PMECTRLSTATUS */ 80 PMCR, 16, 81 Offset (0xA2), /* PG_CONFIG */ 82 , 2, 83 PGEN, 1, /* PG_ENABLE */ 84 } 85 86 /* 87 * _DSM x86 Device Specific Method 88 * Arg0: UUID Unique function identifier 89 * Arg1: Integer Revision Level 90 * Arg2: Integer Function Index (0 = Return Supported Functions) 91 * Arg3: Package Parameters 92 */ 93 Method (_DSM, 4) 94 { 95 If (Arg0 == DSUU) { 96 /* Check the revision */ 97 If (Arg1 >= 0) { 98 /* 99 * Function Index 0 the return value is a buffer containing 100 * one bit for each function index, starting with zero. 101 * Bit 0 - Indicates whether there is support for any 102 * functions other than function 0. 103 * Bit 1 - Indicates support to clear power control register 104 * Bit 2 - Indicates support to set power control register 105 * Bit 3 - Indicates support to set 1.8V signalling 106 * Bit 4 - Indicates support to set 3.3V signalling 107 * Bit 5 - Indicates support for HS200 mode 108 * Bit 6 - Indicates support for HS400 mode 109 * Bit 9 - Indicates eMMC I/O Driver Strength 110 */ 111 /* 112 * For SD we have to support functions to 113 * set 1.8V signalling and 3.3V signalling [BIT4, BIT3] 114 */ 115 If (Arg2 == 0) { 116 Return (Buffer () { 0x19 }) 117 } 118 /* 119 * Function Index 3: Set 1.8v signalling. 120 * We put a sleep of 100ms in this method to 121 * work around a known issue with detecting 122 * UHS SD card on PCH. This is to compensate 123 * for the SD VR slowness. 124 */ 125 If (Arg2 == 3) { 126 Sleep (100) 127 Return(Buffer () { 0x00 }) 128 } 129 /* 130 * Function Index 4: Set 3.3v signalling. 131 * We put a sleep of 100ms in this method to 132 * work around a known issue with detecting 133 * UHS SD card on PCH. This is to compensate 134 * for the SD VR slowness. 135 */ 136 If (Arg2 == 4) { 137 Sleep (100) 138 Return(Buffer () { 0x00 }) 139 } 140 } 141 } 142 Return(Buffer() { 0x0 }) 143 } 144 145 Method(_INI) 146 { 147 /* Clear register 0x1C20/0x4820 */ 148 SCSC (PID_SDX) 149 } 150 151 Method (_PS0, 0, Serialized) 152 { 153 PGEN = 0 /* Disable PG */ 154 155 /* Clear register 0x1C20/0x4820 */ 156 SCSC (PID_SDX) 157 158 /* Set Power State to D0 */ 159 PMCR = PMCR & 0xFFFC 160 TEMP = PMCR 161 162 /* Change pad mode to Native */ 163 GPMO(SD_PWR_EN_PIN, 0x1) 164 } 165 166 Method (_PS3, 0, Serialized) 167 { 168 PGEN = 1 /* Enable PG */ 169 170 /* Set Power State to D3 */ 171 PMCR = PMCR | 0x0003 172 TEMP = PMCR 173 174 /* Change pad mode to GPIO control */ 175 GPMO(SD_PWR_EN_PIN, 0x0) 176 177 /* Enable Tx Buffer */ 178 GTXE(SD_PWR_EN_PIN, 0x1) 179 180 /* Drive TX to zero */ 181 CTXS(SD_PWR_EN_PIN) 182 } 183 184 Device (CARD) 185 { 186 Name (_ADR, 0x00000008) 187 Method (_RMV, 0, NotSerialized) 188 { 189 Return (1) 190 } 191 } 192 } /* Device (SDXC) */ 193} 194