Simon Glass | e42bff5 | 2020-09-22 12:44:48 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2016 Intel Corporation. |
| 4 | */ |
| 5 | |
| 6 | Scope (\_SB) |
| 7 | { |
| 8 | /* Get Pad Configuration DW0 register value */ |
| 9 | Method (GPC0, 0x1, Serialized) |
| 10 | { |
| 11 | /* Arg0 - GPIO DW0 address */ |
| 12 | Store (Arg0, Local0) |
| 13 | OperationRegion (PDW0, SystemMemory, Local0, 4) |
| 14 | Field (PDW0, AnyAcc, NoLock, Preserve) { |
| 15 | TEMP, 32 |
| 16 | } |
| 17 | Return (TEMP) |
| 18 | } |
| 19 | |
| 20 | /* Set Pad Configuration DW0 register value */ |
| 21 | Method (SPC0, 0x2, Serialized) |
| 22 | { |
| 23 | /* Arg0 - GPIO DW0 address */ |
| 24 | /* Arg1 - Value for DW0 register */ |
| 25 | Store (Arg0, Local0) |
| 26 | OperationRegion (PDW0, SystemMemory, Local0, 4) |
| 27 | Field (PDW0, AnyAcc, NoLock, Preserve) { |
| 28 | TEMP,32 |
| 29 | } |
| 30 | Store (Arg1, TEMP) |
| 31 | } |
| 32 | |
| 33 | /* Get Pad Configuration DW1 register value */ |
| 34 | Method (GPC1, 0x1, Serialized) |
| 35 | { |
| 36 | /* Arg0 - GPIO DW0 address */ |
| 37 | Store (Add (Arg0, 0x4), Local0) |
| 38 | OperationRegion (PDW1, SystemMemory, Local0, 4) |
| 39 | Field (PDW1, AnyAcc, NoLock, Preserve) { |
| 40 | TEMP, 32 |
| 41 | } |
| 42 | Return (TEMP) |
| 43 | } |
| 44 | |
| 45 | /* Set Pad Configuration DW1 register value */ |
| 46 | Method (SPC1, 0x2, Serialized) |
| 47 | { |
| 48 | /* Arg0 - GPIO DW0 address */ |
| 49 | /* Arg1 - Value for DW1 register */ |
| 50 | Store (Add (Arg0, 0x4), Local0) |
| 51 | OperationRegion (PDW1, SystemMemory, Local0, 4) |
| 52 | Field(PDW1, AnyAcc, NoLock, Preserve) { |
| 53 | TEMP,32 |
| 54 | } |
| 55 | Store (Arg1, TEMP) |
| 56 | } |
| 57 | |
| 58 | /* Get DW0 address of a given pad */ |
| 59 | Method (GDW0, 0x2, Serialized) |
| 60 | { |
| 61 | /* Arg0 - GPIO portid */ |
| 62 | /* Arg1 - GPIO pad offset relative to the community */ |
| 63 | Store (0, Local1) |
| 64 | Or( Or (ShiftLeft (Arg0, 16), IOMAP_P2SB_BAR), |
| 65 | Local1, Local1) |
| 66 | Or( Add (PAD_CFG_BASE, Multiply (Arg1, Multiply ( |
| 67 | GPIO_NUM_PAD_CFG_REGS, 4))), Local1, Local1) |
| 68 | Return (Local1) |
| 69 | } |
| 70 | |
| 71 | /* Calculate HOSTSW_REG address */ |
| 72 | Method (CHSA, 0x1, Serialized) |
| 73 | { |
| 74 | /* Arg0 - GPIO pad offset relative to the community */ |
| 75 | Add (HOSTSW_OWN_REG_0, Multiply (Divide (Arg0, 32), 4), Local1) |
| 76 | Return (Local1) |
| 77 | } |
| 78 | |
| 79 | /* Get Host ownership register of GPIO Community */ |
| 80 | Method (GHO, 0x2, Serialized) |
| 81 | { |
| 82 | /* Arg0 - GPIO portid */ |
| 83 | /* Arg1 - GPIO pad offset relative to the community */ |
| 84 | Store (CHSA (Arg1), Local1) |
| 85 | |
| 86 | OperationRegion (SHO0, SystemMemory, Or ( Or |
| 87 | (IOMAP_P2SB_BAR, ShiftLeft (Arg0, 16)), Local1), 4) |
| 88 | Field (SHO0, AnyAcc, NoLock, Preserve) { |
| 89 | TEMP, 32 |
| 90 | } |
| 91 | Return (TEMP) |
| 92 | } |
| 93 | |
| 94 | /* Set Host ownership register of GPIO Community */ |
| 95 | Method (SHO, 0x3, Serialized) |
| 96 | { |
| 97 | /* Arg0 - GPIO portid */ |
| 98 | /* Arg1 - GPIO pad offset relative to the community */ |
| 99 | /* Arg2 - Value for Host own register */ |
| 100 | Store (CHSA (Arg1), Local1) |
| 101 | |
| 102 | OperationRegion (SHO0, SystemMemory, Or ( Or |
| 103 | (IOMAP_P2SB_BAR, ShiftLeft (Arg0, 16)), Local1), 4) |
| 104 | Field (SHO0, AnyAcc, NoLock, Preserve) { |
| 105 | TEMP, 32 |
| 106 | } |
| 107 | Store (Arg2, TEMP) |
| 108 | } |
| 109 | } |