hci_intel.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328
  1. /*
  2. *
  3. * Bluetooth HCI UART driver for Intel devices
  4. *
  5. * Copyright (C) 2015 Intel Corporation
  6. *
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/errno.h>
  25. #include <linux/skbuff.h>
  26. #include <linux/firmware.h>
  27. #include <linux/module.h>
  28. #include <linux/wait.h>
  29. #include <linux/tty.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/gpio/consumer.h>
  32. #include <linux/acpi.h>
  33. #include <linux/interrupt.h>
  34. #include <linux/pm_runtime.h>
  35. #include <net/bluetooth/bluetooth.h>
  36. #include <net/bluetooth/hci_core.h>
  37. #include "hci_uart.h"
  38. #include "btintel.h"
  39. #define STATE_BOOTLOADER 0
  40. #define STATE_DOWNLOADING 1
  41. #define STATE_FIRMWARE_LOADED 2
  42. #define STATE_FIRMWARE_FAILED 3
  43. #define STATE_BOOTING 4
  44. #define STATE_LPM_ENABLED 5
  45. #define STATE_TX_ACTIVE 6
  46. #define STATE_SUSPENDED 7
  47. #define STATE_LPM_TRANSACTION 8
  48. #define HCI_LPM_WAKE_PKT 0xf0
  49. #define HCI_LPM_PKT 0xf1
  50. #define HCI_LPM_MAX_SIZE 10
  51. #define HCI_LPM_HDR_SIZE HCI_EVENT_HDR_SIZE
  52. #define LPM_OP_TX_NOTIFY 0x00
  53. #define LPM_OP_SUSPEND_ACK 0x02
  54. #define LPM_OP_RESUME_ACK 0x03
  55. #define LPM_SUSPEND_DELAY_MS 1000
  56. struct hci_lpm_pkt {
  57. __u8 opcode;
  58. __u8 dlen;
  59. __u8 data[0];
  60. } __packed;
  61. struct intel_device {
  62. struct list_head list;
  63. struct platform_device *pdev;
  64. struct gpio_desc *reset;
  65. struct hci_uart *hu;
  66. struct mutex hu_lock;
  67. int irq;
  68. };
  69. static LIST_HEAD(intel_device_list);
  70. static DEFINE_MUTEX(intel_device_list_lock);
  71. struct intel_data {
  72. struct sk_buff *rx_skb;
  73. struct sk_buff_head txq;
  74. struct work_struct busy_work;
  75. struct hci_uart *hu;
  76. unsigned long flags;
  77. };
  78. static u8 intel_convert_speed(unsigned int speed)
  79. {
  80. switch (speed) {
  81. case 9600:
  82. return 0x00;
  83. case 19200:
  84. return 0x01;
  85. case 38400:
  86. return 0x02;
  87. case 57600:
  88. return 0x03;
  89. case 115200:
  90. return 0x04;
  91. case 230400:
  92. return 0x05;
  93. case 460800:
  94. return 0x06;
  95. case 921600:
  96. return 0x07;
  97. case 1843200:
  98. return 0x08;
  99. case 3250000:
  100. return 0x09;
  101. case 2000000:
  102. return 0x0a;
  103. case 3000000:
  104. return 0x0b;
  105. default:
  106. return 0xff;
  107. }
  108. }
  109. static int intel_wait_booting(struct hci_uart *hu)
  110. {
  111. struct intel_data *intel = hu->priv;
  112. int err;
  113. err = wait_on_bit_timeout(&intel->flags, STATE_BOOTING,
  114. TASK_INTERRUPTIBLE,
  115. msecs_to_jiffies(1000));
  116. if (err == 1) {
  117. bt_dev_err(hu->hdev, "Device boot interrupted");
  118. return -EINTR;
  119. }
  120. if (err) {
  121. bt_dev_err(hu->hdev, "Device boot timeout");
  122. return -ETIMEDOUT;
  123. }
  124. return err;
  125. }
  126. #ifdef CONFIG_PM
  127. static int intel_wait_lpm_transaction(struct hci_uart *hu)
  128. {
  129. struct intel_data *intel = hu->priv;
  130. int err;
  131. err = wait_on_bit_timeout(&intel->flags, STATE_LPM_TRANSACTION,
  132. TASK_INTERRUPTIBLE,
  133. msecs_to_jiffies(1000));
  134. if (err == 1) {
  135. bt_dev_err(hu->hdev, "LPM transaction interrupted");
  136. return -EINTR;
  137. }
  138. if (err) {
  139. bt_dev_err(hu->hdev, "LPM transaction timeout");
  140. return -ETIMEDOUT;
  141. }
  142. return err;
  143. }
  144. static int intel_lpm_suspend(struct hci_uart *hu)
  145. {
  146. static const u8 suspend[] = { 0x01, 0x01, 0x01 };
  147. struct intel_data *intel = hu->priv;
  148. struct sk_buff *skb;
  149. if (!test_bit(STATE_LPM_ENABLED, &intel->flags) ||
  150. test_bit(STATE_SUSPENDED, &intel->flags))
  151. return 0;
  152. if (test_bit(STATE_TX_ACTIVE, &intel->flags))
  153. return -EAGAIN;
  154. bt_dev_dbg(hu->hdev, "Suspending");
  155. skb = bt_skb_alloc(sizeof(suspend), GFP_KERNEL);
  156. if (!skb) {
  157. bt_dev_err(hu->hdev, "Failed to alloc memory for LPM packet");
  158. return -ENOMEM;
  159. }
  160. memcpy(skb_put(skb, sizeof(suspend)), suspend, sizeof(suspend));
  161. bt_cb(skb)->pkt_type = HCI_LPM_PKT;
  162. set_bit(STATE_LPM_TRANSACTION, &intel->flags);
  163. /* LPM flow is a priority, enqueue packet at list head */
  164. skb_queue_head(&intel->txq, skb);
  165. hci_uart_tx_wakeup(hu);
  166. intel_wait_lpm_transaction(hu);
  167. /* Even in case of failure, continue and test the suspended flag */
  168. clear_bit(STATE_LPM_TRANSACTION, &intel->flags);
  169. if (!test_bit(STATE_SUSPENDED, &intel->flags)) {
  170. bt_dev_err(hu->hdev, "Device suspend error");
  171. return -EINVAL;
  172. }
  173. bt_dev_dbg(hu->hdev, "Suspended");
  174. hci_uart_set_flow_control(hu, true);
  175. return 0;
  176. }
  177. static int intel_lpm_resume(struct hci_uart *hu)
  178. {
  179. struct intel_data *intel = hu->priv;
  180. struct sk_buff *skb;
  181. if (!test_bit(STATE_LPM_ENABLED, &intel->flags) ||
  182. !test_bit(STATE_SUSPENDED, &intel->flags))
  183. return 0;
  184. bt_dev_dbg(hu->hdev, "Resuming");
  185. hci_uart_set_flow_control(hu, false);
  186. skb = bt_skb_alloc(0, GFP_KERNEL);
  187. if (!skb) {
  188. bt_dev_err(hu->hdev, "Failed to alloc memory for LPM packet");
  189. return -ENOMEM;
  190. }
  191. bt_cb(skb)->pkt_type = HCI_LPM_WAKE_PKT;
  192. set_bit(STATE_LPM_TRANSACTION, &intel->flags);
  193. /* LPM flow is a priority, enqueue packet at list head */
  194. skb_queue_head(&intel->txq, skb);
  195. hci_uart_tx_wakeup(hu);
  196. intel_wait_lpm_transaction(hu);
  197. /* Even in case of failure, continue and test the suspended flag */
  198. clear_bit(STATE_LPM_TRANSACTION, &intel->flags);
  199. if (test_bit(STATE_SUSPENDED, &intel->flags)) {
  200. bt_dev_err(hu->hdev, "Device resume error");
  201. return -EINVAL;
  202. }
  203. bt_dev_dbg(hu->hdev, "Resumed");
  204. return 0;
  205. }
  206. #endif /* CONFIG_PM */
  207. static int intel_lpm_host_wake(struct hci_uart *hu)
  208. {
  209. static const u8 lpm_resume_ack[] = { LPM_OP_RESUME_ACK, 0x00 };
  210. struct intel_data *intel = hu->priv;
  211. struct sk_buff *skb;
  212. hci_uart_set_flow_control(hu, false);
  213. clear_bit(STATE_SUSPENDED, &intel->flags);
  214. skb = bt_skb_alloc(sizeof(lpm_resume_ack), GFP_KERNEL);
  215. if (!skb) {
  216. bt_dev_err(hu->hdev, "Failed to alloc memory for LPM packet");
  217. return -ENOMEM;
  218. }
  219. memcpy(skb_put(skb, sizeof(lpm_resume_ack)), lpm_resume_ack,
  220. sizeof(lpm_resume_ack));
  221. bt_cb(skb)->pkt_type = HCI_LPM_PKT;
  222. /* LPM flow is a priority, enqueue packet at list head */
  223. skb_queue_head(&intel->txq, skb);
  224. hci_uart_tx_wakeup(hu);
  225. bt_dev_dbg(hu->hdev, "Resumed by controller");
  226. return 0;
  227. }
  228. static irqreturn_t intel_irq(int irq, void *dev_id)
  229. {
  230. struct intel_device *idev = dev_id;
  231. dev_info(&idev->pdev->dev, "hci_intel irq\n");
  232. mutex_lock(&idev->hu_lock);
  233. if (idev->hu)
  234. intel_lpm_host_wake(idev->hu);
  235. mutex_unlock(&idev->hu_lock);
  236. /* Host/Controller are now LPM resumed, trigger a new delayed suspend */
  237. pm_runtime_get(&idev->pdev->dev);
  238. pm_runtime_mark_last_busy(&idev->pdev->dev);
  239. pm_runtime_put_autosuspend(&idev->pdev->dev);
  240. return IRQ_HANDLED;
  241. }
  242. static int intel_set_power(struct hci_uart *hu, bool powered)
  243. {
  244. struct list_head *p;
  245. int err = -ENODEV;
  246. if (!hu->tty->dev)
  247. return err;
  248. mutex_lock(&intel_device_list_lock);
  249. list_for_each(p, &intel_device_list) {
  250. struct intel_device *idev = list_entry(p, struct intel_device,
  251. list);
  252. /* tty device and pdev device should share the same parent
  253. * which is the UART port.
  254. */
  255. if (hu->tty->dev->parent != idev->pdev->dev.parent)
  256. continue;
  257. if (!idev->reset) {
  258. err = -ENOTSUPP;
  259. break;
  260. }
  261. BT_INFO("hu %p, Switching compatible pm device (%s) to %u",
  262. hu, dev_name(&idev->pdev->dev), powered);
  263. gpiod_set_value(idev->reset, powered);
  264. /* Provide to idev a hu reference which is used to run LPM
  265. * transactions (lpm suspend/resume) from PM callbacks.
  266. * hu needs to be protected against concurrent removing during
  267. * these PM ops.
  268. */
  269. mutex_lock(&idev->hu_lock);
  270. idev->hu = powered ? hu : NULL;
  271. mutex_unlock(&idev->hu_lock);
  272. if (idev->irq < 0)
  273. break;
  274. if (powered && device_can_wakeup(&idev->pdev->dev)) {
  275. err = devm_request_threaded_irq(&idev->pdev->dev,
  276. idev->irq, NULL,
  277. intel_irq,
  278. IRQF_ONESHOT,
  279. "bt-host-wake", idev);
  280. if (err) {
  281. BT_ERR("hu %p, unable to allocate irq-%d",
  282. hu, idev->irq);
  283. break;
  284. }
  285. device_wakeup_enable(&idev->pdev->dev);
  286. pm_runtime_set_active(&idev->pdev->dev);
  287. pm_runtime_use_autosuspend(&idev->pdev->dev);
  288. pm_runtime_set_autosuspend_delay(&idev->pdev->dev,
  289. LPM_SUSPEND_DELAY_MS);
  290. pm_runtime_enable(&idev->pdev->dev);
  291. } else if (!powered && device_may_wakeup(&idev->pdev->dev)) {
  292. devm_free_irq(&idev->pdev->dev, idev->irq, idev);
  293. device_wakeup_disable(&idev->pdev->dev);
  294. pm_runtime_disable(&idev->pdev->dev);
  295. }
  296. }
  297. mutex_unlock(&intel_device_list_lock);
  298. return err;
  299. }
  300. static void intel_busy_work(struct work_struct *work)
  301. {
  302. struct list_head *p;
  303. struct intel_data *intel = container_of(work, struct intel_data,
  304. busy_work);
  305. if (!intel->hu->tty->dev)
  306. return;
  307. /* Link is busy, delay the suspend */
  308. mutex_lock(&intel_device_list_lock);
  309. list_for_each(p, &intel_device_list) {
  310. struct intel_device *idev = list_entry(p, struct intel_device,
  311. list);
  312. if (intel->hu->tty->dev->parent == idev->pdev->dev.parent) {
  313. pm_runtime_get(&idev->pdev->dev);
  314. pm_runtime_mark_last_busy(&idev->pdev->dev);
  315. pm_runtime_put_autosuspend(&idev->pdev->dev);
  316. break;
  317. }
  318. }
  319. mutex_unlock(&intel_device_list_lock);
  320. }
  321. static int intel_open(struct hci_uart *hu)
  322. {
  323. struct intel_data *intel;
  324. BT_DBG("hu %p", hu);
  325. intel = kzalloc(sizeof(*intel), GFP_KERNEL);
  326. if (!intel)
  327. return -ENOMEM;
  328. skb_queue_head_init(&intel->txq);
  329. INIT_WORK(&intel->busy_work, intel_busy_work);
  330. intel->hu = hu;
  331. hu->priv = intel;
  332. if (!intel_set_power(hu, true))
  333. set_bit(STATE_BOOTING, &intel->flags);
  334. return 0;
  335. }
  336. static int intel_close(struct hci_uart *hu)
  337. {
  338. struct intel_data *intel = hu->priv;
  339. BT_DBG("hu %p", hu);
  340. cancel_work_sync(&intel->busy_work);
  341. intel_set_power(hu, false);
  342. skb_queue_purge(&intel->txq);
  343. kfree_skb(intel->rx_skb);
  344. kfree(intel);
  345. hu->priv = NULL;
  346. return 0;
  347. }
  348. static int intel_flush(struct hci_uart *hu)
  349. {
  350. struct intel_data *intel = hu->priv;
  351. BT_DBG("hu %p", hu);
  352. skb_queue_purge(&intel->txq);
  353. return 0;
  354. }
  355. static int inject_cmd_complete(struct hci_dev *hdev, __u16 opcode)
  356. {
  357. struct sk_buff *skb;
  358. struct hci_event_hdr *hdr;
  359. struct hci_ev_cmd_complete *evt;
  360. skb = bt_skb_alloc(sizeof(*hdr) + sizeof(*evt) + 1, GFP_ATOMIC);
  361. if (!skb)
  362. return -ENOMEM;
  363. hdr = (struct hci_event_hdr *)skb_put(skb, sizeof(*hdr));
  364. hdr->evt = HCI_EV_CMD_COMPLETE;
  365. hdr->plen = sizeof(*evt) + 1;
  366. evt = (struct hci_ev_cmd_complete *)skb_put(skb, sizeof(*evt));
  367. evt->ncmd = 0x01;
  368. evt->opcode = cpu_to_le16(opcode);
  369. *skb_put(skb, 1) = 0x00;
  370. bt_cb(skb)->pkt_type = HCI_EVENT_PKT;
  371. return hci_recv_frame(hdev, skb);
  372. }
  373. static int intel_set_baudrate(struct hci_uart *hu, unsigned int speed)
  374. {
  375. struct intel_data *intel = hu->priv;
  376. struct hci_dev *hdev = hu->hdev;
  377. u8 speed_cmd[] = { 0x06, 0xfc, 0x01, 0x00 };
  378. struct sk_buff *skb;
  379. int err;
  380. /* This can be the first command sent to the chip, check
  381. * that the controller is ready.
  382. */
  383. err = intel_wait_booting(hu);
  384. clear_bit(STATE_BOOTING, &intel->flags);
  385. /* In case of timeout, try to continue anyway */
  386. if (err && err != ETIMEDOUT)
  387. return err;
  388. bt_dev_info(hdev, "Change controller speed to %d", speed);
  389. speed_cmd[3] = intel_convert_speed(speed);
  390. if (speed_cmd[3] == 0xff) {
  391. bt_dev_err(hdev, "Unsupported speed");
  392. return -EINVAL;
  393. }
  394. /* Device will not accept speed change if Intel version has not been
  395. * previously requested.
  396. */
  397. skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_INIT_TIMEOUT);
  398. if (IS_ERR(skb)) {
  399. bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
  400. PTR_ERR(skb));
  401. return PTR_ERR(skb);
  402. }
  403. kfree_skb(skb);
  404. skb = bt_skb_alloc(sizeof(speed_cmd), GFP_KERNEL);
  405. if (!skb) {
  406. bt_dev_err(hdev, "Failed to alloc memory for baudrate packet");
  407. return -ENOMEM;
  408. }
  409. memcpy(skb_put(skb, sizeof(speed_cmd)), speed_cmd, sizeof(speed_cmd));
  410. bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
  411. hci_uart_set_flow_control(hu, true);
  412. skb_queue_tail(&intel->txq, skb);
  413. hci_uart_tx_wakeup(hu);
  414. /* wait 100ms to change baudrate on controller side */
  415. msleep(100);
  416. hci_uart_set_baudrate(hu, speed);
  417. hci_uart_set_flow_control(hu, false);
  418. return 0;
  419. }
  420. static int intel_setup(struct hci_uart *hu)
  421. {
  422. static const u8 reset_param[] = { 0x00, 0x01, 0x00, 0x01,
  423. 0x00, 0x08, 0x04, 0x00 };
  424. static const u8 lpm_param[] = { 0x03, 0x07, 0x01, 0x0b };
  425. struct intel_data *intel = hu->priv;
  426. struct intel_device *idev = NULL;
  427. struct hci_dev *hdev = hu->hdev;
  428. struct sk_buff *skb;
  429. struct intel_version *ver;
  430. struct intel_boot_params *params;
  431. struct list_head *p;
  432. const struct firmware *fw;
  433. const u8 *fw_ptr;
  434. char fwname[64];
  435. u32 frag_len;
  436. ktime_t calltime, delta, rettime;
  437. unsigned long long duration;
  438. unsigned int init_speed, oper_speed;
  439. int speed_change = 0;
  440. int err;
  441. bt_dev_dbg(hdev, "start intel_setup");
  442. hu->hdev->set_diag = btintel_set_diag;
  443. hu->hdev->set_bdaddr = btintel_set_bdaddr;
  444. calltime = ktime_get();
  445. if (hu->init_speed)
  446. init_speed = hu->init_speed;
  447. else
  448. init_speed = hu->proto->init_speed;
  449. if (hu->oper_speed)
  450. oper_speed = hu->oper_speed;
  451. else
  452. oper_speed = hu->proto->oper_speed;
  453. if (oper_speed && init_speed && oper_speed != init_speed)
  454. speed_change = 1;
  455. /* Check that the controller is ready */
  456. err = intel_wait_booting(hu);
  457. clear_bit(STATE_BOOTING, &intel->flags);
  458. /* In case of timeout, try to continue anyway */
  459. if (err && err != ETIMEDOUT)
  460. return err;
  461. set_bit(STATE_BOOTLOADER, &intel->flags);
  462. /* Read the Intel version information to determine if the device
  463. * is in bootloader mode or if it already has operational firmware
  464. * loaded.
  465. */
  466. skb = __hci_cmd_sync(hdev, 0xfc05, 0, NULL, HCI_INIT_TIMEOUT);
  467. if (IS_ERR(skb)) {
  468. bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
  469. PTR_ERR(skb));
  470. return PTR_ERR(skb);
  471. }
  472. if (skb->len != sizeof(*ver)) {
  473. bt_dev_err(hdev, "Intel version event size mismatch");
  474. kfree_skb(skb);
  475. return -EILSEQ;
  476. }
  477. ver = (struct intel_version *)skb->data;
  478. if (ver->status) {
  479. bt_dev_err(hdev, "Intel version command failure (%02x)",
  480. ver->status);
  481. err = -bt_to_errno(ver->status);
  482. kfree_skb(skb);
  483. return err;
  484. }
  485. /* The hardware platform number has a fixed value of 0x37 and
  486. * for now only accept this single value.
  487. */
  488. if (ver->hw_platform != 0x37) {
  489. bt_dev_err(hdev, "Unsupported Intel hardware platform (%u)",
  490. ver->hw_platform);
  491. kfree_skb(skb);
  492. return -EINVAL;
  493. }
  494. /* At the moment only the hardware variant iBT 3.0 (LnP/SfP) is
  495. * supported by this firmware loading method. This check has been
  496. * put in place to ensure correct forward compatibility options
  497. * when newer hardware variants come along.
  498. */
  499. if (ver->hw_variant != 0x0b) {
  500. bt_dev_err(hdev, "Unsupported Intel hardware variant (%u)",
  501. ver->hw_variant);
  502. kfree_skb(skb);
  503. return -EINVAL;
  504. }
  505. btintel_version_info(hdev, ver);
  506. /* The firmware variant determines if the device is in bootloader
  507. * mode or is running operational firmware. The value 0x06 identifies
  508. * the bootloader and the value 0x23 identifies the operational
  509. * firmware.
  510. *
  511. * When the operational firmware is already present, then only
  512. * the check for valid Bluetooth device address is needed. This
  513. * determines if the device will be added as configured or
  514. * unconfigured controller.
  515. *
  516. * It is not possible to use the Secure Boot Parameters in this
  517. * case since that command is only available in bootloader mode.
  518. */
  519. if (ver->fw_variant == 0x23) {
  520. kfree_skb(skb);
  521. clear_bit(STATE_BOOTLOADER, &intel->flags);
  522. btintel_check_bdaddr(hdev);
  523. return 0;
  524. }
  525. /* If the device is not in bootloader mode, then the only possible
  526. * choice is to return an error and abort the device initialization.
  527. */
  528. if (ver->fw_variant != 0x06) {
  529. bt_dev_err(hdev, "Unsupported Intel firmware variant (%u)",
  530. ver->fw_variant);
  531. kfree_skb(skb);
  532. return -ENODEV;
  533. }
  534. kfree_skb(skb);
  535. /* Read the secure boot parameters to identify the operating
  536. * details of the bootloader.
  537. */
  538. skb = __hci_cmd_sync(hdev, 0xfc0d, 0, NULL, HCI_INIT_TIMEOUT);
  539. if (IS_ERR(skb)) {
  540. bt_dev_err(hdev, "Reading Intel boot parameters failed (%ld)",
  541. PTR_ERR(skb));
  542. return PTR_ERR(skb);
  543. }
  544. if (skb->len != sizeof(*params)) {
  545. bt_dev_err(hdev, "Intel boot parameters size mismatch");
  546. kfree_skb(skb);
  547. return -EILSEQ;
  548. }
  549. params = (struct intel_boot_params *)skb->data;
  550. if (params->status) {
  551. bt_dev_err(hdev, "Intel boot parameters command failure (%02x)",
  552. params->status);
  553. err = -bt_to_errno(params->status);
  554. kfree_skb(skb);
  555. return err;
  556. }
  557. bt_dev_info(hdev, "Device revision is %u",
  558. le16_to_cpu(params->dev_revid));
  559. bt_dev_info(hdev, "Secure boot is %s",
  560. params->secure_boot ? "enabled" : "disabled");
  561. bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
  562. params->min_fw_build_nn, params->min_fw_build_cw,
  563. 2000 + params->min_fw_build_yy);
  564. /* It is required that every single firmware fragment is acknowledged
  565. * with a command complete event. If the boot parameters indicate
  566. * that this bootloader does not send them, then abort the setup.
  567. */
  568. if (params->limited_cce != 0x00) {
  569. bt_dev_err(hdev, "Unsupported Intel firmware loading method (%u)",
  570. params->limited_cce);
  571. kfree_skb(skb);
  572. return -EINVAL;
  573. }
  574. /* If the OTP has no valid Bluetooth device address, then there will
  575. * also be no valid address for the operational firmware.
  576. */
  577. if (!bacmp(&params->otp_bdaddr, BDADDR_ANY)) {
  578. bt_dev_info(hdev, "No device address configured");
  579. set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
  580. }
  581. /* With this Intel bootloader only the hardware variant and device
  582. * revision information are used to select the right firmware.
  583. *
  584. * Currently this bootloader support is limited to hardware variant
  585. * iBT 3.0 (LnP/SfP) which is identified by the value 11 (0x0b).
  586. */
  587. snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.sfi",
  588. le16_to_cpu(params->dev_revid));
  589. err = request_firmware(&fw, fwname, &hdev->dev);
  590. if (err < 0) {
  591. bt_dev_err(hdev, "Failed to load Intel firmware file (%d)",
  592. err);
  593. kfree_skb(skb);
  594. return err;
  595. }
  596. bt_dev_info(hdev, "Found device firmware: %s", fwname);
  597. /* Save the DDC file name for later */
  598. snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.ddc",
  599. le16_to_cpu(params->dev_revid));
  600. kfree_skb(skb);
  601. if (fw->size < 644) {
  602. bt_dev_err(hdev, "Invalid size of firmware file (%zu)",
  603. fw->size);
  604. err = -EBADF;
  605. goto done;
  606. }
  607. set_bit(STATE_DOWNLOADING, &intel->flags);
  608. /* Start the firmware download transaction with the Init fragment
  609. * represented by the 128 bytes of CSS header.
  610. */
  611. err = btintel_secure_send(hdev, 0x00, 128, fw->data);
  612. if (err < 0) {
  613. bt_dev_err(hdev, "Failed to send firmware header (%d)", err);
  614. goto done;
  615. }
  616. /* Send the 256 bytes of public key information from the firmware
  617. * as the PKey fragment.
  618. */
  619. err = btintel_secure_send(hdev, 0x03, 256, fw->data + 128);
  620. if (err < 0) {
  621. bt_dev_err(hdev, "Failed to send firmware public key (%d)",
  622. err);
  623. goto done;
  624. }
  625. /* Send the 256 bytes of signature information from the firmware
  626. * as the Sign fragment.
  627. */
  628. err = btintel_secure_send(hdev, 0x02, 256, fw->data + 388);
  629. if (err < 0) {
  630. bt_dev_err(hdev, "Failed to send firmware signature (%d)",
  631. err);
  632. goto done;
  633. }
  634. fw_ptr = fw->data + 644;
  635. frag_len = 0;
  636. while (fw_ptr - fw->data < fw->size) {
  637. struct hci_command_hdr *cmd = (void *)(fw_ptr + frag_len);
  638. frag_len += sizeof(*cmd) + cmd->plen;
  639. bt_dev_dbg(hdev, "Patching %td/%zu", (fw_ptr - fw->data),
  640. fw->size);
  641. /* The parameter length of the secure send command requires
  642. * a 4 byte alignment. It happens so that the firmware file
  643. * contains proper Intel_NOP commands to align the fragments
  644. * as needed.
  645. *
  646. * Send set of commands with 4 byte alignment from the
  647. * firmware data buffer as a single Data fragement.
  648. */
  649. if (frag_len % 4)
  650. continue;
  651. /* Send each command from the firmware data buffer as
  652. * a single Data fragment.
  653. */
  654. err = btintel_secure_send(hdev, 0x01, frag_len, fw_ptr);
  655. if (err < 0) {
  656. bt_dev_err(hdev, "Failed to send firmware data (%d)",
  657. err);
  658. goto done;
  659. }
  660. fw_ptr += frag_len;
  661. frag_len = 0;
  662. }
  663. set_bit(STATE_FIRMWARE_LOADED, &intel->flags);
  664. bt_dev_info(hdev, "Waiting for firmware download to complete");
  665. /* Before switching the device into operational mode and with that
  666. * booting the loaded firmware, wait for the bootloader notification
  667. * that all fragments have been successfully received.
  668. *
  669. * When the event processing receives the notification, then the
  670. * STATE_DOWNLOADING flag will be cleared.
  671. *
  672. * The firmware loading should not take longer than 5 seconds
  673. * and thus just timeout if that happens and fail the setup
  674. * of this device.
  675. */
  676. err = wait_on_bit_timeout(&intel->flags, STATE_DOWNLOADING,
  677. TASK_INTERRUPTIBLE,
  678. msecs_to_jiffies(5000));
  679. if (err == 1) {
  680. bt_dev_err(hdev, "Firmware loading interrupted");
  681. err = -EINTR;
  682. goto done;
  683. }
  684. if (err) {
  685. bt_dev_err(hdev, "Firmware loading timeout");
  686. err = -ETIMEDOUT;
  687. goto done;
  688. }
  689. if (test_bit(STATE_FIRMWARE_FAILED, &intel->flags)) {
  690. bt_dev_err(hdev, "Firmware loading failed");
  691. err = -ENOEXEC;
  692. goto done;
  693. }
  694. rettime = ktime_get();
  695. delta = ktime_sub(rettime, calltime);
  696. duration = (unsigned long long) ktime_to_ns(delta) >> 10;
  697. bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration);
  698. done:
  699. release_firmware(fw);
  700. if (err < 0)
  701. return err;
  702. /* We need to restore the default speed before Intel reset */
  703. if (speed_change) {
  704. err = intel_set_baudrate(hu, init_speed);
  705. if (err)
  706. return err;
  707. }
  708. calltime = ktime_get();
  709. set_bit(STATE_BOOTING, &intel->flags);
  710. skb = __hci_cmd_sync(hdev, 0xfc01, sizeof(reset_param), reset_param,
  711. HCI_INIT_TIMEOUT);
  712. if (IS_ERR(skb))
  713. return PTR_ERR(skb);
  714. kfree_skb(skb);
  715. /* The bootloader will not indicate when the device is ready. This
  716. * is done by the operational firmware sending bootup notification.
  717. *
  718. * Booting into operational firmware should not take longer than
  719. * 1 second. However if that happens, then just fail the setup
  720. * since something went wrong.
  721. */
  722. bt_dev_info(hdev, "Waiting for device to boot");
  723. err = intel_wait_booting(hu);
  724. if (err)
  725. return err;
  726. clear_bit(STATE_BOOTING, &intel->flags);
  727. rettime = ktime_get();
  728. delta = ktime_sub(rettime, calltime);
  729. duration = (unsigned long long) ktime_to_ns(delta) >> 10;
  730. bt_dev_info(hdev, "Device booted in %llu usecs", duration);
  731. /* Enable LPM if matching pdev with wakeup enabled */
  732. mutex_lock(&intel_device_list_lock);
  733. list_for_each(p, &intel_device_list) {
  734. struct intel_device *dev = list_entry(p, struct intel_device,
  735. list);
  736. if (!hu->tty->dev)
  737. break;
  738. if (hu->tty->dev->parent == dev->pdev->dev.parent) {
  739. if (device_may_wakeup(&dev->pdev->dev))
  740. idev = dev;
  741. break;
  742. }
  743. }
  744. mutex_unlock(&intel_device_list_lock);
  745. if (!idev)
  746. goto no_lpm;
  747. bt_dev_info(hdev, "Enabling LPM");
  748. skb = __hci_cmd_sync(hdev, 0xfc8b, sizeof(lpm_param), lpm_param,
  749. HCI_CMD_TIMEOUT);
  750. if (IS_ERR(skb)) {
  751. bt_dev_err(hdev, "Failed to enable LPM");
  752. goto no_lpm;
  753. }
  754. kfree_skb(skb);
  755. set_bit(STATE_LPM_ENABLED, &intel->flags);
  756. no_lpm:
  757. /* Ignore errors, device can work without DDC parameters */
  758. btintel_load_ddc_config(hdev, fwname);
  759. skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_CMD_TIMEOUT);
  760. if (IS_ERR(skb))
  761. return PTR_ERR(skb);
  762. kfree_skb(skb);
  763. if (speed_change) {
  764. err = intel_set_baudrate(hu, oper_speed);
  765. if (err)
  766. return err;
  767. }
  768. bt_dev_info(hdev, "Setup complete");
  769. clear_bit(STATE_BOOTLOADER, &intel->flags);
  770. return 0;
  771. }
  772. static int intel_recv_event(struct hci_dev *hdev, struct sk_buff *skb)
  773. {
  774. struct hci_uart *hu = hci_get_drvdata(hdev);
  775. struct intel_data *intel = hu->priv;
  776. struct hci_event_hdr *hdr;
  777. if (!test_bit(STATE_BOOTLOADER, &intel->flags) &&
  778. !test_bit(STATE_BOOTING, &intel->flags))
  779. goto recv;
  780. hdr = (void *)skb->data;
  781. /* When the firmware loading completes the device sends
  782. * out a vendor specific event indicating the result of
  783. * the firmware loading.
  784. */
  785. if (skb->len == 7 && hdr->evt == 0xff && hdr->plen == 0x05 &&
  786. skb->data[2] == 0x06) {
  787. if (skb->data[3] != 0x00)
  788. set_bit(STATE_FIRMWARE_FAILED, &intel->flags);
  789. if (test_and_clear_bit(STATE_DOWNLOADING, &intel->flags) &&
  790. test_bit(STATE_FIRMWARE_LOADED, &intel->flags)) {
  791. smp_mb__after_atomic();
  792. wake_up_bit(&intel->flags, STATE_DOWNLOADING);
  793. }
  794. /* When switching to the operational firmware the device
  795. * sends a vendor specific event indicating that the bootup
  796. * completed.
  797. */
  798. } else if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
  799. skb->data[2] == 0x02) {
  800. if (test_and_clear_bit(STATE_BOOTING, &intel->flags)) {
  801. smp_mb__after_atomic();
  802. wake_up_bit(&intel->flags, STATE_BOOTING);
  803. }
  804. }
  805. recv:
  806. return hci_recv_frame(hdev, skb);
  807. }
  808. static void intel_recv_lpm_notify(struct hci_dev *hdev, int value)
  809. {
  810. struct hci_uart *hu = hci_get_drvdata(hdev);
  811. struct intel_data *intel = hu->priv;
  812. bt_dev_dbg(hdev, "TX idle notification (%d)", value);
  813. if (value) {
  814. set_bit(STATE_TX_ACTIVE, &intel->flags);
  815. schedule_work(&intel->busy_work);
  816. } else {
  817. clear_bit(STATE_TX_ACTIVE, &intel->flags);
  818. }
  819. }
  820. static int intel_recv_lpm(struct hci_dev *hdev, struct sk_buff *skb)
  821. {
  822. struct hci_lpm_pkt *lpm = (void *)skb->data;
  823. struct hci_uart *hu = hci_get_drvdata(hdev);
  824. struct intel_data *intel = hu->priv;
  825. switch (lpm->opcode) {
  826. case LPM_OP_TX_NOTIFY:
  827. if (lpm->dlen < 1) {
  828. bt_dev_err(hu->hdev, "Invalid LPM notification packet");
  829. break;
  830. }
  831. intel_recv_lpm_notify(hdev, lpm->data[0]);
  832. break;
  833. case LPM_OP_SUSPEND_ACK:
  834. set_bit(STATE_SUSPENDED, &intel->flags);
  835. if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
  836. smp_mb__after_atomic();
  837. wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
  838. }
  839. break;
  840. case LPM_OP_RESUME_ACK:
  841. clear_bit(STATE_SUSPENDED, &intel->flags);
  842. if (test_and_clear_bit(STATE_LPM_TRANSACTION, &intel->flags)) {
  843. smp_mb__after_atomic();
  844. wake_up_bit(&intel->flags, STATE_LPM_TRANSACTION);
  845. }
  846. break;
  847. default:
  848. bt_dev_err(hdev, "Unknown LPM opcode (%02x)", lpm->opcode);
  849. break;
  850. }
  851. kfree_skb(skb);
  852. return 0;
  853. }
  854. #define INTEL_RECV_LPM \
  855. .type = HCI_LPM_PKT, \
  856. .hlen = HCI_LPM_HDR_SIZE, \
  857. .loff = 1, \
  858. .lsize = 1, \
  859. .maxlen = HCI_LPM_MAX_SIZE
  860. static const struct h4_recv_pkt intel_recv_pkts[] = {
  861. { H4_RECV_ACL, .recv = hci_recv_frame },
  862. { H4_RECV_SCO, .recv = hci_recv_frame },
  863. { H4_RECV_EVENT, .recv = intel_recv_event },
  864. { INTEL_RECV_LPM, .recv = intel_recv_lpm },
  865. };
  866. static int intel_recv(struct hci_uart *hu, const void *data, int count)
  867. {
  868. struct intel_data *intel = hu->priv;
  869. if (!test_bit(HCI_UART_REGISTERED, &hu->flags))
  870. return -EUNATCH;
  871. intel->rx_skb = h4_recv_buf(hu->hdev, intel->rx_skb, data, count,
  872. intel_recv_pkts,
  873. ARRAY_SIZE(intel_recv_pkts));
  874. if (IS_ERR(intel->rx_skb)) {
  875. int err = PTR_ERR(intel->rx_skb);
  876. bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err);
  877. intel->rx_skb = NULL;
  878. return err;
  879. }
  880. return count;
  881. }
  882. static int intel_enqueue(struct hci_uart *hu, struct sk_buff *skb)
  883. {
  884. struct intel_data *intel = hu->priv;
  885. struct list_head *p;
  886. BT_DBG("hu %p skb %p", hu, skb);
  887. if (!hu->tty->dev)
  888. goto out_enqueue;
  889. /* Be sure our controller is resumed and potential LPM transaction
  890. * completed before enqueuing any packet.
  891. */
  892. mutex_lock(&intel_device_list_lock);
  893. list_for_each(p, &intel_device_list) {
  894. struct intel_device *idev = list_entry(p, struct intel_device,
  895. list);
  896. if (hu->tty->dev->parent == idev->pdev->dev.parent) {
  897. pm_runtime_get_sync(&idev->pdev->dev);
  898. pm_runtime_mark_last_busy(&idev->pdev->dev);
  899. pm_runtime_put_autosuspend(&idev->pdev->dev);
  900. break;
  901. }
  902. }
  903. mutex_unlock(&intel_device_list_lock);
  904. out_enqueue:
  905. skb_queue_tail(&intel->txq, skb);
  906. return 0;
  907. }
  908. static struct sk_buff *intel_dequeue(struct hci_uart *hu)
  909. {
  910. struct intel_data *intel = hu->priv;
  911. struct sk_buff *skb;
  912. skb = skb_dequeue(&intel->txq);
  913. if (!skb)
  914. return skb;
  915. if (test_bit(STATE_BOOTLOADER, &intel->flags) &&
  916. (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT)) {
  917. struct hci_command_hdr *cmd = (void *)skb->data;
  918. __u16 opcode = le16_to_cpu(cmd->opcode);
  919. /* When the 0xfc01 command is issued to boot into
  920. * the operational firmware, it will actually not
  921. * send a command complete event. To keep the flow
  922. * control working inject that event here.
  923. */
  924. if (opcode == 0xfc01)
  925. inject_cmd_complete(hu->hdev, opcode);
  926. }
  927. /* Prepend skb with frame type */
  928. memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
  929. return skb;
  930. }
  931. static const struct hci_uart_proto intel_proto = {
  932. .id = HCI_UART_INTEL,
  933. .name = "Intel",
  934. .manufacturer = 2,
  935. .init_speed = 115200,
  936. .oper_speed = 3000000,
  937. .open = intel_open,
  938. .close = intel_close,
  939. .flush = intel_flush,
  940. .setup = intel_setup,
  941. .set_baudrate = intel_set_baudrate,
  942. .recv = intel_recv,
  943. .enqueue = intel_enqueue,
  944. .dequeue = intel_dequeue,
  945. };
  946. #ifdef CONFIG_ACPI
  947. static const struct acpi_device_id intel_acpi_match[] = {
  948. { "INT33E1", 0 },
  949. { },
  950. };
  951. MODULE_DEVICE_TABLE(acpi, intel_acpi_match);
  952. #endif
  953. #ifdef CONFIG_PM
  954. static int intel_suspend_device(struct device *dev)
  955. {
  956. struct intel_device *idev = dev_get_drvdata(dev);
  957. mutex_lock(&idev->hu_lock);
  958. if (idev->hu)
  959. intel_lpm_suspend(idev->hu);
  960. mutex_unlock(&idev->hu_lock);
  961. return 0;
  962. }
  963. static int intel_resume_device(struct device *dev)
  964. {
  965. struct intel_device *idev = dev_get_drvdata(dev);
  966. mutex_lock(&idev->hu_lock);
  967. if (idev->hu)
  968. intel_lpm_resume(idev->hu);
  969. mutex_unlock(&idev->hu_lock);
  970. return 0;
  971. }
  972. #endif
  973. #ifdef CONFIG_PM_SLEEP
  974. static int intel_suspend(struct device *dev)
  975. {
  976. struct intel_device *idev = dev_get_drvdata(dev);
  977. if (device_may_wakeup(dev))
  978. enable_irq_wake(idev->irq);
  979. return intel_suspend_device(dev);
  980. }
  981. static int intel_resume(struct device *dev)
  982. {
  983. struct intel_device *idev = dev_get_drvdata(dev);
  984. if (device_may_wakeup(dev))
  985. disable_irq_wake(idev->irq);
  986. return intel_resume_device(dev);
  987. }
  988. #endif
  989. static const struct dev_pm_ops intel_pm_ops = {
  990. SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
  991. SET_RUNTIME_PM_OPS(intel_suspend_device, intel_resume_device, NULL)
  992. };
  993. static int intel_probe(struct platform_device *pdev)
  994. {
  995. struct intel_device *idev;
  996. idev = devm_kzalloc(&pdev->dev, sizeof(*idev), GFP_KERNEL);
  997. if (!idev)
  998. return -ENOMEM;
  999. mutex_init(&idev->hu_lock);
  1000. idev->pdev = pdev;
  1001. idev->reset = devm_gpiod_get(&pdev->dev, "reset", GPIOD_OUT_LOW);
  1002. if (IS_ERR(idev->reset)) {
  1003. dev_err(&pdev->dev, "Unable to retrieve gpio\n");
  1004. return PTR_ERR(idev->reset);
  1005. }
  1006. idev->irq = platform_get_irq(pdev, 0);
  1007. if (idev->irq < 0) {
  1008. struct gpio_desc *host_wake;
  1009. dev_err(&pdev->dev, "No IRQ, falling back to gpio-irq\n");
  1010. host_wake = devm_gpiod_get(&pdev->dev, "host-wake", GPIOD_IN);
  1011. if (IS_ERR(host_wake)) {
  1012. dev_err(&pdev->dev, "Unable to retrieve IRQ\n");
  1013. goto no_irq;
  1014. }
  1015. idev->irq = gpiod_to_irq(host_wake);
  1016. if (idev->irq < 0) {
  1017. dev_err(&pdev->dev, "No corresponding irq for gpio\n");
  1018. goto no_irq;
  1019. }
  1020. }
  1021. /* Only enable wake-up/irq when controller is powered */
  1022. device_set_wakeup_capable(&pdev->dev, true);
  1023. device_wakeup_disable(&pdev->dev);
  1024. no_irq:
  1025. platform_set_drvdata(pdev, idev);
  1026. /* Place this instance on the device list */
  1027. mutex_lock(&intel_device_list_lock);
  1028. list_add_tail(&idev->list, &intel_device_list);
  1029. mutex_unlock(&intel_device_list_lock);
  1030. dev_info(&pdev->dev, "registered, gpio(%d)/irq(%d).\n",
  1031. desc_to_gpio(idev->reset), idev->irq);
  1032. return 0;
  1033. }
  1034. static int intel_remove(struct platform_device *pdev)
  1035. {
  1036. struct intel_device *idev = platform_get_drvdata(pdev);
  1037. device_wakeup_disable(&pdev->dev);
  1038. mutex_lock(&intel_device_list_lock);
  1039. list_del(&idev->list);
  1040. mutex_unlock(&intel_device_list_lock);
  1041. dev_info(&pdev->dev, "unregistered.\n");
  1042. return 0;
  1043. }
  1044. static struct platform_driver intel_driver = {
  1045. .probe = intel_probe,
  1046. .remove = intel_remove,
  1047. .driver = {
  1048. .name = "hci_intel",
  1049. .acpi_match_table = ACPI_PTR(intel_acpi_match),
  1050. .pm = &intel_pm_ops,
  1051. },
  1052. };
  1053. int __init intel_init(void)
  1054. {
  1055. platform_driver_register(&intel_driver);
  1056. return hci_uart_register_proto(&intel_proto);
  1057. }
  1058. int __exit intel_deinit(void)
  1059. {
  1060. platform_driver_unregister(&intel_driver);
  1061. return hci_uart_unregister_proto(&intel_proto);
  1062. }