0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include <linux/types.h>
0036
0037 #define MTHCA_RD_DOORBELL 0x00
0038 #define MTHCA_SEND_DOORBELL 0x10
0039 #define MTHCA_RECEIVE_DOORBELL 0x18
0040 #define MTHCA_CQ_DOORBELL 0x20
0041 #define MTHCA_EQ_DOORBELL 0x28
0042
0043 #if BITS_PER_LONG == 64
0044
0045
0046
0047
0048
0049
0050 #define MTHCA_DECLARE_DOORBELL_LOCK(name)
0051 #define MTHCA_INIT_DOORBELL_LOCK(ptr) do { } while (0)
0052 #define MTHCA_GET_DOORBELL_LOCK(ptr) (NULL)
0053
0054 static inline void mthca_write64_raw(__be64 val, void __iomem *dest)
0055 {
0056 __raw_writeq((__force u64) val, dest);
0057 }
0058
0059 static inline void mthca_write64(u32 hi, u32 lo, void __iomem *dest,
0060 spinlock_t *doorbell_lock)
0061 {
0062 __raw_writeq((__force u64) cpu_to_be64((u64) hi << 32 | lo), dest);
0063 }
0064
0065 static inline void mthca_write_db_rec(__be32 val[2], __be32 *db)
0066 {
0067 *(u64 *) db = *(u64 *) val;
0068 }
0069
0070 #else
0071
0072
0073
0074
0075
0076
0077
0078 #define MTHCA_DECLARE_DOORBELL_LOCK(name) spinlock_t name;
0079 #define MTHCA_INIT_DOORBELL_LOCK(ptr) spin_lock_init(ptr)
0080 #define MTHCA_GET_DOORBELL_LOCK(ptr) (ptr)
0081
0082 static inline void mthca_write64_raw(__be64 val, void __iomem *dest)
0083 {
0084 __raw_writel(((__force u32 *) &val)[0], dest);
0085 __raw_writel(((__force u32 *) &val)[1], dest + 4);
0086 }
0087
0088 static inline void mthca_write64(u32 hi, u32 lo, void __iomem *dest,
0089 spinlock_t *doorbell_lock)
0090 {
0091 unsigned long flags;
0092
0093 hi = (__force u32) cpu_to_be32(hi);
0094 lo = (__force u32) cpu_to_be32(lo);
0095
0096 spin_lock_irqsave(doorbell_lock, flags);
0097 __raw_writel(hi, dest);
0098 __raw_writel(lo, dest + 4);
0099 spin_unlock_irqrestore(doorbell_lock, flags);
0100 }
0101
0102 static inline void mthca_write_db_rec(__be32 val[2], __be32 *db)
0103 {
0104 db[0] = val[0];
0105 wmb();
0106 db[1] = val[1];
0107 }
0108
0109 #endif