]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - board/a3m071/a3m071.c
mpc5200: a3m071/a4m2k: Miscellaneous updates and fixes
[people/ms/u-boot.git] / board / a3m071 / a3m071.c
index 0a86e9abc1ec1b029b7599edef6f72239236e614..c62ba62172c093f99f134d42c3581d3fd671f764 100644 (file)
@@ -8,7 +8,7 @@
  * (C) Copyright 2006
  * MicroSys GmbH
  *
- * Copyright 2012 Stefan Roese <sr@denx.de>
+ * Copyright 2012-2013 Stefan Roese <sr@denx.de>
  *
  * See file CREDITS for list of people who contributed to this
  * project.
@@ -241,12 +241,26 @@ void spl_board_init(void)
 
        /* And write new value back to register */
        out_be32(&mm->ipbi_ws_ctrl, val);
-#endif
 
-       /*
-        * No need to change the pin multiplexing (MPC5XXX_GPS_PORT_CONFIG)
-        * as all 3 config versions (failsave level) have the same setup.
-        */
+
+       /* Setup pin multiplexing */
+       if (failsavelevel == 2) {
+               /* fpga-version ok */
+#if defined(CONFIG_SYS_GPS_PORT_CONFIG_2)
+               out_be32(&gpio->port_config, CONFIG_SYS_GPS_PORT_CONFIG_2);
+#endif
+       } else if (failsavelevel == 1) {
+               /* digiboard-version ok - fpga not */
+#if defined(CONFIG_SYS_GPS_PORT_CONFIG_1)
+               out_be32(&gpio->port_config, CONFIG_SYS_GPS_PORT_CONFIG_1);
+#endif
+       } else {
+               /* full failsave-mode */
+#if defined(CONFIG_SYS_GPS_PORT_CONFIG)
+               out_be32(&gpio->port_config, CONFIG_SYS_GPS_PORT_CONFIG);
+#endif
+       }
+#endif
 
        /*
         * Setup gpio_wkup_7 as watchdog AS INPUT to disable it - see
@@ -255,7 +269,7 @@ void spl_board_init(void)
         * MPC5XXX_WU_GPIO_DIR direction is already 0 (INPUT)
         * set bit 0(msb) to 1
         */
-       setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, 1 << (31 - 0));
+       setbits_be32((void *)MPC5XXX_WU_GPIO_ENABLE, CONFIG_WDOG_GPIO_PIN);
 
 #if defined(CONFIG_A4M2K)
        /* Setup USB[x] as MPCDiag[0..3] GPIO outputs */
@@ -410,3 +424,57 @@ int spl_start_uboot(void)
        return 1;
 }
 #endif
+
+#if defined(CONFIG_HW_WATCHDOG)
+static int watchdog_toggle;
+
+void hw_watchdog_reset(void)
+{
+       int val;
+
+       /*
+        * Check if watchdog is enabled via user command
+        */
+       if ((gd->flags & GD_FLG_RELOC) && watchdog_toggle) {
+               /* Set direction to output */
+               setbits_be32((void *)MPC5XXX_WU_GPIO_DIR, CONFIG_WDOG_GPIO_PIN);
+
+               /*
+                * Toggle watchdog output
+                */
+               val = (in_be32((void *)MPC5XXX_WU_GPIO_DATA_O) &
+                      CONFIG_WDOG_GPIO_PIN);
+               if (val) {
+                       clrbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O,
+                                    CONFIG_WDOG_GPIO_PIN);
+               } else {
+                       setbits_be32((void *)MPC5XXX_WU_GPIO_DATA_O,
+                                    CONFIG_WDOG_GPIO_PIN);
+               }
+       }
+}
+
+int do_wdog_toggle(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       if (argc != 2)
+               goto usage;
+
+       if (strncmp(argv[1], "on", 2) == 0)
+               watchdog_toggle = 1;
+       else if (strncmp(argv[1], "off", 3) == 0)
+               watchdog_toggle = 0;
+       else
+               goto usage;
+
+       return 0;
+usage:
+       printf("Usage: wdogtoggle %s\n", cmdtp->usage);
+       return 1;
+}
+
+U_BOOT_CMD(
+       wdogtoggle, CONFIG_SYS_MAXARGS, 2, do_wdog_toggle,
+       "toggle GPIO pin to service watchdog",
+       "[on/off] - Switch watchdog toggling via GPIO pin on/off"
+);
+#endif