summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTerry Lv <r65388@freescale.com>2012-02-16 01:38:47 +0800
committerTerry Lv <r65388@freescale.com>2012-02-16 02:24:04 +0800
commitc1ce2e692f4c9ac475504b4976b82de241e36b45 (patch)
treebf0f0969bac3c6f840128ed4cd557f47c823e843 /common
parent69665152823a798b3560d42e6456ce3cc041ffec (diff)
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 <regulator name> - Show regulator's voltage in mV regul set core <voltage value> - Set core voltage in mV regul set periph <voltage value> - Set periph voltage in mV regul set <regulator name> <voltage value> - 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 <r65388@freescale.com>
Diffstat (limited to 'common')
-rw-r--r--common/Makefile1
-rw-r--r--common/cmd_regul.c106
2 files changed, 107 insertions, 0 deletions
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 <linux/types.h>
+#include <command.h>
+#include <common.h>
+#include <asm/regulator.h>
+
+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 <regulator name> "
+ "- Show regulator's voltage in mV\n"
+ "regul set core <voltage value> "
+ "- Set core voltage in mV\n"
+ "regul set periph <voltage value> "
+ "- Set periph voltage in mV\n"
+ "regul set <regulator name> <voltage value> "
+ "- Set regulator's voltage in mV");
+