mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: mioa701: fix frequence speedup code
@ 2014-01-18 11:48 Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: pxa: add reset source detection Robert Jarzmik
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

As barebox has become the true SPL of mioa701 board (no intermediate
SPL), a bug was uncovered in the init procedure, where the CPU voltage
was to be increased by commanding the I2C voltage regulator, while the
I2C was shut down.

Fix it by unclock-gating the power I2C bus before using it.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/boards/mioa701/board.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boards/mioa701/board.c b/arch/arm/boards/mioa701/board.c
index c46b5da..7ee0be0 100644
--- a/arch/arm/boards/mioa701/board.c
+++ b/arch/arm/boards/mioa701/board.c
@@ -266,6 +266,7 @@ static int mioa701_coredevice_init(void)
 	 * This requires to command the Maxim 1586 to upgrade core voltage to
 	 * 1.475 V, on the power I2C bus (device 0x14).
 	 */
+	CKEN |= CKEN_PWRI2C;
 	CCCR = CCCR_A | 0x20290;
 	PCFR = PCFR_GPR_EN | PCFR_FVC | PCFR_DC_EN | PCFR_PI2C_EN | PCFR_OPDE;
 	PCMD(0) = PCMD_LC | 0x1f;
-- 
1.7.10.4


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

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

* [PATCH] ARM: pxa: add reset source detection
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
@ 2014-01-18 11:48 ` Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: pxa: add poweroff capability Robert Jarzmik
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

Use PXA register RCSR to detect which is the reset cause.  When
triggering a reset, clear the former reset source first.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/mach-pxa/Makefile       |    1 +
 arch/arm/mach-pxa/common.c       |    4 ++++
 arch/arm/mach-pxa/reset_source.c |   41 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 46 insertions(+)
 create mode 100644 arch/arm/mach-pxa/reset_source.c

diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 6a02a54..ddc042e 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -5,3 +5,4 @@ obj-y += devices.o
 
 obj-$(CONFIG_ARCH_PXA2XX) += mfp-pxa2xx.o
 obj-$(CONFIG_ARCH_PXA27X) += speed-pxa27x.o
+obj-$(CONFIG_RESET_SOURCE) += reset_source.o
diff --git a/arch/arm/mach-pxa/common.c b/arch/arm/mach-pxa/common.c
index 82e81b7..69ec0a7 100644
--- a/arch/arm/mach-pxa/common.c
+++ b/arch/arm/mach-pxa/common.c
@@ -16,6 +16,7 @@
  */
 
 #include <common.h>
+#include <mach/pxa-regs.h>
 #include <asm/io.h>
 
 #define OSMR3	0x40A0000C
@@ -28,6 +29,9 @@
 
 void reset_cpu(ulong addr)
 {
+	/* Clear last reset source */
+	RCSR = RCSR_GPR | RCSR_SMR | RCSR_WDR | RCSR_HWR;
+
 	/* Initialize the watchdog and let it fire */
 	writel(OWER_WME, OWER);
 	writel(OSSR_M3, OSSR);
diff --git a/arch/arm/mach-pxa/reset_source.c b/arch/arm/mach-pxa/reset_source.c
new file mode 100644
index 0000000..2b650c6
--- /dev/null
+++ b/arch/arm/mach-pxa/reset_source.c
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2014 Robert Jarzmik <robert.jarzmik@free.fr>
+ *
+ * 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 <reset_source.h>
+#include <mach/pxa-regs.h>
+
+static int pxa_detect_reset_source(void)
+{
+	u32 reg = RCSR;
+
+	/*
+	 * Order is important, as many bits can be set together
+	 */
+	if (reg & RCSR_GPR)
+		set_reset_source(RESET_RST);
+	else if (reg & RCSR_WDR)
+		set_reset_source(RESET_WDG);
+	else if (reg & RCSR_HWR)
+		set_reset_source(RESET_POR);
+	else if (reg & RCSR_SMR)
+		set_reset_source(RESET_WKE);
+	else
+		set_reset_source(RESET_UKWN);
+
+	return 0;
+}
+
+device_initcall(pxa_detect_reset_source);
-- 
1.7.10.4


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

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

* [PATCH] ARM: pxa: add poweroff capability
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: pxa: add reset source detection Robert Jarzmik
@ 2014-01-18 11:48 ` Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: mioa701 defconfig update Robert Jarzmik
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

Add the capability for the PXA architecture to poweroff.

As there is no true poweroff, ie. the power regulator is not available
for shut off from the core, the poweroff puts the SoC into a deep sleep
mode (mode 7), where almost no current is sunk.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/Kconfig                          |    1 +
 arch/arm/mach-pxa/Makefile                |    1 +
 arch/arm/mach-pxa/common.c                |   13 +++++
 arch/arm/mach-pxa/include/mach/hardware.h |    4 ++
 arch/arm/mach-pxa/sleep.S                 |   81 +++++++++++++++++++++++++++++
 5 files changed, 100 insertions(+)
 create mode 100644 arch/arm/mach-pxa/sleep.S

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 93619d5..243cfc8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -116,6 +116,7 @@ config ARCH_OMAP
 config ARCH_PXA
 	bool "Intel/Marvell PXA based"
 	select GENERIC_GPIO
+	select HAS_POWEROFF
 
 config ARCH_SOCFPGA
 	bool "Altera SOCFPGA cyclone5"
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index ddc042e..6ddb6e5 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -2,6 +2,7 @@ obj-y += clocksource.o
 obj-y += common.o
 obj-y += gpio.o
 obj-y += devices.o
+obj-y += sleep.o
 
 obj-$(CONFIG_ARCH_PXA2XX) += mfp-pxa2xx.o
 obj-$(CONFIG_ARCH_PXA27X) += speed-pxa27x.o
diff --git a/arch/arm/mach-pxa/common.c b/arch/arm/mach-pxa/common.c
index 69ec0a7..0c114ed 100644
--- a/arch/arm/mach-pxa/common.c
+++ b/arch/arm/mach-pxa/common.c
@@ -27,6 +27,8 @@
 #define OWER_WME	(1 << 0)	/* Watch-dog Match Enable */
 #define OSSR_M3		(1 << 3)	/* Match status channel 3 */
 
+extern void pxa_suspend(int mode);
+
 void reset_cpu(ulong addr)
 {
 	/* Clear last reset source */
@@ -39,3 +41,14 @@ void reset_cpu(ulong addr)
 
 	while (1);
 }
+
+void __noreturn poweroff()
+{
+	shutdown_barebox();
+
+	/* Clear last reset source */
+	RCSR = RCSR_GPR | RCSR_SMR | RCSR_WDR | RCSR_HWR;
+
+	pxa_suspend(PWRMODE_DEEPSLEEP);
+	unreachable();
+}
diff --git a/arch/arm/mach-pxa/include/mach/hardware.h b/arch/arm/mach-pxa/include/mach/hardware.h
index e53085c..c5f40d7 100644
--- a/arch/arm/mach-pxa/include/mach/hardware.h
+++ b/arch/arm/mach-pxa/include/mach/hardware.h
@@ -28,4 +28,8 @@
 #define cpu_is_pxa27x()	(0)
 #endif
 
+#ifdef __ASSEMBLY__
+#define __REG(x) (x)
+#endif
+
 #endif	/* !__MACH_HARDWARE_H */
diff --git a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S
new file mode 100644
index 0000000..881033d
--- /dev/null
+++ b/arch/arm/mach-pxa/sleep.S
@@ -0,0 +1,81 @@
+/*
+ * Low-level PXA250/210 sleep/wakeUp support
+ *
+ * Initial SA1110 code:
+ * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
+ *
+ * Adapted for PXA by Nicolas Pitre:
+ * Copyright (c) 2002 Monta Vista Software, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License.
+ */
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <mach/hardware.h>
+#include <mach/pxa2xx-regs.h>
+
+#define MDREFR_KDIV	0x200a4000	// all banks
+#define CCCR_SLEEP	0x00000107	// L=7 2N=2 A=0 PPDIS=0 CPDIS=0
+#define UNCACHED_PHYS_0	0
+		.text
+
+#ifdef CONFIG_ARCH_PXA27X
+/*
+ * pxa27x_finish_suspend()
+ *
+ * Forces CPU into sleep state.
+ *
+ * r0 = value for PWRMODE M field for desired sleep state
+ */
+ENTRY(pxa_suspend)
+	@ Put the processor to sleep
+	@ (also workaround for sighting 28071)
+
+	@ prepare value for sleep mode
+	mov	r1, r0				@ sleep mode
+
+	@ Intel PXA270 Specification Update notes problems sleeping
+	@ with core operating above 91 MHz
+	@ (see Errata 50, ...processor does not exit from sleep...)
+	ldr	r6, =CCCR
+	ldr	r8, [r6]		@ keep original value for resume
+
+	ldr	r7, =CCCR_SLEEP		@ prepare CCCR sleep value
+	mov	r0, #0x2		@ prepare value for CLKCFG
+
+	@ align execution to a cache line
+	b	pxa_cpu_do_suspend
+#endif
+
+
+	.ltorg
+	.align	5
+pxa_cpu_do_suspend:
+
+	@ All needed values are now in registers.
+	@ These last instructions should be in cache
+
+	@ initiate the frequency change...
+	str	r7, [r6]
+	mcr	p14, 0, r0, c6, c0, 0
+
+	@ restore the original cpu speed value for resume
+	str	r8, [r6]
+
+	@ need 6 13-MHz cycles before changing PWRMODE
+	@ just set frequency to 91-MHz... 6*91/13 = 42
+
+	mov	r0, #42
+10:	subs	r0, r0, #1
+	bne	10b
+
+	@ Do not reorder...
+	@ Intel PXA270 Specification Update notes problems performing
+	@ external accesses after SDRAM is put in self-refresh mode
+	@ (see Errata 39 ...hangs when entering self-refresh mode)
+
+	@ enter sleep mode
+	mcr	p14, 0, r1, c7, c0, 0		@ PWRMODE
+20:	b	20b				@ loop waiting for sleep
-- 
1.7.10.4


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

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

* [PATCH] ARM: mioa701 defconfig update
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: pxa: add reset source detection Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: pxa: add poweroff capability Robert Jarzmik
@ 2014-01-18 11:48 ` Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: mioa701 change MTD layout Robert Jarzmik
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

Update mioa701 board for new setup :
 - double the barebox size to 524288 bytes
 - add new commands
 - add device tree support, for future PXA port to devicetree
 - add reset source

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/configs/mioa701_defconfig |   49 +++++++++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 3 deletions(-)

diff --git a/arch/arm/configs/mioa701_defconfig b/arch/arm/configs/mioa701_defconfig
index 5f06b3c..841b9be 100644
--- a/arch/arm/configs/mioa701_defconfig
+++ b/arch/arm/configs/mioa701_defconfig
@@ -1,27 +1,46 @@
 CONFIG_ARCH_PXA=y
+CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x100000
 CONFIG_AEABI=y
+CONFIG_ARM_BOARD_APPEND_ATAG=y
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
 CONFIG_ARM_UNWIND=y
 # CONFIG_BANNER is not set
-CONFIG_TEXT_BASE=0xa3f00000
-CONFIG_BAREBOX_MAX_BARE_INIT_SIZE=0x262144
+CONFIG_MMU=y
+CONFIG_TEXT_BASE=0xa3d00000
+CONFIG_BAREBOX_MAX_BARE_INIT_SIZE=0x80000
 CONFIG_MALLOC_SIZE=0x1000000
 CONFIG_EXPERIMENTAL=y
+CONFIG_MODULES=y
+CONFIG_KALLSYMS=y
 CONFIG_LONGHELP=y
 CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
 CONFIG_HUSH_GETOPT=y
 CONFIG_CMDLINE_EDITING=y
 CONFIG_AUTO_COMPLETE=y
 CONFIG_MENU=y
 CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/mioa701/env"
+CONFIG_RESET_SOURCE=y
 CONFIG_DEBUG_INFO=y
 CONFIG_CMD_EDIT=y
 CONFIG_CMD_SLEEP=y
+CONFIG_CMD_MSLEEP=y
 CONFIG_CMD_SAVEENV=y
 CONFIG_CMD_EXPORT=y
 CONFIG_CMD_PRINTENV=y
 CONFIG_CMD_READLINE=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
+CONFIG_CMD_PASSWD=y
 CONFIG_CMD_TIME=y
+CONFIG_CMD_GLOBAL=y
+CONFIG_CMD_AUTOMOUNT=y
+CONFIG_CMD_BASENAME=y
+CONFIG_CMD_DIRNAME=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_READLINK=y
+CONFIG_CMD_FILETYPE=y
 CONFIG_CMD_ECHO_E=y
 CONFIG_CMD_LOADB=y
 CONFIG_CMD_LOADY=y
@@ -29,24 +48,40 @@ CONFIG_CMD_LOADS=y
 CONFIG_CMD_SAVES=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MM=y
 CONFIG_CMD_CRC=y
 CONFIG_CMD_CRC_CMP=y
 CONFIG_CMD_FLASH=y
+CONFIG_CMD_UBIFORMAT=y
 CONFIG_CMD_BOOTM_SHOW_TYPE=y
 CONFIG_CMD_BOOTM_VERBOSE=y
 CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_FLEXIBLE_BOOTARGS=y
+CONFIG_CMD_BOOT=y
 CONFIG_CMD_RESET=y
+CONFIG_CMD_POWEROFF=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_MEMTEST=y
+CONFIG_CMD_SPLASH=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_PARTITION=y
-CONFIG_CMD_SPLASH=y
+CONFIG_CMD_LSMOD=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_UNCOMPRESS=y
 CONFIG_CMD_LED=y
+CONFIG_CMD_DETECT=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_SERIAL_PXA=y
 # CONFIG_SPI is not set
 CONFIG_MTD=y
 CONFIG_MTD_RAW_DEVICE=y
 CONFIG_MTD_DOCG3=y
+CONFIG_MTD_UBI=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_SERIAL=y
 CONFIG_VIDEO=y
@@ -55,8 +90,16 @@ CONFIG_MCI=y
 CONFIG_MCI_PXA=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
+CONFIG_KEYBOARD_GPIO=y
 CONFIG_FS_CRAMFS=y
+CONFIG_FS_EXT4=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_WRITE=y
 CONFIG_FS_FAT_LFN=y
+CONFIG_FS_UBIFS=y
+CONFIG_FS_UBIFS_COMPRESSION_LZO=y
+CONFIG_FS_UBIFS_COMPRESSION_ZLIB=y
 CONFIG_BZLIB=y
+CONFIG_BMP=y
+CONFIG_PNG=y
+CONFIG_SHA256=y
-- 
1.7.10.4


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

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

* [PATCH] ARM: mioa701 change MTD layout
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
                   ` (2 preceding siblings ...)
  2014-01-18 11:48 ` [PATCH] ARM: mioa701 defconfig update Robert Jarzmik
@ 2014-01-18 11:48 ` Robert Jarzmik
  2014-01-18 11:48 ` [PATCH] ARM: mioa701: poweroff the board on long power press Robert Jarzmik
  2014-01-20 15:38 ` [PATCH] ARM: mioa701: fix frequence speedup code Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

As barebox has grown up in size, because UBI support is now embedded in
barebox, and because the IPL is at least rewritten to be fully GPL,
modify mioa701 support to take into account this new layout :
 - IPL is version 0.5
 - MTD layout is fully changed
 - the boot sequence is rewritten :
   - the volume up button triggers console mode
   - upon PowerOn or Sleep exit, power key is debounced and if not
   help board is powered off back
   - sdcard environment override can now stop the autoboot sequence
   - mtd environment override can now stop the autoboot sequence

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/boards/mioa701/env/bin/barebox_update  |    7 +--
 arch/arm/boards/mioa701/env/bin/console_mode    |    6 +++
 arch/arm/boards/mioa701/env/bin/init            |   55 +++++++++++++++++++----
 arch/arm/boards/mioa701/env/bin/sdcard_override |    3 ++
 arch/arm/boards/mioa701/env/config              |    3 +-
 arch/arm/boards/mioa701/env/data/dps1.raw.gz    |  Bin 1239 -> 1324 bytes
 6 files changed, 62 insertions(+), 12 deletions(-)
 create mode 100644 arch/arm/boards/mioa701/env/bin/console_mode

diff --git a/arch/arm/boards/mioa701/env/bin/barebox_update b/arch/arm/boards/mioa701/env/bin/barebox_update
index 1023770..632c209 100644
--- a/arch/arm/boards/mioa701/env/bin/barebox_update
+++ b/arch/arm/boards/mioa701/env/bin/barebox_update
@@ -1,10 +1,11 @@
 #!/bin/sh
 
 # Page+OOB specific partitions
-addpart /dev/mtd0.raw 1081344@3649536(msipl)
-addpart /dev/mtd0.raw 270336@3649536(barebox)
+addpart /dev/mtd0.raw 2162688@405504(barebox)
 
 if [ -r /barebox.BIP0 ]; then
+	dps1_unlock
 	erase /dev/mtd0.raw.barebox
-	cp -v /barebox.BIP0 /dev/mtd0.raw.barebox
+	cp -v /barebox.BIPO /dev/mtd0.raw.barebox
+	dps1_unlock
 fi
diff --git a/arch/arm/boards/mioa701/env/bin/console_mode b/arch/arm/boards/mioa701/env/bin/console_mode
new file mode 100644
index 0000000..aa06e92
--- /dev/null
+++ b/arch/arm/boards/mioa701/env/bin/console_mode
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Script to run barebox in console mode
+
+splash /dev/mtd0.barebox-logo2
+echo
+echo "Welcome to barebox console"
diff --git a/arch/arm/boards/mioa701/env/bin/init b/arch/arm/boards/mioa701/env/bin/init
index ab5d84d..e914eae 100644
--- a/arch/arm/boards/mioa701/env/bin/init
+++ b/arch/arm/boards/mioa701/env/bin/init
@@ -7,13 +7,55 @@ export PATH
 addpart /dev/mtd0 $mtdparts
 
 usbserial -s "Mio A701 usb gadget"
-led keyboard 0
 
-sdcard_override
+gpio_get_value 22
+is_usb_connected=$?
+
+gpio_get_value 93
+is_vol_up=$?
 
 fb0.enable=1
+# Phase1: Handle Vol-Up key case : drop immediately to console
+if [ $is_vol_up != 0 ]; then
+	console_mode
+	exit
+fi
+
+# Phase2: Handle Power-On case : debounce PowerUp key or Halt
+if [ $global.system.reset = "POR" -o $global.system.reset = "WKE" ]; then
+	powerup_released=0
+
+	gpio_get_value 0
+	is_power_up=$?
+	if [ $is_power_up = 0 ]; then
+		powerup_released=1
+	fi
+	msleep 500
+
+	gpio_get_value 0
+	is_power_up=$?
+	if [ $is_power_up = 0 ]; then
+		powerup_released=1
+	fi
+
+	if [ $powerup_released = 1 ]; then
+		echo "Power button not held, halting"
+		poweroff
+	fi
+fi
+
+# Phase3: display logo
+led keyboard 0
 splash /dev/mtd0.barebox-logo
 
+# Phase4: check for SD Card override
+sdcard_override
+if [ $? = 0 ]; then
+    console_mode
+    exit
+fi
+
+# Phase5: check for MTD override
 mtd_env_override
 if [ $? = 0 ]; then
     echo "Switching to custom environment"
@@ -21,20 +63,17 @@ if [ $? = 0 ]; then
     exit
 fi
 
+# Phase6: check for user interrupting auto-boot
 echo "No custom environment found"
-
-gpio_get_value 22
-is_usb_connected=$?
 if [ $is_usb_connected != 0 ]; then
 	echo -n "Hit any key to stop autoboot: "
 	timeout -a $autoboot_timeout
 	if [ $? != 0 ]; then
-		echo
-		echo "Welcome to barebox console"
+		console_mode
 		exit
 	fi
 fi
 
+# Phase7: auto-boot linux kernel
 echo "Booting linux kernel on docg3 chip ..."
-bootargs="$bootargs mtdparts=docg3.0:$mtdparts ubi.mtd=4 rootfstype=ubifs root=ubi0:linux_root ro"
 bootm /dev/mtd0.kernel
diff --git a/arch/arm/boards/mioa701/env/bin/sdcard_override b/arch/arm/boards/mioa701/env/bin/sdcard_override
index ab83534..7003fa9 100644
--- a/arch/arm/boards/mioa701/env/bin/sdcard_override
+++ b/arch/arm/boards/mioa701/env/bin/sdcard_override
@@ -12,5 +12,8 @@ if [ $mci0.probe = 1 ]; then
 	if [ -f /sdcard/barebox.env ]; then
 		loadenv /sdcard/barebox.env /env.sd
 		/env.sd/bin/init
+		exit
 	fi
 fi
+trigger_error_return_code
+exit
diff --git a/arch/arm/boards/mioa701/env/config b/arch/arm/boards/mioa701/env/config
index 2cc44fd..9201451 100644
--- a/arch/arm/boards/mioa701/env/config
+++ b/arch/arm/boards/mioa701/env/config
@@ -2,4 +2,5 @@
 
 autoboot_timeout=3
 
-mtdparts="256k@3456k(barebox)ro,256k(barebox-logo),128k(barebox-env),4M(kernel),-(root)"
+mtdparts="2048k@384k(barebox)ro,256k(barebox-logo),256k(barebox-logo2),128k(barebox-env),5120k(kernel),-(root)"
+bootargs="$bootargs mtdparts=docg3.0:$mtdparts ubi.mtd=5 rootfstype=ubifs root=ubi0:linux_root ro"
diff --git a/arch/arm/boards/mioa701/env/data/dps1.raw.gz b/arch/arm/boards/mioa701/env/data/dps1.raw.gz
index 93112bfca14762534de50443d4e0b4c9333d0936..9857c83e0718d0268dd8c2082193063cd3dfbc72 100644
GIT binary patch
literal 1324
zcmV+{1=IQ;iwFo+Y|>Hy17vV>F)ngpcL42GacEUl82`?__vvdcy>1KV9D1A!%r?54
zujjVx?YVHIDc)LT!~!*=OvAMd!UEskb4xU8If)^`PMCj1U=)Nx@$8LJ{t?;=B>dyu
zd$_0#WYixLNVng)?@dQE{|fr&{NUp|=eytezH`p^o!>R-L27ATn|L_6uC0cMwyyc{
z^s_hL3^g<~G)&D88X6iJ8vg?Qf6&m-m<yU8H13AeM8EwNhX0hhnK4m}w(i-_H>`77
z_$GG?Z{|<!-}O@e0ls->|H0Sx>_tzVaK?fY_E<n%$XYuWyoYf;^bu$deHglSaW2R}
zH)6i3UdYwZ2QY7f?o)Pr-v?dEbAb)pZj5W7cPJaa^+G?5Z_jZx&IN0h3b}(Tzg+MN
z^gc)*#Nk<=C3C)o@$&E?kEoa?BZFNUCUGk^kMIgI&G!<0AE(MAY~ZtoFzmeb!O)_Q
znHw9Xs<lEgTS%4rtMZxZ5sO3OutocWSTquh;`=Bc3z$tsgAaHrr^QDCcK>%W8rvhm
zJNRxa9gtS}yaa7K#{+YH&bMu7deXZUh8-2HLRPI3lCb8k;wU*DFefL;$p($M`!uwr
zY{{IoFjnWj+&q1VhTpofgiKB((myY->{e=^IQ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EfecP%i4K?>UdH-E$k~un)ZU>tmWv
zf$Kn<#Jh>RT=k;u=;A5?UccqzeL^O{$HDi2?*JbGABE4r*Y87M_Y3<5Ui+GiJ{Wy4
z`e5|I=!4M*qYp+Oj6N8BF#2Hh;lI)c)~3&ys|dy;h{w|97<|GzI*j;htpzo{?q}f7
z#zgH7X#a@27JqczpM<}PJton&(YM{a3h6V2o$kW-@y-{9r^}3;R6%-L*Y62|{QLI_
z8D=xML#JwaBJPZexTk8l8F&WX0v`qc3gQ#sjv`+#{0aC;_~Y<X@W<c}!XJhI2z;Hx
zg>NHY_uaw|z*2~@V#4o&S#Hj^5y$&-((64d`CU1=a1Yu<PTK49<CtFp=iQf+T-&{8
zYhya6m$=dAy}9fCx_+H!1r=mPxv;Y+ZI+dUT(j=xwK#@7viq%yh~nL_tom1TbzO3j
z@XaImj;HsT#G3X@OFKDJyTfB%p;lA9t}sm3uy$u%J469a_4_c@^}*Xu{`nEQfnWpS
zmGZvZD8j94jTbItKk2SkhgaWy-Fe?ihw_LK-Vc2%Qzy<@)SmI^@-|}q)D8ZkM+W}~
zSmz=;Qjfm*lhFsG54HPX^ub^Qj6N8BF#2Gy6^uR@eK7i9uobTB!{4r^9LIn$0011R
Bg!KRb

-- 
1.7.10.4


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

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

* [PATCH] ARM: mioa701: poweroff the board on long power press
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
                   ` (3 preceding siblings ...)
  2014-01-18 11:48 ` [PATCH] ARM: mioa701 change MTD layout Robert Jarzmik
@ 2014-01-18 11:48 ` Robert Jarzmik
  2014-01-20 15:38 ` [PATCH] ARM: mioa701: fix frequence speedup code Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Robert Jarzmik @ 2014-01-18 11:48 UTC (permalink / raw)
  To: barebox

When the board is on console, a way is added to manually power off the
board, on a long power key press (4s).

This enables to be able to poweroff the board whatever the state, and is
the only manual way (no mechanical possibility).

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
 arch/arm/boards/mioa701/Makefile         |    2 +-
 arch/arm/boards/mioa701/gpio0_poweroff.c |   81 ++++++++++++++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/boards/mioa701/gpio0_poweroff.c

diff --git a/arch/arm/boards/mioa701/Makefile b/arch/arm/boards/mioa701/Makefile
index 01c7a25..3072706 100644
--- a/arch/arm/boards/mioa701/Makefile
+++ b/arch/arm/boards/mioa701/Makefile
@@ -1,2 +1,2 @@
-obj-y += board.o
+obj-y += board.o gpio0_poweroff.o
 lwl-y += lowlevel.o
diff --git a/arch/arm/boards/mioa701/gpio0_poweroff.c b/arch/arm/boards/mioa701/gpio0_poweroff.c
new file mode 100644
index 0000000..2054548
--- /dev/null
+++ b/arch/arm/boards/mioa701/gpio0_poweroff.c
@@ -0,0 +1,81 @@
+/*
+ * (C) 2011 Robert Jarzmik <robert.jarzmik@free.fr>
+ *
+ * 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.
+ *
+ */
+
+#include <clock.h>
+#include <common.h>
+#include <init.h>
+#include <gpio.h>
+#include <poller.h>
+
+#include "mioa701.h"
+
+#define POWEROFF_SECS (4 * SECOND)
+
+static void blink_led_keyboard(void)
+{
+	gpio_set_value(GPIO115_LED_nKeyboard, 0);
+	mdelay(400);
+	gpio_set_value(GPIO115_LED_nKeyboard, 1);
+	mdelay(400);
+}
+
+static void try_poweroff(void)
+{
+	int poweroff_released = 0;
+
+	blink_led_keyboard();
+	poweroff_released |= !gpio_get_value(GPIO0_KEY_POWER);
+	if (poweroff_released)
+		return;
+
+	gpio_set_value(GPIO115_LED_nKeyboard, 0);
+	mdelay(2000);
+	poweroff();
+}
+
+static void gpio0_poller_fn(struct poller_struct *poller)
+{
+	static uint64_t gpio0_start;
+	static bool gpio0_activated;
+
+	if (!gpio_get_value(GPIO0_KEY_POWER)) {
+		gpio0_activated = false;
+		return;
+	}
+
+	if (gpio0_activated) {
+		if (is_timeout_non_interruptible(gpio0_start, POWEROFF_SECS)) {
+			try_poweroff();
+			gpio0_activated = false;
+		}
+	} else {
+		gpio0_activated = true;
+		gpio0_start = get_time_ns();
+	}
+}
+
+static struct poller_struct gpio0_poller = {
+	.func = gpio0_poller_fn,
+};
+
+static int gpio0_poweroff_probe(void)
+{
+	return poller_register(&gpio0_poller);
+}
+
+device_initcall(gpio0_poweroff_probe);
-- 
1.7.10.4


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

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

* Re: [PATCH] ARM: mioa701: fix frequence speedup code
  2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
                   ` (4 preceding siblings ...)
  2014-01-18 11:48 ` [PATCH] ARM: mioa701: poweroff the board on long power press Robert Jarzmik
@ 2014-01-20 15:38 ` Sascha Hauer
  5 siblings, 0 replies; 7+ messages in thread
From: Sascha Hauer @ 2014-01-20 15:38 UTC (permalink / raw)
  To: Robert Jarzmik; +Cc: barebox

Hi Robert,

On Sat, Jan 18, 2014 at 12:48:04PM +0100, Robert Jarzmik wrote:
> As barebox has become the true SPL of mioa701 board (no intermediate
> SPL), a bug was uncovered in the init procedure, where the CPU voltage
> was to be increased by commanding the I2C voltage regulator, while the
> I2C was shut down.
> 
> Fix it by unclock-gating the power I2C bus before using it.
> 
> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>

Applied this series, thanks

Sascha

> ---
>  arch/arm/boards/mioa701/board.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/boards/mioa701/board.c b/arch/arm/boards/mioa701/board.c
> index c46b5da..7ee0be0 100644
> --- a/arch/arm/boards/mioa701/board.c
> +++ b/arch/arm/boards/mioa701/board.c
> @@ -266,6 +266,7 @@ static int mioa701_coredevice_init(void)
>  	 * This requires to command the Maxim 1586 to upgrade core voltage to
>  	 * 1.475 V, on the power I2C bus (device 0x14).
>  	 */
> +	CKEN |= CKEN_PWRI2C;
>  	CCCR = CCCR_A | 0x20290;
>  	PCFR = PCFR_GPR_EN | PCFR_FVC | PCFR_DC_EN | PCFR_PI2C_EN | PCFR_OPDE;
>  	PCMD(0) = PCMD_LC | 0x1f;
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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] 7+ messages in thread

end of thread, other threads:[~2014-01-20 15:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-18 11:48 [PATCH] ARM: mioa701: fix frequence speedup code Robert Jarzmik
2014-01-18 11:48 ` [PATCH] ARM: pxa: add reset source detection Robert Jarzmik
2014-01-18 11:48 ` [PATCH] ARM: pxa: add poweroff capability Robert Jarzmik
2014-01-18 11:48 ` [PATCH] ARM: mioa701 defconfig update Robert Jarzmik
2014-01-18 11:48 ` [PATCH] ARM: mioa701 change MTD layout Robert Jarzmik
2014-01-18 11:48 ` [PATCH] ARM: mioa701: poweroff the board on long power press Robert Jarzmik
2014-01-20 15:38 ` [PATCH] ARM: mioa701: fix frequence speedup code Sascha Hauer

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