From c1ce2e692f4c9ac475504b4976b82de241e36b45 Mon Sep 17 00:00:00 2001 From: Terry Lv Date: Thu, 16 Feb 2012 01:38:47 +0800 Subject: ENGR00139213: Add read and change voltage support for mx6 dd read and change voltage support for mx6. For help, pls type "help regul" Detail command info: regul list - List all regulators' name regul show all - Display all regulators' voltage regul show core - Show core voltage in mV regul show periph - Show peripheral voltage in mV regul show - Show regulator's voltage in mV regul set core - Set core voltage in mV regul set periph - Set periph voltage in mV regul set - Set regulator's voltage in mV Example: MX6Q ARM2 U-Boot > regul list Name Voltage vddpu vddcore vddsoc vdd2p5 vdd1p1 vdd3p0 MX6Q ARM2 U-Boot > regul show all Name Voltage vddpu 1100000 vddcore 1100000 vddsoc 1200000 vdd2p5 2400000 vdd1p1 1100000 vdd3p0 3000000 MX6Q ARM2 U-Boot > regul show periph Name Voltage periph: 1100000 MX6Q ARM2 U-Boot > regul show core Name Voltage core: 1100000 MX6Q ARM2 U-Boot > regul set core 1100000 Set voltage succeed! Name Voltage core: 1100000 Signed-off-by: Terry Lv --- common/Makefile | 1 + common/cmd_regul.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 common/cmd_regul.c (limited to 'common') diff --git a/common/Makefile b/common/Makefile index 1f218e7b7e..413b18c1cb 100644 --- a/common/Makefile +++ b/common/Makefile @@ -136,6 +136,7 @@ endif COBJS-y += cmd_pcmcia.o COBJS-$(CONFIG_CMD_PORTIO) += cmd_portio.o COBJS-$(CONFIG_CMD_REGINFO) += cmd_reginfo.o +COBJS-$(CONFIG_CMD_REGUL) += cmd_regul.o COBJS-$(CONFIG_CMD_REISER) += cmd_reiser.o COBJS-$(CONFIG_CMD_SATA) += cmd_sata.o COBJS-$(CONFIG_CMD_SF) += cmd_sf.o diff --git a/common/cmd_regul.c b/common/cmd_regul.c new file mode 100644 index 0000000000..343d616d90 --- /dev/null +++ b/common/cmd_regul.c @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2012 Freescale Semiconductor, Inc. + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include +#include + +int do_regulops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + int rc = 0; + int uv = 0; + + switch (argc) { + case 2: + if (strcmp(argv[1], "list") == 0) + regul_list(0); + else + printf("Unsupported command: %s!\n", argv[1]); + + break; + case 3: + if (strcmp(argv[1], "show") == 0) { + if (strcmp(argv[2], "all") == 0) { + regul_list(1); + break; + } else if (strcmp(argv[2], "core") == 0) + uv = regul_get_core(); + else if (strcmp(argv[2], "periph") == 0) + uv = regul_get_periph(); + else + uv = regul_get(argv[2]); + + if (uv >= 0) + printf("Name\t\tVoltage\n"); + printf("%s:\t\t%d\n", argv[2], uv); + else + printf("Can't get regulator's voltage!\n"); + } else + printf("Unsupported command: %s!\n", argv[1]); + break; + case 4: + if (strcmp(argv[1], "set") == 0) { + uv = simple_strtoul(argv[3], NULL, 10); + if (strcmp(argv[2], "core") == 0) + rc = regul_set_core(uv); + else if (strcmp(argv[2], "periph") == 0) + rc = regul_set_periph(uv); + else + rc = regul_set(argv[2], uv); + + if (!rc) { + printf("Set voltage succeed!\n"); + printf("Name\t\tVoltage\n"); + printf("%s:\t\t%d\n", argv[2], uv); + } + } else + printf("Unsupported command: %s!\n", argv[1]); + break; + default: + rc = 1; + printf("Too many or less parameters!\n"); + break; + } + + return rc; +} + +U_BOOT_CMD( + regul, 4, 1, do_regulops, + "Regulator sub system", + "list - List all regulators' name\n" + "regul show all " + "- Display all regulators' voltage\n" + "regul show core " + "- Show core voltage in mV\n" + "regul show periph " + "- Show peripheral voltage in mV\n" + "regul show " + "- Show regulator's voltage in mV\n" + "regul set core " + "- Set core voltage in mV\n" + "regul set periph " + "- Set periph voltage in mV\n" + "regul set " + "- Set regulator's voltage in mV"); + -- cgit v1.2.3