Blame view
drivers/rapidio/rio-access.c
4.42 KB
2874c5fd2
|
1 |
// SPDX-License-Identifier: GPL-2.0-or-later |
394b701ce
|
2 3 4 5 6 |
/* * RapidIO configuration space access support * * Copyright 2005 MontaVista Software, Inc. * Matt Porter <mporter@kernel.crashing.org> |
394b701ce
|
7 8 9 10 |
*/ #include <linux/rio.h> #include <linux/module.h> |
bd7bca433
|
11 |
#include <linux/rio_drv.h> |
394b701ce
|
12 |
/* |
394b701ce
|
13 |
* Wrappers for all RIO configuration access functions. They just check |
31d1e130f
|
14 |
* alignment and call the low-level functions pointed to by rio_mport->ops. |
394b701ce
|
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
*/ #define RIO_8_BAD 0 #define RIO_16_BAD (offset & 1) #define RIO_32_BAD (offset & 3) /** * RIO_LOP_READ - Generate rio_local_read_config_* functions * @size: Size of configuration space read (8, 16, 32 bits) * @type: C type of value argument * @len: Length of configuration space read (1, 2, 4 bytes) * * Generates rio_local_read_config_* functions used to access * configuration space registers on the local device. */ #define RIO_LOP_READ(size,type,len) \ int __rio_local_read_config_##size \ (struct rio_mport *mport, u32 offset, type *value) \ { \ int res; \ |
394b701ce
|
35 36 |
u32 data = 0; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ |
ad1e9380b
|
37 |
res = mport->ops->lcread(mport, mport->id, offset, len, &data); \ |
394b701ce
|
38 |
*value = (type)data; \ |
394b701ce
|
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
return res; \ } /** * RIO_LOP_WRITE - Generate rio_local_write_config_* functions * @size: Size of configuration space write (8, 16, 32 bits) * @type: C type of value argument * @len: Length of configuration space write (1, 2, 4 bytes) * * Generates rio_local_write_config_* functions used to access * configuration space registers on the local device. */ #define RIO_LOP_WRITE(size,type,len) \ int __rio_local_write_config_##size \ (struct rio_mport *mport, u32 offset, type value) \ { \ |
394b701ce
|
55 |
if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ |
31d1e130f
|
56 |
return mport->ops->lcwrite(mport, mport->id, offset, len, value);\ |
394b701ce
|
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
} RIO_LOP_READ(8, u8, 1) RIO_LOP_READ(16, u16, 2) RIO_LOP_READ(32, u32, 4) RIO_LOP_WRITE(8, u8, 1) RIO_LOP_WRITE(16, u16, 2) RIO_LOP_WRITE(32, u32, 4) EXPORT_SYMBOL_GPL(__rio_local_read_config_8); EXPORT_SYMBOL_GPL(__rio_local_read_config_16); EXPORT_SYMBOL_GPL(__rio_local_read_config_32); EXPORT_SYMBOL_GPL(__rio_local_write_config_8); EXPORT_SYMBOL_GPL(__rio_local_write_config_16); EXPORT_SYMBOL_GPL(__rio_local_write_config_32); /** * RIO_OP_READ - Generate rio_mport_read_config_* functions * @size: Size of configuration space read (8, 16, 32 bits) * @type: C type of value argument * @len: Length of configuration space read (1, 2, 4 bytes) * * Generates rio_mport_read_config_* functions used to access * configuration space registers on the local device. */ #define RIO_OP_READ(size,type,len) \ int rio_mport_read_config_##size \ (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type *value) \ { \ int res; \ |
394b701ce
|
87 88 |
u32 data = 0; \ if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ |
ad1e9380b
|
89 |
res = mport->ops->cread(mport, mport->id, destid, hopcount, offset, len, &data); \ |
394b701ce
|
90 |
*value = (type)data; \ |
394b701ce
|
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
return res; \ } /** * RIO_OP_WRITE - Generate rio_mport_write_config_* functions * @size: Size of configuration space write (8, 16, 32 bits) * @type: C type of value argument * @len: Length of configuration space write (1, 2, 4 bytes) * * Generates rio_mport_write_config_* functions used to access * configuration space registers on the local device. */ #define RIO_OP_WRITE(size,type,len) \ int rio_mport_write_config_##size \ (struct rio_mport *mport, u16 destid, u8 hopcount, u32 offset, type value) \ { \ |
394b701ce
|
107 |
if (RIO_##size##_BAD) return RIO_BAD_SIZE; \ |
31d1e130f
|
108 109 |
return mport->ops->cwrite(mport, mport->id, destid, hopcount, \ offset, len, value); \ |
394b701ce
|
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
} RIO_OP_READ(8, u8, 1) RIO_OP_READ(16, u16, 2) RIO_OP_READ(32, u32, 4) RIO_OP_WRITE(8, u8, 1) RIO_OP_WRITE(16, u16, 2) RIO_OP_WRITE(32, u32, 4) EXPORT_SYMBOL_GPL(rio_mport_read_config_8); EXPORT_SYMBOL_GPL(rio_mport_read_config_16); EXPORT_SYMBOL_GPL(rio_mport_read_config_32); EXPORT_SYMBOL_GPL(rio_mport_write_config_8); EXPORT_SYMBOL_GPL(rio_mport_write_config_16); EXPORT_SYMBOL_GPL(rio_mport_write_config_32); /** * rio_mport_send_doorbell - Send a doorbell message * * @mport: RIO master port * @destid: RIO device destination ID * @data: Doorbell message data * * Send a doorbell message to a RIO device. The doorbell message * has a 16-bit info field provided by the data argument. */ int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data) { |
31d1e130f
|
138 |
return mport->ops->dsend(mport, mport->id, destid, data); |
394b701ce
|
139 140 141 |
} EXPORT_SYMBOL_GPL(rio_mport_send_doorbell); |