blob: 071f41074ba11772f0e0599dd14f9fb3d34f7a0e [file] [log] [blame]
Tom Rix50ce3372009-05-15 23:48:36 +02001/*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
4 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Tom Rix50ce3372009-05-15 23:48:36 +02006 */
7#include <common.h>
8#include <asm/arch/cpu.h>
9#include <asm/io.h>
10#include <asm/arch/mux.h>
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040011#include <asm/gpio.h>
Tom Rix50ce3372009-05-15 23:48:36 +020012
13#define DEBUG_BOARD_CONNECTED 1
14#define DEBUG_BOARD_NOT_CONNECTED 0
15
16static int debug_board_connected = DEBUG_BOARD_CONNECTED;
17
18static void zoom2_debug_board_detect (void)
19{
20 int val = 0;
21
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040022 if (!gpio_request(158, "")) {
Tom Rix50ce3372009-05-15 23:48:36 +020023 /*
24 * GPIO to query for debug board
25 * 158 db board query
26 */
Sanjeev Premi7b3dc822011-09-08 10:51:01 -040027 gpio_direction_input(158);
28 val = gpio_get_value(158);
Tom Rix50ce3372009-05-15 23:48:36 +020029 }
30
31 if (!val)
32 debug_board_connected = DEBUG_BOARD_NOT_CONNECTED;
33}
34
35int zoom2_debug_board_connected (void)
36{
37 static int first_time = 1;
38
39 if (first_time) {
40 zoom2_debug_board_detect ();
41 first_time = 0;
42 }
43 return debug_board_connected;
44}