fsl_rio.c 46 KB

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