ftpci100.h 1.9 KB

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