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