diff options
| -rw-r--r-- | Documentation/ABI/testing/debugfs-wilco-ec | 13 | ||||
| -rw-r--r-- | drivers/platform/chrome/wilco_ec/debugfs.c | 47 |
2 files changed, 60 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/debugfs-wilco-ec b/Documentation/ABI/testing/debugfs-wilco-ec index 7ff6b45be703..73a5a66ddca6 100644 --- a/Documentation/ABI/testing/debugfs-wilco-ec +++ b/Documentation/ABI/testing/debugfs-wilco-ec | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | What: /sys/kernel/debug/wilco_ec/h1_gpio | ||
| 2 | Date: April 2019 | ||
| 3 | KernelVersion: 5.2 | ||
| 4 | Description: | ||
| 5 | As part of Chrome OS's FAFT (Fully Automated Firmware Testing) | ||
| 6 | tests, we need to ensure that the H1 chip is properly setting | ||
| 7 | some GPIO lines. The h1_gpio attribute exposes the state | ||
| 8 | of the lines: | ||
| 9 | - ENTRY_TO_FACT_MODE in BIT(0) | ||
| 10 | - SPI_CHROME_SEL in BIT(1) | ||
| 11 | |||
| 12 | Output will formatted with "0x%02x\n". | ||
| 13 | |||
| 1 | What: /sys/kernel/debug/wilco_ec/raw | 14 | What: /sys/kernel/debug/wilco_ec/raw |
| 2 | Date: January 2019 | 15 | Date: January 2019 |
| 3 | KernelVersion: 5.1 | 16 | KernelVersion: 5.1 |
diff --git a/drivers/platform/chrome/wilco_ec/debugfs.c b/drivers/platform/chrome/wilco_ec/debugfs.c index 8d307378c1cb..f163476d080d 100644 --- a/drivers/platform/chrome/wilco_ec/debugfs.c +++ b/drivers/platform/chrome/wilco_ec/debugfs.c | |||
| @@ -164,6 +164,51 @@ static const struct file_operations fops_raw = { | |||
| 164 | .llseek = no_llseek, | 164 | .llseek = no_llseek, |
| 165 | }; | 165 | }; |
| 166 | 166 | ||
| 167 | #define CMD_KB_CHROME 0x88 | ||
| 168 | #define SUB_CMD_H1_GPIO 0x0A | ||
| 169 | |||
| 170 | struct h1_gpio_status_request { | ||
| 171 | u8 cmd; /* Always CMD_KB_CHROME */ | ||
| 172 | u8 reserved; | ||
| 173 | u8 sub_cmd; /* Always SUB_CMD_H1_GPIO */ | ||
| 174 | } __packed; | ||
| 175 | |||
| 176 | struct hi_gpio_status_response { | ||
| 177 | u8 status; /* 0 if allowed */ | ||
| 178 | u8 val; /* BIT(0)=ENTRY_TO_FACT_MODE, BIT(1)=SPI_CHROME_SEL */ | ||
| 179 | } __packed; | ||
| 180 | |||
| 181 | static int h1_gpio_get(void *arg, u64 *val) | ||
| 182 | { | ||
| 183 | struct wilco_ec_device *ec = arg; | ||
| 184 | struct h1_gpio_status_request rq; | ||
| 185 | struct hi_gpio_status_response rs; | ||
| 186 | struct wilco_ec_message msg; | ||
| 187 | int ret; | ||
| 188 | |||
| 189 | memset(&rq, 0, sizeof(rq)); | ||
| 190 | rq.cmd = CMD_KB_CHROME; | ||
| 191 | rq.sub_cmd = SUB_CMD_H1_GPIO; | ||
| 192 | |||
| 193 | memset(&msg, 0, sizeof(msg)); | ||
| 194 | msg.type = WILCO_EC_MSG_LEGACY; | ||
| 195 | msg.request_data = &rq; | ||
| 196 | msg.request_size = sizeof(rq); | ||
| 197 | msg.response_data = &rs; | ||
| 198 | msg.response_size = sizeof(rs); | ||
| 199 | ret = wilco_ec_mailbox(ec, &msg); | ||
| 200 | if (ret < 0) | ||
| 201 | return ret; | ||
| 202 | if (rs.status) | ||
| 203 | return -EIO; | ||
| 204 | |||
| 205 | *val = rs.val; | ||
| 206 | |||
| 207 | return 0; | ||
| 208 | } | ||
| 209 | |||
| 210 | DEFINE_DEBUGFS_ATTRIBUTE(fops_h1_gpio, h1_gpio_get, NULL, "0x%02llx\n"); | ||
| 211 | |||
| 167 | /** | 212 | /** |
| 168 | * wilco_ec_debugfs_probe() - Create the debugfs node | 213 | * wilco_ec_debugfs_probe() - Create the debugfs node |
| 169 | * @pdev: The platform device, probably created in core.c | 214 | * @pdev: The platform device, probably created in core.c |
| @@ -185,6 +230,8 @@ static int wilco_ec_debugfs_probe(struct platform_device *pdev) | |||
| 185 | if (!debug_info->dir) | 230 | if (!debug_info->dir) |
| 186 | return 0; | 231 | return 0; |
| 187 | debugfs_create_file("raw", 0644, debug_info->dir, NULL, &fops_raw); | 232 | debugfs_create_file("raw", 0644, debug_info->dir, NULL, &fops_raw); |
| 233 | debugfs_create_file("h1_gpio", 0444, debug_info->dir, ec, | ||
| 234 | &fops_h1_gpio); | ||
| 188 | 235 | ||
| 189 | return 0; | 236 | return 0; |
| 190 | } | 237 | } |
