2 * intel_scu_ipc.c: Driver for the Intel SCU IPC mechanism
4 * (C) Copyright 2008-2010 Intel Corporation
5 * Author: Sreedhara DS (sreedhara.ds@intel.com)
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
12 * SCU runing 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.
19 #include <linux/delay.h>
20 #include <linux/errno.h>
21 #include <linux/init.h>
22 #include <linux/sysdev.h>
24 #include <linux/pci.h>
25 #include <linux/interrupt.h>
27 #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 */
36 /* Command id associated with message IPCMSG_PCNTRL */
37 #define IPC_CMD_PCNTRL_W 0 /* Register write */
38 #define IPC_CMD_PCNTRL_R 1 /* Register read */
39 #define IPC_CMD_PCNTRL_M 2 /* Register read-modify-write */
41 /* Miscelaneous Command ids */
42 #define IPC_CMD_INDIRECT_RD 2 /* 32bit indirect read */
43 #define IPC_CMD_INDIRECT_WR 5 /* 32bit indirect write */
46 * IPC register summary
48 * IPC register blocks are memory mapped at fixed address of 0xFF11C000
49 * To read or write information to the SCU, driver writes to IPC-1 memory
50 * mapped registers (base address 0xFF11C000). The following is the IPC
53 * 1. IA core cDMI interface claims this transaction and converts it to a
54 * Transaction Layer Packet (TLP) message which is sent across the cDMI.
56 * 2. South Complex cDMI block receives this message and writes it to
57 * the IPC-1 register block, causing an interrupt to the SCU
59 * 3. SCU firmware decodes this interrupt and IPC message and the appropriate
60 * message handler is called within firmware.
63 #define IPC_BASE_ADDR 0xFF11C000 /* IPC1 base register address */
64 #define IPC_MAX_ADDR 0x100 /* Maximum IPC regisers */
65 #define IPC_WWBUF_SIZE 16 /* IPC Write buffer Size */
66 #define IPC_RWBUF_SIZE 16 /* IPC Read buffer Size */
67 #define IPC_I2C_BASE 0xFF12B000 /* I2C control register base address */
68 #define IPC_I2C_MAX_ADDR 0x10 /* Maximum I2C regisers */
70 static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id);
71 static void ipc_remove(struct pci_dev *pdev);
73 struct intel_scu_ipc_dev {
75 void __iomem *ipc_base;
76 void __iomem *i2c_base;
79 static struct intel_scu_ipc_dev ipcdev; /* Only one for now */
81 #define PLATFORM_LANGWELL 1
82 #define PLATFORM_PENWELL 2
83 static int platform; /* Platform type */
86 * IPC Read Buffer (Read Only):
87 * 16 byte buffer for receiving data from SCU, if IPC command
88 * processing results in response data
90 #define IPC_READ_BUFFER 0x90
92 #define IPC_I2C_CNTRL_ADDR 0
93 #define I2C_DATA_ADDR 0x04
95 static DEFINE_MUTEX(ipclock); /* lock used to prevent multiple call to SCU */
98 * Command Register (Write Only):
99 * A write to this register results in an interrupt to the SCU core processor
101 * |rfu2(8) | size(8) | command id(4) | rfu1(3) | ioc(1) | command(8)|
103 static inline void ipc_command(u32 cmd) /* Send ipc command */
105 writel(cmd, ipcdev.ipc_base);
109 * IPC Write Buffer (Write Only):
110 * 16-byte buffer for sending data associated with IPC command to
111 * SCU. Size of the data is specified in the IPC_COMMAND_REG register
113 static inline void ipc_data_writel(u32 data, u32 offset) /* Write ipc data */
115 writel(data, ipcdev.ipc_base + 0x80 + offset);
119 * IPC destination Pointer (Write Only):
120 * Use content as pointer for destination write
122 static inline void ipc_write_dptr(u32 data) /* Write dptr data */
124 writel(data, ipcdev.ipc_base + 0x0C);
128 * IPC Source Pointer (Write Only):
129 * Use content as pointer for read location
131 static inline void ipc_write_sptr(u32 data) /* Write dptr data */
133 writel(data, ipcdev.ipc_base + 0x08);
137 * Status Register (Read Only):
138 * Driver will read this register to get the ready/busy status of the IPC
139 * block and error status of the IPC command that was just processed by SCU
141 * |rfu3(8)|error code(8)|initiator id(8)|cmd id(4)|rfu1(2)|error(1)|busy(1)|
144 static inline u8 ipc_read_status(void)
146 return __raw_readl(ipcdev.ipc_base + 0x04);
149 static inline u8 ipc_data_readb(u32 offset) /* Read ipc byte data */
151 return readb(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
154 static inline u32 ipc_data_readl(u32 offset) /* Read ipc u32 data */
156 return readl(ipcdev.ipc_base + IPC_READ_BUFFER + offset);
159 static inline int busy_loop(void) /* Wait till scu status is busy */
164 status = ipc_read_status();
166 udelay(1); /* scu processing time is in few u secods */
167 status = ipc_read_status();
169 /* break if scu doesn't reset busy bit after huge retry */
170 if (loop_count > 100000) {
171 dev_err(&ipcdev.pdev->dev, "IPC timed out");
175 return (status >> 1) & 1;
178 /* Read/Write power control(PMIC in Langwell, MSIC in PenWell) registers */
179 static int pwr_reg_rdwr(u16 *addr, u8 *data, u32 count, u32 op, u32 id)
184 u8 cbuf[IPC_WWBUF_SIZE] = { };
185 u32 *wbuf = (u32 *)&cbuf;
187 mutex_lock(&ipclock);
189 if (ipcdev.pdev == NULL) {
190 mutex_unlock(&ipclock);
194 if (platform == PLATFORM_LANGWELL) {
195 /* Entry is 4 bytes for read/write, 5 bytes for read modify */
196 for (nc = 0; nc < count; nc++, offset += 3) {
197 cbuf[offset] = addr[nc];
198 cbuf[offset + 1] = addr[nc] >> 8;
199 if (id != IPC_CMD_PCNTRL_R)
200 cbuf[offset + 2] = data[nc];
201 if (id == IPC_CMD_PCNTRL_M) {
202 cbuf[offset + 3] = data[nc + 1];
206 for (nc = 0, offset = 0; nc < count; nc++, offset += 4)
207 ipc_data_writel(wbuf[nc], offset); /* Write wbuff */
209 if (id != IPC_CMD_PCNTRL_M)
210 ipc_command((count*4) << 16 | id << 12 | 0 << 8 | op);
212 ipc_command((count*5) << 16 | id << 12 | 0 << 8 | op);
215 for (nc = 0; nc < count; nc++, offset += 2) {
216 cbuf[offset] = addr[nc];
217 cbuf[offset + 1] = addr[nc] >> 8;
220 if (id == IPC_CMD_PCNTRL_R) {
221 for (nc = 0, offset = 0; nc < count; nc++, offset += 4)
222 ipc_data_writel(wbuf[nc], offset);
223 ipc_command((count*2) << 16 | id << 12 | 0 << 8 | op);
224 } else if (id == IPC_CMD_PCNTRL_W) {
225 for (nc = 0; nc < count; nc++, offset += 1)
226 cbuf[offset] = data[nc];
227 for (nc = 0, offset = 0; nc < count; nc++, offset += 4)
228 ipc_data_writel(wbuf[nc], offset);
229 ipc_command((count*3) << 16 | id << 12 | 0 << 8 | op);
230 } else if (id == IPC_CMD_PCNTRL_M) {
231 cbuf[offset] = data[0];
232 cbuf[offset + 1] = data[1];
233 ipc_data_writel(wbuf[0], 0); /* Write wbuff */
234 ipc_command(4 << 16 | id << 12 | 0 << 8 | op);
239 if (id == IPC_CMD_PCNTRL_R) { /* Read rbuf */
240 /* Workaround: values are read as 0 without memcpy_fromio */
241 memcpy_fromio(cbuf, ipcdev.ipc_base + 0x90, 16);
242 if (platform == PLATFORM_LANGWELL) {
243 for (nc = 0, offset = 2; nc < count; nc++, offset += 3)
244 data[nc] = ipc_data_readb(offset);
246 for (nc = 0; nc < count; nc++)
247 data[nc] = ipc_data_readb(nc);
250 mutex_unlock(&ipclock);
255 * intel_scu_ipc_ioread8 - read a word via the SCU
256 * @addr: register on SCU
257 * @data: return pointer for read byte
259 * Read a single register. Returns 0 on success or an error code. All
260 * locking between SCU accesses is handled for the caller.
262 * This function may sleep.
264 int intel_scu_ipc_ioread8(u16 addr, u8 *data)
266 return pwr_reg_rdwr(&addr, data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
268 EXPORT_SYMBOL(intel_scu_ipc_ioread8);
271 * intel_scu_ipc_ioread16 - read a word via the SCU
272 * @addr: register on SCU
273 * @data: return pointer for read word
275 * Read a register pair. Returns 0 on success or an error code. All
276 * locking between SCU accesses is handled for the caller.
278 * This function may sleep.
280 int intel_scu_ipc_ioread16(u16 addr, u16 *data)
282 u16 x[2] = {addr, addr + 1 };
283 return pwr_reg_rdwr(x, (u8 *)data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
285 EXPORT_SYMBOL(intel_scu_ipc_ioread16);
288 * intel_scu_ipc_ioread32 - read a dword via the SCU
289 * @addr: register on SCU
290 * @data: return pointer for read dword
292 * Read four registers. Returns 0 on success or an error code. All
293 * locking between SCU accesses is handled for the caller.
295 * This function may sleep.
297 int intel_scu_ipc_ioread32(u16 addr, u32 *data)
299 u16 x[4] = {addr, addr + 1, addr + 2, addr + 3};
300 return pwr_reg_rdwr(x, (u8 *)data, 4, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
302 EXPORT_SYMBOL(intel_scu_ipc_ioread32);
305 * intel_scu_ipc_iowrite8 - write a byte via the SCU
306 * @addr: register on SCU
307 * @data: byte to write
309 * Write a single register. Returns 0 on success or an error code. All
310 * locking between SCU accesses is handled for the caller.
312 * This function may sleep.
314 int intel_scu_ipc_iowrite8(u16 addr, u8 data)
316 return pwr_reg_rdwr(&addr, &data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
318 EXPORT_SYMBOL(intel_scu_ipc_iowrite8);
321 * intel_scu_ipc_iowrite16 - write a word via the SCU
322 * @addr: register on SCU
323 * @data: word to write
325 * Write two registers. Returns 0 on success or an error code. All
326 * locking between SCU accesses is handled for the caller.
328 * This function may sleep.
330 int intel_scu_ipc_iowrite16(u16 addr, u16 data)
332 u16 x[2] = {addr, addr + 1 };
333 return pwr_reg_rdwr(x, (u8 *)&data, 2, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
335 EXPORT_SYMBOL(intel_scu_ipc_iowrite16);
338 * intel_scu_ipc_iowrite32 - write a dword via the SCU
339 * @addr: register on SCU
340 * @data: dword to write
342 * Write four registers. Returns 0 on success or an error code. All
343 * locking between SCU accesses is handled for the caller.
345 * This function may sleep.
347 int intel_scu_ipc_iowrite32(u16 addr, u32 data)
349 u16 x[4] = {addr, addr + 1, addr + 2, addr + 3};
350 return pwr_reg_rdwr(x, (u8 *)&data, 4, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
352 EXPORT_SYMBOL(intel_scu_ipc_iowrite32);
355 * intel_scu_ipc_readvv - read a set of registers
356 * @addr: register list
357 * @data: bytes to return
358 * @len: length of array
360 * Read registers. Returns 0 on success or an error code. All
361 * locking between SCU accesses is handled for the caller.
363 * The largest array length permitted by the hardware is 5 items.
365 * This function may sleep.
367 int intel_scu_ipc_readv(u16 *addr, u8 *data, int len)
369 return pwr_reg_rdwr(addr, data, len, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_R);
371 EXPORT_SYMBOL(intel_scu_ipc_readv);
374 * intel_scu_ipc_writev - write a set of registers
375 * @addr: register list
376 * @data: bytes to write
377 * @len: length of array
379 * Write registers. Returns 0 on success or an error code. All
380 * locking between SCU accesses is handled for the caller.
382 * The largest array length permitted by the hardware is 5 items.
384 * This function may sleep.
387 int intel_scu_ipc_writev(u16 *addr, u8 *data, int len)
389 return pwr_reg_rdwr(addr, data, len, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_W);
391 EXPORT_SYMBOL(intel_scu_ipc_writev);
395 * intel_scu_ipc_update_register - r/m/w a register
396 * @addr: register address
397 * @bits: bits to update
398 * @mask: mask of bits to update
400 * Read-modify-write power control unit register. The first data argument
401 * must be register value and second is mask value
402 * mask is a bitmap that indicates which bits to update.
403 * 0 = masked. Don't modify this bit, 1 = modify this bit.
404 * returns 0 on success or an error code.
406 * This function may sleep. Locking between SCU accesses is handled
409 int intel_scu_ipc_update_register(u16 addr, u8 bits, u8 mask)
411 u8 data[2] = { bits, mask };
412 return pwr_reg_rdwr(&addr, data, 1, IPCMSG_PCNTRL, IPC_CMD_PCNTRL_M);
414 EXPORT_SYMBOL(intel_scu_ipc_update_register);
417 * intel_scu_ipc_register_read - 32bit indirect read
418 * @addr: register address
419 * @value: 32bit value return
421 * Performs IA 32 bit indirect read, returns 0 on success, or an
424 * Can be used when SCCB(System Controller Configuration Block) register
425 * HRIM(Honor Restricted IPC Messages) is set (bit 23)
427 * This function may sleep. Locking for SCU accesses is handled for
430 int intel_scu_ipc_register_read(u32 addr, u32 *value)
434 mutex_lock(&ipclock);
435 if (ipcdev.pdev == NULL) {
436 mutex_unlock(&ipclock);
439 ipc_write_sptr(addr);
440 ipc_command(4 << 16 | IPC_CMD_INDIRECT_RD);
442 *value = ipc_data_readl(0);
443 mutex_unlock(&ipclock);
446 EXPORT_SYMBOL(intel_scu_ipc_register_read);
449 * intel_scu_ipc_register_write - 32bit indirect write
450 * @addr: register address
451 * @value: 32bit value to write
453 * Performs IA 32 bit indirect write, returns 0 on success, or an
456 * Can be used when SCCB(System Controller Configuration Block) register
457 * HRIM(Honor Restricted IPC Messages) is set (bit 23)
459 * This function may sleep. Locking for SCU accesses is handled for
462 int intel_scu_ipc_register_write(u32 addr, u32 value)
466 mutex_lock(&ipclock);
467 if (ipcdev.pdev == NULL) {
468 mutex_unlock(&ipclock);
471 ipc_write_dptr(addr);
472 ipc_data_writel(value, 0);
473 ipc_command(4 << 16 | IPC_CMD_INDIRECT_WR);
475 mutex_unlock(&ipclock);
478 EXPORT_SYMBOL(intel_scu_ipc_register_write);
481 * intel_scu_ipc_simple_command - send a simple command
485 * Issue a simple command to the SCU. Do not use this interface if
486 * you must then access data as any data values may be overwritten
487 * by another SCU access by the time this function returns.
489 * This function may sleep. Locking for SCU accesses is handled for
492 int intel_scu_ipc_simple_command(int cmd, int sub)
496 mutex_lock(&ipclock);
497 if (ipcdev.pdev == NULL) {
498 mutex_unlock(&ipclock);
501 ipc_command(sub << 12 | cmd);
503 mutex_unlock(&ipclock);
506 EXPORT_SYMBOL(intel_scu_ipc_simple_command);
509 * intel_scu_ipc_command - command with data
513 * @inlen: input length in dwords
515 * @outlein: output length in dwords
517 * Issue a command to the SCU which involves data transfers. Do the
518 * data copies under the lock but leave it for the caller to interpret
521 int intel_scu_ipc_command(int cmd, int sub, u32 *in, int inlen,
522 u32 *out, int outlen)
527 mutex_lock(&ipclock);
528 if (ipcdev.pdev == NULL) {
529 mutex_unlock(&ipclock);
533 for (i = 0; i < inlen; i++)
534 ipc_data_writel(*in++, 4 * i);
536 ipc_command((sub << 12) | cmd | (inlen << 18));
539 for (i = 0; i < outlen; i++)
540 *out++ = ipc_data_readl(4 * i);
542 mutex_unlock(&ipclock);
545 EXPORT_SYMBOL(intel_scu_ipc_command);
548 #define IPC_I2C_WRITE 1 /* I2C Write command */
549 #define IPC_I2C_READ 2 /* I2C Read command */
552 * intel_scu_ipc_i2c_cntrl - I2C read/write operations
553 * @addr: I2C address + command bits
554 * @data: data to read/write
556 * Perform an an I2C read/write operation via the SCU. All locking is
557 * handled for the caller. This function may sleep.
559 * Returns an error code or 0 on success.
561 * This has to be in the IPC driver for the locking.
563 int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
567 mutex_lock(&ipclock);
568 if (ipcdev.pdev == NULL) {
569 mutex_unlock(&ipclock);
572 cmd = (addr >> 24) & 0xFF;
573 if (cmd == IPC_I2C_READ) {
574 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR);
575 /* Write not getting updated without delay */
577 *data = readl(ipcdev.i2c_base + I2C_DATA_ADDR);
578 } else if (cmd == IPC_I2C_WRITE) {
579 writel(addr, ipcdev.i2c_base + I2C_DATA_ADDR);
581 writel(addr, ipcdev.i2c_base + IPC_I2C_CNTRL_ADDR);
583 dev_err(&ipcdev.pdev->dev,
584 "intel_scu_ipc: I2C INVALID_CMD = 0x%x\n", cmd);
586 mutex_unlock(&ipclock);
589 mutex_unlock(&ipclock);
592 EXPORT_SYMBOL(intel_scu_ipc_i2c_cntrl);
594 #define IPC_FW_LOAD_ADDR 0xFFFC0000 /* Storage location for FW image */
595 #define IPC_FW_UPDATE_MBOX_ADDR 0xFFFFDFF4 /* Mailbox between ipc and scu */
596 #define IPC_MAX_FW_SIZE 262144 /* 256K storage size for loading the FW image */
597 #define IPC_FW_MIP_HEADER_SIZE 2048 /* Firmware MIP header size */
598 /* IPC inform SCU to get ready for update process */
599 #define IPC_CMD_FW_UPDATE_READY 0x10FE
600 /* IPC inform SCU to go for update process */
601 #define IPC_CMD_FW_UPDATE_GO 0x20FE
602 /* Status code for fw update */
603 #define IPC_FW_UPDATE_SUCCESS 0x444f4e45 /* Status code 'DONE' */
604 #define IPC_FW_UPDATE_BADN 0x4241444E /* Status code 'BADN' */
605 #define IPC_FW_TXHIGH 0x54784849 /* Status code 'IPC_FW_TXHIGH' */
606 #define IPC_FW_TXLOW 0x54784c4f /* Status code 'IPC_FW_TXLOW' */
608 struct fw_update_mailbox {
616 * intel_scu_ipc_fw_update - Firmware update utility
617 * @buffer: firmware buffer
618 * @length: size of firmware buffer
620 * This function provides an interface to load the firmware into
621 * the SCU. Returns 0 on success or -1 on failure
623 int intel_scu_ipc_fw_update(u8 *buffer, u32 length)
625 void __iomem *fw_update_base;
626 struct fw_update_mailbox __iomem *mailbox = NULL;
630 mutex_lock(&ipclock);
631 fw_update_base = ioremap_nocache(IPC_FW_LOAD_ADDR, (128*1024));
632 if (fw_update_base == NULL) {
633 mutex_unlock(&ipclock);
636 mailbox = ioremap_nocache(IPC_FW_UPDATE_MBOX_ADDR,
637 sizeof(struct fw_update_mailbox));
638 if (mailbox == NULL) {
639 iounmap(fw_update_base);
640 mutex_unlock(&ipclock);
644 ipc_command(IPC_CMD_FW_UPDATE_READY);
646 /* Intitialize mailbox */
647 writel(0, &mailbox->status);
648 writel(0, &mailbox->scu_flag);
649 writel(0, &mailbox->driver_flag);
651 /* Driver copies the 2KB MIP header to SRAM at 0xFFFC0000*/
652 memcpy_toio(fw_update_base, buffer, 0x800);
654 /* Driver sends "FW Update" IPC command (CMD_ID 0xFE; MSG_ID 0x02).
655 * Upon receiving this command, SCU will write the 2K MIP header
656 * from 0xFFFC0000 into NAND.
657 * SCU will write a status code into the Mailbox, and then set scu_flag.
660 ipc_command(IPC_CMD_FW_UPDATE_GO);
662 /*Driver stalls until scu_flag is set */
663 while (readl(&mailbox->scu_flag) != 1) {
668 /* Driver checks Mailbox status.
669 * If the status is 'BADN', then abort (bad NAND).
670 * If the status is 'IPC_FW_TXLOW', then continue.
672 while (readl(&mailbox->status) != IPC_FW_TXLOW) {
682 if (readl(&mailbox->status) != IPC_FW_TXLOW)
684 buffer = buffer + 0x800;
685 memcpy_toio(fw_update_base, buffer, 0x20000);
686 writel(1, &mailbox->driver_flag);
687 while (readl(&mailbox->scu_flag) == 1) {
692 /* check for 'BADN' */
693 if (readl(&mailbox->status) == IPC_FW_UPDATE_BADN)
696 while (readl(&mailbox->status) != IPC_FW_TXHIGH) {
702 if (readl(&mailbox->status) != IPC_FW_TXHIGH)
705 buffer = buffer + 0x20000;
706 memcpy_toio(fw_update_base, buffer, 0x20000);
707 writel(0, &mailbox->driver_flag);
709 while (mailbox->scu_flag == 0) {
714 /* check for 'BADN' */
715 if (readl(&mailbox->status) == IPC_FW_UPDATE_BADN)
718 if (readl(&mailbox->status) == IPC_FW_TXLOW) {
724 status = readl(&mailbox->status);
726 iounmap(fw_update_base);
728 mutex_unlock(&ipclock);
730 if (status == IPC_FW_UPDATE_SUCCESS)
734 EXPORT_SYMBOL(intel_scu_ipc_fw_update);
737 * Interrupt handler gets called when ioc bit of IPC_COMMAND_REG set to 1
738 * When ioc bit is set to 1, caller api must wait for interrupt handler called
739 * which in turn unlocks the caller api. Currently this is not used
741 * This is edge triggered so we need take no action to clear anything
743 static irqreturn_t ioc(int irq, void *dev_id)
749 * ipc_probe - probe an Intel SCU IPC
750 * @dev: the PCI device matching
751 * @id: entry in the match table
753 * Enable and install an intel SCU IPC. This appears in the PCI space
754 * but uses some hard coded addresses as well.
756 static int ipc_probe(struct pci_dev *dev, const struct pci_device_id *id)
759 resource_size_t pci_resource;
761 if (ipcdev.pdev) /* We support only one SCU */
764 ipcdev.pdev = pci_dev_get(dev);
766 err = pci_enable_device(dev);
770 err = pci_request_regions(dev, "intel_scu_ipc");
774 pci_resource = pci_resource_start(dev, 0);
778 if (request_irq(dev->irq, ioc, 0, "intel_scu_ipc", &ipcdev))
781 ipcdev.ipc_base = ioremap_nocache(IPC_BASE_ADDR, IPC_MAX_ADDR);
782 if (!ipcdev.ipc_base)
785 ipcdev.i2c_base = ioremap_nocache(IPC_I2C_BASE, IPC_I2C_MAX_ADDR);
786 if (!ipcdev.i2c_base) {
787 iounmap(ipcdev.ipc_base);
794 * ipc_remove - remove a bound IPC device
797 * In practice the SCU is not removable but this function is also
798 * called for each device on a module unload or cleanup which is the
799 * path that will get used.
801 * Free up the mappings and release the PCI resources
803 static void ipc_remove(struct pci_dev *pdev)
805 free_irq(pdev->irq, &ipcdev);
806 pci_release_regions(pdev);
807 pci_dev_put(ipcdev.pdev);
808 iounmap(ipcdev.ipc_base);
809 iounmap(ipcdev.i2c_base);
813 static const struct pci_device_id pci_ids[] = {
814 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x080e)},
815 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x082a)},
818 MODULE_DEVICE_TABLE(pci, pci_ids);
820 static struct pci_driver ipc_driver = {
821 .name = "intel_scu_ipc",
824 .remove = ipc_remove,
828 static int __init intel_scu_ipc_init(void)
830 if (boot_cpu_data.x86 == 6 &&
831 boot_cpu_data.x86_model == 0x27 &&
832 boot_cpu_data.x86_mask == 1)
833 platform = PLATFORM_PENWELL;
834 else if (boot_cpu_data.x86 == 6 &&
835 boot_cpu_data.x86_model == 0x26)
836 platform = PLATFORM_LANGWELL;
838 return pci_register_driver(&ipc_driver);
841 static void __exit intel_scu_ipc_exit(void)
843 pci_unregister_driver(&ipc_driver);
846 MODULE_AUTHOR("Sreedhara DS <sreedhara.ds@intel.com>");
847 MODULE_DESCRIPTION("Intel SCU IPC driver");
848 MODULE_LICENSE("GPL");
850 module_init(intel_scu_ipc_init);
851 module_exit(intel_scu_ipc_exit);