aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2014-04-07 18:38:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-04-07 19:36:07 -0400
commit2aaf308b95b24649a6dcfed89cd956e972089b2a (patch)
treea8fdaea74d50c4a38633bd7aafdc8a98723b1628 /drivers/rapidio
parent40f847baf50debfd42ad66f862bfcfea069ffbe7 (diff)
rapidio: rework device hierarchy and introduce mport class of devices
This patch removes an artificial RapidIO bus root device and establishes actual device hierarchy by providing reference to real parent devices. It also introduces device class for RapidIO controller devices (on-chip or an eternal bridge, known as "mport"). Existing implementation was sufficient for SoC-based platforms that have a single RapidIO controller. With introduction of devices using multiple RapidIO controllers and PCIe-to-RapidIO bridges the old scheme is very limiting or does not work at all. The implemented changes allow to properly reference platform's local RapidIO mport devices and provide device details needed for upper layers. This change to RapidIO device hierarchy does not break any known existing kernel or user space interfaces. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com> Cc: Stef van Os <stef.van.os@prodrive-technologies.com> Cc: Jerry Jacobs <jerry.jacobs@prodrive-technologies.com> Cc: Arno Tiemersma <arno.tiemersma@prodrive-technologies.com> Cc: Rob Landley <rob@landley.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio')
-rw-r--r--drivers/rapidio/devices/tsi721.c1
-rw-r--r--drivers/rapidio/rio-driver.c22
-rw-r--r--drivers/rapidio/rio-scan.c1
-rw-r--r--drivers/rapidio/rio-sysfs.c40
-rw-r--r--drivers/rapidio/rio.c11
-rw-r--r--drivers/rapidio/rio.h1
6 files changed, 69 insertions, 7 deletions
diff --git a/drivers/rapidio/devices/tsi721.c b/drivers/rapidio/devices/tsi721.c
index ff7cbf2d28e3..1753dc693c15 100644
--- a/drivers/rapidio/devices/tsi721.c
+++ b/drivers/rapidio/devices/tsi721.c
@@ -2256,6 +2256,7 @@ static int tsi721_setup_mport(struct tsi721_device *priv)
2256 mport->phy_type = RIO_PHY_SERIAL; 2256 mport->phy_type = RIO_PHY_SERIAL;
2257 mport->priv = (void *)priv; 2257 mport->priv = (void *)priv;
2258 mport->phys_efptr = 0x100; 2258 mport->phys_efptr = 0x100;
2259 mport->dev.parent = &pdev->dev;
2259 priv->mport = mport; 2260 priv->mport = mport;
2260 2261
2261 INIT_LIST_HEAD(&mport->dbells); 2262 INIT_LIST_HEAD(&mport->dbells);
diff --git a/drivers/rapidio/rio-driver.c b/drivers/rapidio/rio-driver.c
index c9ae692d3451..f301f059bb85 100644
--- a/drivers/rapidio/rio-driver.c
+++ b/drivers/rapidio/rio-driver.c
@@ -167,7 +167,6 @@ void rio_unregister_driver(struct rio_driver *rdrv)
167void rio_attach_device(struct rio_dev *rdev) 167void rio_attach_device(struct rio_dev *rdev)
168{ 168{
169 rdev->dev.bus = &rio_bus_type; 169 rdev->dev.bus = &rio_bus_type;
170 rdev->dev.parent = &rio_bus;
171} 170}
172EXPORT_SYMBOL_GPL(rio_attach_device); 171EXPORT_SYMBOL_GPL(rio_attach_device);
173 172
@@ -216,9 +215,12 @@ static int rio_uevent(struct device *dev, struct kobj_uevent_env *env)
216 return 0; 215 return 0;
217} 216}
218 217
219struct device rio_bus = { 218struct class rio_mport_class = {
220 .init_name = "rapidio", 219 .name = "rapidio_port",
220 .owner = THIS_MODULE,
221 .dev_groups = rio_mport_groups,
221}; 222};
223EXPORT_SYMBOL_GPL(rio_mport_class);
222 224
223struct bus_type rio_bus_type = { 225struct bus_type rio_bus_type = {
224 .name = "rapidio", 226 .name = "rapidio",
@@ -233,14 +235,20 @@ struct bus_type rio_bus_type = {
233/** 235/**
234 * rio_bus_init - Register the RapidIO bus with the device model 236 * rio_bus_init - Register the RapidIO bus with the device model
235 * 237 *
236 * Registers the RIO bus device and RIO bus type with the Linux 238 * Registers the RIO mport device class and RIO bus type with the Linux
237 * device model. 239 * device model.
238 */ 240 */
239static int __init rio_bus_init(void) 241static int __init rio_bus_init(void)
240{ 242{
241 if (device_register(&rio_bus) < 0) 243 int ret;
242 printk("RIO: failed to register RIO bus device\n"); 244
243 return bus_register(&rio_bus_type); 245 ret = class_register(&rio_mport_class);
246 if (!ret) {
247 ret = bus_register(&rio_bus_type);
248 if (ret)
249 class_unregister(&rio_mport_class);
250 }
251 return ret;
244} 252}
245 253
246postcore_initcall(rio_bus_init); 254postcore_initcall(rio_bus_init);
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c
index d3a6539a77cc..47a1b2ea76c4 100644
--- a/drivers/rapidio/rio-scan.c
+++ b/drivers/rapidio/rio-scan.c
@@ -461,6 +461,7 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
461 rdev->comp_tag & RIO_CTAG_UDEVID); 461 rdev->comp_tag & RIO_CTAG_UDEVID);
462 } 462 }
463 463
464 rdev->dev.parent = &port->dev;
464 rio_attach_device(rdev); 465 rio_attach_device(rdev);
465 466
466 device_initialize(&rdev->dev); 467 device_initialize(&rdev->dev);
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index e0221c6d0cc2..cdb005c0094d 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -341,3 +341,43 @@ const struct attribute_group *rio_bus_groups[] = {
341 &rio_bus_group, 341 &rio_bus_group,
342 NULL, 342 NULL,
343}; 343};
344
345static ssize_t
346port_destid_show(struct device *dev, struct device_attribute *attr,
347 char *buf)
348{
349 struct rio_mport *mport = to_rio_mport(dev);
350
351 if (mport)
352 return sprintf(buf, "0x%04x\n", mport->host_deviceid);
353 else
354 return -ENODEV;
355}
356static DEVICE_ATTR_RO(port_destid);
357
358static ssize_t sys_size_show(struct device *dev, struct device_attribute *attr,
359 char *buf)
360{
361 struct rio_mport *mport = to_rio_mport(dev);
362
363 if (mport)
364 return sprintf(buf, "%u\n", mport->sys_size);
365 else
366 return -ENODEV;
367}
368static DEVICE_ATTR_RO(sys_size);
369
370static struct attribute *rio_mport_attrs[] = {
371 &dev_attr_port_destid.attr,
372 &dev_attr_sys_size.attr,
373 NULL,
374};
375
376static const struct attribute_group rio_mport_group = {
377 .attrs = rio_mport_attrs,
378};
379
380const struct attribute_group *rio_mport_groups[] = {
381 &rio_mport_group,
382 NULL,
383};
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c
index 2e8a20cac588..a54ba0494dd3 100644
--- a/drivers/rapidio/rio.c
+++ b/drivers/rapidio/rio.c
@@ -1884,6 +1884,7 @@ static int rio_get_hdid(int index)
1884int rio_register_mport(struct rio_mport *port) 1884int rio_register_mport(struct rio_mport *port)
1885{ 1885{
1886 struct rio_scan_node *scan = NULL; 1886 struct rio_scan_node *scan = NULL;
1887 int res = 0;
1887 1888
1888 if (next_portid >= RIO_MAX_MPORTS) { 1889 if (next_portid >= RIO_MAX_MPORTS) {
1889 pr_err("RIO: reached specified max number of mports\n"); 1890 pr_err("RIO: reached specified max number of mports\n");
@@ -1894,6 +1895,16 @@ int rio_register_mport(struct rio_mport *port)
1894 port->host_deviceid = rio_get_hdid(port->id); 1895 port->host_deviceid = rio_get_hdid(port->id);
1895 port->nscan = NULL; 1896 port->nscan = NULL;
1896 1897
1898 dev_set_name(&port->dev, "rapidio%d", port->id);
1899 port->dev.class = &rio_mport_class;
1900
1901 res = device_register(&port->dev);
1902 if (res)
1903 dev_err(&port->dev, "RIO: mport%d registration failed ERR=%d\n",
1904 port->id, res);
1905 else
1906 dev_dbg(&port->dev, "RIO: mport%d registered\n", port->id);
1907
1897 mutex_lock(&rio_mport_list_lock); 1908 mutex_lock(&rio_mport_list_lock);
1898 list_add_tail(&port->node, &rio_mports); 1909 list_add_tail(&port->node, &rio_mports);
1899 1910
diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h
index 5f99d22ad0b0..2d0550e08ea2 100644
--- a/drivers/rapidio/rio.h
+++ b/drivers/rapidio/rio.h
@@ -50,6 +50,7 @@ extern int rio_mport_scan(int mport_id);
50/* Structures internal to the RIO core code */ 50/* Structures internal to the RIO core code */
51extern const struct attribute_group *rio_dev_groups[]; 51extern const struct attribute_group *rio_dev_groups[];
52extern const struct attribute_group *rio_bus_groups[]; 52extern const struct attribute_group *rio_bus_groups[];
53extern const struct attribute_group *rio_mport_groups[];
53 54
54#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16)) 55#define RIO_GET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x00ff0000) >> 16))
55#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16)) 56#define RIO_SET_DID(size, x) (size ? (x & 0xffff) : ((x & 0x000000ff) << 16))