aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev/fsl_rio.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/sysdev/fsl_rio.c')
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c100
1 files changed, 40 insertions, 60 deletions
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index 3eff2c3a9ad5..49798532b477 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
@@ -1293,28 +1288,6 @@ err_out:
1293 return rc; 1288 return rc;
1294} 1289}
1295 1290
1296static char *cmdline = NULL;
1297
1298static int fsl_rio_get_hdid(int index)
1299{
1300 /* XXX Need to parse multiple entries in some format */
1301 if (!cmdline)
1302 return -1;
1303
1304 return simple_strtol(cmdline, NULL, 0);
1305}
1306
1307static int fsl_rio_get_cmdline(char *s)
1308{
1309 if (!s)
1310 return 0;
1311
1312 cmdline = s;
1313 return 1;
1314}
1315
1316__setup("riohdid=", fsl_rio_get_cmdline);
1317
1318static inline void fsl_rio_info(struct device *dev, u32 ccsr) 1291static inline void fsl_rio_info(struct device *dev, u32 ccsr)
1319{ 1292{
1320 const char *str; 1293 const char *str;
@@ -1431,13 +1404,19 @@ int fsl_rio_setup(struct platform_device *dev)
1431 ops->cwrite = fsl_rio_config_write; 1404 ops->cwrite = fsl_rio_config_write;
1432 ops->dsend = fsl_rio_doorbell_send; 1405 ops->dsend = fsl_rio_doorbell_send;
1433 ops->pwenable = fsl_rio_pw_enable; 1406 ops->pwenable = fsl_rio_pw_enable;
1407 ops->open_outb_mbox = fsl_open_outb_mbox;
1408 ops->open_inb_mbox = fsl_open_inb_mbox;
1409 ops->close_outb_mbox = fsl_close_outb_mbox;
1410 ops->close_inb_mbox = fsl_close_inb_mbox;
1411 ops->add_outb_message = fsl_add_outb_message;
1412 ops->add_inb_buffer = fsl_add_inb_buffer;
1413 ops->get_inb_message = fsl_get_inb_message;
1434 1414
1435 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL); 1415 port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
1436 if (!port) { 1416 if (!port) {
1437 rc = -ENOMEM; 1417 rc = -ENOMEM;
1438 goto err_port; 1418 goto err_port;
1439 } 1419 }
1440 port->id = 0;
1441 port->index = 0; 1420 port->index = 0;
1442 1421
1443 priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL); 1422 priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
@@ -1453,6 +1432,14 @@ int fsl_rio_setup(struct platform_device *dev)
1453 port->iores.flags = IORESOURCE_MEM; 1432 port->iores.flags = IORESOURCE_MEM;
1454 port->iores.name = "rio_io_win"; 1433 port->iores.name = "rio_io_win";
1455 1434
1435 if (request_resource(&iomem_resource, &port->iores) < 0) {
1436 dev_err(&dev->dev, "RIO: Error requesting master port region"
1437 " 0x%016llx-0x%016llx\n",
1438 (u64)port->iores.start, (u64)port->iores.end);
1439 rc = -ENOMEM;
1440 goto err_res;
1441 }
1442
1456 priv->pwirq = irq_of_parse_and_map(dev->dev.of_node, 0); 1443 priv->pwirq = irq_of_parse_and_map(dev->dev.of_node, 0);
1457 priv->bellirq = irq_of_parse_and_map(dev->dev.of_node, 2); 1444 priv->bellirq = irq_of_parse_and_map(dev->dev.of_node, 2);
1458 priv->txirq = irq_of_parse_and_map(dev->dev.of_node, 3); 1445 priv->txirq = irq_of_parse_and_map(dev->dev.of_node, 3);
@@ -1468,11 +1455,8 @@ int fsl_rio_setup(struct platform_device *dev)
1468 priv->dev = &dev->dev; 1455 priv->dev = &dev->dev;
1469 1456
1470 port->ops = ops; 1457 port->ops = ops;
1471 port->host_deviceid = fsl_rio_get_hdid(port->id);
1472
1473 port->priv = priv; 1458 port->priv = priv;
1474 port->phys_efptr = 0x100; 1459 port->phys_efptr = 0x100;
1475 rio_register_mport(port);
1476 1460
1477 priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1); 1461 priv->regs_win = ioremap(regs.start, regs.end - regs.start + 1);
1478 rio_regs_win = priv->regs_win; 1462 rio_regs_win = priv->regs_win;
@@ -1519,6 +1503,9 @@ int fsl_rio_setup(struct platform_device *dev)
1519 dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n", 1503 dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n",
1520 port->sys_size ? 65536 : 256); 1504 port->sys_size ? 65536 : 256);
1521 1505
1506 if (rio_register_mport(port))
1507 goto err;
1508
1522 if (port->host_deviceid >= 0) 1509 if (port->host_deviceid >= 0)
1523 out_be32(priv->regs_win + RIO_GCCSR, RIO_PORT_GEN_HOST | 1510 out_be32(priv->regs_win + RIO_GCCSR, RIO_PORT_GEN_HOST |
1524 RIO_PORT_GEN_MASTER | RIO_PORT_GEN_DISCOVERED); 1511 RIO_PORT_GEN_MASTER | RIO_PORT_GEN_DISCOVERED);
@@ -1559,6 +1546,7 @@ int fsl_rio_setup(struct platform_device *dev)
1559 return 0; 1546 return 0;
1560err: 1547err:
1561 iounmap(priv->regs_win); 1548 iounmap(priv->regs_win);
1549err_res:
1562 kfree(priv); 1550 kfree(priv);
1563err_priv: 1551err_priv:
1564 kfree(port); 1552 kfree(port);
@@ -1572,18 +1560,10 @@ err_ops:
1572 */ 1560 */
1573static int __devinit fsl_of_rio_rpn_probe(struct platform_device *dev) 1561static int __devinit fsl_of_rio_rpn_probe(struct platform_device *dev)
1574{ 1562{
1575 int rc;
1576 printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n", 1563 printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n",
1577 dev->dev.of_node->full_name); 1564 dev->dev.of_node->full_name);
1578 1565
1579 rc = fsl_rio_setup(dev); 1566 return fsl_rio_setup(dev);
1580 if (rc)
1581 goto out;
1582
1583 /* Enumerate all registered ports */
1584 rc = rio_init_mports();
1585out:
1586 return rc;
1587}; 1567};
1588 1568
1589static const struct of_device_id fsl_of_rio_rpn_ids[] = { 1569static const struct of_device_id fsl_of_rio_rpn_ids[] = {