hw-txe.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. /*
  2. *
  3. * Intel Management Engine Interface (Intel MEI) Linux driver
  4. * Copyright (c) 2013-2014, Intel Corporation.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms and conditions of the GNU General Public License,
  8. * version 2, as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  13. * more details.
  14. *
  15. */
  16. #include <linux/pci.h>
  17. #include <linux/jiffies.h>
  18. #include <linux/ktime.h>
  19. #include <linux/delay.h>
  20. #include <linux/kthread.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/pm_runtime.h>
  23. #include <linux/mei.h>
  24. #include "mei_dev.h"
  25. #include "hw-txe.h"
  26. #include "client.h"
  27. #include "hbm.h"
  28. #include "mei-trace.h"
  29. /**
  30. * mei_txe_reg_read - Reads 32bit data from the txe device
  31. *
  32. * @base_addr: registers base address
  33. * @offset: register offset
  34. *
  35. * Return: register value
  36. */
  37. static inline u32 mei_txe_reg_read(void __iomem *base_addr,
  38. unsigned long offset)
  39. {
  40. return ioread32(base_addr + offset);
  41. }
  42. /**
  43. * mei_txe_reg_write - Writes 32bit data to the txe device
  44. *
  45. * @base_addr: registers base address
  46. * @offset: register offset
  47. * @value: the value to write
  48. */
  49. static inline void mei_txe_reg_write(void __iomem *base_addr,
  50. unsigned long offset, u32 value)
  51. {
  52. iowrite32(value, base_addr + offset);
  53. }
  54. /**
  55. * mei_txe_sec_reg_read_silent - Reads 32bit data from the SeC BAR
  56. *
  57. * @hw: the txe hardware structure
  58. * @offset: register offset
  59. *
  60. * Doesn't check for aliveness while Reads 32bit data from the SeC BAR
  61. *
  62. * Return: register value
  63. */
  64. static inline u32 mei_txe_sec_reg_read_silent(struct mei_txe_hw *hw,
  65. unsigned long offset)
  66. {
  67. return mei_txe_reg_read(hw->mem_addr[SEC_BAR], offset);
  68. }
  69. /**
  70. * mei_txe_sec_reg_read - Reads 32bit data from the SeC BAR
  71. *
  72. * @hw: the txe hardware structure
  73. * @offset: register offset
  74. *
  75. * Reads 32bit data from the SeC BAR and shout loud if aliveness is not set
  76. *
  77. * Return: register value
  78. */
  79. static inline u32 mei_txe_sec_reg_read(struct mei_txe_hw *hw,
  80. unsigned long offset)
  81. {
  82. WARN(!hw->aliveness, "sec read: aliveness not asserted\n");
  83. return mei_txe_sec_reg_read_silent(hw, offset);
  84. }
  85. /**
  86. * mei_txe_sec_reg_write_silent - Writes 32bit data to the SeC BAR
  87. * doesn't check for aliveness
  88. *
  89. * @hw: the txe hardware structure
  90. * @offset: register offset
  91. * @value: value to write
  92. *
  93. * Doesn't check for aliveness while writes 32bit data from to the SeC BAR
  94. */
  95. static inline void mei_txe_sec_reg_write_silent(struct mei_txe_hw *hw,
  96. unsigned long offset, u32 value)
  97. {
  98. mei_txe_reg_write(hw->mem_addr[SEC_BAR], offset, value);
  99. }
  100. /**
  101. * mei_txe_sec_reg_write - Writes 32bit data to the SeC BAR
  102. *
  103. * @hw: the txe hardware structure
  104. * @offset: register offset
  105. * @value: value to write
  106. *
  107. * Writes 32bit data from the SeC BAR and shout loud if aliveness is not set
  108. */
  109. static inline void mei_txe_sec_reg_write(struct mei_txe_hw *hw,
  110. unsigned long offset, u32 value)
  111. {
  112. WARN(!hw->aliveness, "sec write: aliveness not asserted\n");
  113. mei_txe_sec_reg_write_silent(hw, offset, value);
  114. }
  115. /**
  116. * mei_txe_br_reg_read - Reads 32bit data from the Bridge BAR
  117. *
  118. * @hw: the txe hardware structure
  119. * @offset: offset from which to read the data
  120. *
  121. * Return: the byte read.
  122. */
  123. static inline u32 mei_txe_br_reg_read(struct mei_txe_hw *hw,
  124. unsigned long offset)
  125. {
  126. return mei_txe_reg_read(hw->mem_addr[BRIDGE_BAR], offset);
  127. }
  128. /**
  129. * mei_txe_br_reg_write - Writes 32bit data to the Bridge BAR
  130. *
  131. * @hw: the txe hardware structure
  132. * @offset: offset from which to write the data
  133. * @value: the byte to write
  134. */
  135. static inline void mei_txe_br_reg_write(struct mei_txe_hw *hw,
  136. unsigned long offset, u32 value)
  137. {
  138. mei_txe_reg_write(hw->mem_addr[BRIDGE_BAR], offset, value);
  139. }
  140. /**
  141. * mei_txe_aliveness_set - request for aliveness change
  142. *
  143. * @dev: the device structure
  144. * @req: requested aliveness value
  145. *
  146. * Request for aliveness change and returns true if the change is
  147. * really needed and false if aliveness is already
  148. * in the requested state
  149. *
  150. * Locking: called under "dev->device_lock" lock
  151. *
  152. * Return: true if request was send
  153. */
  154. static bool mei_txe_aliveness_set(struct mei_device *dev, u32 req)
  155. {
  156. struct mei_txe_hw *hw = to_txe_hw(dev);
  157. bool do_req = hw->aliveness != req;
  158. dev_dbg(dev->dev, "Aliveness current=%d request=%d\n",
  159. hw->aliveness, req);
  160. if (do_req) {
  161. dev->pg_event = MEI_PG_EVENT_WAIT;
  162. mei_txe_br_reg_write(hw, SICR_HOST_ALIVENESS_REQ_REG, req);
  163. }
  164. return do_req;
  165. }
  166. /**
  167. * mei_txe_aliveness_req_get - get aliveness requested register value
  168. *
  169. * @dev: the device structure
  170. *
  171. * Extract HICR_HOST_ALIVENESS_RESP_ACK bit from
  172. * from HICR_HOST_ALIVENESS_REQ register value
  173. *
  174. * Return: SICR_HOST_ALIVENESS_REQ_REQUESTED bit value
  175. */
  176. static u32 mei_txe_aliveness_req_get(struct mei_device *dev)
  177. {
  178. struct mei_txe_hw *hw = to_txe_hw(dev);
  179. u32 reg;
  180. reg = mei_txe_br_reg_read(hw, SICR_HOST_ALIVENESS_REQ_REG);
  181. return reg & SICR_HOST_ALIVENESS_REQ_REQUESTED;
  182. }
  183. /**
  184. * mei_txe_aliveness_get - get aliveness response register value
  185. *
  186. * @dev: the device structure
  187. *
  188. * Return: HICR_HOST_ALIVENESS_RESP_ACK bit from HICR_HOST_ALIVENESS_RESP
  189. * register
  190. */
  191. static u32 mei_txe_aliveness_get(struct mei_device *dev)
  192. {
  193. struct mei_txe_hw *hw = to_txe_hw(dev);
  194. u32 reg;
  195. reg = mei_txe_br_reg_read(hw, HICR_HOST_ALIVENESS_RESP_REG);
  196. return reg & HICR_HOST_ALIVENESS_RESP_ACK;
  197. }
  198. /**
  199. * mei_txe_aliveness_poll - waits for aliveness to settle
  200. *
  201. * @dev: the device structure
  202. * @expected: expected aliveness value
  203. *
  204. * Polls for HICR_HOST_ALIVENESS_RESP.ALIVENESS_RESP to be set
  205. *
  206. * Return: 0 if the expected value was received, -ETIME otherwise
  207. */
  208. static int mei_txe_aliveness_poll(struct mei_device *dev, u32 expected)
  209. {
  210. struct mei_txe_hw *hw = to_txe_hw(dev);
  211. ktime_t stop, start;
  212. start = ktime_get();
  213. stop = ktime_add(start, ms_to_ktime(SEC_ALIVENESS_WAIT_TIMEOUT));
  214. do {
  215. hw->aliveness = mei_txe_aliveness_get(dev);
  216. if (hw->aliveness == expected) {
  217. dev->pg_event = MEI_PG_EVENT_IDLE;
  218. dev_dbg(dev->dev, "aliveness settled after %lld usecs\n",
  219. ktime_to_us(ktime_sub(ktime_get(), start)));
  220. return 0;
  221. }
  222. usleep_range(20, 50);
  223. } while (ktime_before(ktime_get(), stop));
  224. dev->pg_event = MEI_PG_EVENT_IDLE;
  225. dev_err(dev->dev, "aliveness timed out\n");
  226. return -ETIME;
  227. }
  228. /**
  229. * mei_txe_aliveness_wait - waits for aliveness to settle
  230. *
  231. * @dev: the device structure
  232. * @expected: expected aliveness value
  233. *
  234. * Waits for HICR_HOST_ALIVENESS_RESP.ALIVENESS_RESP to be set
  235. *
  236. * Return: 0 on success and < 0 otherwise
  237. */
  238. static int mei_txe_aliveness_wait(struct mei_device *dev, u32 expected)
  239. {
  240. struct mei_txe_hw *hw = to_txe_hw(dev);
  241. const unsigned long timeout =
  242. msecs_to_jiffies(SEC_ALIVENESS_WAIT_TIMEOUT);
  243. long err;
  244. int ret;
  245. hw->aliveness = mei_txe_aliveness_get(dev);
  246. if (hw->aliveness == expected)
  247. return 0;
  248. mutex_unlock(&dev->device_lock);
  249. err = wait_event_timeout(hw->wait_aliveness_resp,
  250. dev->pg_event == MEI_PG_EVENT_RECEIVED, timeout);
  251. mutex_lock(&dev->device_lock);
  252. hw->aliveness = mei_txe_aliveness_get(dev);
  253. ret = hw->aliveness == expected ? 0 : -ETIME;
  254. if (ret)
  255. dev_warn(dev->dev, "aliveness timed out = %ld aliveness = %d event = %d\n",
  256. err, hw->aliveness, dev->pg_event);
  257. else
  258. dev_dbg(dev->dev, "aliveness settled after = %d msec aliveness = %d event = %d\n",
  259. jiffies_to_msecs(timeout - err),
  260. hw->aliveness, dev->pg_event);
  261. dev->pg_event = MEI_PG_EVENT_IDLE;
  262. return ret;
  263. }
  264. /**
  265. * mei_txe_aliveness_set_sync - sets an wait for aliveness to complete
  266. *
  267. * @dev: the device structure
  268. * @req: requested aliveness value
  269. *
  270. * Return: 0 on success and < 0 otherwise
  271. */
  272. int mei_txe_aliveness_set_sync(struct mei_device *dev, u32 req)
  273. {
  274. if (mei_txe_aliveness_set(dev, req))
  275. return mei_txe_aliveness_wait(dev, req);
  276. return 0;
  277. }
  278. /**
  279. * mei_txe_pg_in_transition - is device now in pg transition
  280. *
  281. * @dev: the device structure
  282. *
  283. * Return: true if in pg transition, false otherwise
  284. */
  285. static bool mei_txe_pg_in_transition(struct mei_device *dev)
  286. {
  287. return dev->pg_event == MEI_PG_EVENT_WAIT;
  288. }
  289. /**
  290. * mei_txe_pg_is_enabled - detect if PG is supported by HW
  291. *
  292. * @dev: the device structure
  293. *
  294. * Return: true is pg supported, false otherwise
  295. */
  296. static bool mei_txe_pg_is_enabled(struct mei_device *dev)
  297. {
  298. return true;
  299. }
  300. /**
  301. * mei_txe_pg_state - translate aliveness register value
  302. * to the mei power gating state
  303. *
  304. * @dev: the device structure
  305. *
  306. * Return: MEI_PG_OFF if aliveness is on and MEI_PG_ON otherwise
  307. */
  308. static inline enum mei_pg_state mei_txe_pg_state(struct mei_device *dev)
  309. {
  310. struct mei_txe_hw *hw = to_txe_hw(dev);
  311. return hw->aliveness ? MEI_PG_OFF : MEI_PG_ON;
  312. }
  313. /**
  314. * mei_txe_input_ready_interrupt_enable - sets the Input Ready Interrupt
  315. *
  316. * @dev: the device structure
  317. */
  318. static void mei_txe_input_ready_interrupt_enable(struct mei_device *dev)
  319. {
  320. struct mei_txe_hw *hw = to_txe_hw(dev);
  321. u32 hintmsk;
  322. /* Enable the SEC_IPC_HOST_INT_MASK_IN_RDY interrupt */
  323. hintmsk = mei_txe_sec_reg_read(hw, SEC_IPC_HOST_INT_MASK_REG);
  324. hintmsk |= SEC_IPC_HOST_INT_MASK_IN_RDY;
  325. mei_txe_sec_reg_write(hw, SEC_IPC_HOST_INT_MASK_REG, hintmsk);
  326. }
  327. /**
  328. * mei_txe_input_doorbell_set - sets bit 0 in
  329. * SEC_IPC_INPUT_DOORBELL.IPC_INPUT_DOORBELL.
  330. *
  331. * @hw: the txe hardware structure
  332. */
  333. static void mei_txe_input_doorbell_set(struct mei_txe_hw *hw)
  334. {
  335. /* Clear the interrupt cause */
  336. clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause);
  337. mei_txe_sec_reg_write(hw, SEC_IPC_INPUT_DOORBELL_REG, 1);
  338. }
  339. /**
  340. * mei_txe_output_ready_set - Sets the SICR_SEC_IPC_OUTPUT_STATUS bit to 1
  341. *
  342. * @hw: the txe hardware structure
  343. */
  344. static void mei_txe_output_ready_set(struct mei_txe_hw *hw)
  345. {
  346. mei_txe_br_reg_write(hw,
  347. SICR_SEC_IPC_OUTPUT_STATUS_REG,
  348. SEC_IPC_OUTPUT_STATUS_RDY);
  349. }
  350. /**
  351. * mei_txe_is_input_ready - check if TXE is ready for receiving data
  352. *
  353. * @dev: the device structure
  354. *
  355. * Return: true if INPUT STATUS READY bit is set
  356. */
  357. static bool mei_txe_is_input_ready(struct mei_device *dev)
  358. {
  359. struct mei_txe_hw *hw = to_txe_hw(dev);
  360. u32 status;
  361. status = mei_txe_sec_reg_read(hw, SEC_IPC_INPUT_STATUS_REG);
  362. return !!(SEC_IPC_INPUT_STATUS_RDY & status);
  363. }
  364. /**
  365. * mei_txe_intr_clear - clear all interrupts
  366. *
  367. * @dev: the device structure
  368. */
  369. static inline void mei_txe_intr_clear(struct mei_device *dev)
  370. {
  371. struct mei_txe_hw *hw = to_txe_hw(dev);
  372. mei_txe_sec_reg_write_silent(hw, SEC_IPC_HOST_INT_STATUS_REG,
  373. SEC_IPC_HOST_INT_STATUS_PENDING);
  374. mei_txe_br_reg_write(hw, HISR_REG, HISR_INT_STS_MSK);
  375. mei_txe_br_reg_write(hw, HHISR_REG, IPC_HHIER_MSK);
  376. }
  377. /**
  378. * mei_txe_intr_disable - disable all interrupts
  379. *
  380. * @dev: the device structure
  381. */
  382. static void mei_txe_intr_disable(struct mei_device *dev)
  383. {
  384. struct mei_txe_hw *hw = to_txe_hw(dev);
  385. mei_txe_br_reg_write(hw, HHIER_REG, 0);
  386. mei_txe_br_reg_write(hw, HIER_REG, 0);
  387. }
  388. /**
  389. * mei_txe_intr_enable - enable all interrupts
  390. *
  391. * @dev: the device structure
  392. */
  393. static void mei_txe_intr_enable(struct mei_device *dev)
  394. {
  395. struct mei_txe_hw *hw = to_txe_hw(dev);
  396. mei_txe_br_reg_write(hw, HHIER_REG, IPC_HHIER_MSK);
  397. mei_txe_br_reg_write(hw, HIER_REG, HIER_INT_EN_MSK);
  398. }
  399. /**
  400. * mei_txe_synchronize_irq - wait for pending IRQ handlers
  401. *
  402. * @dev: the device structure
  403. */
  404. static void mei_txe_synchronize_irq(struct mei_device *dev)
  405. {
  406. struct pci_dev *pdev = to_pci_dev(dev->dev);
  407. synchronize_irq(pdev->irq);
  408. }
  409. /**
  410. * mei_txe_pending_interrupts - check if there are pending interrupts
  411. * only Aliveness, Input ready, and output doorbell are of relevance
  412. *
  413. * @dev: the device structure
  414. *
  415. * Checks if there are pending interrupts
  416. * only Aliveness, Readiness, Input ready, and Output doorbell are relevant
  417. *
  418. * Return: true if there are pending interrupts
  419. */
  420. static bool mei_txe_pending_interrupts(struct mei_device *dev)
  421. {
  422. struct mei_txe_hw *hw = to_txe_hw(dev);
  423. bool ret = (hw->intr_cause & (TXE_INTR_READINESS |
  424. TXE_INTR_ALIVENESS |
  425. TXE_INTR_IN_READY |
  426. TXE_INTR_OUT_DB));
  427. if (ret) {
  428. dev_dbg(dev->dev,
  429. "Pending Interrupts InReady=%01d Readiness=%01d, Aliveness=%01d, OutDoor=%01d\n",
  430. !!(hw->intr_cause & TXE_INTR_IN_READY),
  431. !!(hw->intr_cause & TXE_INTR_READINESS),
  432. !!(hw->intr_cause & TXE_INTR_ALIVENESS),
  433. !!(hw->intr_cause & TXE_INTR_OUT_DB));
  434. }
  435. return ret;
  436. }
  437. /**
  438. * mei_txe_input_payload_write - write a dword to the host buffer
  439. * at offset idx
  440. *
  441. * @dev: the device structure
  442. * @idx: index in the host buffer
  443. * @value: value
  444. */
  445. static void mei_txe_input_payload_write(struct mei_device *dev,
  446. unsigned long idx, u32 value)
  447. {
  448. struct mei_txe_hw *hw = to_txe_hw(dev);
  449. mei_txe_sec_reg_write(hw, SEC_IPC_INPUT_PAYLOAD_REG +
  450. (idx * sizeof(u32)), value);
  451. }
  452. /**
  453. * mei_txe_out_data_read - read dword from the device buffer
  454. * at offset idx
  455. *
  456. * @dev: the device structure
  457. * @idx: index in the device buffer
  458. *
  459. * Return: register value at index
  460. */
  461. static u32 mei_txe_out_data_read(const struct mei_device *dev,
  462. unsigned long idx)
  463. {
  464. struct mei_txe_hw *hw = to_txe_hw(dev);
  465. return mei_txe_br_reg_read(hw,
  466. BRIDGE_IPC_OUTPUT_PAYLOAD_REG + (idx * sizeof(u32)));
  467. }
  468. /* Readiness */
  469. /**
  470. * mei_txe_readiness_set_host_rdy - set host readiness bit
  471. *
  472. * @dev: the device structure
  473. */
  474. static void mei_txe_readiness_set_host_rdy(struct mei_device *dev)
  475. {
  476. struct mei_txe_hw *hw = to_txe_hw(dev);
  477. mei_txe_br_reg_write(hw,
  478. SICR_HOST_IPC_READINESS_REQ_REG,
  479. SICR_HOST_IPC_READINESS_HOST_RDY);
  480. }
  481. /**
  482. * mei_txe_readiness_clear - clear host readiness bit
  483. *
  484. * @dev: the device structure
  485. */
  486. static void mei_txe_readiness_clear(struct mei_device *dev)
  487. {
  488. struct mei_txe_hw *hw = to_txe_hw(dev);
  489. mei_txe_br_reg_write(hw, SICR_HOST_IPC_READINESS_REQ_REG,
  490. SICR_HOST_IPC_READINESS_RDY_CLR);
  491. }
  492. /**
  493. * mei_txe_readiness_get - Reads and returns
  494. * the HICR_SEC_IPC_READINESS register value
  495. *
  496. * @dev: the device structure
  497. *
  498. * Return: the HICR_SEC_IPC_READINESS register value
  499. */
  500. static u32 mei_txe_readiness_get(struct mei_device *dev)
  501. {
  502. struct mei_txe_hw *hw = to_txe_hw(dev);
  503. return mei_txe_br_reg_read(hw, HICR_SEC_IPC_READINESS_REG);
  504. }
  505. /**
  506. * mei_txe_readiness_is_sec_rdy - check readiness
  507. * for HICR_SEC_IPC_READINESS_SEC_RDY
  508. *
  509. * @readiness: cached readiness state
  510. *
  511. * Return: true if readiness bit is set
  512. */
  513. static inline bool mei_txe_readiness_is_sec_rdy(u32 readiness)
  514. {
  515. return !!(readiness & HICR_SEC_IPC_READINESS_SEC_RDY);
  516. }
  517. /**
  518. * mei_txe_hw_is_ready - check if the hw is ready
  519. *
  520. * @dev: the device structure
  521. *
  522. * Return: true if sec is ready
  523. */
  524. static bool mei_txe_hw_is_ready(struct mei_device *dev)
  525. {
  526. u32 readiness = mei_txe_readiness_get(dev);
  527. return mei_txe_readiness_is_sec_rdy(readiness);
  528. }
  529. /**
  530. * mei_txe_host_is_ready - check if the host is ready
  531. *
  532. * @dev: the device structure
  533. *
  534. * Return: true if host is ready
  535. */
  536. static inline bool mei_txe_host_is_ready(struct mei_device *dev)
  537. {
  538. struct mei_txe_hw *hw = to_txe_hw(dev);
  539. u32 reg = mei_txe_br_reg_read(hw, HICR_SEC_IPC_READINESS_REG);
  540. return !!(reg & HICR_SEC_IPC_READINESS_HOST_RDY);
  541. }
  542. /**
  543. * mei_txe_readiness_wait - wait till readiness settles
  544. *
  545. * @dev: the device structure
  546. *
  547. * Return: 0 on success and -ETIME on timeout
  548. */
  549. static int mei_txe_readiness_wait(struct mei_device *dev)
  550. {
  551. if (mei_txe_hw_is_ready(dev))
  552. return 0;
  553. mutex_unlock(&dev->device_lock);
  554. wait_event_timeout(dev->wait_hw_ready, dev->recvd_hw_ready,
  555. msecs_to_jiffies(SEC_RESET_WAIT_TIMEOUT));
  556. mutex_lock(&dev->device_lock);
  557. if (!dev->recvd_hw_ready) {
  558. dev_err(dev->dev, "wait for readiness failed\n");
  559. return -ETIME;
  560. }
  561. dev->recvd_hw_ready = false;
  562. return 0;
  563. }
  564. static const struct mei_fw_status mei_txe_fw_sts = {
  565. .count = 2,
  566. .status[0] = PCI_CFG_TXE_FW_STS0,
  567. .status[1] = PCI_CFG_TXE_FW_STS1
  568. };
  569. /**
  570. * mei_txe_fw_status - read fw status register from pci config space
  571. *
  572. * @dev: mei device
  573. * @fw_status: fw status register values
  574. *
  575. * Return: 0 on success, error otherwise
  576. */
  577. static int mei_txe_fw_status(struct mei_device *dev,
  578. struct mei_fw_status *fw_status)
  579. {
  580. const struct mei_fw_status *fw_src = &mei_txe_fw_sts;
  581. struct pci_dev *pdev = to_pci_dev(dev->dev);
  582. int ret;
  583. int i;
  584. if (!fw_status)
  585. return -EINVAL;
  586. fw_status->count = fw_src->count;
  587. for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
  588. ret = pci_read_config_dword(pdev, fw_src->status[i],
  589. &fw_status->status[i]);
  590. trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HSF_X",
  591. fw_src->status[i],
  592. fw_status->status[i]);
  593. if (ret)
  594. return ret;
  595. }
  596. return 0;
  597. }
  598. /**
  599. * mei_txe_hw_config - configure hardware at the start of the devices
  600. *
  601. * @dev: the device structure
  602. *
  603. * Configure hardware at the start of the device should be done only
  604. * once at the device probe time
  605. */
  606. static void mei_txe_hw_config(struct mei_device *dev)
  607. {
  608. struct mei_txe_hw *hw = to_txe_hw(dev);
  609. /* Doesn't change in runtime */
  610. dev->hbuf_depth = PAYLOAD_SIZE / 4;
  611. hw->aliveness = mei_txe_aliveness_get(dev);
  612. hw->readiness = mei_txe_readiness_get(dev);
  613. dev_dbg(dev->dev, "aliveness_resp = 0x%08x, readiness = 0x%08x.\n",
  614. hw->aliveness, hw->readiness);
  615. }
  616. /**
  617. * mei_txe_write - writes a message to device.
  618. *
  619. * @dev: the device structure
  620. * @header: header of message
  621. * @buf: message buffer will be written
  622. *
  623. * Return: 0 if success, <0 - otherwise.
  624. */
  625. static int mei_txe_write(struct mei_device *dev,
  626. struct mei_msg_hdr *header,
  627. const unsigned char *buf)
  628. {
  629. struct mei_txe_hw *hw = to_txe_hw(dev);
  630. unsigned long rem;
  631. unsigned long length;
  632. int slots = dev->hbuf_depth;
  633. u32 *reg_buf = (u32 *)buf;
  634. u32 dw_cnt;
  635. int i;
  636. if (WARN_ON(!header || !buf))
  637. return -EINVAL;
  638. length = header->length;
  639. dev_dbg(dev->dev, MEI_HDR_FMT, MEI_HDR_PRM(header));
  640. dw_cnt = mei_data2slots(length);
  641. if (dw_cnt > slots)
  642. return -EMSGSIZE;
  643. if (WARN(!hw->aliveness, "txe write: aliveness not asserted\n"))
  644. return -EAGAIN;
  645. /* Enable Input Ready Interrupt. */
  646. mei_txe_input_ready_interrupt_enable(dev);
  647. if (!mei_txe_is_input_ready(dev)) {
  648. char fw_sts_str[MEI_FW_STATUS_STR_SZ];
  649. mei_fw_status_str(dev, fw_sts_str, MEI_FW_STATUS_STR_SZ);
  650. dev_err(dev->dev, "Input is not ready %s\n", fw_sts_str);
  651. return -EAGAIN;
  652. }
  653. mei_txe_input_payload_write(dev, 0, *((u32 *)header));
  654. for (i = 0; i < length / 4; i++)
  655. mei_txe_input_payload_write(dev, i + 1, reg_buf[i]);
  656. rem = length & 0x3;
  657. if (rem > 0) {
  658. u32 reg = 0;
  659. memcpy(&reg, &buf[length - rem], rem);
  660. mei_txe_input_payload_write(dev, i + 1, reg);
  661. }
  662. /* after each write the whole buffer is consumed */
  663. hw->slots = 0;
  664. /* Set Input-Doorbell */
  665. mei_txe_input_doorbell_set(hw);
  666. return 0;
  667. }
  668. /**
  669. * mei_txe_hbuf_max_len - mimics the me hbuf circular buffer
  670. *
  671. * @dev: the device structure
  672. *
  673. * Return: the PAYLOAD_SIZE - 4
  674. */
  675. static size_t mei_txe_hbuf_max_len(const struct mei_device *dev)
  676. {
  677. return PAYLOAD_SIZE - sizeof(struct mei_msg_hdr);
  678. }
  679. /**
  680. * mei_txe_hbuf_empty_slots - mimics the me hbuf circular buffer
  681. *
  682. * @dev: the device structure
  683. *
  684. * Return: always hbuf_depth
  685. */
  686. static int mei_txe_hbuf_empty_slots(struct mei_device *dev)
  687. {
  688. struct mei_txe_hw *hw = to_txe_hw(dev);
  689. return hw->slots;
  690. }
  691. /**
  692. * mei_txe_count_full_read_slots - mimics the me device circular buffer
  693. *
  694. * @dev: the device structure
  695. *
  696. * Return: always buffer size in dwords count
  697. */
  698. static int mei_txe_count_full_read_slots(struct mei_device *dev)
  699. {
  700. /* read buffers has static size */
  701. return PAYLOAD_SIZE / 4;
  702. }
  703. /**
  704. * mei_txe_read_hdr - read message header which is always in 4 first bytes
  705. *
  706. * @dev: the device structure
  707. *
  708. * Return: mei message header
  709. */
  710. static u32 mei_txe_read_hdr(const struct mei_device *dev)
  711. {
  712. return mei_txe_out_data_read(dev, 0);
  713. }
  714. /**
  715. * mei_txe_read - reads a message from the txe device.
  716. *
  717. * @dev: the device structure
  718. * @buf: message buffer will be written
  719. * @len: message size will be read
  720. *
  721. * Return: -EINVAL on error wrong argument and 0 on success
  722. */
  723. static int mei_txe_read(struct mei_device *dev,
  724. unsigned char *buf, unsigned long len)
  725. {
  726. struct mei_txe_hw *hw = to_txe_hw(dev);
  727. u32 *reg_buf, reg;
  728. u32 rem;
  729. u32 i;
  730. if (WARN_ON(!buf || !len))
  731. return -EINVAL;
  732. reg_buf = (u32 *)buf;
  733. rem = len & 0x3;
  734. dev_dbg(dev->dev, "buffer-length = %lu buf[0]0x%08X\n",
  735. len, mei_txe_out_data_read(dev, 0));
  736. for (i = 0; i < len / 4; i++) {
  737. /* skip header: index starts from 1 */
  738. reg = mei_txe_out_data_read(dev, i + 1);
  739. dev_dbg(dev->dev, "buf[%d] = 0x%08X\n", i, reg);
  740. *reg_buf++ = reg;
  741. }
  742. if (rem) {
  743. reg = mei_txe_out_data_read(dev, i + 1);
  744. memcpy(reg_buf, &reg, rem);
  745. }
  746. mei_txe_output_ready_set(hw);
  747. return 0;
  748. }
  749. /**
  750. * mei_txe_hw_reset - resets host and fw.
  751. *
  752. * @dev: the device structure
  753. * @intr_enable: if interrupt should be enabled after reset.
  754. *
  755. * Return: 0 on success and < 0 in case of error
  756. */
  757. static int mei_txe_hw_reset(struct mei_device *dev, bool intr_enable)
  758. {
  759. struct mei_txe_hw *hw = to_txe_hw(dev);
  760. u32 aliveness_req;
  761. /*
  762. * read input doorbell to ensure consistency between Bridge and SeC
  763. * return value might be garbage return
  764. */
  765. (void)mei_txe_sec_reg_read_silent(hw, SEC_IPC_INPUT_DOORBELL_REG);
  766. aliveness_req = mei_txe_aliveness_req_get(dev);
  767. hw->aliveness = mei_txe_aliveness_get(dev);
  768. /* Disable interrupts in this stage we will poll */
  769. mei_txe_intr_disable(dev);
  770. /*
  771. * If Aliveness Request and Aliveness Response are not equal then
  772. * wait for them to be equal
  773. * Since we might have interrupts disabled - poll for it
  774. */
  775. if (aliveness_req != hw->aliveness)
  776. if (mei_txe_aliveness_poll(dev, aliveness_req) < 0) {
  777. dev_err(dev->dev, "wait for aliveness settle failed ... bailing out\n");
  778. return -EIO;
  779. }
  780. /*
  781. * If Aliveness Request and Aliveness Response are set then clear them
  782. */
  783. if (aliveness_req) {
  784. mei_txe_aliveness_set(dev, 0);
  785. if (mei_txe_aliveness_poll(dev, 0) < 0) {
  786. dev_err(dev->dev, "wait for aliveness failed ... bailing out\n");
  787. return -EIO;
  788. }
  789. }
  790. /*
  791. * Set readiness RDY_CLR bit
  792. */
  793. mei_txe_readiness_clear(dev);
  794. return 0;
  795. }
  796. /**
  797. * mei_txe_hw_start - start the hardware after reset
  798. *
  799. * @dev: the device structure
  800. *
  801. * Return: 0 on success an error code otherwise
  802. */
  803. static int mei_txe_hw_start(struct mei_device *dev)
  804. {
  805. struct mei_txe_hw *hw = to_txe_hw(dev);
  806. int ret;
  807. u32 hisr;
  808. /* bring back interrupts */
  809. mei_txe_intr_enable(dev);
  810. ret = mei_txe_readiness_wait(dev);
  811. if (ret < 0) {
  812. dev_err(dev->dev, "waiting for readiness failed\n");
  813. return ret;
  814. }
  815. /*
  816. * If HISR.INT2_STS interrupt status bit is set then clear it.
  817. */
  818. hisr = mei_txe_br_reg_read(hw, HISR_REG);
  819. if (hisr & HISR_INT_2_STS)
  820. mei_txe_br_reg_write(hw, HISR_REG, HISR_INT_2_STS);
  821. /* Clear the interrupt cause of OutputDoorbell */
  822. clear_bit(TXE_INTR_OUT_DB_BIT, &hw->intr_cause);
  823. ret = mei_txe_aliveness_set_sync(dev, 1);
  824. if (ret < 0) {
  825. dev_err(dev->dev, "wait for aliveness failed ... bailing out\n");
  826. return ret;
  827. }
  828. pm_runtime_set_active(dev->dev);
  829. /* enable input ready interrupts:
  830. * SEC_IPC_HOST_INT_MASK.IPC_INPUT_READY_INT_MASK
  831. */
  832. mei_txe_input_ready_interrupt_enable(dev);
  833. /* Set the SICR_SEC_IPC_OUTPUT_STATUS.IPC_OUTPUT_READY bit */
  834. mei_txe_output_ready_set(hw);
  835. /* Set bit SICR_HOST_IPC_READINESS.HOST_RDY
  836. */
  837. mei_txe_readiness_set_host_rdy(dev);
  838. return 0;
  839. }
  840. /**
  841. * mei_txe_check_and_ack_intrs - translate multi BAR interrupt into
  842. * single bit mask and acknowledge the interrupts
  843. *
  844. * @dev: the device structure
  845. * @do_ack: acknowledge interrupts
  846. *
  847. * Return: true if found interrupts to process.
  848. */
  849. static bool mei_txe_check_and_ack_intrs(struct mei_device *dev, bool do_ack)
  850. {
  851. struct mei_txe_hw *hw = to_txe_hw(dev);
  852. u32 hisr;
  853. u32 hhisr;
  854. u32 ipc_isr;
  855. u32 aliveness;
  856. bool generated;
  857. /* read interrupt registers */
  858. hhisr = mei_txe_br_reg_read(hw, HHISR_REG);
  859. generated = (hhisr & IPC_HHIER_MSK);
  860. if (!generated)
  861. goto out;
  862. hisr = mei_txe_br_reg_read(hw, HISR_REG);
  863. aliveness = mei_txe_aliveness_get(dev);
  864. if (hhisr & IPC_HHIER_SEC && aliveness) {
  865. ipc_isr = mei_txe_sec_reg_read_silent(hw,
  866. SEC_IPC_HOST_INT_STATUS_REG);
  867. } else {
  868. ipc_isr = 0;
  869. hhisr &= ~IPC_HHIER_SEC;
  870. }
  871. generated = generated ||
  872. (hisr & HISR_INT_STS_MSK) ||
  873. (ipc_isr & SEC_IPC_HOST_INT_STATUS_PENDING);
  874. if (generated && do_ack) {
  875. /* Save the interrupt causes */
  876. hw->intr_cause |= hisr & HISR_INT_STS_MSK;
  877. if (ipc_isr & SEC_IPC_HOST_INT_STATUS_IN_RDY)
  878. hw->intr_cause |= TXE_INTR_IN_READY;
  879. mei_txe_intr_disable(dev);
  880. /* Clear the interrupts in hierarchy:
  881. * IPC and Bridge, than the High Level */
  882. mei_txe_sec_reg_write_silent(hw,
  883. SEC_IPC_HOST_INT_STATUS_REG, ipc_isr);
  884. mei_txe_br_reg_write(hw, HISR_REG, hisr);
  885. mei_txe_br_reg_write(hw, HHISR_REG, hhisr);
  886. }
  887. out:
  888. return generated;
  889. }
  890. /**
  891. * mei_txe_irq_quick_handler - The ISR of the MEI device
  892. *
  893. * @irq: The irq number
  894. * @dev_id: pointer to the device structure
  895. *
  896. * Return: IRQ_WAKE_THREAD if interrupt is designed for the device
  897. * IRQ_NONE otherwise
  898. */
  899. irqreturn_t mei_txe_irq_quick_handler(int irq, void *dev_id)
  900. {
  901. struct mei_device *dev = dev_id;
  902. if (mei_txe_check_and_ack_intrs(dev, true))
  903. return IRQ_WAKE_THREAD;
  904. return IRQ_NONE;
  905. }
  906. /**
  907. * mei_txe_irq_thread_handler - txe interrupt thread
  908. *
  909. * @irq: The irq number
  910. * @dev_id: pointer to the device structure
  911. *
  912. * Return: IRQ_HANDLED
  913. */
  914. irqreturn_t mei_txe_irq_thread_handler(int irq, void *dev_id)
  915. {
  916. struct mei_device *dev = (struct mei_device *) dev_id;
  917. struct mei_txe_hw *hw = to_txe_hw(dev);
  918. struct list_head cmpl_list;
  919. s32 slots;
  920. int rets = 0;
  921. dev_dbg(dev->dev, "irq thread: Interrupt Registers HHISR|HISR|SEC=%02X|%04X|%02X\n",
  922. mei_txe_br_reg_read(hw, HHISR_REG),
  923. mei_txe_br_reg_read(hw, HISR_REG),
  924. mei_txe_sec_reg_read_silent(hw, SEC_IPC_HOST_INT_STATUS_REG));
  925. /* initialize our complete list */
  926. mutex_lock(&dev->device_lock);
  927. INIT_LIST_HEAD(&cmpl_list);
  928. if (pci_dev_msi_enabled(to_pci_dev(dev->dev)))
  929. mei_txe_check_and_ack_intrs(dev, true);
  930. /* show irq events */
  931. mei_txe_pending_interrupts(dev);
  932. hw->aliveness = mei_txe_aliveness_get(dev);
  933. hw->readiness = mei_txe_readiness_get(dev);
  934. /* Readiness:
  935. * Detection of TXE driver going through reset
  936. * or TXE driver resetting the HECI interface.
  937. */
  938. if (test_and_clear_bit(TXE_INTR_READINESS_BIT, &hw->intr_cause)) {
  939. dev_dbg(dev->dev, "Readiness Interrupt was received...\n");
  940. /* Check if SeC is going through reset */
  941. if (mei_txe_readiness_is_sec_rdy(hw->readiness)) {
  942. dev_dbg(dev->dev, "we need to start the dev.\n");
  943. dev->recvd_hw_ready = true;
  944. } else {
  945. dev->recvd_hw_ready = false;
  946. if (dev->dev_state != MEI_DEV_RESETTING) {
  947. dev_warn(dev->dev, "FW not ready: resetting.\n");
  948. schedule_work(&dev->reset_work);
  949. goto end;
  950. }
  951. }
  952. wake_up(&dev->wait_hw_ready);
  953. }
  954. /************************************************************/
  955. /* Check interrupt cause:
  956. * Aliveness: Detection of SeC acknowledge of host request that
  957. * it remain alive or host cancellation of that request.
  958. */
  959. if (test_and_clear_bit(TXE_INTR_ALIVENESS_BIT, &hw->intr_cause)) {
  960. /* Clear the interrupt cause */
  961. dev_dbg(dev->dev,
  962. "Aliveness Interrupt: Status: %d\n", hw->aliveness);
  963. dev->pg_event = MEI_PG_EVENT_RECEIVED;
  964. if (waitqueue_active(&hw->wait_aliveness_resp))
  965. wake_up(&hw->wait_aliveness_resp);
  966. }
  967. /* Output Doorbell:
  968. * Detection of SeC having sent output to host
  969. */
  970. slots = mei_count_full_read_slots(dev);
  971. if (test_and_clear_bit(TXE_INTR_OUT_DB_BIT, &hw->intr_cause)) {
  972. /* Read from TXE */
  973. rets = mei_irq_read_handler(dev, &cmpl_list, &slots);
  974. if (rets &&
  975. (dev->dev_state != MEI_DEV_RESETTING &&
  976. dev->dev_state != MEI_DEV_POWER_DOWN)) {
  977. dev_err(dev->dev,
  978. "mei_irq_read_handler ret = %d.\n", rets);
  979. schedule_work(&dev->reset_work);
  980. goto end;
  981. }
  982. }
  983. /* Input Ready: Detection if host can write to SeC */
  984. if (test_and_clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause)) {
  985. dev->hbuf_is_ready = true;
  986. hw->slots = dev->hbuf_depth;
  987. }
  988. if (hw->aliveness && dev->hbuf_is_ready) {
  989. /* get the real register value */
  990. dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
  991. rets = mei_irq_write_handler(dev, &cmpl_list);
  992. if (rets && rets != -EMSGSIZE)
  993. dev_err(dev->dev, "mei_irq_write_handler ret = %d.\n",
  994. rets);
  995. dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
  996. }
  997. mei_irq_compl_handler(dev, &cmpl_list);
  998. end:
  999. dev_dbg(dev->dev, "interrupt thread end ret = %d\n", rets);
  1000. mutex_unlock(&dev->device_lock);
  1001. mei_enable_interrupts(dev);
  1002. return IRQ_HANDLED;
  1003. }
  1004. static const struct mei_hw_ops mei_txe_hw_ops = {
  1005. .host_is_ready = mei_txe_host_is_ready,
  1006. .fw_status = mei_txe_fw_status,
  1007. .pg_state = mei_txe_pg_state,
  1008. .hw_is_ready = mei_txe_hw_is_ready,
  1009. .hw_reset = mei_txe_hw_reset,
  1010. .hw_config = mei_txe_hw_config,
  1011. .hw_start = mei_txe_hw_start,
  1012. .pg_in_transition = mei_txe_pg_in_transition,
  1013. .pg_is_enabled = mei_txe_pg_is_enabled,
  1014. .intr_clear = mei_txe_intr_clear,
  1015. .intr_enable = mei_txe_intr_enable,
  1016. .intr_disable = mei_txe_intr_disable,
  1017. .synchronize_irq = mei_txe_synchronize_irq,
  1018. .hbuf_free_slots = mei_txe_hbuf_empty_slots,
  1019. .hbuf_is_ready = mei_txe_is_input_ready,
  1020. .hbuf_max_len = mei_txe_hbuf_max_len,
  1021. .write = mei_txe_write,
  1022. .rdbuf_full_slots = mei_txe_count_full_read_slots,
  1023. .read_hdr = mei_txe_read_hdr,
  1024. .read = mei_txe_read,
  1025. };
  1026. /**
  1027. * mei_txe_dev_init - allocates and initializes txe hardware specific structure
  1028. *
  1029. * @pdev: pci device
  1030. *
  1031. * Return: struct mei_device * on success or NULL
  1032. */
  1033. struct mei_device *mei_txe_dev_init(struct pci_dev *pdev)
  1034. {
  1035. struct mei_device *dev;
  1036. struct mei_txe_hw *hw;
  1037. dev = devm_kzalloc(&pdev->dev, sizeof(struct mei_device) +
  1038. sizeof(struct mei_txe_hw), GFP_KERNEL);
  1039. if (!dev)
  1040. return NULL;
  1041. mei_device_init(dev, &pdev->dev, &mei_txe_hw_ops);
  1042. hw = to_txe_hw(dev);
  1043. init_waitqueue_head(&hw->wait_aliveness_resp);
  1044. return dev;
  1045. }
  1046. /**
  1047. * mei_txe_setup_satt2 - SATT2 configuration for DMA support.
  1048. *
  1049. * @dev: the device structure
  1050. * @addr: physical address start of the range
  1051. * @range: physical range size
  1052. *
  1053. * Return: 0 on success an error code otherwise
  1054. */
  1055. int mei_txe_setup_satt2(struct mei_device *dev, phys_addr_t addr, u32 range)
  1056. {
  1057. struct mei_txe_hw *hw = to_txe_hw(dev);
  1058. u32 lo32 = lower_32_bits(addr);
  1059. u32 hi32 = upper_32_bits(addr);
  1060. u32 ctrl;
  1061. /* SATT is limited to 36 Bits */
  1062. if (hi32 & ~0xF)
  1063. return -EINVAL;
  1064. /* SATT has to be 16Byte aligned */
  1065. if (lo32 & 0xF)
  1066. return -EINVAL;
  1067. /* SATT range has to be 4Bytes aligned */
  1068. if (range & 0x4)
  1069. return -EINVAL;
  1070. /* SATT is limited to 32 MB range*/
  1071. if (range > SATT_RANGE_MAX)
  1072. return -EINVAL;
  1073. ctrl = SATT2_CTRL_VALID_MSK;
  1074. ctrl |= hi32 << SATT2_CTRL_BR_BASE_ADDR_REG_SHIFT;
  1075. mei_txe_br_reg_write(hw, SATT2_SAP_SIZE_REG, range);
  1076. mei_txe_br_reg_write(hw, SATT2_BRG_BA_LSB_REG, lo32);
  1077. mei_txe_br_reg_write(hw, SATT2_CTRL_REG, ctrl);
  1078. dev_dbg(dev->dev, "SATT2: SAP_SIZE_OFFSET=0x%08X, BRG_BA_LSB_OFFSET=0x%08X, CTRL_OFFSET=0x%08X\n",
  1079. range, lo32, ctrl);
  1080. return 0;
  1081. }