rio-scan.c (eb188d0e857c436b5d365d5ccc629da5a06ed102) rio-scan.c (fa78cc51794912b7e6ee98cd823fcc84cf79d04a)
1/*
2 * RapidIO enumeration and discovery support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16
17#include <linux/delay.h>
1/*
2 * RapidIO enumeration and discovery support
3 *
4 * Copyright 2005 MontaVista Software, Inc.
5 * Matt Porter <mporter@kernel.crashing.org>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 */
12
13#include <linux/config.h>
14#include <linux/types.h>
15#include <linux/kernel.h>
16
17#include <linux/delay.h>
18#include <linux/dma-mapping.h>
18#include <linux/init.h>
19#include <linux/rio.h>
20#include <linux/rio_drv.h>
21#include <linux/rio_ids.h>
22#include <linux/rio_regs.h>
23#include <linux/module.h>
24#include <linux/spinlock.h>
25#include <linux/timer.h>
26
27#include "rio.h"
28
29LIST_HEAD(rio_devices);
30static LIST_HEAD(rio_switches);
31
32#define RIO_ENUM_CMPL_MAGIC 0xdeadbeef
33
34static void rio_enum_timeout(unsigned long);
35
19#include <linux/init.h>
20#include <linux/rio.h>
21#include <linux/rio_drv.h>
22#include <linux/rio_ids.h>
23#include <linux/rio_regs.h>
24#include <linux/module.h>
25#include <linux/spinlock.h>
26#include <linux/timer.h>
27
28#include "rio.h"
29
30LIST_HEAD(rio_devices);
31static LIST_HEAD(rio_switches);
32
33#define RIO_ENUM_CMPL_MAGIC 0xdeadbeef
34
35static void rio_enum_timeout(unsigned long);
36
36spinlock_t rio_global_list_lock = SPIN_LOCK_UNLOCKED;
37DEFINE_SPINLOCK(rio_global_list_lock);
38
37static int next_destid = 0;
38static int next_switchid = 0;
39static int next_net = 0;
40
41static struct timer_list rio_enum_timer =
42TIMER_INITIALIZER(rio_enum_timeout, 0, 0);
43
44static int rio_mport_phys_table[] = {

--- 5 unchanged lines hidden (view full) ---

50};
51
52static int rio_sport_phys_table[] = {
53 RIO_EFB_PAR_EP_FREE_ID,
54 RIO_EFB_SER_EP_FREE_ID,
55 -1,
56};
57
39static int next_destid = 0;
40static int next_switchid = 0;
41static int next_net = 0;
42
43static struct timer_list rio_enum_timer =
44TIMER_INITIALIZER(rio_enum_timeout, 0, 0);
45
46static int rio_mport_phys_table[] = {

--- 5 unchanged lines hidden (view full) ---

52};
53
54static int rio_sport_phys_table[] = {
55 RIO_EFB_PAR_EP_FREE_ID,
56 RIO_EFB_SER_EP_FREE_ID,
57 -1,
58};
59
58extern struct rio_route_ops __start_rio_route_ops[];
59extern struct rio_route_ops __end_rio_route_ops[];
60
61/**
62 * rio_get_device_id - Get the base/extended device id for a device
63 * @port: RIO master port
64 * @destid: Destination ID of device
65 * @hopcount: Hopcount to device
66 *
67 * Reads the base/extended device id from a device. Returns the
68 * 8/16-bit device ID.

--- 11 unchanged lines hidden (view full) ---

80 * rio_set_device_id - Set the base/extended device id for a device
81 * @port: RIO master port
82 * @destid: Destination ID of device
83 * @hopcount: Hopcount to device
84 * @did: Device ID value to be written
85 *
86 * Writes the base/extended device id from a device.
87 */
60/**
61 * rio_get_device_id - Get the base/extended device id for a device
62 * @port: RIO master port
63 * @destid: Destination ID of device
64 * @hopcount: Hopcount to device
65 *
66 * Reads the base/extended device id from a device. Returns the
67 * 8/16-bit device ID.

--- 11 unchanged lines hidden (view full) ---

79 * rio_set_device_id - Set the base/extended device id for a device
80 * @port: RIO master port
81 * @destid: Destination ID of device
82 * @hopcount: Hopcount to device
83 * @did: Device ID value to be written
84 *
85 * Writes the base/extended device id from a device.
86 */
88static void
89rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
87static void rio_set_device_id(struct rio_mport *port, u16 destid, u8 hopcount, u16 did)
90{
91 rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
92 RIO_SET_DID(did));
93}
94
95/**
96 * rio_local_set_device_id - Set the base/extended device id for a port
97 * @port: RIO master port

--- 89 unchanged lines hidden (view full) ---

187 *
188 * Checks the provided @src_ops and @dst_ops for the necessary transaction
189 * capabilities that indicate whether or not a device will implement a
190 * destination ID register. Returns 1 if true or 0 if false.
191 */
192static int rio_device_has_destid(struct rio_mport *port, int src_ops,
193 int dst_ops)
194{
88{
89 rio_mport_write_config_32(port, destid, hopcount, RIO_DID_CSR,
90 RIO_SET_DID(did));
91}
92
93/**
94 * rio_local_set_device_id - Set the base/extended device id for a port
95 * @port: RIO master port

--- 89 unchanged lines hidden (view full) ---

185 *
186 * Checks the provided @src_ops and @dst_ops for the necessary transaction
187 * capabilities that indicate whether or not a device will implement a
188 * destination ID register. Returns 1 if true or 0 if false.
189 */
190static int rio_device_has_destid(struct rio_mport *port, int src_ops,
191 int dst_ops)
192{
195 if (((src_ops & RIO_SRC_OPS_READ) ||
196 (src_ops & RIO_SRC_OPS_WRITE) ||
197 (src_ops & RIO_SRC_OPS_ATOMIC_TST_SWP) ||
198 (src_ops & RIO_SRC_OPS_ATOMIC_INC) ||
199 (src_ops & RIO_SRC_OPS_ATOMIC_DEC) ||
200 (src_ops & RIO_SRC_OPS_ATOMIC_SET) ||
201 (src_ops & RIO_SRC_OPS_ATOMIC_CLR)) &&
202 ((dst_ops & RIO_DST_OPS_READ) ||
203 (dst_ops & RIO_DST_OPS_WRITE) ||
204 (dst_ops & RIO_DST_OPS_ATOMIC_TST_SWP) ||
205 (dst_ops & RIO_DST_OPS_ATOMIC_INC) ||
206 (dst_ops & RIO_DST_OPS_ATOMIC_DEC) ||
207 (dst_ops & RIO_DST_OPS_ATOMIC_SET) ||
208 (dst_ops & RIO_DST_OPS_ATOMIC_CLR))) {
209 return 1;
210 } else
211 return 0;
193 u32 mask = RIO_OPS_READ | RIO_OPS_WRITE | RIO_OPS_ATOMIC_TST_SWP | RIO_OPS_ATOMIC_INC | RIO_OPS_ATOMIC_DEC | RIO_OPS_ATOMIC_SET | RIO_OPS_ATOMIC_CLR;
194
195 return !!((src_ops | dst_ops) & mask);
212}
213
214/**
215 * rio_release_dev- Frees a RIO device struct
216 * @dev: LDM device associated with a RIO device struct
217 *
218 * Gets the RIO device struct associated a RIO device struct.
219 * The RIO device struct is freed.

--- 158 unchanged lines hidden (view full) ---

378 rdev->destid);
379
380 rdev->dev.bus = &rio_bus_type;
381
382 device_initialize(&rdev->dev);
383 rdev->dev.release = rio_release_dev;
384 rio_dev_get(rdev);
385
196}
197
198/**
199 * rio_release_dev- Frees a RIO device struct
200 * @dev: LDM device associated with a RIO device struct
201 *
202 * Gets the RIO device struct associated a RIO device struct.
203 * The RIO device struct is freed.

--- 158 unchanged lines hidden (view full) ---

362 rdev->destid);
363
364 rdev->dev.bus = &rio_bus_type;
365
366 device_initialize(&rdev->dev);
367 rdev->dev.release = rio_release_dev;
368 rio_dev_get(rdev);
369
386 rdev->dev.dma_mask = (u64 *) 0xffffffff;
387 rdev->dev.coherent_dma_mask = 0xffffffffULL;
370 rdev->dma_mask = DMA_32BIT_MASK;
371 rdev->dev.dma_mask = &rdev->dma_mask;
372 rdev->dev.coherent_dma_mask = DMA_32BIT_MASK;
388
389 if ((rdev->pef & RIO_PEF_INB_DOORBELL) &&
390 (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
391 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
392 0, 0xffff);
393
394 rio_add_device(rdev);
395

--- 565 unchanged lines hidden ---
373
374 if ((rdev->pef & RIO_PEF_INB_DOORBELL) &&
375 (rdev->dst_ops & RIO_DST_OPS_DOORBELL))
376 rio_init_dbell_res(&rdev->riores[RIO_DOORBELL_RESOURCE],
377 0, 0xffff);
378
379 rio_add_device(rdev);
380

--- 565 unchanged lines hidden ---