pcie-designware.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * Synopsys Designware PCIe host controller driver
  3. *
  4. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  5. * http://www.samsung.com
  6. *
  7. * Author: Jingoo Han <jg1.han@samsung.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef _PCIE_DESIGNWARE_H
  14. #define _PCIE_DESIGNWARE_H
  15. /*
  16. * Maximum number of MSI IRQs can be 256 per controller. But keep
  17. * it 32 as of now. Probably we will never need more than 32. If needed,
  18. * then increment it in multiple of 32.
  19. */
  20. #define MAX_MSI_IRQS 32
  21. #define MAX_MSI_CTRLS (MAX_MSI_IRQS / 32)
  22. struct pcie_port {
  23. struct device *dev;
  24. u8 root_bus_nr;
  25. void __iomem *dbi_base;
  26. u64 cfg0_base;
  27. void __iomem *va_cfg0_base;
  28. u32 cfg0_size;
  29. u64 cfg1_base;
  30. void __iomem *va_cfg1_base;
  31. u32 cfg1_size;
  32. resource_size_t io_base;
  33. phys_addr_t io_bus_addr;
  34. u32 io_size;
  35. u64 mem_base;
  36. phys_addr_t mem_bus_addr;
  37. u32 mem_size;
  38. struct resource *cfg;
  39. struct resource *io;
  40. struct resource *mem;
  41. struct resource *busn;
  42. int irq;
  43. u32 lanes;
  44. struct pcie_host_ops *ops;
  45. int msi_irq;
  46. struct irq_domain *irq_domain;
  47. unsigned long msi_data;
  48. DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
  49. };
  50. struct pcie_host_ops {
  51. void (*readl_rc)(struct pcie_port *pp,
  52. void __iomem *dbi_base, u32 *val);
  53. void (*writel_rc)(struct pcie_port *pp,
  54. u32 val, void __iomem *dbi_base);
  55. int (*rd_own_conf)(struct pcie_port *pp, int where, int size, u32 *val);
  56. int (*wr_own_conf)(struct pcie_port *pp, int where, int size, u32 val);
  57. int (*rd_other_conf)(struct pcie_port *pp, struct pci_bus *bus,
  58. unsigned int devfn, int where, int size, u32 *val);
  59. int (*wr_other_conf)(struct pcie_port *pp, struct pci_bus *bus,
  60. unsigned int devfn, int where, int size, u32 val);
  61. int (*link_up)(struct pcie_port *pp);
  62. void (*host_init)(struct pcie_port *pp);
  63. void (*msi_set_irq)(struct pcie_port *pp, int irq);
  64. void (*msi_clear_irq)(struct pcie_port *pp, int irq);
  65. phys_addr_t (*get_msi_addr)(struct pcie_port *pp);
  66. u32 (*get_msi_data)(struct pcie_port *pp, int pos);
  67. void (*scan_bus)(struct pcie_port *pp);
  68. int (*msi_host_init)(struct pcie_port *pp, struct msi_controller *chip);
  69. };
  70. int dw_pcie_cfg_read(void __iomem *addr, int size, u32 *val);
  71. int dw_pcie_cfg_write(void __iomem *addr, int size, u32 val);
  72. irqreturn_t dw_handle_msi_irq(struct pcie_port *pp);
  73. void dw_pcie_msi_init(struct pcie_port *pp);
  74. int dw_pcie_link_up(struct pcie_port *pp);
  75. void dw_pcie_setup_rc(struct pcie_port *pp);
  76. int dw_pcie_host_init(struct pcie_port *pp);
  77. #endif /* _PCIE_DESIGNWARE_H */