debug_board.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  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>
  25. #include <asm/arch/gpio.h>
  26. #define DEBUG_BOARD_CONNECTED 1
  27. #define DEBUG_BOARD_NOT_CONNECTED 0
  28. static int debug_board_connected = DEBUG_BOARD_CONNECTED;
  29. static void zoom2_debug_board_detect (void)
  30. {
  31. int val = 0;
  32. if (!omap_request_gpio(158)) {
  33. /*
  34. * GPIO to query for debug board
  35. * 158 db board query
  36. */
  37. omap_set_gpio_direction(158, 1);
  38. val = omap_get_gpio_datain(158);
  39. omap_free_gpio(158);
  40. }
  41. if (!val)
  42. debug_board_connected = DEBUG_BOARD_NOT_CONNECTED;
  43. }
  44. int zoom2_debug_board_connected (void)
  45. {
  46. static int first_time = 1;
  47. if (first_time) {
  48. zoom2_debug_board_detect ();
  49. first_time = 0;
  50. }
  51. return debug_board_connected;
  52. }