aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c52
-rw-r--r--drivers/rapidio/rio.c38
-rw-r--r--include/linux/rio.h23
-rw-r--r--include/linux/rio_drv.h7
4 files changed, 75 insertions, 45 deletions
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 3eff2c3a9ad5..f95cb5636d19 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -482,7 +482,7 @@ fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid,
482} 482}
483 483
484/** 484/**
485 * rio_hw_add_outb_message - Add message to the MPC85xx outbound message queue 485 * fsl_add_outb_message - Add message to the MPC85xx outbound message queue
486 * @mport: Master port with outbound message queue 486 * @mport: Master port with outbound message queue
487 * @rdev: Target of outbound message 487 * @rdev: Target of outbound message
488 * @mbox: Outbound mailbox 488 * @mbox: Outbound mailbox
@@ -492,8 +492,8 @@ fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid,
492 * Adds the @buffer message to the MPC85xx outbound message queue. Returns 492 * Adds the @buffer message to the MPC85xx outbound message queue. Returns
493 * %0 on success or %-EINVAL on failure. 493 * %0 on success or %-EINVAL on failure.
494 */ 494 */
495int 495static int
496rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, 496fsl_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
497 void *buffer, size_t len) 497 void *buffer, size_t len)
498{ 498{
499 struct rio_priv *priv = mport->priv; 499 struct rio_priv *priv = mport->priv;
@@ -502,9 +502,8 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
502 + priv->msg_tx_ring.tx_slot; 502 + priv->msg_tx_ring.tx_slot;
503 int ret = 0; 503 int ret = 0;
504 504
505 pr_debug 505 pr_debug("RIO: fsl_add_outb_message(): destid %4.4x mbox %d buffer " \
506 ("RIO: rio_hw_add_outb_message(): destid %4.4x mbox %d buffer %8.8x len %8.8x\n", 506 "%8.8x len %8.8x\n", rdev->destid, mbox, (int)buffer, len);
507 rdev->destid, mbox, (int)buffer, len);
508 507
509 if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) { 508 if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) {
510 ret = -EINVAL; 509 ret = -EINVAL;
@@ -554,8 +553,6 @@ rio_hw_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
554 return ret; 553 return ret;
555} 554}
556 555
557EXPORT_SYMBOL_GPL(rio_hw_add_outb_message);
558
559/** 556/**
560 * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler 557 * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler
561 * @irq: Linux interrupt number 558 * @irq: Linux interrupt number
@@ -600,7 +597,7 @@ fsl_rio_tx_handler(int irq, void *dev_instance)
600} 597}
601 598
602/** 599/**
603 * rio_open_outb_mbox - Initialize MPC85xx outbound mailbox 600 * fsl_open_outb_mbox - Initialize MPC85xx outbound mailbox
604 * @mport: Master port implementing the outbound message unit 601 * @mport: Master port implementing the outbound message unit
605 * @dev_id: Device specific pointer to pass on event 602 * @dev_id: Device specific pointer to pass on event
606 * @mbox: Mailbox to open 603 * @mbox: Mailbox to open
@@ -610,7 +607,8 @@ fsl_rio_tx_handler(int irq, void *dev_instance)
610 * and enables the outbound message unit. Returns %0 on success and 607 * and enables the outbound message unit. Returns %0 on success and
611 * %-EINVAL or %-ENOMEM on failure. 608 * %-EINVAL or %-ENOMEM on failure.
612 */ 609 */
613int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 610static int
611fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
614{ 612{
615 int i, j, rc = 0; 613 int i, j, rc = 0;
616 struct rio_priv *priv = mport->priv; 614 struct rio_priv *priv = mport->priv;
@@ -706,14 +704,14 @@ int rio_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entr
706} 704}
707 705
708/** 706/**
709 * rio_close_outb_mbox - Shut down MPC85xx outbound mailbox 707 * fsl_close_outb_mbox - Shut down MPC85xx outbound mailbox
710 * @mport: Master port implementing the outbound message unit 708 * @mport: Master port implementing the outbound message unit
711 * @mbox: Mailbox to close 709 * @mbox: Mailbox to close
712 * 710 *
713 * Disables the outbound message unit, free all buffers, and 711 * Disables the outbound message unit, free all buffers, and
714 * frees the outbound message interrupt. 712 * frees the outbound message interrupt.
715 */ 713 */
716void rio_close_outb_mbox(struct rio_mport *mport, int mbox) 714static void fsl_close_outb_mbox(struct rio_mport *mport, int mbox)
717{ 715{
718 struct rio_priv *priv = mport->priv; 716 struct rio_priv *priv = mport->priv;
719 /* Disable inbound message unit */ 717 /* Disable inbound message unit */
@@ -770,7 +768,7 @@ fsl_rio_rx_handler(int irq, void *dev_instance)
770} 768}
771 769
772/** 770/**
773 * rio_open_inb_mbox - Initialize MPC85xx inbound mailbox 771 * fsl_open_inb_mbox - Initialize MPC85xx inbound mailbox
774 * @mport: Master port implementing the inbound message unit 772 * @mport: Master port implementing the inbound message unit
775 * @dev_id: Device specific pointer to pass on event 773 * @dev_id: Device specific pointer to pass on event
776 * @mbox: Mailbox to open 774 * @mbox: Mailbox to open
@@ -780,7 +778,8 @@ fsl_rio_rx_handler(int irq, void *dev_instance)
780 * and enables the inbound message unit. Returns %0 on success 778 * and enables the inbound message unit. Returns %0 on success
781 * and %-EINVAL or %-ENOMEM on failure. 779 * and %-EINVAL or %-ENOMEM on failure.
782 */ 780 */
783int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries) 781static int
782fsl_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
784{ 783{
785 int i, rc = 0; 784 int i, rc = 0;
786 struct rio_priv *priv = mport->priv; 785 struct rio_priv *priv = mport->priv;
@@ -844,14 +843,14 @@ int rio_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entri
844} 843}
845 844
846/** 845/**
847 * rio_close_inb_mbox - Shut down MPC85xx inbound mailbox 846 * fsl_close_inb_mbox - Shut down MPC85xx inbound mailbox
848 * @mport: Master port implementing the inbound message unit 847 * @mport: Master port implementing the inbound message unit
849 * @mbox: Mailbox to close 848 * @mbox: Mailbox to close
850 * 849 *
851 * Disables the inbound message unit, free all buffers, and 850 * Disables the inbound message unit, free all buffers, and
852 * frees the inbound message interrupt. 851 * frees the inbound message interrupt.
853 */ 852 */
854void rio_close_inb_mbox(struct rio_mport *mport, int mbox) 853static void fsl_close_inb_mbox(struct rio_mport *mport, int mbox)
855{ 854{
856 struct rio_priv *priv = mport->priv; 855 struct rio_priv *priv = mport->priv;
857 /* Disable inbound message unit */ 856 /* Disable inbound message unit */
@@ -866,7 +865,7 @@ void rio_close_inb_mbox(struct rio_mport *mport, int mbox)
866} 865}
867 866
868/** 867/**
869 * rio_hw_add_inb_buffer - Add buffer to the MPC85xx inbound message queue 868 * fsl_add_inb_buffer - Add buffer to the MPC85xx inbound message queue
870 * @mport: Master port implementing the inbound message unit 869 * @mport: Master port implementing the inbound message unit
871 * @mbox: Inbound mailbox number 870 * @mbox: Inbound mailbox number
872 * @buf: Buffer to add to inbound queue 871 * @buf: Buffer to add to inbound queue
@@ -874,12 +873,12 @@ void rio_close_inb_mbox(struct rio_mport *mport, int mbox)
874 * Adds the @buf buffer to the MPC85xx inbound message queue. Returns 873 * Adds the @buf buffer to the MPC85xx inbound message queue. Returns
875 * %0 on success or %-EINVAL on failure. 874 * %0 on success or %-EINVAL on failure.
876 */ 875 */
877int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf) 876static int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf)
878{ 877{
879 int rc = 0; 878 int rc = 0;
880 struct rio_priv *priv = mport->priv; 879 struct rio_priv *priv = mport->priv;
881 880
882 pr_debug("RIO: rio_hw_add_inb_buffer(), msg_rx_ring.rx_slot %d\n", 881 pr_debug("RIO: fsl_add_inb_buffer(), msg_rx_ring.rx_slot %d\n",
883 priv->msg_rx_ring.rx_slot); 882 priv->msg_rx_ring.rx_slot);
884 883
885 if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) { 884 if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) {
@@ -898,17 +897,15 @@ int rio_hw_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf)
898 return rc; 897 return rc;
899} 898}
900 899
901EXPORT_SYMBOL_GPL(rio_hw_add_inb_buffer);
902
903/** 900/**
904 * rio_hw_get_inb_message - Fetch inbound message from the MPC85xx message unit 901 * fsl_get_inb_message - Fetch inbound message from the MPC85xx message unit
905 * @mport: Master port implementing the inbound message unit 902 * @mport: Master port implementing the inbound message unit
906 * @mbox: Inbound mailbox number 903 * @mbox: Inbound mailbox number
907 * 904 *
908 * Gets the next available inbound message from the inbound message queue. 905 * Gets the next available inbound message from the inbound message queue.
909 * A pointer to the message is returned on success or NULL on failure. 906 * A pointer to the message is returned on success or NULL on failure.
910 */ 907 */
911void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox) 908static void *fsl_get_inb_message(struct rio_mport *mport, int mbox)
912{ 909{
913 struct rio_priv *priv = mport->priv; 910 struct rio_priv *priv = mport->priv;
914 u32 phys_buf, virt_buf; 911 u32 phys_buf, virt_buf;
@@ -945,8 +942,6 @@ void *rio_hw_get_inb_message(struct rio_mport *mport, int mbox)
945 return buf; 942 return buf;
946} 943}
947 944
948EXPORT_SYMBOL_GPL(rio_hw_get_inb_message);
949
950/** 945/**
951 * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler 946 * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler
952 * @irq: Linux interrupt number 947 * @irq: Linux interrupt number
@@ -1431,6 +1426,13 @@ int fsl_rio_setup(struct platform_device *dev)
1431 ops->cwrite = fsl_rio_config_write; 1426 ops->cwrite = fsl_rio_config_write;
1432 ops->dsend = fsl_rio_doorbell_send; 1427 ops->dsend = fsl_rio_doorbell_send;
1433 ops->pwenable = fsl_rio_pw_enable; 1428 ops->pwenable = fsl_rio_pw_enable;
1429 ops->open_outb_mbox = fsl_open_outb_mbox;
1430 ops->open_inb_mbox = fsl_open_inb_mbox;
1431 ops->close_outb_mbox = fsl_close_outb_mbox;
1432 ops->close_inb_mbox = fsl_close_inb_mbox;
1433 ops->add_outb_message = fsl_add_outb_message;
1434 ops->add_inb_buffer = fsl_add_inb_buffer;
1435 ops->get_inb_message = fsl_get_inb_message;
1434 1436
1435 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); 1437 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
1436 if (!port) { 1438 if (!port) {
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index cc2a3b74d0f0..d520dbaede80 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -68,9 +68,13 @@ int rio_request_inb_mbox(struct rio_mport *mport,
68 void (*minb) (struct rio_mport * mport, void *dev_id, int mbox, 68 void (*minb) (struct rio_mport * mport, void *dev_id, int mbox,
69 int slot)) 69 int slot))
70{ 70{
71 int rc = 0; 71 int rc = -ENOSYS;
72 struct resource *res;
72 73
73 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); 74 if (mport->ops->open_inb_mbox == NULL)
75 goto out;
76
77 res = kmalloc(sizeof(struct resource), GFP_KERNEL);
74 78
75 if (res) { 79 if (res) {
76 rio_init_mbox_res(res, mbox, mbox); 80 rio_init_mbox_res(res, mbox, mbox);
@@ -88,7 +92,7 @@ int rio_request_inb_mbox(struct rio_mport *mport,
88 /* Hook the inbound message callback */ 92 /* Hook the inbound message callback */
89 mport->inb_msg[mbox].mcback = minb; 93 mport->inb_msg[mbox].mcback = minb;
90 94
91 rc = rio_open_inb_mbox(mport, dev_id, mbox, entries); 95 rc = mport->ops->open_inb_mbox(mport, dev_id, mbox, entries);
92 } else 96 } else
93 rc = -ENOMEM; 97 rc = -ENOMEM;
94 98
@@ -106,10 +110,13 @@ int rio_request_inb_mbox(struct rio_mport *mport,
106 */ 110 */
107int rio_release_inb_mbox(struct rio_mport *mport, int mbox) 111int rio_release_inb_mbox(struct rio_mport *mport, int mbox)
108{ 112{
109 rio_close_inb_mbox(mport, mbox); 113 if (mport->ops->close_inb_mbox) {
114 mport->ops->close_inb_mbox(mport, mbox);
110 115
111 /* Release the mailbox resource */ 116 /* Release the mailbox resource */
112 return release_resource(mport->inb_msg[mbox].res); 117 return release_resource(mport->inb_msg[mbox].res);
118 } else
119 return -ENOSYS;
113} 120}
114 121
115/** 122/**
@@ -129,9 +136,13 @@ int rio_request_outb_mbox(struct rio_mport *mport,
129 int entries, 136 int entries,
130 void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot)) 137 void (*moutb) (struct rio_mport * mport, void *dev_id, int mbox, int slot))
131{ 138{
132 int rc = 0; 139 int rc = -ENOSYS;
140 struct resource *res;
133 141
134 struct resource *res = kmalloc(sizeof(struct resource), GFP_KERNEL); 142 if (mport->ops->open_outb_mbox == NULL)
143 goto out;
144
145 res = kmalloc(sizeof(struct resource), GFP_KERNEL);
135 146
136 if (res) { 147 if (res) {
137 rio_init_mbox_res(res, mbox, mbox); 148 rio_init_mbox_res(res, mbox, mbox);
@@ -149,7 +160,7 @@ int rio_request_outb_mbox(struct rio_mport *mport,
149 /* Hook the inbound message callback */ 160 /* Hook the inbound message callback */
150 mport->outb_msg[mbox].mcback = moutb; 161 mport->outb_msg[mbox].mcback = moutb;
151 162
152 rc = rio_open_outb_mbox(mport, dev_id, mbox, entries); 163 rc = mport->ops->open_outb_mbox(mport, dev_id, mbox, entries);
153 } else 164 } else
154 rc = -ENOMEM; 165 rc = -ENOMEM;
155 166
@@ -167,10 +178,13 @@ int rio_request_outb_mbox(struct rio_mport *mport,
167 */ 178 */
168int rio_release_outb_mbox(struct rio_mport *mport, int mbox) 179int rio_release_outb_mbox(struct rio_mport *mport, int mbox)
169{ 180{
170 rio_close_outb_mbox(mport, mbox); 181 if (mport->ops->close_outb_mbox) {
182 mport->ops->close_outb_mbox(mport, mbox);
171 183
172 /* Release the mailbox resource */ 184 /* Release the mailbox resource */
173 return release_resource(mport->outb_msg[mbox].res); 185 return release_resource(mport->outb_msg[mbox].res);
186 } else
187 return -ENOSYS;
174} 188}
175 189
176/** 190/**
diff --git a/include/linux/rio.h b/include/linux/rio.h
index ff681ebba585..efed116efe9c 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -241,7 +241,7 @@ struct rio_mport {
241 struct rio_msg inb_msg[RIO_MAX_MBOX]; 241 struct rio_msg inb_msg[RIO_MAX_MBOX];
242 struct rio_msg outb_msg[RIO_MAX_MBOX]; 242 struct rio_msg outb_msg[RIO_MAX_MBOX];
243 int host_deviceid; /* Host device ID */ 243 int host_deviceid; /* Host device ID */
244 struct rio_ops *ops; /* maintenance transaction functions */ 244 struct rio_ops *ops; /* low-level architecture-dependent routines */
245 unsigned char id; /* port ID, unique among all ports */ 245 unsigned char id; /* port ID, unique among all ports */
246 unsigned char index; /* port index, unique among all port 246 unsigned char index; /* port index, unique among all port
247 interfaces of the same type */ 247 interfaces of the same type */
@@ -285,6 +285,13 @@ struct rio_net {
285 * @cwrite: Callback to perform network write of config space. 285 * @cwrite: Callback to perform network write of config space.
286 * @dsend: Callback to send a doorbell message. 286 * @dsend: Callback to send a doorbell message.
287 * @pwenable: Callback to enable/disable port-write message handling. 287 * @pwenable: Callback to enable/disable port-write message handling.
288 * @open_outb_mbox: Callback to initialize outbound mailbox.
289 * @close_outb_mbox: Callback to shut down outbound mailbox.
290 * @open_inb_mbox: Callback to initialize inbound mailbox.
291 * @close_inb_mbox: Callback to shut down inbound mailbox.
292 * @add_outb_message: Callback to add a message to an outbound mailbox queue.
293 * @add_inb_buffer: Callback to add a buffer to an inbound mailbox queue.
294 * @get_inb_message: Callback to get a message from an inbound mailbox queue.
288 */ 295 */
289struct rio_ops { 296struct rio_ops {
290 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len, 297 int (*lcread) (struct rio_mport *mport, int index, u32 offset, int len,
@@ -297,6 +304,16 @@ struct rio_ops {
297 u8 hopcount, u32 offset, int len, u32 data); 304 u8 hopcount, u32 offset, int len, u32 data);
298 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data); 305 int (*dsend) (struct rio_mport *mport, int index, u16 destid, u16 data);
299 int (*pwenable) (struct rio_mport *mport, int enable); 306 int (*pwenable) (struct rio_mport *mport, int enable);
307 int (*open_outb_mbox)(struct rio_mport *mport, void *dev_id,
308 int mbox, int entries);
309 void (*close_outb_mbox)(struct rio_mport *mport, int mbox);
310 int (*open_inb_mbox)(struct rio_mport *mport, void *dev_id,
311 int mbox, int entries);
312 void (*close_inb_mbox)(struct rio_mport *mport, int mbox);
313 int (*add_outb_message)(struct rio_mport *mport, struct rio_dev *rdev,
314 int mbox, void *buffer, size_t len);
315 int (*add_inb_buffer)(struct rio_mport *mport, int mbox, void *buf);
316 void *(*get_inb_message)(struct rio_mport *mport, int mbox);
300}; 317};
301 318
302#define RIO_RESOURCE_MEM 0x00000100 319#define RIO_RESOURCE_MEM 0x00000100
@@ -380,10 +397,6 @@ union rio_pw_msg {
380/* Architecture and hardware-specific functions */ 397/* Architecture and hardware-specific functions */
381extern int rio_init_mports(void); 398extern int rio_init_mports(void);
382extern void rio_register_mport(struct rio_mport *); 399extern void rio_register_mport(struct rio_mport *);
383extern int rio_hw_add_outb_message(struct rio_mport *, struct rio_dev *, int,
384 void *, size_t);
385extern int rio_hw_add_inb_buffer(struct rio_mport *, int, void *);
386extern void *rio_hw_get_inb_message(struct rio_mport *, int);
387extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int); 400extern int rio_open_inb_mbox(struct rio_mport *, void *, int, int);
388extern void rio_close_inb_mbox(struct rio_mport *, int); 401extern void rio_close_inb_mbox(struct rio_mport *, int);
389extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int); 402extern int rio_open_outb_mbox(struct rio_mport *, void *, int, int);
diff --git a/include/linux/rio_drv.h b/include/linux/rio_drv.h
index e09e565c4bce..229b3ca23134 100644
--- a/include/linux/rio_drv.h
+++ b/include/linux/rio_drv.h
@@ -317,7 +317,8 @@ static inline int rio_add_outb_message(struct rio_mport *mport,
317 struct rio_dev *rdev, int mbox, 317 struct rio_dev *rdev, int mbox,
318 void *buffer, size_t len) 318 void *buffer, size_t len)
319{ 319{
320 return rio_hw_add_outb_message(mport, rdev, mbox, buffer, len); 320 return mport->ops->add_outb_message(mport, rdev, mbox,
321 buffer, len);
321} 322}
322 323
323extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int, 324extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int,
@@ -336,7 +337,7 @@ extern int rio_release_inb_mbox(struct rio_mport *, int);
336static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox, 337static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
337 void *buffer) 338 void *buffer)
338{ 339{
339 return rio_hw_add_inb_buffer(mport, mbox, buffer); 340 return mport->ops->add_inb_buffer(mport, mbox, buffer);
340} 341}
341 342
342/** 343/**
@@ -348,7 +349,7 @@ static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox,
348 */ 349 */
349static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox) 350static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox)
350{ 351{
351 return rio_hw_get_inb_message(mport, mbox); 352 return mport->ops->get_inb_message(mport, mbox);
352} 353}
353 354
354/* Doorbell management */ 355/* Doorbell management */