intel_scu_ipc.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. /*
  2. * intel_scu_ipc.c: Driver for the Intel SCU IPC mechanism
  3. *
  4. * (C) Copyright 2008-2010,2015 Intel Corporation
  5. * Author: Sreedhara DS (sreedhara.ds@intel.com)
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; version 2
  10. * of the License.
  11. *
  12. * SCU running in ARC processor communicates with other entity running in IA
  13. * core through IPC mechanism which in turn messaging between IA core ad SCU.
  14. * SCU has two IPC mechanism IPC-1 and IPC-2. IPC-1 is used between IA32 and
  15. * SCU where IPC-2 is used between P-Unit and SCU. This driver delas with
  16. * IPC-1 Driver provides an API for power control unit registers (e.g. MSIC)
  17. * along with other APIs.
  18. */
  19. #include <linux/delay.h>
  20. #include <linux/errno.h>
  21. #include <linux/init.h>
  22. #include <linux/device.h>
  23. #include <linux/pm.h>
  24. #include <linux/pci.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/sfi.h>
  27. #include <asm/intel-mid.h>
  28. #include <asm/intel_scu_ipc.h>
  29. /* IPC defines the following message types */
  30. #define IPCMSG_WATCHDOG_TIMER 0xF8 /* Set Kernel Watchdog Threshold */
  31. #define IPCMSG_BATTERY 0xEF /* Coulomb Counter Accumulator */
  32. #define IPCMSG_FW_UPDATE 0xFE /* Firmware update */
  33. #define IPCMSG_PCNTRL 0xFF /* Power controller unit read/write */
  34. #define IPCMSG_FW_REVISION 0xF4 /* Get firmware revision */
  35. /* Command id associated with message IPCMSG_PCNTRL */
  36. #define IPC_CMD_PCNTRL_W 0 /* Register write */
  37. #define IPC_CMD_PCNTRL_R 1 /* Register read */
  38. #define IPC_CMD_PCNTRL_M 2 /* Register read-modify-write */
  39. /*
  40. * IPC register summary
  41. *
  42. * IPC register blocks are memory mapped at fixed address of PCI BAR 0.
  43. * To read or write information to the SCU, driver writes to IPC-1 memory
  44. * mapped registers. The following is the IPC mechanism
  45. *
  46. * 1. IA core cDMI interface claims this transaction and converts it to a
  47. * Transaction Layer Packet (TLP) message which is sent across the cDMI.
  48. *
  49. * 2. South Complex cDMI block receives this message and writes it to
  50. * the IPC-1 register block, causing an interrupt to the SCU
  51. *
  52. * 3. SCU firmware decodes this interrupt and IPC message and the appropriate
  53. * message handler is called within firmware.
  54. */
  55. #define IPC_WWBUF_SIZE 20 /* IPC Write buffer Size */
  56. #define IPC_RWBUF_SIZE 20 /* IPC Read buffer Size */
  57. #define IPC_IOC 0x100 /* IPC command register IOC bit */
  58. #define PCI_DEVICE_ID_LINCROFT 0x082a
  59. #define PCI_DEVICE_ID_PENWELL 0x080e
  60. #define PCI_DEVICE_ID_CLOVERVIEW 0x08ea
  61. #define PCI_DEVICE_ID_TANGIER 0x11a0
  62. /* intel scu ipc driver data */
  63. struct intel_scu_ipc_pdata_t {
  64. u32 i2c_base;
  65. u32 i2c_len;
  66. u8 irq_mode;
  67. };
  68. static struct intel_scu_ipc_pdata_t intel_scu_ipc_lincroft_pdata = {
  69. .i2c_base = 0xff12b000,
  70. .i2c_len = 0x10,
  71. .irq_mode = 0,
  72. };
  73. /* Penwell and Cloverview */
  74. static struct intel_scu_ipc_pdata_t intel_scu_ipc_penwell_pdata = {
  75. .i2c_base = 0xff12b000,
  76. .i2c_len = 0x10,
  77. .irq_mode = 1,
  78. };
  79. static struct intel_scu_ipc_pdata_t intel_scu_ipc_tangier_pdata = {
  80. .i2c_base = 0xff00d000,
  81. .i2c_len = 0x10,
  82. .irq_mode = 0,
  83. };
  84. struct intel_scu_ipc_dev {
  85. struct device *dev;
  86. void __iomem *ipc_base;
  87. void __iomem *i2c_base;
  88. struct completion cmd_complete;
  89. u8 irq_mode;
  90. };
  91. static struct intel_scu_ipc_dev ipcdev; /* Only one for now */
  92. /*
  93. * IPC Read Buffer (Read Only):
  94. * 16 byte buffer for receiving data from SCU, if IPC command
  95. * processing results in response data
  96. */
  97. #define IPC_READ_BUFFER 0x90
  98. #define IPC_I2C_CNTRL_ADDR 0
  99. #define I2C_DATA_ADDR 0x04
  100. static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */
  101. /*
  102. * Send ipc command
  103. * Command Register (Write Only):
  104. * A write to this register results in an interrupt to the SCU core processor
  105. * Format:
  106. * |rfu2(8) | size(8) | command id(4) | rfu1(3) | ioc(1) | command(8)|
  107. */
  108. static inline void ipc_command(struct intel_scu_ipc_dev *scu, u32 cmd)
  109. {
  110. if (scu->irq_mode) {
  111. reinit_completion(&scu->cmd_complete);
  112. writel(cmd | IPC_IOC, scu->ipc_base);
  113. }
  114. writel(cmd, scu->ipc_base);
  115. }
  116. /*
  117. * Write ipc data
  118. * IPC Write Buffer (Write Only):
  119. * 16-byte buffer for sending data associated with IPC command to
  120. * SCU. Size of the data is specified in the IPC_COMMAND_REG register
  121. */
  122. static inline void ipc_data_writel(struct intel_scu_ipc_dev *scu, u32 data, u32 offset)
  123. {
  124. writel(data, scu->ipc_base + 0x80 + offset);
  125. }
  126. /*
  127. * Status Register (Read Only):
  128. * Driver will read this register to get the ready/busy status of the IPC
  129. * block and error status of the IPC command that was just processed by SCU
  130. * Format:
  131. * |rfu3(8)|error code(8)|initiator id(8)|cmd id(4)|rfu1(2)|error(1)|busy(1)|
  132. */
  133. static inline u8 ipc_read_status(struct intel_scu_ipc_dev *scu)
  134. {
  135. return __raw_readl(scu->ipc_base + 0x04);
  136. }
  137. /* Read ipc byte data */
  138. static inline u8 ipc_data_readb(struct intel_scu_ipc_dev *scu, u32 offset)
  139. {
  140. return readb(scu->ipc_base + IPC_READ_BUFFER + offset);
  141. }
  142. /* Read ipc u32 data */
  143. static inline u32 ipc_data_readl(struct intel_scu_ipc_dev *scu, u32 offset)
  144. {
  145. return readl(scu->ipc_base + IPC_READ_BUFFER + offset);
  146. }
  147. /* Wait till scu status is busy */
  148. static inline int busy_loop(struct intel_scu_ipc_dev *scu)
  149. {
  150. u32 status = ipc_read_status(scu);
  151. u32 loop_count = 100000;
  152. /* break if scu doesn't reset busy bit after huge retry */
  153. while ((status & BIT(0)) && --loop_count) {
  154. udelay(1); /* scu processing time is in few u secods */
  155. status = ipc_read_status(scu);
  156. }
  157. if (status & BIT(0)) {
  158. dev_err(scu->dev, "IPC timed out");
  159. return -ETIMEDOUT;
  160. }
  161. if (status & BIT(1))
  162. return -EIO;
  163. return 0;
  164. }
  165. /* Wait till ipc ioc interrupt is received or timeout in 3 HZ */
  166. static inline int ipc_wait_for_interrupt(struct intel_scu_ipc_dev *scu)
  167. {
  168. int status;
  169. if (!wait_for_completion_timeout(&scu->cmd_complete, 3 * HZ)) {
  170. dev_err(scu->dev, "IPC timed out\n");
  171. return -ETIMEDOUT;
  172. }
  173. status = ipc_read_status(scu);
  174. if (status & BIT(1))
  175. return -EIO;
  176. return 0;
  177. }
  178. static int intel_scu_ipc_check_status(struct intel_scu_ipc_dev *scu)
  179. {
  180. return scu->irq_mode ? ipc_wait_for_interrupt(scu) : busy_loop(scu);
  181. }
  182. /* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */
  183. static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
  184. {
  185. struct intel_scu_ipc_dev *scu = &ipcdev;
  186. int nc;
  187. u32 offset = 0;
  188. int err;
  189. u8 cbuf[IPC_WWBUF_SIZE];
  190. u32 *wbuf = (u32 *)&cbuf;
  191. memset(cbuf, 0, sizeof(cbuf));
  192. mutex_lock(&ipclock);
  193. if (scu->dev == NULL) {
  194. mutex_unlock(&ipclock);
  195. return -ENODEV;
  196. }
  197. for (nc = 0; nc < count; nc++, offset += 2) {
  198. cbuf[offset] = addr[nc];
  199. cbuf[offset + 1] = addr[nc] >> 8;
  200. }
  201. if (id == IPC_CMD_PCNTRL_R) {
  202. for (nc = 0, offset = 0; nc < count; nc++, offset += 4)
  203. ipc_data_writel(scu, wbuf[nc], offset);
  204. ipc_command(scu, (count * 2) << 16 | id << 12 | 0 << 8 | op);
  205. } else if (id == IPC_CMD_PCNTRL_W) {
  206. for (nc = 0; nc < count; nc++, offset += 1)
  207. cbuf[offset] = data[nc];
  208. for (nc = 0, offset = 0; nc < count; nc++, offset += 4)
  209. ipc_data_writel(scu, wbuf[nc], offset);
  210. ipc_command(scu, (count * 3) << 16 | id << 12 | 0 << 8 | op);
  211. } else if (id == IPC_CMD_PCNTRL_M) {
  212. cbuf[offset] = data[0];
  213. cbuf[offset + 1] = data[1];
  214. ipc_data_writel(scu, wbuf[0], 0); /* Write wbuff */
  215. ipc_command(scu, 4 << 16 | id << 12 | 0 << 8 | op);
  216. }
  217. err = intel_scu_ipc_check_status(scu);
  218. if (!err && id == IPC_CMD_PCNTRL_R) { /* Read rbuf */
  219. /* Workaround: values are read as 0 without memcpy_fromio */
  220. memcpy_fromio(cbuf, scu->ipc_base + 0x90, 16);
  221. for (nc = 0; nc < count; nc++)
  222. data[nc] = ipc_data_readb(scu, nc);
  223. }
  224. mutex_unlock(&ipclock);
  225. return err;
  226. }
  227. /**
  228. * intel_scu_ipc_ioread8 - read a word via the SCU
  229. * @addr: register on SCU
  230. * @data: return pointer for read byte
  231. *
  232. * Read a single register. Returns 0 on success or an error code. All
  233. * locking between SCU accesses is handled for the caller.
  234. *
  235. * This function may sleep.
  236. */
  237. int intel_scu_ipc_ioread8(u16 addr, u8 *data)
  238. {
  239. return pwr_reg_rdwr(&addr, data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
  240. }
  241. EXPORT_SYMBOL(intel_scu_ipc_ioread8);
  242. /**
  243. * intel_scu_ipc_ioread16 - read a word via the SCU
  244. * @addr: register on SCU
  245. * @data: return pointer for read word
  246. *
  247. * Read a register pair. Returns 0 on success or an error code. All
  248. * locking between SCU accesses is handled for the caller.
  249. *
  250. * This function may sleep.
  251. */
  252. int intel_scu_ipc_ioread16(u16 addr, u16 *data)
  253. {
  254. u16 x[2] = {addr, addr + 1};
  255. return pwr_reg_rdwr(x, (u8 *)data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
  256. }
  257. EXPORT_SYMBOL(intel_scu_ipc_ioread16);
  258. /**
  259. * intel_scu_ipc_ioread32 - read a dword via the SCU
  260. * @addr: register on SCU
  261. * @data: return pointer for read dword
  262. *
  263. * Read four registers. Returns 0 on success or an error code. All
  264. * locking between SCU accesses is handled for the caller.
  265. *
  266. * This function may sleep.
  267. */
  268. int intel_scu_ipc_ioread32(u16 addr, u32 *data)
  269. {
  270. u16 x[4] = {addr, addr + 1, addr + 2, addr + 3};
  271. return pwr_reg_rdwr(x, (u8 *)data, 4, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
  272. }
  273. EXPORT_SYMBOL(intel_scu_ipc_ioread32);
  274. /**
  275. * intel_scu_ipc_iowrite8 - write a byte via the SCU
  276. * @addr: register on SCU
  277. * @data: byte to write
  278. *
  279. * Write a single register. Returns 0 on success or an error code. All
  280. * locking between SCU accesses is handled for the caller.
  281. *
  282. * This function may sleep.
  283. */
  284. int intel_scu_ipc_iowrite8(u16 addr, u8 data)
  285. {
  286. return pwr_reg_rdwr(&addr, &data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
  287. }
  288. EXPORT_SYMBOL(intel_scu_ipc_iowrite8);
  289. /**
  290. * intel_scu_ipc_iowrite16 - write a word via the SCU
  291. * @addr: register on SCU
  292. * @data: word to write
  293. *
  294. * Write two registers. Returns 0 on success or an error code. All
  295. * locking between SCU accesses is handled for the caller.
  296. *
  297. * This function may sleep.
  298. */
  299. int intel_scu_ipc_iowrite16(u16 addr, u16 data)
  300. {
  301. u16 x[2] = {addr, addr + 1};
  302. return pwr_reg_rdwr(x, (u8 *)&data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
  303. }
  304. EXPORT_SYMBOL(intel_scu_ipc_iowrite16);
  305. /**
  306. * intel_scu_ipc_iowrite32 - write a dword via the SCU
  307. * @addr: register on SCU
  308. * @data: dword to write
  309. *
  310. * Write four registers. Returns 0 on success or an error code. All
  311. * locking between SCU accesses is handled for the caller.
  312. *
  313. * This function may sleep.
  314. */
  315. int intel_scu_ipc_iowrite32(u16 addr, u32 data)
  316. {
  317. u16 x[4] = {addr, addr + 1, addr + 2, addr + 3};
  318. return pwr_reg_rdwr(x, (u8 *)&data, 4, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
  319. }
  320. EXPORT_SYMBOL(intel_scu_ipc_iowrite32);
  321. /**
  322. * intel_scu_ipc_readvv - read a set of registers
  323. * @addr: register list
  324. * @data: bytes to return
  325. * @len: length of array
  326. *
  327. * Read registers. Returns 0 on success or an error code. All
  328. * locking between SCU accesses is handled for the caller.
  329. *
  330. * The largest array length permitted by the hardware is 5 items.
  331. *
  332. * This function may sleep.
  333. */
  334. int intel_scu_ipc_readv(u16 *addr, u8 *data, int len)
  335. {
  336. return pwr_reg_rdwr(addr, data, len, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
  337. }
  338. EXPORT_SYMBOL(intel_scu_ipc_readv);
  339. /**
  340. * intel_scu_ipc_writev - write a set of registers
  341. * @addr: register list
  342. * @data: bytes to write
  343. * @len: length of array
  344. *
  345. * Write registers. Returns 0 on success or an error code. All
  346. * locking between SCU accesses is handled for the caller.
  347. *
  348. * The largest array length permitted by the hardware is 5 items.
  349. *
  350. * This function may sleep.
  351. *
  352. */
  353. int intel_scu_ipc_writev(u16 *addr, u8 *data, int len)
  354. {
  355. return pwr_reg_rdwr(addr, data, len, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
  356. }
  357. EXPORT_SYMBOL(intel_scu_ipc_writev);
  358. /**
  359. * intel_scu_ipc_update_register - r/m/w a register
  360. * @addr: register address
  361. * @bits: bits to update
  362. * @mask: mask of bits to update
  363. *
  364. * Read-modify-write power control unit register. The first data argument
  365. * must be register value and second is mask value
  366. * mask is a bitmap that indicates which bits to update.
  367. * 0 = masked. Don't modify this bit, 1 = modify this bit.
  368. * returns 0 on success or an error code.
  369. *
  370. * This function may sleep. Locking between SCU accesses is handled
  371. * for the caller.
  372. */
  373. int intel_scu_ipc_update_register(u16 addr, u8 bits, u8 mask)
  374. {
  375. u8 data[2] = { bits, mask };
  376. return pwr_reg_rdwr(&addr, data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_M);
  377. }
  378. EXPORT_SYMBOL(intel_scu_ipc_update_register);
  379. /**
  380. * intel_scu_ipc_simple_command - send a simple command
  381. * @cmd: command
  382. * @sub: sub type
  383. *
  384. * Issue a simple command to the SCU. Do not use this interface if
  385. * you must then access data as any data values may be overwritten
  386. * by another SCU access by the time this function returns.
  387. *
  388. * This function may sleep. Locking for SCU accesses is handled for
  389. * the caller.
  390. */
  391. int intel_scu_ipc_simple_command(int cmd, int sub)
  392. {
  393. struct intel_scu_ipc_dev *scu = &ipcdev;
  394. int err;
  395. mutex_lock(&ipclock);
  396. if (scu->dev == NULL) {
  397. mutex_unlock(&ipclock);
  398. return -ENODEV;
  399. }
  400. ipc_command(scu, sub << 12 | cmd);
  401. err = intel_scu_ipc_check_status(scu);
  402. mutex_unlock(&ipclock);
  403. return err;
  404. }
  405. EXPORT_SYMBOL(intel_scu_ipc_simple_command);
  406. /**
  407. * intel_scu_ipc_command - command with data
  408. * @cmd: command
  409. * @sub: sub type
  410. * @in: input data
  411. * @inlen: input length in dwords
  412. * @out: output data
  413. * @outlein: output length in dwords
  414. *
  415. * Issue a command to the SCU which involves data transfers. Do the
  416. * data copies under the lock but leave it for the caller to interpret
  417. */
  418. int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
  419. u32 *out, int outlen)
  420. {
  421. struct intel_scu_ipc_dev *scu = &ipcdev;
  422. int i, err;
  423. mutex_lock(&ipclock);
  424. if (scu->dev == NULL) {
  425. mutex_unlock(&ipclock);
  426. return -ENODEV;
  427. }
  428. for (i = 0; i < inlen; i++)
  429. ipc_data_writel(scu, *in++, 4 * i);
  430. ipc_command(scu, (inlen << 16) | (sub << 12) | cmd);
  431. err = intel_scu_ipc_check_status(scu);
  432. if (!err) {
  433. for (i = 0; i < outlen; i++)
  434. *out++ = ipc_data_readl(scu, 4 * i);
  435. }
  436. mutex_unlock(&ipclock);
  437. return err;
  438. }
  439. EXPORT_SYMBOL(intel_scu_ipc_command);
  440. /* I2C commands */
  441. #define IPC_I2C_WRITE 1 /* I2C Write command */
  442. #define IPC_I2C_READ 2 /* I2C Read command */
  443. /**
  444. * intel_scu_ipc_i2c_cntrl - I2C read/write operations
  445. * @addr: I2C address + command bits
  446. * @data: data to read/write
  447. *
  448. * Perform an an I2C read/write operation via the SCU. All locking is
  449. * handled for the caller. This function may sleep.
  450. *
  451. * Returns an error code or 0 on success.
  452. *
  453. * This has to be in the IPC driver for the locking.
  454. */
  455. int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
  456. {
  457. struct intel_scu_ipc_dev *scu = &ipcdev;
  458. u32 cmd = 0;
  459. mutex_lock(&ipclock);
  460. if (scu->dev == NULL) {
  461. mutex_unlock(&ipclock);
  462. return -ENODEV;
  463. }
  464. cmd = (addr >> 24) & 0xFF;
  465. if (cmd == IPC_I2C_READ) {
  466. writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR);
  467. /* Write not getting updated without delay */
  468. mdelay(1);
  469. *data = readl(scu->i2c_base + I2C_DATA_ADDR);
  470. } else if (cmd == IPC_I2C_WRITE) {
  471. writel(*data, scu->i2c_base + I2C_DATA_ADDR);
  472. mdelay(1);
  473. writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR);
  474. } else {
  475. dev_err(scu->dev,
  476. "intel_scu_ipc: I2C INVALID_CMD = 0x%x\n", cmd);
  477. mutex_unlock(&ipclock);
  478. return -EIO;
  479. }
  480. mutex_unlock(&ipclock);
  481. return 0;
  482. }
  483. EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);
  484. /*
  485. * Interrupt handler gets called when ioc bit of IPC_COMMAND_REG set to 1
  486. * When ioc bit is set to 1, caller api must wait for interrupt handler called
  487. * which in turn unlocks the caller api. Currently this is not used
  488. *
  489. * This is edge triggered so we need take no action to clear anything
  490. */
  491. static irqreturn_t ioc(int irq, void *dev_id)
  492. {
  493. struct intel_scu_ipc_dev *scu = dev_id;
  494. if (scu->irq_mode)
  495. complete(&scu->cmd_complete);
  496. return IRQ_HANDLED;
  497. }
  498. /**
  499. * ipc_probe - probe an Intel SCU IPC
  500. * @pdev: the PCI device matching
  501. * @id: entry in the match table
  502. *
  503. * Enable and install an intel SCU IPC. This appears in the PCI space
  504. * but uses some hard coded addresses as well.
  505. */
  506. static int ipc_probe(struct pci_dev *pdev, const struct pci_device_id *id)
  507. {
  508. int platform; /* Platform type */
  509. int err;
  510. struct intel_scu_ipc_dev *scu = &ipcdev;
  511. struct intel_scu_ipc_pdata_t *pdata;
  512. platform = intel_mid_identify_cpu();
  513. if (platform == 0)
  514. return -ENODEV;
  515. if (scu->dev) /* We support only one SCU */
  516. return -EBUSY;
  517. pdata = (struct intel_scu_ipc_pdata_t *)id->driver_data;
  518. scu->dev = &pdev->dev;
  519. scu->irq_mode = pdata->irq_mode;
  520. err = pcim_enable_device(pdev);
  521. if (err)
  522. return err;
  523. err = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
  524. if (err)
  525. return err;
  526. init_completion(&scu->cmd_complete);
  527. err = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_scu_ipc",
  528. scu);
  529. if (err)
  530. return err;
  531. scu->ipc_base = pcim_iomap_table(pdev)[0];
  532. scu->i2c_base = ioremap_nocache(pdata->i2c_base, pdata->i2c_len);
  533. if (!scu->i2c_base)
  534. return -ENOMEM;
  535. intel_scu_devices_create();
  536. pci_set_drvdata(pdev, scu);
  537. return 0;
  538. }
  539. static const struct pci_device_id pci_ids[] = {
  540. {
  541. PCI_VDEVICE(INTEL, PCI_DEVICE_ID_LINCROFT),
  542. (kernel_ulong_t)&intel_scu_ipc_lincroft_pdata,
  543. }, {
  544. PCI_VDEVICE(INTEL, PCI_DEVICE_ID_PENWELL),
  545. (kernel_ulong_t)&intel_scu_ipc_penwell_pdata,
  546. }, {
  547. PCI_VDEVICE(INTEL, PCI_DEVICE_ID_CLOVERVIEW),
  548. (kernel_ulong_t)&intel_scu_ipc_penwell_pdata,
  549. }, {
  550. PCI_VDEVICE(INTEL, PCI_DEVICE_ID_TANGIER),
  551. (kernel_ulong_t)&intel_scu_ipc_tangier_pdata,
  552. }, {
  553. 0,
  554. }
  555. };
  556. static struct pci_driver ipc_driver = {
  557. .driver = {
  558. .suppress_bind_attrs = true,
  559. },
  560. .name = "intel_scu_ipc",
  561. .id_table = pci_ids,
  562. .probe = ipc_probe,
  563. };
  564. builtin_pci_driver(ipc_driver);