mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 2/4] twl6030: add power button as an input key
@ 2013-03-12  0:01 Vicente Bergas
  2013-03-12  0:01 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
  2013-03-12 17:48 ` [PATCH 2/4] twl6030: add power button as an input key Sascha Hauer
  0 siblings, 2 replies; 9+ messages in thread
From: Vicente Bergas @ 2013-03-12  0:01 UTC (permalink / raw)
  To: s.hauer, barebox; +Cc: Vicente Bergas

Done as suggested.
Thanks for the suggestion.

Signed-off-by: Vicente Bergas <vicencb@gmail.com>
---
 drivers/input/Kconfig          |   7 +++
 drivers/input/Makefile         |   1 +
 drivers/input/twl6030_pwrbtn.c | 112 +++++++++++++++++++++++++++++++++++++++++
 include/twl6030_pwrbtn.h       |   9 ++++
 4 files changed, 129 insertions(+)
 create mode 100644 drivers/input/twl6030_pwrbtn.c
 create mode 100644 include/twl6030_pwrbtn.h

diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
index a6f1f47..3d9016b 100644
--- a/drivers/input/Kconfig
+++ b/drivers/input/Kconfig
@@ -38,4 +38,11 @@ config KEYBOARD_QT1070
 	  Say Y here if you want to use Atmel AT42QT1070 QTouch
 	  Sensor chip as input device.
 
+config KEYBOARD_TWL6030
+	tristate "TWL6030 power button"
+	depends on MFD_TWL6030
+	select POLLER
+	help
+	  Say Y here if you want to use TWL6030 power button as a key.
+
 endmenu
diff --git a/drivers/input/Makefile b/drivers/input/Makefile
index d042980..b9bcc82 100644
--- a/drivers/input/Makefile
+++ b/drivers/input/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
+obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
 obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
 obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
diff --git a/drivers/input/twl6030_pwrbtn.c b/drivers/input/twl6030_pwrbtn.c
new file mode 100644
index 0000000..ec6cf7f
--- /dev/null
+++ b/drivers/input/twl6030_pwrbtn.c
@@ -0,0 +1,112 @@
+/*
+ * 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.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <malloc.h>
+#include <poller.h>
+#include <kfifo.h>
+#include <mfd/twl6030.h>
+#include <twl6030_pwrbtn.h>
+
+struct twl6030_pwrbtn_internal_data {
+	int code;
+	u8 previous_state;
+	struct twl6030 *twl6030;
+	struct kfifo *recv_fifo;
+	struct console_device cdev;
+	struct poller_struct poller;
+};
+
+#define PWR_PWRON_IRQ (1 << 0)
+
+static void ic2_key_poller(struct poller_struct *poller)
+{
+	struct twl6030_pwrbtn_internal_data *idata = container_of(
+		poller, struct twl6030_pwrbtn_internal_data, poller);
+	u8 val;
+
+	if (twl6030_reg_read(idata->twl6030, TWL6030_PMCM_HW, &val)) {
+		dev_err(idata->cdev.dev, "reading i2c\n");
+		return;
+	}
+	val = !(val & PWR_PWRON_IRQ);
+	if (val != idata->previous_state && val) {
+		kfifo_put(idata->recv_fifo, (u_char *)&idata->code,
+			sizeof(int));
+		dev_dbg(idata->cdev.dev, "pressed power button as %d\n",
+			idata->code);
+	}
+	idata->previous_state = val;
+}
+
+static int twl6030_pwrbtn_tstc(struct console_device *cdev)
+{
+	struct twl6030_pwrbtn_internal_data *idata = container_of(
+		cdev, struct twl6030_pwrbtn_internal_data, cdev);
+
+	return kfifo_len(idata->recv_fifo) ? 1 : 0;
+}
+
+static int twl6030_pwrbtn_getc(struct console_device *cdev)
+{
+	int code = 0;
+	struct twl6030_pwrbtn_internal_data *idata = container_of(
+		cdev, struct twl6030_pwrbtn_internal_data, cdev);
+
+	kfifo_get(idata->recv_fifo, (u_char *)&code, sizeof(int));
+	return code;
+}
+
+static int __init twl6030_pwrbtn_probe(struct device_d *dev)
+{
+	struct twl6030_pwrbtn_internal_data *idata;
+	struct twl6030_pwrbtn_platform_data *pdata;
+
+	pdata = dev->platform_data;
+	if (!pdata) {
+		dev_err(dev, "missing platform_data\n");
+		return -ENODEV;
+	}
+
+	idata = xzalloc(sizeof(struct twl6030_pwrbtn_internal_data));
+	if (!idata) {
+		dev_err(dev, "out of memory allocating idata\n");
+		return -ENOMEM;
+	}
+
+	idata->recv_fifo = kfifo_alloc(sizeof(int));
+	if (!idata->recv_fifo) {
+		dev_err(dev, "out of memory allocating kfifo\n");
+		free(idata);
+		return -ENOMEM;
+	}
+
+	idata->code = pdata->code;
+	idata->twl6030 = twl6030_get();
+	idata->poller.func = ic2_key_poller;
+
+	dev->type_data = &idata->cdev;
+	idata->cdev.dev = dev;
+	idata->cdev.f_caps = CONSOLE_STDIN;
+	idata->cdev.tstc = twl6030_pwrbtn_tstc;
+	idata->cdev.getc = twl6030_pwrbtn_getc;
+	console_register(&idata->cdev);
+
+	return poller_register(&idata->poller);
+}
+
+static struct driver_d twl6030_pwrbtn_driver = {
+	.name	= "twl6030_pwrbtn",
+	.probe	= twl6030_pwrbtn_probe,
+};
+device_platform_driver(twl6030_pwrbtn_driver);
diff --git a/include/twl6030_pwrbtn.h b/include/twl6030_pwrbtn.h
new file mode 100644
index 0000000..c4e13d1
--- /dev/null
+++ b/include/twl6030_pwrbtn.h
@@ -0,0 +1,9 @@
+#ifndef _TWL6030_PWRBTN_H
+#define _TWL6030_PWRBTN_H
+
+struct twl6030_pwrbtn_platform_data {
+	/* key code */
+	int code;
+};
+
+#endif
-- 
1.8.1.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-12  0:01 [PATCH 2/4] twl6030: add power button as an input key Vicente Bergas
@ 2013-03-12  0:01 ` Vicente Bergas
  2013-03-12 17:51   ` Sascha Hauer
  2013-03-12 17:48 ` [PATCH 2/4] twl6030: add power button as an input key Sascha Hauer
  1 sibling, 1 reply; 9+ messages in thread
From: Vicente Bergas @ 2013-03-12  0:01 UTC (permalink / raw)
  To: s.hauer, barebox; +Cc: Vicente Bergas

getopt: done as suggested
bootsrc: done as suggested

IMO this command will be used 99% of the times followed by a reset.
The -r option will avoid the burden of executing always the same two commands.

Signed-off-by: Vicente Bergas <vicencb@gmail.com>
---
 arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
 arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
 commands/Kconfig                                |  5 ++
 commands/Makefile                               |  1 +
 commands/boot_order.c                           | 88 +++++++++++++++++++++++++
 5 files changed, 134 insertions(+)
 create mode 100644 commands/boot_order.c

diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
index 9e82435..7e67abc 100644
--- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
+++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
@@ -161,6 +161,25 @@
 #define OMAP44XX_PRM_RSTCTRL_RESET	0x01
 
 /*
+ * SAR (Save & Rescue) memory region
+ */
+#define OMAP44XX_SAR_RAM_BASE      0x4a326000
+#define OMAP44XX_SAR_CH_ADDRESS    (OMAP44XX_SAR_RAM_BASE + 0xA00)
+#define OMAP44XX_SAR_CH_START      (OMAP44XX_SAR_RAM_BASE + 0xA0C)
+#define OMAP44XX_SAR_BOOT_VOID     0x00
+#define OMAP44XX_SAR_BOOT_XIP      0x01
+#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
+#define OMAP44XX_SAR_BOOT_NAND     0x03
+#define OMAP44XX_SAR_BOOT_ONENAND  0x04
+#define OMAP44XX_SAR_BOOT_MMC1     0x05
+#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
+#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
+#define OMAP44XX_SAR_BOOT_UART     0x43
+#define OMAP44XX_SAR_BOOT_USB_1    0x45
+#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
+#define OMAP44XX_SAR_BOOT_USB_2    0x47
+
+/*
  * Non-secure SRAM Addresses
  * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
  * at 0x40304000(EMU base) so that our code works for both EMU and GP
@@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
 void omap4_power_i2c_send(u32);
 unsigned int omap4_revision(void);
 noinline int omap4_scale_vcores(unsigned vsel0_pin);
+void omap4_set_warmboot_order(u32 *device_list);
 
 #endif
 
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index 2a09eb6..e062332 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
 	while (1);
 }
 
+void omap4_set_warmboot_order(u32 *device_list)
+{
+	const u32 CH[] = {
+		0xCF00AA01,
+		0x0000000C,
+		(device_list[0] << 16) | 0x0000,
+		(device_list[2] << 16) | device_list[1],
+		0x0000 | device_list[3],
+		0x00000000,
+		0x00000000,
+		0x00000000,
+		0x00000000
+	};
+	int i;
+
+	for (i = 0; i < ARRAY_SIZE(CH); i++)
+		writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
+	writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
+}
+
 #define WATCHDOG_WSPR	0x48
 #define WATCHDOG_WWPS	0x34
 
diff --git a/commands/Kconfig b/commands/Kconfig
index 0062758..524f00e 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -474,6 +474,11 @@ config CMD_POWEROFF
 	depends on HAS_POWEROFF
 	prompt "poweroff"
 
+config CMD_BOOT_ORDER
+	tristate
+	depends on ARCH_OMAP4
+	prompt "boot_order"
+
 config CMD_GO
 	tristate
 	prompt "go"
diff --git a/commands/Makefile b/commands/Makefile
index 0ae6b95..428da57 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
 obj-$(CONFIG_CMD_MSLEEP)	+= msleep.o
 obj-$(CONFIG_CMD_RESET)		+= reset.o
 obj-$(CONFIG_CMD_POWEROFF)	+= poweroff.o
+obj-$(CONFIG_CMD_BOOT_ORDER)	+= boot_order.o
 obj-$(CONFIG_CMD_GO)		+= go.o
 obj-$(CONFIG_NET)		+= net.o
 obj-$(CONFIG_CMD_PARTITION)	+= partition.o
diff --git a/commands/boot_order.c b/commands/boot_order.c
new file mode 100644
index 0000000..1c31c16
--- /dev/null
+++ b/commands/boot_order.c
@@ -0,0 +1,88 @@
+/*
+ * boot_order.c - configure omap warm boot
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <getopt.h>
+#include <mach/omap4-silicon.h>
+
+struct bootsrc {
+	const char *name;
+	uint32_t sar;
+};
+
+static int cmd_boot_order(int argc, char *argv[])
+{
+	const struct bootsrc src_list[] = {
+		{"xip"     , OMAP44XX_SAR_BOOT_XIP     },
+		{"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
+		{"nand"    , OMAP44XX_SAR_BOOT_NAND    },
+		{"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
+		{"mmc1"    , OMAP44XX_SAR_BOOT_MMC1    },
+		{"mmc2_1"  , OMAP44XX_SAR_BOOT_MMC2_1  },
+		{"mmc2_2"  , OMAP44XX_SAR_BOOT_MMC2_2  },
+		{"uart"    , OMAP44XX_SAR_BOOT_UART    },
+		{"usb_1"   , OMAP44XX_SAR_BOOT_USB_1   },
+		{"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
+		{"usb_2"   , OMAP44XX_SAR_BOOT_USB_2   },
+	};
+	uint32_t device_list[] = {
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+	};
+	int i, j, opt, do_reset = 0;
+
+	while ((opt = getopt(argc, argv, "r")) > 0) {
+		switch (opt) {
+		case 'r':
+			do_reset = 1;
+			break;
+		}
+	}
+	for (i = 0; i + optind < argc && i < ARRAY_SIZE(device_list); i++) {
+		for (j = 0; j < ARRAY_SIZE(src_list); j++) {
+			if (strcmp(argv[i + optind], src_list[j].name) == 0) {
+				device_list[i] = src_list[j].sar;
+				break;
+			}
+		}
+	}
+	if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
+		printf("First boot device can't be void\n");
+		return COMMAND_ERROR_USAGE;
+	}
+	omap4_set_warmboot_order(device_list);
+	if (do_reset) {
+		shutdown_barebox();
+		reset_cpu(0);
+	}
+	return 0;
+}
+
+static const __maybe_unused char cmd_boot_order_help[] =
+"Usage: boot_order [-r] <device 1> [<device n>]\n"
+"Set warm boot order up to four devices\n"
+"and reset cpu if -r is specified.\n"
+"Each device can be one of:\n"
+"void xip xipwait nand onenand mmc1 mmc2_1 mmc2_2 uart usb_1 usb_ulpi usb_2\n";
+
+BAREBOX_CMD_START(boot_order)
+	.cmd		= cmd_boot_order,
+	.usage		= "boot_order <device 1> [<device n>]",
+	BAREBOX_CMD_HELP(cmd_boot_order_help)
+	BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
-- 
1.8.1.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 2/4] twl6030: add power button as an input key
  2013-03-12  0:01 [PATCH 2/4] twl6030: add power button as an input key Vicente Bergas
  2013-03-12  0:01 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
@ 2013-03-12 17:48 ` Sascha Hauer
  1 sibling, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12 17:48 UTC (permalink / raw)
  To: Vicente Bergas; +Cc: barebox

On Tue, Mar 12, 2013 at 01:01:23AM +0100, Vicente Bergas wrote:
> Done as suggested.
> Thanks for the suggestion.
> 
> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
> ---
>  drivers/input/Kconfig          |   7 +++
>  drivers/input/Makefile         |   1 +
>  drivers/input/twl6030_pwrbtn.c | 112 +++++++++++++++++++++++++++++++++++++++++
>  include/twl6030_pwrbtn.h       |   9 ++++
>  4 files changed, 129 insertions(+)
>  create mode 100644 drivers/input/twl6030_pwrbtn.c
>  create mode 100644 include/twl6030_pwrbtn.h
> 
> diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig
> index a6f1f47..3d9016b 100644
> --- a/drivers/input/Kconfig
> +++ b/drivers/input/Kconfig
> @@ -38,4 +38,11 @@ config KEYBOARD_QT1070
>  	  Say Y here if you want to use Atmel AT42QT1070 QTouch
>  	  Sensor chip as input device.
>  
> +config KEYBOARD_TWL6030
> +	tristate "TWL6030 power button"
> +	depends on MFD_TWL6030
> +	select POLLER
> +	help
> +	  Say Y here if you want to use TWL6030 power button as a key.
> +
>  endmenu
> diff --git a/drivers/input/Makefile b/drivers/input/Makefile
> index d042980..b9bcc82 100644
> --- a/drivers/input/Makefile
> +++ b/drivers/input/Makefile
> @@ -1,3 +1,4 @@
>  obj-$(CONFIG_KEYBOARD_GPIO) += gpio_keys.o
> +obj-$(CONFIG_KEYBOARD_TWL6030) += twl6030_pwrbtn.o
>  obj-$(CONFIG_KEYBOARD_IMX_KEYPAD) += imx_keypad.o
>  obj-$(CONFIG_KEYBOARD_QT1070) += qt1070.o
> diff --git a/drivers/input/twl6030_pwrbtn.c b/drivers/input/twl6030_pwrbtn.c
> new file mode 100644
> index 0000000..ec6cf7f
> --- /dev/null
> +++ b/drivers/input/twl6030_pwrbtn.c
> @@ -0,0 +1,112 @@
> +/*
> + * 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.
> + */
> +
> +#include <common.h>
> +#include <init.h>
> +#include <malloc.h>
> +#include <poller.h>
> +#include <kfifo.h>
> +#include <mfd/twl6030.h>
> +#include <twl6030_pwrbtn.h>
> +
> +struct twl6030_pwrbtn_internal_data {
> +	int code;
> +	u8 previous_state;
> +	struct twl6030 *twl6030;
> +	struct kfifo *recv_fifo;
> +	struct console_device cdev;
> +	struct poller_struct poller;
> +};
> +
> +#define PWR_PWRON_IRQ (1 << 0)
> +
> +static void ic2_key_poller(struct poller_struct *poller)
> +{
> +	struct twl6030_pwrbtn_internal_data *idata = container_of(
> +		poller, struct twl6030_pwrbtn_internal_data, poller);
> +	u8 val;
> +
> +	if (twl6030_reg_read(idata->twl6030, TWL6030_PMCM_HW, &val)) {
> +		dev_err(idata->cdev.dev, "reading i2c\n");
> +		return;
> +	}
> +	val = !(val & PWR_PWRON_IRQ);
> +	if (val != idata->previous_state && val) {
> +		kfifo_put(idata->recv_fifo, (u_char *)&idata->code,
> +			sizeof(int));
> +		dev_dbg(idata->cdev.dev, "pressed power button as %d\n",
> +			idata->code);
> +	}
> +	idata->previous_state = val;
> +}
> +
> +static int twl6030_pwrbtn_tstc(struct console_device *cdev)
> +{
> +	struct twl6030_pwrbtn_internal_data *idata = container_of(
> +		cdev, struct twl6030_pwrbtn_internal_data, cdev);
> +
> +	return kfifo_len(idata->recv_fifo) ? 1 : 0;
> +}
> +
> +static int twl6030_pwrbtn_getc(struct console_device *cdev)
> +{
> +	int code = 0;
> +	struct twl6030_pwrbtn_internal_data *idata = container_of(
> +		cdev, struct twl6030_pwrbtn_internal_data, cdev);
> +
> +	kfifo_get(idata->recv_fifo, (u_char *)&code, sizeof(int));
> +	return code;
> +}
> +
> +static int __init twl6030_pwrbtn_probe(struct device_d *dev)
> +{
> +	struct twl6030_pwrbtn_internal_data *idata;
> +	struct twl6030_pwrbtn_platform_data *pdata;
> +
> +	pdata = dev->platform_data;
> +	if (!pdata) {
> +		dev_err(dev, "missing platform_data\n");
> +		return -ENODEV;
> +	}
> +
> +	idata = xzalloc(sizeof(struct twl6030_pwrbtn_internal_data));
> +	if (!idata) {
> +		dev_err(dev, "out of memory allocating idata\n");
> +		return -ENOMEM;
> +	}

xzalloc always returns memory. You don't need to check the result.

Fixed while applying.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-12  0:01 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
@ 2013-03-12 17:51   ` Sascha Hauer
  2013-03-12 20:20     ` vj
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12 17:51 UTC (permalink / raw)
  To: Vicente Bergas; +Cc: barebox

On Tue, Mar 12, 2013 at 01:01:24AM +0100, Vicente Bergas wrote:
> getopt: done as suggested
> bootsrc: done as suggested
> 
> IMO this command will be used 99% of the times followed by a reset.
> The -r option will avoid the burden of executing always the same two commands.
> 
> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
> ---
>  arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
>  arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
>  commands/Kconfig                                |  5 ++
>  commands/Makefile                               |  1 +
>  commands/boot_order.c                           | 88 +++++++++++++++++++++++++
>  5 files changed, 134 insertions(+)
>  create mode 100644 commands/boot_order.c
> 
> diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
> index 9e82435..7e67abc 100644
> --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
> +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
> @@ -161,6 +161,25 @@
>  #define OMAP44XX_PRM_RSTCTRL_RESET	0x01
>  
>  /*
> + * SAR (Save & Rescue) memory region
> + */
> +#define OMAP44XX_SAR_RAM_BASE      0x4a326000
> +#define OMAP44XX_SAR_CH_ADDRESS    (OMAP44XX_SAR_RAM_BASE + 0xA00)
> +#define OMAP44XX_SAR_CH_START      (OMAP44XX_SAR_RAM_BASE + 0xA0C)
> +#define OMAP44XX_SAR_BOOT_VOID     0x00
> +#define OMAP44XX_SAR_BOOT_XIP      0x01
> +#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
> +#define OMAP44XX_SAR_BOOT_NAND     0x03
> +#define OMAP44XX_SAR_BOOT_ONENAND  0x04
> +#define OMAP44XX_SAR_BOOT_MMC1     0x05
> +#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
> +#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
> +#define OMAP44XX_SAR_BOOT_UART     0x43
> +#define OMAP44XX_SAR_BOOT_USB_1    0x45
> +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
> +#define OMAP44XX_SAR_BOOT_USB_2    0x47
> +
> +/*
>   * Non-secure SRAM Addresses
>   * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
>   * at 0x40304000(EMU base) so that our code works for both EMU and GP
> @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
>  void omap4_power_i2c_send(u32);
>  unsigned int omap4_revision(void);
>  noinline int omap4_scale_vcores(unsigned vsel0_pin);
> +void omap4_set_warmboot_order(u32 *device_list);
>  
>  #endif
>  
> diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
> index 2a09eb6..e062332 100644
> --- a/arch/arm/mach-omap/omap4_generic.c
> +++ b/arch/arm/mach-omap/omap4_generic.c
> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
>  	while (1);
>  }
>  
> +void omap4_set_warmboot_order(u32 *device_list)
> +{
> +	const u32 CH[] = {
> +		0xCF00AA01,
> +		0x0000000C,
> +		(device_list[0] << 16) | 0x0000,
> +		(device_list[2] << 16) | device_list[1],
> +		0x0000 | device_list[3],
> +		0x00000000,
> +		0x00000000,
> +		0x00000000,
> +		0x00000000
> +	};
> +	int i;
> +
> +	for (i = 0; i < ARRAY_SIZE(CH); i++)
> +		writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
> +	writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
> +}
> +
>  #define WATCHDOG_WSPR	0x48
>  #define WATCHDOG_WWPS	0x34
>  
> diff --git a/commands/Kconfig b/commands/Kconfig
> index 0062758..524f00e 100644
> --- a/commands/Kconfig
> +++ b/commands/Kconfig
> @@ -474,6 +474,11 @@ config CMD_POWEROFF
>  	depends on HAS_POWEROFF
>  	prompt "poweroff"
>  
> +config CMD_BOOT_ORDER
> +	tristate
> +	depends on ARCH_OMAP4
> +	prompt "boot_order"
> +
>  config CMD_GO
>  	tristate
>  	prompt "go"
> diff --git a/commands/Makefile b/commands/Makefile
> index 0ae6b95..428da57 100644
> --- a/commands/Makefile
> +++ b/commands/Makefile
> @@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
>  obj-$(CONFIG_CMD_MSLEEP)	+= msleep.o
>  obj-$(CONFIG_CMD_RESET)		+= reset.o
>  obj-$(CONFIG_CMD_POWEROFF)	+= poweroff.o
> +obj-$(CONFIG_CMD_BOOT_ORDER)	+= boot_order.o
>  obj-$(CONFIG_CMD_GO)		+= go.o
>  obj-$(CONFIG_NET)		+= net.o
>  obj-$(CONFIG_CMD_PARTITION)	+= partition.o
> diff --git a/commands/boot_order.c b/commands/boot_order.c
> new file mode 100644
> index 0000000..1c31c16
> --- /dev/null
> +++ b/commands/boot_order.c
> @@ -0,0 +1,88 @@
> +/*
> + * boot_order.c - configure omap warm boot
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation.
> + *
> + * 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.
> + *
> + */
> +
> +#include <common.h>
> +#include <command.h>
> +#include <complete.h>
> +#include <getopt.h>
> +#include <mach/omap4-silicon.h>
> +
> +struct bootsrc {
> +	const char *name;
> +	uint32_t sar;
> +};
> +
> +static int cmd_boot_order(int argc, char *argv[])
> +{
> +	const struct bootsrc src_list[] = {
> +		{"xip"     , OMAP44XX_SAR_BOOT_XIP     },
> +		{"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
> +		{"nand"    , OMAP44XX_SAR_BOOT_NAND    },
> +		{"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
> +		{"mmc1"    , OMAP44XX_SAR_BOOT_MMC1    },
> +		{"mmc2_1"  , OMAP44XX_SAR_BOOT_MMC2_1  },
> +		{"mmc2_2"  , OMAP44XX_SAR_BOOT_MMC2_2  },
> +		{"uart"    , OMAP44XX_SAR_BOOT_UART    },
> +		{"usb_1"   , OMAP44XX_SAR_BOOT_USB_1   },
> +		{"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
> +		{"usb_2"   , OMAP44XX_SAR_BOOT_USB_2   },
> +	};
> +	uint32_t device_list[] = {
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +	};
> +	int i, j, opt, do_reset = 0;
> +
> +	while ((opt = getopt(argc, argv, "r")) > 0) {
> +		switch (opt) {
> +		case 'r':
> +			do_reset = 1;
> +			break;
> +		}
> +	}
> +	for (i = 0; i + optind < argc && i < ARRAY_SIZE(device_list); i++) {
> +		for (j = 0; j < ARRAY_SIZE(src_list); j++) {
> +			if (strcmp(argv[i + optind], src_list[j].name) == 0) {
> +				device_list[i] = src_list[j].sar;
> +				break;
> +			}
> +		}
> +	}
> +	if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
> +		printf("First boot device can't be void\n");
> +		return COMMAND_ERROR_USAGE;
> +	}
> +	omap4_set_warmboot_order(device_list);
> +	if (do_reset) {
> +		shutdown_barebox();
> +		reset_cpu(0);
> +	}

Same question again: Do you really need to resemble the same
functionality what the reset command does here? Why not simply
call reset after this command?

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-12 17:51   ` Sascha Hauer
@ 2013-03-12 20:20     ` vj
  2013-03-12 21:20       ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: vj @ 2013-03-12 20:20 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Tue, Mar 12, 2013 at 6:51 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Tue, Mar 12, 2013 at 01:01:24AM +0100, Vicente Bergas wrote:
>> getopt: done as suggested
>> bootsrc: done as suggested
>>
>> IMO this command will be used 99% of the times followed by a reset.
>> The -r option will avoid the burden of executing always the same two commands.
>>
>> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
>> ---
>>  arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
>>  arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
>>  commands/Kconfig                                |  5 ++
>>  commands/Makefile                               |  1 +
>>  commands/boot_order.c                           | 88 +++++++++++++++++++++++++
>>  5 files changed, 134 insertions(+)
>>  create mode 100644 commands/boot_order.c
>>
>> diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> index 9e82435..7e67abc 100644
>> --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> @@ -161,6 +161,25 @@
>>  #define OMAP44XX_PRM_RSTCTRL_RESET   0x01
>>
>>  /*
>> + * SAR (Save & Rescue) memory region
>> + */
>> +#define OMAP44XX_SAR_RAM_BASE      0x4a326000
>> +#define OMAP44XX_SAR_CH_ADDRESS    (OMAP44XX_SAR_RAM_BASE + 0xA00)
>> +#define OMAP44XX_SAR_CH_START      (OMAP44XX_SAR_RAM_BASE + 0xA0C)
>> +#define OMAP44XX_SAR_BOOT_VOID     0x00
>> +#define OMAP44XX_SAR_BOOT_XIP      0x01
>> +#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
>> +#define OMAP44XX_SAR_BOOT_NAND     0x03
>> +#define OMAP44XX_SAR_BOOT_ONENAND  0x04
>> +#define OMAP44XX_SAR_BOOT_MMC1     0x05
>> +#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
>> +#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
>> +#define OMAP44XX_SAR_BOOT_UART     0x43
>> +#define OMAP44XX_SAR_BOOT_USB_1    0x45
>> +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
>> +#define OMAP44XX_SAR_BOOT_USB_2    0x47
>> +
>> +/*
>>   * Non-secure SRAM Addresses
>>   * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
>>   * at 0x40304000(EMU base) so that our code works for both EMU and GP
>> @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
>>  void omap4_power_i2c_send(u32);
>>  unsigned int omap4_revision(void);
>>  noinline int omap4_scale_vcores(unsigned vsel0_pin);
>> +void omap4_set_warmboot_order(u32 *device_list);
>>
>>  #endif
>>
>> diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
>> index 2a09eb6..e062332 100644
>> --- a/arch/arm/mach-omap/omap4_generic.c
>> +++ b/arch/arm/mach-omap/omap4_generic.c
>> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
>>       while (1);
>>  }
>>
>> +void omap4_set_warmboot_order(u32 *device_list)
>> +{
>> +     const u32 CH[] = {
>> +             0xCF00AA01,
>> +             0x0000000C,
>> +             (device_list[0] << 16) | 0x0000,
>> +             (device_list[2] << 16) | device_list[1],
>> +             0x0000 | device_list[3],
>> +             0x00000000,
>> +             0x00000000,
>> +             0x00000000,
>> +             0x00000000
>> +     };
>> +     int i;
>> +
>> +     for (i = 0; i < ARRAY_SIZE(CH); i++)
>> +             writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
>> +     writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
>> +}
>> +
>>  #define WATCHDOG_WSPR        0x48
>>  #define WATCHDOG_WWPS        0x34
>>
>> diff --git a/commands/Kconfig b/commands/Kconfig
>> index 0062758..524f00e 100644
>> --- a/commands/Kconfig
>> +++ b/commands/Kconfig
>> @@ -474,6 +474,11 @@ config CMD_POWEROFF
>>       depends on HAS_POWEROFF
>>       prompt "poweroff"
>>
>> +config CMD_BOOT_ORDER
>> +     tristate
>> +     depends on ARCH_OMAP4
>> +     prompt "boot_order"
>> +
>>  config CMD_GO
>>       tristate
>>       prompt "go"
>> diff --git a/commands/Makefile b/commands/Makefile
>> index 0ae6b95..428da57 100644
>> --- a/commands/Makefile
>> +++ b/commands/Makefile
>> @@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)             += sleep.o
>>  obj-$(CONFIG_CMD_MSLEEP)     += msleep.o
>>  obj-$(CONFIG_CMD_RESET)              += reset.o
>>  obj-$(CONFIG_CMD_POWEROFF)   += poweroff.o
>> +obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o
>>  obj-$(CONFIG_CMD_GO)         += go.o
>>  obj-$(CONFIG_NET)            += net.o
>>  obj-$(CONFIG_CMD_PARTITION)  += partition.o
>> diff --git a/commands/boot_order.c b/commands/boot_order.c
>> new file mode 100644
>> index 0000000..1c31c16
>> --- /dev/null
>> +++ b/commands/boot_order.c
>> @@ -0,0 +1,88 @@
>> +/*
>> + * boot_order.c - configure omap warm boot
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2
>> + * as published by the Free Software Foundation.
>> + *
>> + * 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.
>> + *
>> + */
>> +
>> +#include <common.h>
>> +#include <command.h>
>> +#include <complete.h>
>> +#include <getopt.h>
>> +#include <mach/omap4-silicon.h>
>> +
>> +struct bootsrc {
>> +     const char *name;
>> +     uint32_t sar;
>> +};
>> +
>> +static int cmd_boot_order(int argc, char *argv[])
>> +{
>> +     const struct bootsrc src_list[] = {
>> +             {"xip"     , OMAP44XX_SAR_BOOT_XIP     },
>> +             {"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
>> +             {"nand"    , OMAP44XX_SAR_BOOT_NAND    },
>> +             {"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
>> +             {"mmc1"    , OMAP44XX_SAR_BOOT_MMC1    },
>> +             {"mmc2_1"  , OMAP44XX_SAR_BOOT_MMC2_1  },
>> +             {"mmc2_2"  , OMAP44XX_SAR_BOOT_MMC2_2  },
>> +             {"uart"    , OMAP44XX_SAR_BOOT_UART    },
>> +             {"usb_1"   , OMAP44XX_SAR_BOOT_USB_1   },
>> +             {"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
>> +             {"usb_2"   , OMAP44XX_SAR_BOOT_USB_2   },
>> +     };
>> +     uint32_t device_list[] = {
>> +             OMAP44XX_SAR_BOOT_VOID,
>> +             OMAP44XX_SAR_BOOT_VOID,
>> +             OMAP44XX_SAR_BOOT_VOID,
>> +             OMAP44XX_SAR_BOOT_VOID,
>> +     };
>> +     int i, j, opt, do_reset = 0;
>> +
>> +     while ((opt = getopt(argc, argv, "r")) > 0) {
>> +             switch (opt) {
>> +             case 'r':
>> +                     do_reset = 1;
>> +                     break;
>> +             }
>> +     }
>> +     for (i = 0; i + optind < argc && i < ARRAY_SIZE(device_list); i++) {
>> +             for (j = 0; j < ARRAY_SIZE(src_list); j++) {
>> +                     if (strcmp(argv[i + optind], src_list[j].name) == 0) {
>> +                             device_list[i] = src_list[j].sar;
>> +                             break;
>> +                     }
>> +             }
>> +     }
>> +     if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
>> +             printf("First boot device can't be void\n");
>> +             return COMMAND_ERROR_USAGE;
>> +     }
>> +     omap4_set_warmboot_order(device_list);
>> +     if (do_reset) {
>> +             shutdown_barebox();
>> +             reset_cpu(0);
>> +     }
>
> Same question again: Do you really need to resemble the same
> functionality what the reset command does here? Why not simply
> call reset after this command?
>
> Sascha
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

What do you mean? calling the reset command from this function or from
the prompt?

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-12 20:20     ` vj
@ 2013-03-12 21:20       ` Sascha Hauer
  2013-03-12 23:07         ` vj
  0 siblings, 1 reply; 9+ messages in thread
From: Sascha Hauer @ 2013-03-12 21:20 UTC (permalink / raw)
  To: vj; +Cc: barebox

On Tue, Mar 12, 2013 at 09:20:11PM +0100, vj wrote:
> On Tue, Mar 12, 2013 at 6:51 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> > On Tue, Mar 12, 2013 at 01:01:24AM +0100, Vicente Bergas wrote:
> >> getopt: done as suggested
> >> bootsrc: done as suggested
> >>
> >> IMO this command will be used 99% of the times followed by a reset.
> >> The -r option will avoid the burden of executing always the same two commands.
> >>
> >> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
> >> ---
> >>  arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
> >>  arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
> >>  commands/Kconfig                                |  5 ++
> >>  commands/Makefile                               |  1 +
> >>  commands/boot_order.c                           | 88 +++++++++++++++++++++++++
> >>  5 files changed, 134 insertions(+)
> >>  create mode 100644 commands/boot_order.c
> >>
> >> diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
> >> index 9e82435..7e67abc 100644
> >> --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
> >> +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
> >> @@ -161,6 +161,25 @@
> >>  #define OMAP44XX_PRM_RSTCTRL_RESET   0x01
> >>
> >>  /*
> >> + * SAR (Save & Rescue) memory region
> >> + */
> >> +#define OMAP44XX_SAR_RAM_BASE      0x4a326000
> >> +#define OMAP44XX_SAR_CH_ADDRESS    (OMAP44XX_SAR_RAM_BASE + 0xA00)
> >> +#define OMAP44XX_SAR_CH_START      (OMAP44XX_SAR_RAM_BASE + 0xA0C)
> >> +#define OMAP44XX_SAR_BOOT_VOID     0x00
> >> +#define OMAP44XX_SAR_BOOT_XIP      0x01
> >> +#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
> >> +#define OMAP44XX_SAR_BOOT_NAND     0x03
> >> +#define OMAP44XX_SAR_BOOT_ONENAND  0x04
> >> +#define OMAP44XX_SAR_BOOT_MMC1     0x05
> >> +#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
> >> +#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
> >> +#define OMAP44XX_SAR_BOOT_UART     0x43
> >> +#define OMAP44XX_SAR_BOOT_USB_1    0x45
> >> +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
> >> +#define OMAP44XX_SAR_BOOT_USB_2    0x47
> >> +
> >> +/*
> >>   * Non-secure SRAM Addresses
> >>   * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
> >>   * at 0x40304000(EMU base) so that our code works for both EMU and GP
> >> @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
> >>  void omap4_power_i2c_send(u32);
> >>  unsigned int omap4_revision(void);
> >>  noinline int omap4_scale_vcores(unsigned vsel0_pin);
> >> +void omap4_set_warmboot_order(u32 *device_list);
> >>
> >>  #endif
> >>
> >> diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
> >> index 2a09eb6..e062332 100644
> >> --- a/arch/arm/mach-omap/omap4_generic.c
> >> +++ b/arch/arm/mach-omap/omap4_generic.c
> >> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
> >>       while (1);
> >>  }
> >>
> >> +void omap4_set_warmboot_order(u32 *device_list)
> >> +{
> >> +     const u32 CH[] = {
> >> +             0xCF00AA01,
> >> +             0x0000000C,
> >> +             (device_list[0] << 16) | 0x0000,
> >> +             (device_list[2] << 16) | device_list[1],
> >> +             0x0000 | device_list[3],
> >> +             0x00000000,
> >> +             0x00000000,
> >> +             0x00000000,
> >> +             0x00000000
> >> +     };
> >> +     int i;
> >> +
> >> +     for (i = 0; i < ARRAY_SIZE(CH); i++)
> >> +             writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
> >> +     writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
> >> +}
> >> +
> >>  #define WATCHDOG_WSPR        0x48
> >>  #define WATCHDOG_WWPS        0x34
> >>
> >> diff --git a/commands/Kconfig b/commands/Kconfig
> >> index 0062758..524f00e 100644
> >> --- a/commands/Kconfig
> >> +++ b/commands/Kconfig
> >> @@ -474,6 +474,11 @@ config CMD_POWEROFF
> >>       depends on HAS_POWEROFF
> >>       prompt "poweroff"
> >>
> >> +config CMD_BOOT_ORDER
> >> +     tristate
> >> +     depends on ARCH_OMAP4
> >> +     prompt "boot_order"
> >> +
> >>  config CMD_GO
> >>       tristate
> >>       prompt "go"
> >> diff --git a/commands/Makefile b/commands/Makefile
> >> index 0ae6b95..428da57 100644
> >> --- a/commands/Makefile
> >> +++ b/commands/Makefile
> >> @@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)             += sleep.o
> >>  obj-$(CONFIG_CMD_MSLEEP)     += msleep.o
> >>  obj-$(CONFIG_CMD_RESET)              += reset.o
> >>  obj-$(CONFIG_CMD_POWEROFF)   += poweroff.o
> >> +obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o
> >>  obj-$(CONFIG_CMD_GO)         += go.o
> >>  obj-$(CONFIG_NET)            += net.o
> >>  obj-$(CONFIG_CMD_PARTITION)  += partition.o
> >> diff --git a/commands/boot_order.c b/commands/boot_order.c
> >> new file mode 100644
> >> index 0000000..1c31c16
> >> --- /dev/null
> >> +++ b/commands/boot_order.c
> >> @@ -0,0 +1,88 @@
> >> +/*
> >> + * boot_order.c - configure omap warm boot
> >> + *
> >> + * This program is free software; you can redistribute it and/or modify
> >> + * it under the terms of the GNU General Public License version 2
> >> + * as published by the Free Software Foundation.
> >> + *
> >> + * 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.
> >> + *
> >> + */
> >> +
> >> +#include <common.h>
> >> +#include <command.h>
> >> +#include <complete.h>
> >> +#include <getopt.h>
> >> +#include <mach/omap4-silicon.h>
> >> +
> >> +struct bootsrc {
> >> +     const char *name;
> >> +     uint32_t sar;
> >> +};
> >> +
> >> +static int cmd_boot_order(int argc, char *argv[])
> >> +{
> >> +     const struct bootsrc src_list[] = {
> >> +             {"xip"     , OMAP44XX_SAR_BOOT_XIP     },
> >> +             {"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
> >> +             {"nand"    , OMAP44XX_SAR_BOOT_NAND    },
> >> +             {"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
> >> +             {"mmc1"    , OMAP44XX_SAR_BOOT_MMC1    },
> >> +             {"mmc2_1"  , OMAP44XX_SAR_BOOT_MMC2_1  },
> >> +             {"mmc2_2"  , OMAP44XX_SAR_BOOT_MMC2_2  },
> >> +             {"uart"    , OMAP44XX_SAR_BOOT_UART    },
> >> +             {"usb_1"   , OMAP44XX_SAR_BOOT_USB_1   },
> >> +             {"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
> >> +             {"usb_2"   , OMAP44XX_SAR_BOOT_USB_2   },
> >> +     };
> >> +     uint32_t device_list[] = {
> >> +             OMAP44XX_SAR_BOOT_VOID,
> >> +             OMAP44XX_SAR_BOOT_VOID,
> >> +             OMAP44XX_SAR_BOOT_VOID,
> >> +             OMAP44XX_SAR_BOOT_VOID,
> >> +     };
> >> +     int i, j, opt, do_reset = 0;
> >> +
> >> +     while ((opt = getopt(argc, argv, "r")) > 0) {
> >> +             switch (opt) {
> >> +             case 'r':
> >> +                     do_reset = 1;
> >> +                     break;
> >> +             }
> >> +     }
> >> +     for (i = 0; i + optind < argc && i < ARRAY_SIZE(device_list); i++) {
> >> +             for (j = 0; j < ARRAY_SIZE(src_list); j++) {
> >> +                     if (strcmp(argv[i + optind], src_list[j].name) == 0) {
> >> +                             device_list[i] = src_list[j].sar;
> >> +                             break;
> >> +                     }
> >> +             }
> >> +     }
> >> +     if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
> >> +             printf("First boot device can't be void\n");
> >> +             return COMMAND_ERROR_USAGE;
> >> +     }
> >> +     omap4_set_warmboot_order(device_list);
> >> +     if (do_reset) {
> >> +             shutdown_barebox();
> >> +             reset_cpu(0);
> >> +     }
> >
> > Same question again: Do you really need to resemble the same
> > functionality what the reset command does here? Why not simply
> > call reset after this command?
> >
> > Sascha
> >
> > --
> > Pengutronix e.K.                           |                             |
> > Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> > Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
> 
> What do you mean? calling the reset command from this function or from
> the prompt?

From the prompt.

Sascha


-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-12 21:20       ` Sascha Hauer
@ 2013-03-12 23:07         ` vj
  0 siblings, 0 replies; 9+ messages in thread
From: vj @ 2013-03-12 23:07 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On Tue, Mar 12, 2013 at 10:20 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Tue, Mar 12, 2013 at 09:20:11PM +0100, vj wrote:
>> On Tue, Mar 12, 2013 at 6:51 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
>> > On Tue, Mar 12, 2013 at 01:01:24AM +0100, Vicente Bergas wrote:
>> >> getopt: done as suggested
>> >> bootsrc: done as suggested
>> >>
>> >> IMO this command will be used 99% of the times followed by a reset.
>> >> The -r option will avoid the burden of executing always the same two commands.
>> >>
>> >> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
>> >> ---
>> >>  arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
>> >>  arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
>> >>  commands/Kconfig                                |  5 ++
>> >>  commands/Makefile                               |  1 +
>> >>  commands/boot_order.c                           | 88 +++++++++++++++++++++++++
>> >>  5 files changed, 134 insertions(+)
>> >>  create mode 100644 commands/boot_order.c
>> >>
>> >> diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> >> index 9e82435..7e67abc 100644
>> >> --- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> >> +++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
>> >> @@ -161,6 +161,25 @@
>> >>  #define OMAP44XX_PRM_RSTCTRL_RESET   0x01
>> >>
>> >>  /*
>> >> + * SAR (Save & Rescue) memory region
>> >> + */
>> >> +#define OMAP44XX_SAR_RAM_BASE      0x4a326000
>> >> +#define OMAP44XX_SAR_CH_ADDRESS    (OMAP44XX_SAR_RAM_BASE + 0xA00)
>> >> +#define OMAP44XX_SAR_CH_START      (OMAP44XX_SAR_RAM_BASE + 0xA0C)
>> >> +#define OMAP44XX_SAR_BOOT_VOID     0x00
>> >> +#define OMAP44XX_SAR_BOOT_XIP      0x01
>> >> +#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
>> >> +#define OMAP44XX_SAR_BOOT_NAND     0x03
>> >> +#define OMAP44XX_SAR_BOOT_ONENAND  0x04
>> >> +#define OMAP44XX_SAR_BOOT_MMC1     0x05
>> >> +#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
>> >> +#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
>> >> +#define OMAP44XX_SAR_BOOT_UART     0x43
>> >> +#define OMAP44XX_SAR_BOOT_USB_1    0x45
>> >> +#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
>> >> +#define OMAP44XX_SAR_BOOT_USB_2    0x47
>> >> +
>> >> +/*
>> >>   * Non-secure SRAM Addresses
>> >>   * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
>> >>   * at 0x40304000(EMU base) so that our code works for both EMU and GP
>> >> @@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
>> >>  void omap4_power_i2c_send(u32);
>> >>  unsigned int omap4_revision(void);
>> >>  noinline int omap4_scale_vcores(unsigned vsel0_pin);
>> >> +void omap4_set_warmboot_order(u32 *device_list);
>> >>
>> >>  #endif
>> >>
>> >> diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
>> >> index 2a09eb6..e062332 100644
>> >> --- a/arch/arm/mach-omap/omap4_generic.c
>> >> +++ b/arch/arm/mach-omap/omap4_generic.c
>> >> @@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
>> >>       while (1);
>> >>  }
>> >>
>> >> +void omap4_set_warmboot_order(u32 *device_list)
>> >> +{
>> >> +     const u32 CH[] = {
>> >> +             0xCF00AA01,
>> >> +             0x0000000C,
>> >> +             (device_list[0] << 16) | 0x0000,
>> >> +             (device_list[2] << 16) | device_list[1],
>> >> +             0x0000 | device_list[3],
>> >> +             0x00000000,
>> >> +             0x00000000,
>> >> +             0x00000000,
>> >> +             0x00000000
>> >> +     };
>> >> +     int i;
>> >> +
>> >> +     for (i = 0; i < ARRAY_SIZE(CH); i++)
>> >> +             writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
>> >> +     writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
>> >> +}
>> >> +
>> >>  #define WATCHDOG_WSPR        0x48
>> >>  #define WATCHDOG_WWPS        0x34
>> >>
>> >> diff --git a/commands/Kconfig b/commands/Kconfig
>> >> index 0062758..524f00e 100644
>> >> --- a/commands/Kconfig
>> >> +++ b/commands/Kconfig
>> >> @@ -474,6 +474,11 @@ config CMD_POWEROFF
>> >>       depends on HAS_POWEROFF
>> >>       prompt "poweroff"
>> >>
>> >> +config CMD_BOOT_ORDER
>> >> +     tristate
>> >> +     depends on ARCH_OMAP4
>> >> +     prompt "boot_order"
>> >> +
>> >>  config CMD_GO
>> >>       tristate
>> >>       prompt "go"
>> >> diff --git a/commands/Makefile b/commands/Makefile
>> >> index 0ae6b95..428da57 100644
>> >> --- a/commands/Makefile
>> >> +++ b/commands/Makefile
>> >> @@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)             += sleep.o
>> >>  obj-$(CONFIG_CMD_MSLEEP)     += msleep.o
>> >>  obj-$(CONFIG_CMD_RESET)              += reset.o
>> >>  obj-$(CONFIG_CMD_POWEROFF)   += poweroff.o
>> >> +obj-$(CONFIG_CMD_BOOT_ORDER) += boot_order.o
>> >>  obj-$(CONFIG_CMD_GO)         += go.o
>> >>  obj-$(CONFIG_NET)            += net.o
>> >>  obj-$(CONFIG_CMD_PARTITION)  += partition.o
>> >> diff --git a/commands/boot_order.c b/commands/boot_order.c
>> >> new file mode 100644
>> >> index 0000000..1c31c16
>> >> --- /dev/null
>> >> +++ b/commands/boot_order.c
>> >> @@ -0,0 +1,88 @@
>> >> +/*
>> >> + * boot_order.c - configure omap warm boot
>> >> + *
>> >> + * This program is free software; you can redistribute it and/or modify
>> >> + * it under the terms of the GNU General Public License version 2
>> >> + * as published by the Free Software Foundation.
>> >> + *
>> >> + * 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.
>> >> + *
>> >> + */
>> >> +
>> >> +#include <common.h>
>> >> +#include <command.h>
>> >> +#include <complete.h>
>> >> +#include <getopt.h>
>> >> +#include <mach/omap4-silicon.h>
>> >> +
>> >> +struct bootsrc {
>> >> +     const char *name;
>> >> +     uint32_t sar;
>> >> +};
>> >> +
>> >> +static int cmd_boot_order(int argc, char *argv[])
>> >> +{
>> >> +     const struct bootsrc src_list[] = {
>> >> +             {"xip"     , OMAP44XX_SAR_BOOT_XIP     },
>> >> +             {"xipwait" , OMAP44XX_SAR_BOOT_XIPWAIT },
>> >> +             {"nand"    , OMAP44XX_SAR_BOOT_NAND    },
>> >> +             {"onenand" , OMAP44XX_SAR_BOOT_ONENAND },
>> >> +             {"mmc1"    , OMAP44XX_SAR_BOOT_MMC1    },
>> >> +             {"mmc2_1"  , OMAP44XX_SAR_BOOT_MMC2_1  },
>> >> +             {"mmc2_2"  , OMAP44XX_SAR_BOOT_MMC2_2  },
>> >> +             {"uart"    , OMAP44XX_SAR_BOOT_UART    },
>> >> +             {"usb_1"   , OMAP44XX_SAR_BOOT_USB_1   },
>> >> +             {"usb_ulpi", OMAP44XX_SAR_BOOT_USB_ULPI},
>> >> +             {"usb_2"   , OMAP44XX_SAR_BOOT_USB_2   },
>> >> +     };
>> >> +     uint32_t device_list[] = {
>> >> +             OMAP44XX_SAR_BOOT_VOID,
>> >> +             OMAP44XX_SAR_BOOT_VOID,
>> >> +             OMAP44XX_SAR_BOOT_VOID,
>> >> +             OMAP44XX_SAR_BOOT_VOID,
>> >> +     };
>> >> +     int i, j, opt, do_reset = 0;
>> >> +
>> >> +     while ((opt = getopt(argc, argv, "r")) > 0) {
>> >> +             switch (opt) {
>> >> +             case 'r':
>> >> +                     do_reset = 1;
>> >> +                     break;
>> >> +             }
>> >> +     }
>> >> +     for (i = 0; i + optind < argc && i < ARRAY_SIZE(device_list); i++) {
>> >> +             for (j = 0; j < ARRAY_SIZE(src_list); j++) {
>> >> +                     if (strcmp(argv[i + optind], src_list[j].name) == 0) {
>> >> +                             device_list[i] = src_list[j].sar;
>> >> +                             break;
>> >> +                     }
>> >> +             }
>> >> +     }
>> >> +     if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
>> >> +             printf("First boot device can't be void\n");
>> >> +             return COMMAND_ERROR_USAGE;
>> >> +     }
>> >> +     omap4_set_warmboot_order(device_list);
>> >> +     if (do_reset) {
>> >> +             shutdown_barebox();
>> >> +             reset_cpu(0);
>> >> +     }
>> >
>> > Same question again: Do you really need to resemble the same
>> > functionality what the reset command does here? Why not simply
>> > call reset after this command?
>> >
>> > Sascha
>> >
>> > --
>> > Pengutronix e.K.                           |                             |
>> > Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>> > Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
>> > Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
>>
>> What do you mean? calling the reset command from this function or from
>> the prompt?
>
> From the prompt.
>
> Sascha
>
>
> --
> Pengutronix e.K.                           |                             |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
> Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

IMO this command will be used 99% of the times followed by a reset.
The -r option will avoid the burden of executing always the same two
commands to the user.
Strictly speaking there is no need to resemble the same functionality,
but if you insist i'll submit a new patch without the '-r' option.

Regards,
  Vicente.

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-10 23:36 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
@ 2013-03-11 21:42   ` Sascha Hauer
  0 siblings, 0 replies; 9+ messages in thread
From: Sascha Hauer @ 2013-03-11 21:42 UTC (permalink / raw)
  To: Vicente Bergas; +Cc: barebox

On Mon, Mar 11, 2013 at 12:36:06AM +0100, Vicente Bergas wrote:
> On OMAP4 SoC there is a SAR memory region (Save & Rescue) where the ROM
> code reads the device to boot from.
> This patch adds a way to set this.
> 
> Signed-off-by: Vicente Bergas <vicencb@gmail.com>
> ---
>  arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
>  arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
>  commands/Kconfig                                |  5 ++
>  commands/Makefile                               |  1 +
>  commands/boot_order.c                           | 83 +++++++++++++++++++++++++
>  5 files changed, 129 insertions(+)
>  create mode 100644 commands/boot_order.c
> 
> +static int cmd_boot_order(int argc, char *argv[])
> +{
> +	u32 device_list[] = {
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +		OMAP44XX_SAR_BOOT_VOID,
> +	};
> +	int i, j = 1, do_reset = 0;
> +
> +	if (argc > 1 && strcmp(argv[1], "-r") == 0) {
> +		do_reset = 1;
> +		j = 2;
> +	}

You should use getopt() to parse options.

> +	for (i = 0; i < 4 && j < argc; i++, j++) {
> +		if      (strcmp(argv[j], "xip") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_XIP;
> +		else if (strcmp(argv[j], "xipwait") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_XIPWAIT;
> +		else if (strcmp(argv[j], "nand") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_NAND;
> +		else if (strcmp(argv[j], "onenand") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_ONENAND;
> +		else if (strcmp(argv[j], "mmc1") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_MMC1;
> +		else if (strcmp(argv[j], "mmc2_1") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_MMC2_1;
> +		else if (strcmp(argv[j], "mmc2_2") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_MMC2_2;
> +		else if (strcmp(argv[j], "uart") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_UART;
> +		else if (strcmp(argv[j], "usb_1") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_USB_1;
> +		else if (strcmp(argv[j], "usb_ulpi") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_USB_ULPI;
> +		else if (strcmp(argv[j], "usb_2") == 0)
> +			device_list[i] = OMAP44XX_SAR_BOOT_USB_2;

You could add a table for this, something like

struct bootsrc {
	const char *name;
	uint32_t sar;
};

> +	}
> +	if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
> +		printf("First boot device can't be void\n");
> +		return COMMAND_ERROR_USAGE;
> +	}
> +	omap4_set_warmboot_order(device_list);
> +	if (do_reset) {
> +		shutdown_barebox();
> +		reset_cpu(0);
> +	}

Why is this done here? I mean you could execute the reset command after
this one.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 3/4] OMAP4: add command to select next boot device priority
  2013-03-10 23:36 [PATCH 0/4] ArchosG9: add keyboard input and new reset menu entries Vicente Bergas
@ 2013-03-10 23:36 ` Vicente Bergas
  2013-03-11 21:42   ` Sascha Hauer
  0 siblings, 1 reply; 9+ messages in thread
From: Vicente Bergas @ 2013-03-10 23:36 UTC (permalink / raw)
  To: barebox; +Cc: Vicente Bergas

On OMAP4 SoC there is a SAR memory region (Save & Rescue) where the ROM
code reads the device to boot from.
This patch adds a way to set this.

Signed-off-by: Vicente Bergas <vicencb@gmail.com>
---
 arch/arm/mach-omap/include/mach/omap4-silicon.h | 20 ++++++
 arch/arm/mach-omap/omap4_generic.c              | 20 ++++++
 commands/Kconfig                                |  5 ++
 commands/Makefile                               |  1 +
 commands/boot_order.c                           | 83 +++++++++++++++++++++++++
 5 files changed, 129 insertions(+)
 create mode 100644 commands/boot_order.c

diff --git a/arch/arm/mach-omap/include/mach/omap4-silicon.h b/arch/arm/mach-omap/include/mach/omap4-silicon.h
index 9e82435..7e67abc 100644
--- a/arch/arm/mach-omap/include/mach/omap4-silicon.h
+++ b/arch/arm/mach-omap/include/mach/omap4-silicon.h
@@ -161,6 +161,25 @@
 #define OMAP44XX_PRM_RSTCTRL_RESET	0x01
 
 /*
+ * SAR (Save & Rescue) memory region
+ */
+#define OMAP44XX_SAR_RAM_BASE      0x4a326000
+#define OMAP44XX_SAR_CH_ADDRESS	   (OMAP44XX_SAR_RAM_BASE + 0xA00)
+#define OMAP44XX_SAR_CH_START	   (OMAP44XX_SAR_RAM_BASE + 0xA0C)
+#define OMAP44XX_SAR_BOOT_VOID     0x00
+#define OMAP44XX_SAR_BOOT_XIP      0x01
+#define OMAP44XX_SAR_BOOT_XIPWAIT  0x02
+#define OMAP44XX_SAR_BOOT_NAND     0x03
+#define OMAP44XX_SAR_BOOT_ONENAND  0x04
+#define OMAP44XX_SAR_BOOT_MMC1     0x05
+#define OMAP44XX_SAR_BOOT_MMC2_1   0x06
+#define OMAP44XX_SAR_BOOT_MMC2_2   0x07
+#define OMAP44XX_SAR_BOOT_UART     0x43
+#define OMAP44XX_SAR_BOOT_USB_1    0x45
+#define OMAP44XX_SAR_BOOT_USB_ULPI 0x46
+#define OMAP44XX_SAR_BOOT_USB_2    0x47
+
+/*
  * Non-secure SRAM Addresses
  * Non-secure RAM starts at 0x40300000 for GP devices. But we keep SRAM_BASE
  * at 0x40304000(EMU base) so that our code works for both EMU and GP
@@ -212,6 +231,7 @@ void omap4_ddr_init(const struct ddr_regs *, const struct dpll_param *);
 void omap4_power_i2c_send(u32);
 unsigned int omap4_revision(void);
 noinline int omap4_scale_vcores(unsigned vsel0_pin);
+void omap4_set_warmboot_order(u32 *device_list);
 
 #endif
 
diff --git a/arch/arm/mach-omap/omap4_generic.c b/arch/arm/mach-omap/omap4_generic.c
index 2a09eb6..7f881f8 100644
--- a/arch/arm/mach-omap/omap4_generic.c
+++ b/arch/arm/mach-omap/omap4_generic.c
@@ -41,6 +41,26 @@ void __noreturn reset_cpu(unsigned long addr)
 	while (1);
 }
 
+void omap4_set_warmboot_order(u32 *device_list)
+{
+	const u32 CH[] = {
+		0xCF00AA01,
+		0x0000000C,
+		(device_list[0] << 16) | 0x0000,
+		(device_list[2] << 16) | device_list[1],
+		0x0000 | device_list[3],
+		0x00000000,
+		0x00000000,
+		0x00000000,
+		0x00000000
+	};
+	int i;
+
+	for (i = 0; i < sizeof(CH)/sizeof(CH[0]); i++)
+		writel(CH[i], OMAP44XX_SAR_CH_START + i*sizeof(CH[0]));
+	writel(OMAP44XX_SAR_CH_START, OMAP44XX_SAR_CH_ADDRESS);
+}
+
 #define WATCHDOG_WSPR	0x48
 #define WATCHDOG_WWPS	0x34
 
diff --git a/commands/Kconfig b/commands/Kconfig
index c1454c7..b4feb27 100644
--- a/commands/Kconfig
+++ b/commands/Kconfig
@@ -474,6 +474,11 @@ config CMD_POWEROFF
 	depends on HAS_POWEROFF
 	prompt "poweroff"
 
+config CMD_BOOT_ORDER
+	tristate
+	depends on ARCH_OMAP4
+	prompt "boot_order"
+
 config CMD_GO
 	tristate
 	prompt "go"
diff --git a/commands/Makefile b/commands/Makefile
index 0ae6b95..428da57 100644
--- a/commands/Makefile
+++ b/commands/Makefile
@@ -14,6 +14,7 @@ obj-$(CONFIG_CMD_SLEEP)		+= sleep.o
 obj-$(CONFIG_CMD_MSLEEP)	+= msleep.o
 obj-$(CONFIG_CMD_RESET)		+= reset.o
 obj-$(CONFIG_CMD_POWEROFF)	+= poweroff.o
+obj-$(CONFIG_CMD_BOOT_ORDER)	+= boot_order.o
 obj-$(CONFIG_CMD_GO)		+= go.o
 obj-$(CONFIG_NET)		+= net.o
 obj-$(CONFIG_CMD_PARTITION)	+= partition.o
diff --git a/commands/boot_order.c b/commands/boot_order.c
new file mode 100644
index 0000000..eb8f7b3
--- /dev/null
+++ b/commands/boot_order.c
@@ -0,0 +1,83 @@
+/*
+ * boot_order.c - configure omap warm boot
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ */
+
+#include <common.h>
+#include <command.h>
+#include <complete.h>
+#include <getopt.h>
+#include <mach/omap4-silicon.h>
+
+static int cmd_boot_order(int argc, char *argv[])
+{
+	u32 device_list[] = {
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+		OMAP44XX_SAR_BOOT_VOID,
+	};
+	int i, j = 1, do_reset = 0;
+
+	if (argc > 1 && strcmp(argv[1], "-r") == 0) {
+		do_reset = 1;
+		j = 2;
+	}
+	for (i = 0; i < 4 && j < argc; i++, j++) {
+		if      (strcmp(argv[j], "xip") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_XIP;
+		else if (strcmp(argv[j], "xipwait") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_XIPWAIT;
+		else if (strcmp(argv[j], "nand") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_NAND;
+		else if (strcmp(argv[j], "onenand") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_ONENAND;
+		else if (strcmp(argv[j], "mmc1") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_MMC1;
+		else if (strcmp(argv[j], "mmc2_1") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_MMC2_1;
+		else if (strcmp(argv[j], "mmc2_2") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_MMC2_2;
+		else if (strcmp(argv[j], "uart") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_UART;
+		else if (strcmp(argv[j], "usb_1") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_USB_1;
+		else if (strcmp(argv[j], "usb_ulpi") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_USB_ULPI;
+		else if (strcmp(argv[j], "usb_2") == 0)
+			device_list[i] = OMAP44XX_SAR_BOOT_USB_2;
+	}
+	if (device_list[0] == OMAP44XX_SAR_BOOT_VOID) {
+		printf("First boot device can't be void\n");
+		return COMMAND_ERROR_USAGE;
+	}
+	omap4_set_warmboot_order(device_list);
+	if (do_reset) {
+		shutdown_barebox();
+		reset_cpu(0);
+	}
+	return 0;
+}
+
+static const __maybe_unused char cmd_boot_order_help[] =
+"Usage: boot_order [-r] <device 1> [<device n>]\n"
+"Set warm boot order up to four devices\n"
+"and reset cpu if -r is specified.\n"
+"Each device can be one of:\n"
+"void xip xipwait nand onenand mmc1 mmc2_1 mmc2_2 uart usb_1 usb_ulpi usb_2\n";
+
+BAREBOX_CMD_START(boot_order)
+	.cmd		= cmd_boot_order,
+	.usage		= "boot_order <device 1> [<device n>]",
+	BAREBOX_CMD_HELP(cmd_boot_order_help)
+	BAREBOX_CMD_COMPLETE(empty_complete)
+BAREBOX_CMD_END
-- 
1.8.1.5


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-03-12 23:07 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-12  0:01 [PATCH 2/4] twl6030: add power button as an input key Vicente Bergas
2013-03-12  0:01 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
2013-03-12 17:51   ` Sascha Hauer
2013-03-12 20:20     ` vj
2013-03-12 21:20       ` Sascha Hauer
2013-03-12 23:07         ` vj
2013-03-12 17:48 ` [PATCH 2/4] twl6030: add power button as an input key Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2013-03-10 23:36 [PATCH 0/4] ArchosG9: add keyboard input and new reset menu entries Vicente Bergas
2013-03-10 23:36 ` [PATCH 3/4] OMAP4: add command to select next boot device priority Vicente Bergas
2013-03-11 21:42   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox