Intel Vision Processing base enabling
Subsystems (6)
v3 cover Intel Vision Processing base enabling
From: Mark Gross <[email protected]>
The Intel Vision Processing Unit (VPU) is an IP block that is showing up for the first time as part of the Keem Bay SOC. Keem Bay is a quad core A53 Arm SOC. It is designed to be used as a stand alone SOC as well as in an PCIe Vision Processing accelerator add in card.
This thrid version of this patch set includes updates to xling-pci some minor updates to a Kconfig help text and global use of EXPORT_SYMBOL_GPL based on review feedback.
At the bottom of this coverletter is the delta between v2 and V3 for easy review of the modifications. Feels like things are converging. :)
Thanks for looking at these and providing feedback.
--mark
C, Udhayakumar (8):
dt-bindings: misc: intel_tsens: Add tsens thermal bindings
documentation
misc: Tsens ARM host thermal driver.
misc: Intel tsens IA host driver.
Intel tsens i2c slave driver.
misc:intel_tsens: Intel Keem Bay tsens driver.
dt-bindings: misc: hddl_dev: Add hddl device management documentation
misc: Hddl device management for local host
misc: HDDL device management for IA host
Daniele Alessandrelli (4):
dt-bindings: mailbox: Add Intel VPU IPC mailbox bindings
mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
dt-bindings: Add bindings for Keem Bay IPC driver
keembay-ipc: Add Keem Bay IPC module
Li, Tingqian (2):
dt-bindings: misc: Add Keem Bay vpumgr
misc: Add Keem Bay VPU manager
Paul Murphy (2):
dt-bindings: Add bindings for Keem Bay VPU IPC driver
keembay-vpu-ipc: Add Keem Bay VPU IPC module
Ramya P Karanth (1):
Intel Keem Bay XLink SMBus driver
Seamus Kelly (7):
xlink-ipc: Add xlink ipc device tree bindings
xlink-ipc: Add xlink ipc driver
xlink-core: Add xlink core device tree bindings
xlink-core: Add xlink core driver xLink
xlink-core: Enable xlink protocol over pcie
xlink-core: Enable VPU IP management and runtime control
xlink-core: add async channel and events
Srikanth Thokala (9):
misc: xlink-pcie: Add documentation for XLink PCIe driver
misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
misc: xlink-pcie: lh: Add PCIe EP DMA functionality
misc: xlink-pcie: lh: Add core communication logic
misc: xlink-pcie: lh: Prepare changes for adding remote host driver
misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
misc: xlink-pcie: rh: Add core communication logic
misc: xlink-pcie: Add XLink API interface
misc: xlink-pcie: Add asynchronous event notification support for
XLink
mark gross (1):
Add Vision Processing Unit (VPU) documentation.
.../mailbox/intel,vpu-ipc-mailbox.yaml | 69 + .../bindings/misc/intel,hddl-client.yaml | 114 + .../bindings/misc/intel,intel-tsens.yaml | 122 + .../bindings/misc/intel,keembay-vpu-mgr.yaml | 48 + .../misc/intel,keembay-xlink-ipc.yaml | 49 + .../bindings/misc/intel,keembay-xlink.yaml | 27 + .../bindings/soc/intel/intel,keembay-ipc.yaml | 45 + .../soc/intel/intel,keembay-vpu-ipc.yaml | 153 ++ Documentation/hwmon/index.rst | 2 + Documentation/hwmon/intel_tsens_host.rst | 71 + Documentation/hwmon/intel_tsens_sensor.rst | 67 + Documentation/i2c/busses/index.rst | 1 + .../i2c/busses/intel-xlink-smbus.rst | 71 + Documentation/index.rst | 1 + .../misc-devices/hddl_device_client.rst | 212 ++ .../misc-devices/hddl_device_server.rst | 205 ++ Documentation/misc-devices/index.rst | 2 + Documentation/vpu/index.rst | 20 + Documentation/vpu/vpu-stack-overview.rst | 270 +++ Documentation/vpu/xlink-core.rst | 81 + Documentation/vpu/xlink-ipc.rst | 51 + Documentation/vpu/xlink-pcie.rst | 90 + MAINTAINERS | 54 + drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/vpu-ipc-mailbox.c | 297 +++ drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 7 + drivers/misc/hddl_device/Kconfig | 26 + drivers/misc/hddl_device/Makefile | 7 + drivers/misc/hddl_device/hddl_device.c | 565 +++++ drivers/misc/hddl_device/hddl_device_lh.c | 764 +++++++ drivers/misc/hddl_device/hddl_device_rh.c | 837 +++++++ drivers/misc/hddl_device/hddl_device_util.h | 52 + drivers/misc/intel_tsens/Kconfig | 55 + drivers/misc/intel_tsens/Makefile | 10 + drivers/misc/intel_tsens/intel_tsens_host.c | 351 +++ drivers/misc/intel_tsens/intel_tsens_i2c.c | 119 + .../misc/intel_tsens/intel_tsens_thermal.c | 651 ++++++ .../misc/intel_tsens/intel_tsens_thermal.h | 38 + drivers/misc/intel_tsens/keembay_thermal.c | 169 ++ drivers/misc/intel_tsens/keembay_tsens.h | 366 +++ drivers/misc/vpumgr/Kconfig | 9 + drivers/misc/vpumgr/Makefile | 3 + drivers/misc/vpumgr/vpu_common.h | 31 + drivers/misc/vpumgr/vpu_mgr.c | 370 +++ drivers/misc/vpumgr/vpu_smm.c | 554 +++++ drivers/misc/vpumgr/vpu_smm.h | 30 + drivers/misc/vpumgr/vpu_vcm.c | 584 +++++ drivers/misc/vpumgr/vpu_vcm.h | 84 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 1331 +++++++++++ drivers/misc/xlink-core/xlink-core.h | 25 + drivers/misc/xlink-core/xlink-defs.h | 181 ++ drivers/misc/xlink-core/xlink-dispatcher.c | 436 ++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-ioctl.c | 554 +++++ drivers/misc/xlink-core/xlink-ioctl.h | 36 + drivers/misc/xlink-core/xlink-multiplexer.c | 1164 ++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 273 +++ drivers/misc/xlink-core/xlink-platform.h | 65 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 878 +++++++ drivers/misc/xlink-pcie/Kconfig | 20 + drivers/misc/xlink-pcie/Makefile | 2 + drivers/misc/xlink-pcie/common/core.h | 245 ++ drivers/misc/xlink-pcie/common/interface.c | 124 + drivers/misc/xlink-pcie/common/util.c | 373 +++ drivers/misc/xlink-pcie/common/util.h | 68 + drivers/misc/xlink-pcie/common/xpcie.h | 100 + drivers/misc/xlink-pcie/local_host/Makefile | 6 + drivers/misc/xlink-pcie/local_host/core.c | 817 +++++++ drivers/misc/xlink-pcie/local_host/dma.c | 575 +++++ drivers/misc/xlink-pcie/local_host/epf.c | 482 ++++ drivers/misc/xlink-pcie/local_host/epf.h | 101 + drivers/misc/xlink-pcie/remote_host/Makefile | 6 + drivers/misc/xlink-pcie/remote_host/core.c | 621 +++++ drivers/misc/xlink-pcie/remote_host/main.c | 93 + drivers/misc/xlink-pcie/remote_host/pci.c | 523 +++++ drivers/misc/xlink-pcie/remote_host/pci.h | 65 + drivers/misc/xlink-smbus/Kconfig | 26 + drivers/misc/xlink-smbus/Makefile | 5 + drivers/misc/xlink-smbus/xlink-smbus.c | 467 ++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 33 + drivers/soc/intel/Makefile | 5 + drivers/soc/intel/keembay-ipc.c | 1364 +++++++++++ drivers/soc/intel/keembay-vpu-ipc.c | 2036 +++++++++++++++++ include/linux/hddl_device.h | 153 ++ include/linux/intel_tsens_host.h | 34 + include/linux/soc/intel/keembay-ipc.h | 30 + include/linux/soc/intel/keembay-vpu-ipc.h | 62 + include/linux/xlink-ipc.h | 48 + include/linux/xlink.h | 146 ++ include/linux/xlink_drv_inf.h | 70 + include/uapi/misc/vpumgr.h | 64 + include/uapi/misc/xlink_uapi.h | 145 ++ 101 files changed, 21788 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml create mode 100644 Documentation/hwmon/intel_tsens_host.rst create mode 100644 Documentation/hwmon/intel_tsens_sensor.rst create mode 100644 Documentation/i2c/busses/intel-xlink-smbus.rst create mode 100644 Documentation/misc-devices/hddl_device_client.rst create mode 100644 Documentation/misc-devices/hddl_device_server.rst create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 Documentation/vpu/xlink-pcie.rst create mode 100644 drivers/mailbox/vpu-ipc-mailbox.c create mode 100644 drivers/misc/hddl_device/Kconfig create mode 100644 drivers/misc/hddl_device/Makefile create mode 100644 drivers/misc/hddl_device/hddl_device.c create mode 100644 drivers/misc/hddl_device/hddl_device_lh.c create mode 100644 drivers/misc/hddl_device/hddl_device_rh.c create mode 100644 drivers/misc/hddl_device/hddl_device_util.h create mode 100644 drivers/misc/intel_tsens/Kconfig create mode 100644 drivers/misc/intel_tsens/Makefile create mode 100644 drivers/misc/intel_tsens/intel_tsens_host.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_i2c.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.h create mode 100644 drivers/misc/intel_tsens/keembay_thermal.c create mode 100644 drivers/misc/intel_tsens/keembay_tsens.h create mode 100644 drivers/misc/vpumgr/Kconfig create mode 100644 drivers/misc/vpumgr/Makefile create mode 100644 drivers/misc/vpumgr/vpu_common.h create mode 100644 drivers/misc/vpumgr/vpu_mgr.c create mode 100644 drivers/misc/vpumgr/vpu_smm.c create mode 100644 drivers/misc/vpumgr/vpu_smm.h create mode 100644 drivers/misc/vpumgr/vpu_vcm.c create mode 100644 drivers/misc/vpumgr/vpu_vcm.h create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/common/core.h create mode 100644 drivers/misc/xlink-pcie/common/interface.c create mode 100644 drivers/misc/xlink-pcie/common/util.c create mode 100644 drivers/misc/xlink-pcie/common/util.h create mode 100644 drivers/misc/xlink-pcie/common/xpcie.h create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h create mode 100644 drivers/misc/xlink-smbus/Kconfig create mode 100644 drivers/misc/xlink-smbus/Makefile create mode 100644 drivers/misc/xlink-smbus/xlink-smbus.c create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/hddl_device.h create mode 100644 include/linux/intel_tsens_host.h create mode 100644 include/linux/soc/intel/keembay-ipc.h create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h create mode 100644 include/linux/xlink-ipc.h create mode 100644 include/linux/xlink.h create mode 100644 include/linux/xlink_drv_inf.h create mode 100644 include/uapi/misc/vpumgr.h create mode 100644 include/uapi/misc/xlink_uapi.h
Signature · 1 line
2.17.1
Documentation/vpu/xlink-core.rst +2 -2
@@ -55,7 +55,7 @@ When a user wants to send data across an interface via xLink it firstly calls xlink connect which connects to the relevant interface (PCIe, USB, IPC, etc.) and then xlink open channel. -Then it calls xlink write function, this takes the data, passes it to the +Then it calls xlink write function. This takes the data, passes it to the kernel which packages up the data and channel and then adds it to a transmit queue.
@@ -70,7 +70,7 @@ any data it adds it to channel packet container. The application at this side of the interface will have called xlink connect, opened the channel and called xlink read function to read data from the -interface and if any exists for that channel , the data gets popped from the +interface and if any exists for that channel, the data gets popped from the channel packet container and copied from kernel space to user space buffer provided by the call.
Documentation/vpu/xlink-pcie.rst +3 -3
@@ -15,7 +15,7 @@ Introduction ============ The Xlink-pcie driver provides transport layer implementation for the data transfers to support Xlink protocol subsystem communication with the -peer device. i.e, between remote host system and Keem Bay device. +peer device, i.e., between remote host system and Keem Bay device. The Keem Bay device is an ARM-based SOC that includes a vision processing unit (VPU) and deep learning, neural network core in the hardware.
@@ -65,8 +65,8 @@ XLink PCIe communication between local host and remote host is achieved through ring buffer management and MSI/Doorbell interrupts. The Xlink-pcie driver subsystem registers the Keem Bay device as an endpoint -driver and provides standard linux PCIe sysfs interface, # -/sys/bus/pci/devices/xxxx:xx:xx.0/ +driver and provides standard Linux PCIe sysfs interface: +'/sys/bus/pci/devices/xxxx:xx:xx.0/' XLink protocol subsystem
drivers/misc/intel_tsens/Kconfig +3 -2
@@ -20,12 +20,12 @@ config INTEL_TSENS_I2C_SLAVE select I2C select I2C_SLAVE help - This option enables tsens i2c slave driver. + This option enables tsens I2C slave driver. This driver is used for reporting thermal data via I2C SMBUS to remote host. Enable this option if you want to have support for thermal - management controller + management controller. Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N.
@@ -40,6 +40,7 @@ config KEEMBAY_THERMAL values from Keem Bay SoC. Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. + config INTEL_TSENS_IA_HOST tristate "Temperature sensor driver for intel tsens remote host" depends on I2C && THERMAL
drivers/misc/intel_tsens/intel_tsens_thermal.c +1 -1
@@ -495,7 +495,7 @@ static int intel_tsens_config_dt(struct intel_tsens_priv *priv) ts =devm_kzalloc (&pdev->dev,sizeof (struct intel_tsens ),GFP_KERNEL ); -if (!ts){ +if (!ts) {of_node_put (s_node);return -ENOMEM ; }
drivers/misc/intel_tsens/keembay_tsens.h +1 -1
@@ -61,7 +61,7 @@ enum keembay_thermal_sensor_en {#define KEEMBAY_SENSOR_BASE_TEMP 27 -static int const raw_kmb[] = { +static const int raw_kmb[] = {39956 ,-39637 ,-39319 ,-39001 ,-38684 ,38367 ,-38050 ,-37734 ,-37418 ,-37103 ,
drivers/misc/vpumgr/vpu_vcm.c +1 -2
@@ -361,8 +361,7 @@ int vcm_wait(struct vpumgr_ctx *v, s32 submit_id, rc =wait_for_completion_interruptible_timeout (&vcmd->complete, timeout);if (rc <0 ) { goto exit; - } -else if (rc ==0 ) { + }else if (rc ==0 ) { rc = -ETIMEDOUT ; goto exit; }else {
drivers/misc/xlink-core/xlink-core.c +24 -24
191 lines not on this page · raw message
drivers/misc/xlink-ipc/xlink-ipc.c +12 -12
@@ -426,7 +426,7 @@ int xlink_ipc_connect(u32 sw_device_id)return 0 ; } -EXPORT_SYMBOL (xlink_ipc_connect); +EXPORT_SYMBOL_GPL (xlink_ipc_connect);/* * xlink_ipc_write() - platform write interface.
@@ -471,7 +471,7 @@ int xlink_ipc_write(u32 sw_device_id, void *data, size_t * const size,return rc; } -EXPORT_SYMBOL (xlink_ipc_write); +EXPORT_SYMBOL_GPL (xlink_ipc_write);/* * xlink_ipc_read() - platform read interface.
@@ -513,7 +513,7 @@ int xlink_ipc_read(u32 sw_device_id, void *data, size_t * const size, }return rc; } -EXPORT_SYMBOL (xlink_ipc_read); +EXPORT_SYMBOL_GPL (xlink_ipc_read);/* * xlink_ipc_get_device_list() - platform get device list interface.
@@ -538,7 +538,7 @@ int xlink_ipc_get_device_list(u32 *sw_device_id_list, u32 *num_devices) *num_devices = i;return 0 ; } -EXPORT_SYMBOL (xlink_ipc_get_device_list); +EXPORT_SYMBOL_GPL (xlink_ipc_get_device_list);/* * xlink_ipc_get_device_name() - platform get device name interface.
@@ -566,7 +566,7 @@ int xlink_ipc_get_device_name(u32 sw_device_id, char *device_name,strncpy (device_name, xlink_dev->device_name, size);return 0 ; } -EXPORT_SYMBOL (xlink_ipc_get_device_name); +EXPORT_SYMBOL_GPL (xlink_ipc_get_device_name);/* * xlink_ipc_get_device_status() - platform get device status interface.
@@ -587,7 +587,7 @@ int xlink_ipc_get_device_status(u32 sw_device_id, u32 *device_status) *device_status =intel_keembay_vpu_status (xlink_dev->vpu_dev);return 0 ; } -EXPORT_SYMBOL (xlink_ipc_get_device_status); +EXPORT_SYMBOL_GPL (xlink_ipc_get_device_status);static void kernel_callback (struct device *dev,enum intel_keembay_vpu_event event) {
@@ -619,7 +619,7 @@ int xlink_ipc_register_for_events(u32 sw_device_id, rc =intel_keembay_vpu_register_for_events (xlink_dev->vpu_dev, kernel_callback);return rc; } -EXPORT_SYMBOL (xlink_ipc_register_for_events); +EXPORT_SYMBOL_GPL (xlink_ipc_register_for_events);/* * xlink_ipc_unregister_for_events() - platform register for events *
@@ -636,7 +636,7 @@ int xlink_ipc_unregister_for_events(u32 sw_device_id) rc =intel_keembay_vpu_unregister_for_events (xlink_dev->vpu_dev);return rc; } -EXPORT_SYMBOL (xlink_ipc_unregister_for_events); +EXPORT_SYMBOL_GPL (xlink_ipc_unregister_for_events);/* * xlink_ipc_boot_device() - platform boot device interface.
@@ -683,7 +683,7 @@ int xlink_ipc_boot_device(u32 sw_device_id, const char *binary_name)pr_info ("VPU was ready.\n" );return 0 ; } -EXPORT_SYMBOL (xlink_ipc_boot_device); +EXPORT_SYMBOL_GPL (xlink_ipc_boot_device);/* * xlink_ipc_reset_device() - platform reset device interface.
@@ -717,7 +717,7 @@ int xlink_ipc_reset_device(u32 sw_device_id) }return 0 ; } -EXPORT_SYMBOL (xlink_ipc_reset_device); +EXPORT_SYMBOL_GPL (xlink_ipc_reset_device);/* * xlink_ipc_open_channel() - platform open channel interface.
@@ -738,7 +738,7 @@ int xlink_ipc_open_channel(u32 sw_device_id, u32 channel) KMB_VPU_IPC_NODE_LEON_MSS, channel);return rc; } -EXPORT_SYMBOL (xlink_ipc_open_channel); +EXPORT_SYMBOL_GPL (xlink_ipc_open_channel);/* * xlink_ipc_close_channel() - platform close channel interface.
@@ -759,7 +759,7 @@ int xlink_ipc_close_channel(u32 sw_device_id, u32 channel) KMB_VPU_IPC_NODE_LEON_MSS, channel);return rc; } -EXPORT_SYMBOL (xlink_ipc_close_channel); +EXPORT_SYMBOL_GPL (xlink_ipc_close_channel);/* * xlink ipc driver functions
drivers/misc/xlink-pcie/common/core.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_
drivers/misc/xlink-pcie/common/interface.c +13 -15
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include <linux/xlink_drv_inf.h>
@@ -22,7 +20,7 @@ int xlink_pcie_get_device_list(u32 *sw_device_id_list, u32 *num_devices)return 0 ; } -EXPORT_SYMBOL (xlink_pcie_get_device_list); +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_list);int xlink_pcie_get_device_name (u32 sw_device_id,char *device_name,size_t name_size)
@@ -33,7 +31,7 @@ int xlink_pcie_get_device_name(u32 sw_device_id, char *device_name,return intel_xpcie_get_device_name_by_id (sw_device_id, device_name, name_size); } -EXPORT_SYMBOL (xlink_pcie_get_device_name); +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_name);int xlink_pcie_get_device_status (u32 sw_device_id,u32 *device_status) {
@@ -68,19 +66,19 @@ int xlink_pcie_get_device_status(u32 sw_device_id, u32 *device_status)return 0 ; } -EXPORT_SYMBOL (xlink_pcie_get_device_status); +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_status);int xlink_pcie_boot_device (u32 sw_device_id,const char *binary_name) {return 0 ; } -EXPORT_SYMBOL (xlink_pcie_boot_device); +EXPORT_SYMBOL_GPL (xlink_pcie_boot_device);int xlink_pcie_connect (u32 sw_device_id) {return intel_xpcie_pci_connect_device (sw_device_id); } -EXPORT_SYMBOL (xlink_pcie_connect); +EXPORT_SYMBOL_GPL (xlink_pcie_connect);int xlink_pcie_read (u32 sw_device_id,void *data,size_t *const size,u32 timeout)
@@ -90,7 +88,7 @@ int xlink_pcie_read(u32 sw_device_id, void *data, size_t *const size,return intel_xpcie_pci_read (sw_device_id, data, size, timeout); } -EXPORT_SYMBOL (xlink_pcie_read); +EXPORT_SYMBOL_GPL (xlink_pcie_read);int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size,u32 timeout)
@@ -100,13 +98,13 @@ int xlink_pcie_write(u32 sw_device_id, void *data, size_t *const size,return intel_xpcie_pci_write (sw_device_id, data, size, timeout); } -EXPORT_SYMBOL (xlink_pcie_write); +EXPORT_SYMBOL_GPL (xlink_pcie_write);int xlink_pcie_reset_device (u32 sw_device_id) {return intel_xpcie_pci_reset_device (sw_device_id); } -EXPORT_SYMBOL (xlink_pcie_reset_device); +EXPORT_SYMBOL_GPL (xlink_pcie_reset_device);int xlink_pcie_register_device_event (u32 sw_device_id,xlink_device_event event_notif_fn)
@@ -117,10 +115,10 @@ int xlink_pcie_register_device_event(u32 sw_device_id,return intel_xpcie_pci_register_device_event (sw_device_id, event_notif_fn); } -EXPORT_SYMBOL (xlink_pcie_register_device_event); +EXPORT_SYMBOL_GPL (xlink_pcie_register_device_event);int xlink_pcie_unregister_device_event (u32 sw_device_id) {return intel_xpcie_pci_unregister_device_event (sw_device_id); } -EXPORT_SYMBOL (xlink_pcie_unregister_device_event); +EXPORT_SYMBOL_GPL (xlink_pcie_unregister_device_event);
drivers/misc/xlink-pcie/common/util.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include "util.h"
drivers/misc/xlink-pcie/common/util.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_UTIL_HEADER_ #define XPCIE_UTIL_HEADER_
drivers/misc/xlink-pcie/common/xpcie.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_HEADER_ #define XPCIE_HEADER_
drivers/misc/xlink-pcie/local_host/core.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include <linux/of_reserved_mem.h>
drivers/misc/xlink-pcie/local_host/dma.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include <linux/delay.h> #include <linux/interrupt.h> #include <linux/wait.h>
drivers/misc/xlink-pcie/local_host/epf.c +8 -48
84 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_EPF_HEADER_ #define XPCIE_EPF_HEADER_
drivers/misc/xlink-pcie/remote_host/core.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include "pci.h"
drivers/misc/xlink-pcie/remote_host/main.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include "pci.h" #include "../common/core.h"
drivers/misc/xlink-pcie/remote_host/pci.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include <linux/mutex.h> #include <linux/pci.h>
drivers/misc/xlink-pcie/remote_host/pci.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_PCI_HEADER_ #define XPCIE_PCI_HEADER_
drivers/soc/intel/keembay-ipc.c +4 -4
@@ -1161,7 +1161,7 @@ int intel_keembay_ipc_open_channel(struct device *dev, u8 node_id, u16 chan_id)return 0 ; } -EXPORT_SYMBOL (intel_keembay_ipc_open_channel); +EXPORT_SYMBOL_GPL (intel_keembay_ipc_open_channel);/** * intel_keembay_ipc_close_channel() - Close an IPC channel.
@@ -1192,7 +1192,7 @@ int intel_keembay_ipc_close_channel(struct device *dev, u8 node_id, u16 chan_id)return 0 ; } -EXPORT_SYMBOL (intel_keembay_ipc_close_channel); +EXPORT_SYMBOL_GPL (intel_keembay_ipc_close_channel);/** * intel_keembay_ipc_send() - Send data via IPC.
@@ -1242,7 +1242,7 @@ int intel_keembay_ipc_send(struct device *dev, u8 node_id, u16 chan_id,srcu_read_unlock (&link->srcu_sp[chan_id], idx);return rc; } -EXPORT_SYMBOL (intel_keembay_ipc_send); +EXPORT_SYMBOL_GPL (intel_keembay_ipc_send);/** * intel_keembay_ipc_recv() - Read data via IPC
@@ -1356,7 +1356,7 @@ int intel_keembay_ipc_recv(struct device *dev, u8 node_id, u16 chan_id,srcu_read_unlock (&link->srcu_sp[chan_id], idx);return rc; } -EXPORT_SYMBOL (intel_keembay_ipc_recv); +EXPORT_SYMBOL_GPL (intel_keembay_ipc_recv);MODULE_DESCRIPTION ("Keem Bay IPC Driver" );MODULE_AUTHOR ("Daniele Alessandrelli <[email protected]>" );
drivers/soc/intel/keembay-vpu-ipc.c +12 -12
@@ -1463,7 +1463,7 @@ int intel_keembay_vpu_ipc_open_channel(struct device *dev, u8 node_id,return intel_keembay_ipc_open_channel (vpu_dev->ipc_dev, node_id, chan_id); } -EXPORT_SYMBOL (intel_keembay_vpu_ipc_open_channel); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_ipc_open_channel);/** * intel_keembay_vpu_ipc_close_channel() - Close an IPC channel.
@@ -1487,7 +1487,7 @@ int intel_keembay_vpu_ipc_close_channel(struct device *dev, u8 node_id,return intel_keembay_ipc_close_channel (vpu_dev->ipc_dev, node_id, chan_id); } -EXPORT_SYMBOL (intel_keembay_vpu_ipc_close_channel); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_ipc_close_channel);/** * intel_keembay_vpu_ipc_send() - Send data via IPC.
@@ -1512,7 +1512,7 @@ int intel_keembay_vpu_ipc_send(struct device *dev, u8 node_id, u16 chan_id,return intel_keembay_ipc_send (vpu_dev->ipc_dev, node_id, chan_id, vpu_addr, size); } -EXPORT_SYMBOL (intel_keembay_vpu_ipc_send); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_ipc_send);/** * intel_keembay_vpu_ipc_recv() - Read data via IPC
@@ -1540,7 +1540,7 @@ int intel_keembay_vpu_ipc_recv(struct device *dev, u8 node_id, u16 chan_id,return intel_keembay_ipc_recv (vpu_dev->ipc_dev, node_id, chan_id, vpu_addr, size, timeout); } -EXPORT_SYMBOL (intel_keembay_vpu_ipc_recv); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_ipc_recv);/** * intel_keembay_vpu_startup() - Boot the VPU
@@ -1582,7 +1582,7 @@ int intel_keembay_vpu_startup(struct device *dev, const char *firmware_name)return do_boot_sequence (vpu_dev); } -EXPORT_SYMBOL (intel_keembay_vpu_startup); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_startup);/** * intel_keembay_vpu_reset() - Reset the VPU
@@ -1610,7 +1610,7 @@ int intel_keembay_vpu_reset(struct device *dev)return do_boot_sequence (vpu_dev); } -EXPORT_SYMBOL (intel_keembay_vpu_reset); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_reset);/** * intel_keembay_vpu_stop() - Stop the VPU
@@ -1659,7 +1659,7 @@ int intel_keembay_vpu_stop(struct device *dev)return rc; } -EXPORT_SYMBOL (intel_keembay_vpu_stop); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_stop);/** * intel_keembay_vpu_status() - Get the VPU state.
@@ -1678,7 +1678,7 @@ enum intel_keembay_vpu_state intel_keembay_vpu_status(struct device *dev)return vpu_dev->state; } -EXPORT_SYMBOL (intel_keembay_vpu_status); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_status);/** * intel_keembay_vpu_get_wdt_count() - Get the WDT count
@@ -1709,7 +1709,7 @@ int intel_keembay_vpu_get_wdt_count(struct device *dev, }return rc; } -EXPORT_SYMBOL (intel_keembay_vpu_get_wdt_count); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_get_wdt_count);/** * intel_keembay_vpu_wait_for_ready() - Sleep until VPU is READY
@@ -1754,7 +1754,7 @@ int intel_keembay_vpu_wait_for_ready(struct device *dev, u32 timeout)return rc; } -EXPORT_SYMBOL (intel_keembay_vpu_wait_for_ready); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_wait_for_ready);/** * intel_keembay_vpu_register_for_events() - Register callback for event notification
@@ -1784,7 +1784,7 @@ int intel_keembay_vpu_register_for_events(struct device *dev,return 0 ; } -EXPORT_SYMBOL (intel_keembay_vpu_register_for_events); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_register_for_events);/** * intel_keembay_vpu_unregister_for_events() - Unregister callback for event notification
@@ -1803,7 +1803,7 @@ int intel_keembay_vpu_unregister_for_events(struct device *dev)return 0 ; } -EXPORT_SYMBOL (intel_keembay_vpu_unregister_for_events); +EXPORT_SYMBOL_GPL (intel_keembay_vpu_unregister_for_events);/* Probe() function for the VPU IPC platform driver. */ static int keembay_vpu_ipc_probe (struct platform_device *pdev)
include/linux/xlink_drv_inf.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef _XLINK_DRV_INF_H_#define _XLINK_DRV_INF_H_
PATCH v3 1/34 Add Vision Processing Unit (VPU) documentation.
From: mark gross <[email protected]>
The Intel VPU needs a complicated SW stack to make it work. Add a directory to hold VPU related documentation including an architectural overview of the SW stack that the patches implement.
--- Documentation/index.rst | 1 + Documentation/vpu/index.rst | 16 ++ Documentation/vpu/vpu-stack-overview.rst | 270 +++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst
Documentation/index.rst +1 -0
@@ -137,6 +137,7 @@ needed). misc-devices/index scheduler/index mhi/index + vpu/index Architecture-agnostic documentation -----------------------------------
Documentation/vpu/index.rst new file +16 -0
@@ -0,0 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============================================ +Vision Processor Unit Documentation +============================================ + +This documentation contains information for the Intel VPU stack. + +.. class:: toc-title + + Table of contents + +.. toctree:: + :maxdepth: 2 + + vpu-stack-overview
Documentation/vpu/vpu-stack-overview.rst new file +270 -0
270 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 1/34 Add Vision Processing Unit (VPU) documentation.
In reply to [email protected]From: mark gross <[email protected]>
The Intel VPU needs a complicated SW stack to make it work. Add a directory to hold VPU related documentation including an architectural overview of the SW stack that the patches implement.
--- Documentation/index.rst | 1 + Documentation/vpu/index.rst | 16 ++ Documentation/vpu/vpu-stack-overview.rst | 270 +++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst
Documentation/index.rst +1 -0
@@ -137,6 +137,7 @@ needed). misc-devices/index scheduler/index mhi/index + vpu/index Architecture-agnostic documentation -----------------------------------
Documentation/vpu/index.rst new file +16 -0
@@ -0,0 +1,16 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +============================================ +Vision Processor Unit Documentation +============================================ + +This documentation contains information for the Intel VPU stack. + +.. class:: toc-title + + Table of contents + +.. toctree:: + :maxdepth: 2 + + vpu-stack-overview
Documentation/vpu/vpu-stack-overview.rst new file +270 -0
270 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 2/34 dt-bindings: mailbox: Add Intel VPU IPC mailbox bindings
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add bindings for the Intel VPU IPC mailbox driver.
--- .../mailbox/intel,vpu-ipc-mailbox.yaml | 69 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml
Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/mailbox/intel,vpu-ipc-mailbox.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel VPU IPC mailbox + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: | + Intel VPU SoCs like Keem Bay have hardware FIFOs to enable Inter-Processor + Communication (IPC) between the CPU and the VPU. + + Specifically, there is one HW FIFO for the CPU (aka Application Processor - + AP) and one for the VPU. Each FIFO can hold 128 entries of 32 bits each. A + "FIFO-not-empty" interrupt is raised every time there is at least a message + in the FIFO. The CPU FIFO raises interrupts to the CPU, while the VPU FIFO + raises interrupts to VPU. When the CPU wants to send a message to the VPU it + writes to the VPU FIFO, similarly, when the VPU want to send a message to the + CPU, it writes to the CPU FIFO. + + Refer to ./mailbox.txt for generic information about mailbox device-tree + bindings. + +properties: + compatible: + const: intel,vpu-ipc-mailbox + + reg: + items: + - description: The CPU FIFO registers + - description: The VPU FIFO registers + + reg-names: + items: + - const: cpu_fifo + - const: vpu_fifo + + interrupts: + items: + - description: CPU FIFO-not-empty interrupt + + "#mbox-cells": + const: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + vpu_ipc_mailbox@203300f0 { + compatible = "intel,vpu-ipc-mailbox"; + #mbox-cells = <1>; + reg = <0x203300f0 0x310>, + <0x208200f0 0x310>; + reg-names = "cpu_fifo", "vpu_fifo"; + interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; + };
MAINTAINERS +6 -0
@@ -9181,6 +9181,12 @@ L: [email protected] S: Maintained F: drivers/platform/x86/intel-vbtn.c +INTEL VPU IPC MAILBOX +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml + INTEL WIRELESS 3945ABG/BG, 4965AGN (iwlegacy) M: Stanislaw Gruszka <[email protected]> L: [email protected]
Signature · 1 line
2.17.1
PATCH v3 3/34 mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of tx_done IRQs and a tasklet is used to simulate the tx_done IRQ. The tasklet is activated by send_data() right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes -EBUSY to mbox_chan_txdone(), to notify the mailbox client of the failed TX.
The client should therefore register a tx_done() callback to properly handle failed transmissions.
Note: the 'txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.
--- MAINTAINERS | 1 + drivers/mailbox/Kconfig | 11 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/vpu-ipc-mailbox.c | 297 ++++++++++++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 drivers/mailbox/vpu-ipc-mailbox.c
MAINTAINERS +1 -0
@@ -9186,6 +9186,7 @@ M: Daniele Alessandrelli <[email protected]> M: Mark Gross <[email protected]> S: Supported F: Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml +F: drivers/mailbox/vpu-ipc-mailbox.c INTEL WIRELESS 3945ABG/BG, 4965AGN (iwlegacy) M: Stanislaw Gruszka <[email protected]>
drivers/mailbox/Kconfig +11 -0
@@ -29,6 +29,17 @@ config IMX_MBOX help Mailbox implementation for i.MX Messaging Unit (MU). +config INTEL_VPU_IPC_MBOX + tristate "Intel VPU IPC Mailbox" + depends on HAS_IOMEM + depends on OF || COMPILE_TEST + help + Mailbox implementation for enabling inter-processor communication + between application processors and Intel VPUs. + + Say Y or M here if you are building for an SoC equipped with an Intel + VPU. If M is selected, the module will be called vpu-ipc-mailbox. + config PLATFORM_MHU tristate "Platform MHU Mailbox" depends on OF
drivers/mailbox/Makefile +2 -0
@@ -56,3 +56,5 @@ obj-$(CONFIG_SUN6I_MSGBOX) += sun6i-msgbox.o obj-$(CONFIG_SPRD_MBOX) += sprd-mailbox.o obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o + +obj-$(CONFIG_INTEL_VPU_IPC_MBOX) += vpu-ipc-mailbox.o
drivers/mailbox/vpu-ipc-mailbox.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.17.1
Jassi Brar
maintainerRe: [PATCH v3 03/34] mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
Quoted 36 lines · On Fri, Jan 29, 2021 at 8:21 PM <[email protected]> wrote:
From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of
tx_doneIRQs and a tasklet is used to simulate thetx_doneIRQ. The tasklet is activated bysend_data()right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes-EBUSYtombox_chan_txdone(), to notify the mailbox client of the failed TX.
Quoted 6 lines
The client should therefore register a
tx_done()callback to properly handle failed transmissions.Note: the '
txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.
txdone means the last submitted transfer has been done with -- successfully or not.
So I think we can do without the tasklet as explained below....
....
drivers/mailbox/vpu-ipc-mailbox.c line 162
Quoted 7 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +7
-0+static int vpu_ipc_mailbox_send_data (struct mbox_chan *chan,void *data) +{ +struct vpu_ipc_mbox *vpu_ipc_mbox = chan->con_priv; +u32 entry, overflow; + + entry = *((u32 *)data); +
Are all messages max 32bits wide?
Usually the controller specifies a packet format (more than just a word but of course that's not mandatory) that a client submits the data to be transmitted in. Esp when it has deep FIFOs.
Quoted 21 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +21
-0+/* Ensure last 6-bits of entry are not used. */ +if (unlikely (entry &IPC_FIFO_ENTRY_RSVD_MASK )) { + vpu_ipc_mbox->txdone_result = -EINVAL ; + goto exit; + } + +/* Add processor ID to entry. */ + entry |=IPC_FIFO_ID_CPU &IPC_FIFO_ENTRY_RSVD_MASK ; + +/* Write entry to VPU FIFO. */ +iowrite32 (entry, vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO ); + +/* Check if we overflew the VPU FIFO. */ + overflow =ioread32 (vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ) & +BIT (IPC_FIFO_ID_CPU ); +if (unlikely (overflow)) { +/* Reset overflow register. */ +iowrite32 (BIT (IPC_FIFO_ID_CPU ), + vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ); + vpu_ipc_mbox->txdone_result = -EBUSY ; + goto exit;
drivers/mailbox/vpu-ipc-mailbox.c line 193
Quoted 10 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +10
-0+ } + vpu_ipc_mbox->txdone_result =0 ; + +exit: +/* Schedule tasklet to call mbox_chan_txdone(). */ +tasklet_schedule (&vpu_ipc_mbox->txdone_tasklet); + +return 0 ; +} +
Maybe set txdone_poll and implement last_tx_done() where you can wait for FIFO to have enough space for another message, so that the next submitted request will never return -EBUSY.
thanks
Re: [PATCH v3 03/34] mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
Hi Jassi,
Thank you very much for your feedback.
Quoted 36 lines · Jassi Brar
Quoted 35 lines · On Fri, Jan 29, 2021 at 8:21 PM <[email protected]> wrote:
From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of
tx_doneIRQs and a tasklet is used to simulate thetx_doneIRQ. The tasklet is activated bysend_data()right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes-EBUSYtombox_chan_txdone(), to notify the mailbox client of the failed TX.
Quoted 8 lines
Quoted 6 lines
The client should therefore register a
tx_done()callback to properly handle failed transmissions.Note: the '
txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.txdone means the last submitted transfer has been done with -- successfully or not.
Yes, that's usually the case, but not for poll mode (at least from what I can tell).
last_tx_done() can return only true or false, but when true is returned, there is no way to know if the TX was successful or not; the mailbox framework just seems to assume that 'true' means "message successfully transmitted", since 0 is passed to tx_tick() (end eventually to the tx_done() client callback):
https://github.com/torvalds/linux/blob/master/drivers/mailbox/mailbox.c#L131
If 'false' is returned, the polling continues until the timeout is reached.
(please correct me if my above understanding is wrong)
Quoted 4 lines
So I think we can do without the tasklet as explained below....
....
Quoted 11 lines
drivers/mailbox/vpu-ipc-mailbox.c line 162
Quoted 7 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +7
-0+static int vpu_ipc_mailbox_send_data (struct mbox_chan *chan,void *data) +{ +struct vpu_ipc_mbox *vpu_ipc_mbox = chan->con_priv; +u32 entry, overflow; + + entry = *((u32 *)data); +Are all messages max 32bits wide?
Usually the controller specifies a packet format (more than just a word but of course that's not mandatory) that a client submits the data to be transmitted in. Esp when it has deep FIFOs.
It's actually only 26 bits, since the last 6 bits are reserved for the overflow detection mechanism; I should probably have explained this better in the commit message, sorry!
Basically, the AP is not the only one that can write to the VPU FIFO:
other components within the SoC can write to it too. Each of these components has a unique 6-bit processor ID associated to it. The HW FIFO expects that the last 6 bits of each 32-bit FIFO entry contain the processor ID of the sender.
Sending a message works as follows:
1. The message must be a 32-bit value with the last 6-bit set to 0 (in practice, the message is meant to be a 32-bit address value, aligned to 64 bytes).
2. The sender adds its processor ID to the 32-bit message being sent: M = m | ProcID
3. The sender writes the message (M) to the TIM_IPC_FIFO register
4. The HW atomically checks if the FIFO is full and if not it writes it to the actual FIFO; if the FIFO is full, the HW reads the ProcID from M and then sets the corresponding bit of TIM_IPC_FIFO_OF_FLAG0, to signal that the write failed, because the FIFO was full
5. The sender reads the TIM_IPC_FIFO_OF_FLAG0 register and checks if the bit corresponding to its ProcID has been set (in order to know if the TX succeeded or failed); if the bit is set, the sender clears it.
Note: as briefly mentioned above, the 32-bit value is meant to be a 32- bit physical address (64-byte aligned). This address points to a predefined struct (i.e., the IPC packet) in shared memory. However, since this struct is not HW dependent (it's just the struct the VPU firmware expects and in theory it could change if a different VPU FW is used), I didn't define it here, but in the Keem Bay IPC driver (patch 4 and 5), which is the mailbox client of this controller (does this design seem reasonable to you?)
Quoted 27 lines
Quoted 27 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +26
-0+/* Ensure last 6-bits of entry are not used. */ +if (unlikely (entry &IPC_FIFO_ENTRY_RSVD_MASK )) { + vpu_ipc_mbox->txdone_result = -EINVAL ; + goto exit; + } + +/* Add processor ID to entry. */ + entry |=IPC_FIFO_ID_CPU &IPC_FIFO_ENTRY_RSVD_MASK ; + +/* Write entry to VPU FIFO. */ +iowrite32 (entry, vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO ); + +/* Check if we overflew the VPU FIFO. */ + overflow =ioread32 (vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ) & +BIT (IPC_FIFO_ID_CPU ); +if (unlikely (overflow)) { +/* Reset overflow register. */ +iowrite32 (BIT (IPC_FIFO_ID_CPU ), + vpu_ipc_mbox->vpu_fifo_base +IPC_FIFO_OF_FLAG0 ); + vpu_ipc_mbox->txdone_result = -EBUSY ; + goto exit; + } + vpu_ipc_mbox->txdone_result =0 ; + +exit: +/* Schedule tasklet to call mbox_chan_txdone(). */
Quoted 8 lines
drivers/mailbox/vpu-ipc-mailbox.c line 193
Quoted 5 lines
drivers/mailbox/vpu-ipc-mailbox.c new file +5
-0+tasklet_schedule (&vpu_ipc_mbox->txdone_tasklet); + +return 0 ; +} +Maybe set
txdone_polland implementlast_tx_done()where you can wait for FIFO to have enough space for another message, so that the next submitted request will never return-EBUSY.
I cannot do that because the AP is not the only one writing to the VPU FIFO (sorry again for not mentioning this in the commit message) and therefore, even if at time 't' there is enough space for another message, at time 't+1' (when the driver actually tries to send the message) the FIFO might be full.
I think that in order for me to avoid using the tasklet we might have to change the mailbox framework itself.
For instance, we could modify the last_tx_done() to return 0 on success and negative error code on failure. Then we can agree that if -EAGAIN is returned, the mailbox framework will keep polling, while if the error is something else, the error will be passed to tx_tick() (and eventually to the tx_done callback).
However, for my specific case, the best solution would probably be to modify how send_data() return values are used (so that I can avoid the polling delay). At the moment, my understanding is that when send_data() reutrn -EBUSY, the message is left into the mailbox channel queue (and will be transmitted at a later stage). While I would probably benefit from having an option to return the error to the client, so that it's up to the client to decide if it's worth trying the re-transmission or not.
Anyway, the current tasklet solution works fine with me, so I'm happy to stick with it if that's fine with you.
Quoted 2 lines
thanks
PATCH v4 2/34 dt-bindings: mailbox: Add Intel VPU IPC mailbox bindings
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add bindings for the Intel VPU IPC mailbox driver.
--- .../mailbox/intel,vpu-ipc-mailbox.yaml | 69 +++++++++++++++++++ MAINTAINERS | 6 ++ 2 files changed, 75 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml
Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml new file +69 -0
@@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (c) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/mailbox/intel,vpu-ipc-mailbox.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel VPU IPC mailbox + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: | + Intel VPU SoCs like Keem Bay have hardware FIFOs to enable Inter-Processor + Communication (IPC) between the CPU and the VPU. + + Specifically, there is one HW FIFO for the CPU (aka Application Processor - + AP) and one for the VPU. Each FIFO can hold 128 entries of 32 bits each. A + "FIFO-not-empty" interrupt is raised every time there is at least a message + in the FIFO. The CPU FIFO raises interrupts to the CPU, while the VPU FIFO + raises interrupts to VPU. When the CPU wants to send a message to the VPU it + writes to the VPU FIFO, similarly, when the VPU want to send a message to the + CPU, it writes to the CPU FIFO. + + Refer to ./mailbox.txt for generic information about mailbox device-tree + bindings. + +properties: + compatible: + const: intel,vpu-ipc-mailbox + + reg: + items: + - description: The CPU FIFO registers + - description: The VPU FIFO registers + + reg-names: + items: + - const: cpu_fifo + - const: vpu_fifo + + interrupts: + items: + - description: CPU FIFO-not-empty interrupt + + "#mbox-cells": + const: 1 + +required: + - compatible + - reg + - reg-names + - interrupts + - "#mbox-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/interrupt-controller/arm-gic.h> + vpu_ipc_mailbox@203300f0 { + compatible = "intel,vpu-ipc-mailbox"; + #mbox-cells = <1>; + reg = <0x203300f0 0x310>, + <0x208200f0 0x310>; + reg-names = "cpu_fifo", "vpu_fifo"; + interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>; + };
MAINTAINERS +6 -0
@@ -9181,6 +9181,12 @@ L: [email protected] S: Maintained F: drivers/platform/x86/intel-vbtn.c +INTEL VPU IPC MAILBOX +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml + INTEL WIRELESS 3945ABG/BG, 4965AGN (iwlegacy) M: Stanislaw Gruszka <[email protected]> L: [email protected]
Signature · 1 line
2.17.1
PATCH v3 4/34 dt-bindings: Add bindings for Keem Bay IPC driver
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
--- .../bindings/soc/intel/intel,keembay-ipc.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +45 -0
@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Keem Bay IPC + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay. + +properties: + compatible: + const: intel,keembay-ipc + + memory-region: + items: + - description: + Reserved memory region used by the CPU to allocate IPC packets. + - description: + Reserved memory region used by the VPU to allocate IPC packets. + + mboxes: + description: VPU IPC Mailbox. + +required: + - compatible + - memory-region + - mboxes + +additionalProperties: false + +examples: + - | + ipc { + compatible = "intel,keembay-ipc"; + memory-region = <&ipc_cpu_reserved>, <&ipc_vpu_reserved>; + mboxes = <&vpu_ipc_mbox 0>; + };
Signature · 1 line
2.17.1
PATCH v4 3/34 mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add mailbox controller enabling inter-processor communication (IPC) between the CPU (aka, the Application Processor - AP) and the VPU on Intel Movidius SoCs like Keem Bay.
The controller uses HW FIFOs to enable such communication. Specifically, there are two FIFOs, one for the CPU and one for VPU. Each FIFO can hold 128 entries (messages) of 32-bit each (but only 26 bits are actually usable, since the 6 least-significant bits are reserved).
When the Linux kernel on the AP needs to send messages to the VPU firmware, it writes them to the VPU FIFO; similarly, when the VPU firmware needs to send messages to the AP, it writes them to the CPU FIFO.
The AP is notified of pending messages in the CPU FIFO by means of the 'FIFO-not-empty' interrupt, which is generated by the CPU FIFO while not empty. This interrupt is cleared automatically once all messages have been read from the FIFO (i.e., the FIFO has been emptied).
The hardware doesn't provide an TX done IRQ (i.e., an IRQ that allows the VPU firmware to notify the AP that the message put into the VPU FIFO has been received); however the AP can ensure that the message has been successfully put into the VPU FIFO (and therefore transmitted) by checking the VPU FIFO status register to ensure that writing the message didn't cause the FIFO to overflow.
Therefore, the mailbox controller is configured as capable of tx_done IRQs and a tasklet is used to simulate the tx_done IRQ. The tasklet is activated by send_data() right after the message has been put into the VPU FIFO and the VPU FIFO status registers has been checked. If an overflow is reported by the status register, the tasklet passes -EBUSY to mbox_chan_txdone(), to notify the mailbox client of the failed TX.
The client should therefore register a tx_done() callback to properly handle failed transmissions.
Note: the 'txdone_poll' mechanism cannot be used because it doesn't provide a way to report a failed transmission.
--- MAINTAINERS | 1 + drivers/mailbox/Kconfig | 11 ++ drivers/mailbox/Makefile | 2 + drivers/mailbox/vpu-ipc-mailbox.c | 297 ++++++++++++++++++++++++++++++ 4 files changed, 311 insertions(+) create mode 100644 drivers/mailbox/vpu-ipc-mailbox.c
MAINTAINERS +1 -0
@@ -9186,6 +9186,7 @@ M: Daniele Alessandrelli <[email protected]> M: Mark Gross <[email protected]> S: Supported F: Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml +F: drivers/mailbox/vpu-ipc-mailbox.c INTEL WIRELESS 3945ABG/BG, 4965AGN (iwlegacy) M: Stanislaw Gruszka <[email protected]>
drivers/mailbox/Kconfig +11 -0
@@ -29,6 +29,17 @@ config IMX_MBOX help Mailbox implementation for i.MX Messaging Unit (MU). +config INTEL_VPU_IPC_MBOX + tristate "Intel VPU IPC Mailbox" + depends on HAS_IOMEM + depends on OF || COMPILE_TEST + help + Mailbox implementation for enabling inter-processor communication + between application processors and Intel VPUs. + + Say Y or M here if you are building for an SoC equipped with an Intel + VPU. If M is selected, the module will be called vpu-ipc-mailbox. + config PLATFORM_MHU tristate "Platform MHU Mailbox" depends on OF
drivers/mailbox/Makefile +2 -0
@@ -56,3 +56,5 @@ obj-$(CONFIG_SUN6I_MSGBOX) += sun6i-msgbox.o obj-$(CONFIG_SPRD_MBOX) += sprd-mailbox.o obj-$(CONFIG_QCOM_IPCC) += qcom-ipcc.o + +obj-$(CONFIG_INTEL_VPU_IPC_MBOX) += vpu-ipc-mailbox.o
drivers/mailbox/vpu-ipc-mailbox.c new file +297 -0
297 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 4/34 dt-bindings: Add bindings for Keem Bay IPC driver
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
Add DT binding documentation for the Intel Keem Bay IPC driver, which enables communication between the Computing Sub-System (CSS) and the Multimedia Sub-System (MSS) of the Intel Movidius SoC code named Keem Bay.
--- .../bindings/soc/intel/intel,keembay-ipc.yaml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml new file +45 -0
@@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright (C) 2020 Intel Corporation +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Keem Bay IPC + +maintainers: + - Daniele Alessandrelli <[email protected]> + +description: + The Keem Bay IPC driver enables Inter-Processor Communication (IPC) with the + Visual Processor Unit (VPU) embedded in the Intel Movidius SoC code named + Keem Bay. + +properties: + compatible: + const: intel,keembay-ipc + + memory-region: + items: + - description: + Reserved memory region used by the CPU to allocate IPC packets. + - description: + Reserved memory region used by the VPU to allocate IPC packets. + + mboxes: + description: VPU IPC Mailbox. + +required: + - compatible + - memory-region + - mboxes + +additionalProperties: false + +examples: + - | + ipc { + compatible = "intel,keembay-ipc"; + memory-region = <&ipc_cpu_reserved>, <&ipc_vpu_reserved>; + mboxes = <&vpu_ipc_mbox 0>; + };
Signature · 1 line
2.17.1
PATCH v4 5/34 keembay-ipc: Add Keem Bay IPC module
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Application Processor(AP) and the VPU is enabled by the Keem Bay Inter-Processor
Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
The IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate
(currently, we just have two nodes, the AP and the VPU).
- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one formed by the AP and the VPU).
- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
The Keem Bay IPC mechanism is built on top of the VPU IPC mailbox, which allows the AP and the VPU to exchange 32-bit messages. Specifically, the IPC uses shared memory (shared between the AP and the VPU) to allocate IPC packets and then exchanges them using the VPU IPC mailbox (the 32-bit physical address of the packet is passed as a message to the VPU IPC mailbox).
IPC packets have a fixed structure containing the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Each IPC node (i.e., both the AP and the VPU) has its own reserved memory region (in shared memory) from which it instantiates its own pool of IPC packets. When instantiated, IPC packets are marked as free. When the node needs to send an IPC message, it gets the first free packet it finds (from its own pool), marks it as allocated (used), and transfer its physical address to the destination node using the VPU IPC mailbox. The destination node uses the received physical address to access the IPC packet, process the packet, and, once done with it, marks it as free (so that the sender can reuse it).
--- MAINTAINERS | 8 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 18 + drivers/soc/intel/Makefile | 4 + drivers/soc/intel/keembay-ipc.c | 1364 +++++++++++++++++++++++++ include/linux/soc/intel/keembay-ipc.h | 30 + 7 files changed, 1426 insertions(+) create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 include/linux/soc/intel/keembay-ipc.h
MAINTAINERS +8 -0
@@ -9060,6 +9060,14 @@ F: drivers/crypto/keembay/keembay-ocs-aes-core.c F: drivers/crypto/keembay/ocs-aes.c F: drivers/crypto/keembay/ocs-aes.h +INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/Kconfig +1 -0
@@ -8,6 +8,7 @@ source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/imx/Kconfig" +source "drivers/soc/intel/Kconfig" source "drivers/soc/ixp4xx/Kconfig" source "drivers/soc/litex/Kconfig" source "drivers/soc/mediatek/Kconfig"
drivers/soc/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/ obj-y += fsl/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ obj-y += imx/ +obj-y += intel/ obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-$(CONFIG_LITEX_SOC_CONTROLLER) += litex/
drivers/soc/intel/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Keem Bay SoC drivers +# + +menu "Intel SoC drivers" + +config KEEMBAY_IPC + tristate "Support for Intel Keem Bay IPC" + depends on INTEL_VPU_IPC_MBOX + depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST) + help + Keem Bay IPC enables communication between the Keem Bay CPU + Sub-System (CSS) and the Keem Bay Media Sub-System (MSS). + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. +endmenu
drivers/soc/intel/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for Keem Bay IPC Linux driver +# +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o
drivers/soc/intel/keembay-ipc.c new file +1364 -0
1,364 lines not on this page · raw message
include/linux/soc/intel/keembay-ipc.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Keem Bay IPC Linux Kernel API +* +* Copyright (C) 2018-2020 Intel Corporation +*/ + +#ifndef __KEEMBAY_IPC_H +#define __KEEMBAY_IPC_H + +#include <linux/types.h> + +/* The possible node IDs. */ +enum { +KMB_IPC_NODE_CPU =0 , +KMB_IPC_NODE_LEON_MSS , +}; + +int intel_keembay_ipc_open_channel (struct device *dev,u8 node_id,u16 chan_id); + +int intel_keembay_ipc_close_channel (struct device *dev,u8 node_id, +u16 chan_id); + +int intel_keembay_ipc_send (struct device *dev,u8 node_id,u16 chan_id, +u32 vpu_addr,size_t size); + +int intel_keembay_ipc_recv (struct device *dev,u8 node_id,u16 chan_id, +u32 *vpu_addr,size_t *size,u32 timeout); + +#endif /* __KEEMBAY_IPC_H */
Signature · 1 line
2.17.1
PATCH v3 5/34 keembay-ipc: Add Keem Bay IPC module
In reply to [email protected]From: Daniele Alessandrelli <[email protected]>
On the Intel Movidius SoC code named Keem Bay, communication between the Application Processor(AP) and the VPU is enabled by the Keem Bay Inter-Processor
Communication (IPC) mechanism.
Add the driver for using Keem Bay IPC from within the Linux Kernel.
The IPC uses the following terminology:
- Node: A processing entity that can use the IPC to communicate
(currently, we just have two nodes, the AP and the VPU).
- Link: Two nodes that can communicate over IPC form an IPC link
(currently, we just have one link, the one formed by the AP and the VPU).
- Channel: An IPC link can provide multiple IPC channels. IPC channels allow communication multiplexing, i.e., the same IPC link can be used by different applications for different communications. Each channel is identified by a channel ID, which must be unique within a single IPC link. Channels are divided in two categories, High-Speed (HS) channels and General-Purpose (GP) channels. HS channels have higher priority over GP channels.
The Keem Bay IPC mechanism is built on top of the VPU IPC mailbox, which allows the AP and the VPU to exchange 32-bit messages. Specifically, the IPC uses shared memory (shared between the AP and the VPU) to allocate IPC packets and then exchanges them using the VPU IPC mailbox (the 32-bit physical address of the packet is passed as a message to the VPU IPC mailbox).
IPC packets have a fixed structure containing the (VPU) physical address of the payload (which must be located in shared memory too) as well as other information (payload size, IPC channel ID, etc.).
Each IPC node (i.e., both the AP and the VPU) has its own reserved memory region (in shared memory) from which it instantiates its own pool of IPC packets. When instantiated, IPC packets are marked as free. When the node needs to send an IPC message, it gets the first free packet it finds (from its own pool), marks it as allocated (used), and transfer its physical address to the destination node using the VPU IPC mailbox. The destination node uses the received physical address to access the IPC packet, process the packet, and, once done with it, marks it as free (so that the sender can reuse it).
--- MAINTAINERS | 8 + drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 18 + drivers/soc/intel/Makefile | 4 + drivers/soc/intel/keembay-ipc.c | 1364 +++++++++++++++++++++++++ include/linux/soc/intel/keembay-ipc.h | 30 + 7 files changed, 1426 insertions(+) create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 include/linux/soc/intel/keembay-ipc.h
MAINTAINERS +8 -0
@@ -9060,6 +9060,14 @@ F: drivers/crypto/keembay/keembay-ocs-aes-core.c F: drivers/crypto/keembay/ocs-aes.c F: drivers/crypto/keembay/ocs-aes.h +INTEL KEEM BAY IPC DRIVER +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml +F: drivers/soc/intel/keembay-ipc.c +F: include/linux/soc/intel/keembay-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/Kconfig +1 -0
@@ -8,6 +8,7 @@ source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/imx/Kconfig" +source "drivers/soc/intel/Kconfig" source "drivers/soc/ixp4xx/Kconfig" source "drivers/soc/litex/Kconfig" source "drivers/soc/mediatek/Kconfig"
drivers/soc/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_MACH_DOVE) += dove/ obj-y += fsl/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ obj-y += imx/ +obj-y += intel/ obj-$(CONFIG_ARCH_IXP4XX) += ixp4xx/ obj-$(CONFIG_SOC_XWAY) += lantiq/ obj-$(CONFIG_LITEX_SOC_CONTROLLER) += litex/
drivers/soc/intel/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Keem Bay SoC drivers +# + +menu "Intel SoC drivers" + +config KEEMBAY_IPC + tristate "Support for Intel Keem Bay IPC" + depends on INTEL_VPU_IPC_MBOX + depends on ARCH_KEEMBAY || (ARM64 && COMPILE_TEST) + help + Keem Bay IPC enables communication between the Keem Bay CPU + Sub-System (CSS) and the Keem Bay Media Sub-System (MSS). + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. +endmenu
drivers/soc/intel/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for Keem Bay IPC Linux driver +# +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o
drivers/soc/intel/keembay-ipc.c new file +1364 -0
1,364 lines not on this page · raw message
include/linux/soc/intel/keembay-ipc.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Keem Bay IPC Linux Kernel API +* +* Copyright (C) 2018-2020 Intel Corporation +*/ + +#ifndef __KEEMBAY_IPC_H +#define __KEEMBAY_IPC_H + +#include <linux/types.h> + +/* The possible node IDs. */ +enum { +KMB_IPC_NODE_CPU =0 , +KMB_IPC_NODE_LEON_MSS , +}; + +int intel_keembay_ipc_open_channel (struct device *dev,u8 node_id,u16 chan_id); + +int intel_keembay_ipc_close_channel (struct device *dev,u8 node_id, +u16 chan_id); + +int intel_keembay_ipc_send (struct device *dev,u8 node_id,u16 chan_id, +u32 vpu_addr,size_t size); + +int intel_keembay_ipc_recv (struct device *dev,u8 node_id,u16 chan_id, +u32 *vpu_addr,size_t *size,u32 timeout); + +#endif /* __KEEMBAY_IPC_H */
Signature · 1 line
2.17.1
PATCH v4 6/34 dt-bindings: Add bindings for Keem Bay VPU IPC driver
In reply to [email protected]From: Paul Murphy <[email protected]>
Add DT bindings documentation for the Keem Bay VPU IPC driver.
--- .../soc/intel/intel,keembay-vpu-ipc.yaml | 143 ++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml new file +143 -0
@@ -0,0 +1,143 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-vpu-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay VPU IPC + +maintainers: + - Paul Murphy <[email protected]> + - Daniele Alessandrelli <[email protected]> + +description: + This binding provides support for the Vision Processing Unit (VPU) found on + the Intel Keem Bay SoC. + + The VPU is started and controlled by SoC CPU, which is in charge of loading + the VPU firmware. The SoC CPU can communicate with the VPU firmware using an + Inter-Processor Communication (IPC) mechanism. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-vpu-ipc + + reg: + items: + - description: NCE WDT registers + - description: NCE TIM_GEN_CONFIG registers + - description: MSS WDT registers + - description: MSS TIM_GEN_CONFIG registers + + reg-names: + items: + - const: nce_wdt + - const: nce_tim_cfg + - const: mss_wdt + - const: mss_tim_cfg + + memory-region: + items: + - description: reference to the VPU reserved memory region + - description: reference to the X509 reserved memory region + - description: reference to the MSS IPC area + + clocks: + items: + - description: cpu clock + - description: pll 0 out 0 rate + - description: pll 0 out 1 rate + - description: pll 0 out 2 rate + - description: pll 0 out 3 rate + - description: pll 1 out 0 rate + - description: pll 1 out 1 rate + - description: pll 1 out 2 rate + - description: pll 1 out 3 rate + - description: pll 2 out 0 rate + - description: pll 2 out 1 rate + - description: pll 2 out 2 rate + - description: pll 2 out 3 rate + + clock-names: + items: + - const: cpu_clock + - const: pll_0_out_0 + - const: pll_0_out_1 + - const: pll_0_out_2 + - const: pll_0_out_3 + - const: pll_1_out_0 + - const: pll_1_out_1 + - const: pll_1_out_2 + - const: pll_1_out_3 + - const: pll_2_out_0 + - const: pll_2_out_1 + - const: pll_2_out_2 + - const: pll_2_out_3 + + interrupts: + items: + - description: number of NCE sub-system WDT timeout IRQ + - description: number of MSS sub-system WDT timeout IRQ + + interrupt-names: + items: + - const: nce_wdt + - const: mss_wdt + + intel,keembay-vpu-ipc-imr: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + Isolated Memory Region (IMR) number that the runtime service must use to + protect the VPU memory region before authentication. + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The VPU ID to be passed to the VPU firmware. + +additionalProperties: False + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + vpu-ipc@3f00209c { + compatible = "intel,keembay-vpu-ipc"; + reg = <0x3f00209c 0x10>, + <0x3f003008 0x4>, + <0x2082009c 0x10>, + <0x20821008 0x4>; + reg-names = "nce_wdt", + "nce_tim_cfg", + "mss_wdt", + "mss_tim_cfg"; + memory-region = <&vpu_reserved>, + <&vpu_x509_reserved>, + <&mss_ipc_reserved>; + clocks = <&scmi_clk 0>, + <&scmi_clk 0>, + <&scmi_clk 1>, + <&scmi_clk 2>, + <&scmi_clk 3>, + <&scmi_clk 4>, + <&scmi_clk 5>, + <&scmi_clk 6>, + <&scmi_clk 7>, + <&scmi_clk 8>, + <&scmi_clk 9>, + <&scmi_clk 10>, + <&scmi_clk 11>; + clock-names = "cpu_clock", + "pll_0_out_0", "pll_0_out_1", + "pll_0_out_2", "pll_0_out_3", + "pll_1_out_0", "pll_1_out_1", + "pll_1_out_2", "pll_1_out_3", + "pll_2_out_0", "pll_2_out_1", + "pll_2_out_2", "pll_2_out_3"; + interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "nce_wdt", "mss_wdt"; + intel,keembay-vpu-ipc-imr = <9>; + intel,keembay-vpu-ipc-id = <0>; + };
Signature · 1 line
2.17.1
PATCH v4 7/34 keembay-vpu-ipc: Add Keem Bay VPU IPC module
In reply to [email protected]From: Paul Murphy <[email protected]>
Intel Keem Bay SoC contains a Vision Processing Unit (VPU) to enable machine vision and other applications.
Enable Linux to control the VPU processor and provides an interface to the Keem Bay IPC for communicating with the VPU firmware.
Specifically the driver provides the following functionality to other kernel components:
- Starting (including loading the VPU firmware) / Stopping / Rebooting
the VPU.
- Getting notifications of VPU events (e.g., WDT events).
- Communicating with the VPU via the Keem Bay IPC mechanism.
In addition to the above, the driver also exposes SoC information (like stepping, device ID, etc.) to user-space via sysfs. Specifically, the following sysfs files are provided:
- /sys/firmware/keembay-vpu-ipc/device_id
- /sys/firmware/keembay-vpu-ipc/feature_exclusion
- /sys/firmware/keembay-vpu-ipc/hardware_id
- /sys/firmware/keembay-vpu-ipc/sku
- /sys/firmware/keembay-vpu-ipc/stepping
--- MAINTAINERS | 9 + drivers/soc/intel/Kconfig | 15 + drivers/soc/intel/Makefile | 3 +- drivers/soc/intel/keembay-vpu-ipc.c | 2026 +++++++++++++++++++++ include/linux/soc/intel/keembay-vpu-ipc.h | 62 + 5 files changed, 2114 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h
MAINTAINERS +9 -0
@@ -9068,6 +9068,15 @@ F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml F: drivers/soc/intel/keembay-ipc.c F: include/linux/soc/intel/keembay-ipc.h +INTEL KEEM BAY VPU IPC DRIVER +M: Paul J Murphy <[email protected]> +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml +F: drivers/soc/intel/keembay-vpu-ipc.c +F: include/linux/soc/intel/keembay-vpu-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/intel/Kconfig +15 -0
@@ -15,4 +15,19 @@ config KEEMBAY_IPC Select this if you are compiling the Kernel for an Intel SoC that includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + +config KEEMBAY_VPU_IPC + tristate "Intel Keem Bay VPU IPC Driver" + depends on KEEMBAY_IPC + depends on HAVE_ARM_SMCCC + help + This option enables support for loading and communicating with + the firmware on the Vision Processing Unit (VPU) of the Keem Bay + SoC. The driver depends on the Keem Bay IPC driver to do + communication, and it depends on secure world monitor software to + do the control of the VPU state. + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + endmenu
drivers/soc/intel/Makefile +2 -1
@@ -1,4 +1,5 @@ # # Makefile for Keem Bay IPC Linux driver # -obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_VPU_IPC) += keembay-vpu-ipc.o
drivers/soc/intel/keembay-vpu-ipc.c new file +2026 -0
2,026 lines not on this page · raw message
include/linux/soc/intel/keembay-vpu-ipc.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 6/34 dt-bindings: Add bindings for Keem Bay VPU IPC driver
In reply to [email protected]From: Paul Murphy <[email protected]>
Add DT bindings documentation for the Keem Bay VPU IPC driver.
--- .../soc/intel/intel,keembay-vpu-ipc.yaml | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml
Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml new file +153 -0
@@ -0,0 +1,153 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/soc/intel/intel,keembay-vpu-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay VPU IPC + +maintainers: + - Paul Murphy <[email protected]> + +description: + The VPU IPC driver facilitates loading of firmware, control, and communication + with the VPU over the IPC FIFO in the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-vpu-ipc + + reg: + items: + - description: NCE WDT registers + - description: NCE TIM_GEN_CONFIG registers + - description: MSS WDT registers + - description: MSS TIM_GEN_CONFIG registers + + reg-names: + items: + - const: nce_wdt + - const: nce_tim_cfg + - const: mss_wdt + - const: mss_tim_cfg + + memory-region: + items: + - description: reference to the VPU reserved memory region + - description: reference to the X509 reserved memory region + - description: reference to the MSS IPC area + + clocks: + items: + - description: cpu clock + - description: pll 0 out 0 rate + - description: pll 0 out 1 rate + - description: pll 0 out 2 rate + - description: pll 0 out 3 rate + - description: pll 1 out 0 rate + - description: pll 1 out 1 rate + - description: pll 1 out 2 rate + - description: pll 1 out 3 rate + - description: pll 2 out 0 rate + - description: pll 2 out 1 rate + - description: pll 2 out 2 rate + - description: pll 2 out 3 rate + + clock-names: + items: + - const: cpu_clock + - const: pll_0_out_0 + - const: pll_0_out_1 + - const: pll_0_out_2 + - const: pll_0_out_3 + - const: pll_1_out_0 + - const: pll_1_out_1 + - const: pll_1_out_2 + - const: pll_1_out_3 + - const: pll_2_out_0 + - const: pll_2_out_1 + - const: pll_2_out_2 + - const: pll_2_out_3 + + interrupts: + items: + - description: number of NCE sub-system WDT timeout IRQ + - description: number of MSS sub-system WDT timeout IRQ + + interrupt-names: + items: + - const: nce_wdt + - const: mss_wdt + + intel,keembay-vpu-ipc-nce-wdt-redirect: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + Number to which we will request that the NCE sub-system + re-directs it's WDT timeout IRQ + + intel,keembay-vpu-ipc-mss-wdt-redirect: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + Number to which we will request that the MSS sub-system + re-directs it's WDT timeout IRQ + + intel,keembay-vpu-ipc-imr: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: + IMR (isolated memory region) number which we will request + the runtime service uses to protect the VPU memory region + before authentication + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The VPU ID to be passed to the VPU firmware. + +additionalProperties: False + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + vpu-ipc@3f00209c { + compatible = "intel,keembay-vpu-ipc"; + reg = <0x3f00209c 0x10>, + <0x3f003008 0x4>, + <0x2082009c 0x10>, + <0x20821008 0x4>; + reg-names = "nce_wdt", + "nce_tim_cfg", + "mss_wdt", + "mss_tim_cfg"; + memory-region = <&vpu_reserved>, + <&vpu_x509_reserved>, + <&mss_ipc_reserved>; + clocks = <&scmi_clk 0>, + <&scmi_clk 0>, + <&scmi_clk 1>, + <&scmi_clk 2>, + <&scmi_clk 3>, + <&scmi_clk 4>, + <&scmi_clk 5>, + <&scmi_clk 6>, + <&scmi_clk 7>, + <&scmi_clk 8>, + <&scmi_clk 9>, + <&scmi_clk 10>, + <&scmi_clk 11>; + clock-names = "cpu_clock", + "pll_0_out_0", "pll_0_out_1", + "pll_0_out_2", "pll_0_out_3", + "pll_1_out_0", "pll_1_out_1", + "pll_1_out_2", "pll_1_out_3", + "pll_2_out_0", "pll_2_out_1", + "pll_2_out_2", "pll_2_out_3"; + interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "nce_wdt", "mss_wdt"; + intel,keembay-vpu-ipc-nce-wdt-redirect = <63>; + intel,keembay-vpu-ipc-mss-wdt-redirect = <47>; + intel,keembay-vpu-ipc-imr = <9>; + intel,keembay-vpu-ipc-id = <0>; + };
Signature · 1 line
2.17.1
PATCH v3 7/34 keembay-vpu-ipc: Add Keem Bay VPU IPC module
In reply to [email protected]From: Paul Murphy <[email protected]>
Intel Keem Bay SoC contains a Vision Processing Unit (VPU) to enable machine vision and other applications.
Enable Linux to control the VPU processor and provides an interface to the Keem Bay IPC for communicating with the VPU firmware.
Specifically the driver provides the following functionality to other kernel components:
- Starting (including loading the VPU firmware) / Stopping / Rebooting
the VPU.
- Getting notifications of VPU events (e.g., WDT events).
- Communicating with the VPU via the Keem Bay IPC mechanism.
In addition to the above, the driver also exposes SoC information (like stepping, device ID, etc.) to user-space via sysfs. Specifically, the following sysfs files are provided:
- /sys/firmware/keembay-vpu-ipc/device_id
- /sys/firmware/keembay-vpu-ipc/feature_exclusion
- /sys/firmware/keembay-vpu-ipc/hardware_id
- /sys/firmware/keembay-vpu-ipc/sku
- /sys/firmware/keembay-vpu-ipc/stepping
--- MAINTAINERS | 9 + drivers/soc/intel/Kconfig | 15 + drivers/soc/intel/Makefile | 3 +- drivers/soc/intel/keembay-vpu-ipc.c | 2036 +++++++++++++++++++++ include/linux/soc/intel/keembay-vpu-ipc.h | 62 + 5 files changed, 2124 insertions(+), 1 deletion(-) create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h
MAINTAINERS +9 -0
@@ -9068,6 +9068,15 @@ F: Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml F: drivers/soc/intel/keembay-ipc.c F: include/linux/soc/intel/keembay-ipc.h +INTEL KEEM BAY VPU IPC DRIVER +M: Paul J Murphy <[email protected]> +M: Daniele Alessandrelli <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml +F: drivers/soc/intel/keembay-vpu-ipc.c +F: include/linux/soc/intel/keembay-vpu-ipc.h + INTEL MANAGEMENT ENGINE (mei) M: Tomas Winkler <[email protected]> L: [email protected]
drivers/soc/intel/Kconfig +15 -0
@@ -15,4 +15,19 @@ config KEEMBAY_IPC Select this if you are compiling the Kernel for an Intel SoC that includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + +config KEEMBAY_VPU_IPC + tristate "Intel Keem Bay VPU IPC Driver" + depends on KEEMBAY_IPC + depends on HAVE_ARM_SMCCC + help + This option enables support for loading and communicating with + the firmware on the Vision Processing Unit (VPU) of the Keem Bay + SoC. The driver depends on the Keem Bay IPC driver to do + communication, and it depends on secure world monitor software to + do the control of the VPU state. + + Select this if you are compiling the Kernel for an Intel SoC that + includes the Intel Vision Processing Unit (VPU) such as Keem Bay. + endmenu
drivers/soc/intel/Makefile +2 -1
@@ -1,4 +1,5 @@ # # Makefile for Keem Bay IPC Linux driver # -obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_IPC) += keembay-ipc.o +obj-$(CONFIG_KEEMBAY_VPU_IPC) += keembay-vpu-ipc.o
drivers/soc/intel/keembay-vpu-ipc.c new file +2036 -0
2,036 lines not on this page · raw message
include/linux/soc/intel/keembay-vpu-ipc.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 8/34 misc: xlink-pcie: Add documentation for XLink PCIe driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide overview of XLink PCIe driver implementation
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-pcie.rst | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Documentation/vpu/xlink-pcie.rst
Documentation/vpu/index.rst +1 -0
@@ -14,3 +14,4 @@ This documentation contains information for the Intel VPU stack. :maxdepth: 2 vpu-stack-overview + xlink-pcie
Documentation/vpu/xlink-pcie.rst new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 8/34 misc: xlink-pcie: Add documentation for XLink PCIe driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide overview of XLink PCIe driver implementation
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-pcie.rst | 90 ++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 Documentation/vpu/xlink-pcie.rst
Documentation/vpu/index.rst +1 -0
@@ -14,3 +14,4 @@ This documentation contains information for the Intel VPU stack. :maxdepth: 2 vpu-stack-overview + xlink-pcie
Documentation/vpu/xlink-pcie.rst new file +90 -0
90 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 9/34 misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe EPF driver for local host (lh) to configure BAR's and other HW resources. Underlying PCIe HW controller is a Synopsys DWC PCIe core.
--- MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-pcie/Kconfig | 9 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/epf.c | 373 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.h | 37 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 38 ++ 9 files changed, 468 insertions(+) create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/local_host/xpcie.h
MAINTAINERS +6 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM KEEM BAY XLINK PCIE SUPPORT +M: Srikanth Thokala <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-pcie/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -481,4 +481,5 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" +source "drivers/misc/xlink-pcie/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-y += xlink-pcie/
drivers/misc/xlink-pcie/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config XLINK_PCIE_LH_DRIVER + tristate "XLink PCIe Local Host driver" + depends on PCI_ENDPOINT && ARCH_KEEMBAY + help + This option enables XLink PCIe Local Host driver. + + Choose M here to compile this driver as a module, name is mxlk_ep. + This driver is used for XLink communication over PCIe and is to be + loaded on the Intel Keem Bay platform.
drivers/misc/xlink-pcie/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/local_host/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o +mxlk_ep-objs := epf.o
drivers/misc/xlink-pcie/local_host/epf.c new file +373 -0
373 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2021 Intel Corporation +*/ + +#ifndef XPCIE_EPF_HEADER_ +#define XPCIE_EPF_HEADER_ + +#include <linux/pci-epc.h> +#include <linux/pci-epf.h> + +#include "xpcie.h" + +#define XPCIE_DRIVER_NAME "mxlk_pcie_epf" +#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver" + +#define KEEMBAY_XPCIE_STEPPING_MAXLEN 8 + +struct xpcie_epf { +struct pci_epf *epf; +void *vaddr[BAR_5 +1 ]; +enum pci_barno comm_bar; +enum pci_barno bar4; +const struct pci_epc_features *epc_features; +struct xpcie xpcie; +int irq; +int irq_dma; +int irq_err; +void __iomem *apb_base; +void __iomem *dma_base; +void __iomem *dbi_base; +char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +}; + +#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/xpcie.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/***************************************************************************** +* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +****************************************************************************/ + +#ifndef XPCIE_HEADER_ +#define XPCIE_HEADER_ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pci_ids.h> + +#ifndef PCI_DEVICE_ID_INTEL_KEEMBAY +#define PCI_DEVICE_ID_INTEL_KEEMBAY 0x6240 +#endif + +#define XPCIE_IO_COMM_SIZE SZ_16K +#define XPCIE_MMIO_OFFSET SZ_4K + +/* MMIO layout and offsets shared between device and host */ +struct xpcie_mmio { +u8 legacy_a0; +} __packed; + +#define XPCIE_MMIO_LEGACY_A0 (offsetof(struct xpcie_mmio, legacy_a0)) + +struct xpcie { +u32 status; +bool legacy_a0; +void *mmio; +void *bar4; +}; + +#endif /* XPCIE_HEADER_ */
Signature · 1 line
2.17.1
PATCH v3 9/34 misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe EPF driver for local host (lh) to configure BAR's and other HW resources. Underlying PCIe HW controller is a Synopsys DWC PCIe core.
--- MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-pcie/Kconfig | 9 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/epf.c | 373 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.h | 37 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 38 ++ 9 files changed, 468 insertions(+) create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/local_host/xpcie.h
MAINTAINERS +6 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM KEEM BAY XLINK PCIE SUPPORT +M: Srikanth Thokala <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-pcie/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -481,4 +481,5 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" +source "drivers/misc/xlink-pcie/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-y += xlink-pcie/
drivers/misc/xlink-pcie/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config XLINK_PCIE_LH_DRIVER + tristate "XLink PCIe Local Host driver" + depends on PCI_ENDPOINT && ARCH_KEEMBAY + help + This option enables XLink PCIe Local Host driver. + + Choose M here to compile this driver as a module, name is mxlk_ep. + This driver is used for XLink communication over PCIe and is to be + loaded on the Intel Keem Bay platform.
drivers/misc/xlink-pcie/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/local_host/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o +mxlk_ep-objs := epf.o
drivers/misc/xlink-pcie/local_host/epf.c new file +373 -0
373 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2021 Intel Corporation +*/ + +#ifndef XPCIE_EPF_HEADER_ +#define XPCIE_EPF_HEADER_ + +#include <linux/pci-epc.h> +#include <linux/pci-epf.h> + +#include "xpcie.h" + +#define XPCIE_DRIVER_NAME "mxlk_pcie_epf" +#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver" + +#define KEEMBAY_XPCIE_STEPPING_MAXLEN 8 + +struct xpcie_epf { +struct pci_epf *epf; +void *vaddr[BAR_5 +1 ]; +enum pci_barno comm_bar; +enum pci_barno bar4; +const struct pci_epc_features *epc_features; +struct xpcie xpcie; +int irq; +int irq_dma; +int irq_err; +void __iomem *apb_base; +void __iomem *dma_base; +void __iomem *dbi_base; +char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +}; + +#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/xpcie.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/***************************************************************************** +* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2020 Intel Corporation +* +****************************************************************************/ + +#ifndef XPCIE_HEADER_ +#define XPCIE_HEADER_ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/pci_ids.h> + +#ifndef PCI_DEVICE_ID_INTEL_KEEMBAY +#define PCI_DEVICE_ID_INTEL_KEEMBAY 0x6240 +#endif + +#define XPCIE_IO_COMM_SIZE SZ_16K +#define XPCIE_MMIO_OFFSET SZ_4K + +/* MMIO layout and offsets shared between device and host */ +struct xpcie_mmio { +u8 legacy_a0; +} __packed; + +#define XPCIE_MMIO_LEGACY_A0 (offsetof(struct xpcie_mmio, legacy_a0)) + +struct xpcie { +u32 status; +bool legacy_a0; +void *mmio; +void *bar4; +}; + +#endif /* XPCIE_HEADER_ */
Signature · 1 line
2.17.1
PATCH v3 10/34 misc: xlink-pcie: lh: Add PCIe EP DMA functionality
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add Synopsys PCIe DWC core embedded-DMA functionality for local host
--- drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/local_host/dma.c | 575 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.c | 15 +- drivers/misc/xlink-pcie/local_host/epf.h | 41 ++ 4 files changed, 629 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o +mxlk_ep-objs += dma.o
drivers/misc/xlink-pcie/local_host/dma.c new file +575 -0
575 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +12 -3
@@ -43,6 +43,8 @@ static irqreturn_t intel_xpcie_err_interrupt(int irq, void *args) xpcie_epf = container_of(xpcie, struct xpcie_epf, xpcie); val =ioread32 (xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS ); +if (val &LINK_REQ_RST_FLG ) +intel_xpcie_ep_dma_reset (xpcie_epf->epf);iowrite32 (val, xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS );
@@ -285,8 +287,17 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf) goto err_cleanup_bars; } + ret =intel_xpcie_ep_dma_init (epf); +if (ret) { +dev_err (&epf->dev,"DMA initialization failed\n" ); + goto err_free_err_irq; + } +return 0 ; +err_free_err_irq: +free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); + err_cleanup_bars:intel_xpcie_cleanup_bars (epf);
@@ -295,11 +306,9 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf)static void intel_xpcie_epf_unbind (struct pci_epf *epf) { -struct xpcie_epf *xpcie_epf =epf_get_drvdata (epf);struct pci_epc *epc = epf->epc; -free_irq (xpcie_epf->irq, &xpcie_epf->xpcie); -free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); +intel_xpcie_ep_dma_uninit (epf);pci_epc_stop (epc);
drivers/misc/xlink-pcie/local_host/epf.h +41 -0
53 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 10/34 misc: xlink-pcie: lh: Add PCIe EP DMA functionality
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add Synopsys PCIe DWC core embedded-DMA functionality for local host
--- drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/local_host/dma.c | 575 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/epf.c | 15 +- drivers/misc/xlink-pcie/local_host/epf.h | 41 ++ 4 files changed, 629 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o +mxlk_ep-objs += dma.o
drivers/misc/xlink-pcie/local_host/dma.c new file +575 -0
575 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +12 -3
@@ -43,6 +43,8 @@ static irqreturn_t intel_xpcie_err_interrupt(int irq, void *args) xpcie_epf = container_of(xpcie, struct xpcie_epf, xpcie); val =ioread32 (xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS ); +if (val &LINK_REQ_RST_FLG ) +intel_xpcie_ep_dma_reset (xpcie_epf->epf);iowrite32 (val, xpcie_epf->apb_base +PCIE_REGS_PCIE_ERR_INTR_FLAGS );
@@ -285,8 +287,17 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf) goto err_cleanup_bars; } + ret =intel_xpcie_ep_dma_init (epf); +if (ret) { +dev_err (&epf->dev,"DMA initialization failed\n" ); + goto err_free_err_irq; + } +return 0 ; +err_free_err_irq: +free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); + err_cleanup_bars:intel_xpcie_cleanup_bars (epf);
@@ -295,11 +306,9 @@ static int intel_xpcie_epf_bind(struct pci_epf *epf)static void intel_xpcie_epf_unbind (struct pci_epf *epf) { -struct xpcie_epf *xpcie_epf =epf_get_drvdata (epf);struct pci_epc *epc = epf->epc; -free_irq (xpcie_epf->irq, &xpcie_epf->xpcie); -free_irq (xpcie_epf->irq_err, &xpcie_epf->xpcie); +intel_xpcie_ep_dma_uninit (epf);pci_epc_stop (epc);
drivers/misc/xlink-pcie/local_host/epf.h +41 -0
53 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 11/34 misc: xlink-pcie: lh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the remote host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/core.c | 806 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/core.h | 247 ++++++ drivers/misc/xlink-pcie/local_host/epf.c | 116 ++- drivers/misc/xlink-pcie/local_host/epf.h | 23 + drivers/misc/xlink-pcie/local_host/util.c | 375 +++++++++ drivers/misc/xlink-pcie/local_host/util.h | 70 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 63 ++ include/linux/xlink_drv_inf.h | 58 ++ 9 files changed, 1752 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/core.h create mode 100644 drivers/misc/xlink-pcie/local_host/util.c create mode 100644 drivers/misc/xlink-pcie/local_host/util.h create mode 100644 include/linux/xlink_drv_inf.h
drivers/misc/xlink-pcie/local_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o +mxlk_ep-objs += core.o +mxlk_ep-objs += util.o
drivers/misc/xlink-pcie/local_host/core.c new file +806 -0
806 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/core.h new file +247 -0
247 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +108 -8
185 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h +23 -0
@@ -12,6 +12,7 @@#include <linux/pci-epf.h> #include "xpcie.h" +#include "util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
@@ -24,6 +25,7 @@#define XPCIE_NUM_RX_DESCS (64)extern bool dma_ll_mode; +extern u32 xlink_sw_id;struct xpcie_dma_ll_desc {u32 dma_ch_control1;
@@ -65,14 +67,35 @@ struct xpcie_epf {void __iomem *dbi_base;char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +irq_handler_t core_irq_callback; +dma_addr_t tx_phys; +void *tx_virt; +size_t tx_size; +struct xpcie_dma_ll_desc_buf tx_desc_buf[DMA_CHAN_NUM ];struct xpcie_dma_ll_desc_buf rx_desc_buf[DMA_CHAN_NUM ]; }; +static inline struct device *xpcie_to_dev (struct xpcie *xpcie) +{ +struct xpcie_epf *xpcie_epf =container_of (xpcie, + struct xpcie_epf, xpcie); + +return &xpcie_epf->epf->dev; +} +int intel_xpcie_ep_dma_init (struct pci_epf *epf);int intel_xpcie_ep_dma_uninit (struct pci_epf *epf);int intel_xpcie_ep_dma_reset (struct pci_epf *epf);int intel_xpcie_ep_dma_read_ll (struct pci_epf *epf,int chan,int descs_num);int intel_xpcie_ep_dma_write_ll (struct pci_epf *epf,int chan,int descs_num); +void intel_xpcie_register_host_irq (struct xpcie *xpcie, +irq_handler_t func); +int intel_xpcie_raise_irq (struct xpcie *xpcie, +enum xpcie_doorbell_type type); +int intel_xpcie_copy_from_host_ll (struct xpcie *xpcie, +int chan,int descs_num); +int intel_xpcie_copy_to_host_ll (struct xpcie *xpcie, +int chan,int descs_num);#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/util.c new file +375 -0
375 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/util.h new file +70 -0
70 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/xpcie.h +63 -0
87 lines not on this page · raw message
include/linux/xlink_drv_inf.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 11/34 misc: xlink-pcie: lh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the remote host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/core.c | 806 ++++++++++++++++++++ drivers/misc/xlink-pcie/local_host/core.h | 247 ++++++ drivers/misc/xlink-pcie/local_host/epf.c | 116 ++- drivers/misc/xlink-pcie/local_host/epf.h | 23 + drivers/misc/xlink-pcie/local_host/util.c | 375 +++++++++ drivers/misc/xlink-pcie/local_host/util.h | 70 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 63 ++ include/linux/xlink_drv_inf.h | 58 ++ 9 files changed, 1752 insertions(+), 8 deletions(-) create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/core.h create mode 100644 drivers/misc/xlink-pcie/local_host/util.c create mode 100644 drivers/misc/xlink-pcie/local_host/util.h create mode 100644 include/linux/xlink_drv_inf.h
drivers/misc/xlink-pcie/local_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o +mxlk_ep-objs += core.o +mxlk_ep-objs += util.o
drivers/misc/xlink-pcie/local_host/core.c new file +806 -0
806 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/core.h new file +247 -0
247 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.c +108 -8
185 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/epf.h +23 -0
@@ -12,6 +12,7 @@#include <linux/pci-epf.h> #include "xpcie.h" +#include "util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
@@ -24,6 +25,7 @@#define XPCIE_NUM_RX_DESCS (64)extern bool dma_ll_mode; +extern u32 xlink_sw_id;struct xpcie_dma_ll_desc {u32 dma_ch_control1;
@@ -65,14 +67,35 @@ struct xpcie_epf {void __iomem *dbi_base;char stepping[KEEMBAY_XPCIE_STEPPING_MAXLEN ]; +irq_handler_t core_irq_callback; +dma_addr_t tx_phys; +void *tx_virt; +size_t tx_size; +struct xpcie_dma_ll_desc_buf tx_desc_buf[DMA_CHAN_NUM ];struct xpcie_dma_ll_desc_buf rx_desc_buf[DMA_CHAN_NUM ]; }; +static inline struct device *xpcie_to_dev (struct xpcie *xpcie) +{ +struct xpcie_epf *xpcie_epf =container_of (xpcie, + struct xpcie_epf, xpcie); + +return &xpcie_epf->epf->dev; +} +int intel_xpcie_ep_dma_init (struct pci_epf *epf);int intel_xpcie_ep_dma_uninit (struct pci_epf *epf);int intel_xpcie_ep_dma_reset (struct pci_epf *epf);int intel_xpcie_ep_dma_read_ll (struct pci_epf *epf,int chan,int descs_num);int intel_xpcie_ep_dma_write_ll (struct pci_epf *epf,int chan,int descs_num); +void intel_xpcie_register_host_irq (struct xpcie *xpcie, +irq_handler_t func); +int intel_xpcie_raise_irq (struct xpcie *xpcie, +enum xpcie_doorbell_type type); +int intel_xpcie_copy_from_host_ll (struct xpcie *xpcie, +int chan,int descs_num); +int intel_xpcie_copy_to_host_ll (struct xpcie *xpcie, +int chan,int descs_num);#endif /* XPCIE_EPF_HEADER_ */
drivers/misc/xlink-pcie/local_host/util.c new file +375 -0
375 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/util.h new file +70 -0
70 lines not on this page · raw message
drivers/misc/xlink-pcie/local_host/xpcie.h +63 -0
87 lines not on this page · raw message
include/linux/xlink_drv_inf.h new file +58 -0
58 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 12/34 misc: xlink-pcie: lh: Prepare changes for adding remote host driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Move logic that can be reused between local host and remote host to common/ folder
---
drivers/misc/xlink-pcie/{local_host => common}/core.h | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/util.c | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/util.h | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/xpcie.h | 8 +++-----
drivers/misc/xlink-pcie/local_host/Makefile | 2 +-
drivers/misc/xlink-pcie/local_host/core.c | 4 ++--
drivers/misc/xlink-pcie/local_host/epf.h | 4 ++--
7 files changed, 17 insertions(+), 25 deletions(-)
rename drivers/misc/xlink-pcie/{local_host => common}/core.h (96%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.c (97%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.h (91%)
rename drivers/misc/xlink-pcie/{local_host => common}/xpcie.h (92%)drivers/misc/xlink-pcie/common/core.h renamed from drivers/misc/xlink-pcie/local_host/core.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_
drivers/misc/xlink-pcie/common/util.c renamed from drivers/misc/xlink-pcie/local_host/util.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include "util.h"
drivers/misc/xlink-pcie/common/util.h renamed from drivers/misc/xlink-pcie/local_host/util.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_UTIL_HEADER_ #define XPCIE_UTIL_HEADER_
drivers/misc/xlink-pcie/common/xpcie.h renamed from drivers/misc/xlink-pcie/local_host/xpcie.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_HEADER_ #define XPCIE_HEADER_
drivers/misc/xlink-pcie/local_host/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o -mxlk_ep-objs += util.o +mxlk_ep-objs += ../common/util.o
drivers/misc/xlink-pcie/local_host/core.c +2 -2
@@ -8,8 +8,8 @@#include <linux/of_reserved_mem.h> #include "epf.h" -#include "core.h" -#include "util.h" +#include "../common/core.h" +#include "../common/util.h" static struct xpcie *global_xpcie;
drivers/misc/xlink-pcie/local_host/epf.h +2 -2
@@ -11,8 +11,8 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> -#include "xpcie.h" -#include "util.h" +#include "../common/xpcie.h" +#include "../common/util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
Signature · 1 line
2.17.1
PATCH v4 12/34 misc: xlink-pcie: lh: Prepare changes for adding remote host driver
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Move logic that can be reused between local host and remote host to common/ folder
---
drivers/misc/xlink-pcie/{local_host => common}/core.h | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/util.c | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/util.h | 8 +++-----
drivers/misc/xlink-pcie/{local_host => common}/xpcie.h | 8 +++-----
drivers/misc/xlink-pcie/local_host/Makefile | 2 +-
drivers/misc/xlink-pcie/local_host/core.c | 4 ++--
drivers/misc/xlink-pcie/local_host/epf.h | 4 ++--
7 files changed, 17 insertions(+), 25 deletions(-)
rename drivers/misc/xlink-pcie/{local_host => common}/core.h (96%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.c (97%)
rename drivers/misc/xlink-pcie/{local_host => common}/util.h (91%)
rename drivers/misc/xlink-pcie/{local_host => common}/xpcie.h (92%)drivers/misc/xlink-pcie/common/core.h renamed from drivers/misc/xlink-pcie/local_host/core.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_
drivers/misc/xlink-pcie/common/util.c renamed from drivers/misc/xlink-pcie/local_host/util.c +3 -5
@@ -1,11 +1,9 @@// SPDX-License-Identifier: GPL-2.0-only -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #include "util.h"
drivers/misc/xlink-pcie/common/util.h renamed from drivers/misc/xlink-pcie/local_host/util.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_UTIL_HEADER_ #define XPCIE_UTIL_HEADER_
drivers/misc/xlink-pcie/common/xpcie.h renamed from drivers/misc/xlink-pcie/local_host/xpcie.h +3 -5
@@ -1,11 +1,9 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/***************************************************************************** -* +/* * Intel Keem Bay XLink PCIe Driver * -* Copyright (C) 2020 Intel Corporation -* -****************************************************************************/ +* Copyright (C) 2021 Intel Corporation +*/ #ifndef XPCIE_HEADER_ #define XPCIE_HEADER_
drivers/misc/xlink-pcie/local_host/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o -mxlk_ep-objs += util.o +mxlk_ep-objs += ../common/util.o
drivers/misc/xlink-pcie/local_host/core.c +2 -2
@@ -8,8 +8,8 @@#include <linux/of_reserved_mem.h> #include "epf.h" -#include "core.h" -#include "util.h" +#include "../common/core.h" +#include "../common/util.h" static struct xpcie *global_xpcie;
drivers/misc/xlink-pcie/local_host/epf.h +2 -2
@@ -11,8 +11,8 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> -#include "xpcie.h" -#include "util.h" +#include "../common/xpcie.h" +#include "../common/util.h" #define XPCIE_DRIVER_NAME "mxlk_pcie_epf"#define XPCIE_DRIVER_DESC "Intel(R) xLink PCIe endpoint function driver"
Signature · 1 line
2.17.1
PATCH v4 13/34 misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe Endpoint driver that configures PCIe BARs and MSIs on the Remote Host
--- MAINTAINERS | 2 +- drivers/misc/xlink-pcie/Kconfig | 11 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/common/xpcie.h | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 3 + drivers/misc/xlink-pcie/remote_host/main.c | 90 ++++ drivers/misc/xlink-pcie/remote_host/pci.c | 449 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 62 +++ 8 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h
MAINTAINERS +1 -1
@@ -1961,7 +1961,7 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi -ARM KEEM BAY XLINK PCIE SUPPORT +ARM/INTEL KEEM BAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]> S: Supported
drivers/misc/xlink-pcie/Kconfig +11 -0
@@ -1,3 +1,14 @@ +config XLINK_PCIE_RH_DRIVER + tristate "XLink PCIe Remote Host driver" + depends on PCI && X86_64 + help + This option enables XLink PCIe Remote Host driver. + + Choose M here to compile this driver as a module, name is mxlk. + This driver is used for XLink communication over PCIe, + and is to be loaded on the IA host which is connected to + the Intel Keem Bay. + config XLINK_PCIE_LH_DRIVER tristate "XLink PCIe Local Host driver" depends on PCI_ENDPOINT && ARCH_KEEMBAY
drivers/misc/xlink-pcie/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += remote_host/ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/common/xpcie.h +1 -0
@@ -69,6 +69,7 @@ struct xpcie_mmio {struct xpcie {u32 status;bool legacy_a0; +void *bar0;void *mmio;void *bar4;
drivers/misc/xlink-pcie/remote_host/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o +mxlk-objs := main.o +mxlk-objs += pci.o
drivers/misc/xlink-pcie/remote_host/main.c new file +90 -0
90 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c new file +449 -0
449 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 13/34 misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add PCIe Endpoint driver that configures PCIe BARs and MSIs on the Remote Host
--- MAINTAINERS | 2 +- drivers/misc/xlink-pcie/Kconfig | 11 + drivers/misc/xlink-pcie/Makefile | 1 + drivers/misc/xlink-pcie/common/xpcie.h | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 3 + drivers/misc/xlink-pcie/remote_host/main.c | 90 ++++ drivers/misc/xlink-pcie/remote_host/pci.c | 449 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 62 +++ 8 files changed, 618 insertions(+), 1 deletion(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h
MAINTAINERS +1 -1
@@ -1961,7 +1961,7 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi -ARM KEEM BAY XLINK PCIE SUPPORT +ARM/INTEL KEEM BAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]> S: Supported
drivers/misc/xlink-pcie/Kconfig +11 -0
@@ -1,3 +1,14 @@ +config XLINK_PCIE_RH_DRIVER + tristate "XLink PCIe Remote Host driver" + depends on PCI && X86_64 + help + This option enables XLink PCIe Remote Host driver. + + Choose M here to compile this driver as a module, name is mxlk. + This driver is used for XLink communication over PCIe, + and is to be loaded on the IA host which is connected to + the Intel Keem Bay. + config XLINK_PCIE_LH_DRIVER tristate "XLink PCIe Local Host driver" depends on PCI_ENDPOINT && ARCH_KEEMBAY
drivers/misc/xlink-pcie/Makefile +1 -0
@@ -1 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += remote_host/ obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
drivers/misc/xlink-pcie/common/xpcie.h +1 -0
@@ -69,6 +69,7 @@ struct xpcie_mmio {struct xpcie {u32 status;bool legacy_a0; +void *bar0;void *mmio;void *bar4;
drivers/misc/xlink-pcie/remote_host/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o +mxlk-objs := main.o +mxlk-objs += pci.o
drivers/misc/xlink-pcie/remote_host/main.c new file +90 -0
90 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c new file +449 -0
449 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.h new file +62 -0
62 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 14/34 misc: xlink-pcie: rh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the local host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/common/core.h | 11 +- drivers/misc/xlink-pcie/remote_host/Makefile | 2 + drivers/misc/xlink-pcie/remote_host/core.c | 621 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.c | 48 +- 4 files changed, 670 insertions(+), 12 deletions(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c
drivers/misc/xlink-pcie/common/core.h +4 -7
@@ -8,15 +8,11 @@#ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_ -#include <linux/io.h> -#include <linux/types.h> -#include <linux/workqueue.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/mempool.h> #include <linux/dma-mapping.h> -#include <linux/cache.h> +#include <linux/mutex.h> +#include <linux/slab.h> #include <linux/wait.h> +#include <linux/workqueue.h> #include <linux/xlink_drv_inf.h>
@@ -62,6 +58,7 @@ struct xpcie_buf_desc {struct xpcie_stream {size_t frag;struct xpcie_pipe pipe; +struct xpcie_buf_desc **ddr; };struct xpcie_list {
drivers/misc/xlink-pcie/remote_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o mxlk-objs := main.o mxlk-objs += pci.o +mxlk-objs += core.o +mxlk-objs += ../common/util.o
drivers/misc/xlink-pcie/remote_host/core.c new file +621 -0
621 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c +43 -5
81 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 14/34 misc: xlink-pcie: rh: Add core communication logic
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add logic to establish communication with the local host which is through ring buffer management and MSI/Doorbell interrupts
--- drivers/misc/xlink-pcie/common/core.h | 11 +- drivers/misc/xlink-pcie/remote_host/Makefile | 2 + drivers/misc/xlink-pcie/remote_host/core.c | 621 +++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.c | 48 +- 4 files changed, 670 insertions(+), 12 deletions(-) create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c
drivers/misc/xlink-pcie/common/core.h +4 -7
@@ -8,15 +8,11 @@#ifndef XPCIE_CORE_HEADER_ #define XPCIE_CORE_HEADER_ -#include <linux/io.h> -#include <linux/types.h> -#include <linux/workqueue.h> -#include <linux/slab.h> -#include <linux/mutex.h> -#include <linux/mempool.h> #include <linux/dma-mapping.h> -#include <linux/cache.h> +#include <linux/mutex.h> +#include <linux/slab.h> #include <linux/wait.h> +#include <linux/workqueue.h> #include <linux/xlink_drv_inf.h>
@@ -62,6 +58,7 @@ struct xpcie_buf_desc {struct xpcie_stream {size_t frag;struct xpcie_pipe pipe; +struct xpcie_buf_desc **ddr; };struct xpcie_list {
drivers/misc/xlink-pcie/remote_host/Makefile +2 -0
@@ -1,3 +1,5 @@ obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o mxlk-objs := main.o mxlk-objs += pci.o +mxlk-objs += core.o +mxlk-objs += ../common/util.o
drivers/misc/xlink-pcie/remote_host/core.c new file +621 -0
621 lines not on this page · raw message
drivers/misc/xlink-pcie/remote_host/pci.c +43 -5
81 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 15/34 misc: xlink-pcie: Add XLink API interface
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide interface for XLink layer to interact with XLink PCIe transport layer on both local host and remote host.
--- drivers/misc/xlink-pcie/common/interface.c | 107 +++++++++++++++++++ drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 1 + 3 files changed, 109 insertions(+) create mode 100644 drivers/misc/xlink-pcie/common/interface.c
drivers/misc/xlink-pcie/common/interface.c new file +107 -0
@@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2021 Intel Corporation +*/ + +#include <linux/xlink_drv_inf.h> + +#include "core.h" +#include "xpcie.h" + +/* Define xpcie driver interface API */ +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices) +{ +if (!sw_device_id_list || !num_devices) +return -EINVAL ; + + *num_devices =intel_xpcie_get_device_num (sw_device_id_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_list); + +int xlink_pcie_get_device_name (u32 sw_device_id,char *device_name, +size_t name_size) +{ +if (!device_name) +return -EINVAL ; + +return intel_xpcie_get_device_name_by_id (sw_device_id, + device_name, name_size); +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_name); + +int xlink_pcie_get_device_status (u32 sw_device_id,u32 *device_status) +{ +u32 status; +int rc; + +if (!device_status) +return -EINVAL ; + + rc =intel_xpcie_get_device_status_by_id (sw_device_id, &status); +if (rc) +return rc; + +switch (status) { +case XPCIE_STATUS_READY : +case XPCIE_STATUS_RUN : + *device_status = _XLINK_DEV_READY; +break ; +case XPCIE_STATUS_ERROR : + *device_status = _XLINK_DEV_ERROR; +break ; +case XPCIE_STATUS_RECOVERY : + *device_status = _XLINK_DEV_RECOVERY; +break ; +case XPCIE_STATUS_OFF : + *device_status = _XLINK_DEV_OFF; +break ; +default : + *device_status = _XLINK_DEV_BUSY; +break ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_status); + +int xlink_pcie_boot_device (u32 sw_device_id,const char *binary_name) +{ +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_boot_device); + +int xlink_pcie_connect (u32 sw_device_id) +{ +return intel_xpcie_pci_connect_device (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_connect); + +int xlink_pcie_read (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_read (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL_GPL (xlink_pcie_read); + +int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_write (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL_GPL (xlink_pcie_write); + +int xlink_pcie_reset_device (u32 sw_device_id) +{ +return intel_xpcie_pci_reset_device (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_reset_device);
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o mxlk_ep-objs += ../common/util.o +mxlk_ep-objs += ../common/interface.o
drivers/misc/xlink-pcie/remote_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk-objs := main.o mxlk-objs += pci.o mxlk-objs += core.o mxlk-objs += ../common/util.o +mxlk-objs += ../common/interface.o
Signature · 1 line
2.17.1
PATCH v3 16/34 misc: xlink-pcie: Add asynchronous event notification support for XLink
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add support to notify XLink layer upon PCIe link UP/DOWN events
--- drivers/misc/xlink-pcie/common/core.h | 3 ++ drivers/misc/xlink-pcie/common/interface.c | 17 ++++++++++ drivers/misc/xlink-pcie/local_host/core.c | 11 +++++++ drivers/misc/xlink-pcie/remote_host/main.c | 3 ++ drivers/misc/xlink-pcie/remote_host/pci.c | 36 ++++++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 3 ++ include/linux/xlink_drv_inf.h | 12 ++++++++ 7 files changed, 85 insertions(+)
drivers/misc/xlink-pcie/common/core.h +3 -0
@@ -239,4 +239,7 @@ int intel_xpcie_pci_connect_device(u32 id);int intel_xpcie_pci_read (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_write (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_reset_device (u32 id); +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id);#endif /* XPCIE_CORE_HEADER_ */
drivers/misc/xlink-pcie/common/interface.c +17 -0
@@ -105,3 +105,20 @@ int xlink_pcie_reset_device(u32 sw_device_id)return intel_xpcie_pci_reset_device (sw_device_id); }EXPORT_SYMBOL_GPL (xlink_pcie_reset_device); + +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +if (!event_notif_fn) +return -EINVAL ; + +return intel_xpcie_pci_register_device_event (sw_device_id, + event_notif_fn); +} +EXPORT_SYMBOL_GPL (xlink_pcie_register_device_event); + +int xlink_pcie_unregister_device_event (u32 sw_device_id) +{ +return intel_xpcie_pci_unregister_device_event (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_unregister_device_event);
drivers/misc/xlink-pcie/local_host/core.c +11 -0
@@ -804,3 +804,14 @@ int intel_xpcie_pci_reset_device(u32 id) {return 0 ; } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +return 0 ; +}
drivers/misc/xlink-pcie/remote_host/main.c +3 -0
@@ -53,6 +53,8 @@ static int intel_xpcie_probe(struct pci_dev *pdev,if (new_device)intel_xpcie_list_add_device (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_CONNECTED ); +return ret; }
@@ -62,6 +64,7 @@ static void intel_xpcie_remove(struct pci_dev *pdev)if (xdev) {intel_xpcie_pci_cleanup (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_DISCONNECTED );intel_xpcie_remove_device (xdev); } }
drivers/misc/xlink-pcie/remote_host/pci.c +36 -0
@@ -6,6 +6,7 @@*/ #include <linux/mutex.h> +#include <linux/pci.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/workqueue.h>
@@ -485,3 +486,38 @@ int intel_xpcie_pci_reset_device(u32 id)return intel_xpcie_pci_prepare_dev_reset (xdev, true); } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn = event_notif_fn; + +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn =NULL ; + +return 0 ; +} + +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type) +{ +if (event_type >=NUM_EVENT_TYPE ) +return ; + +if (xdev->event_fn) + xdev->event_fn (xdev->devid, event_type); +}
drivers/misc/xlink-pcie/remote_host/pci.h +3 -0
@@ -36,6 +36,7 @@ struct xpcie_dev {irq_handler_t core_irq_callback;struct xpcie xpcie; +xlink_device_event event_fn; };static inline struct device *xpcie_to_dev (struct xpcie *xpcie)
@@ -58,5 +59,7 @@ struct xpcie_dev *intel_xpcie_create_device(u32 sw_device_id,void intel_xpcie_remove_device (struct xpcie_dev *xdev);void intel_xpcie_list_add_device (struct xpcie_dev *xdev);void intel_xpcie_list_del_device (struct xpcie_dev *xdev); +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type);#endif /* XPCIE_PCI_HEADER_ */
include/linux/xlink_drv_inf.h +12 -0
@@ -42,6 +42,15 @@ enum _xlink_device_status {_XLINK_DEV_READY }; +enum xlink_device_event_type { +NOTIFY_DEVICE_DISCONNECTED , +NOTIFY_DEVICE_CONNECTED , +NUM_EVENT_TYPE +}; + +typedef int (*xlink_device_event )(u32 sw_device_id, +enum xlink_device_event_type event_type); +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices); int xlink_pcie_get_device_name(u32 sw_device_id, char *device_name,
@@ -55,4 +64,7 @@ int xlink_pcie_read(u32 sw_device_id, void *data, size_t *const size,int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size,u32 timeout);int xlink_pcie_reset_device (u32 sw_device_id); +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int xlink_pcie_unregister_device_event (u32 sw_device_id);#endif
Signature · 1 line
2.17.1
PATCH v3 17/34 xlink-ipc: Add xlink ipc device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for the xLink IPC driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- .../misc/intel,keembay-xlink-ipc.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml new file +49 -0
@@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink IPC + +maintainers: + - Kelly Seamus <[email protected]> + +description: | + The Keem Bay xlink IPC driver enables the communication/control sub-system + for internal IPC communications within the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink-ipc + + memory-region: + items: + - description: reference to the CSS xlink IPC reserved memory region. + - description: reference to the MSS xlink IPC reserved memory region. + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The numeric ID identifying the VPU within the xLink stack. + + intel,keembay-vpu-ipc-name: + $ref: "/schemas/types.yaml#/definitions/string" + description: User-friendly name for the VPU within the xLink stack. + + intel,keembay-vpu-ipc: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: reference to the corresponding intel,keembay-vpu-ipc node. + +examples: + - | + xlink-ipc { + compatible = "intel,keembay-xlink-ipc"; + memory-region = <&css_xlink_reserved>, + <&mss_xlink_reserved>; + intel,keembay-vpu-ipc-id = <0x0>; + intel,keembay-vpu-ipc-name = "vpu-slice-0"; + intel,keembay-vpu-ipc = <&vpuipc>; + };
Signature · 1 line
2.17.1
PATCH v4 15/34 misc: xlink-pcie: Add XLink API interface
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Provide interface for XLink layer to interact with XLink PCIe transport layer on both local host and remote host.
--- drivers/misc/xlink-pcie/common/interface.c | 107 +++++++++++++++++++ drivers/misc/xlink-pcie/local_host/Makefile | 1 + drivers/misc/xlink-pcie/remote_host/Makefile | 1 + 3 files changed, 109 insertions(+) create mode 100644 drivers/misc/xlink-pcie/common/interface.c
drivers/misc/xlink-pcie/common/interface.c new file +107 -0
@@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Intel Keem Bay XLink PCIe Driver +* +* Copyright (C) 2021 Intel Corporation +*/ + +#include <linux/xlink_drv_inf.h> + +#include "core.h" +#include "xpcie.h" + +/* Define xpcie driver interface API */ +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices) +{ +if (!sw_device_id_list || !num_devices) +return -EINVAL ; + + *num_devices =intel_xpcie_get_device_num (sw_device_id_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_list); + +int xlink_pcie_get_device_name (u32 sw_device_id,char *device_name, +size_t name_size) +{ +if (!device_name) +return -EINVAL ; + +return intel_xpcie_get_device_name_by_id (sw_device_id, + device_name, name_size); +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_name); + +int xlink_pcie_get_device_status (u32 sw_device_id,u32 *device_status) +{ +u32 status; +int rc; + +if (!device_status) +return -EINVAL ; + + rc =intel_xpcie_get_device_status_by_id (sw_device_id, &status); +if (rc) +return rc; + +switch (status) { +case XPCIE_STATUS_READY : +case XPCIE_STATUS_RUN : + *device_status = _XLINK_DEV_READY; +break ; +case XPCIE_STATUS_ERROR : + *device_status = _XLINK_DEV_ERROR; +break ; +case XPCIE_STATUS_RECOVERY : + *device_status = _XLINK_DEV_RECOVERY; +break ; +case XPCIE_STATUS_OFF : + *device_status = _XLINK_DEV_OFF; +break ; +default : + *device_status = _XLINK_DEV_BUSY; +break ; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_get_device_status); + +int xlink_pcie_boot_device (u32 sw_device_id,const char *binary_name) +{ +return 0 ; +} +EXPORT_SYMBOL_GPL (xlink_pcie_boot_device); + +int xlink_pcie_connect (u32 sw_device_id) +{ +return intel_xpcie_pci_connect_device (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_connect); + +int xlink_pcie_read (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_read (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL_GPL (xlink_pcie_read); + +int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size, +u32 timeout) +{ +if (!data || !size) +return -EINVAL ; + +return intel_xpcie_pci_write (sw_device_id, data, size, timeout); +} +EXPORT_SYMBOL_GPL (xlink_pcie_write); + +int xlink_pcie_reset_device (u32 sw_device_id) +{ +return intel_xpcie_pci_reset_device (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_reset_device);
drivers/misc/xlink-pcie/local_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk_ep-objs := epf.o mxlk_ep-objs += dma.o mxlk_ep-objs += core.o mxlk_ep-objs += ../common/util.o +mxlk_ep-objs += ../common/interface.o
drivers/misc/xlink-pcie/remote_host/Makefile +1 -0
@@ -3,3 +3,4 @@ mxlk-objs := main.o mxlk-objs += pci.o mxlk-objs += core.o mxlk-objs += ../common/util.o +mxlk-objs += ../common/interface.o
Signature · 1 line
2.17.1
PATCH v3 18/34 xlink-ipc: Add xlink ipc driver
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Specifically the driver enables xLink Core to:
* Boot / Reset the VPU IP
* Register to VPU IP event notifications (device connected, device disconnected, WDT event)
* Query the status of the VPU IP (OFF, BUSY, READY, ERROR, RECOVERY)
* Exchange data with the VPU IP, using the Keem Bay IPC mechanism
- Including the ability to send 'volatile' data (i.e., small amount of data, up to 128-bytes that was not allocated in the CPU/VPU shared memory region)
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-ipc.rst | 51 ++ MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 878 +++++++++++++++++++++++++++++ include/linux/xlink-ipc.h | 48 ++ 9 files changed, 997 insertions(+) create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 include/linux/xlink-ipc.h
Documentation/vpu/index.rst +1 -0
@@ -15,3 +15,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie + xlink-ipc
Documentation/vpu/xlink-ipc.rst new file +51 -0
51 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK IPC SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-ipc/ + ARM/INTEL KEEM BAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]>
drivers/misc/Kconfig +1 -0
@@ -482,4 +482,5 @@ source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" +source "drivers/misc/xlink-ipc/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -58,3 +58,4 @@ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ +obj-$(CONFIG_XLINK_IPC) += xlink-ipc/
drivers/misc/xlink-ipc/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config XLINK_IPC + tristate "Support for XLINK IPC" + depends on KEEMBAY_VPU_IPC + help + XLINK IPC enables the communication/control IPC Sub-System. + + Select M if you have an Intel SoC with a Vision Processing Unit (VPU).
drivers/misc/xlink-ipc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for xlink IPC Linux driver +# +obj-$(CONFIG_XLINK_IPC) += xlink-ipc.o
drivers/misc/xlink-ipc/xlink-ipc.c new file +878 -0
878 lines not on this page · raw message
include/linux/xlink-ipc.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 16/34 misc: xlink-pcie: Add asynchronous event notification support for XLink
In reply to [email protected]From: Srikanth Thokala <[email protected]>
Add support to notify XLink layer upon PCIe link UP/DOWN events
--- drivers/misc/xlink-pcie/common/core.h | 3 ++ drivers/misc/xlink-pcie/common/interface.c | 17 ++++++++++ drivers/misc/xlink-pcie/local_host/core.c | 11 +++++++ drivers/misc/xlink-pcie/remote_host/main.c | 3 ++ drivers/misc/xlink-pcie/remote_host/pci.c | 36 ++++++++++++++++++++++ drivers/misc/xlink-pcie/remote_host/pci.h | 3 ++ include/linux/xlink_drv_inf.h | 12 ++++++++ 7 files changed, 85 insertions(+)
drivers/misc/xlink-pcie/common/core.h +3 -0
@@ -239,4 +239,7 @@ int intel_xpcie_pci_connect_device(u32 id);int intel_xpcie_pci_read (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_write (u32 id,void *data,size_t *size,u32 timeout);int intel_xpcie_pci_reset_device (u32 id); +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id);#endif /* XPCIE_CORE_HEADER_ */
drivers/misc/xlink-pcie/common/interface.c +17 -0
@@ -105,3 +105,20 @@ int xlink_pcie_reset_device(u32 sw_device_id)return intel_xpcie_pci_reset_device (sw_device_id); }EXPORT_SYMBOL_GPL (xlink_pcie_reset_device); + +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +if (!event_notif_fn) +return -EINVAL ; + +return intel_xpcie_pci_register_device_event (sw_device_id, + event_notif_fn); +} +EXPORT_SYMBOL_GPL (xlink_pcie_register_device_event); + +int xlink_pcie_unregister_device_event (u32 sw_device_id) +{ +return intel_xpcie_pci_unregister_device_event (sw_device_id); +} +EXPORT_SYMBOL_GPL (xlink_pcie_unregister_device_event);
drivers/misc/xlink-pcie/local_host/core.c +11 -0
@@ -804,3 +804,14 @@ int intel_xpcie_pci_reset_device(u32 id) {return 0 ; } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +return 0 ; +}
drivers/misc/xlink-pcie/remote_host/main.c +3 -0
@@ -53,6 +53,8 @@ static int intel_xpcie_probe(struct pci_dev *pdev,if (new_device)intel_xpcie_list_add_device (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_CONNECTED ); +return ret; }
@@ -62,6 +64,7 @@ static void intel_xpcie_remove(struct pci_dev *pdev)if (xdev) {intel_xpcie_pci_cleanup (xdev); +intel_xpcie_pci_notify_event (xdev,NOTIFY_DEVICE_DISCONNECTED );intel_xpcie_remove_device (xdev); } }
drivers/misc/xlink-pcie/remote_host/pci.c +36 -0
@@ -6,6 +6,7 @@*/ #include <linux/mutex.h> +#include <linux/pci.h> #include <linux/sched.h> #include <linux/wait.h> #include <linux/workqueue.h>
@@ -485,3 +486,38 @@ int intel_xpcie_pci_reset_device(u32 id)return intel_xpcie_pci_prepare_dev_reset (xdev, true); } + +int intel_xpcie_pci_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn = event_notif_fn; + +return 0 ; +} + +int intel_xpcie_pci_unregister_device_event (u32 sw_device_id) +{ +struct xpcie_dev *xdev =intel_xpcie_get_device_by_id (sw_device_id); + +if (!xdev) +return -ENOMEM ; + + xdev->event_fn =NULL ; + +return 0 ; +} + +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type) +{ +if (event_type >=NUM_EVENT_TYPE ) +return ; + +if (xdev->event_fn) + xdev->event_fn (xdev->devid, event_type); +}
drivers/misc/xlink-pcie/remote_host/pci.h +3 -0
@@ -36,6 +36,7 @@ struct xpcie_dev {irq_handler_t core_irq_callback;struct xpcie xpcie; +xlink_device_event event_fn; };static inline struct device *xpcie_to_dev (struct xpcie *xpcie)
@@ -58,5 +59,7 @@ struct xpcie_dev *intel_xpcie_create_device(u32 sw_device_id,void intel_xpcie_remove_device (struct xpcie_dev *xdev);void intel_xpcie_list_add_device (struct xpcie_dev *xdev);void intel_xpcie_list_del_device (struct xpcie_dev *xdev); +void intel_xpcie_pci_notify_event (struct xpcie_dev *xdev, +enum xlink_device_event_type event_type);#endif /* XPCIE_PCI_HEADER_ */
include/linux/xlink_drv_inf.h +12 -0
@@ -42,6 +42,15 @@ enum _xlink_device_status {_XLINK_DEV_READY }; +enum xlink_device_event_type { +NOTIFY_DEVICE_DISCONNECTED , +NOTIFY_DEVICE_CONNECTED , +NUM_EVENT_TYPE +}; + +typedef int (*xlink_device_event )(u32 sw_device_id, +enum xlink_device_event_type event_type); +int xlink_pcie_get_device_list (u32 *sw_device_id_list,u32 *num_devices); int xlink_pcie_get_device_name(u32 sw_device_id, char *device_name,
@@ -55,4 +64,7 @@ int xlink_pcie_read(u32 sw_device_id, void *data, size_t *const size,int xlink_pcie_write (u32 sw_device_id,void *data,size_t *const size,u32 timeout);int xlink_pcie_reset_device (u32 sw_device_id); +int xlink_pcie_register_device_event (u32 sw_device_id, +xlink_device_event event_notif_fn); +int xlink_pcie_unregister_device_event (u32 sw_device_id);#endif
Signature · 1 line
2.17.1
PATCH v4 17/34 xlink-ipc: Add xlink ipc device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for the xLink IPC driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- .../misc/intel,keembay-xlink-ipc.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml new file +51 -0
@@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink-ipc.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink IPC + +maintainers: + - Kelly Seamus <[email protected]> + +description: | + The Keem Bay xlink IPC driver enables the communication/control sub-system + for internal IPC communications within the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink-ipc + + memory-region: + items: + - description: reference to the CSS xlink IPC reserved memory region. + - description: reference to the MSS xlink IPC reserved memory region. + + intel,keembay-vpu-ipc-id: + $ref: "/schemas/types.yaml#/definitions/uint32" + description: The numeric ID identifying the VPU within the xLink stack. + + intel,keembay-vpu-ipc-name: + $ref: "/schemas/types.yaml#/definitions/string" + description: User-friendly name for the VPU within the xLink stack. + + intel,keembay-vpu-ipc: + $ref: "/schemas/types.yaml#/definitions/phandle" + description: reference to the corresponding intel,keembay-vpu-ipc node. + +additionalProperties: False + +examples: + - | + xlink-ipc { + compatible = "intel,keembay-xlink-ipc"; + memory-region = <&css_xlink_reserved>, + <&mss_xlink_reserved>; + intel,keembay-vpu-ipc-id = <0x0>; + intel,keembay-vpu-ipc-name = "vpu-slice-0"; + intel,keembay-vpu-ipc = <&vpuipc>; + };
Signature · 1 line
2.17.1
v4 cover Intel Vision Processing base enabling
In reply to [email protected]From: Mark Gross <[email protected]>
The Intel Vision Processing Unit (VPU) is an IP block that is showing up for the first time as part of the Keem Bay SOC. Keem Bay is a quad core A53 Arm SOC. It is designed to be used as a stand alone SOC as well as in an PCIe Vision Processing accelerator add in card.
This forth version of this patch set includes updates to the dt yaml files and some missed updates from feedback given on the V2 patch set for keembay-vpu-ipc and the Kconfig for intel_tsens
At the bottom of this coverletter is the delta between v2 and V3 for easy review of the modifications. Feels like things are converging. :)
Thanks for looking at these and providing feedback.
--mark
C, Udhayakumar (8):
dt-bindings: misc: intel_tsens: Add tsens thermal bindings
documentation
misc: Tsens ARM host thermal driver.
misc: Intel tsens IA host driver.
Intel tsens i2c slave driver.
misc:intel_tsens: Intel Keem Bay tsens driver.
dt-bindings: misc: hddl_dev: Add hddl device management documentation
misc: Hddl device management for local host
misc: HDDL device management for IA host
Daniele Alessandrelli (4):
dt-bindings: mailbox: Add Intel VPU IPC mailbox bindings
mailbox: vpu-ipc-mailbox: Add support for Intel VPU IPC mailbox
dt-bindings: Add bindings for Keem Bay IPC driver
keembay-ipc: Add Keem Bay IPC module
Li, Tingqian (2):
dt-bindings: misc: Add Keem Bay vpumgr
misc: Add Keem Bay VPU manager
Paul Murphy (2):
dt-bindings: Add bindings for Keem Bay VPU IPC driver
keembay-vpu-ipc: Add Keem Bay VPU IPC module
Ramya P Karanth (1):
Intel Keem Bay XLink SMBus driver
Seamus Kelly (7):
xlink-ipc: Add xlink ipc device tree bindings
xlink-ipc: Add xlink ipc driver
xlink-core: Add xlink core device tree bindings
xlink-core: Add xlink core driver xLink
xlink-core: Enable xlink protocol over pcie
xlink-core: Enable VPU IP management and runtime control
xlink-core: add async channel and events
Srikanth Thokala (9):
misc: xlink-pcie: Add documentation for XLink PCIe driver
misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
misc: xlink-pcie: lh: Add PCIe EP DMA functionality
misc: xlink-pcie: lh: Add core communication logic
misc: xlink-pcie: lh: Prepare changes for adding remote host driver
misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
misc: xlink-pcie: rh: Add core communication logic
misc: xlink-pcie: Add XLink API interface
misc: xlink-pcie: Add asynchronous event notification support for
XLink
mark gross (1):
Add Vision Processing Unit (VPU) documentation.
.../mailbox/intel,vpu-ipc-mailbox.yaml | 69 + .../bindings/misc/intel,hddl-client.yaml | 114 + .../bindings/misc/intel,intel-tsens.yaml | 118 + .../bindings/misc/intel,keembay-vpu-mgr.yaml | 48 + .../misc/intel,keembay-xlink-ipc.yaml | 51 + .../bindings/misc/intel,keembay-xlink.yaml | 29 + .../bindings/soc/intel/intel,keembay-ipc.yaml | 45 + .../soc/intel/intel,keembay-vpu-ipc.yaml | 143 ++ Documentation/hwmon/index.rst | 2 + Documentation/hwmon/intel_tsens_host.rst | 71 + Documentation/hwmon/intel_tsens_sensor.rst | 67 + Documentation/i2c/busses/index.rst | 1 + .../i2c/busses/intel-xlink-smbus.rst | 71 + Documentation/index.rst | 1 + .../misc-devices/hddl_device_client.rst | 212 ++ .../misc-devices/hddl_device_server.rst | 205 ++ Documentation/misc-devices/index.rst | 2 + Documentation/vpu/index.rst | 20 + Documentation/vpu/vpu-stack-overview.rst | 270 +++ Documentation/vpu/xlink-core.rst | 81 + Documentation/vpu/xlink-ipc.rst | 51 + Documentation/vpu/xlink-pcie.rst | 90 + MAINTAINERS | 54 + drivers/mailbox/Kconfig | 11 + drivers/mailbox/Makefile | 2 + drivers/mailbox/vpu-ipc-mailbox.c | 297 +++ drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 7 + drivers/misc/hddl_device/Kconfig | 26 + drivers/misc/hddl_device/Makefile | 7 + drivers/misc/hddl_device/hddl_device.c | 565 +++++ drivers/misc/hddl_device/hddl_device_lh.c | 764 +++++++ drivers/misc/hddl_device/hddl_device_rh.c | 837 +++++++ drivers/misc/hddl_device/hddl_device_util.h | 52 + drivers/misc/intel_tsens/Kconfig | 54 + drivers/misc/intel_tsens/Makefile | 10 + drivers/misc/intel_tsens/intel_tsens_host.c | 351 +++ drivers/misc/intel_tsens/intel_tsens_i2c.c | 119 + .../misc/intel_tsens/intel_tsens_thermal.c | 651 ++++++ .../misc/intel_tsens/intel_tsens_thermal.h | 38 + drivers/misc/intel_tsens/keembay_thermal.c | 169 ++ drivers/misc/intel_tsens/keembay_tsens.h | 366 +++ drivers/misc/vpumgr/Kconfig | 9 + drivers/misc/vpumgr/Makefile | 3 + drivers/misc/vpumgr/vpu_common.h | 31 + drivers/misc/vpumgr/vpu_mgr.c | 370 +++ drivers/misc/vpumgr/vpu_smm.c | 554 +++++ drivers/misc/vpumgr/vpu_smm.h | 30 + drivers/misc/vpumgr/vpu_vcm.c | 584 +++++ drivers/misc/vpumgr/vpu_vcm.h | 84 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 1331 +++++++++++ drivers/misc/xlink-core/xlink-core.h | 25 + drivers/misc/xlink-core/xlink-defs.h | 181 ++ drivers/misc/xlink-core/xlink-dispatcher.c | 436 ++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-ioctl.c | 554 +++++ drivers/misc/xlink-core/xlink-ioctl.h | 36 + drivers/misc/xlink-core/xlink-multiplexer.c | 1164 ++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 273 +++ drivers/misc/xlink-core/xlink-platform.h | 65 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 878 +++++++ drivers/misc/xlink-pcie/Kconfig | 20 + drivers/misc/xlink-pcie/Makefile | 2 + drivers/misc/xlink-pcie/common/core.h | 245 ++ drivers/misc/xlink-pcie/common/interface.c | 124 + drivers/misc/xlink-pcie/common/util.c | 373 +++ drivers/misc/xlink-pcie/common/util.h | 68 + drivers/misc/xlink-pcie/common/xpcie.h | 100 + drivers/misc/xlink-pcie/local_host/Makefile | 6 + drivers/misc/xlink-pcie/local_host/core.c | 817 +++++++ drivers/misc/xlink-pcie/local_host/dma.c | 575 +++++ drivers/misc/xlink-pcie/local_host/epf.c | 482 ++++ drivers/misc/xlink-pcie/local_host/epf.h | 101 + drivers/misc/xlink-pcie/remote_host/Makefile | 6 + drivers/misc/xlink-pcie/remote_host/core.c | 621 +++++ drivers/misc/xlink-pcie/remote_host/main.c | 93 + drivers/misc/xlink-pcie/remote_host/pci.c | 523 +++++ drivers/misc/xlink-pcie/remote_host/pci.h | 65 + drivers/misc/xlink-smbus/Kconfig | 26 + drivers/misc/xlink-smbus/Makefile | 5 + drivers/misc/xlink-smbus/xlink-smbus.c | 467 ++++ drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/intel/Kconfig | 33 + drivers/soc/intel/Makefile | 5 + drivers/soc/intel/keembay-ipc.c | 1364 +++++++++++ drivers/soc/intel/keembay-vpu-ipc.c | 2026 +++++++++++++++++ include/linux/hddl_device.h | 153 ++ include/linux/intel_tsens_host.h | 34 + include/linux/soc/intel/keembay-ipc.h | 30 + include/linux/soc/intel/keembay-vpu-ipc.h | 62 + include/linux/xlink-ipc.h | 48 + include/linux/xlink.h | 146 ++ include/linux/xlink_drv_inf.h | 70 + include/uapi/misc/vpumgr.h | 64 + include/uapi/misc/xlink_uapi.h | 145 ++ 101 files changed, 21767 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/intel,vpu-ipc-mailbox.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-ipc.yaml create mode 100644 Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml create mode 100644 Documentation/hwmon/intel_tsens_host.rst create mode 100644 Documentation/hwmon/intel_tsens_sensor.rst create mode 100644 Documentation/i2c/busses/intel-xlink-smbus.rst create mode 100644 Documentation/misc-devices/hddl_device_client.rst create mode 100644 Documentation/misc-devices/hddl_device_server.rst create mode 100644 Documentation/vpu/index.rst create mode 100644 Documentation/vpu/vpu-stack-overview.rst create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 Documentation/vpu/xlink-pcie.rst create mode 100644 drivers/mailbox/vpu-ipc-mailbox.c create mode 100644 drivers/misc/hddl_device/Kconfig create mode 100644 drivers/misc/hddl_device/Makefile create mode 100644 drivers/misc/hddl_device/hddl_device.c create mode 100644 drivers/misc/hddl_device/hddl_device_lh.c create mode 100644 drivers/misc/hddl_device/hddl_device_rh.c create mode 100644 drivers/misc/hddl_device/hddl_device_util.h create mode 100644 drivers/misc/intel_tsens/Kconfig create mode 100644 drivers/misc/intel_tsens/Makefile create mode 100644 drivers/misc/intel_tsens/intel_tsens_host.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_i2c.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.h create mode 100644 drivers/misc/intel_tsens/keembay_thermal.c create mode 100644 drivers/misc/intel_tsens/keembay_tsens.h create mode 100644 drivers/misc/vpumgr/Kconfig create mode 100644 drivers/misc/vpumgr/Makefile create mode 100644 drivers/misc/vpumgr/vpu_common.h create mode 100644 drivers/misc/vpumgr/vpu_mgr.c create mode 100644 drivers/misc/vpumgr/vpu_smm.c create mode 100644 drivers/misc/vpumgr/vpu_smm.h create mode 100644 drivers/misc/vpumgr/vpu_vcm.c create mode 100644 drivers/misc/vpumgr/vpu_vcm.h create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/common/core.h create mode 100644 drivers/misc/xlink-pcie/common/interface.c create mode 100644 drivers/misc/xlink-pcie/common/util.c create mode 100644 drivers/misc/xlink-pcie/common/util.h create mode 100644 drivers/misc/xlink-pcie/common/xpcie.h create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/core.c create mode 100644 drivers/misc/xlink-pcie/local_host/dma.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/remote_host/Makefile create mode 100644 drivers/misc/xlink-pcie/remote_host/core.c create mode 100644 drivers/misc/xlink-pcie/remote_host/main.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.c create mode 100644 drivers/misc/xlink-pcie/remote_host/pci.h create mode 100644 drivers/misc/xlink-smbus/Kconfig create mode 100644 drivers/misc/xlink-smbus/Makefile create mode 100644 drivers/misc/xlink-smbus/xlink-smbus.c create mode 100644 drivers/soc/intel/Kconfig create mode 100644 drivers/soc/intel/Makefile create mode 100644 drivers/soc/intel/keembay-ipc.c create mode 100644 drivers/soc/intel/keembay-vpu-ipc.c create mode 100644 include/linux/hddl_device.h create mode 100644 include/linux/intel_tsens_host.h create mode 100644 include/linux/soc/intel/keembay-ipc.h create mode 100644 include/linux/soc/intel/keembay-vpu-ipc.h create mode 100644 include/linux/xlink-ipc.h create mode 100644 include/linux/xlink.h create mode 100644 include/linux/xlink_drv_inf.h create mode 100644 include/uapi/misc/vpumgr.h create mode 100644 include/uapi/misc/xlink_uapi.h
Signature · 1 line
2.17.1
Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml +1 -5
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) %YAML 1.2 --- -$id: "http://devicetree.org/schemas/misc/intel,intel_tsens.yaml#" +$id: "http://devicetree.org/schemas/misc/intel,intel-tsens.yaml#" $schema: "http://devicetree.org/meta-schemas/core.yaml#" title: Intel Temperature sensors in Bay series
@@ -36,8 +36,6 @@ properties: - description: thermal sensor clock clk-rate: - minItems: 1 - maxItems: 1 additionalItems: false items: - description: thermal sensor clock freq
@@ -85,8 +83,6 @@ examples: tsens: tsens@20260000 { compatible = "intel,intel-tsens"; status = "disabled"; - #address-cells = <2>; - #size-cells = <2>; plat_name = "intel,keembay_thermal"; reg = <0x0 0x20260000 0x0 0x100>; clocks = <&scmi_clk>;
Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml +2 -2
@@ -19,8 +19,8 @@ properties: compatible: items: - enum: - - intel,keembay-vpu-mgr - - intel,keembay-vpusmm + - intel,keembay-vpu-mgr + - intel,keembay-vpusmm memory-region: description:
Documentation/devicetree/bindings/misc/intel,keembay-xlink-ipc.yaml +3 -1
@@ -18,7 +18,7 @@ properties: compatible: oneOf: - items: - - const: intel,keembay-xlink-ipc + - const: intel,keembay-xlink-ipc memory-region: items:
@@ -37,6 +37,8 @@ properties: $ref: "/schemas/types.yaml#/definitions/phandle" description: reference to the corresponding intel,keembay-vpu-ipc node. +additionalProperties: False + examples: - | xlink-ipc {
Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml +3 -1
@@ -18,7 +18,9 @@ properties: compatible: oneOf: - items: - - const: intel,keembay-xlink + - const: intel,keembay-xlink + +additionalProperties: False examples: - |
Documentation/devicetree/bindings/soc/intel/intel,keembay-vpu-ipc.yaml +10 -20
@@ -9,16 +9,21 @@ title: Intel Keem Bay VPU IPC maintainers: - Paul Murphy <[email protected]> + - Daniele Alessandrelli <[email protected]> description: - The VPU IPC driver facilitates loading of firmware, control, and communication - with the VPU over the IPC FIFO in the Intel Keem Bay SoC. + This binding provides support for the Vision Processing Unit (VPU) found on + the Intel Keem Bay SoC. + + The VPU is started and controlled by SoC CPU, which is in charge of loading + the VPU firmware. The SoC CPU can communicate with the VPU firmware using an + Inter-Processor Communication (IPC) mechanism. properties: compatible: oneOf: - items: - - const: intel,keembay-vpu-ipc + - const: intel,keembay-vpu-ipc reg: items:
@@ -82,24 +87,11 @@ properties: - const: nce_wdt - const: mss_wdt - intel,keembay-vpu-ipc-nce-wdt-redirect: - $ref: "/schemas/types.yaml#/definitions/uint32" - description: - Number to which we will request that the NCE sub-system - re-directs it's WDT timeout IRQ - - intel,keembay-vpu-ipc-mss-wdt-redirect: - $ref: "/schemas/types.yaml#/definitions/uint32" - description: - Number to which we will request that the MSS sub-system - re-directs it's WDT timeout IRQ - intel,keembay-vpu-ipc-imr: $ref: "/schemas/types.yaml#/definitions/uint32" description: - IMR (isolated memory region) number which we will request - the runtime service uses to protect the VPU memory region - before authentication + Isolated Memory Region (IMR) number that the runtime service must use to + protect the VPU memory region before authentication. intel,keembay-vpu-ipc-id: $ref: "/schemas/types.yaml#/definitions/uint32"
@@ -146,8 +138,6 @@ examples: interrupts = <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>; interrupt-names = "nce_wdt", "mss_wdt"; - intel,keembay-vpu-ipc-nce-wdt-redirect = <63>; - intel,keembay-vpu-ipc-mss-wdt-redirect = <47>; intel,keembay-vpu-ipc-imr = <9>; intel,keembay-vpu-ipc-id = <0>; };
drivers/misc/intel_tsens/Kconfig +1 -2
@@ -17,8 +17,7 @@ config INTEL_TSENS_LOCAL_HOST config INTEL_TSENS_I2C_SLAVE bool "I2C slave driver for intel tsens" depends on INTEL_TSENS_LOCAL_HOST - select I2C - select I2C_SLAVE + depends on I2C=y && I2C_SLAVE help This option enables tsens I2C slave driver.
drivers/soc/intel/keembay-vpu-ipc.c +12 -22
@@ -81,6 +81,7 @@#include <linux/firmware.h> #include <linux/interrupt.h> #include <linux/io.h> +#include <linux/irq.h> #include <linux/kernel.h> #include <linux/kthread.h> #include <linux/module.h>
@@ -175,6 +176,13 @@/* SoC stepping length, in bytes. */ #define SOC_INFO_STEPPING_BYTES 2 +/* +* The offset to convert the HW IRQ reported by irqd_to_hwirq() to the GIC_SPI +* IRQ number specified in the device tree: +* GIC_SPI x = irqd_to_hwirq() - 32 +*/ +#define GIC_SPI_HWIRQ_OFFSET 32 +/** * struct boot_parameters - Boot parameters passed to the VPU. * @magic_number: Magic number to indicate structure populated
@@ -315,8 +323,6 @@ struct atf_mem {* the NCE WDT timeout interrupt. * @mss_irq: IRQ number of the A53 re-direct IRQ which will be used * for receiving the MSS WDT timeout interrupt. -* @nce_wdt_redirect: Re-direct IRQ for NCE ICB. -* @mss_wdt_redirect: Re-direct IRQ for MSS ICB. * @imr: Isolated Memory Region (IMR) to be used to protect the * loaded VPU firmware. * @vpu_id: The ID of the VPU associated with this device.
@@ -349,8 +355,6 @@ struct vpu_ipc_dev {struct clk *pll[NUM_PLLS ][NUM_PLL_OUTPUTS ];int nce_irq;int mss_irq; -u32 nce_wdt_redirect; -u32 mss_wdt_redirect;u32 imr;u32 vpu_id;void __iomem *nce_wdt_reg;
@@ -897,22 +901,6 @@ static int setup_watchdog_resources(struct vpu_ipc_dev *vpu_dev)return rc; } -/* Request interrupt re-direct numbers */ - rc =of_property_read_u32 (dev->of_node, -"intel,keembay-vpu-ipc-nce-wdt-redirect" , - &vpu_dev->nce_wdt_redirect); -if (rc) { -dev_err (dev,"failed to get NCE WDT redirect number.\n" ); -return rc; - } - rc =of_property_read_u32 (dev->of_node, -"intel,keembay-vpu-ipc-mss-wdt-redirect" , - &vpu_dev->mss_wdt_redirect); -if (rc) { -dev_err (dev,"failed to get MSS WDT redirect number.\n" ); -return rc; - } -return 0 ; }
@@ -956,9 +944,11 @@ static int setup_boot_parameters(struct vpu_ipc_dev *vpu_dev)/* Fill in IRQ re-direct request information */ vpu_dev->boot_params->mss_wdt_to_irq_a53_redir = - vpu_dev->mss_wdt_redirect; +irqd_to_hwirq (irq_get_irq_data (vpu_dev->mss_irq)) - +GIC_SPI_HWIRQ_OFFSET ; vpu_dev->boot_params->nce_wdt_to_irq_a53_redir = - vpu_dev->nce_wdt_redirect; +irqd_to_hwirq (irq_get_irq_data (vpu_dev->nce_irq)) - +GIC_SPI_HWIRQ_OFFSET ;/* Setup A53SS_VERSION_ID */ vpu_dev->boot_params->a53ss_version_id = vpu_ipc_soc_info->hardware_id;
PATCH v3 19/34 xlink-core: Add xlink core device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for keembay-xlink.
--- .../bindings/misc/intel,keembay-xlink.yaml | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml new file +27 -0
@@ -0,0 +1,27 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink + +maintainers: + - Seamus Kelly <[email protected]> + +description: | + The Keem Bay xlink driver enables the communication/control sub-system + for internal and external communications to the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink + +examples: + - | + xlink { + compatible = "intel,keembay-xlink"; + };
Signature · 1 line
2.17.1
PATCH v3 20/34 xlink-core: Add xlink core driver xLink
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which provides an abstracted control and communication subsystem based on channel identification.
It is intended to support VPU technology both at SoC level as well as at IP level, over multiple interfaces. This initial patch enables local host user mode to open/close/read/write via IOCTLs.
Specifically the driver enables application/process to:
* Access a common xLink API across all interfaces from both kernel and user space.
* Call typical APIs types (open, close, read, write) that you would associate with a communication interface.
* Call other APIs that are related to other functions that the device can perform e.g. boot, reset get/set device mode. Device mode refers to the power load of the VPU and an API can be used to read and control it.
* Use multiple commnication channels that the driver manages from one interface to another, providing routing of data through these multiple channels across a single physical interface.
xLink: Add xLink Core device tree bindings
Add device tree bindings for the xLink Core driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-core.rst | 81 +++ MAINTAINERS | 12 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 738 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-core.h | 22 + drivers/misc/xlink-core/xlink-defs.h | 175 +++++ drivers/misc/xlink-core/xlink-ioctl.c | 212 ++++++ drivers/misc/xlink-core/xlink-ioctl.h | 21 + drivers/misc/xlink-core/xlink-multiplexer.c | 534 ++++++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 160 +++++ drivers/misc/xlink-core/xlink-platform.h | 65 ++ include/linux/xlink.h | 108 +++ include/uapi/misc/xlink_uapi.h | 145 ++++ 18 files changed, 2349 insertions(+) create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 include/linux/xlink.h create mode 100644 include/uapi/misc/xlink_uapi.h
Documentation/vpu/index.rst +1 -0
@@ -16,3 +16,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie xlink-ipc + xlink-core
Documentation/vpu/xlink-core.rst new file +81 -0
81 lines not on this page · raw message
MAINTAINERS +12 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK CORE SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-core/ + ARM/INTEL XLINK IPC SUPPORT M: Seamus Kelly <[email protected]> M: Mark Gross <[email protected]>
@@ -1973,6 +1979,12 @@ M: Mark Gross <[email protected]> S: Supported F: drivers/misc/xlink-pcie/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Supported +F: drivers/misc/hddl_device/ +F: drivers/misc/intel_tsens/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -483,4 +483,5 @@ source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" +source "drivers/misc/xlink-core/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -59,3 +59,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ +obj-$(CONFIG_XLINK_CORE) += xlink-core/
drivers/misc/xlink-core/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +config XLINK_CORE + tristate "Support for XLINK CORE" + depends on ((XLINK_PCIE_RH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER) || (XLINK_LOCAL_HOST && (XLINK_PCIE_LH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER))) + help + XLINK CORE enables the communication/control subsystem. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called xlink.ko. + +config XLINK_LOCAL_HOST + tristate "Support for XLINK LOCAL HOST" + depends on XLINK_IPC + help + XLINK LOCAL HOST enables local host functionality for + the communication/control Sub-System. + + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) Local Host core. + + If building for a Remote Host kernel, say N. + +config XLINK_PSS + tristate "Support for XLINK PSS (Pre-Silicon Solution)" + depends on XLINK_LOCAL_HOST + help + XLINK PSS enables the communication/control subsystem on a PSS platform. + + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) in a simulated env. + + If building for a VPU silicon, say N.
drivers/misc/xlink-core/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for Keem Bay xlink Linux driver +# +obj-$(CONFIG_XLINK_CORE) += xlink.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o xlink-ioctl.o
drivers/misc/xlink-core/xlink-core.c new file +738 -0
738 lines not on this page · raw message
drivers/misc/xlink-core/xlink-core.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink core header file. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_CORE_H_ +#define XLINK_CORE_H_ +#include "xlink-defs.h" + +#define NUM_REG_EVENTS 4 + +enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size,u32 user_flag); + +enum xlink_error xlink_write_data_user (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size); +#endif /* XLINK_CORE_H_ */
drivers/misc/xlink-core/xlink-defs.h new file +175 -0
175 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.c new file +212 -0
212 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink ioctl header files. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_IOCTL_H_ +#define XLINK_IOCTL_H_ + +int ioctl_connect (unsigned long arg); +int ioctl_open_channel (unsigned long arg); +int ioctl_read_data (unsigned long arg); +int ioctl_write_data (unsigned long arg); +int ioctl_write_volatile_data (unsigned long arg); +int ioctl_release_data (unsigned long arg); +int ioctl_close_channel (unsigned long arg); +int ioctl_disconnect (unsigned long arg); + +#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c new file +534 -0
534 lines not on this page · raw message
drivers/misc/xlink-core/xlink-multiplexer.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Multiplexer. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_MULTIPLEXER_H +#define __XLINK_MULTIPLEXER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_multiplexer_init (void *dev); + +enum xlink_error xlink_multiplexer_connect (u32 link_id); + +enum xlink_error xlink_multiplexer_disconnect (u32 link_id); + +enum xlink_error xlink_multiplexer_destroy (void ); + +enum xlink_error xlink_multiplexer_tx (struct xlink_event *event, +int *event_queued); + +enum xlink_error xlink_multiplexer_rx (struct xlink_event *event); + +enum xlink_error xlink_passthrough (struct xlink_event *event); + +void *find_allocated_buffer (dma_addr_t paddr); + +int unregister_allocated_buffer (void *buf,dma_addr_t paddr); + +int core_release_packet_from_channel (u32 link_id,uint16_t chan, +uint8_t *const addr); + +#endif /* __XLINK_MULTIPLEXER_H */
drivers/misc/xlink-core/xlink-platform.c new file +160 -0
160 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.h new file +65 -0
65 lines not on this page · raw message
include/linux/xlink.h new file +108 -0
108 lines not on this page · raw message
include/uapi/misc/xlink_uapi.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 21/34 xlink-core: Enable xlink protocol over pcie
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable host system access to the VPU over the xlink protocol over PCIe by enabling channel multiplexing and dispatching. This allows for remote host communication channels across pcie links.
add dispatcher
update multiplexer to utilise dispatcher
xlink-core: Patch set 2
Add xlink-dispatcher
creates tx and rx threads
enables queueing of messages for transmission and on reception
Update multiplexer to utilise dispatcher:
handle multiplexing channels over single interface link e.g. PCIe process messages received by dispatcher
pass messages created by API calls to dispatcher for transmission
--- drivers/misc/xlink-core/Makefile | 2 +- drivers/misc/xlink-core/xlink-core.c | 35 +- drivers/misc/xlink-core/xlink-dispatcher.c | 441 +++++++++++++++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-multiplexer.c | 498 +++++++++++++++++++- 5 files changed, 999 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h
drivers/misc/xlink-core/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for Keem Bay xlink Linux driver # obj-$(CONFIG_XLINK_CORE) += xlink.o -xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o xlink-ioctl.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-dispatcher.o xlink-platform.o xlink-ioctl.o
drivers/misc/xlink-core/xlink-core.c +34 -1
@@ -21,6 +21,7 @@#include "xlink-core.h" #include "xlink-defs.h" +#include "xlink-dispatcher.h" #include "xlink-ioctl.h" #include "xlink-multiplexer.h" #include "xlink-platform.h"
@@ -151,6 +152,12 @@ static int kmb_xlink_probe(struct platform_device *pdev) goto r_multiplexer; } +// initialize dispatcher + rc =xlink_dispatcher_init (xlink_dev->pdev); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("Dispatcher initialization failed\n" ); + goto r_dispatcher; + }// initialize xlink data structure xlink_dev->nmb_connected_links =0 ;mutex_init (&xlink_dev->lock);
@@ -168,7 +175,7 @@ static int kmb_xlink_probe(struct platform_device *pdev)/*Allocating Major number*/ if ((alloc_chrdev_region (&xdev,0 ,1 ,"xlinkdev" )) <0 ) {dev_info (&pdev->dev,"Cannot allocate major number\n" ); - goto r_multiplexer; + goto r_dispatcher; }dev_info (&pdev->dev,"Major = %d Minor = %d\n" ,MAJOR (xdev),MINOR (xdev));
@@ -205,6 +212,8 @@ static int kmb_xlink_probe(struct platform_device *pdev)class_destroy (dev_class); r_class:unregister_chrdev_region (xdev,1 ); +r_dispatcher: +xlink_dispatcher_destroy (); r_multiplexer:xlink_multiplexer_destroy ();return -1 ;
@@ -220,6 +229,10 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); +// stop dispatchers and destroy + rc =xlink_dispatcher_destroy (); +if (rc !=X_LINK_SUCCESS ) +pr_err ("Dispatcher destroy failed\n" );mutex_unlock (&xlink->lock);mutex_destroy (&xlink->lock);
@@ -314,6 +327,14 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle = *handle; xlink->nmb_connected_links++;kref_init (&link->refcount); +if (interface !=IPC_INTERFACE ) { +// start dispatcher + rc =xlink_dispatcher_start (link->id, &link->handle); +if (rc) { +pr_err ("dispatcher start failed\n" ); + goto r_cleanup; + } + }// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {
@@ -649,6 +670,7 @@ EXPORT_SYMBOL_GPL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; +int interface =NULL_INTERFACE ;enum xlink_error rc =X_LINK_ERROR ;if (!xlink || !handle)
@@ -661,6 +683,17 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) { +// stop dispatcher + interface =get_interface_from_sw_device_id (link->handle.sw_device_id); +if (interface !=IPC_INTERFACE ) { +// stop dispatcher + rc =xlink_dispatcher_stop (link->id); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("dispatcher stop failed\n" ); +mutex_unlock (&xlink->lock); +return X_LINK_ERROR ; + } + }// deinitialize multiplexer connection rc =xlink_multiplexer_disconnect (link->id);if (rc) {
drivers/misc/xlink-core/xlink-dispatcher.c new file +441 -0
441 lines not on this page · raw message
drivers/misc/xlink-core/xlink-dispatcher.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Dispatcher. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_DISPATCHER_H +#define __XLINK_DISPATCHER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_dispatcher_init (void *dev); + +enum xlink_error xlink_dispatcher_start (int id,struct xlink_handle *handle); + +enum xlink_error xlink_dispatcher_event_add (enum xlink_event_origin origin, +struct xlink_event *event); + +enum xlink_error xlink_dispatcher_stop (int id); + +enum xlink_error xlink_dispatcher_destroy (void ); + +enum xlink_error xlink_dispatcher_ipc_passthru_event_add (struct xlink_event *event); + +#endif /* __XLINK_DISPATCHER_H */
drivers/misc/xlink-core/xlink-multiplexer.c +497 -1
539 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 18/34 xlink-ipc: Add xlink ipc driver
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which interfaces the xLink Core driver with the Keem Bay VPU IPC driver, thus enabling xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
Specifically the driver enables xLink Core to:
* Boot / Reset the VPU IP
* Register to VPU IP event notifications (device connected, device disconnected, WDT event)
* Query the status of the VPU IP (OFF, BUSY, READY, ERROR, RECOVERY)
* Exchange data with the VPU IP, using the Keem Bay IPC mechanism
- Including the ability to send 'volatile' data (i.e., small amount of data, up to 128-bytes that was not allocated in the CPU/VPU shared memory region)
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-ipc.rst | 51 ++ MAINTAINERS | 6 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-ipc/Kconfig | 7 + drivers/misc/xlink-ipc/Makefile | 4 + drivers/misc/xlink-ipc/xlink-ipc.c | 878 +++++++++++++++++++++++++++++ include/linux/xlink-ipc.h | 48 ++ 9 files changed, 997 insertions(+) create mode 100644 Documentation/vpu/xlink-ipc.rst create mode 100644 drivers/misc/xlink-ipc/Kconfig create mode 100644 drivers/misc/xlink-ipc/Makefile create mode 100644 drivers/misc/xlink-ipc/xlink-ipc.c create mode 100644 include/linux/xlink-ipc.h
Documentation/vpu/index.rst +1 -0
@@ -15,3 +15,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie + xlink-ipc
Documentation/vpu/xlink-ipc.rst new file +51 -0
51 lines not on this page · raw message
MAINTAINERS +6 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK IPC SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-ipc/ + ARM/INTEL KEEM BAY XLINK PCIE SUPPORT M: Srikanth Thokala <[email protected]> M: Mark Gross <[email protected]>
drivers/misc/Kconfig +1 -0
@@ -482,4 +482,5 @@ source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" +source "drivers/misc/xlink-ipc/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -58,3 +58,4 @@ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ +obj-$(CONFIG_XLINK_IPC) += xlink-ipc/
drivers/misc/xlink-ipc/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config XLINK_IPC + tristate "Support for XLINK IPC" + depends on KEEMBAY_VPU_IPC + help + XLINK IPC enables the communication/control IPC Sub-System. + + Select M if you have an Intel SoC with a Vision Processing Unit (VPU).
drivers/misc/xlink-ipc/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# +# Makefile for xlink IPC Linux driver +# +obj-$(CONFIG_XLINK_IPC) += xlink-ipc.o
drivers/misc/xlink-ipc/xlink-ipc.c new file +878 -0
878 lines not on this page · raw message
include/linux/xlink-ipc.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 22/34 xlink-core: Enable VPU IP management and runtime control
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable VPU management including, enumeration, boot and runtime control.
Add APIs:
write control data:
used to transmit small, local data
start vpu:
calls boot_device API ( soon to be deprecated )
stop vpu
calls reset_device API ( soon to be deprecated )
reset vpu
calls reset_device API ( soon to be deprecated )
get device name:
Returns the device name for the input device id
This could be a char device path, for example "/dev/ttyUSB0" for a serial device; or it could be a device string description, for example, for PCIE "00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)"
get device list:
Returns the list of software device IDs for all connected physical devices
get device status:
returns the current state of the input device
OFF - The device is off (D3cold/Slot power removed). BUSY - device is busy and not available (device is booting) READY - device is available for use
ERROR - device HW failure is detected
RECOVERY - device is in recovery mode, waiting for recovery operations
boot device:
When used on the remote host - starts the SOC device by calling corresponding function from VPU Driver.
Takes firmware's 'binary_name' as input.
For Linux, the firmware image is expected to be located in '/lib/firmware' folder or its subfolders.
For Linux, 'binary_name' is not a path but an image name that will be searched in the default Linux search paths ('/lib/firmware'). When used on the local host - triggers the booting of VPUIP device.
reset device:
When used on the remote host - resets the device by calling corresponding VPU Driver function.
When used on the local host - resets the VPUIP device
get device mode:
query and returns the current device power mode
set device mode:
used for device throttling or entering various power modes
--- drivers/misc/xlink-core/xlink-core.c | 235 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-defs.h | 2 + drivers/misc/xlink-core/xlink-ioctl.c | 214 ++++++++++++++++++ drivers/misc/xlink-core/xlink-ioctl.h | 9 + drivers/misc/xlink-core/xlink-multiplexer.c | 56 +++++ drivers/misc/xlink-core/xlink-platform.c | 86 +++++++ include/linux/xlink.h | 27 +++ 7 files changed, 629 insertions(+)
drivers/misc/xlink-core/xlink-core.c +235 -0
@@ -73,6 +73,8 @@ struct keembay_xlink_dev {struct mutex lock;// protect access to xlink_dev }; +static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +/* * global variable pointing to our xlink device. *
@@ -264,6 +266,9 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_READ_DATA : rc =ioctl_read_data (arg);break ; +case XL_READ_TO_BUFFER : + rc =ioctl_read_to_buffer (arg); +break ;case XL_WRITE_DATA : rc =ioctl_write_data (arg);break ;
@@ -276,9 +281,39 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_CLOSE_CHANNEL : rc =ioctl_close_channel (arg);break ; +case XL_START_VPU : + rc =ioctl_start_vpu (arg); +break ; +case XL_STOP_VPU : + rc =xlink_stop_vpu (); +break ; +case XL_RESET_VPU : + rc =xlink_stop_vpu (); +break ;case XL_DISCONNECT : rc =ioctl_disconnect (arg);break ; +case XL_GET_DEVICE_NAME : + rc =ioctl_get_device_name (arg); +break ; +case XL_GET_DEVICE_LIST : + rc =ioctl_get_device_list (arg); +break ; +case XL_GET_DEVICE_STATUS : + rc =ioctl_get_device_status (arg); +break ; +case XL_BOOT_DEVICE : + rc =ioctl_boot_device (arg); +break ; +case XL_RESET_DEVICE : + rc =ioctl_reset_device (arg); +break ; +case XL_GET_DEVICE_MODE : + rc =ioctl_get_device_mode (arg); +break ; +case XL_SET_DEVICE_MODE : + rc =ioctl_set_device_mode (arg); +break ; }if (rc)return -EIO ;
@@ -289,6 +324,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)/* * xlink Kernel API. */ +enum xlink_error xlink_stop_vpu (void ) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_reset_device (0x0 );// stop vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_stop_vpu); +enum xlink_error xlink_start_vpu (char *filename) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_boot_device (0x0 , filename);// start vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_start_vpu);enum xlink_error xlink_initialize (void ) {
@@ -527,6 +586,34 @@ enum xlink_error xlink_write_data_user(struct xlink_handle *handle,return rc; } +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size) +{ +struct xlink_event *event; +struct xlink_link *link; +int event_queued =0 ; +enum xlink_error rc; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (size >XLINK_MAX_CONTROL_DATA_SIZE ) +return X_LINK_ERROR ;// TODO: XLink Parameter Error + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + event =xlink_create_event (link->id,XLINK_WRITE_CONTROL_REQ , + &link->handle, chan, size,0 ); +if (!event) +return X_LINK_ERROR ; +memcpy (event->header.control_data, pmessage, size); + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_control_data); +enum xlink_error xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size) {
@@ -711,6 +798,154 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle) }EXPORT_SYMBOL_GPL (xlink_disconnect); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list, +u32 *num_devices) +{ +u32 interface_nmb_devices =0 ; +enum xlink_error rc; +int i; + +if (!xlink) +return X_LINK_ERROR ; +if (!sw_device_id_list || !num_devices) +return X_LINK_ERROR ; +/* loop through each interface and combine the lists */ +for (i =0 ; i <NMB_OF_INTERFACES ; i++) { + rc =xlink_platform_get_device_list (i, sw_device_id_list, + &interface_nmb_devices); +if (!rc) { + *num_devices += interface_nmb_devices; + sw_device_id_list += interface_nmb_devices; + } + interface_nmb_devices =0 ; + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_get_device_list); +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size) +{ +enum xlink_error rc; +int interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!name || !name_size) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_name (interface, handle->sw_device_id, + name, name_size); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_name); +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink) +return X_LINK_ERROR ; +if (!device_status) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_status (interface, handle->sw_device_id, + device_status); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_status); +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!binary_name) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_boot_device (interface, handle->sw_device_id, + binary_name); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_boot_device); +enum xlink_error xlink_reset_device (struct xlink_handle *handle) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_reset_device (interface, handle->sw_device_id); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_reset_device); +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_set_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_set_device_mode); +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_mode);/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-defs.h +2 -0
@@ -101,6 +101,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_REQ ,XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ , +XLINK_WRITE_CONTROL_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -111,6 +112,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_RESP ,XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP , +XLINK_WRITE_CONTROL_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-ioctl.c +214 -0
229 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h +9 -0
@@ -12,10 +12,19 @@int ioctl_connect (unsigned long arg);int ioctl_open_channel (unsigned long arg);int ioctl_read_data (unsigned long arg); +int ioctl_read_to_buffer (unsigned long arg);int ioctl_write_data (unsigned long arg);int ioctl_write_volatile_data (unsigned long arg);int ioctl_release_data (unsigned long arg);int ioctl_close_channel (unsigned long arg); +int ioctl_start_vpu (unsigned long arg);int ioctl_disconnect (unsigned long arg); +int ioctl_get_device_name (unsigned long arg); +int ioctl_get_device_list (unsigned long arg); +int ioctl_get_device_status (unsigned long arg); +int ioctl_boot_device (unsigned long arg); +int ioctl_reset_device (unsigned long arg); +int ioctl_get_device_mode (unsigned long arg); +int ioctl_set_device_mode (unsigned long arg);#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c +56 -0
92 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +86 -0
104 lines not on this page · raw message
include/linux/xlink.h +27 -0
@@ -78,6 +78,10 @@ enum xlink_error xlink_write_data(struct xlink_handle *handle,enum xlink_error xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size); +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size); +enum xlink_error xlink_read_data (struct xlink_handle *handle,u16 chan,u8 **message,u32 *size);
@@ -90,6 +94,29 @@ enum xlink_error xlink_release_data(struct xlink_handle *handle,enum xlink_error xlink_disconnect (struct xlink_handle *handle); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list,u32 *num_devices); + +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size); + +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status); + +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name); + +enum xlink_error xlink_reset_device (struct xlink_handle *handle); + +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode); + +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode); + +enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ + +enum xlink_error xlink_stop_vpu (void );/* depreciated */ +/* API functions to be implemented * * enum xlink_error xlink_write_crc_data(struct xlink_handle *handle,
Signature · 1 line
2.17.1
PATCH v3 23/34 xlink-core: add async channel and events
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable asynchronous channel and event communication.
Add APIs:
data ready callback:
The xLink Data Ready Callback function is used to register a callback function that is invoked when data is ready to be read from a channel
data consumed callback:
The xLink Data Consumed Callback function is used to register a callback function that is invoked when data is consumed by the peer node on a channel
Add event notification handling including APIs:
register device event:
The xLink Register Device Event function is used to register a callback for notification of certain system events. Currently XLink supports 4 such events [0-3] whose meaning is system dependent. Registering for an event means that the callback will be called when the event occurs with 2 parameters the sw_device_id of the device that triggered the event and the event number [0-3]
unregister device event
The xLink Unregister Device Event function is used to unregister events that have previously been registered by register device event API
--- drivers/misc/xlink-core/xlink-core.c | 497 ++++++++++++++++---- drivers/misc/xlink-core/xlink-core.h | 11 +- drivers/misc/xlink-core/xlink-defs.h | 6 +- drivers/misc/xlink-core/xlink-dispatcher.c | 53 +-- drivers/misc/xlink-core/xlink-ioctl.c | 146 +++++- drivers/misc/xlink-core/xlink-ioctl.h | 6 + drivers/misc/xlink-core/xlink-multiplexer.c | 176 +++++-- drivers/misc/xlink-core/xlink-platform.c | 27 ++ include/linux/xlink.h | 15 +- 9 files changed, 757 insertions(+), 180 deletions(-)
drivers/misc/xlink-core/xlink-core.c +411 -86
@@ -55,6 +55,8 @@ static struct cdev xlink_cdev;static long xlink_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +static struct mutex dev_event_lock; +static const struct file_operations fops = { .owner =THIS_MODULE , .unlocked_ioctl = xlink_ioctl,
@@ -66,14 +68,75 @@ struct xlink_link {struct kref refcount; }; +struct xlink_attr { +unsigned long value; +u32 sw_dev_id; +}; +struct keembay_xlink_dev {struct platform_device *pdev;struct xlink_link links[XLINK_MAX_CONNECTIONS ];u32 nmb_connected_links;struct mutex lock;// protect access to xlink_dev +struct xlink_attr eventx[4 ]; +}; + +struct event_info { +struct list_head list; +u32 sw_device_id; +u32 event_type; +u32 user_flag; +xlink_device_event_cb event_notif_fn; }; -static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +// sysfs attribute functions + +static ssize_t eventx_show (struct device *dev,struct device_attribute *attr, +int index,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[index]; + +return sysfs_emit (buf,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event0_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,0 , buf); +} + +static ssize_t event1_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,1 , buf); +} + +static ssize_t event2_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,2 , buf); +} + +static ssize_t event3_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,3 , buf); +} + +static DEVICE_ATTR_RO (event0); +static DEVICE_ATTR_RO (event1); +static DEVICE_ATTR_RO (event2); +static DEVICE_ATTR_RO (event3); +static struct attribute *xlink_sysfs_entries[] = { + &dev_attr_event0.attr, + &dev_attr_event1.attr, + &dev_attr_event2.attr, + &dev_attr_event3.attr, +NULL , +}; + +static const struct attribute_group xlink_sysfs_group = { + .attrs = xlink_sysfs_entries, +}; + +static struct event_info ev_info;/* * global variable pointing to our xlink device.
@@ -207,7 +270,14 @@ static int kmb_xlink_probe(struct platform_device *pdev)dev_info (&pdev->dev,"Cannot add the device to the system\n" ); goto r_class; } +INIT_LIST_HEAD (&ev_info.list); + rc =devm_device_add_group (&pdev->dev, &xlink_sysfs_group); +if (rc) { +dev_err (&pdev->dev,"failed to create sysfs entries: %d\n" , rc); +return rc; + } +mutex_init (&dev_event_lock);return 0 ; r_device:
@@ -231,7 +301,6 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); -// stop dispatchers and destroy rc =xlink_dispatcher_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Dispatcher destroy failed\n" );
@@ -251,7 +320,6 @@ static int kmb_xlink_remove(struct platform_device *pdev)* IOCTL function for User Space access to xlink kernel functions * */ -static long xlink_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {int rc;
@@ -263,6 +331,12 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_OPEN_CHANNEL : rc =ioctl_open_channel (arg);break ; +case XL_DATA_READY_CALLBACK : + rc =ioctl_data_ready_callback (arg); +break ; +case XL_DATA_CONSUMED_CALLBACK : + rc =ioctl_data_consumed_callback (arg); +break ;case XL_READ_DATA : rc =ioctl_read_data (arg);break ;
@@ -275,6 +349,9 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_WRITE_VOLATILE : rc =ioctl_write_volatile_data (arg);break ; +case XL_WRITE_CONTROL_DATA : + rc =ioctl_write_control_data (arg); +break ;case XL_RELEASE_DATA : rc =ioctl_release_data (arg);break ;
@@ -285,10 +362,10 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc =ioctl_start_vpu (arg);break ;case XL_STOP_VPU : - rc =xlink_stop_vpu (); + rc =ioctl_stop_vpu ();break ;case XL_RESET_VPU : - rc =xlink_stop_vpu (); + rc =ioctl_stop_vpu ();break ;case XL_DISCONNECT : rc =ioctl_disconnect (arg);
@@ -314,6 +391,12 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_SET_DEVICE_MODE : rc =ioctl_set_device_mode (arg);break ; +case XL_REGISTER_DEV_EVENT : + rc =ioctl_register_device_event (arg); +break ; +case XL_UNREGISTER_DEV_EVENT : + rc =ioctl_unregister_device_event (arg); +break ; }if (rc)return -EIO ;
@@ -387,14 +470,12 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) xlink->nmb_connected_links++;kref_init (&link->refcount);if (interface !=IPC_INTERFACE ) { -// start dispatcher rc =xlink_dispatcher_start (link->id, &link->handle);if (rc) {pr_err ("dispatcher start failed\n" ); goto r_cleanup; } } -// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {pr_err ("multiplexer connect failed\n" );
@@ -405,7 +486,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle.dev_type, xlink->nmb_connected_links); }else { -// already connected pr_info ("dev 0x%x ALREADY connected - dev_type %d\n" , link->handle.sw_device_id, link->handle.dev_type);
@@ -413,7 +493,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) *handle = link->handle; }mutex_unlock (&xlink->lock); -// TODO: implement ping return X_LINK_SUCCESS ; r_cleanup:
@@ -423,64 +502,109 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) }EXPORT_SYMBOL_GPL (xlink_connect); -enum xlink_error xlink_open_channel (struct xlink_handle *handle, -u16 chan,enum xlink_opmode mode, -u32 data_size,u32 timeout) +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event) {struct xlink_event *event;struct xlink_link *link; -int event_queued =0 ;enum xlink_error rc; +int event_queued =0 ; +char origin ='K' ;if (!xlink || !handle)return X_LINK_ERROR ; +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - - event =xlink_create_event (link->id,XLINK_OPEN_CHANNEL_REQ , - &link->handle, chan, data_size, timeout); + event =xlink_create_event (link->id,XLINK_DATA_READY_CALLBACK_REQ , + &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; - - event->data = (void *)mode; + event->data = data_available_event; + event->callback_origin = origin; +if (!data_available_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued)xlink_destroy_event (event);return rc; } -EXPORT_SYMBOL_GPL (xlink_open_channel); - -enum xlink_error xlink_close_channel (struct xlink_handle *handle, -u16 chan) +EXPORT_SYMBOL_GPL (xlink_data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event) {struct xlink_event *event;struct xlink_link *link;enum xlink_error rc;int event_queued =0 ; +char origin ='K' ;if (!xlink || !handle)return X_LINK_ERROR ; +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - - event =xlink_create_event (link->id,XLINK_CLOSE_CHANNEL_REQ , + event =xlink_create_event (link->id,XLINK_DATA_CONSUMED_CALLBACK_REQ , &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; + event->data = data_consumed_event; + event->callback_origin = origin; +if (!data_consumed_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_data_consumed_event); +enum xlink_error xlink_open_channel (struct xlink_handle *handle, +u16 chan,enum xlink_opmode mode, +u32 data_size,u32 timeout) +{ +struct xlink_event *event; +struct xlink_link *link; +int event_queued =0 ; +enum xlink_error rc; + +if (!xlink || !handle) +return X_LINK_ERROR ; + + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + + event =xlink_create_event (link->id,XLINK_OPEN_CHANNEL_REQ , + &link->handle, chan, data_size, timeout); +if (!event) +return X_LINK_ERROR ; + event->data = (void *)mode; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued)xlink_destroy_event (event);return rc; } -EXPORT_SYMBOL_GPL (xlink_close_channel); +EXPORT_SYMBOL_GPL (xlink_open_channel); -enum xlink_error xlink_write_data (struct xlink_handle *handle, -u16 chan,u8 const *pmessage,u32 size) +enum xlink_error xlink_close_channel (struct xlink_handle *handle, +u16 chan) {struct xlink_event *event;struct xlink_link *link;
@@ -490,38 +614,26 @@ enum xlink_error xlink_write_data(struct xlink_handle *handle,if (!xlink || !handle)return X_LINK_ERROR ; -if (size >XLINK_MAX_DATA_SIZE ) -return X_LINK_ERROR ; - link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - event =xlink_create_event (link->id,XLINK_WRITE_REQ , &link->handle, - chan, size,0 ); + event =xlink_create_event (link->id,XLINK_CLOSE_CHANNEL_REQ , + &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; -if (chan <XLINK_IPC_MAX_CHANNELS && - event->interface ==IPC_INTERFACE ) { -/* only passing message address across IPC interface */ - event->data = &pmessage; - rc =xlink_multiplexer_tx (event, &event_queued); + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued)xlink_destroy_event (event); - }else { - event->data = (u8 *)pmessage; - event->paddr =0 ; - rc =xlink_multiplexer_tx (event, &event_queued); -if (!event_queued) -xlink_destroy_event (event); - } +return rc; } -EXPORT_SYMBOL_GPL (xlink_write_data); +EXPORT_SYMBOL_GPL (xlink_close_channel); -enum xlink_error xlink_write_data_user (struct xlink_handle *handle, -u16 chan,u8 const *pmessage, -u32 size) +static enum xlink_error do_xlink_write_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size,u32 user_flag) {struct xlink_event *event;struct xlink_link *link;
@@ -544,48 +656,78 @@ enum xlink_error xlink_write_data_user(struct xlink_handle *handle, chan, size, 0);if (!event)return X_LINK_ERROR ; - event->user_data =1 ; + event->user_data = user_flag;if (chan <XLINK_IPC_MAX_CHANNELS && event->interface ==IPC_INTERFACE ) {/* only passing message address across IPC interface */ -if (get_user (addr, (u32 __user *)pmessage)) { -xlink_destroy_event (event); -return X_LINK_ERROR ; +if (user_flag) { +if (get_user (addr, (u32 __user *)pmessage)) { +xlink_destroy_event (event); +return X_LINK_ERROR ; + } + event->data = &addr; + }else { + event->data = &pmessage; } - event->data = &addr; rc =xlink_multiplexer_tx (event, &event_queued);xlink_destroy_event (event); }else { - event->data =xlink_platform_allocate (&xlink->pdev->dev, &paddr, - size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); -if (!event->data) { -xlink_destroy_event (event); -return X_LINK_ERROR ; - } -if (copy_from_user (event->data, (void __user *)pmessage, size)) { -xlink_platform_deallocate (&xlink->pdev->dev, - event->data, paddr, size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); -xlink_destroy_event (event); -return X_LINK_ERROR ; +if (user_flag) { + event->data =xlink_platform_allocate (&xlink->pdev->dev, &paddr, + size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); +if (!event->data) { +xlink_destroy_event (event); +return X_LINK_ERROR ; + } +if (copy_from_user (event->data, (void __user *)pmessage, size)) { +xlink_platform_deallocate (&xlink->pdev->dev, + event->data, paddr, size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); +xlink_destroy_event (event); +return X_LINK_ERROR ; + } + event->paddr = paddr; + }else { + event->data = (u8 *)pmessage; + event->paddr =0 ; } - event->paddr = paddr; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued) { -xlink_platform_deallocate (&xlink->pdev->dev, - event->data, paddr, size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); +if (user_flag) { +xlink_platform_deallocate (&xlink->pdev->dev, + event->data, paddr, size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); + }xlink_destroy_event (event); } }return rc; } +enum xlink_error xlink_write_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_data (handle, chan, pmessage, size,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_data); + +enum xlink_error xlink_write_data_user (struct xlink_handle *handle, +u16 chan,u8 const *pmessage,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_data (handle, chan, pmessage, size,1 ); +return rc; +} +enum xlink_error xlink_write_control_data (struct xlink_handle *handle,u16 chan,u8 const *pmessage,u32 size)
@@ -614,16 +756,7 @@ enum xlink_error xlink_write_control_data(struct xlink_handle *handle, }EXPORT_SYMBOL_GPL (xlink_write_control_data); -enum xlink_error xlink_write_volatile (struct xlink_handle *handle, -u16 chan,u8 const *message,u32 size) -{ -enum xlink_error rc =0 ; - - rc =do_xlink_write_volatile (handle, chan, message, size,0 ); -return rc; -} - -enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, +static enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size,u32 user_flag) {
@@ -668,6 +801,26 @@ enum xlink_error do_xlink_write_volatile(struct xlink_handle *handle,return rc; } +enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_volatile (handle, chan, message, size,1 ); +return rc; +} + +enum xlink_error xlink_write_volatile (struct xlink_handle *handle, +u16 chan,u8 const *message,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_volatile (handle, chan, message, size,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_volatile); +enum xlink_error xlink_read_data (struct xlink_handle *handle,u16 chan,u8 **pmessage,u32 *size) {
@@ -757,8 +910,8 @@ EXPORT_SYMBOL_GPL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; -int interface =NULL_INTERFACE ; -enum xlink_error rc =X_LINK_ERROR ; +int interface; +enum xlink_error rc =0 ;if (!xlink || !handle)return X_LINK_ERROR ;
@@ -767,7 +920,6 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)if (!link)return X_LINK_ERROR ; -// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) {// stop dispatcher
@@ -946,6 +1098,179 @@ enum xlink_error xlink_get_device_mode(struct xlink_handle *handle,return rc; }EXPORT_SYMBOL_GPL (xlink_get_device_mode); + +static int xlink_device_event_handler (u32 sw_device_id,u32 event_type) +{ +struct event_info *events =NULL ; +xlink_device_event_cb event_cb; +bool found = false; +char event_attr[7 ]; + +mutex_lock (&dev_event_lock); +// find sw_device_id, event_type in list +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_device_id && + events->event_type == event_type) { + event_cb = events->event_notif_fn; + found = true; +break ; + } + } + } +if (found) { +if (events->user_flag) { + xlink->eventx[events->event_type].value = events->event_type; + xlink->eventx[events->event_type].sw_dev_id = sw_device_id; +sprintf (event_attr,"event%d" , events->event_type); +sysfs_notify (&xlink->pdev->dev.kobj,NULL , event_attr); + }else { +if (event_cb) { +event_cb (sw_device_id, event_type); + }else { +pr_info ("No callback found for sw_device_id : 0x%x event type %d\n" , + sw_device_id, event_type); +mutex_unlock (&dev_event_lock); +return X_LINK_ERROR ; + } + } +pr_info ("sysfs_notify event %d swdev_id %xs\n" , + events->event_type, sw_device_id); + } +mutex_unlock (&dev_event_lock); +return X_LINK_SUCCESS ; +} + +static bool event_registered (u32 sw_dev_id,u32 event) +{ +struct event_info *events =NULL ; + +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_dev_id && + events->event_type == event) { +return true; + } + } + } +return false; +} + +static enum xlink_error do_xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn, +u32 user_flag) +{ +struct event_info *events; +u32 interface; +u32 event; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { + events =kzalloc (sizeof (*events),GFP_KERNEL ); +if (!events) +return X_LINK_ERROR ; + event = *event_list; + events->sw_device_id = handle->sw_device_id; + events->event_notif_fn = event_notif_fn; + events->event_type = *event_list++; + events->user_flag = user_flag; +if (user_flag) { +/* only add to list once if userspace */ +/* xlink userspace handles multi process callbacks */ +if (event_registered (handle->sw_device_id, event)) { +pr_info ("xlink-core: Event 0x%x - %d already registered\n" , + handle->sw_device_id, event); +kfree (events); +continue ; + } + } +pr_info ("xlink-core:Events: sw_device_id 0x%x event %d fn %p user_flag %d\n" , + events->sw_device_id, events->event_type, + events->event_notif_fn, events->user_flag); +list_add_tail (&events->list, &ev_info.list); + } + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_register_for_events (interface, handle->sw_device_id, + xlink_device_event_handler); +return X_LINK_SUCCESS ; +} + +enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,1 ); +return rc; +} + +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_register_device_event); + +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events) +{ +struct event_info *events =NULL ; +u32 interface; +int found =0 ; +int count =0 ; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { +list_for_each_entry (events, &ev_info.list, list) { +if (events->sw_device_id == handle->sw_device_id && + events->event_type == event_list[i]) { + found =1 ; +break ; + } + } +if (!events || !found) +return X_LINK_ERROR ; +pr_info ("removing event %d for sw_device_id 0x%x\n" , + events->event_type, events->sw_device_id); +list_del (&events->list); +kfree (events); + } +// check if any events left for this sw_device_id +// are still registered ( in list ) +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == handle->sw_device_id) { + count++; +break ; + } + } + } +if (count ==0 ) { + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_unregister_for_events (interface, handle->sw_device_id); + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_unregister_device_event); +/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-core.h +7 -4
@@ -12,11 +12,14 @@#define NUM_REG_EVENTS 4 -enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, -u16 chan,u8 const *message, -u32 size,u32 user_flag); -enum xlink_error xlink_write_data_user (struct xlink_handle *handle,u16 chan,u8 const *pmessage,u32 size); +enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size);#endif /* XLINK_CORE_H_ */
drivers/misc/xlink-core/xlink-defs.h +5 -1
@@ -35,7 +35,7 @@#define CONTROL_CHANNEL_TIMEOUT_MS 0U // wait indefinitely#define SIGXLNK 44 // signal XLink uses for callback signalling -#define UNUSED (x) (void)(x) +#define UNUSED (x) ((void)(x))// the end of the IPC channel range (starting at zero) #define XLINK_IPC_MAX_CHANNELS 1024
@@ -102,6 +102,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ ,XLINK_WRITE_CONTROL_REQ , +XLINK_DATA_READY_CALLBACK_REQ , +XLINK_DATA_CONSUMED_CALLBACK_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -113,6 +115,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP ,XLINK_WRITE_CONTROL_RESP , +XLINK_DATA_READY_CALLBACK_RESP , +XLINK_DATA_CONSUMED_CALLBACK_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-dispatcher.c +24 -29
148 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.c +137 -9
167 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h +6 -0
@@ -14,10 +14,12 @@ int ioctl_open_channel(unsigned long arg);int ioctl_read_data (unsigned long arg);int ioctl_read_to_buffer (unsigned long arg);int ioctl_write_data (unsigned long arg); +int ioctl_write_control_data (unsigned long arg);int ioctl_write_volatile_data (unsigned long arg);int ioctl_release_data (unsigned long arg);int ioctl_close_channel (unsigned long arg);int ioctl_start_vpu (unsigned long arg); +int ioctl_stop_vpu (void );int ioctl_disconnect (unsigned long arg);int ioctl_get_device_name (unsigned long arg);int ioctl_get_device_list (unsigned long arg);
@@ -26,5 +28,9 @@ int ioctl_boot_device(unsigned long arg);int ioctl_reset_device (unsigned long arg);int ioctl_get_device_mode (unsigned long arg);int ioctl_set_device_mode (unsigned long arg); +int ioctl_register_device_event (unsigned long arg); +int ioctl_unregister_device_event (unsigned long arg); +int ioctl_data_ready_callback (unsigned long arg); +int ioctl_data_consumed_callback (unsigned long arg);#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c +127 -49
257 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +27 -0
@@ -56,6 +56,11 @@ static inline int xlink_ipc_close_channel(u32 sw_device_id, u32 channel) {return -1 ; } +static inline int xlink_ipc_register_for_events (u32 sw_device_id, +int (*callback)(u32 sw_device_id,u32 event)) +{return -1 ; } +static inline int xlink_ipc_unregister_for_events (u32 sw_device_id) +{return -1 ; }#endif /* CONFIG_XLINK_LOCAL_HOST */ /*
@@ -95,6 +100,13 @@ static int (*open_chan_fcts[NMB_OF_INTERFACES])(u32, u32) = {static int (*close_chan_fcts[NMB_OF_INTERFACES ])(u32 ,u32 ) = { xlink_ipc_close_channel,NULL ,NULL ,NULL }; +static int (*register_for_events_fcts[NMB_OF_INTERFACES ])(u32 , +int (*callback)(u32 sw_device_id,u32 event)) = { + xlink_ipc_register_for_events, + xlink_pcie_register_device_event, +NULL ,NULL }; +static int (*unregister_for_events_fcts[NMB_OF_INTERFACES ])(u32 ) = { + xlink_ipc_unregister_for_events, xlink_pcie_unregister_device_event,NULL ,NULL };/* * xlink low-level driver interface
@@ -207,6 +219,21 @@ int xlink_platform_close_channel(u32 interface, u32 sw_device_id,return close_chan_fcts[interface](sw_device_id, channel); } +int xlink_platform_register_for_events (u32 interface,u32 sw_device_id, +xlink_device_event_cb event_notif_fn) +{ +if (interface >=NMB_OF_INTERFACES || !register_for_events_fcts[interface]) +return -1 ; +return register_for_events_fcts[interface](sw_device_id, event_notif_fn); +} + +int xlink_platform_unregister_for_events (u32 interface,u32 sw_device_id) +{ +if (interface >=NMB_OF_INTERFACES || !unregister_for_events_fcts[interface]) +return -1 ; +return unregister_for_events_fcts[interface](sw_device_id); +} +void *xlink_platform_allocate (struct device *dev,dma_addr_t *handle,u32 size,u32 alignment,enum xlink_memory_region region)
include/linux/xlink.h +13 -2
@@ -70,6 +70,12 @@ enum xlink_error xlink_open_channel(struct xlink_handle *handle, u16 chan, enum xlink_opmode mode, u32 data_size, u32 timeout); +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event);enum xlink_error xlink_close_channel (struct xlink_handle *handle,u16 chan); enum xlink_error xlink_write_data(struct xlink_handle *handle,
@@ -113,9 +119,14 @@ enum xlink_error xlink_set_device_mode(struct xlink_handle *handle,enum xlink_error xlink_get_device_mode (struct xlink_handle *handle,enum xlink_device_power_mode *power_mode); -enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events); +enum xlink_error xlink_start_vpu (char *filename);/* deprecated */ -enum xlink_error xlink_stop_vpu (void );/* depreciated */ +enum xlink_error xlink_stop_vpu (void );/* deprecated */ /* API functions to be implemented *
Signature · 1 line
2.17.1
PATCH v3 24/34 dt-bindings: misc: Add Keem Bay vpumgr
In reply to [email protected]From: "Li, Tingqian" <[email protected]>
Add DT binding schema for VPU on Keem Bay ASoC platform
--- .../bindings/misc/intel,keembay-vpu-mgr.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml
Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml new file +48 -0
@@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +# Copyright (C) 2020 Intel +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/intel,keembay-vpu-mgr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel VPU manager bindings + +maintainers: + - Li, Tingqian <[email protected]> + - Zhou, Luwei <[email protected]> + +description: | + The Intel VPU manager provides shared memory and process + depedent context management for Intel VPU hardware IP. + +properties: + compatible: + items: + - enum: + - intel,keembay-vpu-mgr + - intel,keembay-vpusmm + + memory-region: + description: + phandle to a node describing reserved memory (System RAM memory) + used by VPU (see bindings/reserved-memory/reserved-memory.txt) + maxItems: 1 + + intel,keembay-vpu-ipc-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + the index of the VPU slice to be managed. Default is 0. + +required: + - compatible + - memory-region + +additionalProperties: false + +examples: + - | + vpumgr0 { + compatible = "intel,keembay-vpu-mgr"; + memory-region = <&vpu_reserved>; + intel,keembay-vpu-ipc-id = <0x0>; + };
Signature · 1 line
2.17.1
PATCH v4 19/34 xlink-core: Add xlink core device tree bindings
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add device tree bindings for keembay-xlink.
--- .../bindings/misc/intel,keembay-xlink.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml
Documentation/devicetree/bindings/misc/intel,keembay-xlink.yaml new file +29 -0
@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright (c) Intel Corporation. All rights reserved. +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,keembay-xlink.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Keem Bay xlink + +maintainers: + - Seamus Kelly <[email protected]> + +description: | + The Keem Bay xlink driver enables the communication/control sub-system + for internal and external communications to the Intel Keem Bay SoC. + +properties: + compatible: + oneOf: + - items: + - const: intel,keembay-xlink + +additionalProperties: False + +examples: + - | + xlink { + compatible = "intel,keembay-xlink"; + };
Signature · 1 line
2.17.1
PATCH v4 20/34 xlink-core: Add xlink core driver xLink
In reply to [email protected]From: Seamus Kelly <[email protected]>
Add xLink driver, which provides an abstracted control and communication subsystem based on channel identification.
It is intended to support VPU technology both at SoC level as well as at IP level, over multiple interfaces. This initial patch enables local host user mode to open/close/read/write via IOCTLs.
Specifically the driver enables application/process to:
* Access a common xLink API across all interfaces from both kernel and user space.
* Call typical APIs types (open, close, read, write) that you would associate with a communication interface.
* Call other APIs that are related to other functions that the device can perform e.g. boot, reset get/set device mode. Device mode refers to the power load of the VPU and an API can be used to read and control it.
* Use multiple commnication channels that the driver manages from one interface to another, providing routing of data through these multiple channels across a single physical interface.
xLink: Add xLink Core device tree bindings
Add device tree bindings for the xLink Core driver which enables xLink to control and communicate with the VPU IP present on the Intel Keem Bay SoC.
--- Documentation/vpu/index.rst | 1 + Documentation/vpu/xlink-core.rst | 81 +++ MAINTAINERS | 12 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-core/Kconfig | 33 + drivers/misc/xlink-core/Makefile | 5 + drivers/misc/xlink-core/xlink-core.c | 738 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-core.h | 22 + drivers/misc/xlink-core/xlink-defs.h | 175 +++++ drivers/misc/xlink-core/xlink-ioctl.c | 212 ++++++ drivers/misc/xlink-core/xlink-ioctl.h | 21 + drivers/misc/xlink-core/xlink-multiplexer.c | 534 ++++++++++++++ drivers/misc/xlink-core/xlink-multiplexer.h | 35 + drivers/misc/xlink-core/xlink-platform.c | 160 +++++ drivers/misc/xlink-core/xlink-platform.h | 65 ++ include/linux/xlink.h | 108 +++ include/uapi/misc/xlink_uapi.h | 145 ++++ 18 files changed, 2349 insertions(+) create mode 100644 Documentation/vpu/xlink-core.rst create mode 100644 drivers/misc/xlink-core/Kconfig create mode 100644 drivers/misc/xlink-core/Makefile create mode 100644 drivers/misc/xlink-core/xlink-core.c create mode 100644 drivers/misc/xlink-core/xlink-core.h create mode 100644 drivers/misc/xlink-core/xlink-defs.h create mode 100644 drivers/misc/xlink-core/xlink-ioctl.c create mode 100644 drivers/misc/xlink-core/xlink-ioctl.h create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.c create mode 100644 drivers/misc/xlink-core/xlink-multiplexer.h create mode 100644 drivers/misc/xlink-core/xlink-platform.c create mode 100644 drivers/misc/xlink-core/xlink-platform.h create mode 100644 include/linux/xlink.h create mode 100644 include/uapi/misc/xlink_uapi.h
Documentation/vpu/index.rst +1 -0
@@ -16,3 +16,4 @@ This documentation contains information for the Intel VPU stack. vpu-stack-overview xlink-pcie xlink-ipc + xlink-core
Documentation/vpu/xlink-core.rst new file +81 -0
81 lines not on this page · raw message
MAINTAINERS +12 -0
@@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM/INTEL XLINK CORE SUPPORT +M: Seamus Kelly <[email protected]> +M: Mark Gross <[email protected]> +S: Supported +F: drivers/misc/xlink-core/ + ARM/INTEL XLINK IPC SUPPORT M: Seamus Kelly <[email protected]> M: Mark Gross <[email protected]>
@@ -1973,6 +1979,12 @@ M: Mark Gross <[email protected]> S: Supported F: drivers/misc/xlink-pcie/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Supported +F: drivers/misc/hddl_device/ +F: drivers/misc/intel_tsens/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -483,4 +483,5 @@ source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" +source "drivers/misc/xlink-core/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -59,3 +59,4 @@ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ +obj-$(CONFIG_XLINK_CORE) += xlink-core/
drivers/misc/xlink-core/Kconfig new file +33 -0
@@ -0,0 +1,33 @@ +config XLINK_CORE + tristate "Support for XLINK CORE" + depends on ((XLINK_PCIE_RH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER) || (XLINK_LOCAL_HOST && (XLINK_PCIE_LH_DRIVER || XBAY_XLINK_PCIE_RH_DRIVER))) + help + XLINK CORE enables the communication/control subsystem. + + If unsure, say N. + + To compile this driver as a module, choose M here: the + module will be called xlink.ko. + +config XLINK_LOCAL_HOST + tristate "Support for XLINK LOCAL HOST" + depends on XLINK_IPC + help + XLINK LOCAL HOST enables local host functionality for + the communication/control Sub-System. + + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) Local Host core. + + If building for a Remote Host kernel, say N. + +config XLINK_PSS + tristate "Support for XLINK PSS (Pre-Silicon Solution)" + depends on XLINK_LOCAL_HOST + help + XLINK PSS enables the communication/control subsystem on a PSS platform. + + Enable this config when building the kernel for the Intel Vision + Processing Unit (VPU) in a simulated env. + + If building for a VPU silicon, say N.
drivers/misc/xlink-core/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for Keem Bay xlink Linux driver +# +obj-$(CONFIG_XLINK_CORE) += xlink.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o xlink-ioctl.o
drivers/misc/xlink-core/xlink-core.c new file +738 -0
738 lines not on this page · raw message
drivers/misc/xlink-core/xlink-core.h new file +22 -0
@@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink core header file. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_CORE_H_ +#define XLINK_CORE_H_ +#include "xlink-defs.h" + +#define NUM_REG_EVENTS 4 + +enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size,u32 user_flag); + +enum xlink_error xlink_write_data_user (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size); +#endif /* XLINK_CORE_H_ */
drivers/misc/xlink-core/xlink-defs.h new file +175 -0
175 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.c new file +212 -0
212 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink ioctl header files. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ + +#ifndef XLINK_IOCTL_H_ +#define XLINK_IOCTL_H_ + +int ioctl_connect (unsigned long arg); +int ioctl_open_channel (unsigned long arg); +int ioctl_read_data (unsigned long arg); +int ioctl_write_data (unsigned long arg); +int ioctl_write_volatile_data (unsigned long arg); +int ioctl_release_data (unsigned long arg); +int ioctl_close_channel (unsigned long arg); +int ioctl_disconnect (unsigned long arg); + +#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c new file +534 -0
534 lines not on this page · raw message
drivers/misc/xlink-core/xlink-multiplexer.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Multiplexer. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_MULTIPLEXER_H +#define __XLINK_MULTIPLEXER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_multiplexer_init (void *dev); + +enum xlink_error xlink_multiplexer_connect (u32 link_id); + +enum xlink_error xlink_multiplexer_disconnect (u32 link_id); + +enum xlink_error xlink_multiplexer_destroy (void ); + +enum xlink_error xlink_multiplexer_tx (struct xlink_event *event, +int *event_queued); + +enum xlink_error xlink_multiplexer_rx (struct xlink_event *event); + +enum xlink_error xlink_passthrough (struct xlink_event *event); + +void *find_allocated_buffer (dma_addr_t paddr); + +int unregister_allocated_buffer (void *buf,dma_addr_t paddr); + +int core_release_packet_from_channel (u32 link_id,uint16_t chan, +uint8_t *const addr); + +#endif /* __XLINK_MULTIPLEXER_H */
drivers/misc/xlink-core/xlink-platform.c new file +160 -0
160 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.h new file +65 -0
65 lines not on this page · raw message
include/linux/xlink.h new file +108 -0
108 lines not on this page · raw message
include/uapi/misc/xlink_uapi.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 25/34 misc: Add Keem Bay VPU manager
In reply to [email protected]From: "Li, Tingqian" <[email protected]>
VPU IP on Keem Bay SOC is a vision acceleration IP complex under the control of a RTOS-based firmware (running on RISC MCU inside the VPU IP) serving user-space application running on CPU side for HW accelerated computer vision tasks.
This module is kernel counterpart of the VPUAL(VPU abstraction layer) which bridges firmware on VPU side and applications on CPU user-space, it assists firmware on VPU side serving multiple user space application processes on CPU side concurrently while also performing necessary data buffer management on behave of VPU IP.
objmgr provides basic infrastructure for create/destroy VPU side software object concurrently on demand of user-space application and also automatically release leaked objects during handling of application termination. Note this module only cares about the life-cycle of such objects, it's up to the application and firmware to define the behavior/operations of each object.
objmgr does it's job by communicating with firmware through a fixed reserved xlink channel, using a very simple message protocol.
smm provides DMABuf allocation/import facilities to allow user-space app pass data to/from VPU in zero-copy fashion. it also provided a convenient ioctl function for converting virtual pointer of a mem-mapped and imported DMABuf into it's corresponding dma address, to allow user-space app to specify the sub-regions of a bigger DMABuf to be processed by VPU.
--- drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/vpumgr/Kconfig | 9 + drivers/misc/vpumgr/Makefile | 3 + drivers/misc/vpumgr/vpu_common.h | 31 ++ drivers/misc/vpumgr/vpu_mgr.c | 370 ++++++++++++++++++++ drivers/misc/vpumgr/vpu_smm.c | 554 +++++++++++++++++++++++++++++ drivers/misc/vpumgr/vpu_smm.h | 30 ++ drivers/misc/vpumgr/vpu_vcm.c | 584 +++++++++++++++++++++++++++++++ drivers/misc/vpumgr/vpu_vcm.h | 84 +++++ include/uapi/misc/vpumgr.h | 64 ++++ 11 files changed, 1731 insertions(+) create mode 100644 drivers/misc/vpumgr/Kconfig create mode 100644 drivers/misc/vpumgr/Makefile create mode 100644 drivers/misc/vpumgr/vpu_common.h create mode 100644 drivers/misc/vpumgr/vpu_mgr.c create mode 100644 drivers/misc/vpumgr/vpu_smm.c create mode 100644 drivers/misc/vpumgr/vpu_smm.h create mode 100644 drivers/misc/vpumgr/vpu_vcm.c create mode 100644 drivers/misc/vpumgr/vpu_vcm.h create mode 100644 include/uapi/misc/vpumgr.h
drivers/misc/Kconfig +1 -0
@@ -484,4 +484,5 @@ source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" +source "drivers/misc/vpumgr/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -60,3 +60,4 @@ obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ +obj-$(CONFIG_VPUMGR) += vpumgr/
drivers/misc/vpumgr/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config VPUMGR + tristate "VPU Manager" + depends on ARM64 && XLINK_CORE + help + VPUMGR manages life-cycle of VPU related resources which were + dynamically allocated on demands of user-space application + + Select y or m if you have a processor including the Intel + Vision Processor (VPU) on it.
drivers/misc/vpumgr/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_VPUMGR) += vpumgr.o +vpumgr-objs := vpu_mgr.o vpu_smm.o vpu_vcm.o
drivers/misc/vpumgr/vpu_common.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only +* VPUMGR Kernel module - common definition +* Copyright (C) 2020-2021 Intel Corporation +*/ +#ifndef _VPU_COMMON_H +#define _VPU_COMMON_H +#include <linux/cdev.h> +#include <linux/platform_device.h> + +#include <uapi/misc/vpumgr.h> + +#include "vpu_vcm.h" + +/* there will be one such device for each HW instance */ +struct vpumgr_device { +struct device *sdev; +struct device *dev; +dev_t devnum; +struct cdev cdev; +struct platform_device *pdev; + +struct vcm_dev vcm; +struct dentry *debugfs_root; + +struct mutex client_mutex;/* protect client_list */ +struct list_head client_list; +}; + +#define XLINK_INVALID_SW_DEVID 0xDEADBEEF + +#endif
drivers/misc/vpumgr/vpu_mgr.c new file +370 -0
370 lines not on this page · raw message
drivers/misc/vpumgr/vpu_smm.c new file +554 -0
554 lines not on this page · raw message
drivers/misc/vpumgr/vpu_smm.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only +* Copyright (C) 2020 Intel Corporation +*/ +#ifndef _VPU_SMM_H +#define _VPU_SMM_H +#include <linux/kernel.h> +#include <linux/rbtree.h> + +#include "vpu_common.h" + +struct vpumgr_smm { +struct vpumgr_device *vdev; +struct rb_root imp_rb; +struct mutex imp_rb_lock;/* protects imp_rb */ +}; + +int smm_init (struct vpumgr_device *vdev); +int smm_fini (struct vpumgr_device *vdev); + +int smm_open (struct vpumgr_smm *sess,struct vpumgr_device *vdev); +int smm_close (struct vpumgr_smm *sess); + +int smm_alloc (struct vpumgr_smm *sess,struct vpumgr_args_alloc *arg); +int smm_import (struct vpumgr_smm *sess,struct vpumgr_args_import *arg); +int smm_unimport (struct vpumgr_smm *sess,int *p_dmabuf_fd); +int smm_ptr2vpu (struct vpumgr_smm *sess,unsigned long *arg); + +int smm_debugfs_stats_show (struct seq_file *file,struct vpumgr_smm *sess); + +#endif
drivers/misc/vpumgr/vpu_vcm.c new file +584 -0
584 lines not on this page · raw message
drivers/misc/vpumgr/vpu_vcm.h new file +84 -0
84 lines not on this page · raw message
include/uapi/misc/vpumgr.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH v3 25/34] misc: Add Keem Bay VPU manager
drivers/misc/vpumgr/Kconfig line 6
Quoted 12 lines · On 1/29/21 6:20 PM, [email protected] wrote:
drivers/misc/vpumgr/Kconfig new file +6
-0@@ -0,0 +1,9 @@ +config VPUMGR + tristate "VPU Manager" + depends on ARM64 && XLINK_CORE + help + VPUMGR manages life-cycle of VPU related resources which were + dynamically allocated on demands of user-space application
End above sentence with a period ('.').
Hm, same as I said the previous round of patches (also v3).
Quoted 3 lines
drivers/misc/vpumgr/Kconfig new file +3
-0+ + Select y or m if you have a processor including the Intel + Vision Processor (VPU) on it.
Signature · 1 line
~Randy
PATCH v3 26/34 dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
--- .../bindings/misc/intel,intel-tsens.yaml | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml new file +122 -0
@@ -0,0 +1,122 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,intel_tsens.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Temperature sensors in Bay series + +maintainers: + - Udhayakumar C <[email protected]> + +description: | + The tsens driver enables reading of onchip sensors present + in the Intel Bay SoC. + Each subnode of the tsens represents sensors available + on the soc. + +select: false + +properties: + compatible: + items: + - const: intel,intel-tsens + + plat_name: + contains: + enum: + - intel,keembay_thermal + + reg: + minItems: 1 + maxItems: 2 + + clocks: + items: + - description: thermal sensor clock + + clk-rate: + minItems: 1 + maxItems: 1 + additionalItems: false + items: + - description: thermal sensor clock freq + + sensor_name: + type: object + description: + Details to configure sensor trip points and its types. + + properties: + passive_delay: + minItems: 1 + maxItems: 1 + description: number of milliseconds to wait between polls when + performing passive cooling + + polling_delay: + minItems: 1 + maxItems: 1 + description: number of milliseconds to wait between polls when checking + whether trip points have been crossed (0 for interrupt + driven systems) + + trip_temp: + minItems: 1 + description: temperature for trip points + + trip_type: + minItems: 1 + description: trip type list for trip points + + required: + - passive_delay + - polling_delay + - trip_temp + - trip_type + +required: + - compatible + +additionalProperties: false + +examples: + - | + tsens: tsens@20260000 { + compatible = "intel,intel-tsens"; + status = "disabled"; + #address-cells = <2>; + #size-cells = <2>; + plat_name = "intel,keembay_thermal"; + reg = <0x0 0x20260000 0x0 0x100>; + clocks = <&scmi_clk>; + clk-rate = <1250000>; + + mss { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + css { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + nce { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + soc { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + };
Signature · 1 line
2.17.1
PATCH v3 27/34 misc: Tsens ARM host thermal driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add tsens ARM host thermal driver for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
---------------- -------------------------- | Platform | | Thermal Daemon | | Management SW| | | ---------------- -------------------------- | Intel tsens | | intel tsens i2c slave | | i2c client | | and thermal driver | ---------------- -------------------------- | XLINK I2C | | XLINK I2C Slave | | controller | <=========> | controller | ---------------- smbus --------------------------
intel tsens module:
-------------------
The tsens module enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms. In the tsens module various junction and SoC temperatures are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsystem will be used by platform manageability software running in IA host.
- Local Host driver
* Intended for ARM CPU
* It is based on Thermal and I2C slave Framework
* Driver path:
{tree}/drivers/misc/intel_tsens/intel_tsens_thermal.c
Local host and Remote host drivers communicates using XLINK I2C SMBUS protocol.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/intel_tsens_sensor.rst | 67 ++ MAINTAINERS | 5 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/intel_tsens/Kconfig | 15 + drivers/misc/intel_tsens/Makefile | 7 + .../misc/intel_tsens/intel_tsens_thermal.c | 651 ++++++++++++++++++ .../misc/intel_tsens/intel_tsens_thermal.h | 38 + include/linux/hddl_device.h | 153 ++++ 10 files changed, 939 insertions(+) create mode 100644 Documentation/hwmon/intel_tsens_sensor.rst create mode 100644 drivers/misc/intel_tsens/Kconfig create mode 100644 drivers/misc/intel_tsens/Makefile create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.h create mode 100644 include/linux/hddl_device.h
Documentation/hwmon/index.rst +1 -0
@@ -80,6 +80,7 @@ Hardware Monitoring Kernel Drivers ir38064 isl68137 it87 + intel_tsens_sensor.rst jc42 k10temp k8temp
Documentation/hwmon/intel_tsens_sensor.rst new file +67 -0
67 lines not on this page · raw message
MAINTAINERS +5 -0
@@ -1985,6 +1985,11 @@ S: Supported F: drivers/misc/hddl_device/ F: drivers/misc/intel_tsens/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Supported +F: drivers/misc/intel_tsens/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -485,4 +485,5 @@ source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" +source "drivers/misc/intel_tsens/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -61,3 +61,4 @@ obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ +obj-y += intel_tsens/
drivers/misc/intel_tsens/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config INTEL_TSENS_LOCAL_HOST + bool "Temperature sensor driver for intel tsens" + select THERMAL + help + This option enables tsens thermal local Host driver. + + This driver is used for reporting thermal data via thermal + framework. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/intel_tsens/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for intel tsens Thermal Linux driver +# + +obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o
drivers/misc/intel_tsens/intel_tsens_thermal.c new file +651 -0
651 lines not on this page · raw message
drivers/misc/intel_tsens/intel_tsens_thermal.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* +* Intel tsens thermal Driver +* +* Copyright (C) 2020 Intel Corporation +* +*/ + +#ifndef _LINUX_INTEL_TSENS_H +#define _LINUX_INTEL_TSENS_H + +#include <linux/platform_device.h> +#include <linux/thermal.h> + +struct intel_tsens_plat_data { +const char *name; +void __iomem *base_addr; +int (*get_temp)(struct platform_device *pdev,int type,int *temp); +void *pdata; +}; + +struct intel_tsens_plat_info { +const char *plat_name; +int id; +struct platform_device *pdev; +void __iomem *base_addr; +}; + +struct intel_tsens_i2c_plat_data { +int (*get_temp)(int type,int *temp,void *pdata); +void *pdata; +}; + +/* TSENS i2c platform data */ +extern struct intel_tsens_i2c_plat_data i2c_plat_data; + +#endif /* _LINUX_INTEL_TSENS_H */
include/linux/hddl_device.h new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 28/34 misc: Intel tsens IA host driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add Intel tsens IA host driver for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
---------------- -------------------------- | Platform | | Thermal Daemon | | Management SW| | | ---------------- -------------------------- | Intel tsens | | intel tsens i2c slave | | i2c client | | and thermal driver | ---------------- -------------------------- | XLINK I2C | | XLINK I2C Slave | | controller | <=========> | controller | ---------------- xlink smbus --------------------------
intel tsens module:
-------------------
The tsens module enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms.In the tsens module various junction and SoC temperatures are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsystem will be used by platform manageability software running in IA host.
- Remote Host driver
* Intended for IA CPU
* It is a I2C client driver
* Driver path:
{tree}/drivers/misc/intel_tsens/intel_tsens_host.c
Local host and Remote host drivers communicates using I2C SMBUS protocol.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/intel_tsens_host.rst | 71 ++++ drivers/misc/intel_tsens/Kconfig | 13 + drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/intel_tsens_host.c | 351 ++++++++++++++++++++ include/linux/intel_tsens_host.h | 34 ++ 6 files changed, 471 insertions(+) create mode 100644 Documentation/hwmon/intel_tsens_host.rst create mode 100644 drivers/misc/intel_tsens/intel_tsens_host.c create mode 100644 include/linux/intel_tsens_host.h
Documentation/hwmon/index.rst +1 -0
@@ -81,6 +81,7 @@ Hardware Monitoring Kernel Drivers isl68137 it87 intel_tsens_sensor.rst + intel_tsens_host.rst jc42 k10temp k8temp
Documentation/hwmon/intel_tsens_host.rst new file +71 -0
71 lines not on this page · raw message
drivers/misc/intel_tsens/Kconfig +13 -0
@@ -13,3 +13,16 @@ config INTEL_TSENS_LOCAL_HOST management controller. Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. + +config INTEL_TSENS_IA_HOST + tristate "Temperature sensor driver for intel tsens remote host" + depends on I2C && THERMAL + depends on I2C_SMBUS + help + This option enables tsens i2c and thermal local Host driver. + + This driver is used for reading thermal data via I2C SMBUS + and registers itself to thermal framework, which can be + used by thermal daemon in remote IA host + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/intel_tsens/Makefile +1 -0
@@ -5,3 +5,4 @@ # obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o +obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o
drivers/misc/intel_tsens/intel_tsens_host.c new file +351 -0
351 lines not on this page · raw message
include/linux/intel_tsens_host.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* +* Intel tsens host I2C thermal Driver +* +* Copyright (C) 2020 Intel Corporation +* +*/ + +#ifndef _LINUX_INTEL_TSENS_HOST_DEVICE_H +#define _LINUX_INTEL_TSENS_HOST_DEVICE_H + +struct intel_tsens_host_trip_info { +enum thermal_trip_type trip_type; +int temp; +} __packed__aligned(4) ; + +struct intel_tsens_host { +const char *sensor_name_smbus; +const char *sensor_name_xlk; +struct intel_tsens_data *t_data; +struct intel_tsens_host_trip_info **trip_info; +u32 device_id; +struct i2c_client *i2c_xlk; +struct i2c_client *i2c_smbus; +struct thermal_zone_device *tz_xlk; +struct thermal_zone_device *tz_smbus; +}; + +struct intel_tsens_host_plat_data { +int nsens; +struct intel_tsens_host **tsens; +}; +#endif /*_LINUX_INTEL_TSENS_HOST_DEVICE_H*/
Signature · 1 line
2.17.1
Re: [PATCH v3 28/34] misc: Intel tsens IA host driver.
Quoted 4 lines · On Fri, 2021-01-29 at 18:20 -0800, [email protected] wrote:
From: "C, Udhayakumar" <[email protected]>
Add Intel tsens IA host driver for Intel Edge.AI Computer Vision platforms.
[]
drivers/misc/intel_tsens/intel_tsens_host.c
Quoted 1 line
drivers/misc/intel_tsens/intel_tsens_host.c +0
-0
[]
drivers/misc/intel_tsens/intel_tsens_host.c line 52
Quoted 9 lines
drivers/misc/intel_tsens/intel_tsens_host.c +9
-0+static int tsens_i2c_smbus_read_byte_data (struct i2c_client *i2c,u8 command, +u8 *i2c_val) +{ +union i2c_smbus_data data; +int status; + + status =i2c_smbus_xfer (i2c->adapter, i2c->addr, i2c->flags, +I2C_SMBUS_READ , command, +I2C_SMBUS_BYTE_DATA , &data);
this can fail
drivers/misc/intel_tsens/intel_tsens_host.c line 53
Quoted 1 line
drivers/misc/intel_tsens/intel_tsens_host.c +1
-0+ *i2c_val = data.byte;
Is it appropriate to set the value if it failed and data was not initialized?
drivers/misc/intel_tsens/intel_tsens_host.c line 58
Quoted 5 lines
drivers/misc/intel_tsens/intel_tsens_host.c +5
-0+return status; +} + +/** +* intel_tsens_get_temp - get updated temperatue
Might want to use codespell on all files.
RE: [PATCH v3 28/34] misc: Intel tsens IA host driver.
Quoted 22 lines · On Fri, 2021-01-29 at 18:20 -0800, [email protected] wrote:
Quoted 4 lines
From: "C, Udhayakumar" <[email protected]>
Add Intel tsens IA host driver for Intel Edge.AI Computer Vision platforms.
[]
drivers/misc/intel_tsens/intel_tsens_host.c
Quoted 2 lines
drivers/misc/intel_tsens/intel_tsens_host.c +0
-0[]
Quoted 1 line
+static int tsens_i2c_smbus_read_byte_data(struct
i2c_client*i2c, u8command,
drivers/misc/intel_tsens/intel_tsens_host.c line 52
Quoted 8 lines
drivers/misc/intel_tsens/intel_tsens_host.c +8
-0+ u8 *i2c_val) +{ +union i2c_smbus_data data; +int status; + + status =i2c_smbus_xfer (i2c->adapter, i2c->addr, i2c->flags, +I2C_SMBUS_READ , command, +I2C_SMBUS_BYTE_DATA , &data);this can fail
Quoted 4 lines
drivers/misc/intel_tsens/intel_tsens_host.c line 53
Quoted 1 line
drivers/misc/intel_tsens/intel_tsens_host.c +1
-0+ *i2c_val = data.byte;Is it appropriate to set the value if it failed and data was not initialized?
Thanks for the feedback, I will update as below in next patch version.
if (!status)
*i2c_val = data.byte;
Quoted 7 lines
drivers/misc/intel_tsens/intel_tsens_host.c line 58
Quoted 5 lines
drivers/misc/intel_tsens/intel_tsens_host.c +5
-0+return status; +} + +/** +* intel_tsens_get_temp - get updated temperatue Might want to use codespell on all files.
Yes we have ran codespell before submitting, looks like codespell dictionary doesn't have replacement for ' temperatue'. It has only below words.
temerature->temperaturetempertaure->temperaturetemperture->temperature
--
udhay
Quoted 1 line
PATCH v3 29/34 Intel tsens i2c slave driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add Intel tsens i2c slave driver for Intel Edge.AI Computer Vision platforms.
The tsens i2c slave driver enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms. In the tsens i2c module various junction and SoC temperatures are reported using i2c slave protocol.
--- drivers/misc/intel_tsens/Kconfig | 15 +++ drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/intel_tsens_i2c.c | 119 +++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 drivers/misc/intel_tsens/intel_tsens_i2c.c
drivers/misc/intel_tsens/Kconfig +15 -0
@@ -14,6 +14,21 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + select I2C + select I2C_SLAVE + help + This option enables tsens I2C slave driver. + + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N. + config INTEL_TSENS_IA_HOST tristate "Temperature sensor driver for intel tsens remote host" depends on I2C && THERMAL
drivers/misc/intel_tsens/Makefile +1 -0
@@ -5,4 +5,5 @@ # obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o +obj-$(CONFIG_INTEL_TSENS_I2C_SLAVE) += intel_tsens_i2c.o obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o
drivers/misc/intel_tsens/intel_tsens_i2c.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH v3 29/34] Intel tsens i2c slave driver.
drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 20
Quoted 12 lines · On 1/29/21 6:20 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +4
-0@@ -14,6 +14,21 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + select I2C
Repeating:
No, do not select I2C. Use:
depends on I2C
Quoted 10 lines
drivers/misc/intel_tsens/Kconfig +10
-0+ select I2C_SLAVE + help + This option enables tsens I2C slave driver. + + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
Signature · 1 line
~Randy
PATCH v4 21/34 xlink-core: Enable xlink protocol over pcie
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable host system access to the VPU over the xlink protocol over PCIe by enabling channel multiplexing and dispatching. This allows for remote host communication channels across pcie links.
add dispatcher
update multiplexer to utilise dispatcher
xlink-core: Patch set 2
Add xlink-dispatcher
creates tx and rx threads
enables queueing of messages for transmission and on reception
Update multiplexer to utilise dispatcher:
handle multiplexing channels over single interface link e.g. PCIe process messages received by dispatcher
pass messages created by API calls to dispatcher for transmission
--- drivers/misc/xlink-core/Makefile | 2 +- drivers/misc/xlink-core/xlink-core.c | 35 +- drivers/misc/xlink-core/xlink-dispatcher.c | 441 +++++++++++++++++ drivers/misc/xlink-core/xlink-dispatcher.h | 26 + drivers/misc/xlink-core/xlink-multiplexer.c | 498 +++++++++++++++++++- 5 files changed, 999 insertions(+), 3 deletions(-) create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.c create mode 100644 drivers/misc/xlink-core/xlink-dispatcher.h
drivers/misc/xlink-core/Makefile +1 -1
@@ -2,4 +2,4 @@ # Makefile for Keem Bay xlink Linux driver # obj-$(CONFIG_XLINK_CORE) += xlink.o -xlink-objs += xlink-core.o xlink-multiplexer.o xlink-platform.o xlink-ioctl.o +xlink-objs += xlink-core.o xlink-multiplexer.o xlink-dispatcher.o xlink-platform.o xlink-ioctl.o
drivers/misc/xlink-core/xlink-core.c +34 -1
@@ -21,6 +21,7 @@#include "xlink-core.h" #include "xlink-defs.h" +#include "xlink-dispatcher.h" #include "xlink-ioctl.h" #include "xlink-multiplexer.h" #include "xlink-platform.h"
@@ -151,6 +152,12 @@ static int kmb_xlink_probe(struct platform_device *pdev) goto r_multiplexer; } +// initialize dispatcher + rc =xlink_dispatcher_init (xlink_dev->pdev); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("Dispatcher initialization failed\n" ); + goto r_dispatcher; + }// initialize xlink data structure xlink_dev->nmb_connected_links =0 ;mutex_init (&xlink_dev->lock);
@@ -168,7 +175,7 @@ static int kmb_xlink_probe(struct platform_device *pdev)/*Allocating Major number*/ if ((alloc_chrdev_region (&xdev,0 ,1 ,"xlinkdev" )) <0 ) {dev_info (&pdev->dev,"Cannot allocate major number\n" ); - goto r_multiplexer; + goto r_dispatcher; }dev_info (&pdev->dev,"Major = %d Minor = %d\n" ,MAJOR (xdev),MINOR (xdev));
@@ -205,6 +212,8 @@ static int kmb_xlink_probe(struct platform_device *pdev)class_destroy (dev_class); r_class:unregister_chrdev_region (xdev,1 ); +r_dispatcher: +xlink_dispatcher_destroy (); r_multiplexer:xlink_multiplexer_destroy ();return -1 ;
@@ -220,6 +229,10 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); +// stop dispatchers and destroy + rc =xlink_dispatcher_destroy (); +if (rc !=X_LINK_SUCCESS ) +pr_err ("Dispatcher destroy failed\n" );mutex_unlock (&xlink->lock);mutex_destroy (&xlink->lock);
@@ -314,6 +327,14 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle = *handle; xlink->nmb_connected_links++;kref_init (&link->refcount); +if (interface !=IPC_INTERFACE ) { +// start dispatcher + rc =xlink_dispatcher_start (link->id, &link->handle); +if (rc) { +pr_err ("dispatcher start failed\n" ); + goto r_cleanup; + } + }// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {
@@ -649,6 +670,7 @@ EXPORT_SYMBOL_GPL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; +int interface =NULL_INTERFACE ;enum xlink_error rc =X_LINK_ERROR ;if (!xlink || !handle)
@@ -661,6 +683,17 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) { +// stop dispatcher + interface =get_interface_from_sw_device_id (link->handle.sw_device_id); +if (interface !=IPC_INTERFACE ) { +// stop dispatcher + rc =xlink_dispatcher_stop (link->id); +if (rc !=X_LINK_SUCCESS ) { +pr_err ("dispatcher stop failed\n" ); +mutex_unlock (&xlink->lock); +return X_LINK_ERROR ; + } + }// deinitialize multiplexer connection rc =xlink_multiplexer_disconnect (link->id);if (rc) {
drivers/misc/xlink-core/xlink-dispatcher.c new file +441 -0
441 lines not on this page · raw message
drivers/misc/xlink-core/xlink-dispatcher.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* xlink Dispatcher. +* +* Copyright (C) 2018-2019 Intel Corporation +* +*/ +#ifndef __XLINK_DISPATCHER_H +#define __XLINK_DISPATCHER_H + +#include "xlink-defs.h" + +enum xlink_error xlink_dispatcher_init (void *dev); + +enum xlink_error xlink_dispatcher_start (int id,struct xlink_handle *handle); + +enum xlink_error xlink_dispatcher_event_add (enum xlink_event_origin origin, +struct xlink_event *event); + +enum xlink_error xlink_dispatcher_stop (int id); + +enum xlink_error xlink_dispatcher_destroy (void ); + +enum xlink_error xlink_dispatcher_ipc_passthru_event_add (struct xlink_event *event); + +#endif /* __XLINK_DISPATCHER_H */
drivers/misc/xlink-core/xlink-multiplexer.c +497 -1
539 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 22/34 xlink-core: Enable VPU IP management and runtime control
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable VPU management including, enumeration, boot and runtime control.
Add APIs:
write control data:
used to transmit small, local data
start vpu:
calls boot_device API ( soon to be deprecated )
stop vpu
calls reset_device API ( soon to be deprecated )
reset vpu
calls reset_device API ( soon to be deprecated )
get device name:
Returns the device name for the input device id
This could be a char device path, for example "/dev/ttyUSB0" for a serial device; or it could be a device string description, for example, for PCIE "00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)"
get device list:
Returns the list of software device IDs for all connected physical devices
get device status:
returns the current state of the input device
OFF - The device is off (D3cold/Slot power removed). BUSY - device is busy and not available (device is booting) READY - device is available for use
ERROR - device HW failure is detected
RECOVERY - device is in recovery mode, waiting for recovery operations
boot device:
When used on the remote host - starts the SOC device by calling corresponding function from VPU Driver.
Takes firmware's 'binary_name' as input.
For Linux, the firmware image is expected to be located in '/lib/firmware' folder or its subfolders.
For Linux, 'binary_name' is not a path but an image name that will be searched in the default Linux search paths ('/lib/firmware'). When used on the local host - triggers the booting of VPUIP device.
reset device:
When used on the remote host - resets the device by calling corresponding VPU Driver function.
When used on the local host - resets the VPUIP device
get device mode:
query and returns the current device power mode
set device mode:
used for device throttling or entering various power modes
--- drivers/misc/xlink-core/xlink-core.c | 235 ++++++++++++++++++++ drivers/misc/xlink-core/xlink-defs.h | 2 + drivers/misc/xlink-core/xlink-ioctl.c | 214 ++++++++++++++++++ drivers/misc/xlink-core/xlink-ioctl.h | 9 + drivers/misc/xlink-core/xlink-multiplexer.c | 56 +++++ drivers/misc/xlink-core/xlink-platform.c | 86 +++++++ include/linux/xlink.h | 27 +++ 7 files changed, 629 insertions(+)
drivers/misc/xlink-core/xlink-core.c +235 -0
@@ -73,6 +73,8 @@ struct keembay_xlink_dev {struct mutex lock;// protect access to xlink_dev }; +static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +/* * global variable pointing to our xlink device. *
@@ -264,6 +266,9 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_READ_DATA : rc =ioctl_read_data (arg);break ; +case XL_READ_TO_BUFFER : + rc =ioctl_read_to_buffer (arg); +break ;case XL_WRITE_DATA : rc =ioctl_write_data (arg);break ;
@@ -276,9 +281,39 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_CLOSE_CHANNEL : rc =ioctl_close_channel (arg);break ; +case XL_START_VPU : + rc =ioctl_start_vpu (arg); +break ; +case XL_STOP_VPU : + rc =xlink_stop_vpu (); +break ; +case XL_RESET_VPU : + rc =xlink_stop_vpu (); +break ;case XL_DISCONNECT : rc =ioctl_disconnect (arg);break ; +case XL_GET_DEVICE_NAME : + rc =ioctl_get_device_name (arg); +break ; +case XL_GET_DEVICE_LIST : + rc =ioctl_get_device_list (arg); +break ; +case XL_GET_DEVICE_STATUS : + rc =ioctl_get_device_status (arg); +break ; +case XL_BOOT_DEVICE : + rc =ioctl_boot_device (arg); +break ; +case XL_RESET_DEVICE : + rc =ioctl_reset_device (arg); +break ; +case XL_GET_DEVICE_MODE : + rc =ioctl_get_device_mode (arg); +break ; +case XL_SET_DEVICE_MODE : + rc =ioctl_set_device_mode (arg); +break ; }if (rc)return -EIO ;
@@ -289,6 +324,30 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)/* * xlink Kernel API. */ +enum xlink_error xlink_stop_vpu (void ) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_reset_device (0x0 );// stop vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_stop_vpu); +enum xlink_error xlink_start_vpu (char *filename) +{ +#ifdef CONFIG_XLINK_LOCAL_HOST +int rc; + + rc =xlink_ipc_boot_device (0x0 , filename);// start vpu slice 0 +if (rc) +return X_LINK_ERROR ; +#endif +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_start_vpu);enum xlink_error xlink_initialize (void ) {
@@ -527,6 +586,34 @@ enum xlink_error xlink_write_data_user(struct xlink_handle *handle,return rc; } +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size) +{ +struct xlink_event *event; +struct xlink_link *link; +int event_queued =0 ; +enum xlink_error rc; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (size >XLINK_MAX_CONTROL_DATA_SIZE ) +return X_LINK_ERROR ;// TODO: XLink Parameter Error + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + event =xlink_create_event (link->id,XLINK_WRITE_CONTROL_REQ , + &link->handle, chan, size,0 ); +if (!event) +return X_LINK_ERROR ; +memcpy (event->header.control_data, pmessage, size); + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_control_data); +enum xlink_error xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size) {
@@ -711,6 +798,154 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle) }EXPORT_SYMBOL_GPL (xlink_disconnect); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list, +u32 *num_devices) +{ +u32 interface_nmb_devices =0 ; +enum xlink_error rc; +int i; + +if (!xlink) +return X_LINK_ERROR ; +if (!sw_device_id_list || !num_devices) +return X_LINK_ERROR ; +/* loop through each interface and combine the lists */ +for (i =0 ; i <NMB_OF_INTERFACES ; i++) { + rc =xlink_platform_get_device_list (i, sw_device_id_list, + &interface_nmb_devices); +if (!rc) { + *num_devices += interface_nmb_devices; + sw_device_id_list += interface_nmb_devices; + } + interface_nmb_devices =0 ; + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_get_device_list); +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size) +{ +enum xlink_error rc; +int interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!name || !name_size) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_name (interface, handle->sw_device_id, + name, name_size); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_name); +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink) +return X_LINK_ERROR ; +if (!device_status) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_status (interface, handle->sw_device_id, + device_status); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_status); +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; +if (!binary_name) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_boot_device (interface, handle->sw_device_id, + binary_name); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_boot_device); +enum xlink_error xlink_reset_device (struct xlink_handle *handle) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_reset_device (interface, handle->sw_device_id); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_reset_device); +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_set_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_set_device_mode); +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode) +{ +enum xlink_error rc; +u32 interface; + +if (!xlink || !handle) +return X_LINK_ERROR ; + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; + rc =xlink_platform_get_device_mode (interface, handle->sw_device_id, + power_mode); +if (rc) + rc =X_LINK_ERROR ; +else + rc =X_LINK_SUCCESS ; +return rc; +} +EXPORT_SYMBOL_GPL (xlink_get_device_mode);/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-defs.h +2 -0
@@ -101,6 +101,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_REQ ,XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ , +XLINK_WRITE_CONTROL_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -111,6 +112,7 @@ enum xlink_event_type {XLINK_OPEN_CHANNEL_RESP ,XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP , +XLINK_WRITE_CONTROL_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-ioctl.c +214 -0
229 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h +9 -0
@@ -12,10 +12,19 @@int ioctl_connect (unsigned long arg);int ioctl_open_channel (unsigned long arg);int ioctl_read_data (unsigned long arg); +int ioctl_read_to_buffer (unsigned long arg);int ioctl_write_data (unsigned long arg);int ioctl_write_volatile_data (unsigned long arg);int ioctl_release_data (unsigned long arg);int ioctl_close_channel (unsigned long arg); +int ioctl_start_vpu (unsigned long arg);int ioctl_disconnect (unsigned long arg); +int ioctl_get_device_name (unsigned long arg); +int ioctl_get_device_list (unsigned long arg); +int ioctl_get_device_status (unsigned long arg); +int ioctl_boot_device (unsigned long arg); +int ioctl_reset_device (unsigned long arg); +int ioctl_get_device_mode (unsigned long arg); +int ioctl_set_device_mode (unsigned long arg);#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c +56 -0
92 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +86 -0
104 lines not on this page · raw message
include/linux/xlink.h +27 -0
@@ -78,6 +78,10 @@ enum xlink_error xlink_write_data(struct xlink_handle *handle,enum xlink_error xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size); +enum xlink_error xlink_write_control_data (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size); +enum xlink_error xlink_read_data (struct xlink_handle *handle,u16 chan,u8 **message,u32 *size);
@@ -90,6 +94,29 @@ enum xlink_error xlink_release_data(struct xlink_handle *handle,enum xlink_error xlink_disconnect (struct xlink_handle *handle); +enum xlink_error xlink_get_device_list (u32 *sw_device_id_list,u32 *num_devices); + +enum xlink_error xlink_get_device_name (struct xlink_handle *handle,char *name, +size_t name_size); + +enum xlink_error xlink_get_device_status (struct xlink_handle *handle, +u32 *device_status); + +enum xlink_error xlink_boot_device (struct xlink_handle *handle, +const char *binary_name); + +enum xlink_error xlink_reset_device (struct xlink_handle *handle); + +enum xlink_error xlink_set_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode power_mode); + +enum xlink_error xlink_get_device_mode (struct xlink_handle *handle, +enum xlink_device_power_mode *power_mode); + +enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ + +enum xlink_error xlink_stop_vpu (void );/* depreciated */ +/* API functions to be implemented * * enum xlink_error xlink_write_crc_data(struct xlink_handle *handle,
Signature · 1 line
2.17.1
PATCH v4 23/34 xlink-core: add async channel and events
In reply to [email protected]From: Seamus Kelly <[email protected]>
Enable asynchronous channel and event communication.
Add APIs:
data ready callback:
The xLink Data Ready Callback function is used to register a callback function that is invoked when data is ready to be read from a channel
data consumed callback:
The xLink Data Consumed Callback function is used to register a callback function that is invoked when data is consumed by the peer node on a channel
Add event notification handling including APIs:
register device event:
The xLink Register Device Event function is used to register a callback for notification of certain system events. Currently XLink supports 4 such events [0-3] whose meaning is system dependent. Registering for an event means that the callback will be called when the event occurs with 2 parameters the sw_device_id of the device that triggered the event and the event number [0-3]
unregister device event
The xLink Unregister Device Event function is used to unregister events that have previously been registered by register device event API
--- drivers/misc/xlink-core/xlink-core.c | 497 ++++++++++++++++---- drivers/misc/xlink-core/xlink-core.h | 11 +- drivers/misc/xlink-core/xlink-defs.h | 6 +- drivers/misc/xlink-core/xlink-dispatcher.c | 53 +-- drivers/misc/xlink-core/xlink-ioctl.c | 146 +++++- drivers/misc/xlink-core/xlink-ioctl.h | 6 + drivers/misc/xlink-core/xlink-multiplexer.c | 176 +++++-- drivers/misc/xlink-core/xlink-platform.c | 27 ++ include/linux/xlink.h | 15 +- 9 files changed, 757 insertions(+), 180 deletions(-)
drivers/misc/xlink-core/xlink-core.c +411 -86
@@ -55,6 +55,8 @@ static struct cdev xlink_cdev;static long xlink_ioctl (struct file *file,unsigned int cmd,unsigned long arg); +static struct mutex dev_event_lock; +static const struct file_operations fops = { .owner =THIS_MODULE , .unlocked_ioctl = xlink_ioctl,
@@ -66,14 +68,75 @@ struct xlink_link {struct kref refcount; }; +struct xlink_attr { +unsigned long value; +u32 sw_dev_id; +}; +struct keembay_xlink_dev {struct platform_device *pdev;struct xlink_link links[XLINK_MAX_CONNECTIONS ];u32 nmb_connected_links;struct mutex lock;// protect access to xlink_dev +struct xlink_attr eventx[4 ]; +}; + +struct event_info { +struct list_head list; +u32 sw_device_id; +u32 event_type; +u32 user_flag; +xlink_device_event_cb event_notif_fn; }; -static u8 volbuf[XLINK_MAX_BUF_SIZE ];// buffer for volatile transactions +// sysfs attribute functions + +static ssize_t eventx_show (struct device *dev,struct device_attribute *attr, +int index,char *buf) +{ +struct keembay_xlink_dev *xlink_dev =dev_get_drvdata (dev); +struct xlink_attr *a = &xlink_dev->eventx[index]; + +return sysfs_emit (buf,"0x%x 0x%lx\n" , a->sw_dev_id, a->value); +} + +static ssize_t event0_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,0 , buf); +} + +static ssize_t event1_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,1 , buf); +} + +static ssize_t event2_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,2 , buf); +} + +static ssize_t event3_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +return eventx_show (dev, attr,3 , buf); +} + +static DEVICE_ATTR_RO (event0); +static DEVICE_ATTR_RO (event1); +static DEVICE_ATTR_RO (event2); +static DEVICE_ATTR_RO (event3); +static struct attribute *xlink_sysfs_entries[] = { + &dev_attr_event0.attr, + &dev_attr_event1.attr, + &dev_attr_event2.attr, + &dev_attr_event3.attr, +NULL , +}; + +static const struct attribute_group xlink_sysfs_group = { + .attrs = xlink_sysfs_entries, +}; + +static struct event_info ev_info;/* * global variable pointing to our xlink device.
@@ -207,7 +270,14 @@ static int kmb_xlink_probe(struct platform_device *pdev)dev_info (&pdev->dev,"Cannot add the device to the system\n" ); goto r_class; } +INIT_LIST_HEAD (&ev_info.list); + rc =devm_device_add_group (&pdev->dev, &xlink_sysfs_group); +if (rc) { +dev_err (&pdev->dev,"failed to create sysfs entries: %d\n" , rc); +return rc; + } +mutex_init (&dev_event_lock);return 0 ; r_device:
@@ -231,7 +301,6 @@ static int kmb_xlink_remove(struct platform_device *pdev) rc =xlink_multiplexer_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Multiplexer destroy failed\n" ); -// stop dispatchers and destroy rc =xlink_dispatcher_destroy ();if (rc !=X_LINK_SUCCESS )pr_err ("Dispatcher destroy failed\n" );
@@ -251,7 +320,6 @@ static int kmb_xlink_remove(struct platform_device *pdev)* IOCTL function for User Space access to xlink kernel functions * */ -static long xlink_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {int rc;
@@ -263,6 +331,12 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_OPEN_CHANNEL : rc =ioctl_open_channel (arg);break ; +case XL_DATA_READY_CALLBACK : + rc =ioctl_data_ready_callback (arg); +break ; +case XL_DATA_CONSUMED_CALLBACK : + rc =ioctl_data_consumed_callback (arg); +break ;case XL_READ_DATA : rc =ioctl_read_data (arg);break ;
@@ -275,6 +349,9 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_WRITE_VOLATILE : rc =ioctl_write_volatile_data (arg);break ; +case XL_WRITE_CONTROL_DATA : + rc =ioctl_write_control_data (arg); +break ;case XL_RELEASE_DATA : rc =ioctl_release_data (arg);break ;
@@ -285,10 +362,10 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc =ioctl_start_vpu (arg);break ;case XL_STOP_VPU : - rc =xlink_stop_vpu (); + rc =ioctl_stop_vpu ();break ;case XL_RESET_VPU : - rc =xlink_stop_vpu (); + rc =ioctl_stop_vpu ();break ;case XL_DISCONNECT : rc =ioctl_disconnect (arg);
@@ -314,6 +391,12 @@ static long xlink_ioctl(struct file *file, unsigned int cmd, unsigned long arg)case XL_SET_DEVICE_MODE : rc =ioctl_set_device_mode (arg);break ; +case XL_REGISTER_DEV_EVENT : + rc =ioctl_register_device_event (arg); +break ; +case XL_UNREGISTER_DEV_EVENT : + rc =ioctl_unregister_device_event (arg); +break ; }if (rc)return -EIO ;
@@ -387,14 +470,12 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) xlink->nmb_connected_links++;kref_init (&link->refcount);if (interface !=IPC_INTERFACE ) { -// start dispatcher rc =xlink_dispatcher_start (link->id, &link->handle);if (rc) {pr_err ("dispatcher start failed\n" ); goto r_cleanup; } } -// initialize multiplexer connection rc =xlink_multiplexer_connect (link->id);if (rc) {pr_err ("multiplexer connect failed\n" );
@@ -405,7 +486,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) link->handle.dev_type, xlink->nmb_connected_links); }else { -// already connected pr_info ("dev 0x%x ALREADY connected - dev_type %d\n" , link->handle.sw_device_id, link->handle.dev_type);
@@ -413,7 +493,6 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) *handle = link->handle; }mutex_unlock (&xlink->lock); -// TODO: implement ping return X_LINK_SUCCESS ; r_cleanup:
@@ -423,64 +502,109 @@ enum xlink_error xlink_connect(struct xlink_handle *handle) }EXPORT_SYMBOL_GPL (xlink_connect); -enum xlink_error xlink_open_channel (struct xlink_handle *handle, -u16 chan,enum xlink_opmode mode, -u32 data_size,u32 timeout) +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event) {struct xlink_event *event;struct xlink_link *link; -int event_queued =0 ;enum xlink_error rc; +int event_queued =0 ; +char origin ='K' ;if (!xlink || !handle)return X_LINK_ERROR ; +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - - event =xlink_create_event (link->id,XLINK_OPEN_CHANNEL_REQ , - &link->handle, chan, data_size, timeout); + event =xlink_create_event (link->id,XLINK_DATA_READY_CALLBACK_REQ , + &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; - - event->data = (void *)mode; + event->data = data_available_event; + event->callback_origin = origin; +if (!data_available_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued)xlink_destroy_event (event);return rc; } -EXPORT_SYMBOL_GPL (xlink_open_channel); - -enum xlink_error xlink_close_channel (struct xlink_handle *handle, -u16 chan) +EXPORT_SYMBOL_GPL (xlink_data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event) {struct xlink_event *event;struct xlink_link *link;enum xlink_error rc;int event_queued =0 ; +char origin ='K' ;if (!xlink || !handle)return X_LINK_ERROR ; +if (CHANNEL_USER_BIT_IS_SET (chan)) + origin ='U' ;// function called from user space +CHANNEL_CLEAR_USER_BIT (chan);// restore proper channel value + link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - - event =xlink_create_event (link->id,XLINK_CLOSE_CHANNEL_REQ , + event =xlink_create_event (link->id,XLINK_DATA_CONSUMED_CALLBACK_REQ , &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; + event->data = data_consumed_event; + event->callback_origin = origin; +if (!data_consumed_event) + event->calling_pid =NULL ;// disable callbacks on this channel +else + event->calling_pid = current; + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued) +xlink_destroy_event (event); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_data_consumed_event); +enum xlink_error xlink_open_channel (struct xlink_handle *handle, +u16 chan,enum xlink_opmode mode, +u32 data_size,u32 timeout) +{ +struct xlink_event *event; +struct xlink_link *link; +int event_queued =0 ; +enum xlink_error rc; + +if (!xlink || !handle) +return X_LINK_ERROR ; + + link =get_link_by_sw_device_id (handle->sw_device_id); +if (!link) +return X_LINK_ERROR ; + + event =xlink_create_event (link->id,XLINK_OPEN_CHANNEL_REQ , + &link->handle, chan, data_size, timeout); +if (!event) +return X_LINK_ERROR ; + event->data = (void *)mode; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued)xlink_destroy_event (event);return rc; } -EXPORT_SYMBOL_GPL (xlink_close_channel); +EXPORT_SYMBOL_GPL (xlink_open_channel); -enum xlink_error xlink_write_data (struct xlink_handle *handle, -u16 chan,u8 const *pmessage,u32 size) +enum xlink_error xlink_close_channel (struct xlink_handle *handle, +u16 chan) {struct xlink_event *event;struct xlink_link *link;
@@ -490,38 +614,26 @@ enum xlink_error xlink_write_data(struct xlink_handle *handle,if (!xlink || !handle)return X_LINK_ERROR ; -if (size >XLINK_MAX_DATA_SIZE ) -return X_LINK_ERROR ; - link =get_link_by_sw_device_id (handle->sw_device_id);if (!link)return X_LINK_ERROR ; - event =xlink_create_event (link->id,XLINK_WRITE_REQ , &link->handle, - chan, size,0 ); + event =xlink_create_event (link->id,XLINK_CLOSE_CHANNEL_REQ , + &link->handle, chan,0 ,0 );if (!event)return X_LINK_ERROR ; -if (chan <XLINK_IPC_MAX_CHANNELS && - event->interface ==IPC_INTERFACE ) { -/* only passing message address across IPC interface */ - event->data = &pmessage; - rc =xlink_multiplexer_tx (event, &event_queued); + rc =xlink_multiplexer_tx (event, &event_queued); +if (!event_queued)xlink_destroy_event (event); - }else { - event->data = (u8 *)pmessage; - event->paddr =0 ; - rc =xlink_multiplexer_tx (event, &event_queued); -if (!event_queued) -xlink_destroy_event (event); - } +return rc; } -EXPORT_SYMBOL_GPL (xlink_write_data); +EXPORT_SYMBOL_GPL (xlink_close_channel); -enum xlink_error xlink_write_data_user (struct xlink_handle *handle, -u16 chan,u8 const *pmessage, -u32 size) +static enum xlink_error do_xlink_write_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage, +u32 size,u32 user_flag) {struct xlink_event *event;struct xlink_link *link;
@@ -544,48 +656,78 @@ enum xlink_error xlink_write_data_user(struct xlink_handle *handle, chan, size, 0);if (!event)return X_LINK_ERROR ; - event->user_data =1 ; + event->user_data = user_flag;if (chan <XLINK_IPC_MAX_CHANNELS && event->interface ==IPC_INTERFACE ) {/* only passing message address across IPC interface */ -if (get_user (addr, (u32 __user *)pmessage)) { -xlink_destroy_event (event); -return X_LINK_ERROR ; +if (user_flag) { +if (get_user (addr, (u32 __user *)pmessage)) { +xlink_destroy_event (event); +return X_LINK_ERROR ; + } + event->data = &addr; + }else { + event->data = &pmessage; } - event->data = &addr; rc =xlink_multiplexer_tx (event, &event_queued);xlink_destroy_event (event); }else { - event->data =xlink_platform_allocate (&xlink->pdev->dev, &paddr, - size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); -if (!event->data) { -xlink_destroy_event (event); -return X_LINK_ERROR ; - } -if (copy_from_user (event->data, (void __user *)pmessage, size)) { -xlink_platform_deallocate (&xlink->pdev->dev, - event->data, paddr, size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); -xlink_destroy_event (event); -return X_LINK_ERROR ; +if (user_flag) { + event->data =xlink_platform_allocate (&xlink->pdev->dev, &paddr, + size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); +if (!event->data) { +xlink_destroy_event (event); +return X_LINK_ERROR ; + } +if (copy_from_user (event->data, (void __user *)pmessage, size)) { +xlink_platform_deallocate (&xlink->pdev->dev, + event->data, paddr, size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); +xlink_destroy_event (event); +return X_LINK_ERROR ; + } + event->paddr = paddr; + }else { + event->data = (u8 *)pmessage; + event->paddr =0 ; } - event->paddr = paddr; rc =xlink_multiplexer_tx (event, &event_queued);if (!event_queued) { -xlink_platform_deallocate (&xlink->pdev->dev, - event->data, paddr, size, -XLINK_PACKET_ALIGNMENT , -XLINK_NORMAL_MEMORY ); +if (user_flag) { +xlink_platform_deallocate (&xlink->pdev->dev, + event->data, paddr, size, +XLINK_PACKET_ALIGNMENT , +XLINK_NORMAL_MEMORY ); + }xlink_destroy_event (event); } }return rc; } +enum xlink_error xlink_write_data (struct xlink_handle *handle, +u16 chan,u8 const *pmessage,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_data (handle, chan, pmessage, size,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_data); + +enum xlink_error xlink_write_data_user (struct xlink_handle *handle, +u16 chan,u8 const *pmessage,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_data (handle, chan, pmessage, size,1 ); +return rc; +} +enum xlink_error xlink_write_control_data (struct xlink_handle *handle,u16 chan,u8 const *pmessage,u32 size)
@@ -614,16 +756,7 @@ enum xlink_error xlink_write_control_data(struct xlink_handle *handle, }EXPORT_SYMBOL_GPL (xlink_write_control_data); -enum xlink_error xlink_write_volatile (struct xlink_handle *handle, -u16 chan,u8 const *message,u32 size) -{ -enum xlink_error rc =0 ; - - rc =do_xlink_write_volatile (handle, chan, message, size,0 ); -return rc; -} - -enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, +static enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle,u16 chan,u8 const *message,u32 size,u32 user_flag) {
@@ -668,6 +801,26 @@ enum xlink_error do_xlink_write_volatile(struct xlink_handle *handle,return rc; } +enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_volatile (handle, chan, message, size,1 ); +return rc; +} + +enum xlink_error xlink_write_volatile (struct xlink_handle *handle, +u16 chan,u8 const *message,u32 size) +{ +enum xlink_error rc =0 ; + + rc =do_xlink_write_volatile (handle, chan, message, size,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_write_volatile); +enum xlink_error xlink_read_data (struct xlink_handle *handle,u16 chan,u8 **pmessage,u32 *size) {
@@ -757,8 +910,8 @@ EXPORT_SYMBOL_GPL(xlink_release_data);enum xlink_error xlink_disconnect (struct xlink_handle *handle) {struct xlink_link *link; -int interface =NULL_INTERFACE ; -enum xlink_error rc =X_LINK_ERROR ; +int interface; +enum xlink_error rc =0 ;if (!xlink || !handle)return X_LINK_ERROR ;
@@ -767,7 +920,6 @@ enum xlink_error xlink_disconnect(struct xlink_handle *handle)if (!link)return X_LINK_ERROR ; -// decrement refcount, if count is 0 lock mutex and disconnect if (kref_put_mutex (&link->refcount, release_after_kref_put, &xlink->lock)) {// stop dispatcher
@@ -946,6 +1098,179 @@ enum xlink_error xlink_get_device_mode(struct xlink_handle *handle,return rc; }EXPORT_SYMBOL_GPL (xlink_get_device_mode); + +static int xlink_device_event_handler (u32 sw_device_id,u32 event_type) +{ +struct event_info *events =NULL ; +xlink_device_event_cb event_cb; +bool found = false; +char event_attr[7 ]; + +mutex_lock (&dev_event_lock); +// find sw_device_id, event_type in list +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_device_id && + events->event_type == event_type) { + event_cb = events->event_notif_fn; + found = true; +break ; + } + } + } +if (found) { +if (events->user_flag) { + xlink->eventx[events->event_type].value = events->event_type; + xlink->eventx[events->event_type].sw_dev_id = sw_device_id; +sprintf (event_attr,"event%d" , events->event_type); +sysfs_notify (&xlink->pdev->dev.kobj,NULL , event_attr); + }else { +if (event_cb) { +event_cb (sw_device_id, event_type); + }else { +pr_info ("No callback found for sw_device_id : 0x%x event type %d\n" , + sw_device_id, event_type); +mutex_unlock (&dev_event_lock); +return X_LINK_ERROR ; + } + } +pr_info ("sysfs_notify event %d swdev_id %xs\n" , + events->event_type, sw_device_id); + } +mutex_unlock (&dev_event_lock); +return X_LINK_SUCCESS ; +} + +static bool event_registered (u32 sw_dev_id,u32 event) +{ +struct event_info *events =NULL ; + +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == sw_dev_id && + events->event_type == event) { +return true; + } + } + } +return false; +} + +static enum xlink_error do_xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn, +u32 user_flag) +{ +struct event_info *events; +u32 interface; +u32 event; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { + events =kzalloc (sizeof (*events),GFP_KERNEL ); +if (!events) +return X_LINK_ERROR ; + event = *event_list; + events->sw_device_id = handle->sw_device_id; + events->event_notif_fn = event_notif_fn; + events->event_type = *event_list++; + events->user_flag = user_flag; +if (user_flag) { +/* only add to list once if userspace */ +/* xlink userspace handles multi process callbacks */ +if (event_registered (handle->sw_device_id, event)) { +pr_info ("xlink-core: Event 0x%x - %d already registered\n" , + handle->sw_device_id, event); +kfree (events); +continue ; + } + } +pr_info ("xlink-core:Events: sw_device_id 0x%x event %d fn %p user_flag %d\n" , + events->sw_device_id, events->event_type, + events->event_notif_fn, events->user_flag); +list_add_tail (&events->list, &ev_info.list); + } + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_register_for_events (interface, handle->sw_device_id, + xlink_device_event_handler); +return X_LINK_SUCCESS ; +} + +enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,1 ); +return rc; +} + +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn) +{ +enum xlink_error rc; + + rc =do_xlink_register_device_event (handle, event_list, num_events, + event_notif_fn,0 ); +return rc; +} +EXPORT_SYMBOL_GPL (xlink_register_device_event); + +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list, +u32 num_events) +{ +struct event_info *events =NULL ; +u32 interface; +int found =0 ; +int count =0 ; +int i; + +if (num_events <0 || num_events >=NUM_REG_EVENTS ) +return X_LINK_ERROR ; +for (i =0 ; i < num_events; i++) { +list_for_each_entry (events, &ev_info.list, list) { +if (events->sw_device_id == handle->sw_device_id && + events->event_type == event_list[i]) { + found =1 ; +break ; + } + } +if (!events || !found) +return X_LINK_ERROR ; +pr_info ("removing event %d for sw_device_id 0x%x\n" , + events->event_type, events->sw_device_id); +list_del (&events->list); +kfree (events); + } +// check if any events left for this sw_device_id +// are still registered ( in list ) +list_for_each_entry (events, &ev_info.list, list) { +if (events) { +if (events->sw_device_id == handle->sw_device_id) { + count++; +break ; + } + } + } +if (count ==0 ) { + interface =get_interface_from_sw_device_id (handle->sw_device_id); +if (interface ==NULL_INTERFACE ) +return X_LINK_ERROR ; +xlink_platform_unregister_for_events (interface, handle->sw_device_id); + } +return X_LINK_SUCCESS ; +} +EXPORT_SYMBOL_GPL (xlink_unregister_device_event); +/* Device tree driver match. */ static const struct of_device_id kmb_xlink_of_match[] = { {
drivers/misc/xlink-core/xlink-core.h +7 -4
@@ -12,11 +12,14 @@#define NUM_REG_EVENTS 4 -enum xlink_error do_xlink_write_volatile (struct xlink_handle *handle, -u16 chan,u8 const *message, -u32 size,u32 user_flag); -enum xlink_error xlink_write_data_user (struct xlink_handle *handle,u16 chan,u8 const *pmessage,u32 size); +enum xlink_error xlink_register_device_event_user (struct xlink_handle *handle, +u32 *event_list, +u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_write_volatile_user (struct xlink_handle *handle, +u16 chan,u8 const *message, +u32 size);#endif /* XLINK_CORE_H_ */
drivers/misc/xlink-core/xlink-defs.h +5 -1
@@ -35,7 +35,7 @@#define CONTROL_CHANNEL_TIMEOUT_MS 0U // wait indefinitely#define SIGXLNK 44 // signal XLink uses for callback signalling -#define UNUSED (x) (void)(x) +#define UNUSED (x) ((void)(x))// the end of the IPC channel range (starting at zero) #define XLINK_IPC_MAX_CHANNELS 1024
@@ -102,6 +102,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_REQ ,XLINK_PING_REQ ,XLINK_WRITE_CONTROL_REQ , +XLINK_DATA_READY_CALLBACK_REQ , +XLINK_DATA_CONSUMED_CALLBACK_REQ ,XLINK_REQ_LAST ,// response events XLINK_WRITE_RESP = 0x10,
@@ -113,6 +115,8 @@ enum xlink_event_type {XLINK_CLOSE_CHANNEL_RESP ,XLINK_PING_RESP ,XLINK_WRITE_CONTROL_RESP , +XLINK_DATA_READY_CALLBACK_RESP , +XLINK_DATA_CONSUMED_CALLBACK_RESP , XLINK_RESP_LAST, };
drivers/misc/xlink-core/xlink-dispatcher.c +24 -29
148 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.c +137 -9
167 lines not on this page · raw message
drivers/misc/xlink-core/xlink-ioctl.h +6 -0
@@ -14,10 +14,12 @@ int ioctl_open_channel(unsigned long arg);int ioctl_read_data (unsigned long arg);int ioctl_read_to_buffer (unsigned long arg);int ioctl_write_data (unsigned long arg); +int ioctl_write_control_data (unsigned long arg);int ioctl_write_volatile_data (unsigned long arg);int ioctl_release_data (unsigned long arg);int ioctl_close_channel (unsigned long arg);int ioctl_start_vpu (unsigned long arg); +int ioctl_stop_vpu (void );int ioctl_disconnect (unsigned long arg);int ioctl_get_device_name (unsigned long arg);int ioctl_get_device_list (unsigned long arg);
@@ -26,5 +28,9 @@ int ioctl_boot_device(unsigned long arg);int ioctl_reset_device (unsigned long arg);int ioctl_get_device_mode (unsigned long arg);int ioctl_set_device_mode (unsigned long arg); +int ioctl_register_device_event (unsigned long arg); +int ioctl_unregister_device_event (unsigned long arg); +int ioctl_data_ready_callback (unsigned long arg); +int ioctl_data_consumed_callback (unsigned long arg);#endif /* XLINK_IOCTL_H_ */
drivers/misc/xlink-core/xlink-multiplexer.c +127 -49
257 lines not on this page · raw message
drivers/misc/xlink-core/xlink-platform.c +27 -0
@@ -56,6 +56,11 @@ static inline int xlink_ipc_close_channel(u32 sw_device_id, u32 channel) {return -1 ; } +static inline int xlink_ipc_register_for_events (u32 sw_device_id, +int (*callback)(u32 sw_device_id,u32 event)) +{return -1 ; } +static inline int xlink_ipc_unregister_for_events (u32 sw_device_id) +{return -1 ; }#endif /* CONFIG_XLINK_LOCAL_HOST */ /*
@@ -95,6 +100,13 @@ static int (*open_chan_fcts[NMB_OF_INTERFACES])(u32, u32) = {static int (*close_chan_fcts[NMB_OF_INTERFACES ])(u32 ,u32 ) = { xlink_ipc_close_channel,NULL ,NULL ,NULL }; +static int (*register_for_events_fcts[NMB_OF_INTERFACES ])(u32 , +int (*callback)(u32 sw_device_id,u32 event)) = { + xlink_ipc_register_for_events, + xlink_pcie_register_device_event, +NULL ,NULL }; +static int (*unregister_for_events_fcts[NMB_OF_INTERFACES ])(u32 ) = { + xlink_ipc_unregister_for_events, xlink_pcie_unregister_device_event,NULL ,NULL };/* * xlink low-level driver interface
@@ -207,6 +219,21 @@ int xlink_platform_close_channel(u32 interface, u32 sw_device_id,return close_chan_fcts[interface](sw_device_id, channel); } +int xlink_platform_register_for_events (u32 interface,u32 sw_device_id, +xlink_device_event_cb event_notif_fn) +{ +if (interface >=NMB_OF_INTERFACES || !register_for_events_fcts[interface]) +return -1 ; +return register_for_events_fcts[interface](sw_device_id, event_notif_fn); +} + +int xlink_platform_unregister_for_events (u32 interface,u32 sw_device_id) +{ +if (interface >=NMB_OF_INTERFACES || !unregister_for_events_fcts[interface]) +return -1 ; +return unregister_for_events_fcts[interface](sw_device_id); +} +void *xlink_platform_allocate (struct device *dev,dma_addr_t *handle,u32 size,u32 alignment,enum xlink_memory_region region)
include/linux/xlink.h +13 -2
@@ -70,6 +70,12 @@ enum xlink_error xlink_open_channel(struct xlink_handle *handle, u16 chan, enum xlink_opmode mode, u32 data_size, u32 timeout); +enum xlink_error xlink_data_available_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_available_event); +enum xlink_error xlink_data_consumed_event (struct xlink_handle *handle, +u16 chan, +xlink_event data_consumed_event);enum xlink_error xlink_close_channel (struct xlink_handle *handle,u16 chan); enum xlink_error xlink_write_data(struct xlink_handle *handle,
@@ -113,9 +119,14 @@ enum xlink_error xlink_set_device_mode(struct xlink_handle *handle,enum xlink_error xlink_get_device_mode (struct xlink_handle *handle,enum xlink_device_power_mode *power_mode); -enum xlink_error xlink_start_vpu (char *filename);/* depreciated */ +enum xlink_error xlink_register_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events, +xlink_device_event_cb event_notif_fn); +enum xlink_error xlink_unregister_device_event (struct xlink_handle *handle, +u32 *event_list,u32 num_events); +enum xlink_error xlink_start_vpu (char *filename);/* deprecated */ -enum xlink_error xlink_stop_vpu (void );/* depreciated */ +enum xlink_error xlink_stop_vpu (void );/* deprecated */ /* API functions to be implemented *
Signature · 1 line
2.17.1
PATCH v4 24/34 dt-bindings: misc: Add Keem Bay vpumgr
In reply to [email protected]From: "Li, Tingqian" <[email protected]>
Add DT binding schema for VPU on Keem Bay ASoC platform
--- .../bindings/misc/intel,keembay-vpu-mgr.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml
Documentation/devicetree/bindings/misc/intel,keembay-vpu-mgr.yaml new file +48 -0
@@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +# Copyright (C) 2020 Intel +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/misc/intel,keembay-vpu-mgr.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Intel VPU manager bindings + +maintainers: + - Li, Tingqian <[email protected]> + - Zhou, Luwei <[email protected]> + +description: | + The Intel VPU manager provides shared memory and process + depedent context management for Intel VPU hardware IP. + +properties: + compatible: + items: + - enum: + - intel,keembay-vpu-mgr + - intel,keembay-vpusmm + + memory-region: + description: + phandle to a node describing reserved memory (System RAM memory) + used by VPU (see bindings/reserved-memory/reserved-memory.txt) + maxItems: 1 + + intel,keembay-vpu-ipc-id: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + the index of the VPU slice to be managed. Default is 0. + +required: + - compatible + - memory-region + +additionalProperties: false + +examples: + - | + vpumgr0 { + compatible = "intel,keembay-vpu-mgr"; + memory-region = <&vpu_reserved>; + intel,keembay-vpu-ipc-id = <0x0>; + };
Signature · 1 line
2.17.1
PATCH v4 25/34 misc: Add Keem Bay VPU manager
In reply to [email protected]From: "Li, Tingqian" <[email protected]>
VPU IP on Keem Bay SOC is a vision acceleration IP complex under the control of a RTOS-based firmware (running on RISC MCU inside the VPU IP) serving user-space application running on CPU side for HW accelerated computer vision tasks.
This module is kernel counterpart of the VPUAL(VPU abstraction layer) which bridges firmware on VPU side and applications on CPU user-space, it assists firmware on VPU side serving multiple user space application processes on CPU side concurrently while also performing necessary data buffer management on behave of VPU IP.
objmgr provides basic infrastructure for create/destroy VPU side software object concurrently on demand of user-space application and also automatically release leaked objects during handling of application termination. Note this module only cares about the life-cycle of such objects, it's up to the application and firmware to define the behavior/operations of each object.
objmgr does it's job by communicating with firmware through a fixed reserved xlink channel, using a very simple message protocol.
smm provides DMABuf allocation/import facilities to allow user-space app pass data to/from VPU in zero-copy fashion. it also provided a convenient ioctl function for converting virtual pointer of a mem-mapped and imported DMABuf into it's corresponding dma address, to allow user-space app to specify the sub-regions of a bigger DMABuf to be processed by VPU.
--- drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/vpumgr/Kconfig | 9 + drivers/misc/vpumgr/Makefile | 3 + drivers/misc/vpumgr/vpu_common.h | 31 ++ drivers/misc/vpumgr/vpu_mgr.c | 370 ++++++++++++++++++++ drivers/misc/vpumgr/vpu_smm.c | 554 +++++++++++++++++++++++++++++ drivers/misc/vpumgr/vpu_smm.h | 30 ++ drivers/misc/vpumgr/vpu_vcm.c | 584 +++++++++++++++++++++++++++++++ drivers/misc/vpumgr/vpu_vcm.h | 84 +++++ include/uapi/misc/vpumgr.h | 64 ++++ 11 files changed, 1731 insertions(+) create mode 100644 drivers/misc/vpumgr/Kconfig create mode 100644 drivers/misc/vpumgr/Makefile create mode 100644 drivers/misc/vpumgr/vpu_common.h create mode 100644 drivers/misc/vpumgr/vpu_mgr.c create mode 100644 drivers/misc/vpumgr/vpu_smm.c create mode 100644 drivers/misc/vpumgr/vpu_smm.h create mode 100644 drivers/misc/vpumgr/vpu_vcm.c create mode 100644 drivers/misc/vpumgr/vpu_vcm.h create mode 100644 include/uapi/misc/vpumgr.h
drivers/misc/Kconfig +1 -0
@@ -484,4 +484,5 @@ source "drivers/misc/uacce/Kconfig" source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" +source "drivers/misc/vpumgr/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -60,3 +60,4 @@ obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ +obj-$(CONFIG_VPUMGR) += vpumgr/
drivers/misc/vpumgr/Kconfig new file +9 -0
@@ -0,0 +1,9 @@ +config VPUMGR + tristate "VPU Manager" + depends on ARM64 && XLINK_CORE + help + VPUMGR manages life-cycle of VPU related resources which were + dynamically allocated on demands of user-space application + + Select y or m if you have a processor including the Intel + Vision Processor (VPU) on it.
drivers/misc/vpumgr/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_VPUMGR) += vpumgr.o +vpumgr-objs := vpu_mgr.o vpu_smm.o vpu_vcm.o
drivers/misc/vpumgr/vpu_common.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0-only +* VPUMGR Kernel module - common definition +* Copyright (C) 2020-2021 Intel Corporation +*/ +#ifndef _VPU_COMMON_H +#define _VPU_COMMON_H +#include <linux/cdev.h> +#include <linux/platform_device.h> + +#include <uapi/misc/vpumgr.h> + +#include "vpu_vcm.h" + +/* there will be one such device for each HW instance */ +struct vpumgr_device { +struct device *sdev; +struct device *dev; +dev_t devnum; +struct cdev cdev; +struct platform_device *pdev; + +struct vcm_dev vcm; +struct dentry *debugfs_root; + +struct mutex client_mutex;/* protect client_list */ +struct list_head client_list; +}; + +#define XLINK_INVALID_SW_DEVID 0xDEADBEEF + +#endif
drivers/misc/vpumgr/vpu_mgr.c new file +370 -0
370 lines not on this page · raw message
drivers/misc/vpumgr/vpu_smm.c new file +554 -0
554 lines not on this page · raw message
drivers/misc/vpumgr/vpu_smm.h new file +30 -0
@@ -0,0 +1,30 @@ +/* SPDX-License-Identifier: GPL-2.0-only +* Copyright (C) 2020 Intel Corporation +*/ +#ifndef _VPU_SMM_H +#define _VPU_SMM_H +#include <linux/kernel.h> +#include <linux/rbtree.h> + +#include "vpu_common.h" + +struct vpumgr_smm { +struct vpumgr_device *vdev; +struct rb_root imp_rb; +struct mutex imp_rb_lock;/* protects imp_rb */ +}; + +int smm_init (struct vpumgr_device *vdev); +int smm_fini (struct vpumgr_device *vdev); + +int smm_open (struct vpumgr_smm *sess,struct vpumgr_device *vdev); +int smm_close (struct vpumgr_smm *sess); + +int smm_alloc (struct vpumgr_smm *sess,struct vpumgr_args_alloc *arg); +int smm_import (struct vpumgr_smm *sess,struct vpumgr_args_import *arg); +int smm_unimport (struct vpumgr_smm *sess,int *p_dmabuf_fd); +int smm_ptr2vpu (struct vpumgr_smm *sess,unsigned long *arg); + +int smm_debugfs_stats_show (struct seq_file *file,struct vpumgr_smm *sess); + +#endif
drivers/misc/vpumgr/vpu_vcm.c new file +584 -0
584 lines not on this page · raw message
drivers/misc/vpumgr/vpu_vcm.h new file +84 -0
84 lines not on this page · raw message
include/uapi/misc/vpumgr.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 26/34 dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
--- .../bindings/misc/intel,intel-tsens.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml new file +118 -0
@@ -0,0 +1,118 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,intel-tsens.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel Temperature sensors in Bay series + +maintainers: + - Udhayakumar C <[email protected]> + +description: | + The tsens driver enables reading of onchip sensors present + in the Intel Bay SoC. + Each subnode of the tsens represents sensors available + on the soc. + +select: false + +properties: + compatible: + items: + - const: intel,intel-tsens + + plat_name: + contains: + enum: + - intel,keembay_thermal + + reg: + minItems: 1 + maxItems: 2 + + clocks: + items: + - description: thermal sensor clock + + clk-rate: + additionalItems: false + items: + - description: thermal sensor clock freq + + sensor_name: + type: object + description: + Details to configure sensor trip points and its types. + + properties: + passive_delay: + minItems: 1 + maxItems: 1 + description: number of milliseconds to wait between polls when + performing passive cooling + + polling_delay: + minItems: 1 + maxItems: 1 + description: number of milliseconds to wait between polls when checking + whether trip points have been crossed (0 for interrupt + driven systems) + + trip_temp: + minItems: 1 + description: temperature for trip points + + trip_type: + minItems: 1 + description: trip type list for trip points + + required: + - passive_delay + - polling_delay + - trip_temp + - trip_type + +required: + - compatible + +additionalProperties: false + +examples: + - | + tsens: tsens@20260000 { + compatible = "intel,intel-tsens"; + status = "disabled"; + plat_name = "intel,keembay_thermal"; + reg = <0x0 0x20260000 0x0 0x100>; + clocks = <&scmi_clk>; + clk-rate = <1250000>; + + mss { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + css { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + nce { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + + soc { + passive_delay = <1000>; + polling_delay = <2000>; + trip_temp = <40000 80000 1000000>; + trip_type = "passive", "passive", "critical"; + }; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH v4 26/34] dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
Quoted 22 lines · On Fri, 29 Jan 2021 18:21:16 -0800, [email protected] wrote:
From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
Cc Rob Herring <[email protected]>Acked-by mark gross <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>
Quoted 5 lines
--- .../bindings/misc/intel,intel-tsens.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml: example-0: tsens@20260000:reg:0: [0, 539361280, 0, 256] is too long
From schema: /usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
See https://patchwork.ozlabs.org/patch/1433609
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
RE: [PATCH v4 26/34] dt-bindings: misc: intel_tsens: Add tsens thermal bindings documentation
Quoted 42 lines · On Fri, 29 Jan 2021 18:21:16 -0800, [email protected] wrote:
Quoted 22 lines
From: "C, Udhayakumar" <[email protected]>
Add device tree bindings for local host thermal sensors Intel Edge.AI Computer Vision platforms.
The tsens module enables reading of on chip sensors present in the Intel Bay series SoC. In the tsens module various junction temperature and SoC temperature are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsytem will be used by platform manageability software running in remote host.
Cc Rob Herring <[email protected]>Acked-by mark gross <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>Quoted 6 lines
--- .../bindings/misc/intel,intel-tsens.yaml | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644
Documentation/devicetree/bindings/misc/intel,intel-tsens.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml: example-0: tsens@20260000:reg:0: [0, 539361280, 0, 256] is too long
From schema:/usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
Quoted 2 lines
This lint warning is due to missing address-cells and size-cells fields.
make dt_binding_check dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml
CHKDT Documentation/devicetree/bindings/misc/intel,intel-tsens.yaml DTC Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml CHECK Documentation/devicetree/bindings/misc/intel,intel-tsens.example.dt.yaml
Will update the fix in next patch version.
---
Thanks,
Udhay
Quoted 10 lines
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v3 30/34 misc:intel_tsens: Intel Keem Bay tsens driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add keembey_thermal driver to expose on chip temperature sensors, and register call back functions for periodic sampling.
This driver does following:
* Reads temperature data from on chip sensors present in Keem Bay platform.
* Registers callback function to intel tsens driver for sampling temperature values periodically.
* Decode the raw values from registers to Celsius.
--- drivers/misc/intel_tsens/Kconfig | 12 + drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/keembay_thermal.c | 169 ++++++++++ drivers/misc/intel_tsens/keembay_tsens.h | 366 +++++++++++++++++++++ 4 files changed, 548 insertions(+) create mode 100644 drivers/misc/intel_tsens/keembay_thermal.c create mode 100644 drivers/misc/intel_tsens/keembay_tsens.h
drivers/misc/intel_tsens/Kconfig +12 -0
@@ -29,6 +29,18 @@ config INTEL_TSENS_I2C_SLAVE Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config KEEMBAY_THERMAL + tristate "Temperature sensor driver for intel Keem Bay" + depends on INTEL_TSENS_LOCAL_HOST && ARCH_KEEMBAY + help + Enable this option if you want to have support for Keem Bay + thermal management sensors. + + This driver is used for reading onchip temperature sensor + values from Keem Bay SoC. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N. + config INTEL_TSENS_IA_HOST tristate "Temperature sensor driver for intel tsens remote host" depends on I2C && THERMAL
drivers/misc/intel_tsens/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o obj-$(CONFIG_INTEL_TSENS_I2C_SLAVE) += intel_tsens_i2c.o obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o +obj-$(CONFIG_KEEMBAY_THERMAL) += keembay_thermal.o
drivers/misc/intel_tsens/keembay_thermal.c new file +169 -0
169 lines not on this page · raw message
drivers/misc/intel_tsens/keembay_tsens.h new file +366 -0
366 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 31/34 Intel Keem Bay XLink SMBus driver
In reply to [email protected]From: Ramya P Karanth <[email protected]>
Adds XLink SMBus driver for Intel Keem Bay SoC.
Xlink-smbus driver is a logical smbus adapter which uses Xlink (xlink-pcie) protocol as an interface. Keem Bay(s) vision accelerators are connected to the server via PCI interface. The Server needs to know the temperature of the Soc and the source to get the temperature can be either on board sensors or on chip sensors. The sensors are ideally connected over i2c bus of the Soc and the server does not have access to sensors present in the PCB. With this xlink-smbus interfaces, server access the on board/on chip sensors via xlink smbus adapter.
--- Documentation/i2c/busses/index.rst | 1 + .../i2c/busses/intel-xlink-smbus.rst | 71 +++ drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-smbus/Kconfig | 26 + drivers/misc/xlink-smbus/Makefile | 5 + drivers/misc/xlink-smbus/xlink-smbus.c | 467 ++++++++++++++++++ 7 files changed, 572 insertions(+) create mode 100644 Documentation/i2c/busses/intel-xlink-smbus.rst create mode 100644 drivers/misc/xlink-smbus/Kconfig create mode 100644 drivers/misc/xlink-smbus/Makefile create mode 100644 drivers/misc/xlink-smbus/xlink-smbus.c
Documentation/i2c/busses/index.rst +1 -0
@@ -29,4 +29,5 @@ I2C Bus Drivers i2c-taos-evm i2c-viapro i2c-via + intel-xlink-smbus.rst scx200_acb
Documentation/i2c/busses/intel-xlink-smbus.rst new file +71 -0
71 lines not on this page · raw message
drivers/misc/Kconfig +1 -0
@@ -486,4 +486,5 @@ source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" source "drivers/misc/intel_tsens/Kconfig" +source "drivers/misc/xlink-smbus/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -62,3 +62,4 @@ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ obj-y += intel_tsens/ +obj-$(CONFIG_XLINK_SMBUS) += xlink-smbus/
drivers/misc/xlink-smbus/Kconfig new file +26 -0
@@ -0,0 +1,26 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config XLINK_SMBUS + tristate "Enable smbus interface over Xlink PCIe" + depends on XLINK_CORE + depends on HDDL_DEVICE_CLIENT || HDDL_DEVICE_SERVER + help + Enable xlink-pcie as i2c adapter both slave and master. The server + (Remote Host) will use this interface to get sensor data from the soc + (vision accelerator - Local Host) which is connected over PCIe. + This driver is loaded on both Remote Host and Local Host. + Select M to compile the driver as a module, name is xlink-smbus. + If unsure, select N. + + +config XLINK_SMBUS_PROXY + tristate "Enable SMBUS adapter as proxy for I2C controller" + depends on XLINK_CORE + depends on XLINK_SMBUS + help + Enable this config when SMBUS adapter is acting as proxy for + another I2C controller. + Select M or Y if building for Intel Vision Processing Unit (VPU) + Local Host core. + Select N, if building for a Remote Host kernel.
drivers/misc/xlink-smbus/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only +# Makefile for Xlink SMBus +# +obj-$(CONFIG_XLINK_SMBUS) += xlink-smbus.o
drivers/misc/xlink-smbus/xlink-smbus.c new file +467 -0
467 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 27/34 misc: Tsens ARM host thermal driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add tsens ARM host thermal driver for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
---------------- -------------------------- | Platform | | Thermal Daemon | | Management SW| | | ---------------- -------------------------- | Intel tsens | | intel tsens i2c slave | | i2c client | | and thermal driver | ---------------- -------------------------- | XLINK I2C | | XLINK I2C Slave | | controller | <=========> | controller | ---------------- smbus --------------------------
intel tsens module:
-------------------
The tsens module enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms. In the tsens module various junction and SoC temperatures are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsystem will be used by platform manageability software running in IA host.
- Local Host driver
* Intended for ARM CPU
* It is based on Thermal and I2C slave Framework
* Driver path:
{tree}/drivers/misc/intel_tsens/intel_tsens_thermal.c
Local host and Remote host drivers communicates using XLINK I2C SMBUS protocol.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/intel_tsens_sensor.rst | 67 ++ MAINTAINERS | 5 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/intel_tsens/Kconfig | 15 + drivers/misc/intel_tsens/Makefile | 7 + .../misc/intel_tsens/intel_tsens_thermal.c | 651 ++++++++++++++++++ .../misc/intel_tsens/intel_tsens_thermal.h | 38 + include/linux/hddl_device.h | 153 ++++ 10 files changed, 939 insertions(+) create mode 100644 Documentation/hwmon/intel_tsens_sensor.rst create mode 100644 drivers/misc/intel_tsens/Kconfig create mode 100644 drivers/misc/intel_tsens/Makefile create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.c create mode 100644 drivers/misc/intel_tsens/intel_tsens_thermal.h create mode 100644 include/linux/hddl_device.h
Documentation/hwmon/index.rst +1 -0
@@ -80,6 +80,7 @@ Hardware Monitoring Kernel Drivers ir38064 isl68137 it87 + intel_tsens_sensor.rst jc42 k10temp k8temp
Documentation/hwmon/intel_tsens_sensor.rst new file +67 -0
67 lines not on this page · raw message
MAINTAINERS +5 -0
@@ -1985,6 +1985,11 @@ S: Supported F: drivers/misc/hddl_device/ F: drivers/misc/intel_tsens/ +ARM/INTEL TSENS SUPPORT +M: Udhayakumar C <[email protected]> +S: Supported +F: drivers/misc/intel_tsens/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/misc/Kconfig +1 -0
@@ -485,4 +485,5 @@ source "drivers/misc/xlink-pcie/Kconfig" source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" +source "drivers/misc/intel_tsens/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -61,3 +61,4 @@ obj-y += xlink-pcie/ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ +obj-y += intel_tsens/
drivers/misc/intel_tsens/Kconfig new file +15 -0
@@ -0,0 +1,15 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config INTEL_TSENS_LOCAL_HOST + bool "Temperature sensor driver for intel tsens" + select THERMAL + help + This option enables tsens thermal local Host driver. + + This driver is used for reporting thermal data via thermal + framework. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/intel_tsens/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only +# +# Makefile for intel tsens Thermal Linux driver +# + +obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o
drivers/misc/intel_tsens/intel_tsens_thermal.c new file +651 -0
651 lines not on this page · raw message
drivers/misc/intel_tsens/intel_tsens_thermal.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* +* Intel tsens thermal Driver +* +* Copyright (C) 2020 Intel Corporation +* +*/ + +#ifndef _LINUX_INTEL_TSENS_H +#define _LINUX_INTEL_TSENS_H + +#include <linux/platform_device.h> +#include <linux/thermal.h> + +struct intel_tsens_plat_data { +const char *name; +void __iomem *base_addr; +int (*get_temp)(struct platform_device *pdev,int type,int *temp); +void *pdata; +}; + +struct intel_tsens_plat_info { +const char *plat_name; +int id; +struct platform_device *pdev; +void __iomem *base_addr; +}; + +struct intel_tsens_i2c_plat_data { +int (*get_temp)(int type,int *temp,void *pdata); +void *pdata; +}; + +/* TSENS i2c platform data */ +extern struct intel_tsens_i2c_plat_data i2c_plat_data; + +#endif /* _LINUX_INTEL_TSENS_H */
include/linux/hddl_device.h new file +153 -0
153 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 28/34 misc: Intel tsens IA host driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add Intel tsens IA host driver for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
---------------- -------------------------- | Platform | | Thermal Daemon | | Management SW| | | ---------------- -------------------------- | Intel tsens | | intel tsens i2c slave | | i2c client | | and thermal driver | ---------------- -------------------------- | XLINK I2C | | XLINK I2C Slave | | controller | <=========> | controller | ---------------- xlink smbus --------------------------
intel tsens module:
-------------------
The tsens module enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms.In the tsens module various junction and SoC temperatures are reported using thermal subsystem and i2c subsystem.
Temperature data reported using thermal subsystem will be used for various cooling agents such as DVFS, fan control and shutdown the system in case of critical temperature.
Temperature data reported using i2c subsystem will be used by platform manageability software running in IA host.
- Remote Host driver
* Intended for IA CPU
* It is a I2C client driver
* Driver path:
{tree}/drivers/misc/intel_tsens/intel_tsens_host.c
Local host and Remote host drivers communicates using I2C SMBUS protocol.
--- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/intel_tsens_host.rst | 71 ++++ drivers/misc/intel_tsens/Kconfig | 13 + drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/intel_tsens_host.c | 351 ++++++++++++++++++++ include/linux/intel_tsens_host.h | 34 ++ 6 files changed, 471 insertions(+) create mode 100644 Documentation/hwmon/intel_tsens_host.rst create mode 100644 drivers/misc/intel_tsens/intel_tsens_host.c create mode 100644 include/linux/intel_tsens_host.h
Documentation/hwmon/index.rst +1 -0
@@ -81,6 +81,7 @@ Hardware Monitoring Kernel Drivers isl68137 it87 intel_tsens_sensor.rst + intel_tsens_host.rst jc42 k10temp k8temp
Documentation/hwmon/intel_tsens_host.rst new file +71 -0
71 lines not on this page · raw message
drivers/misc/intel_tsens/Kconfig +13 -0
@@ -13,3 +13,16 @@ config INTEL_TSENS_LOCAL_HOST management controller. Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. + +config INTEL_TSENS_IA_HOST + tristate "Temperature sensor driver for intel tsens remote host" + depends on I2C && THERMAL + depends on I2C_SMBUS + help + This option enables tsens i2c and thermal local Host driver. + + This driver is used for reading thermal data via I2C SMBUS + and registers itself to thermal framework, which can be + used by thermal daemon in remote IA host + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/intel_tsens/Makefile +1 -0
@@ -5,3 +5,4 @@ # obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o +obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o
drivers/misc/intel_tsens/intel_tsens_host.c new file +351 -0
351 lines not on this page · raw message
include/linux/intel_tsens_host.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* +* Intel tsens host I2C thermal Driver +* +* Copyright (C) 2020 Intel Corporation +* +*/ + +#ifndef _LINUX_INTEL_TSENS_HOST_DEVICE_H +#define _LINUX_INTEL_TSENS_HOST_DEVICE_H + +struct intel_tsens_host_trip_info { +enum thermal_trip_type trip_type; +int temp; +} __packed__aligned(4) ; + +struct intel_tsens_host { +const char *sensor_name_smbus; +const char *sensor_name_xlk; +struct intel_tsens_data *t_data; +struct intel_tsens_host_trip_info **trip_info; +u32 device_id; +struct i2c_client *i2c_xlk; +struct i2c_client *i2c_smbus; +struct thermal_zone_device *tz_xlk; +struct thermal_zone_device *tz_smbus; +}; + +struct intel_tsens_host_plat_data { +int nsens; +struct intel_tsens_host **tsens; +}; +#endif /*_LINUX_INTEL_TSENS_HOST_DEVICE_H*/
Signature · 1 line
2.17.1
PATCH v4 29/34 Intel tsens i2c slave driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add Intel tsens i2c slave driver for Intel Edge.AI Computer Vision platforms.
The tsens i2c slave driver enables reading of on chip sensors present in the Intel Edge.AI Computer Vision platforms. In the tsens i2c module various junction and SoC temperatures are reported using i2c slave protocol.
--- drivers/misc/intel_tsens/Kconfig | 14 +++ drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/intel_tsens_i2c.c | 119 +++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 drivers/misc/intel_tsens/intel_tsens_i2c.c
drivers/misc/intel_tsens/Kconfig +14 -0
@@ -14,6 +14,20 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + depends on I2C=y && I2C_SLAVE + help + This option enables tsens I2C slave driver. + + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N. + config INTEL_TSENS_IA_HOST tristate "Temperature sensor driver for intel tsens remote host" depends on I2C && THERMAL
drivers/misc/intel_tsens/Makefile +1 -0
@@ -5,4 +5,5 @@ # obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o +obj-$(CONFIG_INTEL_TSENS_I2C_SLAVE) += intel_tsens_i2c.o obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o
drivers/misc/intel_tsens/intel_tsens_i2c.c new file +119 -0
119 lines not on this page · raw message
Signature · 1 line
2.17.1
Randy Dunlap
reviewerRe: [PATCH v4 29/34] Intel tsens i2c slave driver.
Quoted 5 lines · On 1/29/21 6:21 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +0
-0
drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 22
Quoted 9 lines
drivers/misc/intel_tsens/Kconfig +6
-0@@ -14,6 +14,20 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + depends on I2C=y && I2C_SLAVE + help + This option enables tsens I2C slave driver.
Good, it's OK now.
The repeat v3 and then v4 confused me.
Quoted 7 lines
drivers/misc/intel_tsens/Kconfig +7
-0+ + This driver is used for reporting thermal data via I2C + SMBUS to remote host. + Enable this option if you want to have support for thermal + management controller. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
Signature · 1 line
~Randy
RE: [PATCH v4 29/34] Intel tsens i2c slave driver.
Quoted 22 lines
-----Original Message-----
From: Randy Dunlap <[email protected]>
Sent: Sunday, January 31, 2021 6:14 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; C, Udhayakumar <[email protected]>
Subject: Re: [PATCH v4 29/34] Intel tsens i2c slave driver.Quoted 8 lines · On 1/29/21 6:21 PM, [email protected] wrote:
drivers/misc/intel_tsens/Kconfig +0
-0@@ -14,6 +14,20 @@ config INTEL_TSENS_LOCAL_HOST Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N.
Quoted 9 lines
drivers/misc/intel_tsens/Kconfig config INTEL_TSENS_LOCAL_HOST · line 22
Quoted 6 lines
drivers/misc/intel_tsens/Kconfig +6
-0+config INTEL_TSENS_I2C_SLAVE + bool "I2C slave driver for intel tsens" + depends on INTEL_TSENS_LOCAL_HOST + depends on I2C=y && I2C_SLAVE + help + This option enables tsens I2C slave driver.Good, it's OK now.
The repeat v3 and then v4 confused me.
Hmm, I'm confused too. I should have only sent v4 on Friday. I'll look over my history and logs to see how I could have sent to blasts one or V3 and then V4. Ugh. Sorry about mixing the V3 and V4 patches in the same batch.
FWIW I make an outgoing directory and forgot to clean out the v3 patches that where there from the earlier posting. Resulting in a mixing of the old and current patch set.
I'll write a script to automate the creation of the outgoing directory for next time that should correct future screw ups.
I'm very sorry for the noise.
--mark
PATCH v4 30/34 misc:intel_tsens: Intel Keem Bay tsens driver.
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add keembey_thermal driver to expose on chip temperature sensors, and register call back functions for periodic sampling.
This driver does following:
* Reads temperature data from on chip sensors present in Keem Bay platform.
* Registers callback function to intel tsens driver for sampling temperature values periodically.
* Decode the raw values from registers to Celsius.
--- drivers/misc/intel_tsens/Kconfig | 12 + drivers/misc/intel_tsens/Makefile | 1 + drivers/misc/intel_tsens/keembay_thermal.c | 169 ++++++++++ drivers/misc/intel_tsens/keembay_tsens.h | 366 +++++++++++++++++++++ 4 files changed, 548 insertions(+) create mode 100644 drivers/misc/intel_tsens/keembay_thermal.c create mode 100644 drivers/misc/intel_tsens/keembay_tsens.h
drivers/misc/intel_tsens/Kconfig +12 -0
@@ -28,6 +28,18 @@ config INTEL_TSENS_I2C_SLAVE Say Y if using a processor that includes the Intel VPU such as Keem Bay. If unsure, say N. +config KEEMBAY_THERMAL + tristate "Temperature sensor driver for intel Keem Bay" + depends on INTEL_TSENS_LOCAL_HOST && ARCH_KEEMBAY + help + Enable this option if you want to have support for Keem Bay + thermal management sensors. + + This driver is used for reading onchip temperature sensor + values from Keem Bay SoC. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N. + config INTEL_TSENS_IA_HOST tristate "Temperature sensor driver for intel tsens remote host" depends on I2C && THERMAL
drivers/misc/intel_tsens/Makefile +1 -0
@@ -7,3 +7,4 @@ obj-$(CONFIG_INTEL_TSENS_LOCAL_HOST) += intel_tsens_thermal.o obj-$(CONFIG_INTEL_TSENS_I2C_SLAVE) += intel_tsens_i2c.o obj-$(CONFIG_INTEL_TSENS_IA_HOST) += intel_tsens_host.o +obj-$(CONFIG_KEEMBAY_THERMAL) += keembay_thermal.o
drivers/misc/intel_tsens/keembay_thermal.c new file +169 -0
169 lines not on this page · raw message
drivers/misc/intel_tsens/keembay_tsens.h new file +366 -0
366 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 31/34 Intel Keem Bay XLink SMBus driver
In reply to [email protected]From: Ramya P Karanth <[email protected]>
Adds XLink SMBus driver for Intel Keem Bay SoC.
Xlink-smbus driver is a logical SMBus adapter which uses Xlink (xlink-pcie) protocol as an interface. Keem Bay(s) vision accelerators are connected to the server via PCI interface. The Server needs to know the temperature of the Soc and the source to get the temperature can be either on board sensors or on chip sensors. The sensors are ideally connected over i2c bus of the Soc and the server does not have access to sensors present in the PCB. With this xlink-smbus interfaces, server access the on board/on chip sensors via xlink smbus adapter.
--- Documentation/i2c/busses/index.rst | 1 + .../i2c/busses/intel-xlink-smbus.rst | 71 +++ drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-smbus/Kconfig | 26 + drivers/misc/xlink-smbus/Makefile | 5 + drivers/misc/xlink-smbus/xlink-smbus.c | 467 ++++++++++++++++++ 7 files changed, 572 insertions(+) create mode 100644 Documentation/i2c/busses/intel-xlink-smbus.rst create mode 100644 drivers/misc/xlink-smbus/Kconfig create mode 100644 drivers/misc/xlink-smbus/Makefile create mode 100644 drivers/misc/xlink-smbus/xlink-smbus.c
Documentation/i2c/busses/index.rst +1 -0
@@ -29,4 +29,5 @@ I2C Bus Drivers i2c-taos-evm i2c-viapro i2c-via + intel-xlink-smbus.rst scx200_acb
Documentation/i2c/busses/intel-xlink-smbus.rst new file +71 -0
71 lines not on this page · raw message
drivers/misc/Kconfig +1 -0
@@ -486,4 +486,5 @@ source "drivers/misc/xlink-ipc/Kconfig" source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" source "drivers/misc/intel_tsens/Kconfig" +source "drivers/misc/xlink-smbus/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -62,3 +62,4 @@ obj-$(CONFIG_XLINK_IPC) += xlink-ipc/ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ obj-y += intel_tsens/ +obj-$(CONFIG_XLINK_SMBUS) += xlink-smbus/
drivers/misc/xlink-smbus/Kconfig new file +26 -0
@@ -0,0 +1,26 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config XLINK_SMBUS + tristate "Enable smbus interface over Xlink PCIe" + depends on XLINK_CORE + depends on HDDL_DEVICE_CLIENT || HDDL_DEVICE_SERVER + help + Enable xlink-pcie as i2c adapter both slave and master. The server + (Remote Host) will use this interface to get sensor data from the soc + (vision accelerator - Local Host) which is connected over PCIe. + This driver is loaded on both Remote Host and Local Host. + Select M to compile the driver as a module, name is xlink-smbus. + If unsure, select N. + + +config XLINK_SMBUS_PROXY + tristate "Enable SMBUS adapter as proxy for I2C controller" + depends on XLINK_CORE + depends on XLINK_SMBUS + help + Enable this config when SMBUS adapter is acting as proxy for + another I2C controller. + Select M or Y if building for Intel Vision Processing Unit (VPU) + Local Host core. + Select N, if building for a Remote Host kernel.
drivers/misc/xlink-smbus/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only +# Makefile for Xlink SMBus +# +obj-$(CONFIG_XLINK_SMBUS) += xlink-smbus.o
drivers/misc/xlink-smbus/xlink-smbus.c new file +467 -0
467 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 32/34 dt-bindings: misc: hddl_dev: Add hddl device management documentation
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.
--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
Documentation/devicetree/bindings/misc/intel,hddl-client.yaml new file +114 -0
@@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,hddl-client.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel hddl client device to handle platform management in Bay series + +maintainers: + - Udhayakumar C <[email protected]> + +description: | + The HDDL client driver acts as an software RTC to sync with network time. + It abstracts xlink protocol to communicate with remote host. This driver + exports the details about sensors available in the platform to remote + host as xlink packets. + This driver also handles device connect/disconnect events and identifies + board id and soc id using gpio's based on platform configuration. + +select: false + +properties: + compatible: + items: + - const: intel,hddl-client + + reg: + minItems: 4 + maxItems: 4 + + xlink_chan: + minItems: 1 + maxItems: 1 + description: xlink channel number used for communication + with remote host for time sync and sharing sensor + details available in platform. + + i2c_xlink_chan: + minItems: 1 + maxItems: 1 + description: xlink channel number used for communication + with remote host for xlink i2c smbus. + + sensor_name: + type: object + description: + Details about sensors and its configuration on local host and remote + host. + + properties: + compatible: + items: + - const: intel_tsens + + reg: + description: i2c slave address for sensor. + + local-host: + minItems: 1 + maxItems: 1 + description: enable bit 0 to register sensor as i2c slave + in local host (normal i2c client) + enable bit 1 to mimic sensor as i2c slave + in local host (onchip sensors as i2c slave) + enable bit 2 to register i2c slave as xlink smbus slave + in local host. + remote-host: + minItems: 1 + maxItems: 1 + description: enable bit 0 to register sensor as i2c slave + in remote host (normal i2c client) + enable bit 1 to mimic sensor as i2c slave + in remote host (onchip sensors as i2c slave) + enable bit 2 to register i2c slave as xlink smbus slave + in remote host. + + bus: + minItems: 1 + maxItems: 1 + description: i2c bus number for the i2c client device. + + required: + - compatible + - reg + - local-host + - remote-host + - bus + +required: + - compatible + - reg + - xlink_chan + - i2c_xlink_chan + +additionalProperties: false + +examples: + - | + hddl_dev: hddl@20320000 { + compatible = "intel,hddl-client"; + #address-cells = <2>; + #size-cells = <2>; + status = "disabled"; + reg = <0x0 0x20320000 0x0 0x800>; + xlink_chan = <1080>; + i2c_xlink_chan = <1081>; + kmb_xlink_tj { + status = "okay"; + compatible = "intel_tsens"; + local-host = <0x3>; + remote-host = <0x3>; + bus = <0x1>; + }; + };
Signature · 1 line
2.17.1
PATCH v4 32/34 dt-bindings: misc: hddl_dev: Add hddl device management documentation
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.
--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
Documentation/devicetree/bindings/misc/intel,hddl-client.yaml new file +114 -0
@@ -0,0 +1,114 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/misc/intel,hddl-client.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Intel hddl client device to handle platform management in Bay series + +maintainers: + - Udhayakumar C <[email protected]> + +description: | + The HDDL client driver acts as an software RTC to sync with network time. + It abstracts xlink protocol to communicate with remote host. This driver + exports the details about sensors available in the platform to remote + host as xlink packets. + This driver also handles device connect/disconnect events and identifies + board id and soc id using gpio's based on platform configuration. + +select: false + +properties: + compatible: + items: + - const: intel,hddl-client + + reg: + minItems: 4 + maxItems: 4 + + xlink_chan: + minItems: 1 + maxItems: 1 + description: xlink channel number used for communication + with remote host for time sync and sharing sensor + details available in platform. + + i2c_xlink_chan: + minItems: 1 + maxItems: 1 + description: xlink channel number used for communication + with remote host for xlink i2c smbus. + + sensor_name: + type: object + description: + Details about sensors and its configuration on local host and remote + host. + + properties: + compatible: + items: + - const: intel_tsens + + reg: + description: i2c slave address for sensor. + + local-host: + minItems: 1 + maxItems: 1 + description: enable bit 0 to register sensor as i2c slave + in local host (normal i2c client) + enable bit 1 to mimic sensor as i2c slave + in local host (onchip sensors as i2c slave) + enable bit 2 to register i2c slave as xlink smbus slave + in local host. + remote-host: + minItems: 1 + maxItems: 1 + description: enable bit 0 to register sensor as i2c slave + in remote host (normal i2c client) + enable bit 1 to mimic sensor as i2c slave + in remote host (onchip sensors as i2c slave) + enable bit 2 to register i2c slave as xlink smbus slave + in remote host. + + bus: + minItems: 1 + maxItems: 1 + description: i2c bus number for the i2c client device. + + required: + - compatible + - reg + - local-host + - remote-host + - bus + +required: + - compatible + - reg + - xlink_chan + - i2c_xlink_chan + +additionalProperties: false + +examples: + - | + hddl_dev: hddl@20320000 { + compatible = "intel,hddl-client"; + #address-cells = <2>; + #size-cells = <2>; + status = "disabled"; + reg = <0x0 0x20320000 0x0 0x800>; + xlink_chan = <1080>; + i2c_xlink_chan = <1081>; + kmb_xlink_tj { + status = "okay"; + compatible = "intel_tsens"; + local-host = <0x3>; + remote-host = <0x3>; + bus = <0x1>; + }; + };
Signature · 1 line
2.17.1
Rob Herring
maintainerRe: [PATCH v4 32/34] dt-bindings: misc: hddl_dev: Add hddl device management documentation
Quoted 11 lines · On Fri, 29 Jan 2021 18:21:22 -0800, [email protected] wrote:
From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.
Quoted 9 lines
Cc Rob Herring <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml: example-0: hddl@20320000:reg:0: [0, 540147712, 0, 2048] is too long
From schema: /usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
See https://patchwork.ozlabs.org/patch/1433603
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
RE: [PATCH v4 32/34] dt-bindings: misc: hddl_dev: Add hddl device management documentation
Quoted 35 lines · On Fri, 29 Jan 2021 18:21:22 -0800, [email protected] wrote:
Quoted 15 lines
From: "C, Udhayakumar" <[email protected]>
Add hddl device management documentation
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote IA host. This driver exports the details about sensors available in the platform to remote IA host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's based on platform configuration.Cc Rob Herring <[email protected]>Signed-off-by C Udhayakumar <[email protected]>Signed-off-by Mark Gross <[email protected]>Quoted 6 lines
--- .../bindings/misc/intel,hddl-client.yaml | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644
Documentation/devicetree/bindings/misc/intel,hddl-client.yamlMy bot found errors running 'make
dt_binding_check' on your patch:yamllint warnings/errors:
dtschema/dtc warnings/errors:
/builds/robherring/linux-dt- review/Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml: example-0: hddl@20320000:reg:0: [0, 540147712, 0, 2048] is too long
From schema:/usr/local/lib/python3.8/dist-packages/dtschema/schemas/reg.yaml
Quoted 2 lines
This lint warning is due to missing address-cells and size-cells fields.
make dt_binding_check dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/misc/intel,hddl-client.yaml
SCHEMA Documentation/devicetree/bindings/processed-schema.yaml CHKDT Documentation/devicetree/bindings/misc/intel,hddl-client.yaml DTC Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml CHECK Documentation/devicetree/bindings/misc/intel,hddl-client.example.dt.yaml
Will update the fix in next patch version.
---
Thanks,
Udhay
Quoted 10 lines
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make
dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v4 33/34 misc: Hddl device management for local host
In reply to [email protected]From: "C, Udhayakumar" <[email protected]>
Add local host hddl device management for Intel Edge.AI Computer Vision platforms.
About Intel Edge.AI Computer Vision platforms:
---------------------------------------------
The Intel Edge.AI Computer Vision platforms are vision processing systems targeting machine vision applications for connected devices.
They are based on ARM A53 CPU running Linux and acts as a PCIe endpoint device.
High-level architecture:
------------------------
Remote Host IA CPU Local Host ARM CPU
------------------------------- ---------------------------- | * Send time as xlink packet | |* Sync time with IA host | | * receive sensor details | |* Prepare and share sensor| | and register as i2c or | | details to IA host as | | xlink smbus slaves | | xlink packets | ------------------------------- ---------------------------- | hddl server | <=====> | hddl client | ------------------------------- xlink ----------------------------
hddl device module:
-------------------
The HDDL client driver acts as an software RTC to sync with network time. It abstracts xlink protocol to communicate with remote host. This driver exports the details about sensors available in the platform to remote host as xlink packets.
This driver also handles device connect/disconnect events and identifies board id and soc id using gpio's, based on platform configuration.
- Local Host driver
* Intended for ARM CPU
* It is based on xlink Framework
* Driver path:
{tree}/drivers/misc/hddl_device/hddl_device_client.c
Local arm host and Remote IA host drivers communicates using XLINK protocol.
--- .../misc-devices/hddl_device_client.rst | 212 +++++ Documentation/misc-devices/index.rst | 1 + Documentation/vpu/index.rst | 1 + MAINTAINERS | 1 + drivers/misc/Kconfig | 1 + drivers/misc/Makefile | 1 + drivers/misc/hddl_device/Kconfig | 14 + drivers/misc/hddl_device/Makefile | 5 + drivers/misc/hddl_device/hddl_device.c | 565 +++++++++++++ drivers/misc/hddl_device/hddl_device_lh.c | 764 ++++++++++++++++++ drivers/misc/hddl_device/hddl_device_util.h | 52 ++ 11 files changed, 1617 insertions(+) create mode 100644 Documentation/misc-devices/hddl_device_client.rst create mode 100644 drivers/misc/hddl_device/Kconfig create mode 100644 drivers/misc/hddl_device/Makefile create mode 100644 drivers/misc/hddl_device/hddl_device.c create mode 100644 drivers/misc/hddl_device/hddl_device_lh.c create mode 100644 drivers/misc/hddl_device/hddl_device_util.h
Documentation/misc-devices/hddl_device_client.rst new file +212 -0
@@ -0,0 +1,212 @@ +.. SPDX-License-Identifier: GPL-2.0 + +================================= +Kernel driver: hddl_device_client +================================= + +Supported chips: + * Intel Edge.AI Computer Vision platforms: Keem Bay + +Authors: + - Thalaiappan, Rathina <[email protected]> + - Udhayakumar C <[email protected]> + + +Overview +======== + +This driver supports hddl device management for Intel Edge.AI Computer Vision +platforms. + +This driver supports the following features: + + - Exports deatils of temperature sensor, current sensor and fan controller + present in Intel Edge.AI Computer Vision platforms to IA host. + - Enable Time sync of Intel Edge.AI Computer Vision platform with IA host. + - Handles device connect and disconnect events. + - Receives slave address from the IA host for memory mapped thermal sensors + present in SoC (Documentation/hwmon/intel_tsens_sensors.rst). + - Registers i2c slave device for slaves present in Intel Edge.AI Computer + Vision platform + +Keem Bay platform has +Onchip sensors: + + - Media Subsystem (mss) temperature sensor + - NN subsystem (nce) temperature sensor + - Compute subsystem (cse) temperature sensor + - SOC(Maximum of mss, nce and cse). + +Onboard sensors: + + - two lm75 temperature sensors + - emc2103 fan controller + - ina3221 current sensor + +High-level architecture +======================= +:: + + Remote Host IA CPU Local Host ARM CPU + ------------------------------- ---------------------------- + | * Send time as xlink packet | |* Sync time with IA host | + | * receive sensor details | |* Prepare and share sensor| + | and register as i2c or | | details to IA host as | + | xlink smbus slaves | | xlink packets | + ------------------------------- ---------------------------- + | hddl server | <=====> | hddl client | + ------------------------------- xlink ---------------------------- + +Driver Structure +================ + +The driver provides a platform device where the ``probe`` and ``remove`` +operations are provided. + + - probe: Gets list of external sensors from device-tree entries, identify + board id and soc id based on configuration from device-tree entries and + spawn kernel thread to monitor new PCIE devices. + + - init task: Poll for new PCIE device with time interval of 5 seconds and + creates connect task to setup new device. + + - connect task: Connect task is the main entity which connects to hddl + device server using xlink and does the basic initialisation and handshaking. + Additionally it also monitors the hddl device server link down/link up + events and reinitialise the drivers accordingly in the client side. + + - remove: unregister i2c client devices, i2c adapters and close xlink + channel. + +HDDL Client Sequence – Basic Setup and handshaking with HDDL Device Server +========================================================================== +:: + + ,-----. ,---------. ,------------. ,------------------. + |probe| |Init task| |connect task| |hddl device server| + `--+--' `----+----' `-----+------' `--------+---------' + ----. | | | + | "Parse DT" | | | + <---' | | | + | | | | + | ,------------------!. | | | + | |Get sensor details|_\ | | | + | |from device tree | | | | + | `--------------------' | | | + ----. | | | + | "Identify Board Id"| | | + <---' | | | + | | | | + | "Creates kthread" | | | + |----------------------->| | | + | | | | + | ,-----------------------!. | | + | |creates kernel thread |_\ | | + | |to check for new device | | | + | `-------------------------' | | + ,---------------------!. ----. | | + |check for new device |_\ | | | + |with time interval of | <---' | | + |5 seconds | | | | + `-----------------------' | | | + ,---------------------!. | | | + |if new device found?.|_\ | | | + |creates connect task | |-------------------->| | + |to setup new device | | | | + `-----------------------' | | | + | ,-------------------!. |----. | + | |setup xlink channel|_\| | | + | |to communicate with ||<---' | + | |server || | + | `---------------------'| | + | | | Get time data | + | | | from server | + | | | <-------------------------- + | | | | + | | | share board id | + | | | --------------------------> + | | | | + | | | share total number of | + | | | sensors available in SoC | + | | | --------------------------> + | | | | + | ,-----------------------!. | | + | |For each sensors share |_\| | + | |sensor type, name, trip || --------------------------> + | |temp, trip type || | + | `-------------------------'| | + | | | Receives Send complete. | + | | | <-------------------------- + | | | | + | | |----. | + | | | | Register xlink i2c | + | | |<---' adapters. | + | | | | + | | | | + | | | Receives slave addr for | + | | | each salve in SoC | + | | | <-------------------------- + | | | | + | | |----. | + | | | | Register i2c clients.| + | | |<---' | + | | | | + | | |----. + | | | | poll for device status + | | |<---' + ,--+--. ,----+----. ,-----+------. ,--------+---------. + |probe| |Init task| |connect task| |hddl device server| + `-----' `---------' `------------' `------------------' + + +XLINK i2c sequence: +=================== +:: + + ,-----------------. ,--------. ,-----. ,---------. + |xlink-i2c-adapter| |I2C core| |xlink| |i2c-slave| + `--------+--------' `---+----' `--+--' `----+----' + | | | | + |---------------------->| | | + | | | | + | ,--------------------------!. | | + | |Initialize xlink based i2c|_\ | | + | |adapters. | | | + | `----------------------------' | | + | | | | + |<-----------------------------------------| | + | | | | + | ,--------------------------------!. | | + | |I2C request is received as xlink|_\ | | + | |packet from IA host | | | + | `----------------------------------' | | + | | | | + |---------------------->| | | + | | | | + | | ,---------------------------------!. + | | |xlink I2C request is converted to|_\ + | | |standard i2c request | + | | `-----------------------------------' + | | | | + | | ----------------------------------->| + | | | | + | | ,----------------------!. | + | | |Linux i2c slave device|_\ | + | | |standard request | | + | | `------------------------' | + | | | | + | | <-----------------------------------| + | | | | + | | ,----------------------!. | + | | |Linux i2c slave device|_\ | + | | |standard response | | + | | `------------------------' | + | I2C response | | | + |<----------------------| | | + | | | | + | | | ,-------------------------!. + |----------------------------------------->| |I2C response is converted|_\ + | | | |to xlink packet | + ,--------+--------. ,---+----. ,--+-`---------------------------' + |xlink-i2c-adapter| |I2C core| |xlink| |i2c-slave| + `-----------------' `--------' `-----' `---------'
Documentation/misc-devices/index.rst +1 -0
@@ -19,6 +19,7 @@ fit into other categories. bh1770glc eeprom c2port + hddl_device_client.rst ibmvmc ics932s401 isl29003
Documentation/vpu/index.rst +1 -0
@@ -17,3 +17,4 @@ This documentation contains information for the Intel VPU stack. xlink-pcie xlink-ipc xlink-core + hddl_device_client
MAINTAINERS +1 -0
@@ -1988,6 +1988,7 @@ F: drivers/misc/intel_tsens/ ARM/INTEL TSENS SUPPORT M: Udhayakumar C <[email protected]> S: Supported +F: drivers/misc/hddl_device/ F: drivers/misc/intel_tsens/ ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT
drivers/misc/Kconfig +1 -0
@@ -487,4 +487,5 @@ source "drivers/misc/xlink-core/Kconfig" source "drivers/misc/vpumgr/Kconfig" source "drivers/misc/intel_tsens/Kconfig" source "drivers/misc/xlink-smbus/Kconfig" +source "drivers/misc/hddl_device/Kconfig" endmenu
drivers/misc/Makefile +1 -0
@@ -63,3 +63,4 @@ obj-$(CONFIG_XLINK_CORE) += xlink-core/ obj-$(CONFIG_VPUMGR) += vpumgr/ obj-y += intel_tsens/ obj-$(CONFIG_XLINK_SMBUS) += xlink-smbus/ +obj-y += hddl_device/
drivers/misc/hddl_device/Kconfig new file +14 -0
@@ -0,0 +1,14 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +config HDDL_DEVICE_CLIENT + tristate "Support for hddl device client" + depends on XLINK_CORE && INTEL_TSENS_LOCAL_HOST + help + This option enables HDDL device client module. + + This driver is used for sharing time sync data to local host and + retrives the sensors available on the platform. This also handles + the device connect/disconnect programming sequence. + Say Y if using a processor that includes the Intel VPU such as + Keem Bay. If unsure, say N.
drivers/misc/hddl_device/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# Copyright (C) 2020 Intel Corporation +# SPDX-License-Identifier: GPL-2.0-only + +obj-$(CONFIG_HDDL_DEVICE_CLIENT) += hddl_device_client.o +hddl_device_client-objs += hddl_device_lh.o hddl_device.o
drivers/misc/hddl_device/hddl_device.c new file +565 -0
565 lines not on this page · raw message
drivers/misc/hddl_device/hddl_device_lh.c new file +764 -0
764 lines not on this page · raw message
drivers/misc/hddl_device/hddl_device_util.h new file +52 -0
52 lines not on this page · raw message
Signature · 1 line
2.17.1