cadmus.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright 2004 Freescale Semiconductor.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. /*
  24. * CADMUS Board System Registers
  25. */
  26. #ifndef CFG_CADMUS_BASE_REG
  27. #define CFG_CADMUS_BASE_REG (CADMUS_BASE_ADDR + 0x4000)
  28. #endif
  29. typedef struct cadmus_reg {
  30. u_char cm_ver; /* Board version */
  31. u_char cm_csr; /* General control/status */
  32. u_char cm_rst; /* Reset control */
  33. u_char cm_hsclk; /* High speed clock */
  34. u_char cm_hsxclk; /* High speed clock extended */
  35. u_char cm_led; /* LED data */
  36. u_char cm_pci; /* PCI control/status */
  37. u_char cm_dma; /* DMA control */
  38. u_char cm_reserved[248]; /* Total 256 bytes */
  39. } cadmus_reg_t;
  40. unsigned int
  41. get_board_version(void)
  42. {
  43. volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CFG_CADMUS_BASE_REG;
  44. return cadmus->cm_ver;
  45. }
  46. unsigned long
  47. get_clock_freq(void)
  48. {
  49. volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CFG_CADMUS_BASE_REG;
  50. uint pci1_speed = (cadmus->cm_pci >> 2) & 0x3; /* PSPEED in [4:5] */
  51. if (pci1_speed == 0) {
  52. return 33000000;
  53. } else if (pci1_speed == 1) {
  54. return 66000000;
  55. } else {
  56. /* Really, unknown. Be safe? */
  57. return 33000000;
  58. }
  59. }
  60. unsigned int
  61. get_pci_slot(void)
  62. {
  63. volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CFG_CADMUS_BASE_REG;
  64. /*
  65. * PCI slot in USER bits CSR[6:7] by convention.
  66. */
  67. return ((cadmus->cm_csr >> 6) & 0x3) + 1;
  68. }
  69. unsigned int
  70. get_pci_dual(void)
  71. {
  72. volatile cadmus_reg_t *cadmus = (cadmus_reg_t *)CFG_CADMUS_BASE_REG;
  73. /*
  74. * PCI DUAL in CM_PCI[3]
  75. */
  76. return cadmus->cm_pci & 0x10;
  77. }