pcie-designware.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. spinlock_t conf_lock;
  41. struct resource cfg;
  42. struct resource io;
  43. struct resource mem;
  44. struct pcie_port_info config;
  45. int irq;
  46. u32 lanes;
  47. struct pcie_host_ops *ops;
  48. int msi_irq;
  49. struct irq_domain *irq_domain;
  50. unsigned long msi_data;
  51. DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS);
  52. };
  53. struct pcie_host_ops {
  54. void (*readl_rc)(struct pcie_port *pp,
  55. void __iomem *dbi_base, u32 *val);
  56. void (*writel_rc)(struct pcie_port *pp,
  57. u32 val, void __iomem *dbi_base);
  58. int (*rd_own_conf)(struct pcie_port *pp, int where, int size, u32 *val);
  59. int (*wr_own_conf)(struct pcie_port *pp, int where, int size, u32 val);
  60. int (*link_up)(struct pcie_port *pp);
  61. void (*host_init)(struct pcie_port *pp);
  62. };
  63. int cfg_read(void __iomem *addr, int where, int size, u32 *val);
  64. int cfg_write(void __iomem *addr, int where, int size, u32 val);
  65. void dw_handle_msi_irq(struct pcie_port *pp);
  66. void dw_pcie_msi_init(struct pcie_port *pp);
  67. int dw_pcie_link_up(struct pcie_port *pp);
  68. void dw_pcie_setup_rc(struct pcie_port *pp);
  69. int dw_pcie_host_init(struct pcie_port *pp);
  70. #endif /* _PCIE_DESIGNWARE_H */