blob: 33aa6001bc6b9d33c1beeba0f75c1d92150229f8 [file] [log] [blame]
Tom Rixde193e82009-05-15 23:48:36 +02001/*
2 * Copyright (c) 2009 Wind River Systems, Inc.
3 * Tom Rix <Tom.Rix@windriver.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 *
20 */
21#include <common.h>
22#include <asm/arch/cpu.h>
23#include <asm/io.h>
24#include <asm/arch/mux.h>
Sanjeev Premi84c3b632011-09-08 10:51:01 -040025#include <asm/gpio.h>
Tom Rixde193e82009-05-15 23:48:36 +020026
27#define DEBUG_BOARD_CONNECTED 1
28#define DEBUG_BOARD_NOT_CONNECTED 0
29
30static int debug_board_connected = DEBUG_BOARD_CONNECTED;
31
32static void zoom2_debug_board_detect (void)
33{
34 int val = 0;
35
Sanjeev Premi84c3b632011-09-08 10:51:01 -040036 if (!gpio_request(158, "")) {
Tom Rixde193e82009-05-15 23:48:36 +020037 /*
38 * GPIO to query for debug board
39 * 158 db board query
40 */
Sanjeev Premi84c3b632011-09-08 10:51:01 -040041 gpio_direction_input(158);
42 val = gpio_get_value(158);
43 gpio_free(158);
Tom Rixde193e82009-05-15 23:48:36 +020044 }
45
46 if (!val)
47 debug_board_connected = DEBUG_BOARD_NOT_CONNECTED;
48}
49
50int zoom2_debug_board_connected (void)
51{
52 static int first_time = 1;
53
54 if (first_time) {
55 zoom2_debug_board_detect ();
56 first_time = 0;
57 }
58 return debug_board_connected;
59}