fsl_rio.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651
  1. /*
  2. * Freescale MPC85xx/MPC86xx RapidIO support
  3. *
  4. * Copyright 2009 Sysgo AG
  5. * Thomas Moll <thomas.moll@sysgo.com>
  6. * - fixed maintenance access routines, check for aligned access
  7. *
  8. * Copyright 2009 Integrated Device Technology, Inc.
  9. * Alex Bounine <alexandre.bounine@idt.com>
  10. * - Added Port-Write message handling
  11. * - Added Machine Check exception handling
  12. *
  13. * Copyright (C) 2007, 2008, 2010 Freescale Semiconductor, Inc.
  14. * Zhang Wei <wei.zhang@freescale.com>
  15. *
  16. * Copyright 2005 MontaVista Software, Inc.
  17. * Matt Porter <mporter@kernel.crashing.org>
  18. *
  19. * This program is free software; you can redistribute it and/or modify it
  20. * under the terms of the GNU General Public License as published by the
  21. * Free Software Foundation; either version 2 of the License, or (at your
  22. * option) any later version.
  23. */
  24. #include <linux/init.h>
  25. #include <linux/module.h>
  26. #include <linux/types.h>
  27. #include <linux/dma-mapping.h>
  28. #include <linux/interrupt.h>
  29. #include <linux/device.h>
  30. #include <linux/rio.h>
  31. #include <linux/rio_drv.h>
  32. #include <linux/of_platform.h>
  33. #include <linux/delay.h>
  34. #include <linux/slab.h>
  35. #include <linux/kfifo.h>
  36. #include <asm/io.h>
  37. #include <asm/machdep.h>
  38. #include <asm/uaccess.h>
  39. #undef DEBUG_PW /* Port-Write debugging */
  40. /* RapidIO definition irq, which read from OF-tree */
  41. #define IRQ_RIO_BELL(m) (((struct rio_priv *)(m->priv))->bellirq)
  42. #define IRQ_RIO_TX(m) (((struct rio_priv *)(m->priv))->txirq)
  43. #define IRQ_RIO_RX(m) (((struct rio_priv *)(m->priv))->rxirq)
  44. #define IRQ_RIO_PW(m) (((struct rio_priv *)(m->priv))->pwirq)
  45. #define IPWSR_CLEAR 0x98
  46. #define OMSR_CLEAR 0x1cb3
  47. #define IMSR_CLEAR 0x491
  48. #define IDSR_CLEAR 0x91
  49. #define ODSR_CLEAR 0x1c00
  50. #define LTLEECSR_ENABLE_ALL 0xFFC000FC
  51. #define ESCSR_CLEAR 0x07120204
  52. #define RIO_PORT1_EDCSR 0x0640
  53. #define RIO_PORT2_EDCSR 0x0680
  54. #define RIO_PORT1_IECSR 0x10130
  55. #define RIO_PORT2_IECSR 0x101B0
  56. #define RIO_IM0SR 0x13064
  57. #define RIO_IM1SR 0x13164
  58. #define RIO_OM0SR 0x13004
  59. #define RIO_OM1SR 0x13104
  60. #define RIO_ATMU_REGS_OFFSET 0x10c00
  61. #define RIO_P_MSG_REGS_OFFSET 0x11000
  62. #define RIO_S_MSG_REGS_OFFSET 0x13000
  63. #define RIO_GCCSR 0x13c
  64. #define RIO_ESCSR 0x158
  65. #define RIO_PORT2_ESCSR 0x178
  66. #define RIO_CCSR 0x15c
  67. #define RIO_LTLEDCSR 0x0608
  68. #define RIO_LTLEDCSR_IER 0x80000000
  69. #define RIO_LTLEDCSR_PRT 0x01000000
  70. #define RIO_LTLEECSR 0x060c
  71. #define RIO_EPWISR 0x10010
  72. #define RIO_ISR_AACR 0x10120
  73. #define RIO_ISR_AACR_AA 0x1 /* Accept All ID */
  74. #define RIO_MAINT_WIN_SIZE 0x400000
  75. #define RIO_DBELL_WIN_SIZE 0x1000
  76. #define RIO_MSG_OMR_MUI 0x00000002
  77. #define RIO_MSG_OSR_TE 0x00000080
  78. #define RIO_MSG_OSR_QOI 0x00000020
  79. #define RIO_MSG_OSR_QFI 0x00000010
  80. #define RIO_MSG_OSR_MUB 0x00000004
  81. #define RIO_MSG_OSR_EOMI 0x00000002
  82. #define RIO_MSG_OSR_QEI 0x00000001
  83. #define RIO_MSG_IMR_MI 0x00000002
  84. #define RIO_MSG_ISR_TE 0x00000080
  85. #define RIO_MSG_ISR_QFI 0x00000010
  86. #define RIO_MSG_ISR_DIQI 0x00000001
  87. #define RIO_IPWMR_SEN 0x00100000
  88. #define RIO_IPWMR_QFIE 0x00000100
  89. #define RIO_IPWMR_EIE 0x00000020
  90. #define RIO_IPWMR_CQ 0x00000002
  91. #define RIO_IPWMR_PWE 0x00000001
  92. #define RIO_IPWSR_QF 0x00100000
  93. #define RIO_IPWSR_TE 0x00000080
  94. #define RIO_IPWSR_QFI 0x00000010
  95. #define RIO_IPWSR_PWD 0x00000008
  96. #define RIO_IPWSR_PWB 0x00000004
  97. /* EPWISR Error match value */
  98. #define RIO_EPWISR_PINT1 0x80000000
  99. #define RIO_EPWISR_PINT2 0x40000000
  100. #define RIO_EPWISR_MU 0x00000002
  101. #define RIO_EPWISR_PW 0x00000001
  102. #define RIO_MSG_DESC_SIZE 32
  103. #define RIO_MSG_BUFFER_SIZE 4096
  104. #define RIO_MIN_TX_RING_SIZE 2
  105. #define RIO_MAX_TX_RING_SIZE 2048
  106. #define RIO_MIN_RX_RING_SIZE 2
  107. #define RIO_MAX_RX_RING_SIZE 2048
  108. #define DOORBELL_DMR_DI 0x00000002
  109. #define DOORBELL_DSR_TE 0x00000080
  110. #define DOORBELL_DSR_QFI 0x00000010
  111. #define DOORBELL_DSR_DIQI 0x00000001
  112. #define DOORBELL_TID_OFFSET 0x02
  113. #define DOORBELL_SID_OFFSET 0x04
  114. #define DOORBELL_INFO_OFFSET 0x06
  115. #define DOORBELL_MESSAGE_SIZE 0x08
  116. #define DBELL_SID(x) (*(u16 *)(x + DOORBELL_SID_OFFSET))
  117. #define DBELL_TID(x) (*(u16 *)(x + DOORBELL_TID_OFFSET))
  118. #define DBELL_INF(x) (*(u16 *)(x + DOORBELL_INFO_OFFSET))
  119. struct rio_atmu_regs {
  120. u32 rowtar;
  121. u32 rowtear;
  122. u32 rowbar;
  123. u32 pad2;
  124. u32 rowar;
  125. u32 pad3[3];
  126. };
  127. struct rio_msg_regs {
  128. u32 omr; /* 0xD_3000 - Outbound message 0 mode register */
  129. u32 osr; /* 0xD_3004 - Outbound message 0 status register */
  130. u32 pad1;
  131. u32 odqdpar; /* 0xD_300C - Outbound message 0 descriptor queue
  132. dequeue pointer address register */
  133. u32 pad2;
  134. u32 osar; /* 0xD_3014 - Outbound message 0 source address
  135. register */
  136. u32 odpr; /* 0xD_3018 - Outbound message 0 destination port
  137. register */
  138. u32 odatr; /* 0xD_301C - Outbound message 0 destination attributes
  139. Register*/
  140. u32 odcr; /* 0xD_3020 - Outbound message 0 double-word count
  141. register */
  142. u32 pad3;
  143. u32 odqepar; /* 0xD_3028 - Outbound message 0 descriptor queue
  144. enqueue pointer address register */
  145. u32 pad4[13];
  146. u32 imr; /* 0xD_3060 - Inbound message 0 mode register */
  147. u32 isr; /* 0xD_3064 - Inbound message 0 status register */
  148. u32 pad5;
  149. u32 ifqdpar; /* 0xD_306C - Inbound message 0 frame queue dequeue
  150. pointer address register*/
  151. u32 pad6;
  152. u32 ifqepar; /* 0xD_3074 - Inbound message 0 frame queue enqueue
  153. pointer address register */
  154. u32 pad7[226];
  155. u32 odmr; /* 0xD_3400 - Outbound doorbell mode register */
  156. u32 odsr; /* 0xD_3404 - Outbound doorbell status register */
  157. u32 res0[4];
  158. u32 oddpr; /* 0xD_3418 - Outbound doorbell destination port
  159. register */
  160. u32 oddatr; /* 0xD_341c - Outbound doorbell destination attributes
  161. register */
  162. u32 res1[3];
  163. u32 odretcr; /* 0xD_342C - Outbound doorbell retry error threshold
  164. configuration register */
  165. u32 res2[12];
  166. u32 dmr; /* 0xD_3460 - Inbound doorbell mode register */
  167. u32 dsr; /* 0xD_3464 - Inbound doorbell status register */
  168. u32 pad8;
  169. u32 dqdpar; /* 0xD_346C - Inbound doorbell queue dequeue Pointer
  170. address register */
  171. u32 pad9;
  172. u32 dqepar; /* 0xD_3474 - Inbound doorbell Queue enqueue pointer
  173. address register */
  174. u32 pad10[26];
  175. u32 pwmr; /* 0xD_34E0 - Inbound port-write mode register */
  176. u32 pwsr; /* 0xD_34E4 - Inbound port-write status register */
  177. u32 epwqbar; /* 0xD_34E8 - Extended Port-Write Queue Base Address
  178. register */
  179. u32 pwqbar; /* 0xD_34EC - Inbound port-write queue base address
  180. register */
  181. };
  182. struct rio_tx_desc {
  183. u32 res1;
  184. u32 saddr;
  185. u32 dport;
  186. u32 dattr;
  187. u32 res2;
  188. u32 res3;
  189. u32 dwcnt;
  190. u32 res4;
  191. };
  192. struct rio_dbell_ring {
  193. void *virt;
  194. dma_addr_t phys;
  195. };
  196. struct rio_msg_tx_ring {
  197. void *virt;
  198. dma_addr_t phys;
  199. void *virt_buffer[RIO_MAX_TX_RING_SIZE];
  200. dma_addr_t phys_buffer[RIO_MAX_TX_RING_SIZE];
  201. int tx_slot;
  202. int size;
  203. void *dev_id;
  204. };
  205. struct rio_msg_rx_ring {
  206. void *virt;
  207. dma_addr_t phys;
  208. void *virt_buffer[RIO_MAX_RX_RING_SIZE];
  209. int rx_slot;
  210. int size;
  211. void *dev_id;
  212. };
  213. struct rio_port_write_msg {
  214. void *virt;
  215. dma_addr_t phys;
  216. u32 msg_count;
  217. u32 err_count;
  218. u32 discard_count;
  219. };
  220. struct rio_priv {
  221. struct device *dev;
  222. void __iomem *regs_win;
  223. struct rio_atmu_regs __iomem *atmu_regs;
  224. struct rio_atmu_regs __iomem *maint_atmu_regs;
  225. struct rio_atmu_regs __iomem *dbell_atmu_regs;
  226. void __iomem *dbell_win;
  227. void __iomem *maint_win;
  228. struct rio_msg_regs __iomem *msg_regs;
  229. struct rio_dbell_ring dbell_ring;
  230. struct rio_msg_tx_ring msg_tx_ring;
  231. struct rio_msg_rx_ring msg_rx_ring;
  232. struct rio_port_write_msg port_write_msg;
  233. int bellirq;
  234. int txirq;
  235. int rxirq;
  236. int pwirq;
  237. struct work_struct pw_work;
  238. struct kfifo pw_fifo;
  239. spinlock_t pw_fifo_lock;
  240. };
  241. #define __fsl_read_rio_config(x, addr, err, op) \
  242. __asm__ __volatile__( \
  243. "1: "op" %1,0(%2)\n" \
  244. " eieio\n" \
  245. "2:\n" \
  246. ".section .fixup,\"ax\"\n" \
  247. "3: li %1,-1\n" \
  248. " li %0,%3\n" \
  249. " b 2b\n" \
  250. ".section __ex_table,\"a\"\n" \
  251. " .align 2\n" \
  252. " .long 1b,3b\n" \
  253. ".text" \
  254. : "=r" (err), "=r" (x) \
  255. : "b" (addr), "i" (-EFAULT), "0" (err))
  256. static void __iomem *rio_regs_win;
  257. #ifdef CONFIG_E500
  258. int fsl_rio_mcheck_exception(struct pt_regs *regs)
  259. {
  260. const struct exception_table_entry *entry;
  261. unsigned long reason;
  262. if (!rio_regs_win)
  263. return 0;
  264. reason = in_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR));
  265. if (reason & (RIO_LTLEDCSR_IER | RIO_LTLEDCSR_PRT)) {
  266. /* Check if we are prepared to handle this fault */
  267. entry = search_exception_tables(regs->nip);
  268. if (entry) {
  269. pr_debug("RIO: %s - MC Exception handled\n",
  270. __func__);
  271. out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR),
  272. 0);
  273. regs->msr |= MSR_RI;
  274. regs->nip = entry->fixup;
  275. return 1;
  276. }
  277. }
  278. return 0;
  279. }
  280. EXPORT_SYMBOL_GPL(fsl_rio_mcheck_exception);
  281. #endif
  282. /**
  283. * fsl_rio_doorbell_send - Send a MPC85xx doorbell message
  284. * @mport: RapidIO master port info
  285. * @index: ID of RapidIO interface
  286. * @destid: Destination ID of target device
  287. * @data: 16-bit info field of RapidIO doorbell message
  288. *
  289. * Sends a MPC85xx doorbell message. Returns %0 on success or
  290. * %-EINVAL on failure.
  291. */
  292. static int fsl_rio_doorbell_send(struct rio_mport *mport,
  293. int index, u16 destid, u16 data)
  294. {
  295. struct rio_priv *priv = mport->priv;
  296. pr_debug("fsl_doorbell_send: index %d destid %4.4x data %4.4x\n",
  297. index, destid, data);
  298. switch (mport->phy_type) {
  299. case RIO_PHY_PARALLEL:
  300. out_be32(&priv->dbell_atmu_regs->rowtar, destid << 22);
  301. out_be16(priv->dbell_win, data);
  302. break;
  303. case RIO_PHY_SERIAL:
  304. /* In the serial version silicons, such as MPC8548, MPC8641,
  305. * below operations is must be.
  306. */
  307. out_be32(&priv->msg_regs->odmr, 0x00000000);
  308. out_be32(&priv->msg_regs->odretcr, 0x00000004);
  309. out_be32(&priv->msg_regs->oddpr, destid << 16);
  310. out_be32(&priv->msg_regs->oddatr, data);
  311. out_be32(&priv->msg_regs->odmr, 0x00000001);
  312. break;
  313. }
  314. return 0;
  315. }
  316. /**
  317. * fsl_local_config_read - Generate a MPC85xx local config space read
  318. * @mport: RapidIO master port info
  319. * @index: ID of RapdiIO interface
  320. * @offset: Offset into configuration space
  321. * @len: Length (in bytes) of the maintenance transaction
  322. * @data: Value to be read into
  323. *
  324. * Generates a MPC85xx local configuration space read. Returns %0 on
  325. * success or %-EINVAL on failure.
  326. */
  327. static int fsl_local_config_read(struct rio_mport *mport,
  328. int index, u32 offset, int len, u32 *data)
  329. {
  330. struct rio_priv *priv = mport->priv;
  331. pr_debug("fsl_local_config_read: index %d offset %8.8x\n", index,
  332. offset);
  333. *data = in_be32(priv->regs_win + offset);
  334. return 0;
  335. }
  336. /**
  337. * fsl_local_config_write - Generate a MPC85xx local config space write
  338. * @mport: RapidIO master port info
  339. * @index: ID of RapdiIO interface
  340. * @offset: Offset into configuration space
  341. * @len: Length (in bytes) of the maintenance transaction
  342. * @data: Value to be written
  343. *
  344. * Generates a MPC85xx local configuration space write. Returns %0 on
  345. * success or %-EINVAL on failure.
  346. */
  347. static int fsl_local_config_write(struct rio_mport *mport,
  348. int index, u32 offset, int len, u32 data)
  349. {
  350. struct rio_priv *priv = mport->priv;
  351. pr_debug
  352. ("fsl_local_config_write: index %d offset %8.8x data %8.8x\n",
  353. index, offset, data);
  354. out_be32(priv->regs_win + offset, data);
  355. return 0;
  356. }
  357. /**
  358. * fsl_rio_config_read - Generate a MPC85xx read maintenance transaction
  359. * @mport: RapidIO master port info
  360. * @index: ID of RapdiIO interface
  361. * @destid: Destination ID of transaction
  362. * @hopcount: Number of hops to target device
  363. * @offset: Offset into configuration space
  364. * @len: Length (in bytes) of the maintenance transaction
  365. * @val: Location to be read into
  366. *
  367. * Generates a MPC85xx read maintenance transaction. Returns %0 on
  368. * success or %-EINVAL on failure.
  369. */
  370. static int
  371. fsl_rio_config_read(struct rio_mport *mport, int index, u16 destid,
  372. u8 hopcount, u32 offset, int len, u32 *val)
  373. {
  374. struct rio_priv *priv = mport->priv;
  375. u8 *data;
  376. u32 rval, err = 0;
  377. pr_debug
  378. ("fsl_rio_config_read: index %d destid %d hopcount %d offset %8.8x len %d\n",
  379. index, destid, hopcount, offset, len);
  380. /* 16MB maintenance window possible */
  381. /* allow only aligned access to maintenance registers */
  382. if (offset > (0x1000000 - len) || !IS_ALIGNED(offset, len))
  383. return -EINVAL;
  384. out_be32(&priv->maint_atmu_regs->rowtar,
  385. (destid << 22) | (hopcount << 12) | (offset >> 12));
  386. out_be32(&priv->maint_atmu_regs->rowtear, (destid >> 10));
  387. data = (u8 *) priv->maint_win + (offset & (RIO_MAINT_WIN_SIZE - 1));
  388. switch (len) {
  389. case 1:
  390. __fsl_read_rio_config(rval, data, err, "lbz");
  391. break;
  392. case 2:
  393. __fsl_read_rio_config(rval, data, err, "lhz");
  394. break;
  395. case 4:
  396. __fsl_read_rio_config(rval, data, err, "lwz");
  397. break;
  398. default:
  399. return -EINVAL;
  400. }
  401. if (err) {
  402. pr_debug("RIO: cfg_read error %d for %x:%x:%x\n",
  403. err, destid, hopcount, offset);
  404. }
  405. *val = rval;
  406. return err;
  407. }
  408. /**
  409. * fsl_rio_config_write - Generate a MPC85xx write maintenance transaction
  410. * @mport: RapidIO master port info
  411. * @index: ID of RapdiIO interface
  412. * @destid: Destination ID of transaction
  413. * @hopcount: Number of hops to target device
  414. * @offset: Offset into configuration space
  415. * @len: Length (in bytes) of the maintenance transaction
  416. * @val: Value to be written
  417. *
  418. * Generates an MPC85xx write maintenance transaction. Returns %0 on
  419. * success or %-EINVAL on failure.
  420. */
  421. static int
  422. fsl_rio_config_write(struct rio_mport *mport, int index, u16 destid,
  423. u8 hopcount, u32 offset, int len, u32 val)
  424. {
  425. struct rio_priv *priv = mport->priv;
  426. u8 *data;
  427. pr_debug
  428. ("fsl_rio_config_write: index %d destid %d hopcount %d offset %8.8x len %d val %8.8x\n",
  429. index, destid, hopcount, offset, len, val);
  430. /* 16MB maintenance windows possible */
  431. /* allow only aligned access to maintenance registers */
  432. if (offset > (0x1000000 - len) || !IS_ALIGNED(offset, len))
  433. return -EINVAL;
  434. out_be32(&priv->maint_atmu_regs->rowtar,
  435. (destid << 22) | (hopcount << 12) | (offset >> 12));
  436. out_be32(&priv->maint_atmu_regs->rowtear, (destid >> 10));
  437. data = (u8 *) priv->maint_win + (offset & (RIO_MAINT_WIN_SIZE - 1));
  438. switch (len) {
  439. case 1:
  440. out_8((u8 *) data, val);
  441. break;
  442. case 2:
  443. out_be16((u16 *) data, val);
  444. break;
  445. case 4:
  446. out_be32((u32 *) data, val);
  447. break;
  448. default:
  449. return -EINVAL;
  450. }
  451. return 0;
  452. }
  453. /**
  454. * fsl_add_outb_message - Add message to the MPC85xx outbound message queue
  455. * @mport: Master port with outbound message queue
  456. * @rdev: Target of outbound message
  457. * @mbox: Outbound mailbox
  458. * @buffer: Message to add to outbound queue
  459. * @len: Length of message
  460. *
  461. * Adds the @buffer message to the MPC85xx outbound message queue. Returns
  462. * %0 on success or %-EINVAL on failure.
  463. */
  464. static int
  465. fsl_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox,
  466. void *buffer, size_t len)
  467. {
  468. struct rio_priv *priv = mport->priv;
  469. u32 omr;
  470. struct rio_tx_desc *desc = (struct rio_tx_desc *)priv->msg_tx_ring.virt
  471. + priv->msg_tx_ring.tx_slot;
  472. int ret = 0;
  473. pr_debug("RIO: fsl_add_outb_message(): destid %4.4x mbox %d buffer " \
  474. "%8.8x len %8.8x\n", rdev->destid, mbox, (int)buffer, len);
  475. if ((len < 8) || (len > RIO_MAX_MSG_SIZE)) {
  476. ret = -EINVAL;
  477. goto out;
  478. }
  479. /* Copy and clear rest of buffer */
  480. memcpy(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot], buffer,
  481. len);
  482. if (len < (RIO_MAX_MSG_SIZE - 4))
  483. memset(priv->msg_tx_ring.virt_buffer[priv->msg_tx_ring.tx_slot]
  484. + len, 0, RIO_MAX_MSG_SIZE - len);
  485. switch (mport->phy_type) {
  486. case RIO_PHY_PARALLEL:
  487. /* Set mbox field for message */
  488. desc->dport = mbox & 0x3;
  489. /* Enable EOMI interrupt, set priority, and set destid */
  490. desc->dattr = 0x28000000 | (rdev->destid << 2);
  491. break;
  492. case RIO_PHY_SERIAL:
  493. /* Set mbox field for message, and set destid */
  494. desc->dport = (rdev->destid << 16) | (mbox & 0x3);
  495. /* Enable EOMI interrupt and priority */
  496. desc->dattr = 0x28000000;
  497. break;
  498. }
  499. /* Set transfer size aligned to next power of 2 (in double words) */
  500. desc->dwcnt = is_power_of_2(len) ? len : 1 << get_bitmask_order(len);
  501. /* Set snooping and source buffer address */
  502. desc->saddr = 0x00000004
  503. | priv->msg_tx_ring.phys_buffer[priv->msg_tx_ring.tx_slot];
  504. /* Increment enqueue pointer */
  505. omr = in_be32(&priv->msg_regs->omr);
  506. out_be32(&priv->msg_regs->omr, omr | RIO_MSG_OMR_MUI);
  507. /* Go to next descriptor */
  508. if (++priv->msg_tx_ring.tx_slot == priv->msg_tx_ring.size)
  509. priv->msg_tx_ring.tx_slot = 0;
  510. out:
  511. return ret;
  512. }
  513. /**
  514. * fsl_rio_tx_handler - MPC85xx outbound message interrupt handler
  515. * @irq: Linux interrupt number
  516. * @dev_instance: Pointer to interrupt-specific data
  517. *
  518. * Handles outbound message interrupts. Executes a register outbound
  519. * mailbox event handler and acks the interrupt occurrence.
  520. */
  521. static irqreturn_t
  522. fsl_rio_tx_handler(int irq, void *dev_instance)
  523. {
  524. int osr;
  525. struct rio_mport *port = (struct rio_mport *)dev_instance;
  526. struct rio_priv *priv = port->priv;
  527. osr = in_be32(&priv->msg_regs->osr);
  528. if (osr & RIO_MSG_OSR_TE) {
  529. pr_info("RIO: outbound message transmission error\n");
  530. out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_TE);
  531. goto out;
  532. }
  533. if (osr & RIO_MSG_OSR_QOI) {
  534. pr_info("RIO: outbound message queue overflow\n");
  535. out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_QOI);
  536. goto out;
  537. }
  538. if (osr & RIO_MSG_OSR_EOMI) {
  539. u32 dqp = in_be32(&priv->msg_regs->odqdpar);
  540. int slot = (dqp - priv->msg_tx_ring.phys) >> 5;
  541. port->outb_msg[0].mcback(port, priv->msg_tx_ring.dev_id, -1,
  542. slot);
  543. /* Ack the end-of-message interrupt */
  544. out_be32(&priv->msg_regs->osr, RIO_MSG_OSR_EOMI);
  545. }
  546. out:
  547. return IRQ_HANDLED;
  548. }
  549. /**
  550. * fsl_open_outb_mbox - Initialize MPC85xx outbound mailbox
  551. * @mport: Master port implementing the outbound message unit
  552. * @dev_id: Device specific pointer to pass on event
  553. * @mbox: Mailbox to open
  554. * @entries: Number of entries in the outbound mailbox ring
  555. *
  556. * Initializes buffer ring, request the outbound message interrupt,
  557. * and enables the outbound message unit. Returns %0 on success and
  558. * %-EINVAL or %-ENOMEM on failure.
  559. */
  560. static int
  561. fsl_open_outb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
  562. {
  563. int i, j, rc = 0;
  564. struct rio_priv *priv = mport->priv;
  565. if ((entries < RIO_MIN_TX_RING_SIZE) ||
  566. (entries > RIO_MAX_TX_RING_SIZE) || (!is_power_of_2(entries))) {
  567. rc = -EINVAL;
  568. goto out;
  569. }
  570. /* Initialize shadow copy ring */
  571. priv->msg_tx_ring.dev_id = dev_id;
  572. priv->msg_tx_ring.size = entries;
  573. for (i = 0; i < priv->msg_tx_ring.size; i++) {
  574. priv->msg_tx_ring.virt_buffer[i] =
  575. dma_alloc_coherent(priv->dev, RIO_MSG_BUFFER_SIZE,
  576. &priv->msg_tx_ring.phys_buffer[i], GFP_KERNEL);
  577. if (!priv->msg_tx_ring.virt_buffer[i]) {
  578. rc = -ENOMEM;
  579. for (j = 0; j < priv->msg_tx_ring.size; j++)
  580. if (priv->msg_tx_ring.virt_buffer[j])
  581. dma_free_coherent(priv->dev,
  582. RIO_MSG_BUFFER_SIZE,
  583. priv->msg_tx_ring.
  584. virt_buffer[j],
  585. priv->msg_tx_ring.
  586. phys_buffer[j]);
  587. goto out;
  588. }
  589. }
  590. /* Initialize outbound message descriptor ring */
  591. priv->msg_tx_ring.virt = dma_alloc_coherent(priv->dev,
  592. priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
  593. &priv->msg_tx_ring.phys, GFP_KERNEL);
  594. if (!priv->msg_tx_ring.virt) {
  595. rc = -ENOMEM;
  596. goto out_dma;
  597. }
  598. memset(priv->msg_tx_ring.virt, 0,
  599. priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE);
  600. priv->msg_tx_ring.tx_slot = 0;
  601. /* Point dequeue/enqueue pointers at first entry in ring */
  602. out_be32(&priv->msg_regs->odqdpar, priv->msg_tx_ring.phys);
  603. out_be32(&priv->msg_regs->odqepar, priv->msg_tx_ring.phys);
  604. /* Configure for snooping */
  605. out_be32(&priv->msg_regs->osar, 0x00000004);
  606. /* Clear interrupt status */
  607. out_be32(&priv->msg_regs->osr, 0x000000b3);
  608. /* Hook up outbound message handler */
  609. rc = request_irq(IRQ_RIO_TX(mport), fsl_rio_tx_handler, 0,
  610. "msg_tx", (void *)mport);
  611. if (rc < 0)
  612. goto out_irq;
  613. /*
  614. * Configure outbound message unit
  615. * Snooping
  616. * Interrupts (all enabled, except QEIE)
  617. * Chaining mode
  618. * Disable
  619. */
  620. out_be32(&priv->msg_regs->omr, 0x00100220);
  621. /* Set number of entries */
  622. out_be32(&priv->msg_regs->omr,
  623. in_be32(&priv->msg_regs->omr) |
  624. ((get_bitmask_order(entries) - 2) << 12));
  625. /* Now enable the unit */
  626. out_be32(&priv->msg_regs->omr, in_be32(&priv->msg_regs->omr) | 0x1);
  627. out:
  628. return rc;
  629. out_irq:
  630. dma_free_coherent(priv->dev,
  631. priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
  632. priv->msg_tx_ring.virt, priv->msg_tx_ring.phys);
  633. out_dma:
  634. for (i = 0; i < priv->msg_tx_ring.size; i++)
  635. dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE,
  636. priv->msg_tx_ring.virt_buffer[i],
  637. priv->msg_tx_ring.phys_buffer[i]);
  638. return rc;
  639. }
  640. /**
  641. * fsl_close_outb_mbox - Shut down MPC85xx outbound mailbox
  642. * @mport: Master port implementing the outbound message unit
  643. * @mbox: Mailbox to close
  644. *
  645. * Disables the outbound message unit, free all buffers, and
  646. * frees the outbound message interrupt.
  647. */
  648. static void fsl_close_outb_mbox(struct rio_mport *mport, int mbox)
  649. {
  650. struct rio_priv *priv = mport->priv;
  651. /* Disable inbound message unit */
  652. out_be32(&priv->msg_regs->omr, 0);
  653. /* Free ring */
  654. dma_free_coherent(priv->dev,
  655. priv->msg_tx_ring.size * RIO_MSG_DESC_SIZE,
  656. priv->msg_tx_ring.virt, priv->msg_tx_ring.phys);
  657. /* Free interrupt */
  658. free_irq(IRQ_RIO_TX(mport), (void *)mport);
  659. }
  660. /**
  661. * fsl_rio_rx_handler - MPC85xx inbound message interrupt handler
  662. * @irq: Linux interrupt number
  663. * @dev_instance: Pointer to interrupt-specific data
  664. *
  665. * Handles inbound message interrupts. Executes a registered inbound
  666. * mailbox event handler and acks the interrupt occurrence.
  667. */
  668. static irqreturn_t
  669. fsl_rio_rx_handler(int irq, void *dev_instance)
  670. {
  671. int isr;
  672. struct rio_mport *port = (struct rio_mport *)dev_instance;
  673. struct rio_priv *priv = port->priv;
  674. isr = in_be32(&priv->msg_regs->isr);
  675. if (isr & RIO_MSG_ISR_TE) {
  676. pr_info("RIO: inbound message reception error\n");
  677. out_be32((void *)&priv->msg_regs->isr, RIO_MSG_ISR_TE);
  678. goto out;
  679. }
  680. /* XXX Need to check/dispatch until queue empty */
  681. if (isr & RIO_MSG_ISR_DIQI) {
  682. /*
  683. * We implement *only* mailbox 0, but can receive messages
  684. * for any mailbox/letter to that mailbox destination. So,
  685. * make the callback with an unknown/invalid mailbox number
  686. * argument.
  687. */
  688. port->inb_msg[0].mcback(port, priv->msg_rx_ring.dev_id, -1, -1);
  689. /* Ack the queueing interrupt */
  690. out_be32(&priv->msg_regs->isr, RIO_MSG_ISR_DIQI);
  691. }
  692. out:
  693. return IRQ_HANDLED;
  694. }
  695. /**
  696. * fsl_open_inb_mbox - Initialize MPC85xx inbound mailbox
  697. * @mport: Master port implementing the inbound message unit
  698. * @dev_id: Device specific pointer to pass on event
  699. * @mbox: Mailbox to open
  700. * @entries: Number of entries in the inbound mailbox ring
  701. *
  702. * Initializes buffer ring, request the inbound message interrupt,
  703. * and enables the inbound message unit. Returns %0 on success
  704. * and %-EINVAL or %-ENOMEM on failure.
  705. */
  706. static int
  707. fsl_open_inb_mbox(struct rio_mport *mport, void *dev_id, int mbox, int entries)
  708. {
  709. int i, rc = 0;
  710. struct rio_priv *priv = mport->priv;
  711. if ((entries < RIO_MIN_RX_RING_SIZE) ||
  712. (entries > RIO_MAX_RX_RING_SIZE) || (!is_power_of_2(entries))) {
  713. rc = -EINVAL;
  714. goto out;
  715. }
  716. /* Initialize client buffer ring */
  717. priv->msg_rx_ring.dev_id = dev_id;
  718. priv->msg_rx_ring.size = entries;
  719. priv->msg_rx_ring.rx_slot = 0;
  720. for (i = 0; i < priv->msg_rx_ring.size; i++)
  721. priv->msg_rx_ring.virt_buffer[i] = NULL;
  722. /* Initialize inbound message ring */
  723. priv->msg_rx_ring.virt = dma_alloc_coherent(priv->dev,
  724. priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
  725. &priv->msg_rx_ring.phys, GFP_KERNEL);
  726. if (!priv->msg_rx_ring.virt) {
  727. rc = -ENOMEM;
  728. goto out;
  729. }
  730. /* Point dequeue/enqueue pointers at first entry in ring */
  731. out_be32(&priv->msg_regs->ifqdpar, (u32) priv->msg_rx_ring.phys);
  732. out_be32(&priv->msg_regs->ifqepar, (u32) priv->msg_rx_ring.phys);
  733. /* Clear interrupt status */
  734. out_be32(&priv->msg_regs->isr, 0x00000091);
  735. /* Hook up inbound message handler */
  736. rc = request_irq(IRQ_RIO_RX(mport), fsl_rio_rx_handler, 0,
  737. "msg_rx", (void *)mport);
  738. if (rc < 0) {
  739. dma_free_coherent(priv->dev, RIO_MSG_BUFFER_SIZE,
  740. priv->msg_tx_ring.virt_buffer[i],
  741. priv->msg_tx_ring.phys_buffer[i]);
  742. goto out;
  743. }
  744. /*
  745. * Configure inbound message unit:
  746. * Snooping
  747. * 4KB max message size
  748. * Unmask all interrupt sources
  749. * Disable
  750. */
  751. out_be32(&priv->msg_regs->imr, 0x001b0060);
  752. /* Set number of queue entries */
  753. setbits32(&priv->msg_regs->imr, (get_bitmask_order(entries) - 2) << 12);
  754. /* Now enable the unit */
  755. setbits32(&priv->msg_regs->imr, 0x1);
  756. out:
  757. return rc;
  758. }
  759. /**
  760. * fsl_close_inb_mbox - Shut down MPC85xx inbound mailbox
  761. * @mport: Master port implementing the inbound message unit
  762. * @mbox: Mailbox to close
  763. *
  764. * Disables the inbound message unit, free all buffers, and
  765. * frees the inbound message interrupt.
  766. */
  767. static void fsl_close_inb_mbox(struct rio_mport *mport, int mbox)
  768. {
  769. struct rio_priv *priv = mport->priv;
  770. /* Disable inbound message unit */
  771. out_be32(&priv->msg_regs->imr, 0);
  772. /* Free ring */
  773. dma_free_coherent(priv->dev, priv->msg_rx_ring.size * RIO_MAX_MSG_SIZE,
  774. priv->msg_rx_ring.virt, priv->msg_rx_ring.phys);
  775. /* Free interrupt */
  776. free_irq(IRQ_RIO_RX(mport), (void *)mport);
  777. }
  778. /**
  779. * fsl_add_inb_buffer - Add buffer to the MPC85xx inbound message queue
  780. * @mport: Master port implementing the inbound message unit
  781. * @mbox: Inbound mailbox number
  782. * @buf: Buffer to add to inbound queue
  783. *
  784. * Adds the @buf buffer to the MPC85xx inbound message queue. Returns
  785. * %0 on success or %-EINVAL on failure.
  786. */
  787. static int fsl_add_inb_buffer(struct rio_mport *mport, int mbox, void *buf)
  788. {
  789. int rc = 0;
  790. struct rio_priv *priv = mport->priv;
  791. pr_debug("RIO: fsl_add_inb_buffer(), msg_rx_ring.rx_slot %d\n",
  792. priv->msg_rx_ring.rx_slot);
  793. if (priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot]) {
  794. printk(KERN_ERR
  795. "RIO: error adding inbound buffer %d, buffer exists\n",
  796. priv->msg_rx_ring.rx_slot);
  797. rc = -EINVAL;
  798. goto out;
  799. }
  800. priv->msg_rx_ring.virt_buffer[priv->msg_rx_ring.rx_slot] = buf;
  801. if (++priv->msg_rx_ring.rx_slot == priv->msg_rx_ring.size)
  802. priv->msg_rx_ring.rx_slot = 0;
  803. out:
  804. return rc;
  805. }
  806. /**
  807. * fsl_get_inb_message - Fetch inbound message from the MPC85xx message unit
  808. * @mport: Master port implementing the inbound message unit
  809. * @mbox: Inbound mailbox number
  810. *
  811. * Gets the next available inbound message from the inbound message queue.
  812. * A pointer to the message is returned on success or NULL on failure.
  813. */
  814. static void *fsl_get_inb_message(struct rio_mport *mport, int mbox)
  815. {
  816. struct rio_priv *priv = mport->priv;
  817. u32 phys_buf, virt_buf;
  818. void *buf = NULL;
  819. int buf_idx;
  820. phys_buf = in_be32(&priv->msg_regs->ifqdpar);
  821. /* If no more messages, then bail out */
  822. if (phys_buf == in_be32(&priv->msg_regs->ifqepar))
  823. goto out2;
  824. virt_buf = (u32) priv->msg_rx_ring.virt + (phys_buf
  825. - priv->msg_rx_ring.phys);
  826. buf_idx = (phys_buf - priv->msg_rx_ring.phys) / RIO_MAX_MSG_SIZE;
  827. buf = priv->msg_rx_ring.virt_buffer[buf_idx];
  828. if (!buf) {
  829. printk(KERN_ERR
  830. "RIO: inbound message copy failed, no buffers\n");
  831. goto out1;
  832. }
  833. /* Copy max message size, caller is expected to allocate that big */
  834. memcpy(buf, (void *)virt_buf, RIO_MAX_MSG_SIZE);
  835. /* Clear the available buffer */
  836. priv->msg_rx_ring.virt_buffer[buf_idx] = NULL;
  837. out1:
  838. setbits32(&priv->msg_regs->imr, RIO_MSG_IMR_MI);
  839. out2:
  840. return buf;
  841. }
  842. /**
  843. * fsl_rio_dbell_handler - MPC85xx doorbell interrupt handler
  844. * @irq: Linux interrupt number
  845. * @dev_instance: Pointer to interrupt-specific data
  846. *
  847. * Handles doorbell interrupts. Parses a list of registered
  848. * doorbell event handlers and executes a matching event handler.
  849. */
  850. static irqreturn_t
  851. fsl_rio_dbell_handler(int irq, void *dev_instance)
  852. {
  853. int dsr;
  854. struct rio_mport *port = (struct rio_mport *)dev_instance;
  855. struct rio_priv *priv = port->priv;
  856. dsr = in_be32(&priv->msg_regs->dsr);
  857. if (dsr & DOORBELL_DSR_TE) {
  858. pr_info("RIO: doorbell reception error\n");
  859. out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_TE);
  860. goto out;
  861. }
  862. if (dsr & DOORBELL_DSR_QFI) {
  863. pr_info("RIO: doorbell queue full\n");
  864. out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_QFI);
  865. }
  866. /* XXX Need to check/dispatch until queue empty */
  867. if (dsr & DOORBELL_DSR_DIQI) {
  868. u32 dmsg =
  869. (u32) priv->dbell_ring.virt +
  870. (in_be32(&priv->msg_regs->dqdpar) & 0xfff);
  871. struct rio_dbell *dbell;
  872. int found = 0;
  873. pr_debug
  874. ("RIO: processing doorbell, sid %2.2x tid %2.2x info %4.4x\n",
  875. DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg));
  876. list_for_each_entry(dbell, &port->dbells, node) {
  877. if ((dbell->res->start <= DBELL_INF(dmsg)) &&
  878. (dbell->res->end >= DBELL_INF(dmsg))) {
  879. found = 1;
  880. break;
  881. }
  882. }
  883. if (found) {
  884. dbell->dinb(port, dbell->dev_id, DBELL_SID(dmsg), DBELL_TID(dmsg),
  885. DBELL_INF(dmsg));
  886. } else {
  887. pr_debug
  888. ("RIO: spurious doorbell, sid %2.2x tid %2.2x info %4.4x\n",
  889. DBELL_SID(dmsg), DBELL_TID(dmsg), DBELL_INF(dmsg));
  890. }
  891. setbits32(&priv->msg_regs->dmr, DOORBELL_DMR_DI);
  892. out_be32(&priv->msg_regs->dsr, DOORBELL_DSR_DIQI);
  893. }
  894. out:
  895. return IRQ_HANDLED;
  896. }
  897. /**
  898. * fsl_rio_doorbell_init - MPC85xx doorbell interface init
  899. * @mport: Master port implementing the inbound doorbell unit
  900. *
  901. * Initializes doorbell unit hardware and inbound DMA buffer
  902. * ring. Called from fsl_rio_setup(). Returns %0 on success
  903. * or %-ENOMEM on failure.
  904. */
  905. static int fsl_rio_doorbell_init(struct rio_mport *mport)
  906. {
  907. struct rio_priv *priv = mport->priv;
  908. int rc = 0;
  909. /* Map outbound doorbell window immediately after maintenance window */
  910. priv->dbell_win = ioremap(mport->iores.start + RIO_MAINT_WIN_SIZE,
  911. RIO_DBELL_WIN_SIZE);
  912. if (!priv->dbell_win) {
  913. printk(KERN_ERR
  914. "RIO: unable to map outbound doorbell window\n");
  915. rc = -ENOMEM;
  916. goto out;
  917. }
  918. /* Initialize inbound doorbells */
  919. priv->dbell_ring.virt = dma_alloc_coherent(priv->dev, 512 *
  920. DOORBELL_MESSAGE_SIZE, &priv->dbell_ring.phys, GFP_KERNEL);
  921. if (!priv->dbell_ring.virt) {
  922. printk(KERN_ERR "RIO: unable allocate inbound doorbell ring\n");
  923. rc = -ENOMEM;
  924. iounmap(priv->dbell_win);
  925. goto out;
  926. }
  927. /* Point dequeue/enqueue pointers at first entry in ring */
  928. out_be32(&priv->msg_regs->dqdpar, (u32) priv->dbell_ring.phys);
  929. out_be32(&priv->msg_regs->dqepar, (u32) priv->dbell_ring.phys);
  930. /* Clear interrupt status */
  931. out_be32(&priv->msg_regs->dsr, 0x00000091);
  932. /* Hook up doorbell handler */
  933. rc = request_irq(IRQ_RIO_BELL(mport), fsl_rio_dbell_handler, 0,
  934. "dbell_rx", (void *)mport);
  935. if (rc < 0) {
  936. iounmap(priv->dbell_win);
  937. dma_free_coherent(priv->dev, 512 * DOORBELL_MESSAGE_SIZE,
  938. priv->dbell_ring.virt, priv->dbell_ring.phys);
  939. printk(KERN_ERR
  940. "MPC85xx RIO: unable to request inbound doorbell irq");
  941. goto out;
  942. }
  943. /* Configure doorbells for snooping, 512 entries, and enable */
  944. out_be32(&priv->msg_regs->dmr, 0x00108161);
  945. out:
  946. return rc;
  947. }
  948. static void port_error_handler(struct rio_mport *port, int offset)
  949. {
  950. /*XXX: Error recovery is not implemented, we just clear errors */
  951. out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), 0);
  952. if (offset == 0) {
  953. out_be32((u32 *)(rio_regs_win + RIO_PORT1_EDCSR), 0);
  954. out_be32((u32 *)(rio_regs_win + RIO_PORT1_IECSR), 0);
  955. out_be32((u32 *)(rio_regs_win + RIO_ESCSR), ESCSR_CLEAR);
  956. } else {
  957. out_be32((u32 *)(rio_regs_win + RIO_PORT2_EDCSR), 0);
  958. out_be32((u32 *)(rio_regs_win + RIO_PORT2_IECSR), 0);
  959. out_be32((u32 *)(rio_regs_win + RIO_PORT2_ESCSR), ESCSR_CLEAR);
  960. }
  961. }
  962. static void msg_unit_error_handler(struct rio_mport *port)
  963. {
  964. struct rio_priv *priv = port->priv;
  965. /*XXX: Error recovery is not implemented, we just clear errors */
  966. out_be32((u32 *)(rio_regs_win + RIO_LTLEDCSR), 0);
  967. out_be32((u32 *)(rio_regs_win + RIO_IM0SR), IMSR_CLEAR);
  968. out_be32((u32 *)(rio_regs_win + RIO_IM1SR), IMSR_CLEAR);
  969. out_be32((u32 *)(rio_regs_win + RIO_OM0SR), OMSR_CLEAR);
  970. out_be32((u32 *)(rio_regs_win + RIO_OM1SR), OMSR_CLEAR);
  971. out_be32(&priv->msg_regs->odsr, ODSR_CLEAR);
  972. out_be32(&priv->msg_regs->dsr, IDSR_CLEAR);
  973. out_be32(&priv->msg_regs->pwsr, IPWSR_CLEAR);
  974. }
  975. /**
  976. * fsl_rio_port_write_handler - MPC85xx port write interrupt handler
  977. * @irq: Linux interrupt number
  978. * @dev_instance: Pointer to interrupt-specific data
  979. *
  980. * Handles port write interrupts. Parses a list of registered
  981. * port write event handlers and executes a matching event handler.
  982. */
  983. static irqreturn_t
  984. fsl_rio_port_write_handler(int irq, void *dev_instance)
  985. {
  986. u32 ipwmr, ipwsr;
  987. struct rio_mport *port = (struct rio_mport *)dev_instance;
  988. struct rio_priv *priv = port->priv;
  989. u32 epwisr, tmp;
  990. epwisr = in_be32(priv->regs_win + RIO_EPWISR);
  991. if (!(epwisr & RIO_EPWISR_PW))
  992. goto pw_done;
  993. ipwmr = in_be32(&priv->msg_regs->pwmr);
  994. ipwsr = in_be32(&priv->msg_regs->pwsr);
  995. #ifdef DEBUG_PW
  996. pr_debug("PW Int->IPWMR: 0x%08x IPWSR: 0x%08x (", ipwmr, ipwsr);
  997. if (ipwsr & RIO_IPWSR_QF)
  998. pr_debug(" QF");
  999. if (ipwsr & RIO_IPWSR_TE)
  1000. pr_debug(" TE");
  1001. if (ipwsr & RIO_IPWSR_QFI)
  1002. pr_debug(" QFI");
  1003. if (ipwsr & RIO_IPWSR_PWD)
  1004. pr_debug(" PWD");
  1005. if (ipwsr & RIO_IPWSR_PWB)
  1006. pr_debug(" PWB");
  1007. pr_debug(" )\n");
  1008. #endif
  1009. /* Schedule deferred processing if PW was received */
  1010. if (ipwsr & RIO_IPWSR_QFI) {
  1011. /* Save PW message (if there is room in FIFO),
  1012. * otherwise discard it.
  1013. */
  1014. if (kfifo_avail(&priv->pw_fifo) >= RIO_PW_MSG_SIZE) {
  1015. priv->port_write_msg.msg_count++;
  1016. kfifo_in(&priv->pw_fifo, priv->port_write_msg.virt,
  1017. RIO_PW_MSG_SIZE);
  1018. } else {
  1019. priv->port_write_msg.discard_count++;
  1020. pr_debug("RIO: ISR Discarded Port-Write Msg(s) (%d)\n",
  1021. priv->port_write_msg.discard_count);
  1022. }
  1023. /* Clear interrupt and issue Clear Queue command. This allows
  1024. * another port-write to be received.
  1025. */
  1026. out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_QFI);
  1027. out_be32(&priv->msg_regs->pwmr, ipwmr | RIO_IPWMR_CQ);
  1028. schedule_work(&priv->pw_work);
  1029. }
  1030. if ((ipwmr & RIO_IPWMR_EIE) && (ipwsr & RIO_IPWSR_TE)) {
  1031. priv->port_write_msg.err_count++;
  1032. pr_debug("RIO: Port-Write Transaction Err (%d)\n",
  1033. priv->port_write_msg.err_count);
  1034. /* Clear Transaction Error: port-write controller should be
  1035. * disabled when clearing this error
  1036. */
  1037. out_be32(&priv->msg_regs->pwmr, ipwmr & ~RIO_IPWMR_PWE);
  1038. out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_TE);
  1039. out_be32(&priv->msg_regs->pwmr, ipwmr);
  1040. }
  1041. if (ipwsr & RIO_IPWSR_PWD) {
  1042. priv->port_write_msg.discard_count++;
  1043. pr_debug("RIO: Port Discarded Port-Write Msg(s) (%d)\n",
  1044. priv->port_write_msg.discard_count);
  1045. out_be32(&priv->msg_regs->pwsr, RIO_IPWSR_PWD);
  1046. }
  1047. pw_done:
  1048. if (epwisr & RIO_EPWISR_PINT1) {
  1049. tmp = in_be32(priv->regs_win + RIO_LTLEDCSR);
  1050. pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp);
  1051. port_error_handler(port, 0);
  1052. }
  1053. if (epwisr & RIO_EPWISR_PINT2) {
  1054. tmp = in_be32(priv->regs_win + RIO_LTLEDCSR);
  1055. pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp);
  1056. port_error_handler(port, 1);
  1057. }
  1058. if (epwisr & RIO_EPWISR_MU) {
  1059. tmp = in_be32(priv->regs_win + RIO_LTLEDCSR);
  1060. pr_debug("RIO_LTLEDCSR = 0x%x\n", tmp);
  1061. msg_unit_error_handler(port);
  1062. }
  1063. return IRQ_HANDLED;
  1064. }
  1065. static void fsl_pw_dpc(struct work_struct *work)
  1066. {
  1067. struct rio_priv *priv = container_of(work, struct rio_priv, pw_work);
  1068. unsigned long flags;
  1069. u32 msg_buffer[RIO_PW_MSG_SIZE/sizeof(u32)];
  1070. /*
  1071. * Process port-write messages
  1072. */
  1073. spin_lock_irqsave(&priv->pw_fifo_lock, flags);
  1074. while (kfifo_out(&priv->pw_fifo, (unsigned char *)msg_buffer,
  1075. RIO_PW_MSG_SIZE)) {
  1076. /* Process one message */
  1077. spin_unlock_irqrestore(&priv->pw_fifo_lock, flags);
  1078. #ifdef DEBUG_PW
  1079. {
  1080. u32 i;
  1081. pr_debug("%s : Port-Write Message:", __func__);
  1082. for (i = 0; i < RIO_PW_MSG_SIZE/sizeof(u32); i++) {
  1083. if ((i%4) == 0)
  1084. pr_debug("\n0x%02x: 0x%08x", i*4,
  1085. msg_buffer[i]);
  1086. else
  1087. pr_debug(" 0x%08x", msg_buffer[i]);
  1088. }
  1089. pr_debug("\n");
  1090. }
  1091. #endif
  1092. /* Pass the port-write message to RIO core for processing */
  1093. rio_inb_pwrite_handler((union rio_pw_msg *)msg_buffer);
  1094. spin_lock_irqsave(&priv->pw_fifo_lock, flags);
  1095. }
  1096. spin_unlock_irqrestore(&priv->pw_fifo_lock, flags);
  1097. }
  1098. /**
  1099. * fsl_rio_pw_enable - enable/disable port-write interface init
  1100. * @mport: Master port implementing the port write unit
  1101. * @enable: 1=enable; 0=disable port-write message handling
  1102. */
  1103. static int fsl_rio_pw_enable(struct rio_mport *mport, int enable)
  1104. {
  1105. struct rio_priv *priv = mport->priv;
  1106. u32 rval;
  1107. rval = in_be32(&priv->msg_regs->pwmr);
  1108. if (enable)
  1109. rval |= RIO_IPWMR_PWE;
  1110. else
  1111. rval &= ~RIO_IPWMR_PWE;
  1112. out_be32(&priv->msg_regs->pwmr, rval);
  1113. return 0;
  1114. }
  1115. /**
  1116. * fsl_rio_port_write_init - MPC85xx port write interface init
  1117. * @mport: Master port implementing the port write unit
  1118. *
  1119. * Initializes port write unit hardware and DMA buffer
  1120. * ring. Called from fsl_rio_setup(). Returns %0 on success
  1121. * or %-ENOMEM on failure.
  1122. */
  1123. static int fsl_rio_port_write_init(struct rio_mport *mport)
  1124. {
  1125. struct rio_priv *priv = mport->priv;
  1126. int rc = 0;
  1127. /* Following configurations require a disabled port write controller */
  1128. out_be32(&priv->msg_regs->pwmr,
  1129. in_be32(&priv->msg_regs->pwmr) & ~RIO_IPWMR_PWE);
  1130. /* Initialize port write */
  1131. priv->port_write_msg.virt = dma_alloc_coherent(priv->dev,
  1132. RIO_PW_MSG_SIZE,
  1133. &priv->port_write_msg.phys, GFP_KERNEL);
  1134. if (!priv->port_write_msg.virt) {
  1135. pr_err("RIO: unable allocate port write queue\n");
  1136. return -ENOMEM;
  1137. }
  1138. priv->port_write_msg.err_count = 0;
  1139. priv->port_write_msg.discard_count = 0;
  1140. /* Point dequeue/enqueue pointers at first entry */
  1141. out_be32(&priv->msg_regs->epwqbar, 0);
  1142. out_be32(&priv->msg_regs->pwqbar, (u32) priv->port_write_msg.phys);
  1143. pr_debug("EIPWQBAR: 0x%08x IPWQBAR: 0x%08x\n",
  1144. in_be32(&priv->msg_regs->epwqbar),
  1145. in_be32(&priv->msg_regs->pwqbar));
  1146. /* Clear interrupt status IPWSR */
  1147. out_be32(&priv->msg_regs->pwsr,
  1148. (RIO_IPWSR_TE | RIO_IPWSR_QFI | RIO_IPWSR_PWD));
  1149. /* Configure port write contoller for snooping enable all reporting,
  1150. clear queue full */
  1151. out_be32(&priv->msg_regs->pwmr,
  1152. RIO_IPWMR_SEN | RIO_IPWMR_QFIE | RIO_IPWMR_EIE | RIO_IPWMR_CQ);
  1153. /* Hook up port-write handler */
  1154. rc = request_irq(IRQ_RIO_PW(mport), fsl_rio_port_write_handler,
  1155. IRQF_SHARED, "port-write", (void *)mport);
  1156. if (rc < 0) {
  1157. pr_err("MPC85xx RIO: unable to request inbound doorbell irq");
  1158. goto err_out;
  1159. }
  1160. /* Enable Error Interrupt */
  1161. out_be32((u32 *)(rio_regs_win + RIO_LTLEECSR), LTLEECSR_ENABLE_ALL);
  1162. INIT_WORK(&priv->pw_work, fsl_pw_dpc);
  1163. spin_lock_init(&priv->pw_fifo_lock);
  1164. if (kfifo_alloc(&priv->pw_fifo, RIO_PW_MSG_SIZE * 32, GFP_KERNEL)) {
  1165. pr_err("FIFO allocation failed\n");
  1166. rc = -ENOMEM;
  1167. goto err_out_irq;
  1168. }
  1169. pr_debug("IPWMR: 0x%08x IPWSR: 0x%08x\n",
  1170. in_be32(&priv->msg_regs->pwmr),
  1171. in_be32(&priv->msg_regs->pwsr));
  1172. return rc;
  1173. err_out_irq:
  1174. free_irq(IRQ_RIO_PW(mport), (void *)mport);
  1175. err_out:
  1176. dma_free_coherent(priv->dev, RIO_PW_MSG_SIZE,
  1177. priv->port_write_msg.virt,
  1178. priv->port_write_msg.phys);
  1179. return rc;
  1180. }
  1181. static inline void fsl_rio_info(struct device *dev, u32 ccsr)
  1182. {
  1183. const char *str;
  1184. if (ccsr & 1) {
  1185. /* Serial phy */
  1186. switch (ccsr >> 30) {
  1187. case 0:
  1188. str = "1";
  1189. break;
  1190. case 1:
  1191. str = "4";
  1192. break;
  1193. default:
  1194. str = "Unknown";
  1195. break;
  1196. }
  1197. dev_info(dev, "Hardware port width: %s\n", str);
  1198. switch ((ccsr >> 27) & 7) {
  1199. case 0:
  1200. str = "Single-lane 0";
  1201. break;
  1202. case 1:
  1203. str = "Single-lane 2";
  1204. break;
  1205. case 2:
  1206. str = "Four-lane";
  1207. break;
  1208. default:
  1209. str = "Unknown";
  1210. break;
  1211. }
  1212. dev_info(dev, "Training connection status: %s\n", str);
  1213. } else {
  1214. /* Parallel phy */
  1215. if (!(ccsr & 0x80000000))
  1216. dev_info(dev, "Output port operating in 8-bit mode\n");
  1217. if (!(ccsr & 0x08000000))
  1218. dev_info(dev, "Input port operating in 8-bit mode\n");
  1219. }
  1220. }
  1221. /**
  1222. * fsl_rio_setup - Setup Freescale PowerPC RapidIO interface
  1223. * @dev: platform_device pointer
  1224. *
  1225. * Initializes MPC85xx RapidIO hardware interface, configures
  1226. * master port with system-specific info, and registers the
  1227. * master port with the RapidIO subsystem.
  1228. */
  1229. int fsl_rio_setup(struct platform_device *dev)
  1230. {
  1231. struct rio_ops *ops;
  1232. struct rio_mport *port;
  1233. struct rio_priv *priv;
  1234. int rc = 0;
  1235. const u32 *dt_range, *cell;
  1236. struct resource regs;
  1237. int rlen;
  1238. u32 ccsr;
  1239. u64 law_start, law_size;
  1240. int paw, aw, sw;
  1241. if (!dev->dev.of_node) {
  1242. dev_err(&dev->dev, "Device OF-Node is NULL");
  1243. return -EFAULT;
  1244. }
  1245. rc = of_address_to_resource(dev->dev.of_node, 0, &regs);
  1246. if (rc) {
  1247. dev_err(&dev->dev, "Can't get %s property 'reg'\n",
  1248. dev->dev.of_node->full_name);
  1249. return -EFAULT;
  1250. }
  1251. dev_info(&dev->dev, "Of-device full name %s\n", dev->dev.of_node->full_name);
  1252. dev_info(&dev->dev, "Regs: %pR\n", &regs);
  1253. dt_range = of_get_property(dev->dev.of_node, "ranges", &rlen);
  1254. if (!dt_range) {
  1255. dev_err(&dev->dev, "Can't get %s property 'ranges'\n",
  1256. dev->dev.of_node->full_name);
  1257. return -EFAULT;
  1258. }
  1259. /* Get node address wide */
  1260. cell = of_get_property(dev->dev.of_node, "#address-cells", NULL);
  1261. if (cell)
  1262. aw = *cell;
  1263. else
  1264. aw = of_n_addr_cells(dev->dev.of_node);
  1265. /* Get node size wide */
  1266. cell = of_get_property(dev->dev.of_node, "#size-cells", NULL);
  1267. if (cell)
  1268. sw = *cell;
  1269. else
  1270. sw = of_n_size_cells(dev->dev.of_node);
  1271. /* Get parent address wide wide */
  1272. paw = of_n_addr_cells(dev->dev.of_node);
  1273. law_start = of_read_number(dt_range + aw, paw);
  1274. law_size = of_read_number(dt_range + aw + paw, sw);
  1275. dev_info(&dev->dev, "LAW start 0x%016llx, size 0x%016llx.\n",
  1276. law_start, law_size);
  1277. ops = kzalloc(sizeof(struct rio_ops), GFP_KERNEL);
  1278. if (!ops) {
  1279. rc = -ENOMEM;
  1280. goto err_ops;
  1281. }
  1282. ops->lcread = fsl_local_config_read;
  1283. ops->lcwrite = fsl_local_config_write;
  1284. ops->cread = fsl_rio_config_read;
  1285. ops->cwrite = fsl_rio_config_write;
  1286. ops->dsend = fsl_rio_doorbell_send;
  1287. ops->pwenable = fsl_rio_pw_enable;
  1288. ops->open_outb_mbox = fsl_open_outb_mbox;
  1289. ops->open_inb_mbox = fsl_open_inb_mbox;
  1290. ops->close_outb_mbox = fsl_close_outb_mbox;
  1291. ops->close_inb_mbox = fsl_close_inb_mbox;
  1292. ops->add_outb_message = fsl_add_outb_message;
  1293. ops->add_inb_buffer = fsl_add_inb_buffer;
  1294. ops->get_inb_message = fsl_get_inb_message;
  1295. port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
  1296. if (!port) {
  1297. rc = -ENOMEM;
  1298. goto err_port;
  1299. }
  1300. port->index = 0;
  1301. priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
  1302. if (!priv) {
  1303. printk(KERN_ERR "Can't alloc memory for 'priv'\n");
  1304. rc = -ENOMEM;
  1305. goto err_priv;
  1306. }
  1307. INIT_LIST_HEAD(&port->dbells);
  1308. port->iores.start = law_start;
  1309. port->iores.end = law_start + law_size - 1;
  1310. port->iores.flags = IORESOURCE_MEM;
  1311. port->iores.name = "rio_io_win";
  1312. if (request_resource(&iomem_resource, &port->iores) < 0) {
  1313. dev_err(&dev->dev, "RIO: Error requesting master port region"
  1314. " 0x%016llx-0x%016llx\n",
  1315. (u64)port->iores.start, (u64)port->iores.end);
  1316. rc = -ENOMEM;
  1317. goto err_res;
  1318. }
  1319. priv->pwirq = irq_of_parse_and_map(dev->dev.of_node, 0);
  1320. priv->bellirq = irq_of_parse_and_map(dev->dev.of_node, 2);
  1321. priv->txirq = irq_of_parse_and_map(dev->dev.of_node, 3);
  1322. priv->rxirq = irq_of_parse_and_map(dev->dev.of_node, 4);
  1323. dev_info(&dev->dev, "pwirq: %d, bellirq: %d, txirq: %d, rxirq %d\n",
  1324. priv->pwirq, priv->bellirq, priv->txirq, priv->rxirq);
  1325. rio_init_dbell_res(&port->riores[RIO_DOORBELL_RESOURCE], 0, 0xffff);
  1326. rio_init_mbox_res(&port->riores[RIO_INB_MBOX_RESOURCE], 0, 0);
  1327. rio_init_mbox_res(&port->riores[RIO_OUTB_MBOX_RESOURCE], 0, 0);
  1328. strcpy(port->name, "RIO0 mport");
  1329. priv->dev = &dev->dev;
  1330. port->ops = ops;
  1331. port->priv = priv;
  1332. port->phys_efptr = 0x100;
  1333. priv->regs_win = ioremap(regs.start, resource_size(&regs));
  1334. rio_regs_win = priv->regs_win;
  1335. /* Probe the master port phy type */
  1336. ccsr = in_be32(priv->regs_win + RIO_CCSR);
  1337. port->phy_type = (ccsr & 1) ? RIO_PHY_SERIAL : RIO_PHY_PARALLEL;
  1338. dev_info(&dev->dev, "RapidIO PHY type: %s\n",
  1339. (port->phy_type == RIO_PHY_PARALLEL) ? "parallel" :
  1340. ((port->phy_type == RIO_PHY_SERIAL) ? "serial" :
  1341. "unknown"));
  1342. /* Checking the port training status */
  1343. if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) {
  1344. dev_err(&dev->dev, "Port is not ready. "
  1345. "Try to restart connection...\n");
  1346. switch (port->phy_type) {
  1347. case RIO_PHY_SERIAL:
  1348. /* Disable ports */
  1349. out_be32(priv->regs_win + RIO_CCSR, 0);
  1350. /* Set 1x lane */
  1351. setbits32(priv->regs_win + RIO_CCSR, 0x02000000);
  1352. /* Enable ports */
  1353. setbits32(priv->regs_win + RIO_CCSR, 0x00600000);
  1354. break;
  1355. case RIO_PHY_PARALLEL:
  1356. /* Disable ports */
  1357. out_be32(priv->regs_win + RIO_CCSR, 0x22000000);
  1358. /* Enable ports */
  1359. out_be32(priv->regs_win + RIO_CCSR, 0x44000000);
  1360. break;
  1361. }
  1362. msleep(100);
  1363. if (in_be32((priv->regs_win + RIO_ESCSR)) & 1) {
  1364. dev_err(&dev->dev, "Port restart failed.\n");
  1365. rc = -ENOLINK;
  1366. goto err;
  1367. }
  1368. dev_info(&dev->dev, "Port restart success!\n");
  1369. }
  1370. fsl_rio_info(&dev->dev, ccsr);
  1371. port->sys_size = (in_be32((priv->regs_win + RIO_PEF_CAR))
  1372. & RIO_PEF_CTLS) >> 4;
  1373. dev_info(&dev->dev, "RapidIO Common Transport System size: %d\n",
  1374. port->sys_size ? 65536 : 256);
  1375. if (rio_register_mport(port))
  1376. goto err;
  1377. if (port->host_deviceid >= 0)
  1378. out_be32(priv->regs_win + RIO_GCCSR, RIO_PORT_GEN_HOST |
  1379. RIO_PORT_GEN_MASTER | RIO_PORT_GEN_DISCOVERED);
  1380. else
  1381. out_be32(priv->regs_win + RIO_GCCSR, 0x00000000);
  1382. priv->atmu_regs = (struct rio_atmu_regs *)(priv->regs_win
  1383. + RIO_ATMU_REGS_OFFSET);
  1384. priv->maint_atmu_regs = priv->atmu_regs + 1;
  1385. priv->dbell_atmu_regs = priv->atmu_regs + 2;
  1386. priv->msg_regs = (struct rio_msg_regs *)(priv->regs_win +
  1387. ((port->phy_type == RIO_PHY_SERIAL) ?
  1388. RIO_S_MSG_REGS_OFFSET : RIO_P_MSG_REGS_OFFSET));
  1389. /* Set to receive any dist ID for serial RapidIO controller. */
  1390. if (port->phy_type == RIO_PHY_SERIAL)
  1391. out_be32((priv->regs_win + RIO_ISR_AACR), RIO_ISR_AACR_AA);
  1392. /* Configure maintenance transaction window */
  1393. out_be32(&priv->maint_atmu_regs->rowbar, law_start >> 12);
  1394. out_be32(&priv->maint_atmu_regs->rowar,
  1395. 0x80077000 | (ilog2(RIO_MAINT_WIN_SIZE) - 1));
  1396. priv->maint_win = ioremap(law_start, RIO_MAINT_WIN_SIZE);
  1397. /* Configure outbound doorbell window */
  1398. out_be32(&priv->dbell_atmu_regs->rowbar,
  1399. (law_start + RIO_MAINT_WIN_SIZE) >> 12);
  1400. out_be32(&priv->dbell_atmu_regs->rowar, 0x8004200b); /* 4k */
  1401. fsl_rio_doorbell_init(port);
  1402. fsl_rio_port_write_init(port);
  1403. return 0;
  1404. err:
  1405. iounmap(priv->regs_win);
  1406. err_res:
  1407. kfree(priv);
  1408. err_priv:
  1409. kfree(port);
  1410. err_port:
  1411. kfree(ops);
  1412. err_ops:
  1413. return rc;
  1414. }
  1415. /* The probe function for RapidIO peer-to-peer network.
  1416. */
  1417. static int __devinit fsl_of_rio_rpn_probe(struct platform_device *dev)
  1418. {
  1419. printk(KERN_INFO "Setting up RapidIO peer-to-peer network %s\n",
  1420. dev->dev.of_node->full_name);
  1421. return fsl_rio_setup(dev);
  1422. };
  1423. static const struct of_device_id fsl_of_rio_rpn_ids[] = {
  1424. {
  1425. .compatible = "fsl,rapidio-delta",
  1426. },
  1427. {},
  1428. };
  1429. static struct platform_driver fsl_of_rio_rpn_driver = {
  1430. .driver = {
  1431. .name = "fsl-of-rio",
  1432. .owner = THIS_MODULE,
  1433. .of_match_table = fsl_of_rio_rpn_ids,
  1434. },
  1435. .probe = fsl_of_rio_rpn_probe,
  1436. };
  1437. static __init int fsl_of_rio_rpn_init(void)
  1438. {
  1439. return platform_driver_register(&fsl_of_rio_rpn_driver);
  1440. }
  1441. subsys_initcall(fsl_of_rio_rpn_init);