dlvision.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 buf[64];
  70. int i = getenv_f("serial#", buf, sizeof(buf));
  71. u8 channel2_msr = in_8((void *)CONFIG_UART_BASE + 0x26);
  72. u8 channel3_msr = in_8((void *)CONFIG_UART_BASE + 0x36);
  73. u8 channel7_msr = in_8((void *)CONFIG_UART_BASE + 0x76);
  74. u8 unit_type;
  75. u8 local_con;
  76. u8 audio;
  77. u8 hardware_version;
  78. printf("Board: ");
  79. unit_type = (channel2_msr & 0x80) ? 0x01 : 0x00;
  80. local_con = (channel2_msr & 0x20) ? 0x01 : 0x00;
  81. audio = (channel3_msr & 0x20) ? 0x01 : 0x00;
  82. hardware_version =
  83. ((channel7_msr & 0x20) ? 0x01 : 0x00)
  84. | ((channel7_msr & 0x80) ? 0x02 : 0x00)
  85. | ((channel7_msr & 0x40) ? 0x04 : 0x00);
  86. switch (unit_type) {
  87. case HWTYPE_DLVISION_CON:
  88. printf("DL-Vision-CON");
  89. break;
  90. case HWTYPE_DLVISION_CPU:
  91. printf("DL-Vision-CPU");
  92. break;
  93. default:
  94. printf("UnitType %d, unsupported", unit_type);
  95. break;
  96. }
  97. if (i > 0) {
  98. puts(", serial# ");
  99. puts(buf);
  100. }
  101. puts("\n ");
  102. switch (hardware_version) {
  103. case HWREV_100:
  104. printf("HW-Ver 1.00");
  105. break;
  106. default:
  107. printf("HW-Ver %d, unsupported",
  108. hardware_version);
  109. break;
  110. }
  111. if (local_con)
  112. printf(", local console");
  113. if (audio)
  114. printf(", audio support");
  115. puts("\n");
  116. return 0;
  117. }