host_bridge.c 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2004 Picture Elements, Inc.
  3. * Stephen Williams (steve@icarus.com)
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #ident "$Id:$"
  8. # include <common.h>
  9. # include <pci.h>
  10. # include "jse_priv.h"
  11. /*
  12. * The JSE board has an Intel 21555 non-transparent bridge for
  13. * communication with the host. We need to render it harmless on the
  14. * JSE side, but leave it alone on the host (primary) side. Normally,
  15. * this will all be done before the host BIOS can gain access to the
  16. * board, due to the Primary Access Lockout bit.
  17. *
  18. * The host_bridge_init function is called as a late initialization
  19. * function, after most of the board is set up, including a PCI scan.
  20. */
  21. void host_bridge_init (void)
  22. {
  23. /* The bridge chip is at a fixed location. */
  24. pci_dev_t dev = PCI_BDF (0, 10, 0);
  25. /* Set PCI Class code --
  26. The primary side sees this class code at 0x08 in the
  27. primary config space. This must be something other then a
  28. bridge, or MS Windows starts doing weird stuff to me. */
  29. pci_write_config_dword (dev, 0x48, 0x04800000);
  30. /* Set subsystem ID --
  31. The primary side sees this value at 0x2c. We set it here so
  32. that the host can tell what sort of device this is:
  33. We are a Picture Elements [0x12c5] JSE [0x008a]. */
  34. pci_write_config_dword (dev, 0x6c, 0x008a12c5);
  35. /* Downstream (Primary-to-Secondary) BARs are set up mostly
  36. off. We need only the Memory-0 Bar so that the host can get
  37. at the CSR region to set up tables and the lot. */
  38. /* Downstream Memory 0 setup (4K for CSR) */
  39. pci_write_config_dword (dev, 0xac, 0xfffff000);
  40. /* Downstream Memory 1 setup (off) */
  41. pci_write_config_dword (dev, 0xb0, 0x00000000);
  42. /* Downstream Memory 2 setup (off) */
  43. pci_write_config_dword (dev, 0xb4, 0x00000000);
  44. /* Downstream Memory 3 setup (off) */
  45. pci_write_config_dword (dev, 0xb8, 0x00000000);
  46. /* Upstream (Secondary-to-Primary) BARs are used to get at
  47. host memory from the JSE card. Create two regions: a small
  48. one to manage individual word reads/writes, and a larger
  49. one for doing bulk frame moves. */
  50. /* Upstream Memory 0 Setup -- (BAR2) 4K non-prefetchable */
  51. pci_write_config_dword (dev, 0xc4, 0xfffff000);
  52. /* Upstream Memory 1 setup -- (BAR3) 4K non-prefetchable */
  53. pci_write_config_dword (dev, 0xc8, 0xfffff000);
  54. /* Upstream Memory 2 (BAR4) uses page translation, and is set
  55. up in CCR1. Configure for 4K pages. */
  56. /* Set CCR1,0 reigsters. This clears the Primary PCI Lockout
  57. bit as well, so we are done configuring after this
  58. point. Therefore, this must be the last step.
  59. CC1[15:12]= 0 (disable I2O message unit)
  60. CC1[11:8] = 0x5 (4K page size)
  61. CC0[11] = 1 (Secondary Clock Disable: disable clock)
  62. CC0[10] = 0 (Primary Access Lockout: allow primary access)
  63. */
  64. pci_write_config_dword (dev, 0xcc, 0x05000800);
  65. }