dlvision.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * (C) Copyright 2009
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include <asm/ppc4xx-gpio.h>
  28. enum {
  29. HWTYPE_DLVISION_CPU = 0,
  30. HWTYPE_DLVISION_CON = 1,
  31. };
  32. #define HWREV_100 6
  33. int board_early_init_f(void)
  34. {
  35. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  36. mtdcr(UIC0ER, 0x00000000); /* disable all ints */
  37. mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical */
  38. mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */
  39. mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */
  40. mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest prio */
  41. mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */
  42. /*
  43. * EBC Configuration Register: set ready timeout to 512 ebc-clks
  44. * -> ca. 15 us
  45. */
  46. mtebc(EBC0_CFG, 0xa8400000); /* ebc always driven */
  47. /*
  48. * setup io-latches
  49. */
  50. out_le16((void *)CONFIG_SYS_LATCH_BASE, 0x00f0);
  51. out_le16((void *)(CONFIG_SYS_LATCH_BASE + 0x100), 0x0002);
  52. out_le16((void *)(CONFIG_SYS_LATCH_BASE + 0x200), 0x0000);
  53. return 0;
  54. }
  55. int misc_init_r(void)
  56. {
  57. /*
  58. * set "startup-finished"-gpios
  59. */
  60. gpio_write_bit(21, 0);
  61. gpio_write_bit(22, 1);
  62. return 0;
  63. }
  64. /*
  65. * Check Board Identity:
  66. */
  67. int checkboard(void)
  68. {
  69. char *s = getenv("serial#");
  70. u8 channel2_msr = in_8((void *)CONFIG_UART_BASE + 0x26);
  71. u8 channel3_msr = in_8((void *)CONFIG_UART_BASE + 0x36);
  72. u8 channel7_msr = in_8((void *)CONFIG_UART_BASE + 0x76);
  73. u8 unit_type;
  74. u8 local_con;
  75. u8 audio;
  76. u8 hardware_version;
  77. printf("Board: ");
  78. unit_type = (channel2_msr & 0x80) ? 0x01 : 0x00;
  79. local_con = (channel2_msr & 0x20) ? 0x01 : 0x00;
  80. audio = (channel3_msr & 0x20) ? 0x01 : 0x00;
  81. hardware_version =
  82. ((channel7_msr & 0x20) ? 0x01 : 0x00)
  83. | ((channel7_msr & 0x80) ? 0x02 : 0x00)
  84. | ((channel7_msr & 0x40) ? 0x04 : 0x00);
  85. switch (unit_type) {
  86. case HWTYPE_DLVISION_CON:
  87. printf("DL-Vision-CON");
  88. break;
  89. case HWTYPE_DLVISION_CPU:
  90. printf("DL-Vision-CPU");
  91. break;
  92. default:
  93. printf("UnitType %d, unsupported", unit_type);
  94. break;
  95. }
  96. if (s != NULL) {
  97. puts(", serial# ");
  98. puts(s);
  99. }
  100. puts("\n ");
  101. switch (hardware_version) {
  102. case HWREV_100:
  103. printf("HW-Ver 1.00");
  104. break;
  105. default:
  106. printf("HW-Ver %d, unsupported",
  107. hardware_version);
  108. break;
  109. }
  110. if (local_con)
  111. printf(", local console");
  112. if (audio)
  113. printf(", audio support");
  114. puts("\n");
  115. return 0;
  116. }