aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Porter <mporter@kernel.crashing.org>2005-11-07 04:00:20 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 10:53:47 -0500
commit6978bbc097c2f665c336927a9d56ae39ef75fa56 (patch)
tree541673cd413025c09b52984c5dc0333133c46a71
parent2b0c28d7f8846f80a436093e906f5175d1fa8f55 (diff)
[PATCH] rapidio: message interface updates
Updates the RIO messaging interface to pass a device instance into the event registeration and callbacks. Signed-off-by: Matt Porter <mporter@kernel.crashing.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/ppc/syslib/ppc85xx_rio.c16
-rw-r--r--drivers/rapidio/rio-sysfs.c4
-rw-r--r--drivers/rapidio/rio.c25
-rw-r--r--include/linux/rio.h10
-rw-r--r--include/linux/rio_drv.h12
5 files changed, 41 insertions, 26 deletions
diff --git a/arch/ppc/syslib/ppc85xx_rio.c b/arch/ppc/syslib/ppc85xx_rio.c
index 9d09c2715e0a..297f3b549177 100644
--- a/arch/ppc/syslib/ppc85xx_rio.c
+++ b/arch/ppc/syslib/ppc85xx_rio.c
@@ -135,6 +135,7 @@ static struct rio_msg_tx_ring {
135 dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE]; 135 dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
136 int tx_slot; 136 int tx_slot;
137 int size; 137 int size;
138 void *dev_id;
138} msg_tx_ring; 139} msg_tx_ring;
139 140
140static struct rio_msg_rx_ring { 141static struct rio_msg_rx_ring {
@@ -143,6 +144,7 @@ static struct rio_msg_rx_ring {
143 void *virt_buffer[RIO_MAX_RX_RING_SIZE]; 144 void *virt_buffer[RIO_MAX_RX_RING_SIZE];
144 int rx_slot; 145 int rx_slot;
145 int size; 146 int size;
147 void *dev_id;
146} msg_rx_ring; 148} msg_rx_ring;
147 149
148/** 150/**
@@ -376,7 +378,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
376 if (osr & RIO_MSG_OSR_EOMI) { 378 if (osr & RIO_MSG_OSR_EOMI) {
377 u32 dqp = in_be32((void *)&msg_regs->odqdpar); 379 u32 dqp = in_be32((void *)&msg_regs->odqdpar);
378 int slot = (dqp - msg_tx_ring.phys) >> 5; 380 int slot = (dqp - msg_tx_ring.phys) >> 5;
379 port->outb_msg[0].mcback(port, -1, slot); 381 port->outb_msg[0].mcback(port, msg_tx_ring.dev_id, -1, slot);
380 382
381 /* Ack the end-of-message interrupt */ 383 /* Ack the end-of-message interrupt */
382 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI); 384 out_be32((void *)&msg_regs->osr, RIO_MSG_OSR_EOMI);
@@ -389,6 +391,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
389/** 391/**
390 * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox 392 * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox
391 * @mport: Master port implementing the outbound message unit 393 * @mport: Master port implementing the outbound message unit
394 * @dev_id: Device specific pointer to pass on event
392 * @mbox: Mailbox to open 395 * @mbox: Mailbox to open
393 * @entries: Number of entries in the outbound mailbox ring 396 * @entries: Number of entries in the outbound mailbox ring
394 * 397 *
@@ -396,7 +399,7 @@ mpc85xx_rio_tx_handler(int irq, void *dev_instance, struct pt_regs *regs)
396 * and enables the outbound message unit. Returns %0 on success and 399 * and enables the outbound message unit. Returns %0 on success and
397 * %-EINVAL or %-ENOMEM on failure. 400 * %-EINVAL or %-ENOMEM on failure.
398 */ 401 */
399int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries) 402int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
400{ 403{
401 int i, j, rc = 0; 404 int i, j, rc = 0;
402 405
@@ -407,6 +410,7 @@ int rio_open_outb_mbox(struct rio_mport *mport, int mbox, int entries)
407 } 410 }
408 411
409 /* Initialize shadow copy ring */ 412 /* Initialize shadow copy ring */
413 msg_tx_ring.dev_id = dev_id;
410 msg_tx_ring.size = entries; 414 msg_tx_ring.size = entries;
411 415
412 for (i = 0; i < msg_tx_ring.size; i++) { 416 for (i = 0; i < msg_tx_ring.size; i++) {
@@ -541,7 +545,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
541 * make the callback with an unknown/invalid mailbox number 545 * make the callback with an unknown/invalid mailbox number
542 * argument. 546 * argument.
543 */ 547 */
544 port->inb_msg[0].mcback(port, -1, -1); 548 port->inb_msg[0].mcback(port, msg_rx_ring.dev_id, -1, -1);
545 549
546 /* Ack the queueing interrupt */ 550 /* Ack the queueing interrupt */
547 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI); 551 out_be32((void *)&msg_regs->isr, RIO_MSG_ISR_DIQI);
@@ -554,6 +558,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
554/** 558/**
555 * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox 559 * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox
556 * @mport: Master port implementing the inbound message unit 560 * @mport: Master port implementing the inbound message unit
561 * @dev_id: Device specific pointer to pass on event
557 * @mbox: Mailbox to open 562 * @mbox: Mailbox to open
558 * @entries: Number of entries in the inbound mailbox ring 563 * @entries: Number of entries in the inbound mailbox ring
559 * 564 *
@@ -561,7 +566,7 @@ mpc85xx_rio_rx_handler(int irq, void *dev_instance, struct pt_regs *regs)
561 * and enables the inbound message unit. Returns %0 on success 566 * and enables the inbound message unit. Returns %0 on success
562 * and %-EINVAL or %-ENOMEM on failure. 567 * and %-EINVAL or %-ENOMEM on failure.
563 */ 568 */
564int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries) 569int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
565{ 570{
566 int i, rc = 0; 571 int i, rc = 0;
567 572
@@ -572,6 +577,7 @@ int rio_open_inb_mbox(struct rio_mport *mport, int mbox, int entries)
572 } 577 }
573 578
574 /* Initialize client buffer ring */ 579 /* Initialize client buffer ring */
580 msg_rx_ring.dev_id = dev_id;
575 msg_rx_ring.size = entries; 581 msg_rx_ring.size = entries;
576 msg_rx_ring.rx_slot = 0; 582 msg_rx_ring.rx_slot = 0;
577 for (i = 0; i < msg_rx_ring.size; i++) 583 for (i = 0; i < msg_rx_ring.size; i++)
@@ -777,7 +783,7 @@ mpc85xx_rio_dbell_handler(int irq, void *dev_instance, struct pt_regs *regs)
777 } 783 }
778 } 784 }
779 if (found) { 785 if (found) {
780 dbell->dinb(port, DBELL_SID(dmsg), DBELL_TID(dmsg), 786 dbell->dinb(port, dbell->dev_id, DBELL_SID(dmsg), DBELL_TID(dmsg),
781 DBELL_INF(dmsg)); 787 DBELL_INF(dmsg));
782 } else { 788 } else {
783 pr_debug 789 pr_debug
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 73218a37506d..30a11436e241 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -21,7 +21,7 @@
21/* Sysfs support */ 21/* Sysfs support */
22#define rio_config_attr(field, format_string) \ 22#define rio_config_attr(field, format_string) \
23static ssize_t \ 23static ssize_t \
24 field##_show(struct device *dev, char *buf) \ 24field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
25{ \ 25{ \
26 struct rio_dev *rdev = to_rio_dev(dev); \ 26 struct rio_dev *rdev = to_rio_dev(dev); \
27 \ 27 \
@@ -35,7 +35,7 @@ rio_config_attr(asm_did, "0x%04x\n");
35rio_config_attr(asm_vid, "0x%04x\n"); 35rio_config_attr(asm_vid, "0x%04x\n");
36rio_config_attr(asm_rev, "0x%04x\n"); 36rio_config_attr(asm_rev, "0x%04x\n");
37 37
38static ssize_t routes_show(struct device *dev, char *buf) 38static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
39{ 39{
40 struct rio_dev *rdev = to_rio_dev(dev); 40 struct rio_dev *rdev = to_rio_dev(dev);
41 char *str = buf; 41 char *str = buf;
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index adc299e2b07e..3ca1011ceaac 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -48,6 +48,7 @@ u16 rio_local_get_device_id(struct rio_mport *port)
48/** 48/**
49 * rio_request_inb_mbox - request inbound mailbox service 49 * rio_request_inb_mbox - request inbound mailbox service
50 * @mport: RIO master port from which to allocate the mailbox resource 50 * @mport: RIO master port from which to allocate the mailbox resource
51 * @dev_id: Device specific pointer to pass on event
51 * @mbox: Mailbox number to claim 52 * @mbox: Mailbox number to claim
52 * @entries: Number of entries in inbound mailbox queue 53 * @entries: Number of entries in inbound mailbox queue
53 * @minb: Callback to execute when inbound message is received 54 * @minb: Callback to execute when inbound message is received
@@ -56,9 +57,10 @@ u16 rio_local_get_device_id(struct rio_mport *port)
56 * a callback function to the resource. Returns %0 on success. 57 * a callback function to the resource. Returns %0 on success.
57 */ 58 */
58int rio_request_inb_mbox(struct rio_mport *mport, 59int rio_request_inb_mbox(struct rio_mport *mport,
60 void *dev_id,
59 int mbox, 61 int mbox,
60 int entries, 62 int entries,
61 void (*minb) (struct rio_mport * mport, int mbox, 63 void (*minb) (struct rio_mport * mport, void *dev_id, int mbox,
62 int slot)) 64 int slot))
63{ 65{
64 int rc = 0; 66 int rc = 0;
@@ -81,7 +83,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
81 /* Hook the inbound message callback */ 83 /* Hook the inbound message callback */
82 mport->inb_msg[mbox].mcback = minb; 84 mport->inb_msg[mbox].mcback = minb;
83 85
84 rc = rio_open_inb_mbox(mport, mbox, entries); 86 rc = rio_open_inb_mbox(mport, dev_id, mbox, entries);
85 } else 87 } else
86 rc = -ENOMEM; 88 rc = -ENOMEM;
87 89
@@ -108,6 +110,7 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
108/** 110/**
109 * rio_request_outb_mbox - request outbound mailbox service 111 * rio_request_outb_mbox - request outbound mailbox service
110 * @mport: RIO master port from which to allocate the mailbox resource 112 * @mport: RIO master port from which to allocate the mailbox resource
113 * @dev_id: Device specific pointer to pass on event
111 * @mbox: Mailbox number to claim 114 * @mbox: Mailbox number to claim
112 * @entries: Number of entries in outbound mailbox queue 115 * @entries: Number of entries in outbound mailbox queue
113 * @moutb: Callback to execute when outbound message is sent 116 * @moutb: Callback to execute when outbound message is sent
@@ -116,10 +119,10 @@ int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
116 * a callback function to the resource. Returns 0 on success. 119 * a callback function to the resource. Returns 0 on success.
117 */ 120 */
118int rio_request_outb_mbox(struct rio_mport *mport, 121int rio_request_outb_mbox(struct rio_mport *mport,
122 void *dev_id,
119 int mbox, 123 int mbox,
120 int entries, 124 int entries,
121 void (*moutb) (struct rio_mport * mport, int mbox, 125 void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot))
122 int slot))
123{ 126{
124 int rc = 0; 127 int rc = 0;
125 128
@@ -141,7 +144,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
141 /* Hook the inbound message callback */ 144 /* Hook the inbound message callback */
142 mport->outb_msg[mbox].mcback = moutb; 145 mport->outb_msg[mbox].mcback = moutb;
143 146
144 rc = rio_open_outb_mbox(mport, mbox, entries); 147 rc = rio_open_outb_mbox(mport, dev_id, mbox, entries);
145 } else 148 } else
146 rc = -ENOMEM; 149 rc = -ENOMEM;
147 150
@@ -168,6 +171,7 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
168/** 171/**
169 * rio_setup_inb_dbell - bind inbound doorbell callback 172 * rio_setup_inb_dbell - bind inbound doorbell callback
170 * @mport: RIO master port to bind the doorbell callback 173 * @mport: RIO master port to bind the doorbell callback
174 * @dev_id: Device specific pointer to pass on event
171 * @res: Doorbell message resource 175 * @res: Doorbell message resource
172 * @dinb: Callback to execute when doorbell is received 176 * @dinb: Callback to execute when doorbell is received
173 * 177 *
@@ -176,8 +180,8 @@ int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
176 * satisfied. 180 * satisfied.
177 */ 181 */
178static int 182static int
179rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res, 183rio_setup_inb_dbell(struct rio_mport *mport, void *dev_id, struct resource *res,
180 void (*dinb) (struct rio_mport * mport, u16 src, u16 dst, 184 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src, u16 dst,
181 u16 info)) 185 u16 info))
182{ 186{
183 int rc = 0; 187 int rc = 0;
@@ -190,6 +194,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
190 194
191 dbell->res = res; 195 dbell->res = res;
192 dbell->dinb = dinb; 196 dbell->dinb = dinb;
197 dbell->dev_id = dev_id;
193 198
194 list_add_tail(&dbell->node, &mport->dbells); 199 list_add_tail(&dbell->node, &mport->dbells);
195 200
@@ -200,6 +205,7 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
200/** 205/**
201 * rio_request_inb_dbell - request inbound doorbell message service 206 * rio_request_inb_dbell - request inbound doorbell message service
202 * @mport: RIO master port from which to allocate the doorbell resource 207 * @mport: RIO master port from which to allocate the doorbell resource
208 * @dev_id: Device specific pointer to pass on event
203 * @start: Doorbell info range start 209 * @start: Doorbell info range start
204 * @end: Doorbell info range end 210 * @end: Doorbell info range end
205 * @dinb: Callback to execute when doorbell is received 211 * @dinb: Callback to execute when doorbell is received
@@ -209,9 +215,10 @@ rio_setup_inb_dbell(struct rio_mport *mport, struct resource *res,
209 * has been satisfied. 215 * has been satisfied.
210 */ 216 */
211int rio_request_inb_dbell(struct rio_mport *mport, 217int rio_request_inb_dbell(struct rio_mport *mport,
218 void *dev_id,
212 u16 start, 219 u16 start,
213 u16 end, 220 u16 end,
214 void (*dinb) (struct rio_mport * mport, u16 src, 221 void (*dinb) (struct rio_mport * mport, void *dev_id, u16 src,
215 u16 dst, u16 info)) 222 u16 dst, u16 info))
216{ 223{
217 int rc = 0; 224 int rc = 0;
@@ -230,7 +237,7 @@ int rio_request_inb_dbell(struct rio_mport *mport,
230 } 237 }
231 238
232 /* Hook the doorbell callback */ 239 /* Hook the doorbell callback */
233 rc = rio_setup_inb_dbell(mport, res, dinb); 240 rc = rio_setup_inb_dbell(mport, dev_id, res, dinb);
234 } else 241 } else
235 rc = -ENOMEM; 242 rc = -ENOMEM;
236 243
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 5c29f2f477c2..c7e907faae9c 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -132,7 +132,7 @@ struct rio_dev {
132 */ 132 */
133struct rio_msg { 133struct rio_msg {
134 struct resource *res; 134 struct resource *res;
135 void (*mcback) (struct rio_mport * mport, int mbox, int slot); 135 void (*mcback) (struct rio_mport * mport, void *dev_id, int mbox, int slot);
136}; 136};
137 137
138/** 138/**
@@ -140,11 +140,13 @@ struct rio_msg {
140 * @node: Node in list of doorbell events 140 * @node: Node in list of doorbell events
141 * @res: Doorbell resource 141 * @res: Doorbell resource
142 * @dinb: Doorbell event callback 142 * @dinb: Doorbell event callback
143 * @dev_id: Device specific pointer to pass on event
143 */ 144 */
144struct rio_dbell { 145struct rio_dbell {
145 struct list_head node; 146 struct list_head node;
146 struct resource *res; 147 struct resource *res;
147 void (*dinb) (struct rio_mport * mport, u16 src, u16 dst, u16 info); 148 void (*dinb) (struct rio_mport *mport, void *dev_id, u16 src, u16 dst, u16 info);
149 void *dev_id;
148}; 150};
149 151
150/** 152/**
@@ -314,9 +316,9 @@ extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int,
314 void *, size_t); 316 void *, size_t);
315extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *); 317extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *);
316extern void *rio_hw_get_inb_message(struct rio_mport *, int); 318extern void *rio_hw_get_inb_message(struct rio_mport *, int);
317extern int rio_open_inb_mbox(struct rio_mport *, int, int); 319extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
318extern void rio_close_inb_mbox(struct rio_mport *, int); 320extern void rio_close_inb_mbox(struct rio_mport *, int);
319extern int rio_open_outb_mbox(struct rio_mport *, int, int); 321extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
320extern void rio_close_outb_mbox(struct rio_mport *, int); 322extern void rio_close_outb_mbox(struct rio_mport *, int);
321 323
322#endif /* __KERNEL__ */ 324#endif /* __KERNEL__ */
diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h
index 7483dfc0dfa3..3bd7cce19e26 100644
--- a/include/linux/rio_drv.h
+++ b/include/linux/rio_drv.h
@@ -348,8 +348,8 @@ static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end)
348 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID 348 .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID
349 349
350/* Mailbox management */ 350/* Mailbox management */
351extern int rio_request_outb_mbox(struct rio_mport *, int, int, 351extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int,
352 void (*)(struct rio_mport *, int, int)); 352 void (*)(struct rio_mport *, void *,int, int));
353extern int rio_release_outb_mbox(struct rio_mport *, int); 353extern int rio_release_outb_mbox(struct rio_mport *, int);
354 354
355/** 355/**
@@ -370,8 +370,8 @@ static inline int rio_add_outb_message(struct rio_mport *mport,
370 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len); 370 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len);
371} 371}
372 372
373extern int rio_request_inb_mbox(struct rio_mport *, int, int, 373extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
374 void (*)(struct rio_mport *, int, int)); 374 void (*)(struct rio_mport *, void *, int, int));
375extern int rio_release_inb_mbox(struct rio_mport *, int); 375extern int rio_release_inb_mbox(struct rio_mport *, int);
376 376
377/** 377/**
@@ -403,8 +403,8 @@ static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
403} 403}
404 404
405/* Doorbell management */ 405/* Doorbell management */
406extern int rio_request_inb_dbell(struct rio_mport *, u16, u16, 406extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16,
407 void (*)(struct rio_mport *, u16, u16, u16)); 407 void (*)(struct rio_mport *, void *, u16, u16, u16));
408extern int rio_release_inb_dbell(struct rio_mport *, u16, u16); 408extern int rio_release_inb_dbell(struct rio_mport *, u16, u16);
409extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16); 409extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16);
410extern int rio_release_outb_dbell(struct rio_dev *, struct resource *); 410extern int rio_release_outb_dbell(struct rio_dev *, struct resource *);