2 * Copyright (C) 2008 Yoshihiro Shimoda <shimoda.yoshihiro@renesas.com>
4 * SPDX-License-Identifier: GPL-2.0+
9 #include <asm/processor.h>
12 #if defined(CONFIG_CPU_32BIT)
13 #define NOCACHE_OFFSET 0x00000000
15 #define NOCACHE_OFFSET 0xa0000000
17 #define PLD_LEDCR (0x04000008 + NOCACHE_OFFSET)
18 #define PLD_SWSR (0x0400000a + NOCACHE_OFFSET)
19 #define PLD_VERSR (0x0400000c + NOCACHE_OFFSET)
21 #define SM107_DEVICEID (0x13e00060 + NOCACHE_OFFSET)
23 static void test_pld(void)
25 printf("PLD version = %04x\n", readb(PLD_VERSR));
28 static void test_sm107(void)
30 printf("SM107 device ID = %04x\n", readl(SM107_DEVICEID));
33 static void test_led(void)
35 printf("turn on LEDs 3, 5, 7, 9\n");
36 writeb(0x55, PLD_LEDCR);
38 printf("turn on LEDs 4, 6, 8, 10\n");
39 writeb(0xaa, PLD_LEDCR);
41 writeb(0x00, PLD_LEDCR);
44 static void test_dipsw(void)
46 printf("Please DIPSW set = B'0101\n");
47 while (readb(PLD_SWSR) != 0x05) {
51 printf("Please DIPSW set = B'1010\n");
52 while (readb(PLD_SWSR) != 0x0A) {
59 static void test_net(void)
63 writel(0x80000000, 0xfe0401c0);
64 data = readl(0xfe040220);
65 if (data == 0x816910ec)
66 printf("Ethernet OK\n");
68 printf("Ethernet NG, data = %08x\n", (unsigned int)data);
71 static void test_sata(void)
75 writel(0x80000800, 0xfe0401c0);
76 data = readl(0xfe040220);
77 if (data == 0x35121095)
80 printf("SATA NG, data = %08x\n", (unsigned int)data);
83 static void test_pci(void)
85 writel(0x80001800, 0xfe0401c0);
86 printf("PCI CN1 ID = %08x\n", readl(0xfe040220));
88 writel(0x80001000, 0xfe0401c0);
89 printf("PCI CN2 ID = %08x\n", readl(0xfe040220));
92 int do_hw_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
97 return cmd_usage(cmdtp);
110 case 'p': /* pld or pci */
119 case 'd': /* dipsw */
122 case 's': /* sm107 or sata */
132 return cmd_usage(cmdtp);
139 hwtest, 2, 1, do_hw_test,
140 "hardware test for R0P7785LC0011RL board",
142 "hwtest all - test all hardware\n"
143 "hwtest pld - output PLD version\n"
144 "hwtest led - turn on LEDs\n"
145 "hwtest dipsw - test DIP switch\n"
146 "hwtest sm107 - output SM107 version\n"
147 "hwtest net - check RTL8110 ID\n"
148 "hwtest sata - check SiI3512 ID\n"
149 "hwtest pci - output PCI slot device ID"