]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/keymile/common/common.c
Merge remote-tracking branch 'u-boot-samsung/master'
[karo-tx-uboot.git] / board / keymile / common / common.c
index f26230648d474598583bae608f23842aff11397b..2ddb3da38f35f7245551bd66ebbffabd71f59420 100644 (file)
@@ -5,43 +5,24 @@
  * (C) Copyright 2011
  * Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <ioports.h>
 #include <command.h>
 #include <malloc.h>
-#include <hush.h>
+#include <cli_hush.h>
 #include <net.h>
 #include <netdev.h>
 #include <asm/io.h>
 #include <linux/ctype.h>
 
+#if defined(CONFIG_POST)
+#include "post.h"
+#endif
 #include "common.h"
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
 #include <i2c.h>
-#endif
-
-#if !defined(CONFIG_MPC83xx)
-static void i2c_write_start_seq(void);
-#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -93,7 +74,6 @@ int set_km_env(void)
 }
 
 #if defined(CONFIG_SYS_I2C_INIT_BOARD)
-#if !defined(CONFIG_MPC83xx)
 static void i2c_write_start_seq(void)
 {
        set_sda(1);
@@ -116,21 +96,6 @@ static void i2c_write_start_seq(void)
  */
 int i2c_make_abort(void)
 {
-
-#if defined(CONFIG_HARD_I2C) && !defined(MACH_TYPE_KM_KIRKWOOD)
-       immap_t *immap = (immap_t *)CONFIG_SYS_IMMR ;
-       i2c8260_t *i2c  = (i2c8260_t *)&immap->im_i2c;
-
-       /*
-        * disable I2C controller first, otherwhise it thinks we want to
-        * talk to the slave port...
-        */
-       clrbits_8(&i2c->i2c_i2mod, 0x01);
-
-       /* Set the PortPins to GPIO */
-       setports(1);
-#endif
-
        int     scl_state = 0;
        int     sda_state = 0;
        int     i = 0;
@@ -148,7 +113,6 @@ int i2c_make_abort(void)
                        sda_state = get_sda();
                        if (scl_state && sda_state) {
                                ret = 0;
-                               printf("[INFO] i2c abort after %d clocks\n", i);
                                break;
                        }
                }
@@ -156,8 +120,6 @@ int i2c_make_abort(void)
        if (ret == 0)
                for (i = 0; i < 5; i++)
                        i2c_write_start_seq();
-       else
-               printf("[ERROR] i2c abort failed\n");
 
        /* respect stop setup time */
        udelay(DELAY_ABORT_SEQ);
@@ -166,13 +128,8 @@ int i2c_make_abort(void)
        set_sda(1);
        get_sda();
 
-#if defined(CONFIG_HARD_I2C)
-       /* Set the PortPins back to use for I2C */
-       setports(0);
-#endif
        return ret;
 }
-#endif
 
 /**
  * i2c_init_board - reset i2c bus. When the board is powercycled during a
@@ -185,17 +142,7 @@ void i2c_init_board(void)
 }
 #endif
 
-
-#if !defined(MACH_TYPE_KM_KIRKWOOD)
-int ethernet_present(void)
-{
-       struct km_bec_fpga *base =
-               (struct km_bec_fpga *)CONFIG_SYS_KMBEC_FPGA_BASE;
-
-       return in_8(&base->bprth) & PIGGY_PRESENT;
-}
-#endif
-
+#if defined(CONFIG_KM_COMMON_ETH_INIT)
 int board_eth_init(bd_t *bis)
 {
        if (ethernet_present())
@@ -203,6 +150,7 @@ int board_eth_init(bd_t *bis)
 
        return -1;
 }
+#endif
 
 /*
  * do_setboardid command
@@ -255,7 +203,7 @@ U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", "read out bid and "
  *                             application and in the init scripts (?)
  *     return 0 in case of match, 1 if not match or error
  */
-int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
+static int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc,
                        char *const argv[])
 {
        unsigned long ivmbid = 0, ivmhwkey = 0;
@@ -390,3 +338,36 @@ U_BOOT_CMD(km_checkbidhwk, 2, 0, do_checkboardidhwk,
                "\"boardIdListHex\" against stored boardid and hwkey "\
                "from the IVM\n    v: verbose output"
 );
+
+/*
+ * command km_checktestboot
+ *  if the testpin of the board is asserted, return 1
+ *  *  else return 0
+ */
+static int do_checktestboot(cmd_tbl_t *cmdtp, int flag, int argc,
+                       char *const argv[])
+{
+       int testpin = 0;
+       char *s = NULL;
+       int testboot = 0;
+       int verbose = argc > 1 && *argv[1] == 'v';
+
+#if defined(CONFIG_POST)
+       testpin = post_hotkeys_pressed();
+       s = getenv("test_bank");
+#endif
+       /* when test_bank is not set, act as if testpin is not asserted */
+       testboot = (testpin != 0) && (s);
+       if (verbose) {
+               printf("testpin   = %d\n", testpin);
+               printf("test_bank = %s\n", s ? s : "not set");
+               printf("boot test app : %s\n", (testboot) ? "yes" : "no");
+       }
+       /* return 0 means: testboot, therefore we need the inversion */
+       return !testboot;
+}
+
+U_BOOT_CMD(km_checktestboot, 2, 0, do_checktestboot,
+               "check if testpin is asserted",
+               "[v]\n  v - verbose output"
+);