Angel Pons | 32abdd6 | 2020-04-05 15:47:03 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 2 | |
| 3 | #include <soc/pcr_ids.h> |
| 4 | |
| 5 | Scope (\_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(PEMC) { |
| 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 | |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 40 | PGEN = 0 // Disable PG |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 41 | |
| 42 | /* Clear register 0x1C20/0x4820 */ |
| 43 | ^^SCSC (PID_EMMC) |
| 44 | |
| 45 | /* Set Power State to D0 */ |
| 46 | And (PMCR, 0xFFFC, PMCR) |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 47 | ^TEMP = PMCR |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | Method(_PS3, 0, Serialized) { |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 51 | PGEN = 1 // Enable PG |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 52 | |
| 53 | /* Set Power State to D3 */ |
Felix Singer | 86bc2e7 | 2022-12-16 04:40:39 +0100 | [diff] [blame^] | 54 | PMCR |= 3 |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 55 | ^TEMP = PMCR |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 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, 0x00140005) |
| 72 | Name (_DDN, "SD Controller") |
| 73 | Name (TEMP, 0) |
| 74 | |
| 75 | OperationRegion (SDPC, PCI_Config, 0x00, 0x100) |
| 76 | Field (SDPC, WordAcc, NoLock, Preserve) |
| 77 | { |
| 78 | Offset (0x84), /* PMECTRLSTATUS */ |
| 79 | PMCR, 16, |
| 80 | Offset (0xA2), /* PG_CONFIG */ |
| 81 | , 2, |
| 82 | PGEN, 1, /* PG_ENABLE */ |
| 83 | } |
| 84 | |
| 85 | Method(_INI) |
| 86 | { |
| 87 | /* Clear register 0x1C20/0x4820 */ |
| 88 | ^^SCSC (PID_SDX) |
| 89 | } |
| 90 | |
| 91 | Method (_PS0, 0, Serialized) |
| 92 | { |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 93 | PGEN = 0 /* Disable PG */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 94 | |
| 95 | /* Clear register 0x1C20/0x4820 */ |
| 96 | ^^SCSC (PID_SDX) |
| 97 | |
| 98 | /* Set Power State to D0 */ |
| 99 | And (PMCR, 0xFFFC, PMCR) |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 100 | ^TEMP = PMCR |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | Method (_PS3, 0, Serialized) |
| 104 | { |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 105 | PGEN = 1 /* Enable PG */ |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 106 | |
| 107 | /* Set Power State to D3 */ |
Felix Singer | 86bc2e7 | 2022-12-16 04:40:39 +0100 | [diff] [blame^] | 108 | PMCR |= 3 |
Felix Singer | 8cc2962 | 2022-12-12 07:33:35 +0100 | [diff] [blame] | 109 | ^TEMP = PMCR |
Aamir Bohra | 3ee54bb | 2018-10-17 11:55:01 +0530 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | Device (CARD) |
| 113 | { |
| 114 | Name (_ADR, 0x00000008) |
| 115 | Method (_RMV, 0, NotSerialized) |
| 116 | { |
| 117 | Return (1) |
| 118 | } |
| 119 | } |
| 120 | } /* Device (SDXC) */ |
| 121 | } |