ti_hecc.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  1. /*
  2. * TI HECC (CAN) device driver
  3. *
  4. * This driver supports TI's HECC (High End CAN Controller module) and the
  5. * specs for the same is available at <http://www.ti.com>
  6. *
  7. * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
  8. * Copyright (C) 2019 Jeroen Hofstee <jhofstee@victronenergy.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation version 2.
  13. *
  14. * This program is distributed as is WITHOUT ANY WARRANTY of any
  15. * kind, whether express or implied; without even the implied warranty
  16. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. */
  20. #include <linux/module.h>
  21. #include <linux/kernel.h>
  22. #include <linux/types.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/errno.h>
  25. #include <linux/netdevice.h>
  26. #include <linux/skbuff.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/clk.h>
  29. #include <linux/io.h>
  30. #include <linux/of.h>
  31. #include <linux/of_device.h>
  32. #include <linux/regulator/consumer.h>
  33. #include <linux/can/dev.h>
  34. #include <linux/can/error.h>
  35. #include <linux/can/led.h>
  36. #include <linux/can/rx-offload.h>
  37. #define DRV_NAME "ti_hecc"
  38. #define HECC_MODULE_VERSION "0.7"
  39. MODULE_VERSION(HECC_MODULE_VERSION);
  40. #define DRV_DESC "TI High End CAN Controller Driver " HECC_MODULE_VERSION
  41. /* TX / RX Mailbox Configuration */
  42. #define HECC_MAX_MAILBOXES 32 /* hardware mailboxes - do not change */
  43. #define MAX_TX_PRIO 0x3F /* hardware value - do not change */
  44. /* Important Note: TX mailbox configuration
  45. * TX mailboxes should be restricted to the number of SKB buffers to avoid
  46. * maintaining SKB buffers separately. TX mailboxes should be a power of 2
  47. * for the mailbox logic to work. Top mailbox numbers are reserved for RX
  48. * and lower mailboxes for TX.
  49. *
  50. * HECC_MAX_TX_MBOX HECC_MB_TX_SHIFT
  51. * 4 (default) 2
  52. * 8 3
  53. * 16 4
  54. */
  55. #define HECC_MB_TX_SHIFT 2 /* as per table above */
  56. #define HECC_MAX_TX_MBOX BIT(HECC_MB_TX_SHIFT)
  57. #define HECC_TX_PRIO_SHIFT (HECC_MB_TX_SHIFT)
  58. #define HECC_TX_PRIO_MASK (MAX_TX_PRIO << HECC_MB_TX_SHIFT)
  59. #define HECC_TX_MB_MASK (HECC_MAX_TX_MBOX - 1)
  60. #define HECC_TX_MASK ((HECC_MAX_TX_MBOX - 1) | HECC_TX_PRIO_MASK)
  61. /* RX mailbox configuration
  62. *
  63. * The remaining mailboxes are used for reception and are delivered
  64. * based on their timestamp, to avoid a hardware race when CANME is
  65. * changed while CAN-bus traffic is being received.
  66. */
  67. #define HECC_MAX_RX_MBOX (HECC_MAX_MAILBOXES - HECC_MAX_TX_MBOX)
  68. #define HECC_RX_FIRST_MBOX (HECC_MAX_MAILBOXES - 1)
  69. #define HECC_RX_LAST_MBOX (HECC_MAX_TX_MBOX)
  70. /* TI HECC module registers */
  71. #define HECC_CANME 0x0 /* Mailbox enable */
  72. #define HECC_CANMD 0x4 /* Mailbox direction */
  73. #define HECC_CANTRS 0x8 /* Transmit request set */
  74. #define HECC_CANTRR 0xC /* Transmit request */
  75. #define HECC_CANTA 0x10 /* Transmission acknowledge */
  76. #define HECC_CANAA 0x14 /* Abort acknowledge */
  77. #define HECC_CANRMP 0x18 /* Receive message pending */
  78. #define HECC_CANRML 0x1C /* Receive message lost */
  79. #define HECC_CANRFP 0x20 /* Remote frame pending */
  80. #define HECC_CANGAM 0x24 /* SECC only:Global acceptance mask */
  81. #define HECC_CANMC 0x28 /* Master control */
  82. #define HECC_CANBTC 0x2C /* Bit timing configuration */
  83. #define HECC_CANES 0x30 /* Error and status */
  84. #define HECC_CANTEC 0x34 /* Transmit error counter */
  85. #define HECC_CANREC 0x38 /* Receive error counter */
  86. #define HECC_CANGIF0 0x3C /* Global interrupt flag 0 */
  87. #define HECC_CANGIM 0x40 /* Global interrupt mask */
  88. #define HECC_CANGIF1 0x44 /* Global interrupt flag 1 */
  89. #define HECC_CANMIM 0x48 /* Mailbox interrupt mask */
  90. #define HECC_CANMIL 0x4C /* Mailbox interrupt level */
  91. #define HECC_CANOPC 0x50 /* Overwrite protection control */
  92. #define HECC_CANTIOC 0x54 /* Transmit I/O control */
  93. #define HECC_CANRIOC 0x58 /* Receive I/O control */
  94. #define HECC_CANLNT 0x5C /* HECC only: Local network time */
  95. #define HECC_CANTOC 0x60 /* HECC only: Time-out control */
  96. #define HECC_CANTOS 0x64 /* HECC only: Time-out status */
  97. #define HECC_CANTIOCE 0x68 /* SCC only:Enhanced TX I/O control */
  98. #define HECC_CANRIOCE 0x6C /* SCC only:Enhanced RX I/O control */
  99. /* TI HECC RAM registers */
  100. #define HECC_CANMOTS 0x80 /* Message object time stamp */
  101. /* Mailbox registers */
  102. #define HECC_CANMID 0x0
  103. #define HECC_CANMCF 0x4
  104. #define HECC_CANMDL 0x8
  105. #define HECC_CANMDH 0xC
  106. #define HECC_SET_REG 0xFFFFFFFF
  107. #define HECC_CANID_MASK 0x3FF /* 18 bits mask for extended id's */
  108. #define HECC_CCE_WAIT_COUNT 100 /* Wait for ~1 sec for CCE bit */
  109. #define HECC_CANMC_SCM BIT(13) /* SCC compat mode */
  110. #define HECC_CANMC_CCR BIT(12) /* Change config request */
  111. #define HECC_CANMC_PDR BIT(11) /* Local Power down - for sleep mode */
  112. #define HECC_CANMC_ABO BIT(7) /* Auto Bus On */
  113. #define HECC_CANMC_STM BIT(6) /* Self test mode - loopback */
  114. #define HECC_CANMC_SRES BIT(5) /* Software reset */
  115. #define HECC_CANTIOC_EN BIT(3) /* Enable CAN TX I/O pin */
  116. #define HECC_CANRIOC_EN BIT(3) /* Enable CAN RX I/O pin */
  117. #define HECC_CANMID_IDE BIT(31) /* Extended frame format */
  118. #define HECC_CANMID_AME BIT(30) /* Acceptance mask enable */
  119. #define HECC_CANMID_AAM BIT(29) /* Auto answer mode */
  120. #define HECC_CANES_FE BIT(24) /* form error */
  121. #define HECC_CANES_BE BIT(23) /* bit error */
  122. #define HECC_CANES_SA1 BIT(22) /* stuck at dominant error */
  123. #define HECC_CANES_CRCE BIT(21) /* CRC error */
  124. #define HECC_CANES_SE BIT(20) /* stuff bit error */
  125. #define HECC_CANES_ACKE BIT(19) /* ack error */
  126. #define HECC_CANES_BO BIT(18) /* Bus off status */
  127. #define HECC_CANES_EP BIT(17) /* Error passive status */
  128. #define HECC_CANES_EW BIT(16) /* Error warning status */
  129. #define HECC_CANES_SMA BIT(5) /* suspend mode ack */
  130. #define HECC_CANES_CCE BIT(4) /* Change config enabled */
  131. #define HECC_CANES_PDA BIT(3) /* Power down mode ack */
  132. #define HECC_CANBTC_SAM BIT(7) /* sample points */
  133. #define HECC_BUS_ERROR (HECC_CANES_FE | HECC_CANES_BE |\
  134. HECC_CANES_CRCE | HECC_CANES_SE |\
  135. HECC_CANES_ACKE)
  136. #define HECC_CANES_FLAGS (HECC_BUS_ERROR | HECC_CANES_BO |\
  137. HECC_CANES_EP | HECC_CANES_EW)
  138. #define HECC_CANMCF_RTR BIT(4) /* Remote transmit request */
  139. #define HECC_CANGIF_MAIF BIT(17) /* Message alarm interrupt */
  140. #define HECC_CANGIF_TCOIF BIT(16) /* Timer counter overflow int */
  141. #define HECC_CANGIF_GMIF BIT(15) /* Global mailbox interrupt */
  142. #define HECC_CANGIF_AAIF BIT(14) /* Abort ack interrupt */
  143. #define HECC_CANGIF_WDIF BIT(13) /* Write denied interrupt */
  144. #define HECC_CANGIF_WUIF BIT(12) /* Wake up interrupt */
  145. #define HECC_CANGIF_RMLIF BIT(11) /* Receive message lost interrupt */
  146. #define HECC_CANGIF_BOIF BIT(10) /* Bus off interrupt */
  147. #define HECC_CANGIF_EPIF BIT(9) /* Error passive interrupt */
  148. #define HECC_CANGIF_WLIF BIT(8) /* Warning level interrupt */
  149. #define HECC_CANGIF_MBOX_MASK 0x1F /* Mailbox number mask */
  150. #define HECC_CANGIM_I1EN BIT(1) /* Int line 1 enable */
  151. #define HECC_CANGIM_I0EN BIT(0) /* Int line 0 enable */
  152. #define HECC_CANGIM_DEF_MASK 0x700 /* only busoff/warning/passive */
  153. #define HECC_CANGIM_SIL BIT(2) /* system interrupts to int line 1 */
  154. /* CAN Bittiming constants as per HECC specs */
  155. static const struct can_bittiming_const ti_hecc_bittiming_const = {
  156. .name = DRV_NAME,
  157. .tseg1_min = 1,
  158. .tseg1_max = 16,
  159. .tseg2_min = 1,
  160. .tseg2_max = 8,
  161. .sjw_max = 4,
  162. .brp_min = 1,
  163. .brp_max = 256,
  164. .brp_inc = 1,
  165. };
  166. struct ti_hecc_priv {
  167. struct can_priv can; /* MUST be first member/field */
  168. struct can_rx_offload offload;
  169. struct net_device *ndev;
  170. struct clk *clk;
  171. void __iomem *base;
  172. void __iomem *hecc_ram;
  173. void __iomem *mbx;
  174. bool use_hecc1int;
  175. spinlock_t mbx_lock; /* CANME register needs protection */
  176. u32 tx_head;
  177. u32 tx_tail;
  178. struct regulator *reg_xceiver;
  179. };
  180. static inline int get_tx_head_mb(struct ti_hecc_priv *priv)
  181. {
  182. return priv->tx_head & HECC_TX_MB_MASK;
  183. }
  184. static inline int get_tx_tail_mb(struct ti_hecc_priv *priv)
  185. {
  186. return priv->tx_tail & HECC_TX_MB_MASK;
  187. }
  188. static inline int get_tx_head_prio(struct ti_hecc_priv *priv)
  189. {
  190. return (priv->tx_head >> HECC_TX_PRIO_SHIFT) & MAX_TX_PRIO;
  191. }
  192. static inline void hecc_write_lam(struct ti_hecc_priv *priv, u32 mbxno, u32 val)
  193. {
  194. __raw_writel(val, priv->hecc_ram + mbxno * 4);
  195. }
  196. static inline u32 hecc_read_stamp(struct ti_hecc_priv *priv, u32 mbxno)
  197. {
  198. return __raw_readl(priv->hecc_ram + HECC_CANMOTS + mbxno * 4);
  199. }
  200. static inline void hecc_write_mbx(struct ti_hecc_priv *priv, u32 mbxno,
  201. u32 reg, u32 val)
  202. {
  203. __raw_writel(val, priv->mbx + mbxno * 0x10 + reg);
  204. }
  205. static inline u32 hecc_read_mbx(struct ti_hecc_priv *priv, u32 mbxno, u32 reg)
  206. {
  207. return __raw_readl(priv->mbx + mbxno * 0x10 + reg);
  208. }
  209. static inline void hecc_write(struct ti_hecc_priv *priv, u32 reg, u32 val)
  210. {
  211. __raw_writel(val, priv->base + reg);
  212. }
  213. static inline u32 hecc_read(struct ti_hecc_priv *priv, int reg)
  214. {
  215. return __raw_readl(priv->base + reg);
  216. }
  217. static inline void hecc_set_bit(struct ti_hecc_priv *priv, int reg,
  218. u32 bit_mask)
  219. {
  220. hecc_write(priv, reg, hecc_read(priv, reg) | bit_mask);
  221. }
  222. static inline void hecc_clear_bit(struct ti_hecc_priv *priv, int reg,
  223. u32 bit_mask)
  224. {
  225. hecc_write(priv, reg, hecc_read(priv, reg) & ~bit_mask);
  226. }
  227. static inline u32 hecc_get_bit(struct ti_hecc_priv *priv, int reg, u32 bit_mask)
  228. {
  229. return (hecc_read(priv, reg) & bit_mask) ? 1 : 0;
  230. }
  231. static int ti_hecc_set_btc(struct ti_hecc_priv *priv)
  232. {
  233. struct can_bittiming *bit_timing = &priv->can.bittiming;
  234. u32 can_btc;
  235. can_btc = (bit_timing->phase_seg2 - 1) & 0x7;
  236. can_btc |= ((bit_timing->phase_seg1 + bit_timing->prop_seg - 1)
  237. & 0xF) << 3;
  238. if (priv->can.ctrlmode & CAN_CTRLMODE_3_SAMPLES) {
  239. if (bit_timing->brp > 4)
  240. can_btc |= HECC_CANBTC_SAM;
  241. else
  242. netdev_warn(priv->ndev,
  243. "WARN: Triple sampling not set due to h/w limitations");
  244. }
  245. can_btc |= ((bit_timing->sjw - 1) & 0x3) << 8;
  246. can_btc |= ((bit_timing->brp - 1) & 0xFF) << 16;
  247. /* ERM being set to 0 by default meaning resync at falling edge */
  248. hecc_write(priv, HECC_CANBTC, can_btc);
  249. netdev_info(priv->ndev, "setting CANBTC=%#x\n", can_btc);
  250. return 0;
  251. }
  252. static int ti_hecc_transceiver_switch(const struct ti_hecc_priv *priv,
  253. int on)
  254. {
  255. if (!priv->reg_xceiver)
  256. return 0;
  257. if (on)
  258. return regulator_enable(priv->reg_xceiver);
  259. else
  260. return regulator_disable(priv->reg_xceiver);
  261. }
  262. static void ti_hecc_reset(struct net_device *ndev)
  263. {
  264. u32 cnt;
  265. struct ti_hecc_priv *priv = netdev_priv(ndev);
  266. netdev_dbg(ndev, "resetting hecc ...\n");
  267. hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_SRES);
  268. /* Set change control request and wait till enabled */
  269. hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
  270. /* INFO: It has been observed that at times CCE bit may not be
  271. * set and hw seems to be ok even if this bit is not set so
  272. * timing out with a timing of 1ms to respect the specs
  273. */
  274. cnt = HECC_CCE_WAIT_COUNT;
  275. while (!hecc_get_bit(priv, HECC_CANES, HECC_CANES_CCE) && cnt != 0) {
  276. --cnt;
  277. udelay(10);
  278. }
  279. /* Note: On HECC, BTC can be programmed only in initialization mode, so
  280. * it is expected that the can bittiming parameters are set via ip
  281. * utility before the device is opened
  282. */
  283. ti_hecc_set_btc(priv);
  284. /* Clear CCR (and CANMC register) and wait for CCE = 0 enable */
  285. hecc_write(priv, HECC_CANMC, 0);
  286. /* INFO: CAN net stack handles bus off and hence disabling auto-bus-on
  287. * hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_ABO);
  288. */
  289. /* INFO: It has been observed that at times CCE bit may not be
  290. * set and hw seems to be ok even if this bit is not set so
  291. */
  292. cnt = HECC_CCE_WAIT_COUNT;
  293. while (hecc_get_bit(priv, HECC_CANES, HECC_CANES_CCE) && cnt != 0) {
  294. --cnt;
  295. udelay(10);
  296. }
  297. /* Enable TX and RX I/O Control pins */
  298. hecc_write(priv, HECC_CANTIOC, HECC_CANTIOC_EN);
  299. hecc_write(priv, HECC_CANRIOC, HECC_CANRIOC_EN);
  300. /* Clear registers for clean operation */
  301. hecc_write(priv, HECC_CANTA, HECC_SET_REG);
  302. hecc_write(priv, HECC_CANRMP, HECC_SET_REG);
  303. hecc_write(priv, HECC_CANGIF0, HECC_SET_REG);
  304. hecc_write(priv, HECC_CANGIF1, HECC_SET_REG);
  305. hecc_write(priv, HECC_CANME, 0);
  306. hecc_write(priv, HECC_CANMD, 0);
  307. /* SCC compat mode NOT supported (and not needed too) */
  308. hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_SCM);
  309. }
  310. static void ti_hecc_start(struct net_device *ndev)
  311. {
  312. struct ti_hecc_priv *priv = netdev_priv(ndev);
  313. u32 cnt, mbxno, mbx_mask;
  314. /* put HECC in initialization mode and set btc */
  315. ti_hecc_reset(ndev);
  316. priv->tx_head = HECC_TX_MASK;
  317. priv->tx_tail = HECC_TX_MASK;
  318. /* Enable local and global acceptance mask registers */
  319. hecc_write(priv, HECC_CANGAM, HECC_SET_REG);
  320. /* Prepare configured mailboxes to receive messages */
  321. for (cnt = 0; cnt < HECC_MAX_RX_MBOX; cnt++) {
  322. mbxno = HECC_MAX_MAILBOXES - 1 - cnt;
  323. mbx_mask = BIT(mbxno);
  324. hecc_clear_bit(priv, HECC_CANME, mbx_mask);
  325. hecc_write_mbx(priv, mbxno, HECC_CANMID, HECC_CANMID_AME);
  326. hecc_write_lam(priv, mbxno, HECC_SET_REG);
  327. hecc_set_bit(priv, HECC_CANMD, mbx_mask);
  328. hecc_set_bit(priv, HECC_CANME, mbx_mask);
  329. hecc_set_bit(priv, HECC_CANMIM, mbx_mask);
  330. }
  331. /* Enable tx interrupts */
  332. hecc_set_bit(priv, HECC_CANMIM, BIT(HECC_MAX_TX_MBOX) - 1);
  333. /* Prevent message over-write to create a rx fifo, but not for
  334. * the lowest priority mailbox, since that allows detecting
  335. * overflows instead of the hardware silently dropping the
  336. * messages.
  337. */
  338. mbx_mask = ~BIT(HECC_RX_LAST_MBOX);
  339. hecc_write(priv, HECC_CANOPC, mbx_mask);
  340. /* Enable interrupts */
  341. if (priv->use_hecc1int) {
  342. hecc_write(priv, HECC_CANMIL, HECC_SET_REG);
  343. hecc_write(priv, HECC_CANGIM, HECC_CANGIM_DEF_MASK |
  344. HECC_CANGIM_I1EN | HECC_CANGIM_SIL);
  345. } else {
  346. hecc_write(priv, HECC_CANMIL, 0);
  347. hecc_write(priv, HECC_CANGIM,
  348. HECC_CANGIM_DEF_MASK | HECC_CANGIM_I0EN);
  349. }
  350. priv->can.state = CAN_STATE_ERROR_ACTIVE;
  351. }
  352. static void ti_hecc_stop(struct net_device *ndev)
  353. {
  354. struct ti_hecc_priv *priv = netdev_priv(ndev);
  355. /* Disable the CPK; stop sending, erroring and acking */
  356. hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_CCR);
  357. /* Disable interrupts and disable mailboxes */
  358. hecc_write(priv, HECC_CANGIM, 0);
  359. hecc_write(priv, HECC_CANMIM, 0);
  360. hecc_write(priv, HECC_CANME, 0);
  361. priv->can.state = CAN_STATE_STOPPED;
  362. }
  363. static int ti_hecc_do_set_mode(struct net_device *ndev, enum can_mode mode)
  364. {
  365. int ret = 0;
  366. switch (mode) {
  367. case CAN_MODE_START:
  368. ti_hecc_start(ndev);
  369. netif_wake_queue(ndev);
  370. break;
  371. default:
  372. ret = -EOPNOTSUPP;
  373. break;
  374. }
  375. return ret;
  376. }
  377. static int ti_hecc_get_berr_counter(const struct net_device *ndev,
  378. struct can_berr_counter *bec)
  379. {
  380. struct ti_hecc_priv *priv = netdev_priv(ndev);
  381. bec->txerr = hecc_read(priv, HECC_CANTEC);
  382. bec->rxerr = hecc_read(priv, HECC_CANREC);
  383. return 0;
  384. }
  385. /* ti_hecc_xmit: HECC Transmit
  386. *
  387. * The transmit mailboxes start from 0 to HECC_MAX_TX_MBOX. In HECC the
  388. * priority of the mailbox for tranmission is dependent upon priority setting
  389. * field in mailbox registers. The mailbox with highest value in priority field
  390. * is transmitted first. Only when two mailboxes have the same value in
  391. * priority field the highest numbered mailbox is transmitted first.
  392. *
  393. * To utilize the HECC priority feature as described above we start with the
  394. * highest numbered mailbox with highest priority level and move on to the next
  395. * mailbox with the same priority level and so on. Once we loop through all the
  396. * transmit mailboxes we choose the next priority level (lower) and so on
  397. * until we reach the lowest priority level on the lowest numbered mailbox
  398. * when we stop transmission until all mailboxes are transmitted and then
  399. * restart at highest numbered mailbox with highest priority.
  400. *
  401. * Two counters (head and tail) are used to track the next mailbox to transmit
  402. * and to track the echo buffer for already transmitted mailbox. The queue
  403. * is stopped when all the mailboxes are busy or when there is a priority
  404. * value roll-over happens.
  405. */
  406. static netdev_tx_t ti_hecc_xmit(struct sk_buff *skb, struct net_device *ndev)
  407. {
  408. struct ti_hecc_priv *priv = netdev_priv(ndev);
  409. struct can_frame *cf = (struct can_frame *)skb->data;
  410. u32 mbxno, mbx_mask, data;
  411. unsigned long flags;
  412. if (can_dropped_invalid_skb(ndev, skb))
  413. return NETDEV_TX_OK;
  414. mbxno = get_tx_head_mb(priv);
  415. mbx_mask = BIT(mbxno);
  416. spin_lock_irqsave(&priv->mbx_lock, flags);
  417. if (unlikely(hecc_read(priv, HECC_CANME) & mbx_mask)) {
  418. spin_unlock_irqrestore(&priv->mbx_lock, flags);
  419. netif_stop_queue(ndev);
  420. netdev_err(priv->ndev,
  421. "BUG: TX mbx not ready tx_head=%08X, tx_tail=%08X\n",
  422. priv->tx_head, priv->tx_tail);
  423. return NETDEV_TX_BUSY;
  424. }
  425. spin_unlock_irqrestore(&priv->mbx_lock, flags);
  426. /* Prepare mailbox for transmission */
  427. data = cf->can_dlc | (get_tx_head_prio(priv) << 8);
  428. if (cf->can_id & CAN_RTR_FLAG) /* Remote transmission request */
  429. data |= HECC_CANMCF_RTR;
  430. hecc_write_mbx(priv, mbxno, HECC_CANMCF, data);
  431. if (cf->can_id & CAN_EFF_FLAG) /* Extended frame format */
  432. data = (cf->can_id & CAN_EFF_MASK) | HECC_CANMID_IDE;
  433. else /* Standard frame format */
  434. data = (cf->can_id & CAN_SFF_MASK) << 18;
  435. hecc_write_mbx(priv, mbxno, HECC_CANMID, data);
  436. hecc_write_mbx(priv, mbxno, HECC_CANMDL,
  437. be32_to_cpu(*(__be32 *)(cf->data)));
  438. if (cf->can_dlc > 4)
  439. hecc_write_mbx(priv, mbxno, HECC_CANMDH,
  440. be32_to_cpu(*(__be32 *)(cf->data + 4)));
  441. else
  442. *(u32 *)(cf->data + 4) = 0;
  443. can_put_echo_skb(skb, ndev, mbxno);
  444. spin_lock_irqsave(&priv->mbx_lock, flags);
  445. --priv->tx_head;
  446. if ((hecc_read(priv, HECC_CANME) & BIT(get_tx_head_mb(priv))) ||
  447. (priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK) {
  448. netif_stop_queue(ndev);
  449. }
  450. hecc_set_bit(priv, HECC_CANME, mbx_mask);
  451. spin_unlock_irqrestore(&priv->mbx_lock, flags);
  452. hecc_write(priv, HECC_CANTRS, mbx_mask);
  453. return NETDEV_TX_OK;
  454. }
  455. static inline
  456. struct ti_hecc_priv *rx_offload_to_priv(struct can_rx_offload *offload)
  457. {
  458. return container_of(offload, struct ti_hecc_priv, offload);
  459. }
  460. static unsigned int ti_hecc_mailbox_read(struct can_rx_offload *offload,
  461. struct can_frame *cf,
  462. u32 *timestamp, unsigned int mbxno)
  463. {
  464. struct ti_hecc_priv *priv = rx_offload_to_priv(offload);
  465. u32 data, mbx_mask;
  466. int ret = 1;
  467. mbx_mask = BIT(mbxno);
  468. data = hecc_read_mbx(priv, mbxno, HECC_CANMID);
  469. if (data & HECC_CANMID_IDE)
  470. cf->can_id = (data & CAN_EFF_MASK) | CAN_EFF_FLAG;
  471. else
  472. cf->can_id = (data >> 18) & CAN_SFF_MASK;
  473. data = hecc_read_mbx(priv, mbxno, HECC_CANMCF);
  474. if (data & HECC_CANMCF_RTR)
  475. cf->can_id |= CAN_RTR_FLAG;
  476. cf->can_dlc = get_can_dlc(data & 0xF);
  477. data = hecc_read_mbx(priv, mbxno, HECC_CANMDL);
  478. *(__be32 *)(cf->data) = cpu_to_be32(data);
  479. if (cf->can_dlc > 4) {
  480. data = hecc_read_mbx(priv, mbxno, HECC_CANMDH);
  481. *(__be32 *)(cf->data + 4) = cpu_to_be32(data);
  482. }
  483. *timestamp = hecc_read_stamp(priv, mbxno);
  484. /* Check for FIFO overrun.
  485. *
  486. * All but the last RX mailbox have activated overwrite
  487. * protection. So skip check for overrun, if we're not
  488. * handling the last RX mailbox.
  489. *
  490. * As the overwrite protection for the last RX mailbox is
  491. * disabled, the CAN core might update while we're reading
  492. * it. This means the skb might be inconsistent.
  493. *
  494. * Return an error to let rx-offload discard this CAN frame.
  495. */
  496. if (unlikely(mbxno == HECC_RX_LAST_MBOX &&
  497. hecc_read(priv, HECC_CANRML) & mbx_mask))
  498. ret = -ENOBUFS;
  499. hecc_write(priv, HECC_CANRMP, mbx_mask);
  500. return ret;
  501. }
  502. static int ti_hecc_error(struct net_device *ndev, int int_status,
  503. int err_status)
  504. {
  505. struct ti_hecc_priv *priv = netdev_priv(ndev);
  506. struct can_frame *cf;
  507. struct sk_buff *skb;
  508. u32 timestamp;
  509. int err;
  510. if (err_status & HECC_BUS_ERROR) {
  511. /* propagate the error condition to the can stack */
  512. skb = alloc_can_err_skb(ndev, &cf);
  513. if (!skb) {
  514. if (net_ratelimit())
  515. netdev_err(priv->ndev,
  516. "%s: alloc_can_err_skb() failed\n",
  517. __func__);
  518. return -ENOMEM;
  519. }
  520. ++priv->can.can_stats.bus_error;
  521. cf->can_id |= CAN_ERR_BUSERROR | CAN_ERR_PROT;
  522. if (err_status & HECC_CANES_FE)
  523. cf->data[2] |= CAN_ERR_PROT_FORM;
  524. if (err_status & HECC_CANES_BE)
  525. cf->data[2] |= CAN_ERR_PROT_BIT;
  526. if (err_status & HECC_CANES_SE)
  527. cf->data[2] |= CAN_ERR_PROT_STUFF;
  528. if (err_status & HECC_CANES_CRCE)
  529. cf->data[3] = CAN_ERR_PROT_LOC_CRC_SEQ;
  530. if (err_status & HECC_CANES_ACKE)
  531. cf->data[3] = CAN_ERR_PROT_LOC_ACK;
  532. timestamp = hecc_read(priv, HECC_CANLNT);
  533. err = can_rx_offload_queue_sorted(&priv->offload, skb,
  534. timestamp);
  535. if (err)
  536. ndev->stats.rx_fifo_errors++;
  537. }
  538. hecc_write(priv, HECC_CANES, HECC_CANES_FLAGS);
  539. return 0;
  540. }
  541. static void ti_hecc_change_state(struct net_device *ndev,
  542. enum can_state rx_state,
  543. enum can_state tx_state)
  544. {
  545. struct ti_hecc_priv *priv = netdev_priv(ndev);
  546. struct can_frame *cf;
  547. struct sk_buff *skb;
  548. u32 timestamp;
  549. int err;
  550. skb = alloc_can_err_skb(priv->ndev, &cf);
  551. if (unlikely(!skb)) {
  552. priv->can.state = max(tx_state, rx_state);
  553. return;
  554. }
  555. can_change_state(priv->ndev, cf, tx_state, rx_state);
  556. if (max(tx_state, rx_state) != CAN_STATE_BUS_OFF) {
  557. cf->data[6] = hecc_read(priv, HECC_CANTEC);
  558. cf->data[7] = hecc_read(priv, HECC_CANREC);
  559. }
  560. timestamp = hecc_read(priv, HECC_CANLNT);
  561. err = can_rx_offload_queue_sorted(&priv->offload, skb, timestamp);
  562. if (err)
  563. ndev->stats.rx_fifo_errors++;
  564. }
  565. static irqreturn_t ti_hecc_interrupt(int irq, void *dev_id)
  566. {
  567. struct net_device *ndev = (struct net_device *)dev_id;
  568. struct ti_hecc_priv *priv = netdev_priv(ndev);
  569. struct net_device_stats *stats = &ndev->stats;
  570. u32 mbxno, mbx_mask, int_status, err_status, stamp;
  571. unsigned long flags, rx_pending;
  572. u32 handled = 0;
  573. int_status = hecc_read(priv,
  574. priv->use_hecc1int ?
  575. HECC_CANGIF1 : HECC_CANGIF0);
  576. if (!int_status)
  577. return IRQ_NONE;
  578. err_status = hecc_read(priv, HECC_CANES);
  579. if (unlikely(err_status & HECC_CANES_FLAGS))
  580. ti_hecc_error(ndev, int_status, err_status);
  581. if (unlikely(int_status & HECC_CANGIM_DEF_MASK)) {
  582. enum can_state rx_state, tx_state;
  583. u32 rec = hecc_read(priv, HECC_CANREC);
  584. u32 tec = hecc_read(priv, HECC_CANTEC);
  585. if (int_status & HECC_CANGIF_WLIF) {
  586. handled |= HECC_CANGIF_WLIF;
  587. rx_state = rec >= tec ? CAN_STATE_ERROR_WARNING : 0;
  588. tx_state = rec <= tec ? CAN_STATE_ERROR_WARNING : 0;
  589. netdev_dbg(priv->ndev, "Error Warning interrupt\n");
  590. ti_hecc_change_state(ndev, rx_state, tx_state);
  591. }
  592. if (int_status & HECC_CANGIF_EPIF) {
  593. handled |= HECC_CANGIF_EPIF;
  594. rx_state = rec >= tec ? CAN_STATE_ERROR_PASSIVE : 0;
  595. tx_state = rec <= tec ? CAN_STATE_ERROR_PASSIVE : 0;
  596. netdev_dbg(priv->ndev, "Error passive interrupt\n");
  597. ti_hecc_change_state(ndev, rx_state, tx_state);
  598. }
  599. if (int_status & HECC_CANGIF_BOIF) {
  600. handled |= HECC_CANGIF_BOIF;
  601. rx_state = CAN_STATE_BUS_OFF;
  602. tx_state = CAN_STATE_BUS_OFF;
  603. netdev_dbg(priv->ndev, "Bus off interrupt\n");
  604. /* Disable all interrupts */
  605. hecc_write(priv, HECC_CANGIM, 0);
  606. can_bus_off(ndev);
  607. ti_hecc_change_state(ndev, rx_state, tx_state);
  608. }
  609. } else if (unlikely(priv->can.state != CAN_STATE_ERROR_ACTIVE)) {
  610. enum can_state new_state, tx_state, rx_state;
  611. u32 rec = hecc_read(priv, HECC_CANREC);
  612. u32 tec = hecc_read(priv, HECC_CANTEC);
  613. if (rec >= 128 || tec >= 128)
  614. new_state = CAN_STATE_ERROR_PASSIVE;
  615. else if (rec >= 96 || tec >= 96)
  616. new_state = CAN_STATE_ERROR_WARNING;
  617. else
  618. new_state = CAN_STATE_ERROR_ACTIVE;
  619. if (new_state < priv->can.state) {
  620. rx_state = rec >= tec ? new_state : 0;
  621. tx_state = rec <= tec ? new_state : 0;
  622. ti_hecc_change_state(ndev, rx_state, tx_state);
  623. }
  624. }
  625. if (int_status & HECC_CANGIF_GMIF) {
  626. while (priv->tx_tail - priv->tx_head > 0) {
  627. mbxno = get_tx_tail_mb(priv);
  628. mbx_mask = BIT(mbxno);
  629. if (!(mbx_mask & hecc_read(priv, HECC_CANTA)))
  630. break;
  631. hecc_write(priv, HECC_CANTA, mbx_mask);
  632. spin_lock_irqsave(&priv->mbx_lock, flags);
  633. hecc_clear_bit(priv, HECC_CANME, mbx_mask);
  634. spin_unlock_irqrestore(&priv->mbx_lock, flags);
  635. stamp = hecc_read_stamp(priv, mbxno);
  636. stats->tx_bytes +=
  637. can_rx_offload_get_echo_skb(&priv->offload,
  638. mbxno, stamp);
  639. stats->tx_packets++;
  640. can_led_event(ndev, CAN_LED_EVENT_TX);
  641. --priv->tx_tail;
  642. }
  643. /* restart queue if wrap-up or if queue stalled on last pkt */
  644. if ((priv->tx_head == priv->tx_tail &&
  645. ((priv->tx_head & HECC_TX_MASK) != HECC_TX_MASK)) ||
  646. (((priv->tx_tail & HECC_TX_MASK) == HECC_TX_MASK) &&
  647. ((priv->tx_head & HECC_TX_MASK) == HECC_TX_MASK)))
  648. netif_wake_queue(ndev);
  649. /* offload RX mailboxes and let NAPI deliver them */
  650. while ((rx_pending = hecc_read(priv, HECC_CANRMP))) {
  651. can_rx_offload_irq_offload_timestamp(&priv->offload,
  652. rx_pending);
  653. }
  654. }
  655. /* clear all interrupt conditions - read back to avoid spurious ints */
  656. if (priv->use_hecc1int) {
  657. hecc_write(priv, HECC_CANGIF1, handled);
  658. int_status = hecc_read(priv, HECC_CANGIF1);
  659. } else {
  660. hecc_write(priv, HECC_CANGIF0, handled);
  661. int_status = hecc_read(priv, HECC_CANGIF0);
  662. }
  663. return IRQ_HANDLED;
  664. }
  665. static int ti_hecc_open(struct net_device *ndev)
  666. {
  667. struct ti_hecc_priv *priv = netdev_priv(ndev);
  668. int err;
  669. err = request_irq(ndev->irq, ti_hecc_interrupt, IRQF_SHARED,
  670. ndev->name, ndev);
  671. if (err) {
  672. netdev_err(ndev, "error requesting interrupt\n");
  673. return err;
  674. }
  675. ti_hecc_transceiver_switch(priv, 1);
  676. /* Open common can device */
  677. err = open_candev(ndev);
  678. if (err) {
  679. netdev_err(ndev, "open_candev() failed %d\n", err);
  680. ti_hecc_transceiver_switch(priv, 0);
  681. free_irq(ndev->irq, ndev);
  682. return err;
  683. }
  684. can_led_event(ndev, CAN_LED_EVENT_OPEN);
  685. ti_hecc_start(ndev);
  686. can_rx_offload_enable(&priv->offload);
  687. netif_start_queue(ndev);
  688. return 0;
  689. }
  690. static int ti_hecc_close(struct net_device *ndev)
  691. {
  692. struct ti_hecc_priv *priv = netdev_priv(ndev);
  693. netif_stop_queue(ndev);
  694. can_rx_offload_disable(&priv->offload);
  695. ti_hecc_stop(ndev);
  696. free_irq(ndev->irq, ndev);
  697. close_candev(ndev);
  698. ti_hecc_transceiver_switch(priv, 0);
  699. can_led_event(ndev, CAN_LED_EVENT_STOP);
  700. return 0;
  701. }
  702. static const struct net_device_ops ti_hecc_netdev_ops = {
  703. .ndo_open = ti_hecc_open,
  704. .ndo_stop = ti_hecc_close,
  705. .ndo_start_xmit = ti_hecc_xmit,
  706. .ndo_change_mtu = can_change_mtu,
  707. };
  708. static const struct of_device_id ti_hecc_dt_ids[] = {
  709. {
  710. .compatible = "ti,am3517-hecc",
  711. },
  712. { }
  713. };
  714. MODULE_DEVICE_TABLE(of, ti_hecc_dt_ids);
  715. static int ti_hecc_probe(struct platform_device *pdev)
  716. {
  717. struct net_device *ndev = (struct net_device *)0;
  718. struct ti_hecc_priv *priv;
  719. struct device_node *np = pdev->dev.of_node;
  720. struct resource *res, *irq;
  721. struct regulator *reg_xceiver;
  722. int err = -ENODEV;
  723. if (!IS_ENABLED(CONFIG_OF) || !np)
  724. return -EINVAL;
  725. reg_xceiver = devm_regulator_get(&pdev->dev, "xceiver");
  726. if (PTR_ERR(reg_xceiver) == -EPROBE_DEFER)
  727. return -EPROBE_DEFER;
  728. else if (IS_ERR(reg_xceiver))
  729. reg_xceiver = NULL;
  730. ndev = alloc_candev(sizeof(struct ti_hecc_priv), HECC_MAX_TX_MBOX);
  731. if (!ndev) {
  732. dev_err(&pdev->dev, "alloc_candev failed\n");
  733. return -ENOMEM;
  734. }
  735. priv = netdev_priv(ndev);
  736. /* handle hecc memory */
  737. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc");
  738. if (!res) {
  739. dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc\n");
  740. return -EINVAL;
  741. }
  742. priv->base = devm_ioremap_resource(&pdev->dev, res);
  743. if (IS_ERR(priv->base)) {
  744. dev_err(&pdev->dev, "hecc ioremap failed\n");
  745. err = PTR_ERR(priv->base);
  746. goto probe_exit_candev;
  747. }
  748. /* handle hecc-ram memory */
  749. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "hecc-ram");
  750. if (!res) {
  751. dev_err(&pdev->dev, "can't get IORESOURCE_MEM hecc-ram\n");
  752. return -EINVAL;
  753. }
  754. priv->hecc_ram = devm_ioremap_resource(&pdev->dev, res);
  755. if (IS_ERR(priv->hecc_ram)) {
  756. dev_err(&pdev->dev, "hecc-ram ioremap failed\n");
  757. err = PTR_ERR(priv->hecc_ram);
  758. goto probe_exit_candev;
  759. }
  760. /* handle mbx memory */
  761. res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mbx");
  762. if (!res) {
  763. dev_err(&pdev->dev, "can't get IORESOURCE_MEM mbx\n");
  764. return -EINVAL;
  765. }
  766. priv->mbx = devm_ioremap_resource(&pdev->dev, res);
  767. if (IS_ERR(priv->mbx)) {
  768. dev_err(&pdev->dev, "mbx ioremap failed\n");
  769. err = PTR_ERR(priv->mbx);
  770. goto probe_exit_candev;
  771. }
  772. irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
  773. if (!irq) {
  774. dev_err(&pdev->dev, "No irq resource\n");
  775. goto probe_exit_candev;
  776. }
  777. priv->ndev = ndev;
  778. priv->reg_xceiver = reg_xceiver;
  779. priv->use_hecc1int = of_property_read_bool(np, "ti,use-hecc1int");
  780. priv->can.bittiming_const = &ti_hecc_bittiming_const;
  781. priv->can.do_set_mode = ti_hecc_do_set_mode;
  782. priv->can.do_get_berr_counter = ti_hecc_get_berr_counter;
  783. priv->can.ctrlmode_supported = CAN_CTRLMODE_3_SAMPLES;
  784. spin_lock_init(&priv->mbx_lock);
  785. ndev->irq = irq->start;
  786. ndev->flags |= IFF_ECHO;
  787. platform_set_drvdata(pdev, ndev);
  788. SET_NETDEV_DEV(ndev, &pdev->dev);
  789. ndev->netdev_ops = &ti_hecc_netdev_ops;
  790. priv->clk = clk_get(&pdev->dev, "hecc_ck");
  791. if (IS_ERR(priv->clk)) {
  792. dev_err(&pdev->dev, "No clock available\n");
  793. err = PTR_ERR(priv->clk);
  794. priv->clk = NULL;
  795. goto probe_exit_candev;
  796. }
  797. priv->can.clock.freq = clk_get_rate(priv->clk);
  798. err = clk_prepare_enable(priv->clk);
  799. if (err) {
  800. dev_err(&pdev->dev, "clk_prepare_enable() failed\n");
  801. goto probe_exit_release_clk;
  802. }
  803. priv->offload.mailbox_read = ti_hecc_mailbox_read;
  804. priv->offload.mb_first = HECC_RX_FIRST_MBOX;
  805. priv->offload.mb_last = HECC_RX_LAST_MBOX;
  806. err = can_rx_offload_add_timestamp(ndev, &priv->offload);
  807. if (err) {
  808. dev_err(&pdev->dev, "can_rx_offload_add_timestamp() failed\n");
  809. goto probe_exit_disable_clk;
  810. }
  811. err = register_candev(ndev);
  812. if (err) {
  813. dev_err(&pdev->dev, "register_candev() failed\n");
  814. goto probe_exit_offload;
  815. }
  816. devm_can_led_init(ndev);
  817. dev_info(&pdev->dev, "device registered (reg_base=%p, irq=%u)\n",
  818. priv->base, (u32)ndev->irq);
  819. return 0;
  820. probe_exit_offload:
  821. can_rx_offload_del(&priv->offload);
  822. probe_exit_disable_clk:
  823. clk_disable_unprepare(priv->clk);
  824. probe_exit_release_clk:
  825. clk_put(priv->clk);
  826. probe_exit_candev:
  827. free_candev(ndev);
  828. return err;
  829. }
  830. static int ti_hecc_remove(struct platform_device *pdev)
  831. {
  832. struct net_device *ndev = platform_get_drvdata(pdev);
  833. struct ti_hecc_priv *priv = netdev_priv(ndev);
  834. unregister_candev(ndev);
  835. clk_disable_unprepare(priv->clk);
  836. clk_put(priv->clk);
  837. can_rx_offload_del(&priv->offload);
  838. free_candev(ndev);
  839. return 0;
  840. }
  841. #ifdef CONFIG_PM
  842. static int ti_hecc_suspend(struct platform_device *pdev, pm_message_t state)
  843. {
  844. struct net_device *dev = platform_get_drvdata(pdev);
  845. struct ti_hecc_priv *priv = netdev_priv(dev);
  846. if (netif_running(dev)) {
  847. netif_stop_queue(dev);
  848. netif_device_detach(dev);
  849. }
  850. hecc_set_bit(priv, HECC_CANMC, HECC_CANMC_PDR);
  851. priv->can.state = CAN_STATE_SLEEPING;
  852. clk_disable_unprepare(priv->clk);
  853. return 0;
  854. }
  855. static int ti_hecc_resume(struct platform_device *pdev)
  856. {
  857. struct net_device *dev = platform_get_drvdata(pdev);
  858. struct ti_hecc_priv *priv = netdev_priv(dev);
  859. int err;
  860. err = clk_prepare_enable(priv->clk);
  861. if (err)
  862. return err;
  863. hecc_clear_bit(priv, HECC_CANMC, HECC_CANMC_PDR);
  864. priv->can.state = CAN_STATE_ERROR_ACTIVE;
  865. if (netif_running(dev)) {
  866. netif_device_attach(dev);
  867. netif_start_queue(dev);
  868. }
  869. return 0;
  870. }
  871. #else
  872. #define ti_hecc_suspend NULL
  873. #define ti_hecc_resume NULL
  874. #endif
  875. /* TI HECC netdevice driver: platform driver structure */
  876. static struct platform_driver ti_hecc_driver = {
  877. .driver = {
  878. .name = DRV_NAME,
  879. .of_match_table = ti_hecc_dt_ids,
  880. },
  881. .probe = ti_hecc_probe,
  882. .remove = ti_hecc_remove,
  883. .suspend = ti_hecc_suspend,
  884. .resume = ti_hecc_resume,
  885. };
  886. module_platform_driver(ti_hecc_driver);
  887. MODULE_AUTHOR("Anant Gole <anantgole@ti.com>");
  888. MODULE_LICENSE("GPL v2");
  889. MODULE_DESCRIPTION(DRV_DESC);
  890. MODULE_ALIAS("platform:" DRV_NAME);