Commit 60f37fc6aaece8dcf0241435d42b0580c93c7b91
1 parent
e96fc7dfc8
Exists in
v2017.01-smarct4x
and in
34 other branches
cros_ec: Drop unused CONFIG_DM_CROS_EC
Since all supported boards enable this option now, we can remove it along with the old code. Signed-off-by: Simon Glass <sjg@chromium.org>
Showing 10 changed files with 1 additions and 506 deletions Side-by-side Diff
arch/sandbox/Kconfig
board/samsung/smdk5420/Kconfig
... | ... | @@ -22,9 +22,6 @@ |
22 | 22 | config SYS_CONFIG_NAME |
23 | 23 | default "peach-pi" |
24 | 24 | |
25 | -config DM_CROS_EC | |
26 | - default y | |
27 | - | |
28 | 25 | endif |
29 | 26 | |
30 | 27 | if TARGET_PEACH_PIT |
... | ... | @@ -37,9 +34,6 @@ |
37 | 34 | |
38 | 35 | config SYS_CONFIG_NAME |
39 | 36 | default "peach-pit" |
40 | - | |
41 | -config DM_CROS_EC | |
42 | - default y | |
43 | 37 | |
44 | 38 | endif |
45 | 39 |
common/cros_ec.c
... | ... | @@ -15,18 +15,8 @@ |
15 | 15 | |
16 | 16 | DECLARE_GLOBAL_DATA_PTR; |
17 | 17 | |
18 | -#ifndef CONFIG_DM_CROS_EC | |
19 | -struct local_info { | |
20 | - struct cros_ec_dev *cros_ec_dev; /* Pointer to cros_ec device */ | |
21 | - int cros_ec_err; /* Error for cros_ec, 0 if ok */ | |
22 | -}; | |
23 | - | |
24 | -static struct local_info local; | |
25 | -#endif | |
26 | - | |
27 | 18 | struct cros_ec_dev *board_get_cros_ec_dev(void) |
28 | 19 | { |
29 | -#ifdef CONFIG_DM_CROS_EC | |
30 | 20 | struct udevice *dev; |
31 | 21 | int ret; |
32 | 22 | |
33 | 23 | |
34 | 24 | |
35 | 25 | |
36 | 26 | |
... | ... | @@ -36,30 +26,15 @@ |
36 | 26 | return NULL; |
37 | 27 | } |
38 | 28 | return dev_get_uclass_priv(dev); |
39 | -#else | |
40 | - return local.cros_ec_dev; | |
41 | -#endif | |
42 | 29 | } |
43 | 30 | |
44 | -static int board_init_cros_ec_devices(const void *blob) | |
31 | +int cros_ec_board_init(void) | |
45 | 32 | { |
46 | -#ifndef CONFIG_DM_CROS_EC | |
47 | - local.cros_ec_err = cros_ec_init(blob, &local.cros_ec_dev); | |
48 | - if (local.cros_ec_err) | |
49 | - return -1; /* Will report in board_late_init() */ | |
50 | -#endif | |
51 | - | |
52 | 33 | return 0; |
53 | 34 | } |
54 | 35 | |
55 | -int cros_ec_board_init(void) | |
56 | -{ | |
57 | - return board_init_cros_ec_devices(gd->fdt_blob); | |
58 | -} | |
59 | - | |
60 | 36 | int cros_ec_get_error(void) |
61 | 37 | { |
62 | -#ifdef CONFIG_DM_CROS_EC | |
63 | 38 | struct udevice *dev; |
64 | 39 | int ret; |
65 | 40 | |
... | ... | @@ -68,8 +43,5 @@ |
68 | 43 | return ret; |
69 | 44 | |
70 | 45 | return 0; |
71 | -#else | |
72 | - return local.cros_ec_err; | |
73 | -#endif | |
74 | 46 | } |
configs/sandbox_defconfig
configs/snow_defconfig
drivers/misc/Kconfig
... | ... | @@ -44,16 +44,6 @@ |
44 | 44 | provides a faster and more robust interface than I2C but the bugs |
45 | 45 | are less interesting. |
46 | 46 | |
47 | -config DM_CROS_EC | |
48 | - bool "Enable Driver Model for Chrome OS EC" | |
49 | - depends on DM | |
50 | - help | |
51 | - Enable driver model for the Chrome OS EC interface. This | |
52 | - allows the cros_ec SPI driver to operate with CONFIG_DM_SPI | |
53 | - but otherwise makes few changes. Since cros_ec also supports | |
54 | - LPC (which doesn't support driver model yet), a full | |
55 | - conversion is not yet possible. | |
56 | - | |
57 | 47 | config CONFIG_FSL_SEC_MON |
58 | 48 | bool "Enable FSL SEC_MON Driver" |
59 | 49 | help |
drivers/misc/cros_ec.c
... | ... | @@ -41,10 +41,6 @@ |
41 | 41 | CROS_EC_CMD_HASH_TIMEOUT_MS = 2000, |
42 | 42 | }; |
43 | 43 | |
44 | -#ifndef CONFIG_DM_CROS_EC | |
45 | -static struct cros_ec_dev static_dev, *last_dev; | |
46 | -#endif | |
47 | - | |
48 | 44 | DECLARE_GLOBAL_DATA_PTR; |
49 | 45 | |
50 | 46 | /* Note: depends on enum ec_current_image */ |
51 | 47 | |
... | ... | @@ -211,9 +207,7 @@ |
211 | 207 | const void *dout, int dout_len, |
212 | 208 | uint8_t **dinp, int din_len) |
213 | 209 | { |
214 | -#ifdef CONFIG_DM_CROS_EC | |
215 | 210 | struct dm_cros_ec_ops *ops; |
216 | -#endif | |
217 | 211 | int out_bytes, in_bytes; |
218 | 212 | int rv; |
219 | 213 | |
220 | 214 | |
... | ... | @@ -228,28 +222,8 @@ |
228 | 222 | if (in_bytes < 0) |
229 | 223 | return in_bytes; |
230 | 224 | |
231 | -#ifdef CONFIG_DM_CROS_EC | |
232 | 225 | ops = dm_cros_ec_get_ops(dev->dev); |
233 | 226 | rv = ops->packet ? ops->packet(dev->dev, out_bytes, in_bytes) : -ENOSYS; |
234 | -#else | |
235 | - switch (dev->interface) { | |
236 | -#ifdef CONFIG_CROS_EC_SPI | |
237 | - case CROS_EC_IF_SPI: | |
238 | - rv = cros_ec_spi_packet(dev, out_bytes, in_bytes); | |
239 | - break; | |
240 | -#endif | |
241 | -#ifdef CONFIG_CROS_EC_SANDBOX | |
242 | - case CROS_EC_IF_SANDBOX: | |
243 | - rv = cros_ec_sandbox_packet(dev, out_bytes, in_bytes); | |
244 | - break; | |
245 | -#endif | |
246 | - case CROS_EC_IF_NONE: | |
247 | - /* TODO: support protocol 3 for LPC, I2C; for now fall through */ | |
248 | - default: | |
249 | - debug("%s: Unsupported interface\n", __func__); | |
250 | - rv = -1; | |
251 | - } | |
252 | -#endif | |
253 | 227 | if (rv < 0) |
254 | 228 | return rv; |
255 | 229 | |
256 | 230 | |
... | ... | @@ -261,9 +235,7 @@ |
261 | 235 | const void *dout, int dout_len, |
262 | 236 | uint8_t **dinp, int din_len) |
263 | 237 | { |
264 | -#ifdef CONFIG_DM_CROS_EC | |
265 | 238 | struct dm_cros_ec_ops *ops; |
266 | -#endif | |
267 | 239 | int ret = -1; |
268 | 240 | |
269 | 241 | /* Handle protocol version 3 support */ |
270 | 242 | |
... | ... | @@ -272,38 +244,9 @@ |
272 | 244 | dout, dout_len, dinp, din_len); |
273 | 245 | } |
274 | 246 | |
275 | -#ifdef CONFIG_DM_CROS_EC | |
276 | 247 | ops = dm_cros_ec_get_ops(dev->dev); |
277 | 248 | ret = ops->command(dev->dev, cmd, cmd_version, |
278 | 249 | (const uint8_t *)dout, dout_len, dinp, din_len); |
279 | -#else | |
280 | - switch (dev->interface) { | |
281 | -#ifdef CONFIG_CROS_EC_SPI | |
282 | - case CROS_EC_IF_SPI: | |
283 | - ret = cros_ec_spi_command(dev, cmd, cmd_version, | |
284 | - (const uint8_t *)dout, dout_len, | |
285 | - dinp, din_len); | |
286 | - break; | |
287 | -#endif | |
288 | -#ifdef CONFIG_CROS_EC_I2C | |
289 | - case CROS_EC_IF_I2C: | |
290 | - ret = cros_ec_i2c_command(dev, cmd, cmd_version, | |
291 | - (const uint8_t *)dout, dout_len, | |
292 | - dinp, din_len); | |
293 | - break; | |
294 | -#endif | |
295 | -#ifdef CONFIG_CROS_EC_LPC | |
296 | - case CROS_EC_IF_LPC: | |
297 | - ret = cros_ec_lpc_command(dev, cmd, cmd_version, | |
298 | - (const uint8_t *)dout, dout_len, | |
299 | - dinp, din_len); | |
300 | - break; | |
301 | -#endif | |
302 | - case CROS_EC_IF_NONE: | |
303 | - default: | |
304 | - ret = -1; | |
305 | - } | |
306 | -#endif | |
307 | 250 | |
308 | 251 | return ret; |
309 | 252 | } |
... | ... | @@ -681,7 +624,6 @@ |
681 | 624 | struct ec_params_hello req; |
682 | 625 | struct ec_response_hello *resp; |
683 | 626 | |
684 | -#ifdef CONFIG_DM_CROS_EC | |
685 | 627 | struct dm_cros_ec_ops *ops; |
686 | 628 | int ret; |
687 | 629 | |
... | ... | @@ -691,13 +633,6 @@ |
691 | 633 | if (ret) |
692 | 634 | return ret; |
693 | 635 | } |
694 | -#else | |
695 | -#ifdef CONFIG_CROS_EC_LPC | |
696 | - /* LPC has its own way of doing this */ | |
697 | - if (dev->interface == CROS_EC_IF_LPC) | |
698 | - return cros_ec_lpc_check_version(dev); | |
699 | -#endif | |
700 | -#endif | |
701 | 636 | |
702 | 637 | /* |
703 | 638 | * TODO(sjg@chromium.org). |
... | ... | @@ -1027,76 +962,6 @@ |
1027 | 962 | return 0; |
1028 | 963 | } |
1029 | 964 | |
1030 | -#ifndef CONFIG_DM_CROS_EC | |
1031 | -/** | |
1032 | - * Decode EC interface details from the device tree and allocate a suitable | |
1033 | - * device. | |
1034 | - * | |
1035 | - * @param blob Device tree blob | |
1036 | - * @param node Node to decode from | |
1037 | - * @param devp Returns a pointer to the new allocated device | |
1038 | - * @return 0 if ok, -1 on error | |
1039 | - */ | |
1040 | -static int cros_ec_decode_fdt(const void *blob, int node, | |
1041 | - struct cros_ec_dev **devp) | |
1042 | -{ | |
1043 | - enum fdt_compat_id compat; | |
1044 | - struct cros_ec_dev *dev; | |
1045 | - int parent; | |
1046 | - | |
1047 | - /* See what type of parent we are inside (this is expensive) */ | |
1048 | - parent = fdt_parent_offset(blob, node); | |
1049 | - if (parent < 0) { | |
1050 | - debug("%s: Cannot find node parent\n", __func__); | |
1051 | - return -1; | |
1052 | - } | |
1053 | - | |
1054 | - dev = &static_dev; | |
1055 | - dev->node = node; | |
1056 | - dev->parent_node = parent; | |
1057 | - | |
1058 | - compat = fdtdec_lookup(blob, parent); | |
1059 | - switch (compat) { | |
1060 | -#ifdef CONFIG_CROS_EC_SPI | |
1061 | - case COMPAT_SAMSUNG_EXYNOS_SPI: | |
1062 | - dev->interface = CROS_EC_IF_SPI; | |
1063 | - if (cros_ec_spi_decode_fdt(dev, blob)) | |
1064 | - return -1; | |
1065 | - break; | |
1066 | -#endif | |
1067 | -#ifdef CONFIG_CROS_EC_I2C | |
1068 | - case COMPAT_SAMSUNG_S3C2440_I2C: | |
1069 | - dev->interface = CROS_EC_IF_I2C; | |
1070 | - if (cros_ec_i2c_decode_fdt(dev, blob)) | |
1071 | - return -1; | |
1072 | - break; | |
1073 | -#endif | |
1074 | -#ifdef CONFIG_CROS_EC_LPC | |
1075 | - case COMPAT_INTEL_LPC: | |
1076 | - dev->interface = CROS_EC_IF_LPC; | |
1077 | - break; | |
1078 | -#endif | |
1079 | -#ifdef CONFIG_CROS_EC_SANDBOX | |
1080 | - case COMPAT_SANDBOX_HOST_EMULATION: | |
1081 | - dev->interface = CROS_EC_IF_SANDBOX; | |
1082 | - break; | |
1083 | -#endif | |
1084 | - default: | |
1085 | - debug("%s: Unknown compat id %d\n", __func__, compat); | |
1086 | - return -1; | |
1087 | - } | |
1088 | - | |
1089 | - gpio_request_by_name_nodev(blob, node, "ec-interrupt", 0, &dev->ec_int, | |
1090 | - GPIOD_IS_IN); | |
1091 | - dev->optimise_flash_write = fdtdec_get_bool(blob, node, | |
1092 | - "optimise-flash-write"); | |
1093 | - *devp = dev; | |
1094 | - | |
1095 | - return 0; | |
1096 | -} | |
1097 | -#endif | |
1098 | - | |
1099 | -#ifdef CONFIG_DM_CROS_EC | |
1100 | 965 | int cros_ec_register(struct udevice *dev) |
1101 | 966 | { |
1102 | 967 | struct cros_ec_dev *cdev = dev_get_uclass_priv(dev); |
1103 | 968 | |
... | ... | @@ -1125,95 +990,7 @@ |
1125 | 990 | |
1126 | 991 | return 0; |
1127 | 992 | } |
1128 | -#else | |
1129 | -int cros_ec_init(const void *blob, struct cros_ec_dev **cros_ecp) | |
1130 | -{ | |
1131 | - struct cros_ec_dev *dev; | |
1132 | - char id[MSG_BYTES]; | |
1133 | -#ifdef CONFIG_DM_CROS_EC | |
1134 | - struct udevice *udev; | |
1135 | - int ret; | |
1136 | 993 | |
1137 | - ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev); | |
1138 | - if (!ret) | |
1139 | - device_remove(udev); | |
1140 | - ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); | |
1141 | - if (ret) | |
1142 | - return ret; | |
1143 | - dev = dev_get_uclass_priv(udev); | |
1144 | - return 0; | |
1145 | -#else | |
1146 | - int node = 0; | |
1147 | - | |
1148 | - *cros_ecp = NULL; | |
1149 | - do { | |
1150 | - node = fdtdec_next_compatible(blob, node, | |
1151 | - COMPAT_GOOGLE_CROS_EC); | |
1152 | - if (node < 0) { | |
1153 | - debug("%s: Node not found\n", __func__); | |
1154 | - return 0; | |
1155 | - } | |
1156 | - } while (!fdtdec_get_is_enabled(blob, node)); | |
1157 | - | |
1158 | - if (cros_ec_decode_fdt(blob, node, &dev)) { | |
1159 | - debug("%s: Failed to decode device.\n", __func__); | |
1160 | - return -CROS_EC_ERR_FDT_DECODE; | |
1161 | - } | |
1162 | - | |
1163 | - switch (dev->interface) { | |
1164 | -#ifdef CONFIG_CROS_EC_SPI | |
1165 | - case CROS_EC_IF_SPI: | |
1166 | - if (cros_ec_spi_init(dev, blob)) { | |
1167 | - debug("%s: Could not setup SPI interface\n", __func__); | |
1168 | - return -CROS_EC_ERR_DEV_INIT; | |
1169 | - } | |
1170 | - break; | |
1171 | -#endif | |
1172 | -#ifdef CONFIG_CROS_EC_I2C | |
1173 | - case CROS_EC_IF_I2C: | |
1174 | - if (cros_ec_i2c_init(dev, blob)) | |
1175 | - return -CROS_EC_ERR_DEV_INIT; | |
1176 | - break; | |
1177 | -#endif | |
1178 | -#ifdef CONFIG_CROS_EC_LPC | |
1179 | - case CROS_EC_IF_LPC: | |
1180 | - if (cros_ec_lpc_init(dev, blob)) | |
1181 | - return -CROS_EC_ERR_DEV_INIT; | |
1182 | - break; | |
1183 | -#endif | |
1184 | -#ifdef CONFIG_CROS_EC_SANDBOX | |
1185 | - case CROS_EC_IF_SANDBOX: | |
1186 | - if (cros_ec_sandbox_init(dev, blob)) | |
1187 | - return -CROS_EC_ERR_DEV_INIT; | |
1188 | - break; | |
1189 | -#endif | |
1190 | - case CROS_EC_IF_NONE: | |
1191 | - default: | |
1192 | - return 0; | |
1193 | - } | |
1194 | -#endif | |
1195 | - | |
1196 | - if (cros_ec_check_version(dev)) { | |
1197 | - debug("%s: Could not detect CROS-EC version\n", __func__); | |
1198 | - return -CROS_EC_ERR_CHECK_VERSION; | |
1199 | - } | |
1200 | - | |
1201 | - if (cros_ec_read_id(dev, id, sizeof(id))) { | |
1202 | - debug("%s: Could not read KBC ID\n", __func__); | |
1203 | - return -CROS_EC_ERR_READ_ID; | |
1204 | - } | |
1205 | - | |
1206 | - /* Remember this device for use by the cros_ec command */ | |
1207 | - *cros_ecp = dev; | |
1208 | -#ifndef CONFIG_DM_CROS_EC | |
1209 | - last_dev = dev; | |
1210 | -#endif | |
1211 | - debug("Google Chrome EC CROS-EC driver ready, id '%s'\n", id); | |
1212 | - | |
1213 | - return 0; | |
1214 | -} | |
1215 | -#endif | |
1216 | - | |
1217 | 994 | int cros_ec_decode_region(int argc, char * const argv[]) |
1218 | 995 | { |
1219 | 996 | if (argc > 0) { |
1220 | 997 | |
... | ... | @@ -1595,9 +1372,7 @@ |
1595 | 1372 | static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
1596 | 1373 | { |
1597 | 1374 | struct cros_ec_dev *dev; |
1598 | -#ifdef CONFIG_DM_CROS_EC | |
1599 | 1375 | struct udevice *udev; |
1600 | -#endif | |
1601 | 1376 | const char *cmd; |
1602 | 1377 | int ret = 0; |
1603 | 1378 | |
1604 | 1379 | |
... | ... | @@ -1606,15 +1381,11 @@ |
1606 | 1381 | |
1607 | 1382 | cmd = argv[1]; |
1608 | 1383 | if (0 == strcmp("init", cmd)) { |
1609 | -#ifdef CONFIG_DM_CROS_EC | |
1610 | 1384 | /* Remove any existing device */ |
1611 | 1385 | ret = uclass_find_device(UCLASS_CROS_EC, 0, &udev); |
1612 | 1386 | if (!ret) |
1613 | 1387 | device_remove(udev); |
1614 | 1388 | ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); |
1615 | -#else | |
1616 | - ret = cros_ec_init(gd->fdt_blob, &dev); | |
1617 | -#endif | |
1618 | 1389 | if (ret) { |
1619 | 1390 | printf("Could not init cros_ec device (err %d)\n", ret); |
1620 | 1391 | return 1; |
1621 | 1392 | |
... | ... | @@ -1622,21 +1393,12 @@ |
1622 | 1393 | return 0; |
1623 | 1394 | } |
1624 | 1395 | |
1625 | -#ifdef CONFIG_DM_CROS_EC | |
1626 | 1396 | ret = uclass_get_device(UCLASS_CROS_EC, 0, &udev); |
1627 | 1397 | if (ret) { |
1628 | 1398 | printf("Cannot get cros-ec device (err=%d)\n", ret); |
1629 | 1399 | return 1; |
1630 | 1400 | } |
1631 | 1401 | dev = dev_get_uclass_priv(udev); |
1632 | -#else | |
1633 | - /* Just use the last allocated device; there should be only one */ | |
1634 | - if (!last_dev) { | |
1635 | - printf("No CROS-EC device available\n"); | |
1636 | - return 1; | |
1637 | - } | |
1638 | - dev = last_dev; | |
1639 | -#endif | |
1640 | 1402 | if (0 == strcmp("id", cmd)) { |
1641 | 1403 | char id[MSG_BYTES]; |
1642 | 1404 | |
1643 | 1405 | |
... | ... | @@ -1894,11 +1656,9 @@ |
1894 | 1656 | ); |
1895 | 1657 | #endif |
1896 | 1658 | |
1897 | -#ifdef CONFIG_DM_CROS_EC | |
1898 | 1659 | UCLASS_DRIVER(cros_ec) = { |
1899 | 1660 | .id = UCLASS_CROS_EC, |
1900 | 1661 | .name = "cros_ec", |
1901 | 1662 | .per_device_auto_alloc_size = sizeof(struct cros_ec_dev), |
1902 | 1663 | }; |
1903 | -#endif |
drivers/misc/cros_ec_lpc.c
... | ... | @@ -41,18 +41,11 @@ |
41 | 41 | return 0; |
42 | 42 | } |
43 | 43 | |
44 | -#ifdef CONFIG_DM_CROS_EC | |
45 | 44 | int cros_ec_lpc_command(struct udevice *udev, uint8_t cmd, int cmd_version, |
46 | 45 | const uint8_t *dout, int dout_len, |
47 | 46 | uint8_t **dinp, int din_len) |
48 | 47 | { |
49 | 48 | struct cros_ec_dev *dev = dev_get_uclass_priv(udev); |
50 | -#else | |
51 | -int cros_ec_lpc_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version, | |
52 | - const uint8_t *dout, int dout_len, | |
53 | - uint8_t **dinp, int din_len) | |
54 | -{ | |
55 | -#endif | |
56 | 49 | const int cmd_addr = EC_LPC_ADDR_HOST_CMD; |
57 | 50 | const int data_addr = EC_LPC_ADDR_HOST_DATA; |
58 | 51 | const int args_addr = EC_LPC_ADDR_HOST_ARGS; |
59 | 52 | |
... | ... | @@ -187,11 +180,7 @@ |
187 | 180 | * seeing whether the EC sets the EC_HOST_ARGS_FLAG_FROM_HOST flag |
188 | 181 | * in args when it responds. |
189 | 182 | */ |
190 | -#ifdef CONFIG_DM_CROS_EC | |
191 | 183 | static int cros_ec_lpc_check_version(struct udevice *dev) |
192 | -#else | |
193 | -int cros_ec_lpc_check_version(struct cros_ec_dev *dev) | |
194 | -#endif | |
195 | 184 | { |
196 | 185 | if (inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID) == 'E' && |
197 | 186 | inb(EC_LPC_ADDR_MEMMAP + EC_MEMMAP_ID + 1) |
... | ... | @@ -206,7 +195,6 @@ |
206 | 195 | return -1; |
207 | 196 | } |
208 | 197 | |
209 | -#ifdef CONFIG_DM_CROS_EC | |
210 | 198 | static int cros_ec_probe(struct udevice *dev) |
211 | 199 | { |
212 | 200 | return cros_ec_register(dev); |
... | ... | @@ -229,5 +217,4 @@ |
229 | 217 | .probe = cros_ec_probe, |
230 | 218 | .ops = &cros_ec_ops, |
231 | 219 | }; |
232 | -#endif |
drivers/misc/cros_ec_sandbox.c
... | ... | @@ -467,17 +467,10 @@ |
467 | 467 | return len; |
468 | 468 | } |
469 | 469 | |
470 | -#ifdef CONFIG_DM_CROS_EC | |
471 | 470 | int cros_ec_sandbox_packet(struct udevice *udev, int out_bytes, int in_bytes) |
472 | 471 | { |
473 | 472 | struct cros_ec_dev *dev = dev_get_uclass_priv(udev); |
474 | 473 | struct ec_state *ec = dev_get_priv(dev->dev); |
475 | -#else | |
476 | -int cros_ec_sandbox_packet(struct cros_ec_dev *dev, int out_bytes, | |
477 | - int in_bytes) | |
478 | -{ | |
479 | - struct ec_state *ec = &s_state; | |
480 | -#endif | |
481 | 474 | struct ec_host_request *req_hdr = (struct ec_host_request *)dev->dout; |
482 | 475 | const void *req_data = req_hdr + 1; |
483 | 476 | struct ec_host_response *resp_hdr = (struct ec_host_response *)dev->din; |
484 | 477 | |
485 | 478 | |
... | ... | @@ -500,18 +493,9 @@ |
500 | 493 | return in_bytes; |
501 | 494 | } |
502 | 495 | |
503 | -int cros_ec_sandbox_decode_fdt(struct cros_ec_dev *dev, const void *blob) | |
504 | -{ | |
505 | - return 0; | |
506 | -} | |
507 | - | |
508 | 496 | void cros_ec_check_keyboard(struct cros_ec_dev *dev) |
509 | 497 | { |
510 | -#ifdef CONFIG_DM_CROS_EC | |
511 | 498 | struct ec_state *ec = dev_get_priv(dev->dev); |
512 | -#else | |
513 | - struct ec_state *ec = &s_state; | |
514 | -#endif | |
515 | 499 | ulong start; |
516 | 500 | |
517 | 501 | printf("Press keys for EC to detect on reset (ESC=recovery)..."); |
... | ... | @@ -525,7 +509,6 @@ |
525 | 509 | } |
526 | 510 | } |
527 | 511 | |
528 | -#ifdef CONFIG_DM_CROS_EC | |
529 | 512 | int cros_ec_probe(struct udevice *dev) |
530 | 513 | { |
531 | 514 | struct ec_state *ec = dev->priv; |
... | ... | @@ -569,61 +552,6 @@ |
569 | 552 | return cros_ec_register(dev); |
570 | 553 | } |
571 | 554 | |
572 | -#else | |
573 | - | |
574 | -/** | |
575 | - * Initialize sandbox EC emulation. | |
576 | - * | |
577 | - * @param dev CROS_EC device | |
578 | - * @param blob Device tree blob | |
579 | - * @return 0 if ok, -1 on error | |
580 | - */ | |
581 | -int cros_ec_sandbox_init(struct cros_ec_dev *dev, const void *blob) | |
582 | -{ | |
583 | - struct ec_state *ec = &s_state; | |
584 | - int node; | |
585 | - int err; | |
586 | - | |
587 | - node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC); | |
588 | - if (node < 0) { | |
589 | - debug("Failed to find chrome-ec node'\n"); | |
590 | - return -1; | |
591 | - } | |
592 | - | |
593 | - err = cros_ec_decode_ec_flash(blob, node, &ec->ec_config); | |
594 | - if (err) | |
595 | - return err; | |
596 | - | |
597 | - node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC_KEYB); | |
598 | - if (node < 0) { | |
599 | - debug("%s: No cros_ec keyboard found\n", __func__); | |
600 | - } else if (keyscan_read_fdt_matrix(ec, blob, node)) { | |
601 | - debug("%s: Could not read key matrix\n", __func__); | |
602 | - return -1; | |
603 | - } | |
604 | - | |
605 | - /* If we loaded EC data, check that the length matches */ | |
606 | - if (ec->flash_data && | |
607 | - ec->flash_data_len != ec->ec_config.flash.length) { | |
608 | - printf("EC data length is %x, expected %x, discarding data\n", | |
609 | - ec->flash_data_len, ec->ec_config.flash.length); | |
610 | - os_free(ec->flash_data); | |
611 | - ec->flash_data = NULL; | |
612 | - } | |
613 | - | |
614 | - /* Otherwise allocate the memory */ | |
615 | - if (!ec->flash_data) { | |
616 | - ec->flash_data_len = ec->ec_config.flash.length; | |
617 | - ec->flash_data = os_malloc(ec->flash_data_len); | |
618 | - if (!ec->flash_data) | |
619 | - return -ENOMEM; | |
620 | - } | |
621 | - | |
622 | - return 0; | |
623 | -} | |
624 | -#endif | |
625 | - | |
626 | -#ifdef CONFIG_DM_CROS_EC | |
627 | 555 | struct dm_cros_ec_ops cros_ec_ops = { |
628 | 556 | .packet = cros_ec_sandbox_packet, |
629 | 557 | }; |
... | ... | @@ -641,5 +569,4 @@ |
641 | 569 | .priv_auto_alloc_size = sizeof(struct ec_state), |
642 | 570 | .ops = &cros_ec_ops, |
643 | 571 | }; |
644 | -#endif |
include/cros_ec.h
... | ... | @@ -15,31 +15,9 @@ |
15 | 15 | #include <cros_ec_message.h> |
16 | 16 | #include <asm/gpio.h> |
17 | 17 | |
18 | -#ifndef CONFIG_DM_CROS_EC | |
19 | -/* Which interface is the device on? */ | |
20 | -enum cros_ec_interface_t { | |
21 | - CROS_EC_IF_NONE, | |
22 | - CROS_EC_IF_SPI, | |
23 | - CROS_EC_IF_I2C, | |
24 | - CROS_EC_IF_LPC, /* Intel Low Pin Count interface */ | |
25 | - CROS_EC_IF_SANDBOX, | |
26 | -}; | |
27 | -#endif | |
28 | - | |
29 | 18 | /* Our configuration information */ |
30 | 19 | struct cros_ec_dev { |
31 | -#ifdef CONFIG_DM_CROS_EC | |
32 | 20 | struct udevice *dev; /* Transport device */ |
33 | -#else | |
34 | - enum cros_ec_interface_t interface; | |
35 | - struct spi_slave *spi; /* Our SPI slave, if using SPI */ | |
36 | - int node; /* Our node */ | |
37 | - int parent_node; /* Our parent node (interface) */ | |
38 | - unsigned int cs; /* Our chip select */ | |
39 | - unsigned int addr; /* Device address (for I2C) */ | |
40 | - unsigned int bus_num; /* Bus number (for I2C) */ | |
41 | - unsigned int max_frequency; /* Maximum interface frequency */ | |
42 | -#endif | |
43 | 21 | struct gpio_desc ec_int; /* GPIO used as EC interrupt line */ |
44 | 22 | int protocol_version; /* Protocol version to use */ |
45 | 23 | int optimise_flash_write; /* Don't write erased flash blocks */ |
... | ... | @@ -240,8 +218,6 @@ |
240 | 218 | */ |
241 | 219 | struct cros_ec_dev *board_get_cros_ec_dev(void); |
242 | 220 | |
243 | -#ifdef CONFIG_DM_CROS_EC | |
244 | - | |
245 | 221 | struct dm_cros_ec_ops { |
246 | 222 | int (*check_version)(struct udevice *dev); |
247 | 223 | int (*command)(struct udevice *dev, uint8_t cmd, int cmd_version, |
... | ... | @@ -254,112 +230,6 @@ |
254 | 230 | ((struct dm_cros_ec_ops *)(dev)->driver->ops) |
255 | 231 | |
256 | 232 | int cros_ec_register(struct udevice *dev); |
257 | - | |
258 | -#else /* !CONFIG_DM_CROS_EC */ | |
259 | - | |
260 | -/* Internal interfaces */ | |
261 | -int cros_ec_i2c_init(struct cros_ec_dev *dev, const void *blob); | |
262 | -int cros_ec_spi_init(struct cros_ec_dev *dev, const void *blob); | |
263 | -int cros_ec_lpc_init(struct cros_ec_dev *dev, const void *blob); | |
264 | -int cros_ec_sandbox_init(struct cros_ec_dev *dev, const void *blob); | |
265 | - | |
266 | -/** | |
267 | - * Read information from the fdt for the i2c cros_ec interface | |
268 | - * | |
269 | - * @param dev CROS-EC device | |
270 | - * @param blob Device tree blob | |
271 | - * @return 0 if ok, -1 if we failed to read all required information | |
272 | - */ | |
273 | -int cros_ec_i2c_decode_fdt(struct cros_ec_dev *dev, const void *blob); | |
274 | - | |
275 | -/** | |
276 | - * Read information from the fdt for the spi cros_ec interface | |
277 | - * | |
278 | - * @param dev CROS-EC device | |
279 | - * @param blob Device tree blob | |
280 | - * @return 0 if ok, -1 if we failed to read all required information | |
281 | - */ | |
282 | -int cros_ec_spi_decode_fdt(struct cros_ec_dev *dev, const void *blob); | |
283 | - | |
284 | -/** | |
285 | - * Read information from the fdt for the sandbox cros_ec interface | |
286 | - * | |
287 | - * @param dev CROS-EC device | |
288 | - * @param blob Device tree blob | |
289 | - * @return 0 if ok, -1 if we failed to read all required information | |
290 | - */ | |
291 | -int cros_ec_sandbox_decode_fdt(struct cros_ec_dev *dev, const void *blob); | |
292 | - | |
293 | -/** | |
294 | - * Check whether the LPC interface supports new-style commands. | |
295 | - * | |
296 | - * LPC has its own way of doing this, which involves checking LPC values | |
297 | - * visible to the host. Do this, and update dev->protocol_version accordingly. | |
298 | - * | |
299 | - * @param dev CROS-EC device to check | |
300 | - */ | |
301 | -int cros_ec_lpc_check_version(struct cros_ec_dev *dev); | |
302 | - | |
303 | -/** | |
304 | - * Send a command to an I2C CROS-EC device and return the reply. | |
305 | - * | |
306 | - * This rather complicated function deals with sending both old-style and | |
307 | - * new-style commands. The old ones have just a command byte and arguments. | |
308 | - * The new ones have version, command, arg-len, [args], chksum so are 3 bytes | |
309 | - * longer. | |
310 | - * | |
311 | - * The device's internal input/output buffers are used. | |
312 | - * | |
313 | - * @param dev CROS-EC device | |
314 | - * @param cmd Command to send (EC_CMD_...) | |
315 | - * @param cmd_version Version of command to send (EC_VER_...) | |
316 | - * @param dout Output data (may be NULL If dout_len=0) | |
317 | - * @param dout_len Size of output data in bytes | |
318 | - * @param dinp Returns pointer to response data | |
319 | - * @param din_len Maximum size of response in bytes | |
320 | - * @return number of bytes in response, or -1 on error | |
321 | - */ | |
322 | -int cros_ec_i2c_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version, | |
323 | - const uint8_t *dout, int dout_len, | |
324 | - uint8_t **dinp, int din_len); | |
325 | - | |
326 | -/** | |
327 | - * Send a command to a LPC CROS-EC device and return the reply. | |
328 | - * | |
329 | - * The device's internal input/output buffers are used. | |
330 | - * | |
331 | - * @param dev CROS-EC device | |
332 | - * @param cmd Command to send (EC_CMD_...) | |
333 | - * @param cmd_version Version of command to send (EC_VER_...) | |
334 | - * @param dout Output data (may be NULL If dout_len=0) | |
335 | - * @param dout_len Size of output data in bytes | |
336 | - * @param dinp Returns pointer to response data | |
337 | - * @param din_len Maximum size of response in bytes | |
338 | - * @return number of bytes in response, or -1 on error | |
339 | - */ | |
340 | -int cros_ec_lpc_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version, | |
341 | - const uint8_t *dout, int dout_len, | |
342 | - uint8_t **dinp, int din_len); | |
343 | - | |
344 | -int cros_ec_spi_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version, | |
345 | - const uint8_t *dout, int dout_len, | |
346 | - uint8_t **dinp, int din_len); | |
347 | - | |
348 | -/** | |
349 | - * Send a packet to a CROS-EC device and return the response packet. | |
350 | - * | |
351 | - * Expects the request packet to be stored in dev->dout. Stores the response | |
352 | - * packet in dev->din. | |
353 | - * | |
354 | - * @param dev CROS-EC device | |
355 | - * @param out_bytes Size of request packet to output | |
356 | - * @param in_bytes Maximum size of response packet to receive | |
357 | - * @return number of bytes in response packet, or <0 on error | |
358 | - */ | |
359 | -int cros_ec_spi_packet(struct cros_ec_dev *dev, int out_bytes, int in_bytes); | |
360 | -int cros_ec_sandbox_packet(struct cros_ec_dev *dev, int out_bytes, | |
361 | - int in_bytes); | |
362 | -#endif | |
363 | 233 | |
364 | 234 | /** |
365 | 235 | * Dump a block of data for a command. |