Tom Rix | 50ce337 | 2009-05-15 23:48:36 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2009 Wind River Systems, Inc. |
| 3 | * Tom Rix <Tom.Rix@windriver.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Tom Rix | 50ce337 | 2009-05-15 23:48:36 +0200 | [diff] [blame] | 6 | */ |
| 7 | #include <common.h> |
| 8 | #include <asm/arch/cpu.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/mux.h> |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 11 | #include <asm/gpio.h> |
Tom Rix | 50ce337 | 2009-05-15 23:48:36 +0200 | [diff] [blame] | 12 | |
| 13 | #define DEBUG_BOARD_CONNECTED 1 |
| 14 | #define DEBUG_BOARD_NOT_CONNECTED 0 |
| 15 | |
| 16 | static int debug_board_connected = DEBUG_BOARD_CONNECTED; |
| 17 | |
| 18 | static void zoom2_debug_board_detect (void) |
| 19 | { |
| 20 | int val = 0; |
| 21 | |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 22 | if (!gpio_request(158, "")) { |
Tom Rix | 50ce337 | 2009-05-15 23:48:36 +0200 | [diff] [blame] | 23 | /* |
| 24 | * GPIO to query for debug board |
| 25 | * 158 db board query |
| 26 | */ |
Sanjeev Premi | 7b3dc82 | 2011-09-08 10:51:01 -0400 | [diff] [blame] | 27 | gpio_direction_input(158); |
| 28 | val = gpio_get_value(158); |
Tom Rix | 50ce337 | 2009-05-15 23:48:36 +0200 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | if (!val) |
| 32 | debug_board_connected = DEBUG_BOARD_NOT_CONNECTED; |
| 33 | } |
| 34 | |
| 35 | int 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 | } |