ftpci100.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Faraday FTPCI100 PCI Bridge Controller Device Driver Implementation
  4. *
  5. * Copyright (C) 2010 Andes Technology Corporation
  6. * Gavin Guo, Andes Technology Corporation <gavinguo@andestech.com>
  7. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  8. */
  9. #ifndef __FTPCI100_H
  10. #define __FTPCI100_H
  11. /* AHB Control Registers */
  12. struct ftpci100_ahbc {
  13. unsigned int iosize; /* 0x00 - I/O Space Size Signal */
  14. unsigned int prot; /* 0x04 - AHB Protection */
  15. unsigned int rsved[8]; /* 0x08-0x24 - Reserved */
  16. unsigned int conf; /* 0x28 - PCI Configuration */
  17. unsigned int data; /* 0x2c - PCI Configuration DATA */
  18. };
  19. /*
  20. * FTPCI100_IOSIZE_REG's constant definitions
  21. */
  22. #define FTPCI100_BASE_IO_SIZE(x) (ffs(x) - 1) /* 1M - 2048M */
  23. /*
  24. * PCI Configuration Register
  25. */
  26. #define PCI_INT_MASK 0x4c
  27. #define PCI_MEM_BASE_SIZE1 0x50
  28. #define PCI_MEM_BASE_SIZE2 0x54
  29. #define PCI_MEM_BASE_SIZE3 0x58
  30. /*
  31. * PCI_INT_MASK's bit definitions
  32. */
  33. #define PCI_INTA_ENABLE (1 << 22)
  34. #define PCI_INTB_ENABLE (1 << 23)
  35. #define PCI_INTC_ENABLE (1 << 24)
  36. #define PCI_INTD_ENABLE (1 << 25)
  37. /*
  38. * PCI_MEM_BASE_SIZE1's constant definitions
  39. */
  40. #define FTPCI100_BASE_ADR_SIZE(x) ((ffs(x) - 1) << 16) /* 1M - 2048M */
  41. #define FTPCI100_MAX_FUNCTIONS 20
  42. #define PCI_IRQ_LINES 4
  43. #define MAX_BUS_NUM 256
  44. #define MAX_DEV_NUM 32
  45. #define MAX_FUN_NUM 8
  46. #define PCI_MAX_BAR_PER_FUNC 6
  47. /*
  48. * PCI_MEM_SIZE
  49. */
  50. #define FTPCI100_MEM_SIZE(x) (ffs(x) << 24)
  51. /* This definition is used by pci_ftpci_init() */
  52. #define FTPCI100_BRIDGE_VENDORID 0x159b
  53. #define FTPCI100_BRIDGE_DEVICEID 0x4321
  54. void pci_ftpci_init(void);
  55. struct pcibar {
  56. unsigned int size;
  57. unsigned int addr;
  58. };
  59. struct pci_config {
  60. unsigned int bus;
  61. unsigned int dev; /* device */
  62. unsigned int func;
  63. unsigned int pin;
  64. unsigned short v_id; /* vendor id */
  65. unsigned short d_id; /* device id */
  66. struct pcibar bar[PCI_MAX_BAR_PER_FUNC + 1];
  67. };
  68. #endif