pcie-designware.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. struct pcie_port_info {
  16. u32 cfg0_size;
  17. u32 cfg1_size;
  18. u32 io_size;
  19. u32 mem_size;
  20. phys_addr_t io_bus_addr;
  21. phys_addr_t mem_bus_addr;
  22. };
  23. /*
  24. * Maximum number of MSI IRQs can be 256 per controller. But keep
  25. * it 32 as of now. Probably we will never need more than 32. If needed,
  26. * then increment it in multiple of 32.
  27. */
  28. #define MAX_MSI_IRQS 32
  29. #define MAX_MSI_CTRLS (MAX_MSI_IRQS / 32)
  30. struct pcie_port {
  31. struct device *dev;
  32. u8 root_bus_nr;
  33. void __iomem *dbi_base;
  34. u64 cfg0_base;
  35. void __iomem *va_cfg0_base;
  36. u64 cfg1_base;
  37. void __iomem *va_cfg1_base;
  38. u64 io_base;
  39. u64 mem_base;
  40. struct resource cfg;
  41. struct resource io;
  42. struct resource mem;
  43. struct pcie_port_info config;
  44. int irq;
  45. u32 lanes;
  46. struct pcie_host_ops *ops;
  47. int msi_irq;
  48. struct irq_domain *irq_domain;
  49. unsigned long msi_data;
  50. DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
  51. };
  52. struct pcie_host_ops {
  53. void (*readl_rc)(struct pcie_port *pp,
  54. void __iomem *dbi_base, u32 *val);
  55. void (*writel_rc)(struct pcie_port *pp,
  56. u32 val, void __iomem *dbi_base);
  57. int (*rd_own_conf)(struct pcie_port *pp, int where, int size, u32 *val);
  58. int (*wr_own_conf)(struct pcie_port *pp, int where, int size, u32 val);
  59. int (*link_up)(struct pcie_port *pp);
  60. void (*host_init)(struct pcie_port *pp);
  61. };
  62. int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val);
  63. int dw_pcie_cfg_write(void __iomem *addr, int where, int size, u32 val);
  64. irqreturn_t dw_handle_msi_irq(struct pcie_port *pp);
  65. void dw_pcie_msi_init(struct pcie_port *pp);
  66. int dw_pcie_link_up(struct pcie_port *pp);
  67. void dw_pcie_setup_rc(struct pcie_port *pp);
  68. int dw_pcie_host_init(struct pcie_port *pp);
  69. #endif /* _PCIE_DESIGNWARE_H */