fsl_rio.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Freescale MPC85xx/MPC86xx RapidIO support
  3. *
  4. * Copyright 2009 Sysgo AG
  5. * Thomas Moll <thomas.moll@sysgo.com>
  6. * - fixed maintenance access routines, check for aligned access
  7. *
  8. * Copyright 2009 Integrated Device Technology, Inc.
  9. * Alex Bounine <alexandre.bounine@idt.com>
  10. * - Added Port-Write message handling
  11. * - Added Machine Check exception handling
  12. *
  13. * Copyright (C) 2007, 2008, 2010, 2011 Freescale Semiconductor, Inc.
  14. * Zhang Wei <wei.zhang@freescale.com>
  15. * Lian Minghuan-B31939 <Minghuan.Lian@freescale.com>
  16. * Liu Gang <Gang.Liu@freescale.com>
  17. *
  18. * Copyright 2005 MontaVista Software, Inc.
  19. * Matt Porter <mporter@kernel.crashing.org>
  20. *
  21. * This program is free software; you can redistribute it and/or modify it
  22. * under the terms of the GNU General Public License as published by the
  23. * Free Software Foundation; either version 2 of the License, or (at your
  24. * option) any later version.
  25. */
  26. #ifndef __FSL_RIO_H
  27. #define __FSL_RIO_H
  28. #include <linux/rio.h>
  29. #include <linux/rio_drv.h>
  30. #include <linux/kfifo.h>
  31. #define RIO_REGS_WIN(mport) (((struct rio_priv *)(mport->priv))->regs_win)
  32. #define RIO_MAINT_WIN_SIZE 0x400000
  33. #define RIO_LTLEDCSR 0x0608
  34. #define DOORBELL_ROWAR_EN 0x80000000
  35. #define DOORBELL_ROWAR_TFLOWLV 0x08000000 /* highest priority level */
  36. #define DOORBELL_ROWAR_PCI 0x02000000 /* PCI window */
  37. #define DOORBELL_ROWAR_NREAD 0x00040000 /* NREAD */
  38. #define DOORBELL_ROWAR_MAINTRD 0x00070000 /* maintenance read */
  39. #define DOORBELL_ROWAR_RES 0x00002000 /* wrtpy: reserverd */
  40. #define DOORBELL_ROWAR_MAINTWD 0x00007000
  41. #define DOORBELL_ROWAR_SIZE 0x0000000b /* window size is 4k */
  42. #define RIO_ATMU_REGS_PORT1_OFFSET 0x10c00
  43. #define RIO_ATMU_REGS_PORT2_OFFSET 0x10e00
  44. #define RIO_S_DBELL_REGS_OFFSET 0x13400
  45. #define RIO_S_PW_REGS_OFFSET 0x134e0
  46. #define RIO_ATMU_REGS_DBELL_OFFSET 0x10C40
  47. #define MAX_MSG_UNIT_NUM 2
  48. #define MAX_PORT_NUM 4
  49. struct rio_atmu_regs {
  50. u32 rowtar;
  51. u32 rowtear;
  52. u32 rowbar;
  53. u32 pad1;
  54. u32 rowar;
  55. u32 pad2[3];
  56. };
  57. struct rio_dbell_ring {
  58. void *virt;
  59. dma_addr_t phys;
  60. };
  61. struct rio_port_write_msg {
  62. void *virt;
  63. dma_addr_t phys;
  64. u32 msg_count;
  65. u32 err_count;
  66. u32 discard_count;
  67. };
  68. struct fsl_rio_dbell {
  69. struct rio_mport *mport[MAX_PORT_NUM];
  70. struct device *dev;
  71. struct rio_dbell_regs __iomem *dbell_regs;
  72. struct rio_dbell_ring dbell_ring;
  73. int bellirq;
  74. };
  75. struct fsl_rio_pw {
  76. struct device *dev;
  77. struct rio_pw_regs __iomem *pw_regs;
  78. struct rio_port_write_msg port_write_msg;
  79. int pwirq;
  80. struct work_struct pw_work;
  81. struct kfifo pw_fifo;
  82. spinlock_t pw_fifo_lock;
  83. };
  84. struct rio_priv {
  85. struct device *dev;
  86. void __iomem *regs_win;
  87. struct rio_atmu_regs __iomem *atmu_regs;
  88. struct rio_atmu_regs __iomem *maint_atmu_regs;
  89. void __iomem *maint_win;
  90. void *rmm_handle; /* RapidIO message manager(unit) Handle */
  91. };
  92. extern void __iomem *rio_regs_win;
  93. extern void __iomem *rmu_regs_win;
  94. extern resource_size_t rio_law_start;
  95. extern struct fsl_rio_dbell *dbell;
  96. extern struct fsl_rio_pw *pw;
  97. extern int fsl_rio_setup_rmu(struct rio_mport *mport,
  98. struct device_node *node);
  99. extern int fsl_rio_port_write_init(struct fsl_rio_pw *pw);
  100. extern int fsl_rio_pw_enable(struct rio_mport *mport, int enable);
  101. extern void fsl_rio_port_error_handler(int offset);
  102. extern int fsl_rio_doorbell_init(struct fsl_rio_dbell *dbell);
  103. extern int fsl_rio_doorbell_send(struct rio_mport *mport,
  104. int index, u16 destid, u16 data);
  105. extern int fsl_add_outb_message(struct rio_mport *mport,
  106. struct rio_dev *rdev,
  107. int mbox, void *buffer, size_t len);
  108. extern int fsl_open_outb_mbox(struct rio_mport *mport,
  109. void *dev_id, int mbox, int entries);
  110. extern void fsl_close_outb_mbox(struct rio_mport *mport, int mbox);
  111. extern int fsl_open_inb_mbox(struct rio_mport *mport,
  112. void *dev_id, int mbox, int entries);
  113. extern void fsl_close_inb_mbox(struct rio_mport *mport, int mbox);
  114. extern int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf);
  115. extern void *fsl_get_inb_message(struct rio_mport *mport, int mbox);
  116. #endif