arm: vf610: add uart0 clock/iomux definitions
[u-boot/qq2440-u-boot.git] / common / cmd_io.c
blobeefac36f87e9b235595437d1fce637be39c9c723
1 /*
2 * Copyright (c) 2012 The Chromium OS Authors.
4 * SPDX-License-Identifier: GPL-2.0+
5 */
7 /*
8 * IO space access commands.
9 */
11 #include <common.h>
12 #include <command.h>
13 #include <asm/io.h>
16 * IO Display
18 * Syntax:
19 * iod{.b, .w, .l} {addr}
21 int do_io_iod(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
23 ulong addr;
24 int size;
26 if (argc != 2)
27 return CMD_RET_USAGE;
29 size = cmd_get_data_size(argv[0], 4);
30 if (size < 0)
31 return 1;
33 addr = simple_strtoul(argv[1], NULL, 16);
35 printf("%04x: ", (u16) addr);
37 if (size == 4)
38 printf("%08x\n", inl(addr));
39 else if (size == 2)
40 printf("%04x\n", inw(addr));
41 else
42 printf("%02x\n", inb(addr));
44 return 0;
47 int do_io_iow(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
49 ulong addr, size, val;
51 if (argc != 3)
52 return CMD_RET_USAGE;
54 size = cmd_get_data_size(argv[0], 4);
55 if (size < 0)
56 return 1;
58 addr = simple_strtoul(argv[1], NULL, 16);
59 val = simple_strtoul(argv[2], NULL, 16);
61 if (size == 4)
62 outl((u32) val, addr);
63 else if (size == 2)
64 outw((u16) val, addr);
65 else
66 outb((u8) val, addr);
68 return 0;
71 /**************************************************/
72 U_BOOT_CMD(iod, 2, 0, do_io_iod,
73 "IO space display", "[.b, .w, .l] address [# of objects]");
75 U_BOOT_CMD(iow, 3, 0, do_io_iow,
76 "IO space modify (auto-incrementing address)",
77 "[.b, .w, .l] address");