Lines Matching +full:sub +full:- +full:message
1 // SPDX-License-Identifier: GPL-2.0
5 * (C) Copyright 2008-2010,2015 Intel Corporation
10 * SCU has two IPC mechanism IPC-1 and IPC-2. IPC-1 is used between IA32 and
11 * SCU where IPC-2 is used between P-Unit and SCU. This driver delas with
12 * IPC-1 Driver provides an API for power control unit registers (e.g. MSIC)
29 /* IPC defines the following message types */
32 /* Command id associated with message IPCMSG_PCNTRL */
35 #define IPC_CMD_PCNTRL_M 2 /* Register read-modify-write */
41 * To read or write information to the SCU, driver writes to IPC-1 memory
45 * Transaction Layer Packet (TLP) message which is sent across the cDMI.
47 * 2. South Complex cDMI block receives this message and writes it to
48 * the IPC-1 register block, causing an interrupt to the SCU
50 * 3. SCU firmware decodes this interrupt and IPC message and the appropriate
51 * message handler is called within firmware.
90 * intel_scu_ipc_dev_get() - Get SCU IPC instance
106 get_device(&ipcdev->dev); in intel_scu_ipc_dev_get()
111 if (try_module_get(ipcdev->owner)) in intel_scu_ipc_dev_get()
114 put_device(&ipcdev->dev); in intel_scu_ipc_dev_get()
122 * intel_scu_ipc_dev_put() - Put SCU IPC instance
132 module_put(scu->owner); in intel_scu_ipc_dev_put()
133 put_device(&scu->dev); in intel_scu_ipc_dev_put()
145 struct intel_scu_ipc_dev *scu = dr->scu; in devm_intel_scu_ipc_dev_release()
151 * devm_intel_scu_ipc_dev_get() - Allocate managed SCU IPC device
176 dr->scu = scu; in devm_intel_scu_ipc_dev_get()
192 reinit_completion(&scu->cmd_complete); in ipc_command()
193 writel(cmd | IPC_IOC, scu->ipc_base); in ipc_command()
199 * 16-byte buffer for sending data associated with IPC command to
204 writel(data, scu->ipc_base + IPC_WRITE_BUFFER + offset); in ipc_data_writel()
216 return __raw_readl(scu->ipc_base + IPC_STATUS); in ipc_read_status()
222 return readl(scu->ipc_base + IPC_READ_BUFFER + offset); in ipc_data_readl()
236 return (status & IPC_STATUS_ERR) ? -EIO : 0; in busy_loop()
244 wait_for_completion_timeout(&scu->cmd_complete, IPC_TIMEOUT); in ipc_wait_for_interrupt()
248 return -ETIMEDOUT; in ipc_wait_for_interrupt()
251 return -EIO; in ipc_wait_for_interrupt()
258 return scu->data.irq > 0 ? ipc_wait_for_interrupt(scu) : busy_loop(scu); in intel_scu_ipc_check_status()
268 return ERR_PTR(-ENODEV); in intel_scu_ipc_get()
272 dev_dbg(&scu->dev, "device is busy\n"); in intel_scu_ipc_get()
273 return ERR_PTR(-EBUSY); in intel_scu_ipc_get()
332 * intel_scu_ipc_dev_ioread8() - Read a byte via the SCU
349 * intel_scu_ipc_dev_iowrite8() - Write a byte via the SCU
366 * intel_scu_ipc_dev_readv() - Read a set of registers
387 * intel_scu_ipc_dev_writev() - Write a set of registers
408 * intel_scu_ipc_dev_update() - Update a register
414 * Read-modify-write power control unit register. The first data argument
431 * intel_scu_ipc_dev_simple_command() - Send a simple command
434 * @sub: Sub type
444 int sub) in intel_scu_ipc_dev_simple_command() argument
455 cmdval = sub << 12 | cmd; in intel_scu_ipc_dev_simple_command()
459 dev_err(&scu->dev, "IPC command %#x failed with %d\n", cmdval, err); in intel_scu_ipc_dev_simple_command()
465 * intel_scu_ipc_dev_command_with_size() - Command with data
468 * @sub: Sub type
481 int sub, const void *in, size_t inlen, in intel_scu_ipc_dev_command_with_size() argument
490 return -EINVAL; in intel_scu_ipc_dev_command_with_size()
502 cmdval = (size << 16) | (sub << 12) | cmd; in intel_scu_ipc_dev_command_with_size()
506 dev_err(&scu->dev, "IPC command %#x failed with %d\n", cmdval, err); in intel_scu_ipc_dev_command_with_size()
531 writel(status | IPC_STATUS_IRQ, scu->ipc_base + IPC_STATUS); in ioc()
532 complete(&scu->cmd_complete); in ioc()
540 struct intel_scu_ipc_data *data = &scu->data; in intel_scu_ipc_release()
542 if (data->irq > 0) in intel_scu_ipc_release()
543 free_irq(data->irq, scu); in intel_scu_ipc_release()
544 iounmap(scu->ipc_base); in intel_scu_ipc_release()
545 release_mem_region(data->mem.start, resource_size(&data->mem)); in intel_scu_ipc_release()
550 * __intel_scu_ipc_register() - Register SCU IPC device
574 return ERR_PTR(-EBUSY); in __intel_scu_ipc_register()
578 return ERR_PTR(-ENOMEM); in __intel_scu_ipc_register()
580 scu->owner = owner; in __intel_scu_ipc_register()
581 scu->dev.parent = parent; in __intel_scu_ipc_register()
582 scu->dev.class = &intel_scu_ipc_class; in __intel_scu_ipc_register()
583 scu->dev.release = intel_scu_ipc_release; in __intel_scu_ipc_register()
585 memcpy(&scu->data, scu_data, sizeof(scu->data)); in __intel_scu_ipc_register()
586 data = &scu->data; in __intel_scu_ipc_register()
588 if (!request_mem_region(data->mem.start, resource_size(&data->mem), "intel_scu_ipc")) { in __intel_scu_ipc_register()
589 err = -EBUSY; in __intel_scu_ipc_register()
593 ipc_base = ioremap(data->mem.start, resource_size(&data->mem)); in __intel_scu_ipc_register()
595 err = -ENOMEM; in __intel_scu_ipc_register()
599 scu->ipc_base = ipc_base; in __intel_scu_ipc_register()
600 init_completion(&scu->cmd_complete); in __intel_scu_ipc_register()
602 if (data->irq > 0) { in __intel_scu_ipc_register()
603 err = request_irq(data->irq, ioc, 0, "intel_scu_ipc", scu); in __intel_scu_ipc_register()
612 dev_set_name(&scu->dev, "intel_scu_ipc"); in __intel_scu_ipc_register()
613 err = device_register(&scu->dev); in __intel_scu_ipc_register()
615 put_device(&scu->dev); in __intel_scu_ipc_register()
626 release_mem_region(data->mem.start, resource_size(&data->mem)); in __intel_scu_ipc_register()
634 * intel_scu_ipc_unregister() - Unregister SCU IPC
646 device_unregister(&scu->dev); in intel_scu_ipc_unregister()
654 struct intel_scu_ipc_dev *scu = dr->scu; in devm_intel_scu_ipc_unregister()
660 * __devm_intel_scu_ipc_register() - Register managed SCU IPC device
688 dr->scu = scu; in __devm_intel_scu_ipc_register()