blob: 0798decfae13b3280ebb212b65fea8a291650942 [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
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 Roese38730322021-05-05 09:15:10 +020016int mvebu_comphy_rx_training_cmd(struct cmd_tbl *cmdtp, int flag, int argc,
17 char * const argv[])
Igal Liberman6795a662021-03-23 11:57:57 +010018{
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
28 cp_index = simple_strtoul(argv[1], NULL, 16);
29 comphy_index = simple_strtoul(argv[2], NULL, 16);
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
53U_BOOT_CMD(
Stefan Roese38730322021-05-05 09:15:10 +020054 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 Liberman6795a662021-03-23 11:57:57 +010057);