Commit 27aede24bcdec3777da7b23efc0a8cb777d83d6a

Authored by Lukasz Majewski
Committed by Stefano Babic
1 parent cf74e0a96b

display5: Support for the emergency PAD pressing

To enter the special mode, one needs to short cut two pads with e.g. screw
driver.

After power up the SPL will execute u-boot in which proper actions will be
taken.

It is worth noting that we do not alter envs (even the BOOT_FROM variable)
and unconditionally go to recovery.

Signed-off-by: Lukasz Majewski <lukma@denx.de>

Showing 5 changed files with 58 additions and 2 deletions Side-by-side Diff

board/liebherr/display5/common.c
... ... @@ -34,6 +34,16 @@
34 34 SETUP_IOMUX_PADS(uart_pads);
35 35 }
36 36  
  37 +iomux_v3_cfg_t const misc_pads_spl[] = {
  38 + /* Emergency recovery pin */
  39 + MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
  40 +};
  41 +
  42 +void displ5_set_iomux_misc_spl(void)
  43 +{
  44 + SETUP_IOMUX_PADS(misc_pads_spl);
  45 +}
  46 +
37 47 #ifdef CONFIG_MXC_SPI
38 48 iomux_v3_cfg_t const ecspi_pads[] = {
39 49 /* SPI3 */
board/liebherr/display5/common.h
... ... @@ -37,6 +37,7 @@
37 37 void displ5_set_iomux_ecspi(void);
38 38 void displ5_set_iomux_usdhc_spl(void);
39 39 void displ5_set_iomux_usdhc(void);
  40 +void displ5_set_iomux_misc_spl(void);
40 41  
41 42 #endif /* __DISPL5_COMMON_H_ */
board/liebherr/display5/display5.c
... ... @@ -44,6 +44,7 @@
44 44 static u32 cpu_id;
45 45 static u32 unit_id;
46 46  
  47 +#define EM_PAD IMX_GPIO_NR(3, 29)
47 48 #define SW0 IMX_GPIO_NR(2, 4)
48 49 #define SW1 IMX_GPIO_NR(2, 5)
49 50 #define SW2 IMX_GPIO_NR(2, 6)
... ... @@ -179,6 +180,9 @@
179 180  
180 181 /* XTALOSC */
181 182 MX6_PAD_GPIO_3__XTALOSC_REF_CLK_24M | MUX_PAD_CTRL(NO_PAD_CTRL),
  183 +
  184 + /* Emergency recovery pin */
  185 + MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
182 186 };
183 187  
184 188 #ifdef CONFIG_FSL_ESDHC
185 189  
... ... @@ -369,7 +373,22 @@
369 373  
370 374 int misc_init_r(void)
371 375 {
  376 + int ret;
  377 +
372 378 setup_boot_modes();
  379 +
  380 + ret = gpio_request(EM_PAD, "Emergency_PAD");
  381 + if (ret) {
  382 + printf("Can't request emergency PAD gpio\n");
  383 + return ret;
  384 + }
  385 +
  386 + ret = gpio_direction_input(EM_PAD);
  387 + if (ret) {
  388 + printf("Can't set emergency PAD direction\n");
  389 + return ret;
  390 + }
  391 +
373 392 return 0;
374 393 }
375 394  
board/liebherr/display5/spl.c
... ... @@ -16,6 +16,7 @@
16 16 #include <asm/arch/imx-regs.h>
17 17 #include "asm/arch/iomux.h"
18 18 #include <asm/mach-imx/iomux-v3.h>
  19 +#include <asm/gpio.h>
19 20 #include <environment.h>
20 21 #include <fsl_esdhc.h>
21 22 #include <netdev.h>
22 23  
... ... @@ -194,10 +195,24 @@
194 195 /* Clear the BSS. */
195 196 memset(__bss_start, 0, __bss_end - __bss_start);
196 197  
  198 + displ5_set_iomux_misc_spl();
  199 +
197 200 /* load/boot image from boot device */
198 201 board_init_r(NULL, 0);
199 202 }
200 203  
  204 +#define EM_PAD IMX_GPIO_NR(3, 29)
  205 +int board_check_emergency_pad(void)
  206 +{
  207 + int ret;
  208 +
  209 + ret = gpio_direction_input(EM_PAD);
  210 + if (ret)
  211 + return ret;
  212 +
  213 + return !gpio_get_value(EM_PAD);
  214 +}
  215 +
201 216 void board_boot_order(u32 *spl_boot_list)
202 217 {
203 218 /* Default boot sequence SPI -> MMC */
... ... @@ -205,6 +220,13 @@
205 220 spl_boot_list[1] = BOOT_DEVICE_MMC1;
206 221 spl_boot_list[2] = BOOT_DEVICE_UART;
207 222 spl_boot_list[3] = BOOT_DEVICE_NONE;
  223 +
  224 + /*
  225 + * In case of emergency PAD pressed, we always boot
  226 + * to proper u-boot and perform recovery tasks there.
  227 + */
  228 + if (board_check_emergency_pad())
  229 + return;
208 230  
209 231 #ifdef CONFIG_SPL_ENV_SUPPORT
210 232 /* 'fastboot' */
include/configs/display5.h
... ... @@ -100,11 +100,13 @@
100 100 #define CONFIG_BAUDRATE 115200
101 101  
102 102 #ifndef CONFIG_BOOTCOMMAND
103   -#define CONFIG_BOOTCOMMAND "if test ${BOOT_FROM} = FACTORY; then " \
  103 +#define CONFIG_BOOTCOMMAND "if run check_em_pad; then " \
  104 + "run recovery;" \
  105 + "else if test ${BOOT_FROM} = FACTORY; then " \
104 106 "run factory_nfs;" \
105 107 "else " \
106 108 "run boot_mmc;" \
107   - "fi"
  109 + "fi;fi"
108 110 #endif
109 111  
110 112 #define PARTS_DEFAULT \
... ... @@ -246,6 +248,8 @@
246 248  
247 249 #define CONFIG_EXTRA_ENV_SETTINGS \
248 250 PARTS_DEFAULT \
  251 + "gpio_recovery=93\0" \
  252 + "check_em_pad=gpio input ${gpio_recovery};test $? -eq 0;\0" \
249 253 "display=tianma-tm070-800x480\0" \
250 254 "board=display5\0" \
251 255 "mmcdev=0\0" \