Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (C) 2017 Marvell International Ltd. |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0 |
| 6 | */ |
| 7 | |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 8 | #include <command.h> |
| 9 | #include <console.h> |
| 10 | #include <dm.h> |
| 11 | #include <fdtdec.h> |
| 12 | #include <dm/device-internal.h> |
| 13 | #include <mvebu/comphy.h> |
| 14 | |
Stefan Roese | 3873032 | 2021-05-05 09:15:10 +0200 | [diff] [blame] | 15 | int mvebu_comphy_rx_training_cmd(struct cmd_tbl *cmdtp, int flag, int argc, |
| 16 | char * const argv[]) |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 17 | { |
| 18 | struct udevice *dev; |
| 19 | struct uclass *uc; |
| 20 | int ret, cp_index, comphy_index, i = 0; |
| 21 | |
| 22 | if (argc != 3) { |
| 23 | printf("missing arguments\n"); |
Shenlin Liang | 588ea36 | 2022-12-09 17:17:43 +0800 | [diff] [blame] | 24 | return CMD_RET_USAGE; |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 25 | } |
| 26 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 27 | cp_index = hextoul(argv[1], NULL); |
| 28 | comphy_index = hextoul(argv[2], NULL); |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 29 | |
| 30 | ret = uclass_get(UCLASS_MISC, &uc); |
| 31 | if (ret) { |
| 32 | printf("Couldn't find UCLASS_MISC\n"); |
| 33 | return ret; |
| 34 | } |
| 35 | |
| 36 | uclass_foreach_dev(dev, uc) { |
| 37 | if (!(memcmp(dev->name, "comphy", 5))) { |
| 38 | if (i == cp_index) { |
| 39 | comphy_rx_training(dev, comphy_index); |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | i++; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | printf("Coudn't find comphy %d\n", cp_index); |
| 48 | |
| 49 | return 0; |
| 50 | } |
| 51 | |
| 52 | U_BOOT_CMD( |
Stefan Roese | 3873032 | 2021-05-05 09:15:10 +0200 | [diff] [blame] | 53 | mvebu_comphy_rx_training, 3, 0, mvebu_comphy_rx_training_cmd, |
| 54 | "mvebu_comphy_rx_training <cp id> <comphy id>\n", |
| 55 | "\n\tRun COMPHY RX training sequence, the user must state CP index (0/1) and comphy ID (0/5)" |
Igal Liberman | 6795a66 | 2021-03-23 11:57:57 +0100 | [diff] [blame] | 56 | ); |