cmd_ocrtc.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * (C) Copyright 2003
  3. * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
  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 <pci.h>
  26. #include <405gp_pci.h>
  27. #if (CONFIG_COMMANDS & CFG_CMD_BSP)
  28. #define AMCC_VENDOR_ID 0x1014
  29. #define PPC405_DEVICE_ID 0x0156
  30. /*
  31. * Set device number on pci board
  32. */
  33. int do_setdevice(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  34. {
  35. int idx = 1; /* start at 1 (skip device 0) */
  36. pci_dev_t bdf = 0;
  37. u32 addr;
  38. while (bdf >= 0) {
  39. if ((bdf = pci_find_device(AMCC_VENDOR_ID, PPC405_DEVICE_ID, idx++)) < 0) {
  40. break;
  41. }
  42. printf("Found device nr %d at %x!\n", idx-1, bdf);
  43. pci_read_config_dword(bdf, PCI_BASE_ADDRESS_1, &addr);
  44. addr &= ~0xf;
  45. *(u32 *)addr = (bdf & 0x0000f800) >> 11;
  46. printf("Wrote %x at %x!\n", (bdf & 0x0000f800) >> 11, addr);
  47. }
  48. return 0;
  49. }
  50. U_BOOT_CMD(
  51. setdevice, 1, 1, do_setdevice,
  52. "setdevice - Set device number on pci adapter boards\n",
  53. NULL
  54. );
  55. /*
  56. * Get device number on pci board
  57. */
  58. int do_getdevice(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  59. {
  60. u32 device;
  61. char str[32];
  62. device = *(u32 *)0x0;
  63. device = 0x16 - device; /* calculate vxworks bp slot id */
  64. sprintf(str, "%d", device);
  65. setenv("slot", str);
  66. printf("Variabel slot set to %x\n", device);
  67. return 0;
  68. }
  69. U_BOOT_CMD(
  70. getdevice, 1, 1, do_getdevice,
  71. "getdevice - Get device number and set slot env variable\n",
  72. NULL
  73. );
  74. #endif