1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * RapidIO configuration space access support
5 * Copyright 2005 MontaVista Software, Inc.
6 * Matt Porter <mporter@kernel.crashing.org>
10 #include <linux/module.h>
13 * Wrappers for all RIO configuration access functions. They just check
14 * alignment and call the low-level functions pointed to by rio_mport->ops.
18 #define RIO_16_BAD (offset & 1)
19 #define RIO_32_BAD (offset & 3)
22 * RIO_LOP_READ - Generate rio_local_read_config_* functions
23 * @size: Size of configuration space read (8, 16, 32 bits)
24 * @type: C type of value argument
25 * @len: Length of configuration space read (1, 2, 4 bytes)
27 * Generates rio_local_read_config_* functions used to access
28 * configuration space registers on the local device.
30 #define RIO_LOP_READ(size,type,len) \
31 int __rio_local_read_config_##size \
32 (struct rio_mport *mport, u32 offset, type *value) \
36 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
37 res = mport->ops->lcread(mport, mport->id, offset, len, &data); \
38 *value = (type)data; \
43 * RIO_LOP_WRITE - Generate rio_local_write_config_* functions
44 * @size: Size of configuration space write (8, 16, 32 bits)
45 * @type: C type of value argument
46 * @len: Length of configuration space write (1, 2, 4 bytes)
48 * Generates rio_local_write_config_* functions used to access
49 * configuration space registers on the local device.
51 #define RIO_LOP_WRITE(size,type,len) \
52 int __rio_local_write_config_##size \
53 (struct rio_mport *mport, u32 offset, type value) \
55 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
56 return mport->ops->lcwrite(mport, mport->id, offset, len, value);\
59 RIO_LOP_READ(8, u8
, 1)
60 RIO_LOP_READ(16, u16
, 2)
61 RIO_LOP_READ(32, u32
, 4)
62 RIO_LOP_WRITE(8, u8
, 1)
63 RIO_LOP_WRITE(16, u16
, 2)
64 RIO_LOP_WRITE(32, u32
, 4)
66 EXPORT_SYMBOL_GPL(__rio_local_read_config_8
);
67 EXPORT_SYMBOL_GPL(__rio_local_read_config_16
);
68 EXPORT_SYMBOL_GPL(__rio_local_read_config_32
);
69 EXPORT_SYMBOL_GPL(__rio_local_write_config_8
);
70 EXPORT_SYMBOL_GPL(__rio_local_write_config_16
);
71 EXPORT_SYMBOL_GPL(__rio_local_write_config_32
);
74 * RIO_OP_READ - Generate rio_mport_read_config_* functions
75 * @size: Size of configuration space read (8, 16, 32 bits)
76 * @type: C type of value argument
77 * @len: Length of configuration space read (1, 2, 4 bytes)
79 * Generates rio_mport_read_config_* functions used to access
80 * configuration space registers on the local device.
82 #define RIO_OP_READ(size,type,len) \
83 int rio_mport_read_config_##size \
84 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value) \
88 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
89 res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \
90 *value = (type)data; \
95 * RIO_OP_WRITE - Generate rio_mport_write_config_* functions
96 * @size: Size of configuration space write (8, 16, 32 bits)
97 * @type: C type of value argument
98 * @len: Length of configuration space write (1, 2, 4 bytes)
100 * Generates rio_mport_write_config_* functions used to access
101 * configuration space registers on the local device.
103 #define RIO_OP_WRITE(size,type,len) \
104 int rio_mport_write_config_##size \
105 (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value) \
107 if (RIO_##size##_BAD) return RIO_BAD_SIZE; \
108 return mport->ops->cwrite(mport, mport->id, destid, hopcount, \
109 offset, len, value); \
112 RIO_OP_READ(8, u8
, 1)
113 RIO_OP_READ(16, u16
, 2)
114 RIO_OP_READ(32, u32
, 4)
115 RIO_OP_WRITE(8, u8
, 1)
116 RIO_OP_WRITE(16, u16
, 2)
117 RIO_OP_WRITE(32, u32
, 4)
119 EXPORT_SYMBOL_GPL(rio_mport_read_config_8
);
120 EXPORT_SYMBOL_GPL(rio_mport_read_config_16
);
121 EXPORT_SYMBOL_GPL(rio_mport_read_config_32
);
122 EXPORT_SYMBOL_GPL(rio_mport_write_config_8
);
123 EXPORT_SYMBOL_GPL(rio_mport_write_config_16
);
124 EXPORT_SYMBOL_GPL(rio_mport_write_config_32
);
127 * rio_mport_send_doorbell - Send a doorbell message
129 * @mport: RIO master port
130 * @destid: RIO device destination ID
131 * @data: Doorbell message data
133 * Send a doorbell message to a RIO device. The doorbell message
134 * has a 16-bit info field provided by the data argument.
136 int rio_mport_send_doorbell(struct rio_mport
*mport
, u16 destid
, u16 data
)
138 return mport
->ops
->dsend(mport
, mport
->id
, destid
, data
);
141 EXPORT_SYMBOL_GPL(rio_mport_send_doorbell
);