blob: 5653877cd4a2cbca0b70c605c392acb72c80ff61 [file] [log] [blame]
Igal Liberman6795a662021-03-23 11:57:57 +01001// 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 Liberman6795a662021-03-23 11:57:57 +01008#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 Roese38730322021-05-05 09:15:10 +020015int mvebu_comphy_rx_training_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
16 char * const argv[])
Igal Liberman6795a662021-03-23 11:57:57 +010017{
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 Liang588ea362022-12-09 17:17:43 +080024 return CMD_RET_USAGE;
Igal Liberman6795a662021-03-23 11:57:57 +010025 }
26
Simon Glass3ff49ec2021-07-24 09:03:29 -060027 cp_index = hextoul(argv[1], NULL);
28 comphy_index = hextoul(argv[2], NULL);
Igal Liberman6795a662021-03-23 11:57:57 +010029
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
52U_BOOT_CMD(
Stefan Roese38730322021-05-05 09:15:10 +020053 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 Liberman6795a662021-03-23 11:57:57 +010056);