Add AMD ISP4 driver
Subsystems (9)
Bin Du
maintainerv2 cover Add AMD ISP4 driver
Hello,
AMD ISP4 is the AMD image processing gen 4 which can be found in HP ZBook Ultra G1a 14 inch Mobile Workstation PC ( Ryzen AI Max 385)
(https://ubuntu.com/certified/202411-36043)
This patch series introduces the initial driver support for the AMD ISP4.
Patch summary:
- Powers up/off and initializes ISP HW
- Configures and kicks off ISP FW
- Interacts with APP using standard V4l2 interface by video node
- Controls ISP HW and interacts with ISP FW to do image processing
- Support enum/set output image format and resolution
- Support queueing buffer from app and dequeueing ISP filled buffer to App
- Starts/stops sensor and mipi csi when camera App starts/stops streaming.
- It supports libcamera ver0.2 SimplePipeline
- It is verified on qv4l2, cheese and qcam
- It is verified together with following patches
platform/x86: Add AMD ISP platform config for OV05C10 (https://lore.kernel.org/all/[email protected]/) media: i2c: Add OV05C10 camera sensor driver (https://lore.kernel.org/all/[email protected]/) pinctrl: amd: isp411: Add amdisp GPIO pinctrl (https://github.com/torvalds/linux/commit/e97435ab09f3ad7b6a588dd7c4e45a96699bbb4a) i2c: amd-isp: Add ISP i2c-designware driver (https://github.com/torvalds/linux/commit/d6263c468a761cd4c89887073614394ac48441e1) drm/amd/amdgpu: Add GPIO resources required for amdisp (https://gitlab.freedesktop.org/agd5f/linux/-/commit/ad0f5966ed8297aa47b3184192b00b7379ae0758)
AMD ISP4 Key features:
- Processes bayer raw data from the connected sensor and output them to different YUV formats
- Downscale input image to different output image resolution
- Pipeline to do image processing on the input image including demosaic, denoise, 3A, etc
Changes v1 -> v2:
- Fix media CI test errors and valid warnings
- Reduce patch number in the series from 9 to 8 by merging MAINTAINERS adding patch to the first patch
- In patch 5
- do modification to use remote endpoint instead of local endpoint
- use link frequency and port number as start phy parameter instead of extra added phy-id and phy-bit-rate property of endpoint
It passes v4l2 compliance test, the test reports for:
(a) ov05c10 device /dev/v4l-subdev0
(b) amd_isp_capture device /dev/video0
Compliance test for device /dev/v4l-subdev0:
--------------------------------------------
atg@isp-pv-linux:~/v4l-utils/build/utils/v4l2-compliance$ sudo ./v4l2-compliance -u 0 v4l2-compliance 1.29.0-5348, 64 bits, 64-bit time_t v4l2-compliance SHA: 75e3f0e2c2cb 2025-03-17 18:12:17
Compliance test for device /dev/v4l-subdev0:
Driver Info:
Driver version : 6.14.0
Capabilities : 0x00000000
Client Capabilities: 0x0000000000000002 interval-uses-which Required ioctls:
test VIDIOC_SUDBEV_QUERYCAP: OK
test invalid ioctls: OKAllow for multiple opens:
test second /dev/v4l-subdev0 open: OK
test VIDIOC_SUBDEV_QUERYCAP: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 11 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK (Not Supported) test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK (Not Supported)
test VIDIOC_TRY_FMT: OK (Not Supported)
test VIDIOC_S_FMT: OK (Not Supported)
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK (Not Supported) test CREATE_BUFS maximum buffers: OK
test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK (Not Supported)
test Requests: OK (Not Supported)
test blocking wait: OK (Not Supported)
Total for device /dev/v4l-subdev0: 46, Succeeded: 46, Failed: 0, Warnings: 0
---
Compliance test for amd_isp_capture device /dev/video0:
-------------------------------------------------------
atg@isp-pv-linux:~/test$ sudo ./v4l2-compliance -d /dev/video0 v4l2-compliance 1.29.0-5348, 64 bits, 64-bit time_t v4l2-compliance SHA: 75e3f0e2c2cb 2025-03-17 18:12:17
Compliance test for amd_isp_capture device /dev/video0:
Driver Info:
Driver name : amd_isp_capture
Card type : amd_isp_capture
Bus info : platform:amd_isp_capture
Driver version : 6.14.0
Capabilities : 0xa4200001 Video Capture
I/O MC
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x24200001
Video Capture
I/O MC
Streaming
Extended Pix Format
Media Driver Info:
Driver name : amd_isp_capture
Model : amd_isp41_mdev
Serial :
Bus info : platform:amd_isp_capture
Media version : 6.14.0
Hardware revision: 0x00000000 (0)
Driver version : 6.14.0Interface Info:
ID : 0x03000003
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : Preview
Function : V4L2 I/O
Pad 0x01000002 : 0: Sink
Link 0x02000007: from remote pad 0x1000006 of entity 'ov05c10 99-0010' (Camera Sensor): Data, Enabled, ImmutableRequired ioctls:
test MC information (see 'Media Driver Info' above): OK test VIDIOC_QUERYCAP: OK
test invalid ioctls: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) test VIDIOC_QUERYCTRL: OK (Not Supported)
test VIDIOC_G/S_CTRL: OK (Not Supported)
test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK
test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls (Input 0):
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test CREATE_BUFS maximum buffers: OK test VIDIOC_REMOVE_BUFS: OK
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported) test blocking wait: OK
Total for amd_isp_capture device /dev/video0: 49, Succeeded: 49, Failed: 0, Warnings: 0
Please review and provide feedback.
Many thanks,
Bin Du (8):
media: platform: amd: Introduce amd isp4 capture driver
media: platform: amd: low level support for isp4 firmware
media: platform: amd: Add helpers to configure isp4 mipi phy
media: platform: amd: Add isp4 fw and hw interface
media: platform: amd: isp4 subdev and firmware loading handling added
media: platform: amd: isp4 video node and buffers handling added
media: platform: amd: isp4 debug fs logging and more descriptive
errors
Documentation: add documentation of AMD isp 4 driver
Documentation/admin-guide/media/amdisp4-1.rst | 64 + Documentation/admin-guide/media/amdisp4.dot | 8 + MAINTAINERS | 12 + drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 + drivers/media/platform/amd/Makefile | 5 + drivers/media/platform/amd/isp4/Makefile | 38 + drivers/media/platform/amd/isp4/isp4.c | 406 +++++ drivers/media/platform/amd/isp4/isp4.h | 37 + drivers/media/platform/amd/isp4/isp4_debug.c | 272 +++ drivers/media/platform/amd/isp4/isp4_debug.h | 41 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 ++++ drivers/media/platform/amd/isp4/isp4_hw.c | 46 + drivers/media/platform/amd/isp4/isp4_hw.h | 14 + drivers/media/platform/amd/isp4/isp4_hw_reg.h | 116 ++ .../media/platform/amd/isp4/isp4_interface.c | 1064 ++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 ++ drivers/media/platform/amd/isp4/isp4_phy.c | 1547 +++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + drivers/media/platform/amd/isp4/isp4_subdev.c | 1308 ++++++++++++++ drivers/media/platform/amd/isp4/isp4_subdev.h | 147 ++ drivers/media/platform/amd/isp4/isp4_video.c | 1443 +++++++++++++++ drivers/media/platform/amd/isp4/isp4_video.h | 93 + 24 files changed, 7176 insertions(+) create mode 100644 Documentation/admin-guide/media/amdisp4-1.rst create mode 100644 Documentation/admin-guide/media/amdisp4.dot create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.c create mode 100644 drivers/media/platform/amd/isp4/isp4_debug.h create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.c create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.h create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.h create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.h create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.c create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.h create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.c create mode 100644 drivers/media/platform/amd/isp4/isp4_subdev.h create mode 100644 drivers/media/platform/amd/isp4/isp4_video.c create mode 100644 drivers/media/platform/amd/isp4/isp4_video.h
Signature · 1 line
2.34.1
Bin Du
maintainerPATCH v2 1/8 media: platform: amd: Introduce amd isp4 capture driver
Amd isp4 capture is a v4l2 media device which implements media controller interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
--- MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 + drivers/media/platform/amd/isp4/Makefile | 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++ 8 files changed, 229 insertions(+) create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.h
MAINTAINERS +10 -0
@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git F: drivers/iommu/amd/ F: include/linux/amd-iommu.h +AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* + AMD KFD M: Felix Kuehling <[email protected]> L: [email protected]
drivers/media/platform/Kconfig +1 -0
@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig" source "drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif # MEDIA_PLATFORM_DRIVERS
drivers/media/platform/Makefile +1 -0
@@ -32,6 +32,7 @@ obj-y += ti/ obj-y += verisilicon/ obj-y += via/ obj-y += xilinx/ +obj-y += amd/ # Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by Kconfig name
drivers/media/platform/amd/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default y + depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.
drivers/media/platform/amd/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc. +# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endif
drivers/media/platform/amd/isp4/Makefile new file +21 -0
@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.o +amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) + cc_stack_align := -mpreferred-stack-boundary=4 +endif + +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-value
drivers/media/platform/amd/isp4/isp4.c new file +139 -0
139 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> +#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { +void *adev; +void *bo; +void *cpu_ptr; +u64 gpu_addr; +u32 size; +u32 asic_type; +resource_size_t base_rmmio_size; +}; + +struct isp4_device { +struct v4l2_device v4l2_dev; +struct media_device mdev; + +struct isp4_platform_data *pltf_data; +struct platform_device *pdev; +struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */
Signature · 1 line
2.34.1
Re: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
Quoted 1 line · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller
AMD
Quoted 2 lines
interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connected
AMD
Quoted 3 lines
to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
MAINTAINERS
Quoted 3 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>
Who actually developed? If both are developers there should be a Co-developed-by tag.
Quoted 53 lines
--- MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 + drivers/media/platform/amd/isp4/Makefile | 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++ 8 files changed, 229 insertions(+)create mode 100644
drivers/media/platform/amd/Kconfigcreate mode 100644drivers/media/platform/amd/Makefilecreate mode 100644drivers/media/platform/amd/isp4/Makefilecreate mode 100644drivers/media/platform/amd/isp4/isp4.ccreate mode 100644drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +10
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git F: drivers/iommu/amd/ F: include/linux/amd-iommu.h +AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* + AMD KFD M: Felix Kuehling <[email protected]> L: [email protected]drivers/media/platform/Kconfig +1
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig" source "drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif # MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +0
-0
drivers/media/platform/Makefile obj-y += ti/ · line 35
Quoted 4 lines
drivers/media/platform/Makefile +1
-0@@ -32,6 +32,7 @@ obj-y += ti/ obj-y += verisilicon/ obj-y += via/ obj-y += xilinx/ +obj-y += amd/
Is this whole file alphabetical? If so this is the wrong place.
Quoted 9 lines
drivers/media/platform/Makefile +0
-0# Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by Kconfig namedrivers/media/platform/amd/Kconfig new file +0
-0
drivers/media/platform/amd/Kconfig line 5
Quoted 5 lines
drivers/media/platform/amd/Kconfig new file +5
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default y
I don't believe this should default 'y'. Normally drivers need to be opt in.
Quoted 18 lines
drivers/media/platform/amd/Kconfig new file +12
-0+ depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.drivers/media/platform/amd/Makefile new file +0
-0
drivers/media/platform/amd/Makefile line 1
Quoted 1 line
drivers/media/platform/amd/Makefile new file +1
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc.
2025
Quoted 10 lines
drivers/media/platform/amd/Makefile new file +4
-0+# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +0
-0
drivers/media/platform/amd/isp4/Makefile line 5
Quoted 5 lines
drivers/media/platform/amd/isp4/Makefile new file +5
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.o
As the directory is already conditional on CONFIG_AMD_ISP4 is this obj-$() needed? Or should it really be obj-y?
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +6
-0+amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
drivers/media/platform/amd/isp4/Makefile line 21
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile new file +10
-0+ cc_stack_align := -mpreferred-stack-boundary=4 +endif + +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-value
Do you really need to enforce all these flags just for this driver?
Was this just for development to avoid having to remember to call the build with W=1 or CONFIG_WERROR?
Quoted 31 lines
drivers/media/platform/amd/isp4/isp4.c new file +25
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h" + +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { +0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ +1 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */ +3 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ +4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device, v4l2_dev))
drivers/media/platform/amd/isp4/isp4.c line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ +struct isp4_device *isp_dev =dev_get_drvdata ((struct device *)arg); + +if (!isp_dev) + goto error_drv_data; + +error_drv_data: +return IRQ_HANDLED ;
In patch 5 you change this function, including dropping the goto and label.
So I suggest that for patch 1 you KISS:
static irqreturn_t isp4_irq_handler(int irq, void *arg)
{
return IRQ_HANDLED;
}Then in patch 5 add the extra conditional code and real handling.
drivers/media/platform/amd/isp4/isp4.c line 40
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+} + +/* +* amd capture module +*/
Pointless comment, no?
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+static int isp4_capture_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct isp4_device *isp_dev; +
Why newline here?
Quoted 15 lines
drivers/media/platform/amd/isp4/isp4.c new file +15
-0+int i, irq, ret; + + isp_dev =devm_kzalloc (&pdev->dev,sizeof (*isp_dev),GFP_KERNEL ); +if (!isp_dev) +return -ENOMEM ; + + isp_dev->pdev = pdev; + dev->init_name =ISP4_DRV_NAME ; + +for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { + irq =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +if (irq <0 ) +return dev_err_probe (dev, -ENODEV , +"fail to get irq %d\n" , + isp4_ringbuf_interrupt_num[i]);
drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ ret =devm_request_irq (&pdev->dev, irq, isp4_irq_handler,0 , +"ISP_IRQ" , &pdev->dev); +if (ret) +return dev_err_probe (dev, ret,"fail to req irq %d\n" , + irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + +dev_dbg (dev,"isp irq registration successful\n" );
As you have error handling in place with dev_err_probe() I think the lack of an error implies this message. I'd say drop it.
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ +/* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + +/* Initialize media device */ +strscpy (isp_dev->mdev.model,"amd_isp41_mdev" , +sizeof (isp_dev->mdev.model)); +snprintf (isp_dev->mdev.bus_info,sizeof (isp_dev->mdev.bus_info), +"platform:%s" ,ISP4_DRV_NAME ); + isp_dev->mdev.dev = &pdev->dev; +media_device_init (&isp_dev->mdev);
drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +/* register v4l2 device */ +snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name), +"AMD-V4L2-ROOT" ); + ret =v4l2_device_register (&pdev->dev, &isp_dev->v4l2_dev); +if (ret) +return dev_err_probe (dev, ret, +"fail register v4l2 device\n" ); + +dev_dbg (dev,"AMD ISP v4l2 device registered\n" );
As you have error handling in place with dev_err_probe() I think the lack of an error implies this message. I'd say drop it.
Quoted 18 lines
drivers/media/platform/amd/isp4/isp4.c new file +18
-0+ + ret =media_device_register (&isp_dev->mdev); +if (ret) { +dev_err (dev,"fail to register media device %d\n" , ret); + goto err_unreg_v4l2; + } + +platform_set_drvdata (pdev, isp_dev); + +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev); + +return 0 ; + +err_unreg_v4l2: +v4l2_device_unregister (&isp_dev->v4l2_dev); + +return dev_err_probe (dev, ret,"isp probe fail\n" );
drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ +struct isp4_device *isp_dev =platform_get_drvdata (pdev); +struct device *dev = &pdev->dev; + +media_device_unregister (&isp_dev->mdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +dev_dbg (dev,"AMD ISP v4l2 device unregistered\n" );
Probably not needed message anymore, right?
Quoted 35 lines
drivers/media/platform/amd/isp4/isp4.c new file +20
-0+} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name =ISP4_DRV_NAME , + .owner =THIS_MODULE , + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +9
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h>
drivers/media/platform/amd/isp4/isp4.h line 19
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { +void *adev; +void *bo; +void *cpu_ptr;
Will touch more on these in later patches, but I would say don't introduce them until the patch they're needed.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.h new file +6
-0+u64 gpu_addr; +u32 size; +u32 asic_type; +resource_size_t base_rmmio_size; +}; +
drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+struct isp4_device { +struct v4l2_device v4l2_dev; +struct media_device mdev; + +struct isp4_platform_data *pltf_data; +struct platform_device *pdev; +struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */
/* ISP4_H */
Du, Bin
maintainerRe: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
Many thx Mario for your comments, really helpful, will address all of them in the next patch. Add inline for some of your comments, pls check
Quoted 128 lines · Mario Limonciello
Quoted 1 line · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller
AMD
Quoted 2 lines
interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connectedAMD
Quoted 3 lines
to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
MAINTAINERSQuoted 3 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>Who actually developed? If both are developers there should be a Co- developed-by tag.
Quoted 52 lines
---
MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 +drivers/media/platform/amd/isp4/Makefile| 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++8 files changed, 229 insertions(+)create mode 100644
drivers/media/platform/amd/Kconfigcreate mode 100644drivers/media/platform/amd/Makefilecreate mode 100644drivers/media/platform/amd/isp4/Makefilecreate mode 100644drivers/media/platform/amd/isp4/isp4.ccreate mode 100644drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +0
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/
kernel/git/iommu/linux.git
F:drivers/iommu/amd/
F:include/linux/amd-iommu.hMAINTAINERS +10
-0+AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* +AMD KFD
M: Felix Kuehling <[email protected]>
L: [email protected]drivers/media/platform/Kconfig +0
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig"source "
drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif #MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +0
-0@@ -32,6 +32,7 @@ obj-y += ti/Quoted 4 lines
obj-y += verisilicon/
obj-y += via/
obj-y += xilinx/
+obj-y += amd/Is this whole file alphabetical? If so this is the wrong place.
drivers/media/platform/amd/Kconfig line 5
Quoted 13 lines
# Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by
Kconfignamedrivers/media/platform/amd/Kconfig new file +5
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default yI don't believe this should default 'y'. Normally drivers need to be opt in.
Quoted 18 lines
drivers/media/platform/amd/Kconfig new file +12
-0+ depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.drivers/media/platform/amd/Makefile new file +0
-0drivers/media/platform/amd/Makefile line 1
Quoted 1 line
drivers/media/platform/amd/Makefile new file +1
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc.2025
Quoted 9 lines
drivers/media/platform/amd/Makefile new file +4
-0+# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +0
-0
Quoted 9 lines
drivers/media/platform/amd/isp4/Makefile line 5
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +5
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.oAs the directory is already conditional on
CONFIG_AMD_ISP4is this obj- $() needed? Or should it really be obj-y?
Yes, it is needed, because AMD_ISP4 is trisate in Kconfig, it can be y or m
Quoted 19 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +6
-0+amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)drivers/media/platform/amd/isp4/Makefile line 21
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile new file +10
-0+ cc_stack_align := -mpreferred-stack-boundary=4 +endif + +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-valueDo you really need to enforce all these flags just for this driver?
Quoted 2 lines
Was this just for development to avoid having to remember to call the build with W=1 or
CONFIG_WERROR?
We found after patch submission, Media CI robot test will be triggered, when it builds the patch it will set these flags, so adding these flags to align with Media CI robot test to discover potential issue before submission.
Quoted 220 lines
Quoted 32 lines
drivers/media/platform/amd/isp4/isp4.c new file +25
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h" + +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { + 0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ + 1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */ + 3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ + 4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device,
v4l2_dev))drivers/media/platform/amd/isp4/isp4.c line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ + struct isp4_device *isp_dev = dev_get_drvdata((struct device *)arg); + + if (!isp_dev) + goto error_drv_data; + +error_drv_data: + return IRQ_HANDLED;In patch 5 you change this function, including dropping the goto and label.
So I suggest that for patch 1 you KISS:
static
irqreturn_tisp4_irq_handler(int irq, void *arg){
returnIRQ_HANDLED;
}Then in patch 5 add the extra conditional code and real handling.
drivers/media/platform/amd/isp4/isp4.c line 40
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+} + +/* +* amd capture module +*/ Pointless comment, no?
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+static int isp4_capture_probe (struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct isp4_device *isp_dev; +Why newline here?
Quoted 15 lines
+ int i, irq, ret;
drivers/media/platform/amd/isp4/isp4.c new file +14
-0+ + isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL); + if (!isp_dev) + return -ENOMEM; + + isp_dev->pdev = pdev; + dev->init_name = ISP4_DRV_NAME; + + for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) { + irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]); + if (irq < 0) + return dev_err_probe(dev, -ENODEV, + "fail to get irq %d\n", + isp4_ringbuf_interrupt_num[i]);drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0, + "ISP_IRQ", &pdev->dev); + if (ret) + return dev_err_probe(dev, ret, "fail to req irq %d\n", + irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + + dev_dbg(dev, "isp irq registration successful\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ + /* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + + /* Initialize media device */ + strscpy(isp_dev->mdev.model, "amd_isp41_mdev", + sizeof(isp_dev->mdev.model)); + snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info), + "platform:%s", ISP4_DRV_NAME); + isp_dev->mdev.dev = &pdev->dev; + media_device_init(&isp_dev->mdev);drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ + /* register v4l2 device */ + snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name), + "AMD-V4L2-ROOT"); + ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev); + if (ret) + return dev_err_probe(dev, ret, + "fail register v4l2 device\n"); + + dev_dbg(dev, "AMD ISP v4l2 device registered\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 18 lines
drivers/media/platform/amd/isp4/isp4.c new file +18
-0+ + ret = media_device_register(&isp_dev->mdev); + if (ret) { + dev_err(dev, "fail to register media device %d\n", ret); + goto err_unreg_v4l2; + } + + platform_set_drvdata(pdev, isp_dev); + + pm_runtime_set_suspended(dev); + pm_runtime_enable(dev); + + return 0; + +err_unreg_v4l2: + v4l2_device_unregister(&isp_dev->v4l2_dev); + + return dev_err_probe(dev, ret, "isp probe fail\n");drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ + struct isp4_device *isp_dev = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + + media_device_unregister(&isp_dev->mdev); + v4l2_device_unregister(&isp_dev->v4l2_dev); + dev_dbg(dev, "AMD ISP v4l2 device unregistered\n");Probably not needed message anymore, right?
Quoted 35 lines
drivers/media/platform/amd/isp4/isp4.c new file +20
-0+} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name = ISP4_DRV_NAME, + .owner = THIS_MODULE, + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +9
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> drivers/media/platform/amd/isp4/isp4.h line 19
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { + void *adev; + void *bo; + void *cpu_ptr;Will touch more on these in later patches, but I would say don't introduce them until the patch they're needed.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.h new file +6
-0+ u64 gpu_addr; + u32 size; + u32 asic_type; + resource_size_t base_rmmio_size; +}; +drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+struct isp4_device { + struct v4l2_device v4l2_dev; + struct media_device mdev; + + struct isp4_platform_data *pltf_data; + struct platform_device *pdev; + struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */ /*
ISP4_H*/
Re: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
Quoted 143 lines · Bin
Many thx Mario for your comments, really helpful, will address all of them in the next patch. Add inline for some of your comments, pls check
Quoted 130 lines · Mario Limonciello
Quoted 1 line · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller
AMD
Quoted 2 lines
interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connectedAMD
Quoted 3 lines
to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
MAINTAINERSQuoted 3 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>Who actually developed? If both are developers there should be a Co- developed-by tag.
Quoted 52 lines
---
MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 +drivers/media/platform/amd/isp4/Makefile| 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++8 files changed, 229 insertions(+)create mode 100644
drivers/media/platform/amd/Kconfigcreate mode 100644drivers/media/platform/amd/Makefilecreate mode 100644drivers/media/platform/amd/isp4/Makefilecreate mode 100644drivers/media/platform/amd/isp4/isp4.ccreate mode 100644drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +0
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/
kernel/git/iommu/linux.git
F:drivers/iommu/amd/
F:include/linux/amd-iommu.hMAINTAINERS +10
-0+AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* +AMD KFD
M: Felix Kuehling <[email protected]>
L: [email protected]drivers/media/platform/Kconfig +0
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig"source "
drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif #MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +0
-0@@ -32,6 +32,7 @@ obj-y += ti/Quoted 4 lines
obj-y += verisilicon/
obj-y += via/
obj-y += xilinx/
+obj-y += amd/Is this whole file alphabetical? If so this is the wrong place.
drivers/media/platform/amd/Kconfig line 5
Quoted 13 lines
# Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by
Kconfignamedrivers/media/platform/amd/Kconfig new file +5
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default yI don't believe this should default 'y'. Normally drivers need to be opt in.
Quoted 20 lines
drivers/media/platform/amd/Kconfig new file +10
-0+ depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for videocapture.
+ To compile this driver as a module, choose M here. The module will
+ be calledamd_capture.drivers/media/platform/amd/Makefile new file +0
-0drivers/media/platform/amd/Makefile line 1
Quoted 1 line
drivers/media/platform/amd/Makefile new file +1
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc.2025
Quoted 9 lines
drivers/media/platform/amd/Makefile new file +4
-0+# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +0
-0Quoted 9 lines
drivers/media/platform/amd/isp4/Makefile line 5
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +5
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.oAs the directory is already conditional on
CONFIG_AMD_ISP4is this obj- $() needed? Or should it really be obj-y?
Quoted 1 line
Yes, it is needed, because
AMD_ISP4is trisate inKconfig, it can be y or m
Got it, thanks for clarification.
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
drivers/media/platform/amd/isp4/Makefile new file +6
-0+amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)drivers/media/platform/amd/isp4/Makefile line 21
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile new file +10
-0+ cc_stack_align := -mpreferred-stack-boundary=4 +endif + +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-valueDo you really need to enforce all these flags just for this driver?
Quoted 3 lines
Quoted 2 lines
Was this just for development to avoid having to remember to call the build with W=1 or
CONFIG_WERROR?We found after patch submission, Media CI robot test will be triggered, when it builds the patch it will set these flags, so adding these flags to align with Media CI robot test to discover potential issue before submission.
I believe you can just compile with CONFIG_WERROR and get same result, no? If I'm wrong, nonetheless this should be set in your external build environment script not in the Makefile to be going upstream.
Quoted 223 lines
Quoted 222 lines
Quoted 38 lines
drivers/media/platform/amd/isp4/isp4.c new file +25
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h" + +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { + 0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ + 1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */ + 3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ + 4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device,
v4l2_dev))drivers/media/platform/amd/isp4/isp4.c new file +4
-0+ +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ + struct isp4_device *isp_dev = dev_get_drvdata((struct device*)arg);
drivers/media/platform/amd/isp4/isp4.c line 35
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ + if (!isp_dev) + goto error_drv_data; + +error_drv_data: + return IRQ_HANDLED;In patch 5 you change this function, including dropping the goto and label.
So I suggest that for patch 1 you KISS:
static
irqreturn_tisp4_irq_handler(int irq, void *arg){
returnIRQ_HANDLED;
}Then in patch 5 add the extra conditional code and real handling.
drivers/media/platform/amd/isp4/isp4.c line 40
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+} + +/* +* amd capture module +*/ Pointless comment, no?
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+static int isp4_capture_probe (struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct isp4_device *isp_dev; +Why newline here?
Quoted 15 lines
+ int i, irq, ret;
drivers/media/platform/amd/isp4/isp4.c new file +14
-0+ + isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL); + if (!isp_dev) + return -ENOMEM; + + isp_dev->pdev = pdev; + dev->init_name = ISP4_DRV_NAME; + + for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) { + irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]); + if (irq < 0) + return dev_err_probe(dev, -ENODEV, + "fail to get irq %d\n", + isp4_ringbuf_interrupt_num[i]);drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0, + "ISP_IRQ", &pdev->dev); + if (ret) + return dev_err_probe(dev, ret, "fail to req irq %d\n", + irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + + dev_dbg(dev, "isp irq registration successful\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ + /* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + + /* Initialize media device */ + strscpy(isp_dev->mdev.model, "amd_isp41_mdev", + sizeof(isp_dev->mdev.model)); + snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info), + "platform:%s", ISP4_DRV_NAME); + isp_dev->mdev.dev = &pdev->dev; + media_device_init(&isp_dev->mdev);drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ + /* register v4l2 device */ + snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name), + "AMD-V4L2-ROOT"); + ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev); + if (ret) + return dev_err_probe(dev, ret, + "fail register v4l2 device\n"); + + dev_dbg(dev, "AMD ISP v4l2 device registered\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 18 lines
drivers/media/platform/amd/isp4/isp4.c new file +18
-0+ + ret = media_device_register(&isp_dev->mdev); + if (ret) { + dev_err(dev, "fail to register media device %d\n", ret); + goto err_unreg_v4l2; + } + + platform_set_drvdata(pdev, isp_dev); + + pm_runtime_set_suspended(dev); + pm_runtime_enable(dev); + + return 0; + +err_unreg_v4l2: + v4l2_device_unregister(&isp_dev->v4l2_dev); + + return dev_err_probe(dev, ret, "isp probe fail\n");drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ + struct isp4_device *isp_dev = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + + media_device_unregister(&isp_dev->mdev); + v4l2_device_unregister(&isp_dev->v4l2_dev); + dev_dbg(dev, "AMD ISP v4l2 device unregistered\n");Probably not needed message anymore, right?
Quoted 35 lines
drivers/media/platform/amd/isp4/isp4.c new file +20
-0+} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name = ISP4_DRV_NAME, + .owner = THIS_MODULE, + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +9
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> drivers/media/platform/amd/isp4/isp4.h line 19
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { + void *adev; + void *bo; + void *cpu_ptr;Will touch more on these in later patches, but I would say don't introduce them until the patch they're needed.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.h new file +6
-0+ u64 gpu_addr; + u32 size; + u32 asic_type; + resource_size_t base_rmmio_size; +}; +drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+struct isp4_device { + struct v4l2_device v4l2_dev; + struct media_device mdev; + + struct isp4_platform_data *pltf_data; + struct platform_device *pdev; + struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */ /*
ISP4_H*/
Du, Bin
maintainerRe: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
Thanks Mario, just add one more comment for the CONFIG_WERROR
Quoted 169 lines · Mario Limonciello
Quoted 144 lines · Bin
Many thx Mario for your comments, really helpful, will address all of them in the next patch. Add inline for some of your comments, pls check
Quoted 131 lines · Mario Limonciello
Quoted 1 line · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller
AMD
Quoted 2 lines
interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connectedAMD
Quoted 3 lines
to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
MAINTAINERSQuoted 3 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>Who actually developed? If both are developers there should be a Co- developed-by tag.
Quoted 53 lines
---
MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 +drivers/media/platform/amd/isp4/Makefile| 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++
++++
drivers/media/platform/amd/isp4/isp4.h | 35 ++++++8 files changed, 229 insertions(+)create mode 100644
drivers/media/platform/amd/Kconfigcreate mode 100644drivers/media/platform/amd/Makefilecreate mode 100644drivers/media/platform/amd/isp4/Makefilecreate mode 100644drivers/media/platform/amd/isp4/isp4.ccreate mode 100644drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +0
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/
kernel/git/iommu/linux.git
F:drivers/iommu/amd/
F:include/linux/amd-iommu.hMAINTAINERS +10
-0+AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* +AMD KFD
M: Felix Kuehling <[email protected]>
L: [email protected]drivers/media/platform/Kconfig +0
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig"source "
drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif #MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +0
-0@@ -32,6 +32,7 @@ obj-y += ti/Quoted 4 lines
obj-y += verisilicon/
obj-y += via/
obj-y += xilinx/
+obj-y += amd/Is this whole file alphabetical? If so this is the wrong place.
drivers/media/platform/amd/Kconfig line 5
Quoted 13 lines
# Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by
Kconfignamedrivers/media/platform/amd/Kconfig new file +5
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default yI don't believe this should default 'y'. Normally drivers need to be opt in.
Quoted 20 lines
drivers/media/platform/amd/Kconfig new file +10
-0+ depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG + help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for videocapture.
+ To compile this driver as a module, choose M here. The module will
+ be calledamd_capture.drivers/media/platform/amd/Makefile new file +0
-0drivers/media/platform/amd/Makefile line 1
Quoted 1 line
drivers/media/platform/amd/Makefile new file +1
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc.2025
Quoted 9 lines
drivers/media/platform/amd/Makefile new file +4
-0+# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +0
-0Quoted 9 lines
drivers/media/platform/amd/isp4/Makefile line 5
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +5
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.oAs the directory is already conditional on
CONFIG_AMD_ISP4is this obj- $() needed? Or should it really be obj-y?Quoted 1 line
Yes, it is needed, because
AMD_ISP4is trisate inKconfig, it can be y or mGot it, thanks for clarification.
Quoted 20 lines
Quoted 20 lines
Quoted 7 lines
drivers/media/platform/amd/isp4/Makefile new file +6
-0+amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)drivers/media/platform/amd/isp4/Makefile line 21
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile new file +10
-0+ cc_stack_align := -mpreferred-stack-boundary=4 +endif + +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-valueDo you really need to enforce all these flags just for this driver?
Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Was this just for development to avoid having to remember to call the build with W=1 or
CONFIG_WERROR?We found after patch submission, Media CI robot test will be triggered, when it builds the patch it will set these flags, so adding these flags to align with Media CI robot test to discover potential issue before submission.
I believe you can just compile with
CONFIG_WERRORand get same result, no? If I'm wrong, nonetheless this should be set in your external build environment script not in theMakefileto be going upstream.
IMO, CONFIG_WERROR just treats warning as error, won't add other extra flags. Sure, will remove them from the makefile and only add them to the local build environment.
Quoted 224 lines
Quoted 223 lines
Quoted 222 lines
Quoted 38 lines
drivers/media/platform/amd/isp4/isp4.c new file +25
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> + +#include "isp4.h" + +#define VIDEO_BUF_NUM 5 + +#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { + 0, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ + 1, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */ + 3, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ + 4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device,
v4l2_dev))drivers/media/platform/amd/isp4/isp4.c new file +4
-0+ +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ + struct isp4_device *isp_dev = dev_get_drvdata((struct device*)arg);
drivers/media/platform/amd/isp4/isp4.c line 35
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ + if (!isp_dev) + goto error_drv_data; + +error_drv_data: + return IRQ_HANDLED;In patch 5 you change this function, including dropping the goto and label.
So I suggest that for patch 1 you KISS:
static
irqreturn_tisp4_irq_handler(int irq, void *arg){
returnIRQ_HANDLED;
}Then in patch 5 add the extra conditional code and real handling.
drivers/media/platform/amd/isp4/isp4.c line 40
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+} + +/* +* amd capture module +*/ Pointless comment, no?
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+static int isp4_capture_probe (struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct isp4_device *isp_dev; +Why newline here?
Quoted 15 lines
+ int i, irq, ret;
drivers/media/platform/amd/isp4/isp4.c new file +14
-0+ + isp_dev = devm_kzalloc(&pdev->dev, sizeof(*isp_dev), GFP_KERNEL); + if (!isp_dev) + return -ENOMEM; + + isp_dev->pdev = pdev; + dev->init_name = ISP4_DRV_NAME; + + for (i = 0; i < ARRAY_SIZE(isp4_ringbuf_interrupt_num); i++) { + irq = platform_get_irq(pdev, isp4_ringbuf_interrupt_num[i]); + if (irq < 0) + return dev_err_probe(dev, -ENODEV, + "fail to get irq %d\n", + isp4_ringbuf_interrupt_num[i]);drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ ret = devm_request_irq(&pdev->dev, irq, isp4_irq_handler, 0, + "ISP_IRQ", &pdev->dev); + if (ret) + return dev_err_probe(dev, ret, "fail to req irq %d\n", + irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + + dev_dbg(dev, "isp irq registration successful\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ + /* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + + /* Initialize media device */ + strscpy(isp_dev->mdev.model, "amd_isp41_mdev", + sizeof(isp_dev->mdev.model)); + snprintf(isp_dev->mdev.bus_info, sizeof(isp_dev->mdev.bus_info), + "platform:%s", ISP4_DRV_NAME); + isp_dev->mdev.dev = &pdev->dev; + media_device_init(&isp_dev->mdev);drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ + /* register v4l2 device */ + snprintf(isp_dev->v4l2_dev.name, sizeof(isp_dev->v4l2_dev.name), + "AMD-V4L2-ROOT"); + ret = v4l2_device_register(&pdev->dev, &isp_dev->v4l2_dev); + if (ret) + return dev_err_probe(dev, ret, + "fail register v4l2 device\n"); + + dev_dbg(dev, "AMD ISP v4l2 device registered\n");As you have error handling in place with
dev_err_probe()I think the lack of an error implies this message. I'd say drop it.Quoted 18 lines
drivers/media/platform/amd/isp4/isp4.c new file +18
-0+ + ret = media_device_register(&isp_dev->mdev); + if (ret) { + dev_err(dev, "fail to register media device %d\n", ret); + goto err_unreg_v4l2; + } + + platform_set_drvdata(pdev, isp_dev); + + pm_runtime_set_suspended(dev); + pm_runtime_enable(dev); + + return 0; + +err_unreg_v4l2: + v4l2_device_unregister(&isp_dev->v4l2_dev); + + return dev_err_probe(dev, ret, "isp probe fail\n");drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ + struct isp4_device *isp_dev = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + + media_device_unregister(&isp_dev->mdev); + v4l2_device_unregister(&isp_dev->v4l2_dev); + dev_dbg(dev, "AMD ISP v4l2 device unregistered\n");Probably not needed message anymore, right?
Quoted 35 lines
drivers/media/platform/amd/isp4/isp4.c new file +20
-0+} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name = ISP4_DRV_NAME, + .owner = THIS_MODULE, + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +9
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> drivers/media/platform/amd/isp4/isp4.h line 19
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { + void *adev; + void *bo; + void *cpu_ptr;Will touch more on these in later patches, but I would say don't introduce them until the patch they're needed.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.h new file +6
-0+ u64 gpu_addr; + u32 size; + u32 asic_type; + resource_size_t base_rmmio_size; +}; +drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+struct isp4_device { + struct v4l2_device v4l2_dev; + struct media_device mdev; + + struct isp4_platform_data *pltf_data; + struct platform_device *pdev; + struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */ /*
ISP4_H*/
Sakari Ailus
maintainerRe: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
In reply to Bin DuHi Bin,
Quoted 6 lines · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
You could rewrap the text and use the full lines here -- up to 75 characters per line.
Quoted 71 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 + drivers/media/platform/amd/isp4/Makefile | 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++ 8 files changed, 229 insertions(+) create mode 100644 drivers/media/platform/amd/Kconfig create mode 100644 drivers/media/platform/amd/Makefile create mode 100644 drivers/media/platform/amd/isp4/Makefile create mode 100644 drivers/media/platform/amd/isp4/isp4.c create mode 100644 drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +10
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git F: drivers/iommu/amd/ F: include/linux/amd-iommu.h +AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* + AMD KFD M: Felix Kuehling <[email protected]> L: [email protected]drivers/media/platform/Kconfig +1
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig" source "drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif # MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +1
-0@@ -32,6 +32,7 @@ obj-y += ti/ obj-y += verisilicon/ obj-y += via/ obj-y += xilinx/ +obj-y += amd/ # Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by Kconfig namedrivers/media/platform/amd/Kconfig new file +2
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT +
drivers/media/platform/amd/Kconfig line 12
Quoted 10 lines
drivers/media/platform/amd/Kconfig new file +10
-0+config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default y + depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API + select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SG
Do you need all these three? Most drivers need only one.
Quoted 25 lines
drivers/media/platform/amd/Kconfig new file +5
-0+ help + This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.drivers/media/platform/amd/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc. +# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +3
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc.
drivers/media/platform/amd/isp4/Makefile line 13
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile new file +10
-0+ +obj-$(CONFIG_AMD_ISP4) += amd_capture.o +amd_capture-objs := isp4.o + +ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) + cc_stack_align := -mpreferred-stack-boundary=4 +endif
Uh... does the driver actually depend on this?
Quoted 14 lines
drivers/media/platform/amd/isp4/Makefile new file +8
-0+ +ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-valuedrivers/media/platform/amd/isp4/isp4.c new file +0
-0
drivers/media/platform/amd/isp4/isp4.c line 8
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4.c new file +8
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h>
Alphabetic order, please.
drivers/media/platform/amd/isp4/isp4.c line 12
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4.c new file +4
-0+ +#include "isp4.h" + +#define VIDEO_BUF_NUM 5
Unused.
drivers/media/platform/amd/isp4/isp4.c line 25
Quoted 13 lines
drivers/media/platform/amd/isp4/isp4.c new file +13
-0+ +#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { +0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ +1 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */ +3 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ +4 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device, v4l2_dev))
No need for the cast.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ +struct isp4_device *isp_dev =dev_get_drvdata ((struct device *)arg); + +if (!isp_dev) + goto error_drv_data; + +error_drv_data: +return IRQ_HANDLED ;
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +/* +* amd capture module +*/ +static int isp4_capture_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct isp4_device *isp_dev; +
Extra newline.
drivers/media/platform/amd/isp4/isp4.c line 46
Quoted 1 line
drivers/media/platform/amd/isp4/isp4.c new file +1
-0+int i, irq, ret;
unsigned int i?
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4.c new file +14
-0+ + isp_dev =devm_kzalloc (&pdev->dev,sizeof (*isp_dev),GFP_KERNEL ); +if (!isp_dev) +return -ENOMEM ; + + isp_dev->pdev = pdev; + dev->init_name =ISP4_DRV_NAME ; + +for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { + irq =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +if (irq <0 ) +return dev_err_probe (dev, -ENODEV , +"fail to get irq %d\n" , + isp4_ringbuf_interrupt_num[i]);
drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ ret =devm_request_irq (&pdev->dev, irq, isp4_irq_handler,0 , +"ISP_IRQ" , &pdev->dev); +if (ret) +return dev_err_probe (dev, ret,"fail to req irq %d\n" , + irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + +dev_dbg (dev,"isp irq registration successful\n" );
Please leave this out.
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ +/* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + +/* Initialize media device */ +strscpy (isp_dev->mdev.model,"amd_isp41_mdev" , +sizeof (isp_dev->mdev.model)); +snprintf (isp_dev->mdev.bus_info,sizeof (isp_dev->mdev.bus_info), +"platform:%s" ,ISP4_DRV_NAME ); + isp_dev->mdev.dev = &pdev->dev; +media_device_init (&isp_dev->mdev);
drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+ +/* register v4l2 device */ +snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name), +"AMD-V4L2-ROOT" ); + ret =v4l2_device_register (&pdev->dev, &isp_dev->v4l2_dev); +if (ret) +return dev_err_probe (dev, ret, +"fail register v4l2 device\n" ); + +dev_dbg (dev,"AMD ISP v4l2 device registered\n" );
This doesn't seem useful.
drivers/media/platform/amd/isp4/isp4.c line 102
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4.c new file +11
-0+ + ret =media_device_register (&isp_dev->mdev); +if (ret) { +dev_err (dev,"fail to register media device %d\n" , ret); + goto err_unreg_v4l2; + } + +platform_set_drvdata (pdev, isp_dev); + +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev);
You'll need to enable runtime PM before registering any interfaces on UAPI. Same goes for setting driver data for the device.
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4.c new file +7
-0+ +return 0 ; + +err_unreg_v4l2: +v4l2_device_unregister (&isp_dev->v4l2_dev); + +return dev_err_probe (dev, ret,"isp probe fail\n" );
drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+} + +static void isp4_capture_remove (struct platform_device *pdev) +{ +struct isp4_device *isp_dev =platform_get_drvdata (pdev); +struct device *dev = &pdev->dev; + +media_device_unregister (&isp_dev->mdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +dev_dbg (dev,"AMD ISP v4l2 device unregistered\n" );
I'd say this is redundant.
Quoted 51 lines
drivers/media/platform/amd/isp4/isp4.c new file +20
-0+} + +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name =ISP4_DRV_NAME , + .owner =THIS_MODULE , + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +25
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> +#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE (isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { +void *adev; +void *bo; +void *cpu_ptr; +u64 gpu_addr; +u32 size; +u32 asic_type; +resource_size_t base_rmmio_size; +}; +
drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.h new file +10
-0+struct isp4_device { +struct v4l2_device v4l2_dev; +struct media_device mdev; + +struct isp4_platform_data *pltf_data; +struct platform_device *pdev; +struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */
Use the same name as for the macro here, please.
Signature · 3 lines
Kind regards, Sakari Ailus
Du, Bin
maintainerRe: [PATCH v2 1/8] media: platform: amd: Introduce amd isp4 capture driver
Many thanks Askari Alius for your careful review.
Quoted 10 lines · Sakari Ailus
Hi Bin,
Quoted 6 lines · Bin Du
Amd isp4 capture is a v4l2 media device which implements media controller interface.
It has one sub-device (amd ISP4 sub-device) endpoint which can be connected to a remote CSI2 TX endpoint. It supports only one physical interface for now.
Also add ISP4 driver related entry info into the MAINAINERS file
Quoted 3 lines
You could rewrap the text and use the full lines here -- up to 75 characters per line.
Sure, will do in the next patch>>
Quoted 74 lines
Quoted 74 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- MAINTAINERS | 10 ++ drivers/media/platform/Kconfig | 1 + drivers/media/platform/Makefile | 1 + drivers/media/platform/amd/Kconfig | 17 +++ drivers/media/platform/amd/Makefile | 5 + drivers/media/platform/amd/isp4/Makefile | 21 ++++ drivers/media/platform/amd/isp4/isp4.c | 139 +++++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4.h | 35 ++++++ 8 files changed, 229 insertions(+)create mode 100644
drivers/media/platform/amd/Kconfigcreate mode 100644drivers/media/platform/amd/Makefilecreate mode 100644drivers/media/platform/amd/isp4/Makefilecreate mode 100644drivers/media/platform/amd/isp4/isp4.ccreate mode 100644drivers/media/platform/amd/isp4/isp4.hMAINTAINERS +10
-0@@ -1107,6 +1107,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/iommu/linux.git F: drivers/iommu/amd/ F: include/linux/amd-iommu.h +AMD ISP4 DRIVER +M: Bin Du <[email protected]> +M: Nirujogi Pratap <[email protected]> +L: [email protected] +S: Maintained +T: git git://linuxtv.org/media.git +F: drivers/media/platform/amd/Kconfig +F: drivers/media/platform/amd/Makefile +F: drivers/media/platform/amd/isp4/* + AMD KFD M: Felix Kuehling <[email protected]> L: [email protected]drivers/media/platform/Kconfig +1
-0@@ -89,5 +89,6 @@ source "drivers/media/platform/ti/Kconfig" source "drivers/media/platform/verisilicon/Kconfig" source "drivers/media/platform/via/Kconfig" source "drivers/media/platform/xilinx/Kconfig" +source "drivers/media/platform/amd/Kconfig" endif # MEDIA_PLATFORM_DRIVERSdrivers/media/platform/Makefile +1
-0@@ -32,6 +32,7 @@ obj-y += ti/ obj-y += verisilicon/ obj-y += via/ obj-y += xilinx/ +obj-y += amd/ # Please place here only ancillary drivers that aren't SoC-specific # Please keep it alphabetically sorted by Kconfig namedrivers/media/platform/amd/Kconfig new file +6
-0@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: MIT + +config AMD_ISP4 + tristate "AMD ISP4 and camera driver" + default y + depends on VIDEO_DEV && VIDEO_V4L2_SUBDEV_API
Quoted 9 lines
drivers/media/platform/amd/Kconfig line 12
Quoted 6 lines
drivers/media/platform/amd/Kconfig new file +6
-0+ select VIDEOBUF2_CORE + select VIDEOBUF2_V4L2 + select VIDEOBUF2_MEMOPS + select VIDEOBUF2_VMALLOC + select VIDEOBUF2_DMA_CONTIG + select VIDEOBUF2_DMA_SGDo you need all these three? Most drivers need only one.
After double check, yes, none of theam are used in our code, will remove them and also the header files included>> + help
Quoted 28 lines
Quoted 28 lines
drivers/media/platform/amd/Kconfig new file +4
-0+ This is support for AMD ISP4 and camera subsystem driver. + Say Y here to enable the ISP4 and camera device for video capture. + To compile this driver as a module, choose M here. The module will + be called amd_capture.drivers/media/platform/amd/Makefile new file +5
-0@@ -0,0 +1,5 @@ +# Copyright 2024 Advanced Micro Devices, Inc. +# add isp block +ifneq ($(CONFIG_AMD_ISP4),) +obj-y += isp4/ +endifdrivers/media/platform/amd/isp4/Makefile new file +7
-0@@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (C) 2025 Advanced Micro Devices, Inc. + +obj-$(CONFIG_AMD_ISP4) += amd_capture.o +amd_capture-objs := isp4.o +
Quoted 9 lines
drivers/media/platform/amd/isp4/Makefile line 13
Quoted 6 lines
drivers/media/platform/amd/isp4/Makefile new file +6
-0+ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/include + +ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) + cc_stack_align := -mpreferred-stack-boundary=4 +endifUh... does the driver actually depend on this?
Yes, other comments also mentioned this, will update in the next patch>> +
Quoted 15 lines
Quoted 15 lines
drivers/media/platform/amd/isp4/Makefile new file +7
-0+ccflags-y += $(cc_stack_align) +ccflags-y += -DCONFIG_COMPAT +ccflags-y += -Wunused-but-set-variable +ccflags-y += -Wmissing-include-dirs +ccflags-y += -Wunused-const-variable +ccflags-y += -Wmaybe-uninitialized +ccflags-y += -Wunused-valuedrivers/media/platform/amd/isp4/isp4.c new file +2
-0@@ -0,0 +1,139 @@ +// SPDX-License-Identifier: GPL-2.0+ +/*
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 8
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/pm_runtime.h> +#include <linux/vmalloc.h> +#include <media/v4l2-ioctl.h> Alphabetic order, please.
Sorry, seems it's already in alphabetic order, an example in drivers/media/v4l2-core/v4l2-ioctl.c is like #include <linux/v4l2-subdev.h>
#include <linux/videodev2.h>
#include <media/media-device.h> /* for media_set_bus_info() */ #include <media/v4l2-common.h>
Suppose i can add an empty line before #include <media/v4l2-ioctl.h>>> +
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c line 12
Quoted 3 lines
drivers/media/platform/amd/isp4/isp4.c new file +3
-0+#include "isp4.h" + +#define VIDEO_BUF_NUM 5Unused.
Yes, other comments also mentioned this, will remove it in the next patch>> +
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+#define ISP4_DRV_NAME "amd_isp_capture" + +/* interrupt num */ +static const u32 isp4_ringbuf_interrupt_num[] = { +0 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT9 */ +1 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT10 */
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 25
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+3 ,/* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT11 */ + 4, /* ISP_4_1__SRCID__ISP_RINGBUFFER_WPT12 */ +}; + +#define to_isp4_device (dev) \ + ((struct isp4_device *)container_of(dev, struct isp4_device, v4l2_dev))No need for the cast.
Sure, will remove the cast in the next patch>> +
Quoted 13 lines
Quoted 13 lines
drivers/media/platform/amd/isp4/isp4.c new file +13
-0+static irqreturn_t isp4_irq_handler (int irq,void *arg) +{ +struct isp4_device *isp_dev =dev_get_drvdata ((struct device *)arg); + +if (!isp_dev) + goto error_drv_data; + +error_drv_data: +return IRQ_HANDLED ; +} + +/* +* amd capture module
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 45
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+*/ +static int isp4_capture_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct isp4_device *isp_dev; +Extra newline.
Yes, other comments also mentioned this, will remove it in the next patch>> + int i, irq, ret;
Quoted 3 lines
unsigned int i?
Weired, no compile warning about this, will change it to size_t i in the next patch.>> +
Quoted 17 lines
Quoted 17 lines
drivers/media/platform/amd/isp4/isp4.c new file +17
-0+ isp_dev =devm_kzalloc (&pdev->dev,sizeof (*isp_dev),GFP_KERNEL ); +if (!isp_dev) +return -ENOMEM ; + + isp_dev->pdev = pdev; + dev->init_name =ISP4_DRV_NAME ; + +for (i =0 ; i <ARRAY_SIZE (isp4_ringbuf_interrupt_num); i++) { + irq =platform_get_irq (pdev, isp4_ringbuf_interrupt_num[i]); +if (irq <0 ) +return dev_err_probe (dev, -ENODEV , +"fail to get irq %d\n" , + isp4_ringbuf_interrupt_num[i]); + ret =devm_request_irq (&pdev->dev, irq, isp4_irq_handler,0 , +"ISP_IRQ" , &pdev->dev); +if (ret) + return dev_err_probe(dev, ret, "fail to req irq %d\n",
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 70
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ irq); + } + + isp_dev->pltf_data = pdev->dev.platform_data; + +dev_dbg (dev,"isp irq registration successful\n" );Please leave this out.
Yes, other comments also mentioned this, will remove it in the next patch>> +
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4.c new file +14
-0+/* Link the media device within the v4l2_device */ + isp_dev->v4l2_dev.mdev = &isp_dev->mdev; + +/* Initialize media device */ +strscpy (isp_dev->mdev.model,"amd_isp41_mdev" , +sizeof (isp_dev->mdev.model)); +snprintf (isp_dev->mdev.bus_info,sizeof (isp_dev->mdev.bus_info), +"platform:%s" ,ISP4_DRV_NAME ); + isp_dev->mdev.dev = &pdev->dev; +media_device_init (&isp_dev->mdev); + +/* register v4l2 device */ +snprintf (isp_dev->v4l2_dev.name,sizeof (isp_dev->v4l2_dev.name), +"AMD-V4L2-ROOT" );
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 91
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+ ret =v4l2_device_register (&pdev->dev, &isp_dev->v4l2_dev); +if (ret) +return dev_err_probe (dev, ret, +"fail register v4l2 device\n" ); + +dev_dbg (dev,"AMD ISP v4l2 device registered\n" );This doesn't seem useful.
Yes, other comments also mentioned this, will remove it in the next patch>> +
Quoted 5 lines
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+ ret =media_device_register (&isp_dev->mdev); +if (ret) { +dev_err (dev,"fail to register media device %d\n" , ret); + goto err_unreg_v4l2; + }
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 102
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4.c new file +5
-0+ +platform_set_drvdata (pdev, isp_dev); + +pm_runtime_set_suspended (dev); +pm_runtime_enable (dev);You'll need to enable runtime PM before registering any interfaces on UAPI. Same goes for setting driver data for the device.
Sure, will modify in the next patch>> +
Quoted 10 lines
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4.c new file +10
-0+return 0 ; + +err_unreg_v4l2: +v4l2_device_unregister (&isp_dev->v4l2_dev); + +return dev_err_probe (dev, ret,"isp probe fail\n" ); +} + +static void isp4_capture_remove (struct platform_device *pdev) +{
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.c line 119
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.c new file +6
-0+struct isp4_device *isp_dev =platform_get_drvdata (pdev); +struct device *dev = &pdev->dev; + +media_device_unregister (&isp_dev->mdev); +v4l2_device_unregister (&isp_dev->v4l2_dev); +dev_dbg (dev,"AMD ISP v4l2 device unregistered\n" );I'd say this is redundant.
Yes, other comments also mentioned this, will remove it in the next patch>> +}
Quoted 54 lines
Quoted 54 lines
drivers/media/platform/amd/isp4/isp4.c new file +19
-0+ +static struct platform_driver isp4_capture_drv = { + .probe = isp4_capture_probe, + .remove = isp4_capture_remove, + .driver = { + .name =ISP4_DRV_NAME , + .owner =THIS_MODULE , + } +}; + +module_platform_driver (isp4_capture_drv); + +MODULE_ALIAS ("platform:" ISP4_DRV_NAME ); +MODULE_IMPORT_NS ("DMA_BUF" ); + +MODULE_DESCRIPTION ("AMD ISP4 Driver" ); +MODULE_AUTHOR ("Bin Du <[email protected]>" ); +MODULE_AUTHOR ("Pratap Nirujogi <[email protected]>" ); +MODULE_LICENSE ("GPL" );drivers/media/platform/amd/isp4/isp4.h new file +29
-0@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_H_ +#define _ISP4_H_ + +#include <linux/mutex.h> +#include <media/v4l2-device.h> +#include <media/videobuf2-memops.h> +#include <media/videobuf2-vmalloc.h> + +#define ISP4_GET_ISP_REG_BASE(isp4sd) (((isp4sd))->mmio) + +struct isp4_platform_data { + void *adev; + void *bo; + void *cpu_ptr; + u64 gpu_addr; + u32 size; + u32 asic_type; + resource_size_t base_rmmio_size; +}; + +struct isp4_device { + struct v4l2_device v4l2_dev; + struct media_device mdev; +
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4.h line 35
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4.h new file +6
-0+struct isp4_platform_data *pltf_data; +struct platform_device *pdev; + struct notifier_block i2c_nb; +}; + +#endif /* isp4.h */ Use the same name as for the macro here, please.
Yes, other comments also mentioned this, will modify in the next patch
Bin Du
maintainerPATCH v2 2/8 media: platform: amd: low level support for isp4 firmware
In reply to Bin DuLow level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware.
Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.
--- drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4_hw.c | 46 +++++++ drivers/media/platform/amd/isp4/isp4_hw.h | 14 +++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 116 ++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.c create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.h create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.h
drivers/media/platform/amd/isp4/Makefile +2 -1
@@ -3,7 +3,8 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc. obj-$(CONFIG_AMD_ISP4) += amd_capture.o -amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 ccflags-y += -I$(srctree)/include
drivers/media/platform/amd/isp4/isp4_hw.c new file +46 -0
46 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_hw.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_H_ +#define _ISP4_HW_H_ + +#define RREG_FAILED_VAL 0xFFFFFFFF + +u32 isp4hw_rreg (void __iomem *base,u32 reg); +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val); + +#endif
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +116 -0
116 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 2/8] media: platform: amd: low level support for isp4 firmware
Quoted 8 lines · Bin Du
Low level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware.
Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>
Same comment as first patch (and others), who wrote it? Is Co-developed-by missing?
Quoted 218 lines
--- drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4_hw.c | 46 +++++++ drivers/media/platform/amd/isp4/isp4_hw.h | 14 +++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 116 ++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)create mode 100644
drivers/media/platform/amd/isp4/isp4_hw.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_hw.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_hw_reg.hdrivers/media/platform/amd/isp4/Makefile +2
-1@@ -3,7 +3,8 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc. obj-$(CONFIG_AMD_ISP4) += amd_capture.o -amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 ccflags-y += -I$(srctree)/includedrivers/media/platform/amd/isp4/isp4_hw.c new file +46
-0@@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/io.h> +#include <linux/types.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" + +#define RMMIO_SIZE 524288 + +u32 isp4hw_rreg (void __iomem *base,u32 reg) +{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE ) +return RREG_FAILED_VAL ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 ); +else +return RREG_FAILED_VAL ; + +return readl (reg_addr); +}; + +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val) +{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE ) +return ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 ); +else +return ; + +writel (val, reg_addr); +};drivers/media/platform/amd/isp4/isp4_hw.h new file +14
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_H_ +#define _ISP4_HW_H_ + +#define RREG_FAILED_VAL 0xFFFFFFFF + +u32 isp4hw_rreg (void __iomem *base,u32 reg); +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val); + +#endif drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +116
-0@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_REG_H_ +#define _ISP4_HW_REG_H_ + +#define ISP_SOFT_RESET 0x62000 +#define ISP_SYS_INT0_EN 0x62010 +#define ISP_SYS_INT0_STATUS 0x62014 +#define ISP_SYS_INT0_ACK 0x62018 +#define ISP_CCPU_CNTL 0x62054 +#define ISP_STATUS 0x62058 +#define ISP_LOG_RB_BASE_LO0 0x62148 +#define ISP_LOG_RB_BASE_HI0 0x6214C +#define ISP_LOG_RB_SIZE0 0x62150 +#define ISP_LOG_RB_RPTR0 0x62154 +#define ISP_LOG_RB_WPTR0 0x62158 +#define ISP_RB_BASE_LO1 0x62170 +#define ISP_RB_BASE_HI1 0x62174 +#define ISP_RB_SIZE1 0x62178 +#define ISP_RB_RPTR1 0x6217C +#define ISP_RB_WPTR1 0x62180 +#define ISP_RB_BASE_LO2 0x62184 +#define ISP_RB_BASE_HI2 0x62188 +#define ISP_RB_SIZE2 0x6218C +#define ISP_RB_RPTR2 0x62190 +#define ISP_RB_WPTR2 0x62194 +#define ISP_RB_BASE_LO3 0x62198 +#define ISP_RB_BASE_HI3 0x6219C +#define ISP_RB_SIZE3 0x621A0 +#define ISP_RB_RPTR3 0x621A4 +#define ISP_RB_WPTR3 0x621A8 +#define ISP_RB_BASE_LO4 0x621AC +#define ISP_RB_BASE_HI4 0x621B0 +#define ISP_RB_SIZE4 0x621B4 +#define ISP_RB_RPTR4 0x621B8 +#define ISP_RB_WPTR4 0x621BC +#define ISP_RB_BASE_LO5 0x621C0 +#define ISP_RB_BASE_HI5 0x621C4 +#define ISP_RB_SIZE5 0x621C8 +#define ISP_RB_RPTR5 0x621CC +#define ISP_RB_WPTR5 0x621D0 +#define ISP_RB_BASE_LO6 0x621D4 +#define ISP_RB_BASE_HI6 0x621D8 +#define ISP_RB_SIZE6 0x621DC +#define ISP_RB_RPTR6 0x621E0 +#define ISP_RB_WPTR6 0x621E4 +#define ISP_RB_BASE_LO7 0x621E8 +#define ISP_RB_BASE_HI7 0x621EC +#define ISP_RB_SIZE7 0x621F0 +#define ISP_RB_RPTR7 0x621F4 +#define ISP_RB_WPTR7 0x621F8 +#define ISP_RB_BASE_LO8 0x621FC +#define ISP_RB_BASE_HI8 0x62200 +#define ISP_RB_SIZE8 0x62204 +#define ISP_RB_RPTR8 0x62208 +#define ISP_RB_WPTR8 0x6220C +#define ISP_RB_BASE_LO9 0x62210 +#define ISP_RB_BASE_HI9 0x62214 +#define ISP_RB_SIZE9 0x62218 +#define ISP_RB_RPTR9 0x6221C +#define ISP_RB_WPTR9 0x62220 +#define ISP_RB_BASE_LO10 0x62224 +#define ISP_RB_BASE_HI10 0x62228 +#define ISP_RB_SIZE10 0x6222C +#define ISP_RB_RPTR10 0x62230 +#define ISP_RB_WPTR10 0x62234 +#define ISP_RB_BASE_LO11 0x62238 +#define ISP_RB_BASE_HI11 0x6223C +#define ISP_RB_SIZE11 0x62240 +#define ISP_RB_RPTR11 0x62244 +#define ISP_RB_WPTR11 0x62248 +#define ISP_RB_BASE_LO12 0x6224C +#define ISP_RB_BASE_HI12 0x62250 +#define ISP_RB_SIZE12 0x62254 +#define ISP_RB_RPTR12 0x62258 +#define ISP_RB_WPTR12 0x6225C + +#define ISP_POWER_STATUS 0x60000 + +#define ISP_MIPI_PHY0_REG0 0x66700 +#define ISP_MIPI_PHY1_REG0 0x66780 +#define ISP_MIPI_PHY2_REG0 0x67400 + +#define ISP_MIPI_PHY0_SIZE 0xD30 + +/* ISP_SOFT_RESET */ +#define ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK 0x00000001UL + +/* ISP_CCPU_CNTL */ +#define ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK 0x00040000UL + +/* ISP_STATUS */ +#define ISP_STATUS__CCPU_REPORT_MASK 0x000000feUL + +/* ISP_SYS_INT0_STATUS */ +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK 0x00010000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT10_INT_MASK 0x00040000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT11_INT_MASK 0x00100000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK 0x00400000UL + +/* ISP_SYS_INT0_EN */ +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK 0x00010000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK 0x00040000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK 0x00100000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK 0x00400000UL + +/* ISP_SYS_INT0_ACK */ +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK 0x00010000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT10_ACK_MASK 0x00040000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT11_ACK_MASK 0x00100000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK 0x00400000UL + +#endif
Du, Bin
maintainerRe: [PATCH v2 2/8] media: platform: amd: low level support for isp4 firmware
Thanks Mario, will add the Co-developed-by in all patches in the series.
Quoted 240 lines · Mario Limonciello
Quoted 8 lines · Bin Du
Low level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware.
Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>Same comment as first patch (and others), who wrote it? Is Co- developed-by missing?
Quoted 227 lines
---
drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4_hw.c | 46 +++++++ drivers/media/platform/amd/isp4/isp4_hw.h | 14 +++drivers/media/platform/amd/isp4/isp4_hw_reg.h| 116 ++++++++++++++++++4 files changed, 178 insertions(+), 1 deletion(-)create mode 100644
drivers/media/platform/amd/isp4/isp4_hw.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_hw.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_hw_reg.hdrivers/media/platform/amd/isp4/Makefile +0
-0@@ -3,7 +3,8 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc.obj-$(CONFIG_AMD_ISP4) += amd_capture.o
drivers/media/platform/amd/isp4/Makefile +2
-1-amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_hw.o \ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 ccflags-y += -I$(srctree)/include
drivers/media/platform/amd/isp4/isp4_hw.c new file +46
-0@@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/io.h> +#include <linux/types.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" + +#define RMMIO_SIZE 524288 + +u32 isp4hw_rreg (void __iomem *base,u32 reg) +{ + void __iomem *reg_addr; + + if (reg >= RMMIO_SIZE) + return RREG_FAILED_VAL; + + if (reg < ISP_MIPI_PHY0_REG0) + reg_addr = base + reg; + else if (reg <= ISP_MIPI_PHY0_REG0 + ISP_MIPI_PHY0_SIZE) + reg_addr = base + (reg - ISP_MIPI_PHY0_REG0); + else + return RREG_FAILED_VAL; + + return readl(reg_addr); +}; + +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val) +{ + void __iomem *reg_addr; + + if (reg >= RMMIO_SIZE) + return; + + if (reg < ISP_MIPI_PHY0_REG0) + reg_addr = base + reg; + else if (reg <= ISP_MIPI_PHY0_REG0 + ISP_MIPI_PHY0_SIZE) + reg_addr = base + (reg - ISP_MIPI_PHY0_REG0); + else + return; + + writel(val, reg_addr); +};drivers/media/platform/amd/isp4/isp4_hw.h new file +14
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_H_ +#define _ISP4_HW_H_ + +#define RREG_FAILED_VAL 0xFFFFFFFF + +u32 isp4hw_rreg (void __iomem *base,u32 reg); +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val); + +#endif drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +99
-0@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_REG_H_ +#define _ISP4_HW_REG_H_ + +#define ISP_SOFT_RESET 0x62000 +#define ISP_SYS_INT0_EN 0x62010 +#define ISP_SYS_INT0_STATUS 0x62014 +#define ISP_SYS_INT0_ACK 0x62018 +#define ISP_CCPU_CNTL 0x62054 +#define ISP_STATUS 0x62058 +#define ISP_LOG_RB_BASE_LO0 0x62148 +#define ISP_LOG_RB_BASE_HI0 0x6214C +#define ISP_LOG_RB_SIZE0 0x62150 +#define ISP_LOG_RB_RPTR0 0x62154 +#define ISP_LOG_RB_WPTR0 0x62158 +#define ISP_RB_BASE_LO1 0x62170 +#define ISP_RB_BASE_HI1 0x62174 +#define ISP_RB_SIZE1 0x62178 +#define ISP_RB_RPTR1 0x6217C +#define ISP_RB_WPTR1 0x62180 +#define ISP_RB_BASE_LO2 0x62184 +#define ISP_RB_BASE_HI2 0x62188 +#define ISP_RB_SIZE2 0x6218C +#define ISP_RB_RPTR2 0x62190 +#define ISP_RB_WPTR2 0x62194 +#define ISP_RB_BASE_LO3 0x62198 +#define ISP_RB_BASE_HI3 0x6219C +#define ISP_RB_SIZE3 0x621A0 +#define ISP_RB_RPTR3 0x621A4 +#define ISP_RB_WPTR3 0x621A8 +#define ISP_RB_BASE_LO4 0x621AC +#define ISP_RB_BASE_HI4 0x621B0 +#define ISP_RB_SIZE4 0x621B4 +#define ISP_RB_RPTR4 0x621B8 +#define ISP_RB_WPTR4 0x621BC +#define ISP_RB_BASE_LO5 0x621C0 +#define ISP_RB_BASE_HI5 0x621C4 +#define ISP_RB_SIZE5 0x621C8 +#define ISP_RB_RPTR5 0x621CC +#define ISP_RB_WPTR5 0x621D0 +#define ISP_RB_BASE_LO6 0x621D4 +#define ISP_RB_BASE_HI6 0x621D8 +#define ISP_RB_SIZE6 0x621DC +#define ISP_RB_RPTR6 0x621E0 +#define ISP_RB_WPTR6 0x621E4 +#define ISP_RB_BASE_LO7 0x621E8 +#define ISP_RB_BASE_HI7 0x621EC +#define ISP_RB_SIZE7 0x621F0 +#define ISP_RB_RPTR7 0x621F4 +#define ISP_RB_WPTR7 0x621F8 +#define ISP_RB_BASE_LO8 0x621FC +#define ISP_RB_BASE_HI8 0x62200 +#define ISP_RB_SIZE8 0x62204 +#define ISP_RB_RPTR8 0x62208 +#define ISP_RB_WPTR8 0x6220C +#define ISP_RB_BASE_LO9 0x62210 +#define ISP_RB_BASE_HI9 0x62214 +#define ISP_RB_SIZE9 0x62218 +#define ISP_RB_RPTR9 0x6221C +#define ISP_RB_WPTR9 0x62220 +#define ISP_RB_BASE_LO10 0x62224 +#define ISP_RB_BASE_HI10 0x62228 +#define ISP_RB_SIZE10 0x6222C +#define ISP_RB_RPTR10 0x62230 +#define ISP_RB_WPTR10 0x62234 +#define ISP_RB_BASE_LO11 0x62238 +#define ISP_RB_BASE_HI11 0x6223C +#define ISP_RB_SIZE11 0x62240 +#define ISP_RB_RPTR11 0x62244 +#define ISP_RB_WPTR11 0x62248 +#define ISP_RB_BASE_LO12 0x6224C +#define ISP_RB_BASE_HI12 0x62250 +#define ISP_RB_SIZE12 0x62254 +#define ISP_RB_RPTR12 0x62258 +#define ISP_RB_WPTR12 0x6225C + +#define ISP_POWER_STATUS 0x60000 + +#define ISP_MIPI_PHY0_REG0 0x66700 +#define ISP_MIPI_PHY1_REG0 0x66780 +#define ISP_MIPI_PHY2_REG0 0x67400 + +#define ISP_MIPI_PHY0_SIZE 0xD30 + +/* ISP_SOFT_RESET */ +#define ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK 0x00000001UL + +/* ISP_CCPU_CNTL */ +#define ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK 0x00040000UL + +/* ISP_STATUS */ +#define ISP_STATUS__CCPU_REPORT_MASK 0x000000feUL + +/* ISP_SYS_INT0_STATUS */ +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK
0x00010000UL
+#defineISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT10_INT_MASK0x00040000UL
+#defineISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT11_INT_MASK0x00100000UL
+#defineISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK0x00400000ULdrivers/media/platform/amd/isp4/isp4_hw_reg.h new file +4
-0+ +/* ISP_SYS_INT0_EN */ +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK 0x00010000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK
0x00040000UL
+#defineISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK0x00100000UL
+#defineISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK0x00400000ULdrivers/media/platform/amd/isp4/isp4_hw_reg.h new file +3
-0+ +/* ISP_SYS_INT0_ACK */ +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK
0x00010000UL
+#defineISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT10_ACK_MASK0x00040000UL
+#defineISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT11_ACK_MASK0x00100000UL
+#defineISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK0x00400000ULdrivers/media/platform/amd/isp4/isp4_hw_reg.h new file +2
-0+ +#endif
Sakari Ailus
maintainerRe: [PATCH v2 2/8] media: platform: amd: low level support for isp4 firmware
In reply to Bin DuHi Bin,
Quoted 5 lines · Bin Du
Low level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware.
Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.
Please rewrap this, the third line could well be longer.
Quoted 47 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4_hw.c | 46 +++++++ drivers/media/platform/amd/isp4/isp4_hw.h | 14 +++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 116 ++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.c create mode 100644 drivers/media/platform/amd/isp4/isp4_hw.h create mode 100644 drivers/media/platform/amd/isp4/isp4_hw_reg.hdrivers/media/platform/amd/isp4/Makefile +2
-1@@ -3,7 +3,8 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc. obj-$(CONFIG_AMD_ISP4) += amd_capture.o -amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 ccflags-y += -I$(srctree)/includedrivers/media/platform/amd/isp4/isp4_hw.c new file +14
-0@@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/io.h> +#include <linux/types.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" + +#define RMMIO_SIZE 524288 + +u32 isp4hw_rreg (void __iomem *base,u32 reg)
drivers/media/platform/amd/isp4/isp4_hw.c line 24
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +10
-0+{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE ) +return RREG_FAILED_VAL ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 );
Redundant parentheses.
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +7
-0+else +return RREG_FAILED_VAL ; + +return readl (reg_addr); +}; + +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val)
drivers/media/platform/amd/isp4/isp4_hw.c line 41
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +10
-0+{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE ) +return ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 );
Ditto.
Quoted 37 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +5
-0+else +return ; + +writel (val, reg_addr); +};drivers/media/platform/amd/isp4/isp4_hw.h new file +14
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_H_ +#define _ISP4_HW_H_ + +#define RREG_FAILED_VAL 0xFFFFFFFF + +u32 isp4hw_rreg (void __iomem *base,u32 reg); +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val); + +#endif drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +6
-0@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_REG_H_
drivers/media/platform/amd/isp4/isp4_hw_reg.h line 16
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +10
-0+#define _ISP4_HW_REG_H_ + +#define ISP_SOFT_RESET 0x62000 +#define ISP_SYS_INT0_EN 0x62010 +#define ISP_SYS_INT0_STATUS 0x62014 +#define ISP_SYS_INT0_ACK 0x62018 +#define ISP_CCPU_CNTL 0x62054 +#define ISP_STATUS 0x62058 +#define ISP_LOG_RB_BASE_LO0 0x62148 +#define ISP_LOG_RB_BASE_HI0 0x6214C
Lower case hexadecimals, please.
Quoted 100 lines
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +100
-0+#define ISP_LOG_RB_SIZE0 0x62150 +#define ISP_LOG_RB_RPTR0 0x62154 +#define ISP_LOG_RB_WPTR0 0x62158 +#define ISP_RB_BASE_LO1 0x62170 +#define ISP_RB_BASE_HI1 0x62174 +#define ISP_RB_SIZE1 0x62178 +#define ISP_RB_RPTR1 0x6217C +#define ISP_RB_WPTR1 0x62180 +#define ISP_RB_BASE_LO2 0x62184 +#define ISP_RB_BASE_HI2 0x62188 +#define ISP_RB_SIZE2 0x6218C +#define ISP_RB_RPTR2 0x62190 +#define ISP_RB_WPTR2 0x62194 +#define ISP_RB_BASE_LO3 0x62198 +#define ISP_RB_BASE_HI3 0x6219C +#define ISP_RB_SIZE3 0x621A0 +#define ISP_RB_RPTR3 0x621A4 +#define ISP_RB_WPTR3 0x621A8 +#define ISP_RB_BASE_LO4 0x621AC +#define ISP_RB_BASE_HI4 0x621B0 +#define ISP_RB_SIZE4 0x621B4 +#define ISP_RB_RPTR4 0x621B8 +#define ISP_RB_WPTR4 0x621BC +#define ISP_RB_BASE_LO5 0x621C0 +#define ISP_RB_BASE_HI5 0x621C4 +#define ISP_RB_SIZE5 0x621C8 +#define ISP_RB_RPTR5 0x621CC +#define ISP_RB_WPTR5 0x621D0 +#define ISP_RB_BASE_LO6 0x621D4 +#define ISP_RB_BASE_HI6 0x621D8 +#define ISP_RB_SIZE6 0x621DC +#define ISP_RB_RPTR6 0x621E0 +#define ISP_RB_WPTR6 0x621E4 +#define ISP_RB_BASE_LO7 0x621E8 +#define ISP_RB_BASE_HI7 0x621EC +#define ISP_RB_SIZE7 0x621F0 +#define ISP_RB_RPTR7 0x621F4 +#define ISP_RB_WPTR7 0x621F8 +#define ISP_RB_BASE_LO8 0x621FC +#define ISP_RB_BASE_HI8 0x62200 +#define ISP_RB_SIZE8 0x62204 +#define ISP_RB_RPTR8 0x62208 +#define ISP_RB_WPTR8 0x6220C +#define ISP_RB_BASE_LO9 0x62210 +#define ISP_RB_BASE_HI9 0x62214 +#define ISP_RB_SIZE9 0x62218 +#define ISP_RB_RPTR9 0x6221C +#define ISP_RB_WPTR9 0x62220 +#define ISP_RB_BASE_LO10 0x62224 +#define ISP_RB_BASE_HI10 0x62228 +#define ISP_RB_SIZE10 0x6222C +#define ISP_RB_RPTR10 0x62230 +#define ISP_RB_WPTR10 0x62234 +#define ISP_RB_BASE_LO11 0x62238 +#define ISP_RB_BASE_HI11 0x6223C +#define ISP_RB_SIZE11 0x62240 +#define ISP_RB_RPTR11 0x62244 +#define ISP_RB_WPTR11 0x62248 +#define ISP_RB_BASE_LO12 0x6224C +#define ISP_RB_BASE_HI12 0x62250 +#define ISP_RB_SIZE12 0x62254 +#define ISP_RB_RPTR12 0x62258 +#define ISP_RB_WPTR12 0x6225C + +#define ISP_POWER_STATUS 0x60000 + +#define ISP_MIPI_PHY0_REG0 0x66700 +#define ISP_MIPI_PHY1_REG0 0x66780 +#define ISP_MIPI_PHY2_REG0 0x67400 + +#define ISP_MIPI_PHY0_SIZE 0xD30 + +/* ISP_SOFT_RESET */ +#define ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK 0x00000001UL + +/* ISP_CCPU_CNTL */ +#define ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK 0x00040000UL + +/* ISP_STATUS */ +#define ISP_STATUS__CCPU_REPORT_MASK 0x000000feUL + +/* ISP_SYS_INT0_STATUS */ +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK 0x00010000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT10_INT_MASK 0x00040000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT11_INT_MASK 0x00100000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK 0x00400000UL + +/* ISP_SYS_INT0_EN */ +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK 0x00010000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK 0x00040000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK 0x00100000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK 0x00400000UL + +/* ISP_SYS_INT0_ACK */ +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK 0x00010000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT10_ACK_MASK 0x00040000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT11_ACK_MASK 0x00100000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK 0x00400000UL + +#endif
Signature · 3 lines
Kind regards, Sakari Ailus
Du, Bin
maintainerRe: [PATCH v2 2/8] media: platform: amd: low level support for isp4 firmware
Many thanks Sakari Ailus for the review.
Quoted 11 lines · Sakari Ailus
Hi Bin,
Quoted 5 lines · Bin Du
Low level functions for access the registers and mapping to their ranges. This change also includes register definitions for ring buffer used to communicate with ISP Firmware.
Ring buffer is the communication interface between driver and ISP Firmware. Command and responses are exchanged through the ring buffer.Please rewrap this, the third line could well be longer.
Sure, will do in the next patch
Quoted 51 lines
Quoted 51 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 3 +- drivers/media/platform/amd/isp4/isp4_hw.c | 46 +++++++ drivers/media/platform/amd/isp4/isp4_hw.h | 14 +++ drivers/media/platform/amd/isp4/isp4_hw_reg.h | 116 ++++++++++++++++++ 4 files changed, 178 insertions(+), 1 deletion(-)create mode 100644
drivers/media/platform/amd/isp4/isp4_hw.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_hw.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_hw_reg.hdrivers/media/platform/amd/isp4/Makefile +2
-1@@ -3,7 +3,8 @@ # Copyright (C) 2025 Advanced Micro Devices, Inc. obj-$(CONFIG_AMD_ISP4) += amd_capture.o -amd_capture-objs := isp4.o +amd_capture-objs := isp4.o \ + isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 ccflags-y += -I$(srctree)/includedrivers/media/platform/amd/isp4/isp4_hw.c new file +18
-0@@ -0,0 +1,46 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/io.h> +#include <linux/types.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" + +#define RMMIO_SIZE 524288 + +u32 isp4hw_rreg (void __iomem *base,u32 reg) +{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE )
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_hw.c line 24
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +6
-0+return RREG_FAILED_VAL ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 );Redundant parentheses.
Sure, will remove it in the next patch
Quoted 11 lines
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +11
-0+else +return RREG_FAILED_VAL ; + +return readl (reg_addr); +}; + +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val) +{ +void __iomem *reg_addr; + +if (reg >=RMMIO_SIZE )
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_hw.c line 41
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +6
-0+return ; + +if (reg <ISP_MIPI_PHY0_REG0 ) + reg_addr = base + reg; +else if (reg <=ISP_MIPI_PHY0_REG0 +ISP_MIPI_PHY0_SIZE ) + reg_addr = base + (reg -ISP_MIPI_PHY0_REG0 );Ditto.
Sure, will remove it in the next patch
Quoted 41 lines
Quoted 41 lines
drivers/media/platform/amd/isp4/isp4_hw.c new file +5
-0+else +return ; + +writel (val, reg_addr); +};drivers/media/platform/amd/isp4/isp4_hw.h new file +14
-0@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_H_ +#define _ISP4_HW_H_ + +#define RREG_FAILED_VAL 0xFFFFFFFF + +u32 isp4hw_rreg (void __iomem *base,u32 reg); +void isp4hw_wreg (void __iomem *base,u32 reg,u32 val); + +#endif drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +10
-0@@ -0,0 +1,116 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_HW_REG_H_ +#define _ISP4_HW_REG_H_ + +#define ISP_SOFT_RESET 0x62000 +#define ISP_SYS_INT0_EN 0x62010
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_hw_reg.h line 16
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +6
-0+#define ISP_SYS_INT0_STATUS 0x62014 +#define ISP_SYS_INT0_ACK 0x62018 +#define ISP_CCPU_CNTL 0x62054 +#define ISP_STATUS 0x62058 +#define ISP_LOG_RB_BASE_LO0 0x62148 +#define ISP_LOG_RB_BASE_HI0 0x6214CLower case hexadecimals, please.
Sure, will modify in the next patch
Quoted 101 lines
Quoted 100 lines
drivers/media/platform/amd/isp4/isp4_hw_reg.h new file +100
-0+#define ISP_LOG_RB_SIZE0 0x62150 +#define ISP_LOG_RB_RPTR0 0x62154 +#define ISP_LOG_RB_WPTR0 0x62158 +#define ISP_RB_BASE_LO1 0x62170 +#define ISP_RB_BASE_HI1 0x62174 +#define ISP_RB_SIZE1 0x62178 +#define ISP_RB_RPTR1 0x6217C +#define ISP_RB_WPTR1 0x62180 +#define ISP_RB_BASE_LO2 0x62184 +#define ISP_RB_BASE_HI2 0x62188 +#define ISP_RB_SIZE2 0x6218C +#define ISP_RB_RPTR2 0x62190 +#define ISP_RB_WPTR2 0x62194 +#define ISP_RB_BASE_LO3 0x62198 +#define ISP_RB_BASE_HI3 0x6219C +#define ISP_RB_SIZE3 0x621A0 +#define ISP_RB_RPTR3 0x621A4 +#define ISP_RB_WPTR3 0x621A8 +#define ISP_RB_BASE_LO4 0x621AC +#define ISP_RB_BASE_HI4 0x621B0 +#define ISP_RB_SIZE4 0x621B4 +#define ISP_RB_RPTR4 0x621B8 +#define ISP_RB_WPTR4 0x621BC +#define ISP_RB_BASE_LO5 0x621C0 +#define ISP_RB_BASE_HI5 0x621C4 +#define ISP_RB_SIZE5 0x621C8 +#define ISP_RB_RPTR5 0x621CC +#define ISP_RB_WPTR5 0x621D0 +#define ISP_RB_BASE_LO6 0x621D4 +#define ISP_RB_BASE_HI6 0x621D8 +#define ISP_RB_SIZE6 0x621DC +#define ISP_RB_RPTR6 0x621E0 +#define ISP_RB_WPTR6 0x621E4 +#define ISP_RB_BASE_LO7 0x621E8 +#define ISP_RB_BASE_HI7 0x621EC +#define ISP_RB_SIZE7 0x621F0 +#define ISP_RB_RPTR7 0x621F4 +#define ISP_RB_WPTR7 0x621F8 +#define ISP_RB_BASE_LO8 0x621FC +#define ISP_RB_BASE_HI8 0x62200 +#define ISP_RB_SIZE8 0x62204 +#define ISP_RB_RPTR8 0x62208 +#define ISP_RB_WPTR8 0x6220C +#define ISP_RB_BASE_LO9 0x62210 +#define ISP_RB_BASE_HI9 0x62214 +#define ISP_RB_SIZE9 0x62218 +#define ISP_RB_RPTR9 0x6221C +#define ISP_RB_WPTR9 0x62220 +#define ISP_RB_BASE_LO10 0x62224 +#define ISP_RB_BASE_HI10 0x62228 +#define ISP_RB_SIZE10 0x6222C +#define ISP_RB_RPTR10 0x62230 +#define ISP_RB_WPTR10 0x62234 +#define ISP_RB_BASE_LO11 0x62238 +#define ISP_RB_BASE_HI11 0x6223C +#define ISP_RB_SIZE11 0x62240 +#define ISP_RB_RPTR11 0x62244 +#define ISP_RB_WPTR11 0x62248 +#define ISP_RB_BASE_LO12 0x6224C +#define ISP_RB_BASE_HI12 0x62250 +#define ISP_RB_SIZE12 0x62254 +#define ISP_RB_RPTR12 0x62258 +#define ISP_RB_WPTR12 0x6225C + +#define ISP_POWER_STATUS 0x60000 + +#define ISP_MIPI_PHY0_REG0 0x66700 +#define ISP_MIPI_PHY1_REG0 0x66780 +#define ISP_MIPI_PHY2_REG0 0x67400 + +#define ISP_MIPI_PHY0_SIZE 0xD30 + +/* ISP_SOFT_RESET */ +#define ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK 0x00000001UL + +/* ISP_CCPU_CNTL */ +#define ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK 0x00040000UL + +/* ISP_STATUS */ +#define ISP_STATUS__CCPU_REPORT_MASK 0x000000feUL + +/* ISP_SYS_INT0_STATUS */ +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT9_INT_MASK 0x00010000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT10_INT_MASK 0x00040000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT11_INT_MASK 0x00100000UL +#define ISP_SYS_INT0_STATUS__SYS_INT_RINGBUFFER_WPT12_INT_MASK 0x00400000UL + +/* ISP_SYS_INT0_EN */ +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK 0x00010000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK 0x00040000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK 0x00100000UL +#define ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK 0x00400000UL + +/* ISP_SYS_INT0_ACK */ +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT9_ACK_MASK 0x00010000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT10_ACK_MASK 0x00040000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT11_ACK_MASK 0x00100000UL +#define ISP_SYS_INT0_ACK__SYS_INT_RINGBUFFER_WPT12_ACK_MASK 0x00400000UL + +#endif
Bin Du
maintainerPATCH v2 3/8 media: platform: amd: Add helpers to configure isp4 mipi phy
In reply to Bin DuThe helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.c create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.h
drivers/media/platform/amd/isp4/Makefile +1 -0
@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_phy.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4
drivers/media/platform/amd/isp4/isp4_phy.c new file +1547 -0
1,547 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_phy.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_PHY_H_ +#define _ISP4_PHY_H_ + +int isp4phy_start (struct device *dev, +void __iomem *base,u32 phy_id,u64 bit_rate, +u32 lane_num); +int isp4phy_stop (void __iomem *base,u32 phy_id); + +#endif
Signature · 1 line
2.34.1
Sakari Ailus
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Hi Bin,
Quoted 44 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.c create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.hdrivers/media/platform/amd/isp4/Makefile +1
-0@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_phy.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/isp4_phy.c new file +11
-0@@ -0,0 +1,1547 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/delay.h> +#include <linux/device.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_phy.h"
drivers/media/platform/amd/isp4/isp4_phy.c line 21
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ +#define ISP_MIPI_DPHY 0 +#define T_DCO 5/* nominal: 200MHz */ +#define TMIN_RX 4 +#define TIMEBASE 5/* 5us */ + +#define MIN_T_HS_SETTLE_NS 95 +#define MAX_T_HS_SETTLE_NS 130 +#define MIN_T_HS_SETTLE_UI 4 +#define MAX_T_HS_SETTLE_UI 6
Please align the macro bodies to the same column.
Also using a descriptive prefix for these (such as AMDISP4) would seem like a reasonable idea. The same goes for the other macros used by the driver, too.
Speaking of macro names, some of the names below look quite random. Are these from a hardware datasheet (or something alike)? I might consider sanitising them. Some are also not in form fit for use in drivers, e.g. if you have many of something, then the number should be an argument to the macro, not part of the macro name, e.g. configuration related to lanes -- if feasible.
Quoted 317 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +317
-0+ +#define PPI_STARTUP_RW_COMMON_DPHY_2 0x0C02 +#define PPI_STARTUP_RW_COMMON_DPHY_6 0x0C06 +#define PPI_STARTUP_RW_COMMON_DPHY_7 0x0C07 +#define PPI_STARTUP_RW_COMMON_DPHY_8 0x0C08 +#define PPI_STARTUP_RW_COMMON_DPHY_10 0x0C10 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 0x1CF2 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 0x1CF0 +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1 0x0C11 +#define PPI_CALIBCTRL_RW_COMMON_BG_0 0x0C26 +#define PPI_RW_LPDCOCAL_NREF 0x0E02 +#define PPI_RW_LPDCOCAL_NREF_RANGE 0x0E03 +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG 0x0E05 +#define PPI_RW_LPDCOCAL_VT_CONFIG 0x0E06 +#define PPI_RW_LPDCOCAL_COARSE_CFG 0x0E08 +#define PPI_RW_COMMON_CFG 0x0E36 +#define PPI_RW_TERMCAL_CFG_0 0x0E40 +#define PPI_RW_OFFSETCAL_CFG_0 0x0E50 +#define PPI_RW_LPDCOCAL_TIMEBASE 0x0E01 +#define CORE_AFE_CTRL_2_0 0x1C20 +#define CORE_AFE_CTRL_2_1 0x1C21 +#define CORE_AFE_CTRL_2_3 0x1C23 +#define CORE_AFE_CTRL_2_5 0x1C25 +#define CORE_AFE_CTRL_2_6 0x1C26 +#define CORE_AFE_CTRL_2_7 0x1C27 +#define CORE_DIG_COMMON_RW_DESKEW_FINE_MEM 0x1FF0 +#define CORE_DIG_DLANE_CLK_RW_CFG_0 0x3800 +#define CORE_DIG_DLANE_0_RW_CFG_0 0x3000 +#define CORE_DIG_DLANE_1_RW_CFG_0 0x3200 +#define CORE_DIG_DLANE_2_RW_CFG_0 0x3400 +#define CORE_DIG_DLANE_3_RW_CFG_0 0x3600 +#define CORE_AFE_LANE0_CTRL_2_9 0x1029 +#define CORE_AFE_LANE1_CTRL_2_9 0x1229 +#define CORE_AFE_LANE2_CTRL_2_9 0x1429 +#define CORE_AFE_LANE3_CTRL_2_9 0x1629 +#define CORE_AFE_LANE4_CTRL_2_9 0x1829 +#define CORE_DIG_RW_COMMON_6 0x1C46 +#define CORE_DIG_RW_COMMON_7 0x1C47 +#define PPI_RW_DDLCAL_CFG_0 0x0E20 +#define PPI_RW_DDLCAL_CFG_1 0x0E21 +#define PPI_RW_DDLCAL_CFG_2 0x0E22 +#define PPI_RW_DDLCAL_CFG_3 0x0E23 +#define PPI_RW_DDLCAL_CFG_4 0x0E24 +#define PPI_RW_DDLCAL_CFG_5 0x0E25 +#define PPI_RW_DDLCAL_CFG_6 0x0E26 +#define PPI_RW_DDLCAL_CFG_7 0x0E27 +#define CORE_AFE_LANE0_CTRL_2_8 0x1028 +#define CORE_AFE_LANE1_CTRL_2_8 0x1228 +#define CORE_AFE_LANE2_CTRL_2_8 0x1428 +#define CORE_AFE_LANE3_CTRL_2_8 0x1628 +#define CORE_AFE_LANE4_CTRL_2_8 0x1828 +#define CORE_DIG_DLANE_0_RW_LP_0 0x3040 +#define CORE_DIG_DLANE_1_RW_LP_0 0x3240 +#define CORE_DIG_DLANE_2_RW_LP_0 0x3440 +#define CORE_DIG_DLANE_3_RW_LP_0 0x3640 +#define CORE_AFE_LANE0_CTRL_2_2 0x1022 +#define CORE_AFE_LANE1_CTRL_2_2 0x1222 +#define CORE_AFE_LANE2_CTRL_2_2 0x1422 +#define CORE_AFE_LANE3_CTRL_2_2 0x1622 +#define CORE_AFE_LANE4_CTRL_2_2 0x1822 +#define CORE_AFE_LANE0_CTRL_2_12 0x102C +#define CORE_AFE_LANE1_CTRL_2_12 0x122C +#define CORE_AFE_LANE2_CTRL_2_12 0x142C +#define CORE_AFE_LANE3_CTRL_2_12 0x162C +#define CORE_AFE_LANE4_CTRL_2_12 0x182C +#define CORE_AFE_LANE0_CTRL_2_13 0x102D +#define CORE_AFE_LANE1_CTRL_2_13 0x122D +#define CORE_AFE_LANE2_CTRL_2_13 0x142D +#define CORE_AFE_LANE3_CTRL_2_13 0x162D +#define CORE_AFE_LANE4_CTRL_2_13 0x182D +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0 0x3880 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7 0x3887 +#define CORE_DIG_DLANE_0_RW_HS_RX_0 0x3080 +#define CORE_DIG_DLANE_1_RW_HS_RX_0 0x3280 +#define CORE_DIG_DLANE_2_RW_HS_RX_0 0x3480 +#define CORE_DIG_DLANE_3_RW_HS_RX_0 0x3680 +#define CORE_DIG_DLANE_0_RW_CFG_1 0x3001 +#define CORE_DIG_DLANE_1_RW_CFG_1 0x3201 +#define CORE_DIG_DLANE_2_RW_CFG_1 0x3401 +#define CORE_DIG_DLANE_3_RW_CFG_1 0x3601 +#define CORE_DIG_DLANE_0_RW_HS_RX_2 0x3082 +#define CORE_DIG_DLANE_1_RW_HS_RX_2 0x3282 +#define CORE_DIG_DLANE_2_RW_HS_RX_2 0x3482 +#define CORE_DIG_DLANE_3_RW_HS_RX_2 0x3682 +#define CORE_DIG_DLANE_0_RW_LP_2 0x3042 +#define CORE_DIG_DLANE_1_RW_LP_2 0x3242 +#define CORE_DIG_DLANE_2_RW_LP_2 0x3442 +#define CORE_DIG_DLANE_3_RW_LP_2 0x3642 +#define CORE_DIG_DLANE_CLK_RW_LP_0 0x3840 +#define CORE_DIG_DLANE_CLK_RW_LP_2 0x3842 +#define CORE_DIG_DLANE_0_RW_HS_RX_1 0x3081 +#define CORE_DIG_DLANE_1_RW_HS_RX_1 0x3281 +#define CORE_DIG_DLANE_2_RW_HS_RX_1 0x3481 +#define CORE_DIG_DLANE_3_RW_HS_RX_1 0x3681 +#define CORE_DIG_DLANE_0_RW_HS_RX_3 0x3083 +#define CORE_DIG_DLANE_1_RW_HS_RX_3 0x3283 +#define CORE_DIG_DLANE_2_RW_HS_RX_3 0x3483 +#define CORE_DIG_DLANE_3_RW_HS_RX_3 0x3683 +#define CORE_DIG_DLANE_0_RW_HS_RX_4 0x3084 +#define CORE_DIG_DLANE_1_RW_HS_RX_4 0x3284 +#define CORE_DIG_DLANE_2_RW_HS_RX_4 0x3484 +#define CORE_DIG_DLANE_3_RW_HS_RX_4 0x3684 +#define CORE_DIG_DLANE_0_RW_HS_RX_5 0x3085 +#define CORE_DIG_DLANE_1_RW_HS_RX_5 0x3285 +#define CORE_DIG_DLANE_2_RW_HS_RX_5 0x3485 +#define CORE_DIG_DLANE_3_RW_HS_RX_5 0x3685 +#define CORE_DIG_DLANE_0_RW_HS_RX_6 0x3086 +#define CORE_DIG_DLANE_1_RW_HS_RX_6 0x3286 +#define CORE_DIG_DLANE_2_RW_HS_RX_6 0x3486 +#define CORE_DIG_DLANE_3_RW_HS_RX_6 0x3686 +#define CORE_DIG_DLANE_0_RW_HS_RX_7 0x3087 +#define CORE_DIG_DLANE_1_RW_HS_RX_7 0x3287 +#define CORE_DIG_DLANE_2_RW_HS_RX_7 0x3487 +#define CORE_DIG_DLANE_3_RW_HS_RX_7 0x3687 +#define CORE_DIG_DLANE_0_RW_HS_RX_9 0x3089 +#define CORE_DIG_DLANE_1_RW_HS_RX_9 0x3289 +#define CORE_DIG_DLANE_2_RW_HS_RX_9 0x3489 +#define CORE_DIG_DLANE_3_RW_HS_RX_9 0x3689 +#define PPI_R_TERMCAL_DEBUG_0 0x0E41 + +#define PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK 0x00FF +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK 0x2000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK 0x1000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK 0x00FC +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK 0x0FFF +#define PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK 0x00FF +#define PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK 0x01FF +#define PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK 0x07FF +#define PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK 0x001F +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK 0xFE00 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK 0x0001 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK 0x0002 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK 0x007C +#define PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK 0x0003 +#define PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK 0x0003 +#define PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK 0x007F +#define PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK 0x001F +#define PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK 0x03FF +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK 0x01FF +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK 0xFF80 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK 0x0100 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK 0x2000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK 0x1000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK 0x0100 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK 0x4000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK 0x0100 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0003 +#define CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x000C +#define CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0030 +#define CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x00C0 +#define CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0300 +#define PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK 0x1F80 +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK 0xFF00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK 0xF000 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK 0x0C00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK 0x0100 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK 0x0200 +#define PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK 0x007F +#define PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK 0x03F0 +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK 0x000F +#define CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK 0x0001 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK 0x0038 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK 0x0007 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK 0x00FF +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 + +struct isp4phy_mipi_reg_seq { +u16 addr; +u16 mask; +u16 data; +}; + +union isp4phy_mipi_0 {
drivers/media/platform/amd/isp4/isp4_phy.c line 348
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_1 { + struct { + u32 mode : 1;
Please pad these -- I don't think the ABI otherwise requires they're in a particular location of the container (u32).
Quoted 50 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +50
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; +
drivers/media/platform/amd/isp4/isp4_phy.c line 408
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_idx { + struct { + u32 addr : 16;
u16 would seem appropriate here.
drivers/media/platform/amd/isp4/isp4_phy.c line 415
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { + struct { + u32 data : 16;
Ditto.
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +12
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +}; +
drivers/media/platform/amd/isp4/isp4_phy.c line 437
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+struct isp4phy_mipi_reg { +union isp4phy_mipi_0 isp_mipi_phy0; +union isp4phy_mipi_1 isp_mipi_phy1; +union isp4phy_mipi_2 isp_mipi_phy2; +struct isp4phy_mipi_3 isp_mipi_phy3; +union isp4phy_mipi_4 isp_mipi_phy4; +union isp4phy_mipi_5 isp_mipi_phy5; +union isp4phy_mipi_6 isp_mipi_phy6; +union isp4phy_mipi_7 isp_mipi_phy7; +u32 reserve;
"reserved"?
Quoted 24 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +24
-0+union isp4phy_mipi_ind_idx isp_mipi_phy_ind_idx; +union isp4phy_mipi_ind_data isp_mipi_phy_ind_data; +union isp4phy_mipi_ind_wack isp_mipi_phy_inc_wack; +}; + +struct isp4phy_mipi_config { +u16 afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg; +u16 max_phase; +u16 ddlcal_cfg_5ddlcal_dll_fbk_reg; +u16 ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg; +u16 cfg_1cfg_1_sot_detection_reg; +u16 hs_rx_2hs_rx_2_ignore_alterncal_reg; +u16 cfg_1cfg_1_deskew_supported_reg; +u16 afe_lanex_ctrl_2_9oa_hs_clk_div_reg; +u16 hs_rx_0hs_rx_0_thssettle_reg; +u16 hs_rx_3hs_rx_3_fjump_deskew_reg; +u16 hs_rx_6hs_rx_6_min_eye_opening_deskew_reg; +}; + +enum isp4phy_mipi_id {
drivers/media/platform/amd/isp4/isp4_phy.c line 471
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ISP_MIPI_PHY_ID_0 =0 , +ISP_MIPI_PHY_ID_1 =1 , +ISP_MIPI_PHY_ID_2 =2 , +ISP_MIPI_PHY_ID_MAX +}; + +static const struct isp4phy_mipi_reg *isp_mipi_phy_reg[ISP_MIPI_PHY_ID_MAX ] = { + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY0_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY1_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY2_REG0,
That's an interesting way to prefill structs. I don't think these macros expand to valid pointers.
Quoted 185 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +185
-0+}; + +static const struct isp4phy_mipi_reg_seq startup_seq_general_common_config[] = { + {PPI_STARTUP_RW_COMMON_DPHY_10 ,PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK ,0x30 }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK ,0x0 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK ,0x1 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK ,0x3F + }, + { +PPI_STARTUP_RW_COMMON_STARTUP_1_1 , +PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK ,0x233 + }, + {PPI_STARTUP_RW_COMMON_DPHY_6 ,PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK ,0x27 }, + {PPI_CALIBCTRL_RW_COMMON_BG_0 ,PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK ,0x1F4 }, + {PPI_RW_LPDCOCAL_NREF ,PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK ,0x320 }, + {PPI_RW_LPDCOCAL_NREF_RANGE ,PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_TWAIT_CONFIG ,PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK ,0x7F }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK ,0x1 }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK ,0x0 }, + {PPI_RW_LPDCOCAL_COARSE_CFG ,PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK ,0x1 }, + {PPI_RW_COMMON_CFG ,PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK ,0x3 }, +}; + +static const struct isp4phy_mipi_reg_seq startup_seq_common[] = { + {PPI_STARTUP_RW_COMMON_DPHY_2 ,PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK ,0x5 }, + {PPI_RW_TERMCAL_CFG_0 ,PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK ,0x17 }, + {PPI_RW_OFFSETCAL_CFG_0 ,PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK ,0x4 }, + {PPI_RW_LPDCOCAL_TIMEBASE ,PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK ,0x5F }, + { +PPI_RW_LPDCOCAL_TWAIT_CONFIG , +PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK ,0x1D + }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK ,0x1D }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_5 ,CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK ,0x0 }, +}; + +static const struct isp4phy_mipi_reg_seq + startup_seq_dphy_periodic_deskew_program[] = { + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x404 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x40C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x414 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x41C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x423 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x429 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x430 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x43A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x445 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x44A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x450 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x45A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x465 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x469 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x472 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x47A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x485 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x489 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x490 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x49A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x504 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x50C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x514 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x51C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x523 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x529 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x530 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x53A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x545 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x54A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x550 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x55A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x565 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x569 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x572 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x57A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x585 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x589 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x590 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x59A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x604 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x60C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x614 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x61C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x623 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x629 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x632 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x63A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x645 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x64A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x650 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x65A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x665 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x669 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x672 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x67A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x685 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x689 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x690 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x69A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x704 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x70C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x714 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x71C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x723 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x72A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x730 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x73A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x745 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x74A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x750 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x75A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x765 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x769 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x772 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x77A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x785 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x789 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x790 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x79A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7EC },
drivers/media/platform/amd/isp4/isp4_phy.c line 666
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ { CORE_DIG_COMMON_RW_DESKEW_FINE_MEM, 0, 0x7F4 }, + { CORE_DIG_COMMON_RW_DESKEW_FINE_MEM, 0, 0x7FC }, +}; + +inline u16 isp4phy_rreg (void __iomem *base,u32 phy_id,u16 addr) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +return (u16 )isp4hw_rreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data));
Redundant parentheses.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+} + +inline void isp4phy_wreg (void __iomem *base,u32 phy_id,u16 addr,u16 data) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data), data); +} +
drivers/media/platform/amd/isp4/isp4_phy.c line 686
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+static void isp4phy_mask_wreg (void __iomem *base,u32 phy_id,u16 addr, +u16 mask,u16 regval) +{ +unsigned long _mask = mask; +u16 shift =0 ; +u16 data; + + data =isp4phy_rreg (base, phy_id, addr); +if (mask) + shift =find_first_bit (&_mask,16 );
__ffs()?
Quoted 44 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +44
-0+ data = (data & ~mask) | ((regval << shift) & mask); + +isp4phy_wreg (base, phy_id, addr, data); +} + +static void isp4phy_optional_features_dphy (void __iomem *base,u32 phy_id) +{ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_9 , +CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_9 , +CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK , +0x0 );
drivers/media/platform/amd/isp4/isp4_phy.c line 740
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_9 , +CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK , +0x0 ); + } +} + +static void isp4phy_dphy_periodic_deskew_program (void __iomem *base, +u32 phy_id) +{ + for (int ctr = 0;
unsigned int?
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+ ctr <ARRAY_SIZE (startup_seq_dphy_periodic_deskew_program); + ctr++) +isp4phy_wreg (base, phy_id, + startup_seq_dphy_periodic_deskew_program[ctr].addr, + startup_seq_dphy_periodic_deskew_program[ctr].data); +}
drivers/media/platform/amd/isp4/isp4_phy.c line 756
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ +static void isp4phy_dphy_specific (void __iomem *base,u32 phy_id, +u64 data_rate, +struct isp4phy_mipi_config *phycfg) +{ +u64 half_rate = data_rate >>1 ; +u16 ddl_cal; + + ddl_cal =TIMEBASE * half_rate; + ddl_cal = (ddl_cal +31 ) >>5 ;
I think you could do this on a single line as well.
Quoted 457 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +457
-0+ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_8 , +PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK ,0x50 ); + +if (data_rate <1500 ) { +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x68 ); + }else { +/* Digital Delay Line (DDL) tuning calibration */ +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x28 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_0 , +PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK ,0x77 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK ,0x22 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK ,0x4 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK ,0x1 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_4 , +PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK ,0xA ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_6 , +PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK ,0xA ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK ,0xB ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_3 , +PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK , ddl_cal); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK , phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK , + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK , + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_8 , +CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_8 , +CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_8 , +CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_8 , +CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_8 , +CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); + } + } + +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_2 , +CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK ,0x0 ); + +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_2 , +CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_2 , +CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK ,0x0 ); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK ,0x1 ); + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_0 , +CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK ,0x1C ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_7 , +CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK ,0x6 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_0 , +CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_0 , +CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_0 , +CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_0 , +CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_2 , +CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_2 , +CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_2 , +CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_2 , +CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_0 , +CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_2 , +CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_1 , +CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_1 , +CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_1 , +CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_1 , +CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_4 , +CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_4 , +CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_4 , +CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_4 , +CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_6 , +CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_6 , +CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_9 , +CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_9 , +CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_9 , +CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_9 , +CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); + isp4phy_mask_wreg(base, phy_id, CORE_DIG_DLANE_1_RW_HS_RX_6,
drivers/media/platform/amd/isp4/isp4_phy.c line 1223
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_6 , +CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); + }
Could you do this using a loop instead? With a bit saner macros, that should be quite a bit easier, too.
drivers/media/platform/amd/isp4/isp4_phy.c line 1236
Quoted 13 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +13
-0+} + +static void isp4phy_common (void __iomem *base,u32 phy_id) +{ +for (int ctr =0 ; ctr <ARRAY_SIZE (startup_seq_common); ctr++) +isp4phy_mask_wreg (base, phy_id, startup_seq_common[ctr].addr, + startup_seq_common[ctr].mask, + startup_seq_common[ctr].data); +} + +static void isp4phy_general_common_config (void __iomem *base,u32 phy_id) +{ +for (int ctr =0 ; ctr <ARRAY_SIZE (startup_seq_general_common_config); ctr++)
Unsigned int for these, too, please.
Quoted 84 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +84
-0+isp4phy_mask_wreg (base, phy_id, + startup_seq_general_common_config[ctr].addr, + startup_seq_general_common_config[ctr].mask, + startup_seq_general_common_config[ctr].data); +} + +static void +isp4phy_calculate_datarate_cfgs_rx (u32 phy_id,u64 data_rate, +u32 lane, +struct isp4phy_mipi_config *phycfg) +{ +u64 half_rate = data_rate >>1 ; +u64 hs_clk_freq; + + hs_clk_freq = half_rate *1000 ; + +if (data_rate <=2500 ) + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg =1 ; +else if (data_rate <=4500 ) + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg =0 ; + +if (data_rate <1500 ) { +/* do nothing */ + }else if (data_rate <1588 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =143 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =17 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =3 ; + }else if (data_rate <1688 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =135 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =16 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <1800 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =127 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =15 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <1929 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =119 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =14 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <2077 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =111 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =13 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <2250 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =103 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =12 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <2455 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =95 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =11 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <2700 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =87 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =10 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <3000 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =79 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =9 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <3230 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =71 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =8 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =0 ; + }else if (data_rate <3600 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =87 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =10 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <4000 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =79 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =9 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <4500 ) {
drivers/media/platform/amd/isp4/isp4_phy.c line 1330
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =71 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =8 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =63 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =7 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =0 ; + }
Please add an array for the values and implement this as a loop instead.
Quoted 19 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +19
-0+ +if (data_rate <=1500 ) { + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg =1 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg =1 ; + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg =1 ; + phycfg->cfg_1cfg_1_deskew_supported_reg =0 ; + phycfg->cfg_1cfg_1_sot_detection_reg =1 ; + }else if (data_rate <=4500 ) { + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg =0 ; + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg =0 ; + phycfg->cfg_1cfg_1_deskew_supported_reg =1 ; + phycfg->cfg_1cfg_1_sot_detection_reg =0 ; + } + +if (data_rate <160 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b001 ;
drivers/media/platform/amd/isp4/isp4_phy.c line 1359
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+else if (data_rate <320 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b010 ; +else if (data_rate <640 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b011 ; +else if (data_rate <1280 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b100 ; +else if (data_rate <2560 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b101 ; +else + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b110 ;
Ditto. Or maybe use ilog2()?
Quoted 16 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +16
-0+ +u32 t_hs_settle_ns =MIN_T_HS_SETTLE_NS +MAX_T_HS_SETTLE_NS ; + + t_hs_settle_ns = t_hs_settle_ns >>1 ; +u32 t_hs_settle_ui =MIN_T_HS_SETTLE_UI +MAX_T_HS_SETTLE_UI ; + + t_hs_settle_ui = t_hs_settle_ui >>1 ; + + t_hs_settle_ui = t_hs_settle_ui *1000000 ; + t_hs_settle_ui = t_hs_settle_ui >>1 ; + t_hs_settle_ui =div64_u64 (t_hs_settle_ui, hs_clk_freq); + +u32 ths_settle_target = t_hs_settle_ns + t_hs_settle_ui; + + ths_settle_target =div64_u64 (ths_settle_target,T_DCO ); + phycfg->hs_rx_0hs_rx_0_thssettle_reg = ths_settle_target -TMIN_RX -7 ;
drivers/media/platform/amd/isp4/isp4_phy.c line 1385
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ +u16 jump_deskew_reg = phycfg->max_phase +39 ; + + jump_deskew_reg =div64_u64 (jump_deskew_reg,40 ); + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg = jump_deskew_reg; + +u16 eye_opening_deskew_reg = phycfg->max_phase +4 ; + + eye_opening_deskew_reg =div64_u64 (eye_opening_deskew_reg,5 ); + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg = eye_opening_deskew_reg;
You could just as well do these without a temporary variable.
drivers/media/platform/amd/isp4/isp4_phy.c line 1393
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0+} + +static void isp4phy_startup_seq_dphy_rx (void __iomem *base,u32 phy_id, +u64 data_rate,u32 lane) +{ +struct isp4phy_mipi_config phycfg; + +memset (&phycfg,0 ,sizeof (phycfg));
Would assigning phycfg to { } do the job?
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +4
-0+ +isp4phy_calculate_datarate_cfgs_rx (phy_id, data_rate, lane, &phycfg); +isp4phy_general_common_config (base, phy_id); +isp4phy_common (base, phy_id);
drivers/media/platform/amd/isp4/isp4_phy.c line 1407
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+isp4phy_dphy_specific (base, phy_id, data_rate, &phycfg); +isp4phy_dphy_periodic_deskew_program (base, phy_id); +isp4phy_optional_features_dphy (base, phy_id); +} + +static int isp4phy_startup_seq_cdphy_rx (struct device *dev, +void __iomem *base,u32 phy_id, +u64 data_rate,u32 lane) +{ +struct isp4phy_mipi_reg phy_reg = {0 };
{ } is enough.
Quoted 41 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +41
-0+ +/* readback the mipi phy reg */ + phy_reg.isp_mipi_phy0.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy0); + phy_reg.isp_mipi_phy1.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy1); + phy_reg.isp_mipi_phy2.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy2); + phy_reg.isp_mipi_phy4.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy4); + phy_reg.isp_mipi_phy5.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy5); + phy_reg.isp_mipi_phy6.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy6); + phy_reg.isp_mipi_phy7.value = +isp4hw_rreg (base, (uintptr_t )&isp_mipi_phy_reg[phy_id]->isp_mipi_phy7); + + phy_reg.isp_mipi_phy0.bit.shutdownz =0 ; + phy_reg.isp_mipi_phy0.bit.rstz =0 ; +isp4hw_wreg (base, (uintptr_t )(&isp_mipi_phy_reg[phy_id]->isp_mipi_phy0), + phy_reg.isp_mipi_phy0.value); + +/*PHY register access test */ +isp4phy_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 ,0x473C ); +usleep_range (10 ,20 ); +if (isp4phy_rreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 ) ==0x473C ) { +dev_dbg (dev,"PHY register access test suc\n" ); + }else { +dev_err (dev,"PHY register access test fail\n" ); +return -EFAULT ;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
drivers/media/platform/amd/isp4/isp4_phy.c line 1447
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ } + +/** T1: top level static inputs must be set to the desired +* configuration (for example, phyMode. These *inputs can be +* identified with Startup and Active Mode state: Static label +* in Chapter 4, ¡°Signal Descriptions¡±). +*/ + phy_reg.isp_mipi_phy5.value = (1 << lane) -1 ; + phy_reg.isp_mipi_phy5.bit.forcerxmode_clk =1 ; + isp4hw_wreg(base, (uintptr_t)&isp_mipi_phy_reg[phy_id]->isp_mipi_phy5,
/* Single-line comment. */
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/*
* Multi-line
* comment.
*/
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 23 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Why uintptr_t btw.? This seems to be a recurring pattern.
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Use read_poll_timeout() maybe?
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 19 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +19
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
How about using "amdisp4" as the prefix for the driver's symbol names? Just "isp4" is very generic.
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Maybe use a similar format than for the 4-lane case?
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Maybe a switch for phy_id?
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 2 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +2
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
This line would benefit from wrapping.
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 12 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +12
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Extra parentheses.
34 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
Du, Bin
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Many thanks Sakari Ailus for your careful review
Quoted 51 lines · Sakari Ailus
Hi Bin,
Quoted 48 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_phy.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_phy.hdrivers/media/platform/amd/isp4/Makefile +1
-0@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_phy.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/isp4_phy.c new file +15
-0@@ -0,0 +1,1547 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/delay.h> +#include <linux/device.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_phy.h" + +#define ISP_MIPI_DPHY 0 +#define T_DCO 5/* nominal: 200MHz */ +#define TMIN_RX 4
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 21
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+#define TIMEBASE 5/* 5us */ + +#define MIN_T_HS_SETTLE_NS 95 +#define MAX_T_HS_SETTLE_NS 130 +#define MIN_T_HS_SETTLE_UI 4 +#define MAX_T_HS_SETTLE_UI 6Please align the macro bodies to the same column.
Sure, will do that in the next patch
Quoted 4 lines
Also using a descriptive prefix for these (such as AMDISP4) would seem like a reasonable idea. The same goes for the other macros used by the driver, too.
Sure, will add prefix ISP4PHY_ as prefix of all macros in this file. Macros in other files follow the same naming convension(using file name as prefix).
Quoted 7 lines
Speaking of macro names, some of the names below look quite random. Are these from a hardware datasheet (or something alike)? I might consider sanitising them. Some are also not in form fit for use in drivers, e.g. if you have many of something, then the number should be an argument to the macro, not part of the macro name, e.g. configuration related to lanes -- if feasible.
Yes, they are from HW datasheet and reference. Not sure if I got your point, different number in the macro makes different macro standing for different registers or fields, no idea how to make the number as parameter. Would you mind to give a detailed sample based on current code?
Quoted 322 lines
Quoted 322 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +322
-0+ +#define PPI_STARTUP_RW_COMMON_DPHY_2 0x0C02 +#define PPI_STARTUP_RW_COMMON_DPHY_6 0x0C06 +#define PPI_STARTUP_RW_COMMON_DPHY_7 0x0C07 +#define PPI_STARTUP_RW_COMMON_DPHY_8 0x0C08 +#define PPI_STARTUP_RW_COMMON_DPHY_10 0x0C10 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 0x1CF2 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 0x1CF0 +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1 0x0C11 +#define PPI_CALIBCTRL_RW_COMMON_BG_0 0x0C26 +#define PPI_RW_LPDCOCAL_NREF 0x0E02 +#define PPI_RW_LPDCOCAL_NREF_RANGE 0x0E03 +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG 0x0E05 +#define PPI_RW_LPDCOCAL_VT_CONFIG 0x0E06 +#define PPI_RW_LPDCOCAL_COARSE_CFG 0x0E08 +#define PPI_RW_COMMON_CFG 0x0E36 +#define PPI_RW_TERMCAL_CFG_0 0x0E40 +#define PPI_RW_OFFSETCAL_CFG_0 0x0E50 +#define PPI_RW_LPDCOCAL_TIMEBASE 0x0E01 +#define CORE_AFE_CTRL_2_0 0x1C20 +#define CORE_AFE_CTRL_2_1 0x1C21 +#define CORE_AFE_CTRL_2_3 0x1C23 +#define CORE_AFE_CTRL_2_5 0x1C25 +#define CORE_AFE_CTRL_2_6 0x1C26 +#define CORE_AFE_CTRL_2_7 0x1C27 +#define CORE_DIG_COMMON_RW_DESKEW_FINE_MEM 0x1FF0 +#define CORE_DIG_DLANE_CLK_RW_CFG_0 0x3800 +#define CORE_DIG_DLANE_0_RW_CFG_0 0x3000 +#define CORE_DIG_DLANE_1_RW_CFG_0 0x3200 +#define CORE_DIG_DLANE_2_RW_CFG_0 0x3400 +#define CORE_DIG_DLANE_3_RW_CFG_0 0x3600 +#define CORE_AFE_LANE0_CTRL_2_9 0x1029 +#define CORE_AFE_LANE1_CTRL_2_9 0x1229 +#define CORE_AFE_LANE2_CTRL_2_9 0x1429 +#define CORE_AFE_LANE3_CTRL_2_9 0x1629 +#define CORE_AFE_LANE4_CTRL_2_9 0x1829 +#define CORE_DIG_RW_COMMON_6 0x1C46 +#define CORE_DIG_RW_COMMON_7 0x1C47 +#define PPI_RW_DDLCAL_CFG_0 0x0E20 +#define PPI_RW_DDLCAL_CFG_1 0x0E21 +#define PPI_RW_DDLCAL_CFG_2 0x0E22 +#define PPI_RW_DDLCAL_CFG_3 0x0E23 +#define PPI_RW_DDLCAL_CFG_4 0x0E24 +#define PPI_RW_DDLCAL_CFG_5 0x0E25 +#define PPI_RW_DDLCAL_CFG_6 0x0E26 +#define PPI_RW_DDLCAL_CFG_7 0x0E27 +#define CORE_AFE_LANE0_CTRL_2_8 0x1028 +#define CORE_AFE_LANE1_CTRL_2_8 0x1228 +#define CORE_AFE_LANE2_CTRL_2_8 0x1428 +#define CORE_AFE_LANE3_CTRL_2_8 0x1628 +#define CORE_AFE_LANE4_CTRL_2_8 0x1828 +#define CORE_DIG_DLANE_0_RW_LP_0 0x3040 +#define CORE_DIG_DLANE_1_RW_LP_0 0x3240 +#define CORE_DIG_DLANE_2_RW_LP_0 0x3440 +#define CORE_DIG_DLANE_3_RW_LP_0 0x3640 +#define CORE_AFE_LANE0_CTRL_2_2 0x1022 +#define CORE_AFE_LANE1_CTRL_2_2 0x1222 +#define CORE_AFE_LANE2_CTRL_2_2 0x1422 +#define CORE_AFE_LANE3_CTRL_2_2 0x1622 +#define CORE_AFE_LANE4_CTRL_2_2 0x1822 +#define CORE_AFE_LANE0_CTRL_2_12 0x102C +#define CORE_AFE_LANE1_CTRL_2_12 0x122C +#define CORE_AFE_LANE2_CTRL_2_12 0x142C +#define CORE_AFE_LANE3_CTRL_2_12 0x162C +#define CORE_AFE_LANE4_CTRL_2_12 0x182C +#define CORE_AFE_LANE0_CTRL_2_13 0x102D +#define CORE_AFE_LANE1_CTRL_2_13 0x122D +#define CORE_AFE_LANE2_CTRL_2_13 0x142D +#define CORE_AFE_LANE3_CTRL_2_13 0x162D +#define CORE_AFE_LANE4_CTRL_2_13 0x182D +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0 0x3880 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7 0x3887 +#define CORE_DIG_DLANE_0_RW_HS_RX_0 0x3080 +#define CORE_DIG_DLANE_1_RW_HS_RX_0 0x3280 +#define CORE_DIG_DLANE_2_RW_HS_RX_0 0x3480 +#define CORE_DIG_DLANE_3_RW_HS_RX_0 0x3680 +#define CORE_DIG_DLANE_0_RW_CFG_1 0x3001 +#define CORE_DIG_DLANE_1_RW_CFG_1 0x3201 +#define CORE_DIG_DLANE_2_RW_CFG_1 0x3401 +#define CORE_DIG_DLANE_3_RW_CFG_1 0x3601 +#define CORE_DIG_DLANE_0_RW_HS_RX_2 0x3082 +#define CORE_DIG_DLANE_1_RW_HS_RX_2 0x3282 +#define CORE_DIG_DLANE_2_RW_HS_RX_2 0x3482 +#define CORE_DIG_DLANE_3_RW_HS_RX_2 0x3682 +#define CORE_DIG_DLANE_0_RW_LP_2 0x3042 +#define CORE_DIG_DLANE_1_RW_LP_2 0x3242 +#define CORE_DIG_DLANE_2_RW_LP_2 0x3442 +#define CORE_DIG_DLANE_3_RW_LP_2 0x3642 +#define CORE_DIG_DLANE_CLK_RW_LP_0 0x3840 +#define CORE_DIG_DLANE_CLK_RW_LP_2 0x3842 +#define CORE_DIG_DLANE_0_RW_HS_RX_1 0x3081 +#define CORE_DIG_DLANE_1_RW_HS_RX_1 0x3281 +#define CORE_DIG_DLANE_2_RW_HS_RX_1 0x3481 +#define CORE_DIG_DLANE_3_RW_HS_RX_1 0x3681 +#define CORE_DIG_DLANE_0_RW_HS_RX_3 0x3083 +#define CORE_DIG_DLANE_1_RW_HS_RX_3 0x3283 +#define CORE_DIG_DLANE_2_RW_HS_RX_3 0x3483 +#define CORE_DIG_DLANE_3_RW_HS_RX_3 0x3683 +#define CORE_DIG_DLANE_0_RW_HS_RX_4 0x3084 +#define CORE_DIG_DLANE_1_RW_HS_RX_4 0x3284 +#define CORE_DIG_DLANE_2_RW_HS_RX_4 0x3484 +#define CORE_DIG_DLANE_3_RW_HS_RX_4 0x3684 +#define CORE_DIG_DLANE_0_RW_HS_RX_5 0x3085 +#define CORE_DIG_DLANE_1_RW_HS_RX_5 0x3285 +#define CORE_DIG_DLANE_2_RW_HS_RX_5 0x3485 +#define CORE_DIG_DLANE_3_RW_HS_RX_5 0x3685 +#define CORE_DIG_DLANE_0_RW_HS_RX_6 0x3086 +#define CORE_DIG_DLANE_1_RW_HS_RX_6 0x3286 +#define CORE_DIG_DLANE_2_RW_HS_RX_6 0x3486 +#define CORE_DIG_DLANE_3_RW_HS_RX_6 0x3686 +#define CORE_DIG_DLANE_0_RW_HS_RX_7 0x3087 +#define CORE_DIG_DLANE_1_RW_HS_RX_7 0x3287 +#define CORE_DIG_DLANE_2_RW_HS_RX_7 0x3487 +#define CORE_DIG_DLANE_3_RW_HS_RX_7 0x3687 +#define CORE_DIG_DLANE_0_RW_HS_RX_9 0x3089 +#define CORE_DIG_DLANE_1_RW_HS_RX_9 0x3289 +#define CORE_DIG_DLANE_2_RW_HS_RX_9 0x3489 +#define CORE_DIG_DLANE_3_RW_HS_RX_9 0x3689 +#define PPI_R_TERMCAL_DEBUG_0 0x0E41 + +#define PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK 0x00FF +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK 0x2000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK 0x1000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK 0x00FC +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK 0x0FFF +#define PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK 0x00FF +#define PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK 0x01FF +#define PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK 0x07FF +#define PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK 0x001F +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK 0xFE00 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK 0x0001 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK 0x0002 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK 0x007C +#define PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK 0x0003 +#define PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK 0x0003 +#define PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK 0x007F +#define PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK 0x001F +#define PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK 0x03FF +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK 0x01FF +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK 0xFF80 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK 0x0100 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK 0x2000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK 0x1000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK 0x0100 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK 0x4000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK 0x0100 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0003 +#define CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x000C +#define CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0030 +#define CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x00C0 +#define CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0300 +#define PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK 0x1F80 +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK 0xFF00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK 0xF000 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK 0x0C00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK 0x0100 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK 0x0200 +#define PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK 0x007F +#define PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK 0x03F0 +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK 0x000F +#define CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK 0x0001 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK 0x0038 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK 0x0007 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK 0x00FF +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 + +struct isp4phy_mipi_reg_seq { +u16 addr; +u16 mask; +u16 data; +}; + +union isp4phy_mipi_0 { +struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 348
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+}; + +union isp4phy_mipi_1 { + struct { + u32 mode : 1;Please pad these -- I don't think the ABI otherwise requires they're in a particular location of the container (u32).
Sure, will do that in the next patch
Quoted 54 lines
Quoted 54 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +54
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 408
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+u32 value; +}; + +union isp4phy_mipi_ind_idx { + struct { + u32 addr : 16;u16 would seem appropriate here.
I think u32 here is similar as u32 enableclk : 1 or u32 rxdatawidthhs_0 : 2, indicate an unsigned value, if change to u16, : 16 will be no need, So prefer to keeping it and adding u32 reserved : 16 after it.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 415
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { + struct { + u32 data : 16;Ditto.
Ditto
Quoted 16 lines
Quoted 16 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +16
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_reg { +union isp4phy_mipi_0 isp_mipi_phy0; +union isp4phy_mipi_1 isp_mipi_phy1; +union isp4phy_mipi_2 isp_mipi_phy2;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 437
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+struct isp4phy_mipi_3 isp_mipi_phy3; +union isp4phy_mipi_4 isp_mipi_phy4; +union isp4phy_mipi_5 isp_mipi_phy5; +union isp4phy_mipi_6 isp_mipi_phy6; +union isp4phy_mipi_7 isp_mipi_phy7; +u32 reserve;"reserved"?
Sure, will fix it in the next patch
Quoted 29 lines
Quoted 29 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +29
-0+union isp4phy_mipi_ind_idx isp_mipi_phy_ind_idx; +union isp4phy_mipi_ind_data isp_mipi_phy_ind_data; +union isp4phy_mipi_ind_wack isp_mipi_phy_inc_wack; +}; + +struct isp4phy_mipi_config { +u16 afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg; +u16 max_phase; +u16 ddlcal_cfg_5ddlcal_dll_fbk_reg; +u16 ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg; +u16 cfg_1cfg_1_sot_detection_reg; +u16 hs_rx_2hs_rx_2_ignore_alterncal_reg; +u16 cfg_1cfg_1_deskew_supported_reg; +u16 afe_lanex_ctrl_2_9oa_hs_clk_div_reg; +u16 hs_rx_0hs_rx_0_thssettle_reg; +u16 hs_rx_3hs_rx_3_fjump_deskew_reg; +u16 hs_rx_6hs_rx_6_min_eye_opening_deskew_reg; +}; + +enum isp4phy_mipi_id { +ISP_MIPI_PHY_ID_0 =0 , +ISP_MIPI_PHY_ID_1 =1 , +ISP_MIPI_PHY_ID_2 =2 , +ISP_MIPI_PHY_ID_MAX +};
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 471
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+ +static const struct isp4phy_mipi_reg *isp_mipi_phy_reg[ISP_MIPI_PHY_ID_MAX ] = { + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY0_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY1_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY2_REG0 ,That's an interesting way to prefill structs. I don't think these macros expand to valid pointers.
Yes, these are valid pointers, but they are not pointing to system memory, they are phy registers address, can be accessed by adding the mmio base.
Quoted 189 lines
Quoted 189 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +189
-0+}; + +static const struct isp4phy_mipi_reg_seq startup_seq_general_common_config[] = { + {PPI_STARTUP_RW_COMMON_DPHY_10 ,PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK ,0x30 }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK ,0x0 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK ,0x1 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK ,0x3F + }, + { +PPI_STARTUP_RW_COMMON_STARTUP_1_1 , +PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK ,0x233 + }, + {PPI_STARTUP_RW_COMMON_DPHY_6 ,PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK ,0x27 }, + {PPI_CALIBCTRL_RW_COMMON_BG_0 ,PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK ,0x1F4 }, + {PPI_RW_LPDCOCAL_NREF ,PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK ,0x320 }, + {PPI_RW_LPDCOCAL_NREF_RANGE ,PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_TWAIT_CONFIG ,PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK ,0x7F }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK ,0x1 }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK ,0x0 }, + {PPI_RW_LPDCOCAL_COARSE_CFG ,PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK ,0x1 }, + {PPI_RW_COMMON_CFG ,PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK ,0x3 }, +}; + +static const struct isp4phy_mipi_reg_seq startup_seq_common[] = { + {PPI_STARTUP_RW_COMMON_DPHY_2 ,PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK ,0x5 }, + {PPI_RW_TERMCAL_CFG_0 ,PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK ,0x17 }, + {PPI_RW_OFFSETCAL_CFG_0 ,PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK ,0x4 }, + {PPI_RW_LPDCOCAL_TIMEBASE ,PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK ,0x5F }, + { +PPI_RW_LPDCOCAL_TWAIT_CONFIG , +PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK ,0x1D + }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK ,0x1D }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_5 ,CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK ,0x0 }, +}; + +static const struct isp4phy_mipi_reg_seq + startup_seq_dphy_periodic_deskew_program[] = { + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x404 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x40C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x414 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x41C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x423 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x429 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x430 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x43A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x445 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x44A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x450 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x45A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x465 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x469 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x472 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x47A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x485 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x489 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x490 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x49A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x504 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x50C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x514 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x51C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x523 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x529 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x530 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x53A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x545 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x54A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x550 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x55A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x565 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x569 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x572 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x57A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x585 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x589 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x590 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x59A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x604 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x60C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x614 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x61C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x623 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x629 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x632 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x63A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x645 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x64A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x650 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x65A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x665 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x669 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x672 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x67A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x685 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x689 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x690 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x69A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x704 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x70C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x714 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x71C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x723 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x72A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x730 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x73A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x745 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x74A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x750 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x75A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x765 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x769 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x772 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x77A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x785 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x789 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x790 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x79A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7FC }, +}; +
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 666
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+inline u16 isp4phy_rreg (void __iomem *base,u32 phy_id,u16 addr) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +return (u16 )isp4hw_rreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data));Redundant parentheses.
Sure, will remove it and all others in the next patch
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +14
-0+} + +inline void isp4phy_wreg (void __iomem *base,u32 phy_id,u16 addr,u16 data) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data), data); +} + +static void isp4phy_mask_wreg (void __iomem *base,u32 phy_id,u16 addr, +u16 mask,u16 regval) +{ +unsigned long _mask = mask;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 686
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+u16 shift =0 ; +u16 data; + + data =isp4phy_rreg (base, phy_id, addr); +if (mask) + shift =find_first_bit (&_mask,16 );
__ffs()?
Sure, will do that in the next patch
Quoted 48 lines
Quoted 48 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +48
-0+ data = (data & ~mask) | ((regval << shift) & mask); + +isp4phy_wreg (base, phy_id, addr, data); +} + +static void isp4phy_optional_features_dphy (void __iomem *base,u32 phy_id) +{ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_9 , +CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_9 , +CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_9 , +CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK , +0x0 ); + }
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 740
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+} + +static void isp4phy_dphy_periodic_deskew_program (void __iomem *base, +u32 phy_id) +{ + for (int ctr = 0;unsigned int?
Sure, will modify to use size_t in the next patch
Quoted 10 lines
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ ctr <ARRAY_SIZE (startup_seq_dphy_periodic_deskew_program); + ctr++) +isp4phy_wreg (base, phy_id, + startup_seq_dphy_periodic_deskew_program[ctr].addr, + startup_seq_dphy_periodic_deskew_program[ctr].data); +} + +static void isp4phy_dphy_specific (void __iomem *base,u32 phy_id, +u64 data_rate, +struct isp4phy_mipi_config *phycfg)
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 756
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+{ +u64 half_rate = data_rate >>1 ; +u16 ddl_cal; + + ddl_cal =TIMEBASE * half_rate; + ddl_cal = (ddl_cal +31 ) >>5 ;I think you could do this on a single line as well.
Sure, will do that in the next patch
Quoted 462 lines
Quoted 462 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +462
-0+ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_8 , +PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK ,0x50 ); + +if (data_rate <1500 ) { +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x68 ); + }else { +/* Digital Delay Line (DDL) tuning calibration */ +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x28 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_0 , +PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK ,0x77 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK ,0x22 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK ,0x4 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK ,0x1 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_4 , +PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK ,0xA ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_6 , +PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK ,0xA ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK ,0xB ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_3 , +PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK , ddl_cal); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK , phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK , + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK , + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_8 , +CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_8 , +CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_8 , +CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_8 , +CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_8 , +CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); + } + } + +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_2 , +CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK ,0x0 ); + +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_2 , +CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_2 , +CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK ,0x0 ); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK ,0x1 ); + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_0 , +CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK ,0x1C ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_7 , +CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK ,0x6 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_0 , +CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_0 , +CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_0 , +CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_0 , +CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_2 , +CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_2 , +CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_2 , +CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_2 , +CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_0 , +CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_2 , +CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_1 , +CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_1 , +CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_1 , +CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_1 , +CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_4 , +CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_4 , +CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_4 , +CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_4 , +CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_6 , +CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_6 , +CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_9 , +CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_9 , +CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_9 , +CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_9 , +CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_6 , +CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { + isp4phy_mask_wreg(base, phy_id, CORE_DIG_DLANE_2_RW_HS_RX_6, + CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK,
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 1223
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+ phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); + }Could you do this using a loop instead? With a bit saner macros, that should be quite a bit easier, too.
No very sure how, would you mind to give a sample?
Quoted 7 lines
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+} + +static void isp4phy_common (void __iomem *base,u32 phy_id) +{ +for (int ctr =0 ; ctr <ARRAY_SIZE (startup_seq_common); ctr++) + isp4phy_mask_wreg(base, phy_id, startup_seq_common[ctr].addr, + startup_seq_common[ctr].mask,
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 1236
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+ startup_seq_common[ctr].data); +} + +static void isp4phy_general_common_config (void __iomem *base,u32 phy_id) +{ +for (int ctr =0 ; ctr <ARRAY_SIZE (startup_seq_general_common_config); ctr++)Unsigned int for these, too, please.
Sure, will modify to use size_t in the next patch
Quoted 88 lines
Quoted 88 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +88
-0+isp4phy_mask_wreg (base, phy_id, + startup_seq_general_common_config[ctr].addr, + startup_seq_general_common_config[ctr].mask, + startup_seq_general_common_config[ctr].data); +} + +static void +isp4phy_calculate_datarate_cfgs_rx (u32 phy_id,u64 data_rate, +u32 lane, +struct isp4phy_mipi_config *phycfg) +{ +u64 half_rate = data_rate >>1 ; +u64 hs_clk_freq; + + hs_clk_freq = half_rate *1000 ; + +if (data_rate <=2500 ) + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg =1 ; +else if (data_rate <=4500 ) + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg =0 ; + +if (data_rate <1500 ) { +/* do nothing */ + }else if (data_rate <1588 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =143 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =17 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =3 ; + }else if (data_rate <1688 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =135 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =16 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <1800 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =127 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =15 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <1929 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =119 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =14 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <2077 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =111 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =13 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =2 ; + }else if (data_rate <2250 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =103 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =12 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <2455 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =95 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =11 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <2700 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =87 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =10 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <3000 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =79 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =9 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <3230 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =0 ; + phycfg->max_phase =71 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =8 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =0 ; + }else if (data_rate <3600 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =87 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =10 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <4000 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =79 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =9 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ; + }else if (data_rate <4500 ) { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =71 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =8 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =1 ;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 1330
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+ }else { + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg =1 ; + phycfg->max_phase =63 ; + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg =7 ; + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg =0 ; + }Please add an array for the values and implement this as a loop instead.
Sure, will do that in the next patch
Quoted 23 lines
Quoted 23 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +23
-0+ +if (data_rate <=1500 ) { + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg =1 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg =1 ; + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg =1 ; + phycfg->cfg_1cfg_1_deskew_supported_reg =0 ; + phycfg->cfg_1cfg_1_sot_detection_reg =1 ; + }else if (data_rate <=4500 ) { + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg =0 ; + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg =0 ; + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg =0 ; + phycfg->cfg_1cfg_1_deskew_supported_reg =1 ; + phycfg->cfg_1cfg_1_sot_detection_reg =0 ; + } + +if (data_rate <160 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b001 ; +else if (data_rate <320 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b010 ; +else if (data_rate <640 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b011 ;
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 1359
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+else if (data_rate <1280 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b100 ; +else if (data_rate <2560 ) + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b101 ; +else + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg =0b110 ;Ditto. Or maybe use
ilog2()?
I'd prefer to using the hex value directly because it's more readable, what do you think?
Quoted 20 lines
Quoted 20 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +20
-0+ +u32 t_hs_settle_ns =MIN_T_HS_SETTLE_NS +MAX_T_HS_SETTLE_NS ; + + t_hs_settle_ns = t_hs_settle_ns >>1 ; +u32 t_hs_settle_ui =MIN_T_HS_SETTLE_UI +MAX_T_HS_SETTLE_UI ; + + t_hs_settle_ui = t_hs_settle_ui >>1 ; + + t_hs_settle_ui = t_hs_settle_ui *1000000 ; + t_hs_settle_ui = t_hs_settle_ui >>1 ; + t_hs_settle_ui =div64_u64 (t_hs_settle_ui, hs_clk_freq); + +u32 ths_settle_target = t_hs_settle_ns + t_hs_settle_ui;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
You could just as well do these without a temporary variable.
Sure, will remove it in the next patch
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Would assigning phycfg to { } do the job?
Sure, will do that in the next patch
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
{ } is enough.
Sure, will do that in the next patch
Quoted 45 lines
Quoted 45 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +45
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/* Single-line comment. */
Sure, will modify in the next patch
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/*
* Multi-line
* comment.
*/
Sure, will modify in the next patch
Quoted 17 lines
Quoted 17 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Why
uintptr_tbtw.? This seems to be a recurring pattern.
To make safe conversion between pointer and big enough integer, removing it will result in compiling warning.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Use
read_poll_timeout()maybe?
Sure, will modify in the next patch
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
How about using "amdisp4" as the prefix for the driver's symbol names? Just "isp4" is very generic.
Actually all symbols in this driver follow the same convention, just use file name as prefix, the reason of not adding amd is 1. All files are located under amd folder, so no confusion. 2. To make symbol name short 3. No export symbol from this driver, if there is, the export symbol should add amd as part of prefix. Is that acceptible to you?
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Maybe use a similar format than for the 4-lane case?
Not very sure your meaning, will rewrithe this part using switch like
switch (phy_id) {
case ISP_MIPI_PHY_ID_0:
case ISP_MIPI_PHY_ID_1:
if (lane_num > 4) {
dev_err(dev, "fail invalid lane number %u for phy%d\n", lane_num,
phy_id);
return -EINVAL;
}
break;
case ISP_MIPI_PHY_ID_2:
if (lane_num > 2) {
dev_err(dev, "fail invalid lane number %u for phy%d\n", lane_num,
phy_id);
return -EINVAL;
}
break;3 lines not shown · raw message
69 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
Re: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Quoted 565 lines · Bin
Quoted 49 lines · Sakari Ailus
Quoted 48 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_phy.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_phy.hdrivers/media/platform/amd/isp4/Makefile +1
-0@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_phy.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/isp4_phy.c new file +15
-0@@ -0,0 +1,1547 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/delay.h> +#include <linux/device.h> + +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_phy.h" + +#define ISP_MIPI_DPHY 0 +#define T_DCO 5/* nominal: 200MHz */ +#define TMIN_RX 4Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 21
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+#define TIMEBASE 5/* 5us */ + +#define MIN_T_HS_SETTLE_NS 95 +#define MAX_T_HS_SETTLE_NS 130 +#define MIN_T_HS_SETTLE_UI 4 +#define MAX_T_HS_SETTLE_UI 6Please align the macro bodies to the same column.
Sure, will do that in the next patch
Quoted 4 lines
Also using a descriptive prefix for these (such as AMDISP4) would seem like a reasonable idea. The same goes for the other macros used by the driver, too.
Sure, will add prefix
ISP4PHY_as prefix of all macros in this file. Macros in other files follow the same naming convension(using file name as prefix).Quoted 7 lines
Speaking of macro names, some of the names below look quite random. Are these from a hardware datasheet (or something alike)? I might consider sanitising them. Some are also not in form fit for use in drivers, e.g. if you have many of something, then the number should be an argument to the macro, not part of the macro name, e.g. configuration related to lanes -- if feasible.
Yes, they are from HW datasheet and reference. Not sure if I got your point, different number in the macro makes different macro standing for different registers or fields, no idea how to make the number as parameter. Would you mind to give a detailed sample based on current code?
Quoted 322 lines
Quoted 322 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +322
-0+ +#define PPI_STARTUP_RW_COMMON_DPHY_2 0x0C02 +#define PPI_STARTUP_RW_COMMON_DPHY_6 0x0C06 +#define PPI_STARTUP_RW_COMMON_DPHY_7 0x0C07 +#define PPI_STARTUP_RW_COMMON_DPHY_8 0x0C08 +#define PPI_STARTUP_RW_COMMON_DPHY_10 0x0C10 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 0x1CF2 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 0x1CF0 +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1 0x0C11 +#define PPI_CALIBCTRL_RW_COMMON_BG_0 0x0C26 +#define PPI_RW_LPDCOCAL_NREF 0x0E02 +#define PPI_RW_LPDCOCAL_NREF_RANGE 0x0E03 +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG 0x0E05 +#define PPI_RW_LPDCOCAL_VT_CONFIG 0x0E06 +#define PPI_RW_LPDCOCAL_COARSE_CFG 0x0E08 +#define PPI_RW_COMMON_CFG 0x0E36 +#define PPI_RW_TERMCAL_CFG_0 0x0E40 +#define PPI_RW_OFFSETCAL_CFG_0 0x0E50 +#define PPI_RW_LPDCOCAL_TIMEBASE 0x0E01 +#define CORE_AFE_CTRL_2_0 0x1C20 +#define CORE_AFE_CTRL_2_1 0x1C21 +#define CORE_AFE_CTRL_2_3 0x1C23 +#define CORE_AFE_CTRL_2_5 0x1C25 +#define CORE_AFE_CTRL_2_6 0x1C26 +#define CORE_AFE_CTRL_2_7 0x1C27 +#define CORE_DIG_COMMON_RW_DESKEW_FINE_MEM 0x1FF0 +#define CORE_DIG_DLANE_CLK_RW_CFG_0 0x3800 +#define CORE_DIG_DLANE_0_RW_CFG_0 0x3000 +#define CORE_DIG_DLANE_1_RW_CFG_0 0x3200 +#define CORE_DIG_DLANE_2_RW_CFG_0 0x3400 +#define CORE_DIG_DLANE_3_RW_CFG_0 0x3600 +#define CORE_AFE_LANE0_CTRL_2_9 0x1029 +#define CORE_AFE_LANE1_CTRL_2_9 0x1229 +#define CORE_AFE_LANE2_CTRL_2_9 0x1429 +#define CORE_AFE_LANE3_CTRL_2_9 0x1629 +#define CORE_AFE_LANE4_CTRL_2_9 0x1829 +#define CORE_DIG_RW_COMMON_6 0x1C46 +#define CORE_DIG_RW_COMMON_7 0x1C47 +#define PPI_RW_DDLCAL_CFG_0 0x0E20 +#define PPI_RW_DDLCAL_CFG_1 0x0E21 +#define PPI_RW_DDLCAL_CFG_2 0x0E22 +#define PPI_RW_DDLCAL_CFG_3 0x0E23 +#define PPI_RW_DDLCAL_CFG_4 0x0E24 +#define PPI_RW_DDLCAL_CFG_5 0x0E25 +#define PPI_RW_DDLCAL_CFG_6 0x0E26 +#define PPI_RW_DDLCAL_CFG_7 0x0E27 +#define CORE_AFE_LANE0_CTRL_2_8 0x1028 +#define CORE_AFE_LANE1_CTRL_2_8 0x1228 +#define CORE_AFE_LANE2_CTRL_2_8 0x1428 +#define CORE_AFE_LANE3_CTRL_2_8 0x1628 +#define CORE_AFE_LANE4_CTRL_2_8 0x1828 +#define CORE_DIG_DLANE_0_RW_LP_0 0x3040 +#define CORE_DIG_DLANE_1_RW_LP_0 0x3240 +#define CORE_DIG_DLANE_2_RW_LP_0 0x3440 +#define CORE_DIG_DLANE_3_RW_LP_0 0x3640 +#define CORE_AFE_LANE0_CTRL_2_2 0x1022 +#define CORE_AFE_LANE1_CTRL_2_2 0x1222 +#define CORE_AFE_LANE2_CTRL_2_2 0x1422 +#define CORE_AFE_LANE3_CTRL_2_2 0x1622 +#define CORE_AFE_LANE4_CTRL_2_2 0x1822 +#define CORE_AFE_LANE0_CTRL_2_12 0x102C +#define CORE_AFE_LANE1_CTRL_2_12 0x122C +#define CORE_AFE_LANE2_CTRL_2_12 0x142C +#define CORE_AFE_LANE3_CTRL_2_12 0x162C +#define CORE_AFE_LANE4_CTRL_2_12 0x182C +#define CORE_AFE_LANE0_CTRL_2_13 0x102D +#define CORE_AFE_LANE1_CTRL_2_13 0x122D +#define CORE_AFE_LANE2_CTRL_2_13 0x142D +#define CORE_AFE_LANE3_CTRL_2_13 0x162D +#define CORE_AFE_LANE4_CTRL_2_13 0x182D +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0 0x3880 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7 0x3887 +#define CORE_DIG_DLANE_0_RW_HS_RX_0 0x3080 +#define CORE_DIG_DLANE_1_RW_HS_RX_0 0x3280 +#define CORE_DIG_DLANE_2_RW_HS_RX_0 0x3480 +#define CORE_DIG_DLANE_3_RW_HS_RX_0 0x3680 +#define CORE_DIG_DLANE_0_RW_CFG_1 0x3001 +#define CORE_DIG_DLANE_1_RW_CFG_1 0x3201 +#define CORE_DIG_DLANE_2_RW_CFG_1 0x3401 +#define CORE_DIG_DLANE_3_RW_CFG_1 0x3601 +#define CORE_DIG_DLANE_0_RW_HS_RX_2 0x3082 +#define CORE_DIG_DLANE_1_RW_HS_RX_2 0x3282 +#define CORE_DIG_DLANE_2_RW_HS_RX_2 0x3482 +#define CORE_DIG_DLANE_3_RW_HS_RX_2 0x3682 +#define CORE_DIG_DLANE_0_RW_LP_2 0x3042 +#define CORE_DIG_DLANE_1_RW_LP_2 0x3242 +#define CORE_DIG_DLANE_2_RW_LP_2 0x3442 +#define CORE_DIG_DLANE_3_RW_LP_2 0x3642 +#define CORE_DIG_DLANE_CLK_RW_LP_0 0x3840 +#define CORE_DIG_DLANE_CLK_RW_LP_2 0x3842 +#define CORE_DIG_DLANE_0_RW_HS_RX_1 0x3081 +#define CORE_DIG_DLANE_1_RW_HS_RX_1 0x3281 +#define CORE_DIG_DLANE_2_RW_HS_RX_1 0x3481 +#define CORE_DIG_DLANE_3_RW_HS_RX_1 0x3681 +#define CORE_DIG_DLANE_0_RW_HS_RX_3 0x3083 +#define CORE_DIG_DLANE_1_RW_HS_RX_3 0x3283 +#define CORE_DIG_DLANE_2_RW_HS_RX_3 0x3483 +#define CORE_DIG_DLANE_3_RW_HS_RX_3 0x3683 +#define CORE_DIG_DLANE_0_RW_HS_RX_4 0x3084 +#define CORE_DIG_DLANE_1_RW_HS_RX_4 0x3284 +#define CORE_DIG_DLANE_2_RW_HS_RX_4 0x3484 +#define CORE_DIG_DLANE_3_RW_HS_RX_4 0x3684 +#define CORE_DIG_DLANE_0_RW_HS_RX_5 0x3085 +#define CORE_DIG_DLANE_1_RW_HS_RX_5 0x3285 +#define CORE_DIG_DLANE_2_RW_HS_RX_5 0x3485 +#define CORE_DIG_DLANE_3_RW_HS_RX_5 0x3685 +#define CORE_DIG_DLANE_0_RW_HS_RX_6 0x3086 +#define CORE_DIG_DLANE_1_RW_HS_RX_6 0x3286 +#define CORE_DIG_DLANE_2_RW_HS_RX_6 0x3486 +#define CORE_DIG_DLANE_3_RW_HS_RX_6 0x3686 +#define CORE_DIG_DLANE_0_RW_HS_RX_7 0x3087 +#define CORE_DIG_DLANE_1_RW_HS_RX_7 0x3287 +#define CORE_DIG_DLANE_2_RW_HS_RX_7 0x3487 +#define CORE_DIG_DLANE_3_RW_HS_RX_7 0x3687 +#define CORE_DIG_DLANE_0_RW_HS_RX_9 0x3089 +#define CORE_DIG_DLANE_1_RW_HS_RX_9 0x3289 +#define CORE_DIG_DLANE_2_RW_HS_RX_9 0x3489 +#define CORE_DIG_DLANE_3_RW_HS_RX_9 0x3689 +#define PPI_R_TERMCAL_DEBUG_0 0x0E41 + +#define PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK 0x00FF +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK 0x2000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK 0x1000 +#define CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK 0x00FC +#define PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK 0x0FFF +#define PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK 0x00FF +#define PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK 0x01FF +#define PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK 0x07FF +#define PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK 0x001F +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK 0xFE00 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK 0x0001 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK 0x0002 +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK 0x007C +#define PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK 0x0003 +#define PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK 0x0003 +#define PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK 0x007F +#define PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK 0x001F +#define PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK 0x03FF +#define PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK 0x01FF +#define PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK 0xFF80 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK 0x0400 +#define CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK 0x0100 +#define CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK 0x8000 +#define CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK 0x2000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK 0x0200 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK 0x1000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK 0x0100 +#define CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK 0x4000 +#define CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK 0x0400 +#define CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK 0x0100 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK 0x0100 +#define CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0003 +#define CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x000C +#define CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0030 +#define CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x00C0 +#define CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK 0x0300 +#define PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK 0x1F80 +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK 0xFF00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK 0xF000 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK 0x0C00 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK 0x0100 +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK 0x0200 +#define PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK 0x007F +#define PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK 0x03FF +#define PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK 0x00FF +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK 0x03F0 +#define PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK 0x000F +#define CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK 0x1000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK 0x0F00 +#define CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK 0x0001 +#define CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK 0x0001 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK 0x0038 +#define CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK 0x0007 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK 0x0002 +#define CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK 0x0008 +#define CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK 0x0008 +#define CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK 0x00E0 +#define CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK 0x00FF +#define CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK 0x0004 +#define CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK 0x0008 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK 0xF000 +#define CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK 0x0001 +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK 0x1E00 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK 0x0007 +#define CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK 0xFFFF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK 0x2000 +#define CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK 0x8000 +#define CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK 0x01F8 +#define CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK 0x00FF +#define CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK 0xFF00 +#define CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK 0x0002 + +struct isp4phy_mipi_reg_seq { +u16 addr; +u16 mask; +u16 data; +}; + +union isp4phy_mipi_0 { +struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value;Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 348
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+}; + +union isp4phy_mipi_1 { + struct { + u32 mode : 1;Please pad these -- I don't think the ABI otherwise requires they're in a particular location of the container (u32).
Sure, will do that in the next patch
Quoted 54 lines
Quoted 54 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +54
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit;Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 408
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+u32 value; +}; + +union isp4phy_mipi_ind_idx { + struct { + u32 addr : 16;u16 would seem appropriate here.
I think u32 here is similar as u32 enableclk : 1 or u32
rxdatawidthhs_0: 2, indicate an unsigned value, if change to u16, : 16 will be no need, So prefer to keeping it and adding u32 reserved : 16 after it.Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 415
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { + struct { + u32 data : 16;Ditto.
Ditto
Quoted 16 lines
Quoted 16 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +16
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_reg { +union isp4phy_mipi_0 isp_mipi_phy0; +union isp4phy_mipi_1 isp_mipi_phy1; +union isp4phy_mipi_2 isp_mipi_phy2;Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 437
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+struct isp4phy_mipi_3 isp_mipi_phy3; +union isp4phy_mipi_4 isp_mipi_phy4; +union isp4phy_mipi_5 isp_mipi_phy5; +union isp4phy_mipi_6 isp_mipi_phy6; +union isp4phy_mipi_7 isp_mipi_phy7; +u32 reserve;"reserved"?
Sure, will fix it in the next patch
Quoted 29 lines
Quoted 29 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +29
-0+union isp4phy_mipi_ind_idx isp_mipi_phy_ind_idx; +union isp4phy_mipi_ind_data isp_mipi_phy_ind_data; +union isp4phy_mipi_ind_wack isp_mipi_phy_inc_wack; +}; + +struct isp4phy_mipi_config { +u16 afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg; +u16 max_phase; +u16 ddlcal_cfg_5ddlcal_dll_fbk_reg; +u16 ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg; +u16 afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg; +u16 afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg; +u16 cfg_1cfg_1_sot_detection_reg; +u16 hs_rx_2hs_rx_2_ignore_alterncal_reg; +u16 cfg_1cfg_1_deskew_supported_reg; +u16 afe_lanex_ctrl_2_9oa_hs_clk_div_reg; +u16 hs_rx_0hs_rx_0_thssettle_reg; +u16 hs_rx_3hs_rx_3_fjump_deskew_reg; +u16 hs_rx_6hs_rx_6_min_eye_opening_deskew_reg; +}; + +enum isp4phy_mipi_id { +ISP_MIPI_PHY_ID_0 =0 , +ISP_MIPI_PHY_ID_1 =1 , +ISP_MIPI_PHY_ID_2 =2 , +ISP_MIPI_PHY_ID_MAX +};Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 471
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+ +static const struct isp4phy_mipi_reg *isp_mipi_phy_reg[ISP_MIPI_PHY_ID_MAX ] = { + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY0_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY1_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY2_REG0 ,That's an interesting way to prefill structs. I don't think these macros expand to valid pointers.
Quoted 3 lines
Yes, these are valid pointers, but they are not pointing to system memory, they are phy registers address, can be accessed by adding the mmio base.
Please don't do that. Store register addresses in macros, and use them through the code as appropriate. Stop passing the base mmio address around through functions, store it in a PHY object, and pass that object to the isp4phy_start() instead of a dev pointer, base pointer and phy id.
Quoted 1,252 lines
Quoted 189 lines
Quoted 189 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +189
-0+}; + +static const struct isp4phy_mipi_reg_seq startup_seq_general_common_config[] = { + {PPI_STARTUP_RW_COMMON_DPHY_10 ,PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK ,0x30 }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK ,0x0 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK ,0x1 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK ,0x3F + }, + { +PPI_STARTUP_RW_COMMON_STARTUP_1_1 , +PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK ,0x233 + }, + {PPI_STARTUP_RW_COMMON_DPHY_6 ,PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK ,0x27 }, + {PPI_CALIBCTRL_RW_COMMON_BG_0 ,PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK ,0x1F4 }, + {PPI_RW_LPDCOCAL_NREF ,PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK ,0x320 }, + {PPI_RW_LPDCOCAL_NREF_RANGE ,PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_TWAIT_CONFIG ,PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK ,0x7F }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK ,0x1 }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK ,0x0 }, + {PPI_RW_LPDCOCAL_COARSE_CFG ,PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK ,0x1 }, + {PPI_RW_COMMON_CFG ,PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK ,0x3 }, +}; + +static const struct isp4phy_mipi_reg_seq startup_seq_common[] = { + {PPI_STARTUP_RW_COMMON_DPHY_2 ,PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK ,0x5 }, + {PPI_RW_TERMCAL_CFG_0 ,PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK ,0x17 }, + {PPI_RW_OFFSETCAL_CFG_0 ,PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK ,0x4 }, + {PPI_RW_LPDCOCAL_TIMEBASE ,PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK ,0x5F }, + { +PPI_RW_LPDCOCAL_TWAIT_CONFIG , +PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK ,0x1D + }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_TWAIT_FINE_MASK ,0x1D }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTX_VCOMM_REG_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTX_VCOMM_REG_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_1 ,CORE_AFE_CTRL_2_1_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK0_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_0 ,CORE_AFE_CTRL_2_0_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_3 ,CORE_AFE_CTRL_2_3_OA_CB_HSTXLB_DCO_CLK90_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_PON_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_PON_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_6 ,CORE_AFE_CTRL_2_6_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_EN_MASK ,0x1 }, + {CORE_AFE_CTRL_2_7 ,CORE_AFE_CTRL_2_7_OA_CB_HSTXLB_DCO_TUNE_CLKDIG_EN_OVR_VAL_MASK ,0x0 }, + {CORE_AFE_CTRL_2_5 ,CORE_AFE_CTRL_2_5_OA_CB_SEL_45OHM_50OHM_MASK ,0x0 }, +}; + +static const struct isp4phy_mipi_reg_seq + startup_seq_dphy_periodic_deskew_program[] = { + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x404 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x40C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x414 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x41C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x423 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x429 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x430 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x43A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x445 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x44A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x450 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x45A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x465 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x469 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x472 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x47A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x485 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x489 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x490 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x49A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x4FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x504 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x50C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x514 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x51C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x523 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x529 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x530 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x53A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x545 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x54A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x550 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x55A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x565 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x569 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x572 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x57A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x585 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x589 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x590 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x59A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x5FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x604 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x60C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x614 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x61C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x623 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x629 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x632 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x63A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x645 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x64A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x650 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x65A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x665 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x669 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x672 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x67A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x685 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x689 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x690 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x69A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x6FC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x704 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x70C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x714 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x71C }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x723 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x72A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x730 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x73A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x745 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x74A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x750 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x75A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x765 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x769 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x772 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x77A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x785 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x789 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x790 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x79A }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7A4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7AC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7B4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7BC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7C4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7CC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7D4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7DC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7E4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7EC }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7F4 }, + {CORE_DIG_COMMON_RW_DESKEW_FINE_MEM ,0 ,0x7FC }, +}; +Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 666
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+inline u16 isp4phy_rreg (void __iomem *base,u32 phy_id,u16 addr) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +return (u16 )isp4hw_rreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data));Redundant parentheses.
Sure, will remove it and all others in the next patch
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +14
-0+} + +inline void isp4phy_wreg (void __iomem *base,u32 phy_id,u16 addr,u16 data) +{ +const struct isp4phy_mipi_reg *reg = isp_mipi_phy_reg[phy_id]; + +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_idx), addr); +isp4hw_wreg (base, (uintptr_t )(®->isp_mipi_phy_ind_data), data); +} + +static void isp4phy_mask_wreg (void __iomem *base,u32 phy_id,u16 addr, +u16 mask,u16 regval) +{ +unsigned long _mask = mask;Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 686
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+u16 shift =0 ; +u16 data; + + data =isp4phy_rreg (base, phy_id, addr); +if (mask) + shift =find_first_bit (&_mask,16 );
__ffs()?Sure, will do that in the next patch
Quoted 48 lines
Quoted 48 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +48
-0+ data = (data & ~mask) | ((regval << shift) & mask); + +isp4phy_wreg (base, phy_id, addr, data); +} + +static void isp4phy_optional_features_dphy (void __iomem *base,u32 phy_id) +{ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_CFG_0 , +CORE_DIG_DLANE_CLK_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_LP_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_0 , +CORE_DIG_DLANE_0_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_0 , +CORE_DIG_DLANE_1_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_0 , +CORE_DIG_DLANE_2_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_0 , +CORE_DIG_DLANE_3_RW_CFG_0_CFG_0_HS_PIN_SWAP_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_9 , +CORE_AFE_LANE0_CTRL_2_9_OA_LANE0_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_SEL_GATED_POLARITY_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_9 , +CORE_AFE_LANE3_CTRL_2_9_OA_LANE3_HSRX_SEL_GATED_POLARITY_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_9 , +CORE_AFE_LANE4_CTRL_2_9_OA_LANE4_HSRX_SEL_GATED_POLARITY_MASK , +0x0 ); + }Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 740
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+} + +static void isp4phy_dphy_periodic_deskew_program (void __iomem *base, +u32 phy_id) +{ + for (int ctr = 0;unsigned int?
Sure, will modify to use
size_tin the next patchQuoted 10 lines
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+ ctr <ARRAY_SIZE (startup_seq_dphy_periodic_deskew_program); + ctr++) +isp4phy_wreg (base, phy_id, + startup_seq_dphy_periodic_deskew_program[ctr].addr, + startup_seq_dphy_periodic_deskew_program[ctr].data); +} + +static void isp4phy_dphy_specific (void __iomem *base,u32 phy_id, +u64 data_rate, +struct isp4phy_mipi_config *phycfg)Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 756
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+{ +u64 half_rate = data_rate >>1 ; +u16 ddl_cal; + + ddl_cal =TIMEBASE * half_rate; + ddl_cal = (ddl_cal +31 ) >>5 ;I think you could do this on a single line as well.
Sure, will do that in the next patch
Quoted 462 lines
Quoted 462 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +462
-0+ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE0_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE1_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE2_HSRX_WORD_CLK_SEL_GATING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE3_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_7 , +CORE_DIG_RW_COMMON_7_LANE4_HSRX_WORD_CLK_SEL_GATING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_8 , +PPI_STARTUP_RW_COMMON_DPHY_8_CPHY_DDL_CAL_ADDR_MASK ,0x50 ); + +if (data_rate <1500 ) { +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x68 ); + }else { +/* Digital Delay Line (DDL) tuning calibration */ +isp4phy_mask_wreg (base, phy_id,PPI_STARTUP_RW_COMMON_DPHY_7 , +PPI_STARTUP_RW_COMMON_DPHY_7_DPHY_DDL_CAL_ADDR_MASK ,0x28 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_0 , +PPI_RW_DDLCAL_CFG_0_DDLCAL_TIMEBASE_TARGET_MASK ,0x77 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_DECR_WAIT_MASK ,0x22 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_DISABLE_TIME_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_WAIT_MASK ,0x4 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_TUNE_MODE_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_DDL_DLL_MASK ,0x1 ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_ENABLE_WAIT_MASK ,0x17 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_2 , +PPI_RW_DDLCAL_CFG_2_DDLCAL_UPDATE_SETTINGS_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_4 , +PPI_RW_DDLCAL_CFG_4_DDLCAL_STUCK_THRESH_MASK ,0xA ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_6 , +PPI_RW_DDLCAL_CFG_6_DDLCAL_MAX_DIFF_MASK ,0xA ); +/* LUT->24MHz case */ +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_7 , +PPI_RW_DDLCAL_CFG_7_DDLCAL_START_DELAY_MASK ,0xB ); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_3 , +PPI_RW_DDLCAL_CFG_3_DDLCAL_COUNTER_REF_MASK , ddl_cal); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_1 , +PPI_RW_DDLCAL_CFG_1_DDLCAL_MAX_PHASE_MASK , phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DLL_FBK_MASK , + phycfg->ddlcal_cfg_5ddlcal_dll_fbk_reg); +isp4phy_mask_wreg (base, phy_id,PPI_RW_DDLCAL_CFG_5 , +PPI_RW_DDLCAL_CFG_5_DDLCAL_DDL_COARSE_BANK_MASK , + phycfg->ddlcal_cfg_5ddlcal_ddl_coarse_bank_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_8 , +CORE_AFE_LANE0_CTRL_2_8_OA_LANE0_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_8 , +CORE_AFE_LANE1_CTRL_2_8_OA_LANE1_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_8 , +CORE_AFE_LANE2_CTRL_2_8_OA_LANE2_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_8 , +CORE_AFE_LANE3_CTRL_2_8_OA_LANE3_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_8 , +CORE_AFE_LANE4_CTRL_2_8_OA_LANE4_HSRX_CDPHY_SEL_FAST_MASK , + phycfg->afe_lanex_ctrl_2_8oa_cdphy_sel_fast_reg); + } + } + +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); +/* Write 6 if Tlpx (far end / near end) ratio < 1 +* Write 7 if Tlpx (far end / near end) ratio >= 1 +*/ +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_TTAGO_REG_MASK ,0x7 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_2 , +CORE_AFE_LANE0_CTRL_2_2_OA_LANE0_SEL_LANE_CFG_MASK ,0x0 ); + +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_2 , +CORE_AFE_LANE3_CTRL_2_2_OA_LANE3_SEL_LANE_CFG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_2 , +CORE_AFE_LANE4_CTRL_2_2_OA_LANE4_SEL_LANE_CFG_MASK ,0x0 ); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_2 , +CORE_AFE_LANE1_CTRL_2_2_OA_LANE1_SEL_LANE_CFG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_2 , +CORE_AFE_LANE2_CTRL_2_2_OA_LANE2_SEL_LANE_CFG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_EN_DEASS_COUNT_THRESH_D_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_RW_COMMON_6 , +CORE_DIG_RW_COMMON_6_DESERIALIZER_DIV_EN_DELAY_THRESH_D_MASK ,0x1 ); + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_ddl_bypass_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_HSRX_DPHY_DDL_BYPASS_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_ddl_bypass_en_ovr_en_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_12 , +CORE_AFE_LANE0_CTRL_2_12_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_12 , +CORE_AFE_LANE1_CTRL_2_12_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_12 , +CORE_AFE_LANE2_CTRL_2_12_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_12 , +CORE_AFE_LANE3_CTRL_2_12_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_12 , +CORE_AFE_LANE4_CTRL_2_12_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_VAL_MASK , + phycfg->afe_lanex_ctrl_2_12oa_dphy_dll_en_ovr_val_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE0_CTRL_2_13 , +CORE_AFE_LANE0_CTRL_2_13_OA_LANE0_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_13 , +CORE_AFE_LANE1_CTRL_2_13_OA_LANE1_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_13 , +CORE_AFE_LANE2_CTRL_2_13_OA_LANE2_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE3_CTRL_2_13 , +CORE_AFE_LANE3_CTRL_2_13_OA_LANE3_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE4_CTRL_2_13 , +CORE_AFE_LANE4_CTRL_2_13_OA_LANE4_HSRX_DPHY_DLL_EN_OVR_EN_MASK , + phycfg->afe_lanex_ctrl_2_13oa_dphy_dll_en_ovr_en_reg); +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE2_CTRL_2_9 , +CORE_AFE_LANE2_CTRL_2_9_OA_LANE2_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + }else { +isp4phy_mask_wreg (base, phy_id,CORE_AFE_LANE1_CTRL_2_9 , +CORE_AFE_LANE1_CTRL_2_9_OA_LANE1_HSRX_HS_CLK_DIV_MASK , + phycfg->afe_lanex_ctrl_2_9oa_hs_clk_div_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_0 , +CORE_DIG_DLANE_CLK_RW_HS_RX_0_HS_RX_0_TCLKSETTLE_REG_MASK ,0x1C ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_HS_RX_7 , +CORE_DIG_DLANE_CLK_RW_HS_RX_7_HS_RX_7_TCLKMISS_REG_MASK ,0x6 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_0 , +CORE_DIG_DLANE_0_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_0 , +CORE_DIG_DLANE_1_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_0 , +CORE_DIG_DLANE_2_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_0 , +CORE_DIG_DLANE_3_RW_HS_RX_0_HS_RX_0_THSSETTLE_REG_MASK , + phycfg->hs_rx_0hs_rx_0_thssettle_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_DESKEW_SUPPORTED_REG_MASK , + phycfg->cfg_1cfg_1_deskew_supported_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_CFG_1 , +CORE_DIG_DLANE_0_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_CFG_1 , +CORE_DIG_DLANE_1_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_CFG_1 , +CORE_DIG_DLANE_2_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_CFG_1 , +CORE_DIG_DLANE_3_RW_CFG_1_CFG_1_SOT_DETECTION_REG_MASK , + phycfg->cfg_1cfg_1_sot_detection_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_IGNORE_ALTERNCAL_REG_MASK , + phycfg->hs_rx_2hs_rx_2_ignore_alterncal_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_0 , +CORE_DIG_DLANE_0_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_0 , +CORE_DIG_DLANE_1_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_0 , +CORE_DIG_DLANE_2_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_0 , +CORE_DIG_DLANE_3_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_LP_2 , +CORE_DIG_DLANE_0_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_LP_2 , +CORE_DIG_DLANE_1_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_LP_2 , +CORE_DIG_DLANE_2_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_LP_2 , +CORE_DIG_DLANE_3_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK , +0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_0 , +CORE_DIG_DLANE_CLK_RW_LP_0_LP_0_ITMINRX_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_CLK_RW_LP_2 , +CORE_DIG_DLANE_CLK_RW_LP_2_LP_2_FILTER_INPUT_SAMPLING_REG_MASK ,0x0 ); + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_UPDATE_SETTINGS_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_UPDATE_SETTINGS_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_1 , +CORE_DIG_DLANE_0_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_1 , +CORE_DIG_DLANE_1_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK ,0x10 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_1 , +CORE_DIG_DLANE_2_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_1 , +CORE_DIG_DLANE_3_RW_HS_RX_1_HS_RX_1_FILTER_SIZE_DESKEW_REG_MASK , +0x10 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_2 , +CORE_DIG_DLANE_0_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_2 , +CORE_DIG_DLANE_1_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK ,0x3 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_2 , +CORE_DIG_DLANE_2_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_2 , +CORE_DIG_DLANE_3_RW_HS_RX_2_HS_RX_2_WINDOW_SIZE_DESKEW_REG_MASK , +0x3 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_STEP_SIZE_DESKEW_REG_MASK , +0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_4 , +CORE_DIG_DLANE_0_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_4 , +CORE_DIG_DLANE_1_RW_HS_RX_4_HS_RX_4_MAX_ITERATIONS_DESKEW_REG_MASK ,0x96 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_4 , +CORE_DIG_DLANE_2_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_4 , +CORE_DIG_DLANE_3_RW_HS_RX_4_HS_MAX_ITERATIONS_DESKEW_REG_MASK , +0x96 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_LEFT_INIT_REG_MASK ,0x0 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_5 , +CORE_DIG_DLANE_0_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_5 , +CORE_DIG_DLANE_1_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_5 , +CORE_DIG_DLANE_2_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_5 , +CORE_DIG_DLANE_3_RW_HS_RX_5_HS_RX_5_DDL_MID_INIT_REG_MASK ,0x1 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_6 , +CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_6 , +CORE_DIG_DLANE_2_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_RX_6_DDL_RIGHT_INIT_REG_MASK ,0x2 ); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_RX_7_DESKEW_AUTO_ALGO_SEL_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_7 , +CORE_DIG_DLANE_0_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_7 , +CORE_DIG_DLANE_1_RW_HS_RX_7_HS_RX_7_SELECT_ALTERNATE_ALGO_REG_MASK ,0x0 ); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_7 , +CORE_DIG_DLANE_2_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_7 , +CORE_DIG_DLANE_3_RW_HS_RX_7_HS_SELECT_ALTERNATE_ALGO_REG_MASK , +0x0 ); + } +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_3 , +CORE_DIG_DLANE_0_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_3 , +CORE_DIG_DLANE_1_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_3 , +CORE_DIG_DLANE_2_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_3 , +CORE_DIG_DLANE_3_RW_HS_RX_3_HS_RX_3_FJUMP_DESKEW_REG_MASK , + phycfg->hs_rx_3hs_rx_3_fjump_deskew_reg); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_9 , +CORE_DIG_DLANE_0_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_9 , +CORE_DIG_DLANE_1_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_2_RW_HS_RX_9 , +CORE_DIG_DLANE_2_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_9 , +CORE_DIG_DLANE_3_RW_HS_RX_9_HS_RX_9_PHASE_BOUND_REG_MASK , + phycfg->max_phase); + } + +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_0_RW_HS_RX_6 , +CORE_DIG_DLANE_0_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_1_RW_HS_RX_6 , +CORE_DIG_DLANE_1_RW_HS_RX_6_HS_RX_6_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +if (phy_id <=ISP_MIPI_PHY_ID_1 ) { + isp4phy_mask_wreg(base, phy_id, CORE_DIG_DLANE_2_RW_HS_RX_6, + CORE_DIG_DLANE_2_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK,Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 1223
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+ phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); +isp4phy_mask_wreg (base, phy_id,CORE_DIG_DLANE_3_RW_HS_RX_6 , +CORE_DIG_DLANE_3_RW_HS_RX_6_HS_MIN_EYE_OPENING_DESKEW_REG_MASK , + phycfg->hs_rx_6hs_rx_6_min_eye_opening_deskew_reg); + }Could you do this using a loop instead? With a bit saner macros, that should be quite a bit easier, too.
No very sure how, would you mind to give a sample?
Quoted 7 lines
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+} + +static void isp4phy_common (void __iomem *base,u32 phy_id) +{ +for (int ctr =0 ; ctr <ARRAY_SIZE (startup_seq_common); ctr++) + isp4phy_mask_wreg(base, phy_id, startup_seq_common[ctr].addr,Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Unsigned int for these, too, please.
Sure, will modify to use
size_tin the next patchQuoted 88 lines
Quoted 88 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +88
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Please add an array for the values and implement this as a loop instead.
Sure, will do that in the next patch
Quoted 23 lines
Quoted 23 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +23
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Ditto. Or maybe use
ilog2()?I'd prefer to using the hex value directly because it's more readable, what do you think?
Quoted 20 lines
Quoted 20 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +20
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
You could just as well do these without a temporary variable.
Sure, will remove it in the next patch
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Would assigning phycfg to { } do the job?
Sure, will do that in the next patch
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
{ } is enough.
Sure, will do that in the next patch
Quoted 45 lines
Quoted 45 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +45
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/* Single-line comment. */
Sure, will modify in the next patch
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +4
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
/*
* Multi-line
* comment.
*/Sure, will modify in the next patch
Quoted 17 lines
Quoted 17 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +17
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Why
uintptr_tbtw.? This seems to be a recurring pattern.To make safe conversion between pointer and big enough integer, removing it will result in compiling warning.
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 3 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +3
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Use
read_poll_timeout()maybe?Sure, will modify in the next patch
Quoted 14 lines
Quoted 14 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +14
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
How about using "amdisp4" as the prefix for the driver's symbol names? Just "isp4" is very generic.
Actually all symbols in this driver follow the same convention, just use file name as prefix, the reason of not adding amd is 1. All files are located under amd folder, so no confusion. 2. To make symbol name short
3. No export symbol from this driver, if there is, the export symbol should add amd as part of prefix. Is that acceptible to you?Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Maybe use a similar format than for the 4-lane case?
Not very sure your meaning, will rewrithe this part using switch like
switch (phy_id) { case ISP_MIPI_PHY_ID_0: case ISP_MIPI_PHY_ID_1: if (lane_num > 4) { dev_err(dev, "fail invalid lane number %u for phy%d\n", lane_num,14 lines not shown · raw message
68 lines not shown · raw message
3 lines not shown · raw message
Parts of this message are not shown here. View the raw message.
Du, Bin
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Thanks Laurent Pinchart for the review.
Quoted 34 lines · Laurent Pinchart
Quoted 33 lines · Bin
Quoted 32 lines · Sakari Ailus
Quoted 31 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_phy.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_phy.hdrivers/media/platform/amd/isp4/Makefile +1
-0@@ -4,6 +4,7 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ + isp4_phy.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/isp4_phy.c new file +0
-1--- /dev/null
[snip]
Quoted 13 lines
Quoted 9 lines
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 471
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+ +static const struct isp4phy_mipi_reg *isp_mipi_phy_reg[ISP_MIPI_PHY_ID_MAX ] = { + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY0_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY1_REG0 , + (struct isp4phy_mipi_reg *)ISP_MIPI_PHY2_REG0 ,That's an interesting way to prefill structs. I don't think these macros expand to valid pointers.
Quoted 3 lines
Yes, these are valid pointers, but they are not pointing to system memory, they are phy registers address, can be accessed by adding the mmio base.
Quoted 6 lines
Please don't do that. Store register addresses in macros, and use them through the code as appropriate. Stop passing the base mmio address around through functions, store it in a PHY object, and pass that object to the
isp4phy_start()instead of a dev pointer, base pointer and phy id.
Sure, will do that and update in the next patch
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +33
-0+}; + +static const struct isp4phy_mipi_reg_seq startup_seq_general_common_config[] = { + {PPI_STARTUP_RW_COMMON_DPHY_10 ,PPI_STARTUP_RW_COMMON_DPHY_10_PHY_READY_ADDR_MASK ,0x30 }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_VAL_MASK ,0x0 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_2_GLOBAL_ULPS_OVR_EN_MASK ,0x1 + }, + { +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0 , +CORE_DIG_ANACTRL_RW_COMMON_ANACTRL_0_CB_LP_DCO_EN_DLY_MASK ,0x3F + }, + { +PPI_STARTUP_RW_COMMON_STARTUP_1_1 , +PPI_STARTUP_RW_COMMON_STARTUP_1_1_PHY_READY_DLY_MASK ,0x233 + }, + {PPI_STARTUP_RW_COMMON_DPHY_6 ,PPI_STARTUP_RW_COMMON_DPHY_6_LP_DCO_CAL_ADDR_MASK ,0x27 }, + {PPI_CALIBCTRL_RW_COMMON_BG_0 ,PPI_CALIBCTRL_RW_COMMON_BG_0_BG_MAX_COUNTER_MASK ,0x1F4 }, + {PPI_RW_LPDCOCAL_NREF ,PPI_RW_LPDCOCAL_NREF_LPDCOCAL_NREF_MASK ,0x320 }, + {PPI_RW_LPDCOCAL_NREF_RANGE ,PPI_RW_LPDCOCAL_NREF_RANGE_LPDCOCAL_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_TWAIT_CONFIG ,PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_PON_MASK ,0x7F }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_NREF_RANGE_MASK ,0x1B }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_USE_IDEAL_NREF_MASK ,0x1 }, + {PPI_RW_LPDCOCAL_VT_CONFIG ,PPI_RW_LPDCOCAL_VT_CONFIG_LPDCOCAL_VT_TRACKING_EN_MASK ,0x0 }, + {PPI_RW_LPDCOCAL_COARSE_CFG ,PPI_RW_LPDCOCAL_COARSE_CFG_NCOARSE_START_MASK ,0x1 }, + {PPI_RW_COMMON_CFG ,PPI_RW_COMMON_CFG_CFG_CLK_DIV_FACTOR_MASK ,0x3 }, +}; + +static const struct isp4phy_mipi_reg_seq startup_seq_common[] = {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 512
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +8
-0+ { PPI_STARTUP_RW_COMMON_DPHY_2, PPI_STARTUP_RW_COMMON_DPHY_2_RCAL_ADDR_MASK, 0x5 }, + { PPI_RW_TERMCAL_CFG_0, PPI_RW_TERMCAL_CFG_0_TERMCAL_TIMER_MASK, 0x17 }, + { PPI_RW_OFFSETCAL_CFG_0, PPI_RW_OFFSETCAL_CFG_0_OFFSETCAL_WAIT_THRESH_MASK, 0x4 }, + { PPI_RW_LPDCOCAL_TIMEBASE, PPI_RW_LPDCOCAL_TIMEBASE_LPDCOCAL_TIMEBASE_MASK, 0x5F }, + { +PPI_RW_LPDCOCAL_TWAIT_CONFIG , +PPI_RW_LPDCOCAL_TWAIT_CONFIG_LPDCOCAL_TWAIT_COARSE_MASK ,0x1D + },
[snip]
--
Regards,
Bin
Re: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
In reply to Sakari AilusQuoted 15 lines · Sakari Ailus
Quoted 14 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.c create mode 100644 drivers/media/platform/amd/isp4/isp4_phy.h
[snip]
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +0
-0@@ -0,0 +1,1547 @@
[snip]
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+union isp4phy_mipi_0 { +struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value;
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 348
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+}; + +union isp4phy_mipi_1 { + struct { + u32 mode : 1;Please pad these -- I don't think the ABI otherwise requires they're in a particular location of the container (u32).
Or better, ditch the structures, and use macros to define register fields like all other drivers do.
Quoted 84 lines
Quoted 50 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +50
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; +drivers/media/platform/amd/isp4/isp4_phy.c line 408
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_idx { + struct { + u32 addr : 16;u16 would seem appropriate here.
drivers/media/platform/amd/isp4/isp4_phy.c line 415
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { + struct { + u32 data : 16;Ditto.
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +11
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +};
[snip]
Signature · 3 lines
Regards, Laurent Pinchart
Du, Bin
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Thanks Laurent Pinchart for your review
Quoted 43 lines · Laurent Pinchart
Quoted 15 lines · Sakari Ailus
Quoted 14 lines · Bin Du
The helper functions is for configuring, starting and stop the MIPI PHY. All configurations related to MIPI PHY configuration and calibration parameters are encapsulated in two helper functions: start and stop mipi phy.
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 1 + drivers/media/platform/amd/isp4/isp4_phy.c | 1547 ++++++++++++++++++++ drivers/media/platform/amd/isp4/isp4_phy.h | 14 + 3 files changed, 1562 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_phy.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_phy.h[snip]
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +0
-0@@ -0,0 +1,1547 @@[snip]
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+union isp4phy_mipi_0 { +struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value;Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_phy.c line 348
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +5
-0+}; + +union isp4phy_mipi_1 { + struct { + u32 mode : 1;Please pad these -- I don't think the ABI otherwise requires they're in a particular location of the container (u32).
Quoted 3 lines
Or better, ditch the structures, and use macros to define register fields like all other drivers do.
Sure, will look into it and update in the next patch
Quoted 73 lines
Quoted 73 lines
Quoted 50 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +50
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; +drivers/media/platform/amd/isp4/isp4_phy.c line 408
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_idx { + struct { + u32 addr : 16;u16 would seem appropriate here.
drivers/media/platform/amd/isp4/isp4_phy.c line 415
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +7
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { + struct { + u32 data : 16;Ditto.
Quoted 14 lines
Quoted 11 lines
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +11
-0+ } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +};[snip]
Regards,
Bin
Sakari Ailus
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
In reply to Bin DuHi Bin,
Quoted 100 lines · Bin Du
drivers/media/platform/amd/isp4/isp4_phy.c new file +100
-0+struct isp4phy_mipi_reg_seq { +u16 addr; +u16 mask; +u16 data; +}; + +union isp4phy_mipi_0 { +struct { +u32 shutdownz :1 ; +u32 rstz :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_1 { +struct { +u32 mode :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_2 { +struct { +u32 rxdatawidthhs_0 :2 ; +u32 rxdatawidthhs_1 :2 ; +u32 rxdatawidthhs_2 :2 ; +u32 rxdatawidthhs_3 :2 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_3 { +u32 reserved; +}; + +union isp4phy_mipi_4 { +struct { +u32 enableclk :1 ; +u32 enable_0 :1 ; +u32 enable_1 :1 ; +u32 enable_2 :1 ; +u32 enable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_5 { +struct { +u32 forcerxmode_0 :1 ; +u32 forcerxmode_1 :1 ; +u32 forcerxmode_2 :1 ; +u32 forcerxmode_3 :1 ; +u32 forcerxmode_clk :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_6 { +struct { +u32 turndisable_0 :1 ; +u32 turndisable_1 :1 ; +u32 turndisable_2 :1 ; +u32 turndisable_3 :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_7 { +struct { +u32 ready :1 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_idx { +struct { +u32 addr :16 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_data { +struct { +u32 data :16 ; + } bit; +u32 value; +}; + +union isp4phy_mipi_ind_wack { +struct { +u32 ack :1 ; +u32 pslverr :1 ; + } bit; +u32 value; +}; + +struct isp4phy_mipi_reg { +union isp4phy_mipi_0 isp_mipi_phy0; +union isp4phy_mipi_1 isp_mipi_phy1; +union isp4phy_mipi_2 isp_mipi_phy2;
drivers/media/platform/amd/isp4/isp4_phy.c line 441
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+struct isp4phy_mipi_3 isp_mipi_phy3; +union isp4phy_mipi_4 isp_mipi_phy4; +union isp4phy_mipi_5 isp_mipi_phy5; +union isp4phy_mipi_6 isp_mipi_phy6; +union isp4phy_mipi_7 isp_mipi_phy7; +u32 reserve; +union isp4phy_mipi_ind_idx isp_mipi_phy_ind_idx; +union isp4phy_mipi_ind_data isp_mipi_phy_ind_data; +union isp4phy_mipi_ind_wack isp_mipi_phy_inc_wack; +};
One more thing. Is there an endianness issue here?
Overall the CPU endianness may be big or little while the device endianness is little, presumably. You should use __le* types and functions to convert the endianness when dealing with the messages to and from the device.
Signature · 3 lines
Kind regards, Sakari Ailus
Du, Bin
maintainerRe: [PATCH v2 3/8] media: platform: amd: Add helpers to configure isp4 mipi phy
Many thanks Sakari Ailus for your review
Quoted 9 lines · Sakari Ailus
Hi Bin,
Quoted 6 lines · Bin Du
drivers/media/platform/amd/isp4/isp4_phy.c new file +6
-0+struct isp4phy_mipi_reg_seq { +u16 addr; +u16 mask; +u16 data; +}; +
[snip]
Quoted 17 lines
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +4
-0+struct isp4phy_mipi_reg { +union isp4phy_mipi_0 isp_mipi_phy0; +union isp4phy_mipi_1 isp_mipi_phy1; +union isp4phy_mipi_2 isp_mipi_phy2;drivers/media/platform/amd/isp4/isp4_phy.c line 441
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_phy.c new file +10
-0+struct isp4phy_mipi_3 isp_mipi_phy3; +union isp4phy_mipi_4 isp_mipi_phy4; +union isp4phy_mipi_5 isp_mipi_phy5; +union isp4phy_mipi_6 isp_mipi_phy6; +union isp4phy_mipi_7 isp_mipi_phy7; +u32 reserve; +union isp4phy_mipi_ind_idx isp_mipi_phy_ind_idx; +union isp4phy_mipi_ind_data isp_mipi_phy_ind_data; +union isp4phy_mipi_ind_wack isp_mipi_phy_inc_wack; +};One more thing. Is there an endianness issue here?
Quoted 4 lines
Overall the CPU endianness may be big or little while the device endianness is little, presumably. You should use __le* types and functions to convert the endianness when dealing with the messages to and from the device.
Good consideration, no endianness issue here because AMD APU is little endian x64 arch which aligns with the device endianness, so, no extra conversion is needed
Regards,
Bin
Bin Du
maintainerPATCH v2 4/8 media: platform: amd: Add isp4 fw and hw interface
In reply to Bin DuISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.
--- drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 +++ 4 files changed, 1546 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.h
drivers/media/platform/amd/isp4/Makefile +12 -0
@@ -5,10 +5,22 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ isp4_phy.o \ + isp4_interface.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drm ccflags-y += -I$(srctree)/include +ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dm ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) cc_stack_align := -mpreferred-stack-boundary=4
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +318 -0
318 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.c new file +1052 -0
1,052 lines not on this page · raw message
drivers/media/platform/amd/isp4/isp4_interface.h new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v2 4/8] media: platform: amd: Add isp4 fw and hw interface
+Alex
+amd-gfx
Quoted 39 lines · Bin Du
ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 +++ 4 files changed, 1546 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.hdrivers/media/platform/amd/isp4/Makefile +3
-0@@ -5,10 +5,22 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ isp4_phy.o \ + isp4_interface.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu
drivers/media/platform/amd/isp4/Makefile line 23
Quoted 10 lines
drivers/media/platform/amd/isp4/Makefile +9
-0+ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drm ccflags-y += -I$(srctree)/include +ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dm
IMO this feels like a hack and also fragile to be sharing so much across subsystems.
Either there should be a kernel wide include/ header that can be used by both or there should be a helper exported to get just the data that is needed.
Quoted 9 lines
drivers/media/platform/amd/isp4/Makefile +0
-0ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) cc_stack_align := -mpreferred-stack-boundary=4drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +0
-0
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 9
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +9
-0@@ -0,0 +1,318 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_CMD_RESP_H_ +#define _ISP4_CMD_RESP_H_ + +/*
Did you mean this to be kernel doc? If so you need:
/**
Quoted 23 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +23
-0+* @brief Host and Firmware command & response channel. +* Two types of command/response channel. +* Type Global Command has one command/response channel. +* Type Stream Command has one command/response channel. +*----------- ------------ +*| | --------------------------- | | +*| | ---->| Global Command |----> | | +*| | --------------------------- | | +*| | | | +*| | | | +*| | --------------------------- | | +*| | ---->| Stream Command |----> | | +*| | --------------------------- | | +*| | | | +*| | | | +*| | | | +*| HOST | | Firmware | +*| | | | +*| | | | +*| | -------------------------- | | +*| | <----| Global Response |<---- | | +*| | -------------------------- | | +*| | | |
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 42
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +10
-0+*| | | | +*| | -------------------------- | | +*| | <----| Stream Response |<---- | | +*| | -------------------------- | | +*| | | | +*| | | | +*----------- ------------ +*/ + +/*
Same comment about kernel doc
Quoted 23 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +23
-0+* @brief command ID format +* cmd_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define CMD_TYPE_SHIFT (24) +#define CMD_GROUP_SHIFT (16) +#define CMD_TYPE_STREAM_CTRL ((u32)0x2 << CMD_TYPE_SHIFT) + +#define CMD_GROUP_STREAM_CTRL ((u32)0x1 << CMD_GROUP_SHIFT) +#define CMD_GROUP_STREAM_BUFFER ((u32)0x4 << CMD_GROUP_SHIFT) + +/* Stream Command */ +#define CMD_ID_SET_STREAM_CONFIG \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x1) +#define CMD_ID_SET_OUT_CHAN_PROP \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x3) +#define CMD_ID_ENABLE_OUT_CHAN \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x5)
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 75
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +10
-0+#define CMD_ID_START_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x7) +#define CMD_ID_STOP_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x8) + +/* Stream Buffer Command */ +#define CMD_ID_SEND_BUFFER \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_BUFFER | 0x1) + +/*
Same comment about kernel doc
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +11
-0+* @brief response ID format +* resp_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define RESP_GROUP_SHIFT (16) +#define RESP_GROUP_MASK (0xff << RESP_GROUP_SHIFT)
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 96
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +10
-0+ +#define GET_RESP_GROUP_VALUE (resp_id) \ + (((resp_id) & RESP_GROUP_MASK) >> \ + RESP_GROUP_SHIFT) +#define GET_RESP_ID_VALUE (resp_id) ((resp_id) & 0xffff) + +#define RESP_GROUP_GENERAL (0x1 << RESP_GROUP_SHIFT) +#define RESP_GROUP_NOTIFICATION (0x3 << RESP_GROUP_SHIFT) + +/* General Response */
Extra whitespace between words
Quoted 378 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +222
-0+#define RESP_ID_CMD_DONE (RESP_GROUP_GENERAL | 0x1) + +/* Notification */ +#define RESP_ID_NOTI_FRAME_DONE (RESP_GROUP_NOTIFICATION | 0x1) + +#define CMD_STATUS_SUCCESS (0) +#define CMD_STATUS_FAIL (1) +#define CMD_STATUS_SKIPPED (2) + +#define ADDR_SPACE_TYPE_GPU_VA 4 + +#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) + +/* +* standard ISP mipicsi=>isp +*/ +#define MIPI0_ISP_PIPELINE_ID 0x5f91 + +enum isp4fw_sensor_id { +SENSOR_ID_ON_MIPI0 =0 ,/* Sensor id for ISP input from MIPI port 0 */ +}; + +enum isp4fw_stream_id { +STREAM_ID_INVALID =-1 ,/* STREAM_ID_INVALID. */ +STREAM_ID_1 =0 ,/* STREAM_ID_1. */ +STREAM_ID_2 =1 ,/* STREAM_ID_2. */ +STREAM_ID_3 =2 ,/* STREAM_ID_3. */ +STREAM_ID_MAXIMUM /* STREAM_ID_MAXIMUM. */ +}; + +enum isp4fw_image_format { +IMAGE_FORMAT_NV12 =1 ,/* 4:2:0,semi-planar, 8-bit */ +IMAGE_FORMAT_YUV422INTERLEAVED =7 ,/* interleave, 4:2:2, 8-bit */ +}; + +enum isp4fw_pipe_out_ch { +ISP_PIPE_OUT_CH_PREVIEW =0 , +}; + +enum isp4fw_yuv_range { +ISP_YUV_RANGE_FULL =0 ,/* YUV value range in 0~255 */ +ISP_YUV_RANGE_NARROW =1 ,/* YUV value range in 16~235 */ +ISP_YUV_RANGE_MAX +}; + +enum isp4fw_buffer_type { +BUFFER_TYPE_PREVIEW =8 , +BUFFER_TYPE_META_INFO =10 , +BUFFER_TYPE_MEM_POOL =15 , +}; + +enum isp4fw_buffer_status { +BUFFER_STATUS_INVALID ,/* The buffer is INVALID */ +BUFFER_STATUS_SKIPPED ,/* The buffer is not filled with image data */ +BUFFER_STATUS_EXIST ,/* The buffer is exist and waiting for filled */ +BUFFER_STATUS_DONE ,/* The buffer is filled with image data */ +BUFFER_STATUS_LACK ,/* The buffer is unavailable */ +BUFFER_STATUS_DIRTY ,/* The buffer is dirty, probably caused by +* LMI leakage +*/ +BUFFER_STATUS_MAX /* The buffer STATUS_MAX */ +}; + +enum isp4fw_buffer_source { +/* The buffer is from the stream buffer queue */ +BUFFER_SOURCE_STREAM , +}; + +struct isp4fw_error_code { +u32 code1; +u32 code2; +u32 code3; +u32 code4; +u32 code5; +}; + +/* +* Command Structure for FW +*/ + +struct isp4fw_cmd { +u32 cmd_seq_num; +u32 cmd_id; +u32 cmd_param[12 ]; +u16 cmd_stream_id; +u8 cmd_silent_resp; +u8 reserved; +u32 cmd_check_sum; +}; + +struct isp4fw_resp_cmd_done { +/* The host2fw command seqNum. +* To indicate which command this response refer to. +*/ +u32 cmd_seq_num; +/* The host2fw command id for host double check. */ +u32 cmd_id; +/* Indicate the command process status. +* 0 means success. 1 means fail. 2 means skipped +*/ +u16 cmd_status; +/* If the cmd_status is 1, that means the command is processed fail, */ +/* host can check the isp4fw_error_code to get the detail +* error information +*/ +u16 isp4fw_error_code; +/* The response payload will be in different struct type */ +/* according to different cmd done response. */ +u8 payload[36 ]; +}; + +struct isp4fw_resp_param_package { +u32 package_addr_lo;/* The low 32 bit addr of the pkg address. */ +u32 package_addr_hi;/* The high 32 bit addr of the pkg address. */ +u32 package_size;/* The total pkg size in bytes. */ +u32 package_check_sum;/* The byte sum of the pkg. */ +}; + +struct isp4fw_resp { +u32 resp_seq_num; +u32 resp_id; +union { +struct isp4fw_resp_cmd_done cmd_done; +struct isp4fw_resp_param_package frame_done; +u32 resp_param[12 ]; + } param; +u8 reserved[4 ]; +u32 resp_check_sum; +}; + +struct isp4fw_mipi_pipe_path_cfg { +u32 b_enable; +enum isp4fw_sensor_id isp4fw_sensor_id; +}; + +struct isp4fw_isp_pipe_path_cfg { +u32 isp_pipe_id;/* pipe ids for pipeline construction */ +}; + +struct isp4fw_isp_stream_cfg { +/* Isp mipi path */ +struct isp4fw_mipi_pipe_path_cfg mipi_pipe_path_cfg; +/* Isp pipe path */ +struct isp4fw_isp_pipe_path_cfg isp_pipe_path_cfg; +/* enable TNR */ +u32 b_enable_tnr; +/* number of frame rta per-processing, +* set to 0 to use fw default value +*/ +u32 rta_frames_per_proc; +}; + +struct isp4fw_image_prop { +enum isp4fw_image_format image_format;/* Image format */ +u32 width;/* Width */ +u32 height;/* Height */ +u32 luma_pitch;/* Luma pitch */ +u32 chroma_pitch;/* Chrom pitch */ +enum isp4fw_yuv_range yuv_range;/* YUV value range */ +}; + +struct isp4fw_buffer { +/* A check num for debug usage, host need to */ +/* set the buf_tags to different number */ +u32 buf_tags; +union { +u32 value; +struct { +u32 space :16 ; +u32 vmid :16 ; + } bit; + } vmid_space; +u32 buf_base_a_lo;/* Low address of buffer A */ +u32 buf_base_a_hi;/* High address of buffer A */ +u32 buf_size_a;/* Buffer size of buffer A */ + +u32 buf_base_b_lo;/* Low address of buffer B */ +u32 buf_base_b_hi;/* High address of buffer B */ +u32 buf_size_b;/* Buffer size of buffer B */ + +u32 buf_base_c_lo;/* Low address of buffer C */ +u32 buf_base_c_hi;/* High address of buffer C */ +u32 buf_size_c;/* Buffer size of buffer C */ +}; + +struct isp4fw_buffer_meta_info { +u32 enabled;/* enabled flag */ +enum isp4fw_buffer_status status;/* BufferStatus */ +struct isp4fw_error_code err;/* err code */ +enum isp4fw_buffer_source source;/* BufferSource */ +struct isp4fw_image_prop image_prop;/* image_prop */ +struct isp4fw_buffer buffer;/* buffer */ +}; + +struct isp4fw_meta_info { +u32 poc;/* frame id */ +u32 fc_id;/* frame ctl id */ +u32 time_stamp_lo;/* time_stamp_lo */ +u32 time_stamp_hi;/* time_stamp_hi */ +struct isp4fw_buffer_meta_info preview;/* preview BufferMetaInfo */ +}; + +struct isp4fw_cmd_send_buffer { +enum isp4fw_buffer_type buffer_type;/* buffer Type */ +struct isp4fw_buffer buffer;/* buffer info */ +}; + +struct isp4fw_cmd_set_out_ch_prop { +enum isp4fw_pipe_out_ch ch;/* ISP pipe out channel */ +struct isp4fw_image_prop image_prop;/* image property */ +}; + +struct isp4fw_cmd_enable_out_ch { +enum isp4fw_pipe_out_ch ch;/* ISP pipe out channel */ +u32 is_enable;/* If enable channel or not */ +}; + +struct isp4fw_cmd_set_stream_cfg { +struct isp4fw_isp_stream_cfg stream_cfg;/* stream path config */ +}; + +#endif drivers/media/platform/amd/isp4/isp4_interface.c new file +150
-0@@ -0,0 +1,1052 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/mutex.h> + +#include "amdgpu_object.h" + +#include "isp4_fw_cmd_resp.h" +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_interface.h" + +#define ISP4IF_FW_RESP_RB_IRQ_EN_MASK \ + (ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK) + +struct isp4if_rb_config { +const char *name; +u32 index; +u32 reg_rptr; +u32 reg_wptr; +u32 reg_base_lo; +u32 reg_base_hi; +u32 reg_size; +u32 val_size; +u64 base_mc_addr; +void *base_sys_addr; +}; + +/* FW cmd ring buffer configuration */ +static struct isp4if_rb_config + isp4if_cmd_rb_config[ISP4IF_STREAM_ID_MAX ] = { + { + .name ="CMD_RB_GBL0" , + .index =3 , + .reg_rptr =ISP_RB_RPTR4 , + .reg_wptr =ISP_RB_WPTR4 , + .reg_base_lo =ISP_RB_BASE_LO4 , + .reg_base_hi =ISP_RB_BASE_HI4 , + .reg_size =ISP_RB_SIZE4 , + }, + { + .name ="CMD_RB_STR1" , + .index =0 , + .reg_rptr =ISP_RB_RPTR1 , + .reg_wptr =ISP_RB_WPTR1 , + .reg_base_lo =ISP_RB_BASE_LO1 , + .reg_base_hi =ISP_RB_BASE_HI1 , + .reg_size =ISP_RB_SIZE1 , + }, + { + .name ="CMD_RB_STR2" , + .index =1 , + .reg_rptr =ISP_RB_RPTR2 , + .reg_wptr =ISP_RB_WPTR2 , + .reg_base_lo =ISP_RB_BASE_LO2 , + .reg_base_hi =ISP_RB_BASE_HI2 , + .reg_size =ISP_RB_SIZE2 , + }, + { + .name ="CMD_RB_STR3" , + .index =2 , + .reg_rptr =ISP_RB_RPTR3 , + .reg_wptr =ISP_RB_WPTR3 , + .reg_base_lo =ISP_RB_BASE_LO3 , + .reg_base_hi =ISP_RB_BASE_HI3 , + .reg_size =ISP_RB_SIZE3 , + }, +}; + +/* FW resp ring buffer configuration */ +static struct isp4if_rb_config + isp4if_resp_rb_config[ISP4IF_STREAM_ID_MAX ] = { + { + .name ="RES_RB_GBL0" , + .index =3 , + .reg_rptr =ISP_RB_RPTR12 , + .reg_wptr =ISP_RB_WPTR12 , + .reg_base_lo =ISP_RB_BASE_LO12 , + .reg_base_hi =ISP_RB_BASE_HI12 , + .reg_size =ISP_RB_SIZE12 , + }, + { + .name ="RES_RB_STR1" , + .index =0 , + .reg_rptr =ISP_RB_RPTR9 , + .reg_wptr =ISP_RB_WPTR9 , + .reg_base_lo =ISP_RB_BASE_LO9 , + .reg_base_hi =ISP_RB_BASE_HI9 , + .reg_size =ISP_RB_SIZE9 , + }, + { + .name ="RES_RB_STR2" , + .index =1 , + .reg_rptr =ISP_RB_RPTR10 , + .reg_wptr =ISP_RB_WPTR10 , + .reg_base_lo =ISP_RB_BASE_LO10 , + .reg_base_hi =ISP_RB_BASE_HI10 , + .reg_size =ISP_RB_SIZE10 , + }, + { + .name ="RES_RB_STR3" , + .index =2 , + .reg_rptr =ISP_RB_RPTR11 , + .reg_wptr =ISP_RB_WPTR11 , + .reg_base_lo =ISP_RB_BASE_LO11 , + .reg_base_hi =ISP_RB_BASE_HI11 , + .reg_size =ISP_RB_SIZE11 , + }, +}; + +/* FW log ring buffer configuration */ +static struct isp4if_rb_config isp4if_log_rb_config = { + .name ="LOG_RB" , + .index =0 , + .reg_rptr =ISP_LOG_RB_RPTR0 , + .reg_wptr =ISP_LOG_RB_WPTR0 , + .reg_base_lo =ISP_LOG_RB_BASE_LO0 , + .reg_base_hi =ISP_LOG_RB_BASE_HI0 , + .reg_size =ISP_LOG_RB_SIZE0 , +}; + +static struct isp4if_gpu_mem_info *isp4if_gpu_mem_alloc (struct isp4_interface + *ispif, +u32 mem_size) +{ +struct isp4if_gpu_mem_info *mem_info; +struct amdgpu_bo *bo =NULL ; +struct amdgpu_device *adev; +struct device *dev; + +void *cpu_ptr; +u64 gpu_addr; +u32 ret; + + dev = ispif->dev; + +if (!mem_size) +return NULL ; + + mem_info =kzalloc (sizeof (*mem_info),GFP_KERNEL ); +if (!mem_info) +return NULL ; + + adev = (struct amdgpu_device *)ispif->adev; + mem_info->mem_size = mem_size;
drivers/media/platform/amd/isp4/isp4_interface.c line 160
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ mem_info->mem_align =ISP4IF_ISP_MC_ADDR_ALIGN ; + mem_info->mem_domain =AMDGPU_GEM_DOMAIN_GTT ; + + ret =amdgpu_bo_create_kernel (adev, + mem_info->mem_size, + mem_info->mem_align, + mem_info->mem_domain, + &bo, + &gpu_addr, + &cpu_ptr);
IMO this is begging for an extra helper that has a true exported symbol and kernel-wide header for use rather than hacking around the includes for drm headers.
The kernel-wide header can describe the data types exchanged, so there wouldn't be a need to have all the amdgpu headers included.
Quoted 18 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +18
-0+ +if (!cpu_ptr || ret) { +dev_err (dev,"gpuvm buffer alloc fail, size %u\n" , mem_size); +kfree (mem_info); +return NULL ; + } + + mem_info->sys_addr = cpu_ptr; + mem_info->gpu_mc_addr = gpu_addr; + mem_info->mem_handle = (void *)bo; + +return mem_info; +} + +static int isp4if_gpu_mem_free (struct isp4_interface *ispif, +struct isp4if_gpu_mem_info *mem_info) +{ +struct device *dev = ispif->dev;
drivers/media/platform/amd/isp4/isp4_interface.c line 188
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+struct amdgpu_bo *bo; + +if (!mem_info) { +dev_err (dev,"invalid mem_info\n" ); +return -EINVAL ; + } + + bo = (struct amdgpu_bo *)mem_info->mem_handle; + +amdgpu_bo_free_kernel (&bo, &mem_info->gpu_mc_addr, &mem_info->sys_addr);
This also I think needs another helper
Quoted 56 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +56
-0+ +kfree (mem_info); + +return 0 ; +} + +static int isp4if_dealloc_fw_gpumem (struct isp4_interface *ispif) +{ +int i; + +if (ispif->fw_mem_pool) { +isp4if_gpu_mem_free (ispif, ispif->fw_mem_pool); + ispif->fw_mem_pool =NULL ; + } + +if (ispif->fw_cmd_resp_buf) { +isp4if_gpu_mem_free (ispif, ispif->fw_cmd_resp_buf); + ispif->fw_cmd_resp_buf =NULL ; + } + +if (ispif->fw_log_buf) { +isp4if_gpu_mem_free (ispif, ispif->fw_log_buf); + ispif->fw_log_buf =NULL ; + } + +for (i =0 ; i <ISP4IF_MAX_STREAM_META_BUF_COUNT ; i++) { +if (ispif->metainfo_buf_pool[i]) { +isp4if_gpu_mem_free (ispif, ispif->metainfo_buf_pool[i]); + ispif->metainfo_buf_pool[i] =NULL ; + } + } + +return 0 ; +} + +static int isp4if_alloc_fw_gpumem (struct isp4_interface *ispif) +{ +struct device *dev = ispif->dev; +int i; + + ispif->fw_mem_pool =isp4if_gpu_mem_alloc (ispif,FW_MEMORY_POOL_SIZE ); +if (!ispif->fw_mem_pool) + goto error_no_memory; + + ispif->fw_cmd_resp_buf = +isp4if_gpu_mem_alloc (ispif,ISP4IF_RB_PMBMAP_MEM_SIZE ); +if (!ispif->fw_cmd_resp_buf) + goto error_no_memory; + + ispif->fw_log_buf = +isp4if_gpu_mem_alloc (ispif,ISP4IF_FW_LOG_RINGBUF_SIZE ); +if (!ispif->fw_log_buf) + goto error_no_memory; + +for (i =0 ; i <ISP4IF_MAX_STREAM_META_BUF_COUNT ; i++) { + ispif->metainfo_buf_pool[i] =
drivers/media/platform/amd/isp4/isp4_interface.c line 254
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+isp4if_gpu_mem_alloc (ispif, +ISP4IF_META_INFO_BUF_SIZE ); +if (!ispif->metainfo_buf_pool[i]) + goto error_no_memory; + } + +return 0 ; + +error_no_memory: +dev_err (dev,"failed to allocate gpu memory" );
I don't think the error message is necessary, checkpatch usually complains about this.
Quoted 968 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +798
-0+return -ENOMEM ; +} + +static u32 isp4if_compute_check_sum (u8 *buf,u32 buf_size) +{ +u32 checksum =0 ; +u8 *surplus_ptr; +u32 *buffer; +u32 i; + + buffer = (u32 *)buf; +for (i =0 ; i < buf_size /sizeof (u32); i++) + checksum += buffer[i]; + + surplus_ptr = (u8 *)&buffer[i]; +/* add surplus data crc checksum */ +for (i =0 ; i < buf_size %sizeof (u32); i++) + checksum += surplus_ptr[i]; + +return checksum; +} + +void isp4if_clear_cmdq (struct isp4_interface *ispif) +{ +struct isp4if_cmd_element *buf_node =NULL ; +struct isp4if_cmd_element *tmp_node =NULL ; + +guard (mutex)(&ispif->cmdq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->cmdq, list) { +list_del (&buf_node->list); +kfree (buf_node); + } +} + +static bool isp4if_is_cmdq_rb_full (struct isp4_interface *ispif, +enum isp4if_stream_id cmd_buf_idx) +{ +struct isp4if_rb_config *rb_config; +u32 rd_ptr, wr_ptr; +u32 new_wr_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_cmd_rb_config[cmd_buf_idx]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + len = rb_config->val_size; + + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); + + new_wr_ptr = wr_ptr +sizeof (struct isp4fw_cmd ); + +if (wr_ptr >= rd_ptr) { +if (new_wr_ptr < len) { +return false; + }else if (new_wr_ptr == len) { +if (rd_ptr ==0 ) +return true; + +return false; + } + + new_wr_ptr -= len; +if (new_wr_ptr < rd_ptr) +return false; + +return true; + } + +if (new_wr_ptr < rd_ptr) +return false; + +return true; +} + +static struct isp4if_cmd_element * +isp4if_append_cmd_2_cmdq (struct isp4_interface *ispif, +struct isp4if_cmd_element *cmd_ele) +{ +struct isp4if_cmd_element *copy_command =NULL ; + + copy_command =kmalloc (sizeof (*copy_command),GFP_KERNEL ); +if (!copy_command) +return NULL ; + +memcpy (copy_command, cmd_ele,sizeof (*copy_command)); + +guard (mutex)(&ispif->cmdq_mutex); + +list_add_tail (©_command->list, &ispif->cmdq); + +return copy_command; +} + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, +u32 seq_num, +u32 cmd_id) +{ +struct isp4if_cmd_element *buf_node =NULL ; +struct isp4if_cmd_element *tmp_node =NULL ; + +guard (mutex)(&ispif->cmdq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->cmdq, list) { +if (buf_node->seq_num == seq_num && + buf_node->cmd_id == cmd_id) { +list_del (&buf_node->list); +return buf_node; + } + } + +return NULL ; +} + +static int isp4if_insert_isp_fw_cmd (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +struct isp4fw_cmd *cmd) +{ +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +u64 mem_addr; +u64 mem_sys; +u32 wr_ptr; +u32 rd_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_cmd_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = (u64 )rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + +if (isp4if_is_cmdq_rb_full (ispif, stream)) { +dev_err (dev,"fail no cmdslot (%d)\n" , stream); +return -EINVAL ; + } + + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + +if (rd_ptr > len) { +dev_err (dev,"fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + +if (wr_ptr > len) { +dev_err (dev,"fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n" , + stream, wr_ptr, len, rd_ptr); +return -EINVAL ; + } + +if (wr_ptr < rd_ptr) { + mem_addr += wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd,sizeof (struct isp4fw_cmd )); + }else { +if ((len - wr_ptr) >= (sizeof (struct isp4fw_cmd ))) { + mem_addr += wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd,sizeof (struct isp4fw_cmd )); + }else { +u32 size; +u8 *src; + + src = (u8 *)cmd; + size = len - wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), src, size); + + src += size; + size =sizeof (struct isp4fw_cmd ) - size; +memcpy ((u8 *)(mem_sys), src, size); + } + } + + wr_ptr +=sizeof (struct isp4fw_cmd ); +if (wr_ptr >= len) + wr_ptr -= len; + +isp4hw_wreg (ispif->mmio, wreg, wr_ptr); + +return 0 ; +} + +static inline enum isp4if_stream_id isp4if_get_fw_stream (u32 cmd_id) +{ +return ISP4IF_STREAM_ID_1 ; +} + +static int isp4if_send_fw_cmd (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +wait_queue_head_t *wq, +u32 *wq_cond, +u32 *seq) +{ +enum isp4if_stream_id stream =isp4if_get_fw_stream (cmd_id); +struct isp4if_cmd_element command_element = {0 }; +struct isp4if_gpu_mem_info *gpu_mem =NULL ; +struct isp4if_cmd_element *cmd_ele =NULL ; +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +struct isp4fw_cmd cmd = {0 }; +u64 package_base =0 ; +u32 sleep_count; +u32 seq_num; +u32 rreg; +u32 wreg; +int ret; + +if (package_size >sizeof (cmd.cmd_param)) { +dev_err (dev,"fail pkgsize(%u)>%lu cmd:0x%x,stream %d\n" , + package_size,sizeof (cmd.cmd_param), cmd_id, stream); +return -EINVAL ; + } + + sleep_count =0 ; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + +guard (mutex)(&ispif->isp4if_mutex); + +while (1 ) { +if (isp4if_is_cmdq_rb_full (ispif, stream)) { +u32 rd_ptr, wr_ptr; + +if (sleep_count <ISP4IF_MAX_SLEEP_COUNT ) { +msleep (ISP4IF_MAX_SLEEP_TIME ); + sleep_count++; +continue ; + } + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); +dev_err (dev,"fail to get cmdq slot,stream (%d), rd %u, wr %u\n" , + stream, rd_ptr, wr_ptr); +return -ETIMEDOUT ; + } +break ; + } + + cmd.cmd_id = cmd_id; +switch (stream) { +case ISP4IF_STREAM_ID_GLOBAL : + cmd.cmd_stream_id = (u16 )STREAM_ID_INVALID ; +break ; +case ISP4IF_STREAM_ID_1 : + cmd.cmd_stream_id =STREAM_ID_1 ; +break ; +default : +dev_err (dev,"fail bad stream id %d\n" , stream); +return -EINVAL ; + } + +if (package && package_size) +memcpy (cmd.cmd_param, package, package_size); + + seq_num = ispif->host2fw_seq_num++; + cmd.cmd_seq_num = seq_num; + cmd.cmd_check_sum = +isp4if_compute_check_sum ((u8 *)&cmd,sizeof (cmd) -4 ); + +if (seq) + *seq = seq_num; + command_element.seq_num = seq_num; + command_element.cmd_id = cmd_id; + command_element.mc_addr = package_base; + command_element.wq = wq; + command_element.wq_cond = wq_cond; + command_element.gpu_pkg = gpu_mem; + command_element.stream = stream; +/* only append the fw cmd to queue when its response needs to be +* waited for, currently there are only two such commands, +* disable channel and stop stream which are only sent after close +* camera +*/ +if (wq && wq_cond) { + cmd_ele =isp4if_append_cmd_2_cmdq (ispif, &command_element); +if (!cmd_ele) { +dev_err (dev,"fail for isp_append_cmd_2_cmdq\n" ); +return -ENOMEM ; + } + } + + ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); +if (ret) { +dev_err (dev,"fail for insert_isp_fw_cmd camId (0x%08x)\n" , + cmd_id); +if (cmd_ele) { +isp4if_rm_cmd_from_cmdq (ispif, cmd_ele->seq_num, + cmd_ele->cmd_id); +kfree (cmd_ele); + } + } + +return ret; +} + +static int isp4if_send_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_info *buf_info) +{ +struct isp4fw_cmd_send_buffer cmd; + +memset (&cmd,0 ,sizeof (cmd)); + cmd.buffer_type =BUFFER_TYPE_PREVIEW ; + cmd.buffer.vmid_space.bit.vmid =0 ; + cmd.buffer.vmid_space.bit.space =ADDR_SPACE_TYPE_GPU_VA ; +isp4if_split_addr64 (buf_info->planes[0 ].mc_addr, + &cmd.buffer.buf_base_a_lo, + &cmd.buffer.buf_base_a_hi); + cmd.buffer.buf_size_a = buf_info->planes[0 ].len; + +isp4if_split_addr64 (buf_info->planes[1 ].mc_addr, + &cmd.buffer.buf_base_b_lo, + &cmd.buffer.buf_base_b_hi); + cmd.buffer.buf_size_b = buf_info->planes[1 ].len; + +isp4if_split_addr64 (buf_info->planes[2 ].mc_addr, + &cmd.buffer.buf_base_c_lo, + &cmd.buffer.buf_base_c_hi); + cmd.buffer.buf_size_c = buf_info->planes[2 ].len; + +return isp4if_send_fw_cmd (ispif,CMD_ID_SEND_BUFFER , &cmd, +sizeof (cmd),NULL ,NULL ,NULL ); +} + +static void isp4if_init_rb_config (struct isp4_interface *ispif, +struct isp4if_rb_config *rb_config) +{ +u32 lo; +u32 hi; + +isp4if_split_addr64 (rb_config->base_mc_addr, &lo, &hi); + +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_rptr,0x0 ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_wptr,0x0 ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_base_lo, lo); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_base_hi, hi); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_size, rb_config->val_size); +} + +static int isp4if_fw_init (struct isp4_interface *ispif) +{ +struct isp4if_rb_config *rb_config; +u32 offset; +int i; + +/* initialize CMD_RB streams */ +for (i =0 ; i <ISP4IF_STREAM_ID_MAX ; i++) { + rb_config = (isp4if_cmd_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->cmd_rb_base_index); + + rb_config->val_size =ISP4IF_FW_CMD_BUF_SIZE ; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + +isp4if_init_rb_config (ispif, rb_config); + } + +/* initialize RESP_RB streams */ +for (i =0 ; i <ISP4IF_STREAM_ID_MAX ; i++) { + rb_config = (isp4if_resp_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->resp_rb_base_index); + + rb_config->val_size =ISP4IF_FW_CMD_BUF_SIZE ; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + +isp4if_init_rb_config (ispif, rb_config); + } + +/* initialize LOG_RB stream */ + rb_config = &isp4if_log_rb_config; + rb_config->val_size =ISP4IF_FW_LOG_RINGBUF_SIZE ; + rb_config->base_mc_addr = ispif->fw_log_buf->gpu_mc_addr; + rb_config->base_sys_addr = ispif->fw_log_buf->sys_addr; + +isp4if_init_rb_config (ispif, rb_config); + +return 0 ; +} + +static int isp4if_wait_fw_ready (struct isp4_interface *ispif, +u32 isp_status_addr) +{ +struct device *dev = ispif->dev; +u32 fw_ready_timeout; +u32 timeout_ms =100 ; +u32 interval_ms =1 ; +u32 timeout =0 ; +u32 reg_val; + + fw_ready_timeout = timeout_ms / interval_ms; + +/* wait for FW initialize done! */ +while (timeout < fw_ready_timeout) { + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), + isp_status_addr); +if (reg_val &ISP_STATUS__CCPU_REPORT_MASK ) +return 0 ; + +msleep (interval_ms); + timeout++; + } + +dev_err (dev,"ISP CCPU FW boot failed\n" ); + +return -ETIME ; +} + +static void isp4if_enable_ccpu (struct isp4_interface *ispif) +{ +u32 reg_val; + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET ); + reg_val &= (~ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET , reg_val); + +usleep_range (100 ,150 ); + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL ); + reg_val &= (~ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL , reg_val); +} + +static void isp4if_disable_ccpu (struct isp4_interface *ispif) +{ +u32 reg_val; + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL ); + reg_val |=ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK ; +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL , reg_val); + +usleep_range (100 ,150 ); + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET ); + reg_val |=ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK ; +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET , reg_val); +} + +static int isp4if_fw_boot (struct isp4_interface *ispif) +{ +struct device *dev = ispif->dev; + +if (ispif->status !=ISP4IF_STATUS_PWR_ON ) { +dev_err (dev,"invalid isp power status %d\n" , ispif->status); +return -EINVAL ; + } + +isp4if_disable_ccpu (ispif); + +isp4if_fw_init (ispif); + +/* clear ccpu status */ +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_STATUS ,0x0 ); + +isp4if_enable_ccpu (ispif); + +if (isp4if_wait_fw_ready (ispif,ISP_STATUS )) { +isp4if_disable_ccpu (ispif); +return -EINVAL ; + } + +/* enable interrupts */ +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SYS_INT0_EN , +ISP4IF_FW_RESP_RB_IRQ_EN_MASK ); + + ispif->status =ISP4IF_STATUS_FW_RUNNING ; + +dev_dbg (dev,"ISP CCPU FW boot success\n" ); + +return 0 ; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +void *resp) +{ +struct isp4fw_resp *response = resp; +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +u32 rd_ptr_dbg; +u32 wr_ptr_dbg; +void *mem_sys; +u64 mem_addr; +u32 checksum; +u32 rd_ptr; +u32 wr_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + + rd_ptr =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), rreg); + wr_ptr =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), wreg); + rd_ptr_dbg = rd_ptr; + wr_ptr_dbg = wr_ptr; + +if (rd_ptr > len) { +dev_err (dev,"fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + +if (wr_ptr > len) { +dev_err (dev,"fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n" , + stream, wr_ptr, len, rd_ptr); +return -EINVAL ; + } + +if (rd_ptr < wr_ptr) { +if ((wr_ptr - rd_ptr) >= (sizeof (struct isp4fw_resp ))) { +memcpy ((u8 *)response, (u8 *)mem_sys + rd_ptr, +sizeof (struct isp4fw_resp )); + + rd_ptr +=sizeof (struct isp4fw_resp ); +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { +dev_err (dev,"(%u),rd %u(should<=%u),wr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + + }else { +dev_err (dev,"sth wrong with wptr and rptr\n" ); +return -EINVAL ; + } + }else if (rd_ptr > wr_ptr) { +u32 size; +u8 *dst; + + dst = (u8 *)response; + + size = len - rd_ptr; +if (size >sizeof (struct isp4fw_resp )) { + mem_addr += rd_ptr; +memcpy ((u8 *)response, + (u8 *)(mem_sys) + rd_ptr, +sizeof (struct isp4fw_resp )); + rd_ptr +=sizeof (struct isp4fw_resp ); +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { +dev_err (dev,"(%u),rd %u(should<=%u),wr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + + }else { +if ((size + wr_ptr) < (sizeof (struct isp4fw_resp ))) { +dev_err (dev,"sth wrong with wptr and rptr1\n" ); +return -EINVAL ; + } + +memcpy (dst, (u8 *)(mem_sys) + rd_ptr, size); + + dst += size; + size =sizeof (struct isp4fw_resp ) - size; +if (size) +memcpy (dst, (u8 *)(mem_sys), size); + rd_ptr = size; +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { +dev_err (dev,"(%u),rd %u(should<=%u),wr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + } + }else { +return -ETIME ; + } + + checksum =isp4if_compute_check_sum ((u8 *)response, + (sizeof (struct isp4fw_resp ) -4 )); + +if (checksum != response->resp_check_sum) { +dev_err (dev,"resp checksum 0x%x,should 0x%x,rptr %u,wptr %u\n" , + checksum, response->resp_check_sum, + rd_ptr_dbg, wr_ptr_dbg); + +dev_err (dev,"(%u), seqNo %u, resp_id (0x%x)\n" , + stream, + response->resp_seq_num, + response->resp_id); + +return -EINVAL ; + } + +return 0 ; +} + +int isp4if_send_command (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size) +{ +return isp4if_send_fw_cmd (ispif, + cmd_id, package, + package_size,NULL ,NULL ,NULL ); +} + +int isp4if_send_command_sync (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +u32 timeout) +{ +struct device *dev = ispif->dev; +DECLARE_WAIT_QUEUE_HEAD (cmd_wq); +u32 wq_cond =0 ; +int ret; +u32 seq; + + ret =isp4if_send_fw_cmd (ispif, + cmd_id, package, + package_size, &cmd_wq, &wq_cond, &seq); + +if (ret) { +dev_err (dev,"send fw cmd fail %d\n" , ret); +return ret; + } + + ret =wait_event_timeout (cmd_wq, wq_cond !=0 , +msecs_to_jiffies (timeout)); + +/* timeout occurred */ +if (ret ==0 ) { +struct isp4if_cmd_element *ele; + + ele =isp4if_rm_cmd_from_cmdq (ispif, seq, cmd_id); +kfree (ele); +return -ETIMEDOUT ; + } + +return 0 ; +} + +void isp4if_clear_bufq (struct isp4_interface *ispif) +{ +struct isp4if_img_buf_node *buf_node =NULL ; +struct isp4if_img_buf_node *tmp_node =NULL ; + +guard (mutex)(&ispif->bufq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->bufq, + node) { +list_del (&buf_node->node); +kfree (buf_node); + } +} + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node) +{ +kfree (buf_node); +} + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info) +{ +struct isp4if_img_buf_node *node =NULL ; + + node =kmalloc (sizeof (*node),GFP_KERNEL ); +if (node) + node->buf_info = *buf_info; + +return node; +}; + +struct isp4if_img_buf_node * +isp4if_dequeue_buffer (struct isp4_interface *ispif) +{ +struct isp4if_img_buf_node *buf_node =NULL ; + +guard (mutex)(&ispif->bufq_mutex); + + buf_node =list_first_entry_or_null (&ispif->bufq, +typeof (*buf_node), + node); +if (buf_node) +list_del (&buf_node->node); + +return buf_node; +} + +int isp4if_queue_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_node *buf_node) +{ +int ret; + + ret =isp4if_send_buffer (ispif, &buf_node->buf_info); +if (ret) +return ret; + +guard (mutex)(&ispif->bufq_mutex); + +list_add_tail (&buf_node->node, &ispif->bufq); + +return 0 ; +} + +int isp4if_stop (struct isp4_interface *ispif) +{ +isp4if_disable_ccpu (ispif); + +isp4if_dealloc_fw_gpumem (ispif); + +return 0 ; +} + +int isp4if_start (struct isp4_interface *ispif) +{ +int ret; + + ret =isp4if_alloc_fw_gpumem (ispif); +if (ret) + goto failed_gpumem_alloc; + + ret =isp4if_fw_boot (ispif); +if (ret) + goto failed_fw_boot; + +return 0 ; + +failed_gpumem_alloc: +return -ENOMEM ; + +failed_fw_boot: +isp4if_dealloc_fw_gpumem (ispif); +return ret; +} + +int isp4if_deinit (struct isp4_interface *ispif) +{ +isp4if_clear_cmdq (ispif); + +isp4if_clear_bufq (ispif); + +mutex_destroy (&ispif->cmdq_mutex); +mutex_destroy (&ispif->bufq_mutex); +mutex_destroy (&ispif->isp4if_mutex); + +return 0 ; +} + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, +void *amdgpu_dev,void __iomem *isp_mmip) +{ + ispif->dev = dev; + ispif->adev = amdgpu_dev; + ispif->mmio = isp_mmip; + + ispif->cmd_rb_base_index =0 ; + ispif->resp_rb_base_index =ISP4IF_RESP_CHAN_TO_RB_OFFSET -1 ; + ispif->aligned_rb_chunk_size =ISP4IF_RB_PMBMAP_MEM_CHUNK &0xffffffc0 ; + +mutex_init (&ispif->cmdq_mutex);/* used for cmdq access */ +mutex_init (&ispif->bufq_mutex);/* used for bufq access */ +mutex_init (&ispif->isp4if_mutex);/* used for commands sent to ispfw */ + +INIT_LIST_HEAD (&ispif->cmdq); +INIT_LIST_HEAD (&ispif->bufq); + +return 0 ; +}drivers/media/platform/amd/isp4/isp4_interface.h new file +164
-0@@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_INTERFACE_ +#define _ISP4_INTERFACE_ + +#define ISP4IF_RB_MAX (25) +#define ISP4IF_RESP_CHAN_TO_RB_OFFSET (9) +#define ISP4IF_RB_PMBMAP_MEM_SIZE (16 * 1024 * 1024 - 1) +#define ISP4IF_RB_PMBMAP_MEM_CHUNK (ISP4IF_RB_PMBMAP_MEM_SIZE \ + / (ISP4IF_RB_MAX - 1)) +#define ISP4IF_ISP_MC_ADDR_ALIGN (1024 * 32) +#define ISP4IF_HOST2FW_COMMAND_SIZE (sizeof(struct isp4fw_cmd)) +#define ISP4IF_FW_CMD_BUF_COUNT 4 +#define ISP4IF_FW_RESP_BUF_COUNT 4 +#define ISP4IF_MAX_NUM_HOST2FW_COMMAND (40) +#define ISP4IF_FW_CMD_BUF_SIZE (ISP4IF_MAX_NUM_HOST2FW_COMMAND \ + * ISP4IF_HOST2FW_COMMAND_SIZE) +#define ISP4IF_MAX_SLEEP_COUNT (10) +#define ISP4IF_MAX_SLEEP_TIME (33) + +#define ISP4IF_META_INFO_BUF_SIZE ALIGN(sizeof(struct isp4fw_meta_info), 0x8000) +#define ISP4IF_MAX_STREAM_META_BUF_COUNT 6 + +#define ISP4IF_FW_LOG_RINGBUF_SIZE (2 * 1024 * 1024) + +#define ISP4IF_MAX_CMD_RESPONSE_BUF_SIZE (4 * 1024) + +#define GET_ISP4IF_REG_BASE (ispif) (((ispif))->mmio) + +enum isp4if_stream_id { +ISP4IF_STREAM_ID_GLOBAL =0 , +ISP4IF_STREAM_ID_1 =1 , +ISP4IF_STREAM_ID_MAX =4 +}; + +enum isp4if_status { +ISP4IF_STATUS_PWR_OFF , +ISP4IF_STATUS_PWR_ON , +ISP4IF_STATUS_FW_RUNNING , +ISP4IF_FSM_STATUS_MAX +}; + +struct isp4if_gpu_mem_info { +u32 mem_domain; +u64 mem_size; +u32 mem_align; +u64 gpu_mc_addr; +void *sys_addr; +void *mem_handle; +}; + +struct isp4if_img_buf_info { +struct { +void *sys_addr; +u64 mc_addr; +u32 len; + } planes[3 ]; +}; + +struct isp4if_img_buf_node { +struct list_head node; +struct isp4if_img_buf_info buf_info; +}; + +struct isp4if_cmd_element { +struct list_head list; +u32 seq_num; +u32 cmd_id; +enum isp4if_stream_id stream; +u64 mc_addr; +wait_queue_head_t *wq; +u32 *wq_cond; +struct isp4if_gpu_mem_info *gpu_pkg; +}; + +struct isp4_interface { +struct amdgpu_device *adev; + +struct device *dev; +void __iomem *mmio; + +struct mutex cmdq_mutex;/* used for cmdq access */ +struct mutex bufq_mutex;/* used for bufq access */ +struct mutex isp4if_mutex;/* used to send fw cmd and read fw log */ + +struct list_head cmdq;/* commands sent to fw */ +struct list_head bufq;/* buffers sent to fw */ + +enum isp4if_status status; +u32 host2fw_seq_num; + +/* FW ring buffer configs */ +u32 cmd_rb_base_index; +u32 resp_rb_base_index; +u32 aligned_rb_chunk_size; + +/* ISP fw buffers */ +struct isp4if_gpu_mem_info *fw_log_buf; +struct isp4if_gpu_mem_info *fw_cmd_resp_buf; +struct isp4if_gpu_mem_info *fw_mem_pool; +struct isp4if_gpu_mem_info * + metainfo_buf_pool[ISP4IF_MAX_STREAM_META_BUF_COUNT ]; +}; + +static inline void isp4if_split_addr64 (u64 addr,u32 *lo,u32 *hi) +{ +if (lo) + *lo = (u32)(addr &0xffffffff ); +if (hi) + *hi = (u32)(addr >>32 ); +} + +static inline u64 isp4if_join_addr64 (u32 lo,u32 hi) +{ +return (((u64 )hi) <<32 ) | (u64 )lo; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +void *response); + +int isp4if_send_command (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size); + +int isp4if_send_command_sync (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +u32 timeout); + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, +u32 seq_num, +u32 cmd_id); + +void isp4if_clear_cmdq (struct isp4_interface *ispif); + +void isp4if_clear_bufq (struct isp4_interface *ispif); + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node); + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info); + +struct isp4if_img_buf_node *isp4if_dequeue_buffer (struct isp4_interface *ispif); + +int isp4if_queue_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_node *buf_node); + +int isp4if_stop (struct isp4_interface *ispif); + +int isp4if_start (struct isp4_interface *ispif); + +int isp4if_deinit (struct isp4_interface *ispif); + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, +void *amdgpu_dev,void __iomem *isp_mmip); + +#endif
Du, Bin
maintainerRe: [PATCH v2 4/8] media: platform: amd: Add isp4 fw and hw interface
Thanks Mario, will fix in the next version and pls see some of my comments
Quoted 55 lines · Mario Limonciello
(quoted diff) +2
-0+Alex +amd-gfxQuoted 41 lines · Bin Du
ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>---
drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 +++4 files changed, 1546 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.hdrivers/media/platform/amd/isp4/Makefile +0
-0@@ -5,10 +5,22 @@obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \
isp4_phy.o \
+ isp4_interface.o \
isp4_hw.o \
ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/Makefile +4
-0+ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drmccflags-y += -I$(srctree)/include
drivers/media/platform/amd/isp4/Makefile line 23
Quoted 7 lines
drivers/media/platform/amd/isp4/Makefile +7
-0+ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dmIMO this feels like a hack and also fragile to be sharing so much across subsystems.
Quoted 1 line
Either there should be a kernel wide
include/header that can be used by both or there should be a helper exported to get just the data that is needed.
Yes, will refine to remove unnecessary ones in the next version, actually isp driver needs to access function amdgpu_bo_create_kernel which is exported by amdgpu and delared in amdgpu_object.h, because amdgpu_object.h also includes other amd gpu header files, so have to add these include path to avoid compilation error. It'll be greate if there is kernel wide include, any suggestion for this?
Quoted 21 lines
Quoted 9 lines
ifneq ($(call cc-option, -mpreferred-stack-boundary=4),)
cc_stack_align:= -mpreferred-stack-boundary=4drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +0
-0drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 9
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +9
-0@@ -0,0 +1,318 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_CMD_RESP_H_ +#define _ISP4_CMD_RESP_H_ + +/* Did you mean this to be kernel doc? If so you need:
Quoted 2 lines
/**
Many thx, will update in the next patch
Quoted 27 lines
Quoted 27 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +27
-0+ * @brief Host and Firmware command & response channel. + * Two types of command/response channel. + * Type Global Command has one command/response channel. + * Type Stream Command has one command/response channel. + *----------- ------------ + *| | --------------------------- | | + *| | ---->| Global Command |----> | | + *| | --------------------------- | | + *| | | | + *| | | | + *| | --------------------------- | | + *| | ---->| Stream Command |----> | | + *| | --------------------------- | | + *| | | | + *| | | | + *| | | | + *| HOST | | Firmware | + *| | | | + *| | | | + *| | -------------------------- | | + *| | <----| Global Response |<---- | | + *| | -------------------------- | | + *| | | | + *| | | | + *| | -------------------------- | | + *| | <----| Stream Response |<---- | | + *| | -------------------------- | |
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 42
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +6
-0+*| | | | +*| | | | +*----------- ------------ +*/ + +/* Same comment about kernel doc
Many thx, will update in the next patch>> + * @brief command ID format
Quoted 26 lines
Quoted 26 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +26
-0+* cmd_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define CMD_TYPE_SHIFT (24) +#define CMD_GROUP_SHIFT (16) +#define CMD_TYPE_STREAM_CTRL ((u32)0x2 << CMD_TYPE_SHIFT) + +#define CMD_GROUP_STREAM_CTRL ((u32)0x1 << CMD_GROUP_SHIFT) +#define CMD_GROUP_STREAM_BUFFER ((u32)0x4 << CMD_GROUP_SHIFT) + +/* Stream Command */ +#define CMD_ID_SET_STREAM_CONFIG \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x1) +#define CMD_ID_SET_OUT_CHAN_PROP \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x3) +#define CMD_ID_ENABLE_OUT_CHAN \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x5) +#define CMD_ID_START_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x7) +#define CMD_ID_STOP_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x8)
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 75
Quoted 6 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +6
-0+ +/* Stream Buffer Command */ +#define CMD_ID_SEND_BUFFER \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_BUFFER | 0x1) + +/* Same comment about kernel doc
Many thx, will update in the next patch>> + * @brief response ID format
Quoted 13 lines
Quoted 13 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +13
-0+* resp_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define RESP_GROUP_SHIFT (16) +#define RESP_GROUP_MASK (0xff << RESP_GROUP_SHIFT) + +#define GET_RESP_GROUP_VALUE (resp_id) \ + (((resp_id) & RESP_GROUP_MASK) >> \
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 96
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +7
-0+ RESP_GROUP_SHIFT) +#define GET_RESP_ID_VALUE (resp_id) ((resp_id) & 0xffff) + +#define RESP_GROUP_GENERAL (0x1 << RESP_GROUP_SHIFT) +#define RESP_GROUP_NOTIFICATION (0x3 << RESP_GROUP_SHIFT) + +/* General Response */ Extra whitespace between words
Many thx, will update in the next patch
Quoted 399 lines
Quoted 386 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +20
-0+#define RESP_ID_CMD_DONE (RESP_GROUP_GENERAL | 0x1) + +/* Notification */ +#define RESP_ID_NOTI_FRAME_DONE (RESP_GROUP_NOTIFICATION | 0x1) + +#define CMD_STATUS_SUCCESS (0) +#define CMD_STATUS_FAIL (1) +#define CMD_STATUS_SKIPPED (2) + +#define ADDR_SPACE_TYPE_GPU_VA 4 + +#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) + +/* +* standard ISP mipicsi=>isp +*/ +#define MIPI0_ISP_PIPELINE_ID 0x5f91 + +enum isp4fw_sensor_id { + SENSOR_ID_ON_MIPI0 = 0, /* Sensor id for ISP input from MIPIport 0 */
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +34
-0+}; + +enum isp4fw_stream_id { + STREAM_ID_INVALID = -1, /* STREAM_ID_INVALID. */ + STREAM_ID_1 = 0, /* STREAM_ID_1. */ + STREAM_ID_2 = 1, /* STREAM_ID_2. */ + STREAM_ID_3 = 2, /* STREAM_ID_3. */ + STREAM_ID_MAXIMUM /* STREAM_ID_MAXIMUM. */ +}; + +enum isp4fw_image_format { + IMAGE_FORMAT_NV12 = 1, /* 4:2:0,semi-planar, 8-bit */ + IMAGE_FORMAT_YUV422INTERLEAVED = 7, /* interleave, 4:2:2, 8-bit */ +}; + +enum isp4fw_pipe_out_ch { + ISP_PIPE_OUT_CH_PREVIEW = 0, +}; + +enum isp4fw_yuv_range { + ISP_YUV_RANGE_FULL = 0, /* YUV value range in 0~255 */ + ISP_YUV_RANGE_NARROW = 1, /* YUV value range in 16~235 */ + ISP_YUV_RANGE_MAX +}; + +enum isp4fw_buffer_type { + BUFFER_TYPE_PREVIEW = 8, + BUFFER_TYPE_META_INFO = 10, + BUFFER_TYPE_MEM_POOL = 15, +}; + +enum isp4fw_buffer_status { + BUFFER_STATUS_INVALID, /* The buffer is INVALID */ + BUFFER_STATUS_SKIPPED, /* The buffer is not filled with imagedata */
+ BUFFER_STATUS_EXIST, /* The buffer is exist and waiting for filled */
+ BUFFER_STATUS_DONE, /* The buffer is filled with image data */ + BUFFER_STATUS_LACK, /* The buffer is unavailable */ + BUFFER_STATUS_DIRTY, /* The buffer is dirty, probably caused by + * LMI leakage
+ */
+ BUFFER_STATUS_MAX /* The bufferSTATUS_MAX*/drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +41
-0+}; + +enum isp4fw_buffer_source { + /* The buffer is from the stream buffer queue */ + BUFFER_SOURCE_STREAM, +}; + +struct isp4fw_error_code { + u32 code1; + u32 code2; + u32 code3; + u32 code4; + u32 code5; +}; + +/* +* Command Structure for FW +*/ + +struct isp4fw_cmd { + u32 cmd_seq_num; + u32 cmd_id; + u32 cmd_param[12]; + u16 cmd_stream_id; + u8 cmd_silent_resp; + u8 reserved; + u32 cmd_check_sum; +}; + +struct isp4fw_resp_cmd_done { + /* The host2fw command seqNum. + * To indicate which command this response refer to. + */ + u32 cmd_seq_num; + /* The host2fw command id for host double check. */ + u32 cmd_id; + /* Indicate the command process status. + * 0 means success. 1 means fail. 2 means skipped + */ + u16 cmd_status; + /* If the cmd_status is 1, that means the command is processedfail, */
+ /* host can check theisp4fw_error_codeto get the detail + * error information
+ */
+ u16isp4fw_error_code;
+ /* The response payload will be in different struct type */ + /* according to different cmd done response. */
+ u8 payload[36];drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +4
-0+}; + +struct isp4fw_resp_param_package { + u32 package_addr_lo; /* The low 32 bit addr of the pkgaddress. */
+ u32 package_addr_hi; /* The high 32 bit addr of the pkg address. */
+ u32 package_size; /* The total pkg size in bytes. */ + u32 package_check_sum; /* The byte sum of the pkg. */drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +84
-0+}; + +struct isp4fw_resp { + u32 resp_seq_num; + u32 resp_id; + union { + struct isp4fw_resp_cmd_done cmd_done; + struct isp4fw_resp_param_package frame_done; + u32 resp_param[12]; + } param; + u8 reserved[4]; + u32 resp_check_sum; +}; + +struct isp4fw_mipi_pipe_path_cfg { + u32 b_enable; + enum isp4fw_sensor_id isp4fw_sensor_id; +}; + +struct isp4fw_isp_pipe_path_cfg { + u32 isp_pipe_id; /* pipe ids for pipeline construction */ +}; + +struct isp4fw_isp_stream_cfg { + /* Isp mipi path */ + struct isp4fw_mipi_pipe_path_cfg mipi_pipe_path_cfg; + /* Isp pipe path */ + struct isp4fw_isp_pipe_path_cfg isp_pipe_path_cfg; + /* enable TNR */ + u32 b_enable_tnr; + /* number of frame rta per-processing, + * set to 0 to use fw default value + */ + u32 rta_frames_per_proc; +}; + +struct isp4fw_image_prop { + enum isp4fw_image_format image_format; /* Image format */ + u32 width; /* Width */ + u32 height; /* Height */ + u32 luma_pitch; /* Luma pitch */ + u32 chroma_pitch; /* Chrom pitch */ + enum isp4fw_yuv_range yuv_range; /* YUV value range */ +}; + +struct isp4fw_buffer { + /* A check num for debug usage, host need to */ + /* set the buf_tags to different number */ + u32 buf_tags; + union { + u32 value; + struct { + u32 space : 16; + u32 vmid : 16; + } bit; + } vmid_space; + u32 buf_base_a_lo; /* Low address of buffer A */ + u32 buf_base_a_hi; /* High address of buffer A */ + u32 buf_size_a; /* Buffer size of buffer A */ + + u32 buf_base_b_lo; /* Low address of buffer B */ + u32 buf_base_b_hi; /* High address of buffer B */ + u32 buf_size_b; /* Buffer size of buffer B */ + + u32 buf_base_c_lo; /* Low address of buffer C */ + u32 buf_base_c_hi; /* High address of buffer C */ + u32 buf_size_c; /* Buffer size of buffer C */ +}; + +struct isp4fw_buffer_meta_info { + u32 enabled; /* enabled flag */ + enum isp4fw_buffer_status status; /* BufferStatus */ + struct isp4fw_error_code err; /* err code */ + enum isp4fw_buffer_source source; /* BufferSource */ + struct isp4fw_image_prop image_prop; /* image_prop */ + struct isp4fw_buffer buffer; /* buffer */ +}; + +struct isp4fw_meta_info { + u32 poc; /* frame id */ + u32 fc_id; /* frame ctl id */ + u32 time_stamp_lo; /* time_stamp_lo */ + u32 time_stamp_hi; /* time_stamp_hi */ + struct isp4fw_buffer_meta_info preview; /* previewBufferMetaInfo */
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +22
-0+}; + +struct isp4fw_cmd_send_buffer { + enum isp4fw_buffer_type buffer_type; /* buffer Type */ + struct isp4fw_buffer buffer; /* buffer info */ +}; + +struct isp4fw_cmd_set_out_ch_prop { + enum isp4fw_pipe_out_ch ch; /* ISP pipe out channel */ + struct isp4fw_image_prop image_prop; /* image property */ +}; + +struct isp4fw_cmd_enable_out_ch { + enum isp4fw_pipe_out_ch ch; /* ISP pipe out channel */ + u32 is_enable; /* If enable channel or not */ +}; + +struct isp4fw_cmd_set_stream_cfg { + struct isp4fw_isp_stream_cfg stream_cfg; /* stream path config */ +}; + +#endif drivers/media/platform/amd/isp4/isp4_interface.c new file +127
-0@@ -0,0 +1,1052 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/mutex.h> + +#include "amdgpu_object.h" + +#include "isp4_fw_cmd_resp.h" +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_interface.h" + +#define ISP4IF_FW_RESP_RB_IRQ_EN_MASK \ + (ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK) + +struct isp4if_rb_config { + const char *name; + u32 index; + u32 reg_rptr; + u32 reg_wptr; + u32 reg_base_lo; + u32 reg_base_hi; + u32 reg_size; + u32 val_size; + u64 base_mc_addr; + void *base_sys_addr; +}; + +/* FW cmd ring buffer configuration */ +static struct isp4if_rb_config + isp4if_cmd_rb_config[ISP4IF_STREAM_ID_MAX] = { + { + .name = "CMD_RB_GBL0", + .index = 3, + .reg_rptr = ISP_RB_RPTR4, + .reg_wptr = ISP_RB_WPTR4, + .reg_base_lo = ISP_RB_BASE_LO4, + .reg_base_hi = ISP_RB_BASE_HI4, + .reg_size = ISP_RB_SIZE4, + }, + { + .name = "CMD_RB_STR1", + .index = 0, + .reg_rptr = ISP_RB_RPTR1, + .reg_wptr = ISP_RB_WPTR1, + .reg_base_lo = ISP_RB_BASE_LO1, + .reg_base_hi = ISP_RB_BASE_HI1, + .reg_size = ISP_RB_SIZE1, + }, + { + .name = "CMD_RB_STR2", + .index = 1, + .reg_rptr = ISP_RB_RPTR2, + .reg_wptr = ISP_RB_WPTR2, + .reg_base_lo = ISP_RB_BASE_LO2, + .reg_base_hi = ISP_RB_BASE_HI2, + .reg_size = ISP_RB_SIZE2, + }, + { + .name = "CMD_RB_STR3", + .index = 2, + .reg_rptr = ISP_RB_RPTR3, + .reg_wptr = ISP_RB_WPTR3, + .reg_base_lo = ISP_RB_BASE_LO3, + .reg_base_hi = ISP_RB_BASE_HI3, + .reg_size = ISP_RB_SIZE3, + }, +}; + +/* FW resp ring buffer configuration */ +static struct isp4if_rb_config + isp4if_resp_rb_config[ISP4IF_STREAM_ID_MAX] = { + { + .name = "RES_RB_GBL0", + .index = 3, + .reg_rptr = ISP_RB_RPTR12, + .reg_wptr = ISP_RB_WPTR12, + .reg_base_lo = ISP_RB_BASE_LO12, + .reg_base_hi = ISP_RB_BASE_HI12, + .reg_size = ISP_RB_SIZE12, + }, + { + .name = "RES_RB_STR1", + .index = 0, + .reg_rptr = ISP_RB_RPTR9, + .reg_wptr = ISP_RB_WPTR9, + .reg_base_lo = ISP_RB_BASE_LO9, + .reg_base_hi = ISP_RB_BASE_HI9, + .reg_size = ISP_RB_SIZE9, + }, + { + .name = "RES_RB_STR2", + .index = 1, + .reg_rptr = ISP_RB_RPTR10, + .reg_wptr = ISP_RB_WPTR10, + .reg_base_lo = ISP_RB_BASE_LO10, + .reg_base_hi = ISP_RB_BASE_HI10, + .reg_size = ISP_RB_SIZE10, + }, + { + .name = "RES_RB_STR3", + .index = 2, + .reg_rptr = ISP_RB_RPTR11, + .reg_wptr = ISP_RB_WPTR11, + .reg_base_lo = ISP_RB_BASE_LO11, + .reg_base_hi = ISP_RB_BASE_HI11, + .reg_size = ISP_RB_SIZE11, + }, +}; + +/* FW log ring buffer configuration */ +static struct isp4if_rb_config isp4if_log_rb_config = { + .name = "LOG_RB", + .index = 0, + .reg_rptr = ISP_LOG_RB_RPTR0, + .reg_wptr = ISP_LOG_RB_WPTR0, + .reg_base_lo = ISP_LOG_RB_BASE_LO0, + .reg_base_hi = ISP_LOG_RB_BASE_HI0, + .reg_size = ISP_LOG_RB_SIZE0, +}; + +static struct isp4if_gpu_mem_info *isp4if_gpu_mem_alloc(struct
isp4_interface
+ *ispif,
+ u32mem_size)drivers/media/platform/amd/isp4/isp4_interface.c new file +21
-0+{ + struct isp4if_gpu_mem_info *mem_info; + struct amdgpu_bo *bo = NULL; + struct amdgpu_device *adev; + struct device *dev; + + void *cpu_ptr; + u64 gpu_addr; + u32 ret; + + dev = ispif->dev; + + if (!mem_size) + return NULL; + + mem_info = kzalloc(sizeof(*mem_info), GFP_KERNEL); + if (!mem_info) + return NULL; + + adev = (struct amdgpu_device *)ispif->adev; + mem_info->mem_size = mem_size;drivers/media/platform/amd/isp4/isp4_interface.c line 160
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ mem_info->mem_align = ISP4IF_ISP_MC_ADDR_ALIGN; + mem_info->mem_domain = AMDGPU_GEM_DOMAIN_GTT; + + ret = amdgpu_bo_create_kernel(adev, + mem_info->mem_size, + mem_info->mem_align, + mem_info->mem_domain, + &bo, + &gpu_addr, + &cpu_ptr);IMO this is begging for an extra helper that has a true exported symbol and kernel-wide header for use rather than hacking around the includes for drm headers.
Quoted 1 line
The kernel-wide header can describe the data types exchanged, so there wouldn't be a need to have all the amdgpu headers included.
Many thanks, will double check. Seems amdgpu_bo_create_kernel is a true exported symbol from amdgpu. If there is kernel-wide header and functions to achieve the same, that'll be great. Any suggestions for this?
Quoted 29 lines
Quoted 29 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +28
-0+ + if (!cpu_ptr || ret) { + dev_err(dev, "gpuvm buffer alloc fail, size %u\n", mem_size); + kfree(mem_info); + return NULL; + } + + mem_info->sys_addr = cpu_ptr; + mem_info->gpu_mc_addr = gpu_addr; + mem_info->mem_handle = (void *)bo; + + return mem_info; +} + +static int isp4if_gpu_mem_free (struct isp4_interface *ispif, + struct isp4if_gpu_mem_info *mem_info) +{ + struct device *dev = ispif->dev; + struct amdgpu_bo *bo; + + if (!mem_info) { + dev_err(dev, "invalid mem_info\n"); + return -EINVAL; + } + + bo = (struct amdgpu_bo *)mem_info->mem_handle; + + amdgpu_bo_free_kernel(&bo, &mem_info->gpu_mc_addr, &mem_info-
Quoted 3 lines
Quoted 1 line
Quoted 1 line
sys_addr);This also I think needs another helper
Many thx, same comments as above>
Quoted 61 lines
Quoted 61 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +41
-0+ + kfree(mem_info); + + return 0; +} + +static int isp4if_dealloc_fw_gpumem (struct isp4_interface *ispif) +{ + int i; + + if (ispif->fw_mem_pool) { + isp4if_gpu_mem_free(ispif, ispif->fw_mem_pool); + ispif->fw_mem_pool = NULL; + } + + if (ispif->fw_cmd_resp_buf) { + isp4if_gpu_mem_free(ispif, ispif->fw_cmd_resp_buf); + ispif->fw_cmd_resp_buf = NULL; + } + + if (ispif->fw_log_buf) { + isp4if_gpu_mem_free(ispif, ispif->fw_log_buf); + ispif->fw_log_buf = NULL; + } + + for (i = 0; i < ISP4IF_MAX_STREAM_META_BUF_COUNT; i++) { + if (ispif->metainfo_buf_pool[i]) { + isp4if_gpu_mem_free(ispif, ispif->metainfo_buf_pool[i]); + ispif->metainfo_buf_pool[i] = NULL; + } + } + + return 0; +} + +static int isp4if_alloc_fw_gpumem (struct isp4_interface *ispif) +{ + struct device *dev = ispif->dev; + int i; + + ispif->fw_mem_pool = isp4if_gpu_mem_alloc(ispif,
FW_MEMORY_POOL_SIZE);
+ if (!ispif->fw_mem_pool)
+ gotoerror_no_memory;drivers/media/platform/amd/isp4/isp4_interface.c new file +17
-0+ + ispif->fw_cmd_resp_buf = + isp4if_gpu_mem_alloc(ispif, ISP4IF_RB_PMBMAP_MEM_SIZE); + if (!ispif->fw_cmd_resp_buf) + goto error_no_memory; + + ispif->fw_log_buf = + isp4if_gpu_mem_alloc(ispif, ISP4IF_FW_LOG_RINGBUF_SIZE); + if (!ispif->fw_log_buf) + goto error_no_memory; + + for (i = 0; i < ISP4IF_MAX_STREAM_META_BUF_COUNT; i++) { + ispif->metainfo_buf_pool[i] = + isp4if_gpu_mem_alloc(ispif, + ISP4IF_META_INFO_BUF_SIZE); + if (!ispif->metainfo_buf_pool[i]) + goto error_no_memory;
Quoted 8 lines
drivers/media/platform/amd/isp4/isp4_interface.c line 254
Quoted 6 lines
+ }
drivers/media/platform/amd/isp4/isp4_interface.c new file +5
-0+ + return 0; + +error_no_memory: + dev_err(dev, "failed to allocate gpu memory");I don't think the error message is necessary, checkpatch usually complains about this.
Many thanks, actually checkpatch doesn't say anything about it. Sure we can remove it if you think it better.
Quoted 975 lines
Quoted 974 lines
+ return
-ENOMEM;drivers/media/platform/amd/isp4/isp4_interface.c new file +246
-0+} + +static u32 isp4if_compute_check_sum (u8 *buf,u32 buf_size) +{ + u32 checksum = 0; + u8 *surplus_ptr; + u32 *buffer; + u32 i; + + buffer = (u32 *)buf; + for (i = 0; i < buf_size / sizeof(u32); i++) + checksum += buffer[i]; + + surplus_ptr = (u8 *)&buffer[i]; + /* add surplus data crc checksum */ + for (i = 0; i < buf_size % sizeof(u32); i++) + checksum += surplus_ptr[i]; + + return checksum; +} + +void isp4if_clear_cmdq (struct isp4_interface *ispif) +{ + struct isp4if_cmd_element *buf_node = NULL; + struct isp4if_cmd_element *tmp_node = NULL; + + guard(mutex)(&ispif->cmdq_mutex); + + list_for_each_entry_safe(buf_node, tmp_node, &ispif->cmdq, list) { + list_del(&buf_node->list); + kfree(buf_node); + } +} + +static bool isp4if_is_cmdq_rb_full (struct isp4_interface *ispif, + enum isp4if_stream_id cmd_buf_idx) +{ + struct isp4if_rb_config *rb_config; + u32 rd_ptr, wr_ptr; + u32 new_wr_ptr; + u32 rreg; + u32 wreg; + u32 len; + + rb_config = &isp4if_cmd_rb_config[cmd_buf_idx]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + len = rb_config->val_size; + + rd_ptr = isp4hw_rreg(ispif->mmio, rreg); + wr_ptr = isp4hw_rreg(ispif->mmio, wreg); + + new_wr_ptr = wr_ptr + sizeof(struct isp4fw_cmd); + + if (wr_ptr >= rd_ptr) { + if (new_wr_ptr < len) { + return false; + } else if (new_wr_ptr == len) { + if (rd_ptr == 0) + return true; + + return false; + } + + new_wr_ptr -= len; + if (new_wr_ptr < rd_ptr) + return false; + + return true; + } + + if (new_wr_ptr < rd_ptr) + return false; + + return true; +} + +static struct isp4if_cmd_element * +isp4if_append_cmd_2_cmdq (struct isp4_interface *ispif, + struct isp4if_cmd_element *cmd_ele) +{ + struct isp4if_cmd_element *copy_command = NULL; + + copy_command = kmalloc(sizeof(*copy_command), GFP_KERNEL); + if (!copy_command) + return NULL; + + memcpy(copy_command, cmd_ele, sizeof(*copy_command)); + + guard(mutex)(&ispif->cmdq_mutex); + + list_add_tail(©_command->list, &ispif->cmdq); + + return copy_command; +} + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, + u32 seq_num, + u32 cmd_id) +{ + struct isp4if_cmd_element *buf_node = NULL; + struct isp4if_cmd_element *tmp_node = NULL; + + guard(mutex)(&ispif->cmdq_mutex); + + list_for_each_entry_safe(buf_node, tmp_node, &ispif->cmdq, list) { + if (buf_node->seq_num == seq_num && + buf_node->cmd_id == cmd_id) { + list_del(&buf_node->list); + return buf_node; + } + } + + return NULL; +} + +static int isp4if_insert_isp_fw_cmd (struct isp4_interface *ispif, + enum isp4if_stream_id stream, + struct isp4fw_cmd *cmd) +{ + struct isp4if_rb_config *rb_config; + struct device *dev = ispif->dev; + u64 mem_addr; + u64 mem_sys; + u32 wr_ptr; + u32 rd_ptr; + u32 rreg; + u32 wreg; + u32 len; + + rb_config = &isp4if_cmd_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = (u64)rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + + if (isp4if_is_cmdq_rb_full(ispif, stream)) { + dev_err(dev, "fail no cmdslot (%d)\n", stream); + return -EINVAL; + } + + wr_ptr = isp4hw_rreg(ispif->mmio, wreg); + rd_ptr = isp4hw_rreg(ispif->mmio, rreg); + + if (rd_ptr > len) { + dev_err(dev, "fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n", + stream, rd_ptr, len, wr_ptr); + return -EINVAL; + } + + if (wr_ptr > len) { + dev_err(dev, "fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n", + stream, wr_ptr, len, rd_ptr); + return -EINVAL; + } + + if (wr_ptr < rd_ptr) { + mem_addr += wr_ptr; + + memcpy((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd, sizeof(struct isp4fw_cmd)); + } else { + if ((len - wr_ptr) >= (sizeof(struct isp4fw_cmd))) { + mem_addr += wr_ptr; + + memcpy((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd, sizeof(struct isp4fw_cmd)); + } else { + u32 size; + u8 *src; + + src = (u8 *)cmd; + size = len - wr_ptr; + + memcpy((u8 *)(mem_sys + wr_ptr), src, size); + + src += size; + size = sizeof(struct isp4fw_cmd) - size; + memcpy((u8 *)(mem_sys), src, size); + } + } + + wr_ptr += sizeof(struct isp4fw_cmd); + if (wr_ptr >= len) + wr_ptr -= len; + + isp4hw_wreg(ispif->mmio, wreg, wr_ptr); + + return 0; +} + +static inline enum isp4if_stream_id isp4if_get_fw_stream (u32 cmd_id) +{ + return ISP4IF_STREAM_ID_1; +} + +static int isp4if_send_fw_cmd (struct isp4_interface *ispif, + u32 cmd_id, + void *package, + u32 package_size, + wait_queue_head_t *wq, + u32 *wq_cond, + u32 *seq) +{ + enum isp4if_stream_id stream = isp4if_get_fw_stream(cmd_id); + struct isp4if_cmd_element command_element = { 0 }; + struct isp4if_gpu_mem_info *gpu_mem = NULL; + struct isp4if_cmd_element *cmd_ele = NULL; + struct isp4if_rb_config *rb_config; + struct device *dev = ispif->dev; + struct isp4fw_cmd cmd = {0}; + u64 package_base = 0; + u32 sleep_count; + u32 seq_num; + u32 rreg; + u32 wreg; + int ret; + + if (package_size > sizeof(cmd.cmd_param)) { + dev_err(dev, "fail pkgsize(%u)>%lu cmd:0x%x,stream %d\n", + package_size, sizeof(cmd.cmd_param), cmd_id, stream); + return -EINVAL; + } + + sleep_count = 0; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + + guard(mutex)(&ispif->isp4if_mutex); + + while (1) { + if (isp4if_is_cmdq_rb_full(ispif, stream)) { + u32 rd_ptr, wr_ptr; + + if (sleep_count < ISP4IF_MAX_SLEEP_COUNT) { + msleep(ISP4IF_MAX_SLEEP_TIME); + sleep_count++; + continue; + } + rd_ptr = isp4hw_rreg(ispif->mmio, rreg); + wr_ptr = isp4hw_rreg(ispif->mmio, wreg); + dev_err(dev, "fail to get cmdq slot,stream (%d), rd %u,wr %u\n",
+ stream,rd_ptr,wr_ptr);
+ return-ETIMEDOUT;
+ }
+ break;
+ }drivers/media/platform/amd/isp4/isp4_interface.c new file +536
-0+ + cmd.cmd_id = cmd_id; + switch (stream) { + case ISP4IF_STREAM_ID_GLOBAL: + cmd.cmd_stream_id = (u16)STREAM_ID_INVALID; + break; + case ISP4IF_STREAM_ID_1: + cmd.cmd_stream_id = STREAM_ID_1; + break; + default: + dev_err(dev, "fail bad stream id %d\n", stream); + return -EINVAL; + } + + if (package && package_size) + memcpy(cmd.cmd_param, package, package_size); + + seq_num = ispif->host2fw_seq_num++; + cmd.cmd_seq_num = seq_num; + cmd.cmd_check_sum = + isp4if_compute_check_sum((u8 *)&cmd, sizeof(cmd) - 4); + + if (seq) + *seq = seq_num; + command_element.seq_num = seq_num; + command_element.cmd_id = cmd_id; + command_element.mc_addr = package_base; + command_element.wq = wq; + command_element.wq_cond = wq_cond; + command_element.gpu_pkg = gpu_mem; + command_element.stream = stream; + /* only append the fw cmd to queue when its response needs to be + * waited for, currently there are only two such commands, + * disable channel and stop stream which are only sent after close + * camera + */ + if (wq && wq_cond) { + cmd_ele = isp4if_append_cmd_2_cmdq(ispif, &command_element); + if (!cmd_ele) { + dev_err(dev, "fail for isp_append_cmd_2_cmdq\n"); + return -ENOMEM; + } + } + + ret = isp4if_insert_isp_fw_cmd(ispif, stream, &cmd); + if (ret) { + dev_err(dev, "fail for insert_isp_fw_cmd camId (0x%08x)\n", + cmd_id); + if (cmd_ele) { + isp4if_rm_cmd_from_cmdq(ispif, cmd_ele->seq_num, + cmd_ele->cmd_id); + kfree(cmd_ele); + } + } + + return ret; +} + +static int isp4if_send_buffer (struct isp4_interface *ispif, + struct isp4if_img_buf_info *buf_info) +{ + struct isp4fw_cmd_send_buffer cmd; + + memset(&cmd, 0, sizeof(cmd)); + cmd.buffer_type = BUFFER_TYPE_PREVIEW; + cmd.buffer.vmid_space.bit.vmid = 0; + cmd.buffer.vmid_space.bit.space = ADDR_SPACE_TYPE_GPU_VA; + isp4if_split_addr64(buf_info->planes[0].mc_addr, + &cmd.buffer.buf_base_a_lo, + &cmd.buffer.buf_base_a_hi); + cmd.buffer.buf_size_a = buf_info->planes[0].len; + + isp4if_split_addr64(buf_info->planes[1].mc_addr, + &cmd.buffer.buf_base_b_lo, + &cmd.buffer.buf_base_b_hi); + cmd.buffer.buf_size_b = buf_info->planes[1].len; + + isp4if_split_addr64(buf_info->planes[2].mc_addr, + &cmd.buffer.buf_base_c_lo, + &cmd.buffer.buf_base_c_hi); + cmd.buffer.buf_size_c = buf_info->planes[2].len; + + return isp4if_send_fw_cmd(ispif, CMD_ID_SEND_BUFFER, &cmd, + sizeof(cmd), NULL, NULL, NULL); +} + +static void isp4if_init_rb_config (struct isp4_interface *ispif, + struct isp4if_rb_config *rb_config) +{ + u32 lo; + u32 hi; + + isp4if_split_addr64(rb_config->base_mc_addr, &lo, &hi); + + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rb_config->reg_rptr, 0x0); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rb_config->reg_wptr, 0x0); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rb_config->reg_base_lo, lo); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rb_config->reg_base_hi, hi); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rb_config->reg_size, rb_config->val_size); +} + +static int isp4if_fw_init (struct isp4_interface *ispif) +{ + struct isp4if_rb_config *rb_config; + u32 offset; + int i; + + /* initialize CMD_RB streams */ + for (i = 0; i < ISP4IF_STREAM_ID_MAX; i++) { + rb_config = (isp4if_cmd_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->cmd_rb_base_index); + + rb_config->val_size = ISP4IF_FW_CMD_BUF_SIZE; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + + isp4if_init_rb_config(ispif, rb_config); + } + + /* initialize RESP_RB streams */ + for (i = 0; i < ISP4IF_STREAM_ID_MAX; i++) { + rb_config = (isp4if_resp_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->resp_rb_base_index); + + rb_config->val_size = ISP4IF_FW_CMD_BUF_SIZE; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + + isp4if_init_rb_config(ispif, rb_config); + } + + /* initialize LOG_RB stream */ + rb_config = &isp4if_log_rb_config; + rb_config->val_size = ISP4IF_FW_LOG_RINGBUF_SIZE; + rb_config->base_mc_addr = ispif->fw_log_buf->gpu_mc_addr; + rb_config->base_sys_addr = ispif->fw_log_buf->sys_addr; + + isp4if_init_rb_config(ispif, rb_config); + + return 0; +} + +static int isp4if_wait_fw_ready (struct isp4_interface *ispif, + u32 isp_status_addr) +{ + struct device *dev = ispif->dev; + u32 fw_ready_timeout; + u32 timeout_ms = 100; + u32 interval_ms = 1; + u32 timeout = 0; + u32 reg_val; + + fw_ready_timeout = timeout_ms / interval_ms; + + /* wait for FW initialize done! */ + while (timeout < fw_ready_timeout) { + reg_val = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), + isp_status_addr); + if (reg_val & ISP_STATUS__CCPU_REPORT_MASK) + return 0; + + msleep(interval_ms); + timeout++; + } + + dev_err(dev, "ISP CCPU FW boot failed\n"); + + return -ETIME; +} + +static void isp4if_enable_ccpu (struct isp4_interface *ispif) +{ + u32 reg_val; + + reg_val = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), ISP_SOFT_RESET); + reg_val &= (~ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_SOFT_RESET, reg_val); + + usleep_range(100, 150); + + reg_val = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), ISP_CCPU_CNTL); + reg_val &= (~ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK); + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_CCPU_CNTL, reg_val); +} + +static void isp4if_disable_ccpu (struct isp4_interface *ispif) +{ + u32 reg_val; + + reg_val = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), ISP_CCPU_CNTL); + reg_val |= ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK; + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_CCPU_CNTL, reg_val); + + usleep_range(100, 150); + + reg_val = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), ISP_SOFT_RESET); + reg_val |= ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK; + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_SOFT_RESET, reg_val); +} + +static int isp4if_fw_boot (struct isp4_interface *ispif) +{ + struct device *dev = ispif->dev; + + if (ispif->status != ISP4IF_STATUS_PWR_ON) { + dev_err(dev, "invalid isp power status %d\n", ispif->status); + return -EINVAL; + } + + isp4if_disable_ccpu(ispif); + + isp4if_fw_init(ispif); + + /* clear ccpu status */ + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_STATUS, 0x0); + + isp4if_enable_ccpu(ispif); + + if (isp4if_wait_fw_ready(ispif, ISP_STATUS)) { + isp4if_disable_ccpu(ispif); + return -EINVAL; + } + + /* enable interrupts */ + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), ISP_SYS_INT0_EN, + ISP4IF_FW_RESP_RB_IRQ_EN_MASK); + + ispif->status = ISP4IF_STATUS_FW_RUNNING; + + dev_dbg(dev, "ISP CCPU FW boot success\n"); + + return 0; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, + enum isp4if_stream_id stream, + void *resp) +{ + struct isp4fw_resp *response = resp; + struct isp4if_rb_config *rb_config; + struct device *dev = ispif->dev; + u32 rd_ptr_dbg; + u32 wr_ptr_dbg; + void *mem_sys; + u64 mem_addr; + u32 checksum; + u32 rd_ptr; + u32 wr_ptr; + u32 rreg; + u32 wreg; + u32 len; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + + rd_ptr = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), rreg); + wr_ptr = isp4hw_rreg(GET_ISP4IF_REG_BASE(ispif), wreg); + rd_ptr_dbg = rd_ptr; + wr_ptr_dbg = wr_ptr; + + if (rd_ptr > len) { + dev_err(dev, "fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n", + stream, rd_ptr, len, wr_ptr); + return -EINVAL; + } + + if (wr_ptr > len) { + dev_err(dev, "fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n", + stream, wr_ptr, len, rd_ptr); + return -EINVAL; + } + + if (rd_ptr < wr_ptr) { + if ((wr_ptr - rd_ptr) >= (sizeof(struct isp4fw_resp))) { + memcpy((u8 *)response, (u8 *)mem_sys + rd_ptr, + sizeof(struct isp4fw_resp)); + + rd_ptr += sizeof(struct isp4fw_resp); + if (rd_ptr < len) { + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rreg, rd_ptr); + } else { + dev_err(dev, "(%u),rd %u(should<=%u),wr %u\n", + stream, rd_ptr, len, wr_ptr); + return -EINVAL; + } + + } else { + dev_err(dev, "sth wrong with wptr and rptr\n"); + return -EINVAL; + } + } else if (rd_ptr > wr_ptr) { + u32 size; + u8 *dst; + + dst = (u8 *)response; + + size = len - rd_ptr; + if (size > sizeof(struct isp4fw_resp)) { + mem_addr += rd_ptr; + memcpy((u8 *)response, + (u8 *)(mem_sys) + rd_ptr, + sizeof(struct isp4fw_resp)); + rd_ptr += sizeof(struct isp4fw_resp); + if (rd_ptr < len) { + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rreg, rd_ptr); + } else { + dev_err(dev, "(%u),rd %u(should<=%u),wr %u\n", + stream, rd_ptr, len, wr_ptr); + return -EINVAL; + } + + } else { + if ((size + wr_ptr) < (sizeof(struct isp4fw_resp))) { + dev_err(dev, "sth wrong with wptr and rptr1\n"); + return -EINVAL; + } + + memcpy(dst, (u8 *)(mem_sys) + rd_ptr, size); + + dst += size; + size = sizeof(struct isp4fw_resp) - size; + if (size) + memcpy(dst, (u8 *)(mem_sys), size); + rd_ptr = size; + if (rd_ptr < len) { + isp4hw_wreg(GET_ISP4IF_REG_BASE(ispif), + rreg, rd_ptr); + } else { + dev_err(dev, "(%u),rd %u(should<=%u),wr %u\n", + stream, rd_ptr, len, wr_ptr); + return -EINVAL; + } + } + } else { + return -ETIME; + } + + checksum = isp4if_compute_check_sum((u8 *)response, + (sizeof(struct isp4fw_resp) - 4)); + + if (checksum != response->resp_check_sum) { + dev_err(dev, "resp checksum 0x%x,should 0x%x,rptr %u,wptr %u\n", + checksum, response->resp_check_sum, + rd_ptr_dbg, wr_ptr_dbg); + + dev_err(dev, "(%u), seqNo %u, resp_id (0x%x)\n", + stream, + response->resp_seq_num, + response->resp_id); + + return -EINVAL; + } + + return 0; +} + +int isp4if_send_command (struct isp4_interface *ispif, + u32 cmd_id, + void *package, + u32 package_size) +{ + return isp4if_send_fw_cmd(ispif, + cmd_id, package, + package_size, NULL, NULL, NULL); +} + +int isp4if_send_command_sync (struct isp4_interface *ispif, + u32 cmd_id, + void *package, + u32 package_size, + u32 timeout) +{ + struct device *dev = ispif->dev; + DECLARE_WAIT_QUEUE_HEAD(cmd_wq); + u32 wq_cond = 0; + int ret; + u32 seq; + + ret = isp4if_send_fw_cmd(ispif, + cmd_id, package, + package_size, &cmd_wq, &wq_cond, &seq); + + if (ret) { + dev_err(dev, "send fw cmd fail %d\n", ret); + return ret; + } + + ret = wait_event_timeout(cmd_wq, wq_cond != 0, + msecs_to_jiffies(timeout)); + + /* timeout occurred */ + if (ret == 0) { + struct isp4if_cmd_element *ele; + + ele = isp4if_rm_cmd_from_cmdq(ispif, seq, cmd_id); + kfree(ele); + return -ETIMEDOUT; + } + + return 0; +} + +void isp4if_clear_bufq (struct isp4_interface *ispif) +{ + struct isp4if_img_buf_node *buf_node = NULL; + struct isp4if_img_buf_node *tmp_node = NULL; + + guard(mutex)(&ispif->bufq_mutex); + + list_for_each_entry_safe(buf_node, tmp_node, &ispif->bufq, + node) { + list_del(&buf_node->node); + kfree(buf_node); + } +} + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node) +{ + kfree(buf_node); +} + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info) +{ + struct isp4if_img_buf_node *node = NULL; + + node = kmalloc(sizeof(*node), GFP_KERNEL); + if (node) + node->buf_info = *buf_info; + + return node; +}; + +struct isp4if_img_buf_node * +isp4if_dequeue_buffer (struct isp4_interface *ispif) +{ + struct isp4if_img_buf_node *buf_node = NULL; + + guard(mutex)(&ispif->bufq_mutex); + + buf_node = list_first_entry_or_null(&ispif->bufq, + typeof(*buf_node), + node); + if (buf_node) + list_del(&buf_node->node); + + return buf_node; +} + +int isp4if_queue_buffer (struct isp4_interface *ispif, + struct isp4if_img_buf_node *buf_node) +{ + int ret; + + ret = isp4if_send_buffer(ispif, &buf_node->buf_info); + if (ret) + return ret; + + guard(mutex)(&ispif->bufq_mutex); + + list_add_tail(&buf_node->node, &ispif->bufq); + + return 0; +} + +int isp4if_stop (struct isp4_interface *ispif) +{ + isp4if_disable_ccpu(ispif); + + isp4if_dealloc_fw_gpumem(ispif); + + return 0; +} + +int isp4if_start (struct isp4_interface *ispif) +{ + int ret; + + ret = isp4if_alloc_fw_gpumem(ispif); + if (ret) + goto failed_gpumem_alloc; + + ret = isp4if_fw_boot(ispif); + if (ret) + goto failed_fw_boot; + + return 0; + +failed_gpumem_alloc: + return -ENOMEM; + +failed_fw_boot: + isp4if_dealloc_fw_gpumem(ispif); + return ret; +} + +int isp4if_deinit (struct isp4_interface *ispif) +{ + isp4if_clear_cmdq(ispif); + + isp4if_clear_bufq(ispif); + + mutex_destroy(&ispif->cmdq_mutex); + mutex_destroy(&ispif->bufq_mutex); + mutex_destroy(&ispif->isp4if_mutex); + + return 0; +} + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, + void *amdgpu_dev, void __iomem *isp_mmip) +{ + ispif->dev = dev; + ispif->adev = amdgpu_dev; + ispif->mmio = isp_mmip; + + ispif->cmd_rb_base_index = 0; + ispif->resp_rb_base_index = ISP4IF_RESP_CHAN_TO_RB_OFFSET - 1; + ispif->aligned_rb_chunk_size = ISP4IF_RB_PMBMAP_MEM_CHUNK &
0xffffffc0;
+
+mutex_init(&ispif->cmdq_mutex); /* used for cmdq access */ +mutex_init(&ispif->bufq_mutex); /* used for bufq access */ +mutex_init(&ispif->isp4if_mutex); /* used for commands sent to ispfw */drivers/media/platform/amd/isp4/isp4_interface.c new file +6
-0+ + INIT_LIST_HEAD(&ispif->cmdq); + INIT_LIST_HEAD(&ispif->bufq); + + return 0; +}drivers/media/platform/amd/isp4/isp4_interface.h new file +24
-0@@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_INTERFACE_ +#define _ISP4_INTERFACE_ + +#define ISP4IF_RB_MAX (25) +#define ISP4IF_RESP_CHAN_TO_RB_OFFSET (9) +#define ISP4IF_RB_PMBMAP_MEM_SIZE (16 * 1024 * 1024 - 1) +#define ISP4IF_RB_PMBMAP_MEM_CHUNK (ISP4IF_RB_PMBMAP_MEM_SIZE \ + / (ISP4IF_RB_MAX - 1)) +#define ISP4IF_ISP_MC_ADDR_ALIGN (1024 * 32) +#define ISP4IF_HOST2FW_COMMAND_SIZE (sizeof(struct isp4fw_cmd)) +#define ISP4IF_FW_CMD_BUF_COUNT 4 +#define ISP4IF_FW_RESP_BUF_COUNT 4 +#define ISP4IF_MAX_NUM_HOST2FW_COMMAND (40) +#define ISP4IF_FW_CMD_BUF_SIZE (ISP4IF_MAX_NUM_HOST2FW_COMMAND \ + * ISP4IF_HOST2FW_COMMAND_SIZE) +#define ISP4IF_MAX_SLEEP_COUNT (10) +#define ISP4IF_MAX_SLEEP_TIME (33) + +#define ISP4IF_META_INFO_BUF_SIZE ALIGN(sizeof(struct
isp4fw_meta_info),0x8000)drivers/media/platform/amd/isp4/isp4_interface.h new file +126
-0+#define ISP4IF_MAX_STREAM_META_BUF_COUNT 6 + +#define ISP4IF_FW_LOG_RINGBUF_SIZE (2 * 1024 * 1024) + +#define ISP4IF_MAX_CMD_RESPONSE_BUF_SIZE (4 * 1024) + +#define GET_ISP4IF_REG_BASE (ispif) (((ispif))->mmio) + +enum isp4if_stream_id { + ISP4IF_STREAM_ID_GLOBAL = 0, + ISP4IF_STREAM_ID_1 = 1, + ISP4IF_STREAM_ID_MAX = 4 +}; + +enum isp4if_status { + ISP4IF_STATUS_PWR_OFF, + ISP4IF_STATUS_PWR_ON, + ISP4IF_STATUS_FW_RUNNING, + ISP4IF_FSM_STATUS_MAX +}; + +struct isp4if_gpu_mem_info { + u32 mem_domain; + u64 mem_size; + u32 mem_align; + u64 gpu_mc_addr; + void *sys_addr; + void *mem_handle; +}; + +struct isp4if_img_buf_info { + struct { + void *sys_addr; + u64 mc_addr; + u32 len; + } planes[3]; +}; + +struct isp4if_img_buf_node { + struct list_head node; + struct isp4if_img_buf_info buf_info; +}; + +struct isp4if_cmd_element { + struct list_head list; + u32 seq_num; + u32 cmd_id; + enum isp4if_stream_id stream; + u64 mc_addr; + wait_queue_head_t *wq; + u32 *wq_cond; + struct isp4if_gpu_mem_info *gpu_pkg; +}; + +struct isp4_interface { + struct amdgpu_device *adev; + + struct device *dev; + void __iomem *mmio; + + struct mutex cmdq_mutex; /* used for cmdq access */ + struct mutex bufq_mutex; /* used for bufq access */ + struct mutex isp4if_mutex; /* used to send fw cmd and read fw log */ + + struct list_head cmdq; /* commands sent to fw */ + struct list_head bufq; /* buffers sent to fw */ + + enum isp4if_status status; + u32 host2fw_seq_num; + + /* FW ring buffer configs */ + u32 cmd_rb_base_index; + u32 resp_rb_base_index; + u32 aligned_rb_chunk_size; + + /* ISP fw buffers */ + struct isp4if_gpu_mem_info *fw_log_buf; + struct isp4if_gpu_mem_info *fw_cmd_resp_buf; + struct isp4if_gpu_mem_info *fw_mem_pool; + struct isp4if_gpu_mem_info * + metainfo_buf_pool[ISP4IF_MAX_STREAM_META_BUF_COUNT]; +}; + +static inline void isp4if_split_addr64 (u64 addr,u32 *lo,u32 *hi) +{ + if (lo) + *lo = (u32)(addr & 0xffffffff); + if (hi) + *hi = (u32)(addr >> 32); +} + +static inline u64 isp4if_join_addr64 (u32 lo,u32 hi) +{ + return (((u64)hi) << 32) | (u64)lo; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, + enum isp4if_stream_id stream, + void *response); + +int isp4if_send_command (struct isp4_interface *ispif, + u32 cmd_id, + void *package, + u32 package_size); + +int isp4if_send_command_sync (struct isp4_interface *ispif, + u32 cmd_id, + void *package, + u32 package_size, + u32 timeout); + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, + u32 seq_num, + u32 cmd_id); + +void isp4if_clear_cmdq (struct isp4_interface *ispif); + +void isp4if_clear_bufq (struct isp4_interface *ispif); + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node); + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info); + +struct isp4if_img_buf_node *isp4if_dequeue_buffer(struct
isp4_interface*ispif);drivers/media/platform/amd/isp4/isp4_interface.h new file +14
-0+ +int isp4if_queue_buffer (struct isp4_interface *ispif, + struct isp4if_img_buf_node *buf_node); + +int isp4if_stop (struct isp4_interface *ispif); + +int isp4if_start (struct isp4_interface *ispif); + +int isp4if_deinit (struct isp4_interface *ispif); + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, + void *amdgpu_dev, void __iomem *isp_mmip); + +#endif
Re: [PATCH v2 4/8] media: platform: amd: Add isp4 fw and hw interface
Quoted 58 lines · Bin
Thanks Mario, will fix in the next version and pls see some of my comments
Quoted 55 lines · Mario Limonciello
(quoted diff) +2
-0+Alex +amd-gfxQuoted 41 lines · Bin Du
ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>---
drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 +++4 files changed, 1546 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.hdrivers/media/platform/amd/isp4/Makefile +0
-0@@ -5,10 +5,22 @@obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \
isp4_phy.o \
+ isp4_interface.o \
isp4_hw.o \
ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/Makefile +4
-0+ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drmccflags-y += -I$(srctree)/include
drivers/media/platform/amd/isp4/Makefile line 23
Quoted 7 lines
drivers/media/platform/amd/isp4/Makefile +7
-0+ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dmIMO this feels like a hack and also fragile to be sharing so much across subsystems.
Quoted 5 lines
Quoted 1 line
Either there should be a kernel wide
include/header that can be used by both or there should be a helper exported to get just the data that is needed.Yes, will refine to remove unnecessary ones in the next version, actually isp driver needs to access function
amdgpu_bo_create_kernelwhich is exported by amdgpu and delared inamdgpu_object.h, becauseamdgpu_object.halso includes other amd gpu header files, so have to add these include path to avoid compilation error. It'll be greate if there is kernel wide include, any suggestion for this?
Ah yeah I do see exports as of https://git.kernel.org/torvalds/c/ebbe34edc0a90
So based on what is in the tree right now what you did "makes sense", but I don't think it's "correct". From another driver like the ISP driver I feel that the code should really just be something like:
#include <linux/amdgpu/isp.h>
I see a few ways forward.
1) A new set of helpers created for amdgpu that can take
opaque" data arguments (maybe the mfd device?) and return back a pointer to the new buffer. Describe those new helpers in that isp.h header.
2) Manage the lifecycle of the buffers in sw_init/sw_fini of the ISP in amdgpu. Store pointers to them for access in the mfd device, and let the ISP driver take references. This only works if you don't need new buffers after the driver is loaded.
I personally prefer option 2 if it is feasible.
Alex or others might have some other ideas too.
Du, Bin
maintainerRe: [PATCH v2 4/8] media: platform: amd: Add isp4 fw and hw interface
Thanks Mario, add more comments
Quoted 74 lines · Mario Limonciello
Quoted 59 lines · Bin
Thanks Mario, will fix in the next version and pls see some of my comments
Quoted 56 lines · Mario Limonciello
(quoted diff) +2
-0+Alex +amd-gfxQuoted 42 lines · Bin Du
ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>---
drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++
++++
.../media/platform/amd/isp4/isp4_interface.h | 164 +++4 files changed, 1546 insertions(+)create mode 100644
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.hcreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.ccreate mode 100644drivers/media/platform/amd/isp4/isp4_interface.hdrivers/media/platform/amd/isp4/Makefile +0
-0@@ -5,10 +5,22 @@obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \
isp4_phy.o \
+ isp4_interface.o \
isp4_hw.o \
ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4drivers/media/platform/amd/isp4/Makefile +4
-0+ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drmccflags-y += -I$(srctree)/include
drivers/media/platform/amd/isp4/Makefile line 23
Quoted 7 lines
drivers/media/platform/amd/isp4/Makefile +7
-0+ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dmIMO this feels like a hack and also fragile to be sharing so much across subsystems.
Quoted 5 lines
Quoted 1 line
Either there should be a kernel wide
include/header that can be used by both or there should be a helper exported to get just the data that is needed.Yes, will refine to remove unnecessary ones in the next version, actually isp driver needs to access function
amdgpu_bo_create_kernelwhich is exported by amdgpu and delared inamdgpu_object.h, becauseamdgpu_object.halso includes other amd gpu header files, so have to add these include path to avoid compilation error. It'll be greate if there is kernel wide include, any suggestion for this?Ah yeah I do see exports as of https://git.kernel.org/torvalds/c/
ebbe34edc0a90So based on what is in the tree right now what you did "makes sense", but I don't think it's "correct". From another driver like the ISP driver I feel that the code should really just be something like:
#include <
linux/amdgpu/isp.h>I see a few ways forward.
Quoted 8 lines
1) A new set of helpers created for amdgpu that can take
opaque" data arguments (maybe the mfd device?) and return back a pointer to the new buffer. Describe those new helpers in thatisp.hheader.2) Manage the lifecycle of the buffers in sw_init/sw_fini of the ISP in amdgpu. Store pointers to them for access in the mfd device, and let the ISP driver take references. This only works if you don't need new buffers after the driver is loaded.
I personally prefer option 2 if it is feasible.
Alex or others might have some other ideas too.
2 is not feasible, because the buffer size and number are decided by App at runtime. 1 is really a good idea, will have more investigation internally
Sakari Ailus
maintainerRe: [PATCH v2 4/8] media: platform: amd: Add isp4 fw and hw interface
In reply to Bin DuHi Bin,
Quoted 4 lines · Bin Du
ISP firmware controls ISP HW pipeline using dedicated embedded processor called ccpu.
The communication between ISP FW and driver is using commands and response messages sent through the ring buffer. Command buffers support
Quoted 8 lines
either global setting that is not specific to the steam and support stream specific parameters. Response buffers contains ISP FW notification information such as frame buffer done and command done. IRQ is used for receiving response buffer from ISP firmware, which is handled in the main isp4 media device. ISP ccpu is booted up through the firmware loading helper function prior to stream start.
Memory used for command buffer and response buffer needs to be allocated from amdgpu buffer manager because isp4 is a child device of amdgpu.
Please rewrap this, some lines above are quite short.
Quoted 89 lines
Signed-off-by Bin Du <[email protected]>Signed-off-by Svetoslav Stoilov <[email protected]>--- drivers/media/platform/amd/isp4/Makefile | 12 + .../platform/amd/isp4/isp4_fw_cmd_resp.h | 318 +++++ .../media/platform/amd/isp4/isp4_interface.c | 1052 +++++++++++++++++ .../media/platform/amd/isp4/isp4_interface.h | 164 +++ 4 files changed, 1546 insertions(+) create mode 100644 drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.c create mode 100644 drivers/media/platform/amd/isp4/isp4_interface.hdrivers/media/platform/amd/isp4/Makefile +12
-0@@ -5,10 +5,22 @@ obj-$(CONFIG_AMD_ISP4) += amd_capture.o amd_capture-objs := isp4.o \ isp4_phy.o \ + isp4_interface.o \ isp4_hw.o \ ccflags-y += -I$(srctree)/drivers/media/platform/amd/isp4 +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/amdgpu +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/pm/inc +ccflags-y += -I$(srctree)/include/drm ccflags-y += -I$(srctree)/include +ccflags-y += -I$(srctree)/include/uapi/drm +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/acp/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/include +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/modules/inc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/dc +ccflags-y += -I$(srctree)/drivers/gpu/drm/amd/display/amdgpu_dm ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) cc_stack_align := -mpreferred-stack-boundary=4drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +43
-0@@ -0,0 +1,318 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_CMD_RESP_H_ +#define _ISP4_CMD_RESP_H_ + +/* +* @brief Host and Firmware command & response channel. +* Two types of command/response channel. +* Type Global Command has one command/response channel. +* Type Stream Command has one command/response channel. +*----------- ------------ +*| | --------------------------- | | +*| | ---->| Global Command |----> | | +*| | --------------------------- | | +*| | | | +*| | | | +*| | --------------------------- | | +*| | ---->| Stream Command |----> | | +*| | --------------------------- | | +*| | | | +*| | | | +*| | | | +*| HOST | | Firmware | +*| | | | +*| | | | +*| | -------------------------- | | +*| | <----| Global Response |<---- | | +*| | -------------------------- | | +*| | | | +*| | | | +*| | -------------------------- | | +*| | <----| Stream Response |<---- | | +*| | -------------------------- | | +*| | | | +*| | | | +*----------- ------------ +*/ + +/* +* @brief command ID format
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 53
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +10
-0+* cmd_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define CMD_TYPE_SHIFT (24) +#define CMD_GROUP_SHIFT (16)
Redundant parentheses. Please remove all of them.
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 54
Quoted 1 line
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +1
-0+#define CMD_TYPE_STREAM_CTRL ((u32)0x2 << CMD_TYPE_SHIFT)
Maybe 0x2U << CMD_TYPE_SHIFT instead?
Quoted 40 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +40
-0+ +#define CMD_GROUP_STREAM_CTRL ((u32)0x1 << CMD_GROUP_SHIFT) +#define CMD_GROUP_STREAM_BUFFER ((u32)0x4 << CMD_GROUP_SHIFT) + +/* Stream Command */ +#define CMD_ID_SET_STREAM_CONFIG \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x1) +#define CMD_ID_SET_OUT_CHAN_PROP \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x3) +#define CMD_ID_ENABLE_OUT_CHAN \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x5) +#define CMD_ID_START_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x7) +#define CMD_ID_STOP_STREAM \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_CTRL | 0x8) + +/* Stream Buffer Command */ +#define CMD_ID_SEND_BUFFER \ + (CMD_TYPE_STREAM_CTRL | CMD_GROUP_STREAM_BUFFER | 0x1) + +/* +* @brief response ID format +* resp_id is in the format of following type: +* type: indicate command type, global/stream commands. +* group: indicate the command group. +* id: A unique command identification in one type and group. +* |<-Bit31 ~ Bit24->|<-Bit23 ~ Bit16->|<-Bit15 ~ Bit0->| +* | type | group | id | +*/ + +#define RESP_GROUP_SHIFT (16) +#define RESP_GROUP_MASK (0xff << RESP_GROUP_SHIFT) + +#define GET_RESP_GROUP_VALUE (resp_id) \ + (((resp_id) & RESP_GROUP_MASK) >> \ + RESP_GROUP_SHIFT) +#define GET_RESP_ID_VALUE (resp_id) ((resp_id) & 0xffff) + +#define RESP_GROUP_GENERAL (0x1 << RESP_GROUP_SHIFT) +#define RESP_GROUP_NOTIFICATION (0x3 << RESP_GROUP_SHIFT)
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h line 104
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +10
-0+ +/* General Response */ +#define RESP_ID_CMD_DONE (RESP_GROUP_GENERAL | 0x1) + +/* Notification */ +#define RESP_ID_NOTI_FRAME_DONE (RESP_GROUP_NOTIFICATION | 0x1) + +#define CMD_STATUS_SUCCESS (0) +#define CMD_STATUS_FAIL (1) +#define CMD_STATUS_SKIPPED (2)
Again, please align macro bodies.
Quoted 345 lines
drivers/media/platform/amd/isp4/isp4_fw_cmd_resp.h new file +214
-0+ +#define ADDR_SPACE_TYPE_GPU_VA 4 + +#define FW_MEMORY_POOL_SIZE (200 * 1024 * 1024) + +/* +* standard ISP mipicsi=>isp +*/ +#define MIPI0_ISP_PIPELINE_ID 0x5f91 + +enum isp4fw_sensor_id { +SENSOR_ID_ON_MIPI0 =0 ,/* Sensor id for ISP input from MIPI port 0 */ +}; + +enum isp4fw_stream_id { +STREAM_ID_INVALID =-1 ,/* STREAM_ID_INVALID. */ +STREAM_ID_1 =0 ,/* STREAM_ID_1. */ +STREAM_ID_2 =1 ,/* STREAM_ID_2. */ +STREAM_ID_3 =2 ,/* STREAM_ID_3. */ +STREAM_ID_MAXIMUM /* STREAM_ID_MAXIMUM. */ +}; + +enum isp4fw_image_format { +IMAGE_FORMAT_NV12 =1 ,/* 4:2:0,semi-planar, 8-bit */ +IMAGE_FORMAT_YUV422INTERLEAVED =7 ,/* interleave, 4:2:2, 8-bit */ +}; + +enum isp4fw_pipe_out_ch { +ISP_PIPE_OUT_CH_PREVIEW =0 , +}; + +enum isp4fw_yuv_range { +ISP_YUV_RANGE_FULL =0 ,/* YUV value range in 0~255 */ +ISP_YUV_RANGE_NARROW =1 ,/* YUV value range in 16~235 */ +ISP_YUV_RANGE_MAX +}; + +enum isp4fw_buffer_type { +BUFFER_TYPE_PREVIEW =8 , +BUFFER_TYPE_META_INFO =10 , +BUFFER_TYPE_MEM_POOL =15 , +}; + +enum isp4fw_buffer_status { +BUFFER_STATUS_INVALID ,/* The buffer is INVALID */ +BUFFER_STATUS_SKIPPED ,/* The buffer is not filled with image data */ +BUFFER_STATUS_EXIST ,/* The buffer is exist and waiting for filled */ +BUFFER_STATUS_DONE ,/* The buffer is filled with image data */ +BUFFER_STATUS_LACK ,/* The buffer is unavailable */ +BUFFER_STATUS_DIRTY ,/* The buffer is dirty, probably caused by +* LMI leakage +*/ +BUFFER_STATUS_MAX /* The buffer STATUS_MAX */ +}; + +enum isp4fw_buffer_source { +/* The buffer is from the stream buffer queue */ +BUFFER_SOURCE_STREAM , +}; + +struct isp4fw_error_code { +u32 code1; +u32 code2; +u32 code3; +u32 code4; +u32 code5; +}; + +/* +* Command Structure for FW +*/ + +struct isp4fw_cmd { +u32 cmd_seq_num; +u32 cmd_id; +u32 cmd_param[12 ]; +u16 cmd_stream_id; +u8 cmd_silent_resp; +u8 reserved; +u32 cmd_check_sum; +}; + +struct isp4fw_resp_cmd_done { +/* The host2fw command seqNum. +* To indicate which command this response refer to. +*/ +u32 cmd_seq_num; +/* The host2fw command id for host double check. */ +u32 cmd_id; +/* Indicate the command process status. +* 0 means success. 1 means fail. 2 means skipped +*/ +u16 cmd_status; +/* If the cmd_status is 1, that means the command is processed fail, */ +/* host can check the isp4fw_error_code to get the detail +* error information +*/ +u16 isp4fw_error_code; +/* The response payload will be in different struct type */ +/* according to different cmd done response. */ +u8 payload[36 ]; +}; + +struct isp4fw_resp_param_package { +u32 package_addr_lo;/* The low 32 bit addr of the pkg address. */ +u32 package_addr_hi;/* The high 32 bit addr of the pkg address. */ +u32 package_size;/* The total pkg size in bytes. */ +u32 package_check_sum;/* The byte sum of the pkg. */ +}; + +struct isp4fw_resp { +u32 resp_seq_num; +u32 resp_id; +union { +struct isp4fw_resp_cmd_done cmd_done; +struct isp4fw_resp_param_package frame_done; +u32 resp_param[12 ]; + } param; +u8 reserved[4 ]; +u32 resp_check_sum; +}; + +struct isp4fw_mipi_pipe_path_cfg { +u32 b_enable; +enum isp4fw_sensor_id isp4fw_sensor_id; +}; + +struct isp4fw_isp_pipe_path_cfg { +u32 isp_pipe_id;/* pipe ids for pipeline construction */ +}; + +struct isp4fw_isp_stream_cfg { +/* Isp mipi path */ +struct isp4fw_mipi_pipe_path_cfg mipi_pipe_path_cfg; +/* Isp pipe path */ +struct isp4fw_isp_pipe_path_cfg isp_pipe_path_cfg; +/* enable TNR */ +u32 b_enable_tnr; +/* number of frame rta per-processing, +* set to 0 to use fw default value +*/ +u32 rta_frames_per_proc; +}; + +struct isp4fw_image_prop { +enum isp4fw_image_format image_format;/* Image format */ +u32 width;/* Width */ +u32 height;/* Height */ +u32 luma_pitch;/* Luma pitch */ +u32 chroma_pitch;/* Chrom pitch */ +enum isp4fw_yuv_range yuv_range;/* YUV value range */ +}; + +struct isp4fw_buffer { +/* A check num for debug usage, host need to */ +/* set the buf_tags to different number */ +u32 buf_tags; +union { +u32 value; +struct { +u32 space :16 ; +u32 vmid :16 ; + } bit; + } vmid_space; +u32 buf_base_a_lo;/* Low address of buffer A */ +u32 buf_base_a_hi;/* High address of buffer A */ +u32 buf_size_a;/* Buffer size of buffer A */ + +u32 buf_base_b_lo;/* Low address of buffer B */ +u32 buf_base_b_hi;/* High address of buffer B */ +u32 buf_size_b;/* Buffer size of buffer B */ + +u32 buf_base_c_lo;/* Low address of buffer C */ +u32 buf_base_c_hi;/* High address of buffer C */ +u32 buf_size_c;/* Buffer size of buffer C */ +}; + +struct isp4fw_buffer_meta_info { +u32 enabled;/* enabled flag */ +enum isp4fw_buffer_status status;/* BufferStatus */ +struct isp4fw_error_code err;/* err code */ +enum isp4fw_buffer_source source;/* BufferSource */ +struct isp4fw_image_prop image_prop;/* image_prop */ +struct isp4fw_buffer buffer;/* buffer */ +}; + +struct isp4fw_meta_info { +u32 poc;/* frame id */ +u32 fc_id;/* frame ctl id */ +u32 time_stamp_lo;/* time_stamp_lo */ +u32 time_stamp_hi;/* time_stamp_hi */ +struct isp4fw_buffer_meta_info preview;/* preview BufferMetaInfo */ +}; + +struct isp4fw_cmd_send_buffer { +enum isp4fw_buffer_type buffer_type;/* buffer Type */ +struct isp4fw_buffer buffer;/* buffer info */ +}; + +struct isp4fw_cmd_set_out_ch_prop { +enum isp4fw_pipe_out_ch ch;/* ISP pipe out channel */ +struct isp4fw_image_prop image_prop;/* image property */ +}; + +struct isp4fw_cmd_enable_out_ch { +enum isp4fw_pipe_out_ch ch;/* ISP pipe out channel */ +u32 is_enable;/* If enable channel or not */ +}; + +struct isp4fw_cmd_set_stream_cfg { +struct isp4fw_isp_stream_cfg stream_cfg;/* stream path config */ +}; + +#endif drivers/media/platform/amd/isp4/isp4_interface.c new file +125
-0@@ -0,0 +1,1052 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#include <linux/mutex.h> + +#include "amdgpu_object.h" + +#include "isp4_fw_cmd_resp.h" +#include "isp4_hw.h" +#include "isp4_hw_reg.h" +#include "isp4_interface.h" + +#define ISP4IF_FW_RESP_RB_IRQ_EN_MASK \ + (ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT9_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT10_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT11_EN_MASK | \ + ISP_SYS_INT0_EN__SYS_INT_RINGBUFFER_WPT12_EN_MASK) + +struct isp4if_rb_config { +const char *name; +u32 index; +u32 reg_rptr; +u32 reg_wptr; +u32 reg_base_lo; +u32 reg_base_hi; +u32 reg_size; +u32 val_size; +u64 base_mc_addr; +void *base_sys_addr; +}; + +/* FW cmd ring buffer configuration */ +static struct isp4if_rb_config + isp4if_cmd_rb_config[ISP4IF_STREAM_ID_MAX ] = { + { + .name ="CMD_RB_GBL0" , + .index =3 , + .reg_rptr =ISP_RB_RPTR4 , + .reg_wptr =ISP_RB_WPTR4 , + .reg_base_lo =ISP_RB_BASE_LO4 , + .reg_base_hi =ISP_RB_BASE_HI4 , + .reg_size =ISP_RB_SIZE4 , + }, + { + .name ="CMD_RB_STR1" , + .index =0 , + .reg_rptr =ISP_RB_RPTR1 , + .reg_wptr =ISP_RB_WPTR1 , + .reg_base_lo =ISP_RB_BASE_LO1 , + .reg_base_hi =ISP_RB_BASE_HI1 , + .reg_size =ISP_RB_SIZE1 , + }, + { + .name ="CMD_RB_STR2" , + .index =1 , + .reg_rptr =ISP_RB_RPTR2 , + .reg_wptr =ISP_RB_WPTR2 , + .reg_base_lo =ISP_RB_BASE_LO2 , + .reg_base_hi =ISP_RB_BASE_HI2 , + .reg_size =ISP_RB_SIZE2 , + }, + { + .name ="CMD_RB_STR3" , + .index =2 , + .reg_rptr =ISP_RB_RPTR3 , + .reg_wptr =ISP_RB_WPTR3 , + .reg_base_lo =ISP_RB_BASE_LO3 , + .reg_base_hi =ISP_RB_BASE_HI3 , + .reg_size =ISP_RB_SIZE3 , + }, +}; + +/* FW resp ring buffer configuration */ +static struct isp4if_rb_config + isp4if_resp_rb_config[ISP4IF_STREAM_ID_MAX ] = { + { + .name ="RES_RB_GBL0" , + .index =3 , + .reg_rptr =ISP_RB_RPTR12 , + .reg_wptr =ISP_RB_WPTR12 , + .reg_base_lo =ISP_RB_BASE_LO12 , + .reg_base_hi =ISP_RB_BASE_HI12 , + .reg_size =ISP_RB_SIZE12 , + }, + { + .name ="RES_RB_STR1" , + .index =0 , + .reg_rptr =ISP_RB_RPTR9 , + .reg_wptr =ISP_RB_WPTR9 , + .reg_base_lo =ISP_RB_BASE_LO9 , + .reg_base_hi =ISP_RB_BASE_HI9 , + .reg_size =ISP_RB_SIZE9 , + }, + { + .name ="RES_RB_STR2" , + .index =1 , + .reg_rptr =ISP_RB_RPTR10 , + .reg_wptr =ISP_RB_WPTR10 , + .reg_base_lo =ISP_RB_BASE_LO10 , + .reg_base_hi =ISP_RB_BASE_HI10 , + .reg_size =ISP_RB_SIZE10 , + }, + { + .name ="RES_RB_STR3" , + .index =2 , + .reg_rptr =ISP_RB_RPTR11 , + .reg_wptr =ISP_RB_WPTR11 , + .reg_base_lo =ISP_RB_BASE_LO11 , + .reg_base_hi =ISP_RB_BASE_HI11 , + .reg_size =ISP_RB_SIZE11 , + }, +}; + +/* FW log ring buffer configuration */ +static struct isp4if_rb_config isp4if_log_rb_config = { + .name ="LOG_RB" , + .index =0 , + .reg_rptr =ISP_LOG_RB_RPTR0 , + .reg_wptr =ISP_LOG_RB_WPTR0 , + .reg_base_lo =ISP_LOG_RB_BASE_LO0 , + .reg_base_hi =ISP_LOG_RB_BASE_HI0 , + .reg_size =ISP_LOG_RB_SIZE0 , +};
drivers/media/platform/amd/isp4/isp4_interface.c line 135
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ +static struct isp4if_gpu_mem_info *isp4if_gpu_mem_alloc (struct isp4_interface + *ispif, +u32 mem_size) +{ +struct isp4if_gpu_mem_info *mem_info; +struct amdgpu_bo *bo =NULL ; +struct amdgpu_device *adev; +struct device *dev; +
Extra newline.
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +4
-0+void *cpu_ptr; +u64 gpu_addr; +u32 ret; +
drivers/media/platform/amd/isp4/isp4_interface.c line 149
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ dev = ispif->dev; + +if (!mem_size) +return NULL ; + + mem_info =kzalloc (sizeof (*mem_info),GFP_KERNEL ); +if (!mem_info) +return NULL ; + + adev = (struct amdgpu_device *)ispif->adev;
Why the cast?
adev isn't a great name here as it's usually used for struct acpi_devices.
drivers/media/platform/amd/isp4/isp4_interface.c line 160
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +11
-0+ mem_info->mem_size = mem_size; + mem_info->mem_align =ISP4IF_ISP_MC_ADDR_ALIGN ; + mem_info->mem_domain =AMDGPU_GEM_DOMAIN_GTT ; + + ret =amdgpu_bo_create_kernel (adev, + mem_info->mem_size, + mem_info->mem_align, + mem_info->mem_domain, + &bo, + &gpu_addr, + &cpu_ptr);
This fits on fewer lines.
drivers/media/platform/amd/isp4/isp4_interface.c line 161
Quoted 1 line
drivers/media/platform/amd/isp4/isp4_interface.c new file +1
-0+
Extra newline.
Quoted 15 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +15
-0+if (!cpu_ptr || ret) { +dev_err (dev,"gpuvm buffer alloc fail, size %u\n" , mem_size); +kfree (mem_info); +return NULL ; + } + + mem_info->sys_addr = cpu_ptr; + mem_info->gpu_mc_addr = gpu_addr; + mem_info->mem_handle = (void *)bo; + +return mem_info; +} + +static int isp4if_gpu_mem_free (struct isp4_interface *ispif, +struct isp4if_gpu_mem_info *mem_info)
drivers/media/platform/amd/isp4/isp4_interface.c line 186
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+{ +struct device *dev = ispif->dev; +struct amdgpu_bo *bo; + +if (!mem_info) { +dev_err (dev,"invalid mem_info\n" ); +return -EINVAL ; + } + + bo = (struct amdgpu_bo *)mem_info->mem_handle;
Why do you need to cast here?
Quoted 31 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +31
-0+ +amdgpu_bo_free_kernel (&bo, &mem_info->gpu_mc_addr, &mem_info->sys_addr); + +kfree (mem_info); + +return 0 ; +} + +static int isp4if_dealloc_fw_gpumem (struct isp4_interface *ispif) +{ +int i; + +if (ispif->fw_mem_pool) { +isp4if_gpu_mem_free (ispif, ispif->fw_mem_pool); + ispif->fw_mem_pool =NULL ; + } + +if (ispif->fw_cmd_resp_buf) { +isp4if_gpu_mem_free (ispif, ispif->fw_cmd_resp_buf); + ispif->fw_cmd_resp_buf =NULL ; + } + +if (ispif->fw_log_buf) { +isp4if_gpu_mem_free (ispif, ispif->fw_log_buf); + ispif->fw_log_buf =NULL ; + } + +for (i =0 ; i <ISP4IF_MAX_STREAM_META_BUF_COUNT ; i++) { +if (ispif->metainfo_buf_pool[i]) { +isp4if_gpu_mem_free (ispif, ispif->metainfo_buf_pool[i]); + ispif->metainfo_buf_pool[i] =NULL ;
drivers/media/platform/amd/isp4/isp4_interface.c line 227
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ } + } + +return 0 ; +} + +static int isp4if_alloc_fw_gpumem (struct isp4_interface *ispif) +{ +struct device *dev = ispif->dev; +int i;
Unsigned int, please.
Quoted 106 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +106
-0+ + ispif->fw_mem_pool =isp4if_gpu_mem_alloc (ispif,FW_MEMORY_POOL_SIZE ); +if (!ispif->fw_mem_pool) + goto error_no_memory; + + ispif->fw_cmd_resp_buf = +isp4if_gpu_mem_alloc (ispif,ISP4IF_RB_PMBMAP_MEM_SIZE ); +if (!ispif->fw_cmd_resp_buf) + goto error_no_memory; + + ispif->fw_log_buf = +isp4if_gpu_mem_alloc (ispif,ISP4IF_FW_LOG_RINGBUF_SIZE ); +if (!ispif->fw_log_buf) + goto error_no_memory; + +for (i =0 ; i <ISP4IF_MAX_STREAM_META_BUF_COUNT ; i++) { + ispif->metainfo_buf_pool[i] = +isp4if_gpu_mem_alloc (ispif, +ISP4IF_META_INFO_BUF_SIZE ); +if (!ispif->metainfo_buf_pool[i]) + goto error_no_memory; + } + +return 0 ; + +error_no_memory: +dev_err (dev,"failed to allocate gpu memory" ); +return -ENOMEM ; +} + +static u32 isp4if_compute_check_sum (u8 *buf,u32 buf_size) +{ +u32 checksum =0 ; +u8 *surplus_ptr; +u32 *buffer; +u32 i; + + buffer = (u32 *)buf; +for (i =0 ; i < buf_size /sizeof (u32); i++) + checksum += buffer[i]; + + surplus_ptr = (u8 *)&buffer[i]; +/* add surplus data crc checksum */ +for (i =0 ; i < buf_size %sizeof (u32); i++) + checksum += surplus_ptr[i]; + +return checksum; +} + +void isp4if_clear_cmdq (struct isp4_interface *ispif) +{ +struct isp4if_cmd_element *buf_node =NULL ; +struct isp4if_cmd_element *tmp_node =NULL ; + +guard (mutex)(&ispif->cmdq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->cmdq, list) { +list_del (&buf_node->list); +kfree (buf_node); + } +} + +static bool isp4if_is_cmdq_rb_full (struct isp4_interface *ispif, +enum isp4if_stream_id cmd_buf_idx) +{ +struct isp4if_rb_config *rb_config; +u32 rd_ptr, wr_ptr; +u32 new_wr_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_cmd_rb_config[cmd_buf_idx]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + len = rb_config->val_size; + + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); + + new_wr_ptr = wr_ptr +sizeof (struct isp4fw_cmd ); + +if (wr_ptr >= rd_ptr) { +if (new_wr_ptr < len) { +return false; + }else if (new_wr_ptr == len) { +if (rd_ptr ==0 ) +return true; + +return false; + } + + new_wr_ptr -= len; +if (new_wr_ptr < rd_ptr) +return false; + +return true; + } + +if (new_wr_ptr < rd_ptr) +return false; + +return true; +} + +static struct isp4if_cmd_element *
drivers/media/platform/amd/isp4/isp4_interface.c line 343
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+isp4if_append_cmd_2_cmdq(struct isp4_interface *ispif, + struct isp4if_cmd_element *cmd_ele) +{ + struct isp4if_cmd_element *copy_command = NULL; + + copy_command =kmalloc (sizeof (*copy_command),GFP_KERNEL ); +if (!copy_command) +return NULL ; + +memcpy (copy_command, cmd_ele,sizeof (*copy_command));
kmemdup()?
Quoted 153 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +153
-0+ +guard (mutex)(&ispif->cmdq_mutex); + +list_add_tail (©_command->list, &ispif->cmdq); + +return copy_command; +} + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, +u32 seq_num, +u32 cmd_id) +{ +struct isp4if_cmd_element *buf_node =NULL ; +struct isp4if_cmd_element *tmp_node =NULL ; + +guard (mutex)(&ispif->cmdq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->cmdq, list) { +if (buf_node->seq_num == seq_num && + buf_node->cmd_id == cmd_id) { +list_del (&buf_node->list); +return buf_node; + } + } + +return NULL ; +} + +static int isp4if_insert_isp_fw_cmd (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +struct isp4fw_cmd *cmd) +{ +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +u64 mem_addr; +u64 mem_sys; +u32 wr_ptr; +u32 rd_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_cmd_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = (u64 )rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + +if (isp4if_is_cmdq_rb_full (ispif, stream)) { +dev_err (dev,"fail no cmdslot (%d)\n" , stream); +return -EINVAL ; + } + + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + +if (rd_ptr > len) { +dev_err (dev,"fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + +if (wr_ptr > len) { +dev_err (dev,"fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n" , + stream, wr_ptr, len, rd_ptr); +return -EINVAL ; + } + +if (wr_ptr < rd_ptr) { + mem_addr += wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd,sizeof (struct isp4fw_cmd )); + }else { +if ((len - wr_ptr) >= (sizeof (struct isp4fw_cmd ))) { + mem_addr += wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), + (u8 *)cmd,sizeof (struct isp4fw_cmd )); + }else { +u32 size; +u8 *src; + + src = (u8 *)cmd; + size = len - wr_ptr; + +memcpy ((u8 *)(mem_sys + wr_ptr), src, size); + + src += size; + size =sizeof (struct isp4fw_cmd ) - size; +memcpy ((u8 *)(mem_sys), src, size); + } + } + + wr_ptr +=sizeof (struct isp4fw_cmd ); +if (wr_ptr >= len) + wr_ptr -= len; + +isp4hw_wreg (ispif->mmio, wreg, wr_ptr); + +return 0 ; +} + +static inline enum isp4if_stream_id isp4if_get_fw_stream (u32 cmd_id) +{ +return ISP4IF_STREAM_ID_1 ; +} + +static int isp4if_send_fw_cmd (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +wait_queue_head_t *wq, +u32 *wq_cond, +u32 *seq) +{ +enum isp4if_stream_id stream =isp4if_get_fw_stream (cmd_id); +struct isp4if_cmd_element command_element = {0 }; +struct isp4if_gpu_mem_info *gpu_mem =NULL ; +struct isp4if_cmd_element *cmd_ele =NULL ; +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +struct isp4fw_cmd cmd = {0 }; +u64 package_base =0 ; +u32 sleep_count; +u32 seq_num; +u32 rreg; +u32 wreg; +int ret; + +if (package_size >sizeof (cmd.cmd_param)) { +dev_err (dev,"fail pkgsize(%u)>%lu cmd:0x%x,stream %d\n" , + package_size,sizeof (cmd.cmd_param), cmd_id, stream); +return -EINVAL ; + } + + sleep_count =0 ; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + +guard (mutex)(&ispif->isp4if_mutex); + +while (1 ) { +if (isp4if_is_cmdq_rb_full (ispif, stream)) { +u32 rd_ptr, wr_ptr; + +if (sleep_count <ISP4IF_MAX_SLEEP_COUNT ) { +msleep (ISP4IF_MAX_SLEEP_TIME ); + sleep_count++;
drivers/media/platform/amd/isp4/isp4_interface.c line 506
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+continue ; + } + rd_ptr =isp4hw_rreg (ispif->mmio, rreg); + wr_ptr =isp4hw_rreg (ispif->mmio, wreg); +dev_err (dev,"fail to get cmdq slot,stream (%d), rd %u, wr %u\n" , + stream, rd_ptr, wr_ptr); +return -ETIMEDOUT ; + } +break ; + }
read_poll_timeout()?
drivers/media/platform/amd/isp4/isp4_interface.c line 511
Quoted 5 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +5
-0+ + cmd.cmd_id = cmd_id; +switch (stream) { +case ISP4IF_STREAM_ID_GLOBAL : + cmd.cmd_stream_id = (u16 )STREAM_ID_INVALID ;
Is there a need to cast here?
Quoted 47 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +47
-0+break ; +case ISP4IF_STREAM_ID_1 : + cmd.cmd_stream_id =STREAM_ID_1 ; +break ; +default : +dev_err (dev,"fail bad stream id %d\n" , stream); +return -EINVAL ; + } + +if (package && package_size) +memcpy (cmd.cmd_param, package, package_size); + + seq_num = ispif->host2fw_seq_num++; + cmd.cmd_seq_num = seq_num; + cmd.cmd_check_sum = +isp4if_compute_check_sum ((u8 *)&cmd,sizeof (cmd) -4 ); + +if (seq) + *seq = seq_num; + command_element.seq_num = seq_num; + command_element.cmd_id = cmd_id; + command_element.mc_addr = package_base; + command_element.wq = wq; + command_element.wq_cond = wq_cond; + command_element.gpu_pkg = gpu_mem; + command_element.stream = stream; +/* only append the fw cmd to queue when its response needs to be +* waited for, currently there are only two such commands, +* disable channel and stop stream which are only sent after close +* camera +*/ +if (wq && wq_cond) { + cmd_ele =isp4if_append_cmd_2_cmdq (ispif, &command_element); +if (!cmd_ele) { +dev_err (dev,"fail for isp_append_cmd_2_cmdq\n" ); +return -ENOMEM ; + } + } + + ret =isp4if_insert_isp_fw_cmd (ispif, stream, &cmd); +if (ret) { +dev_err (dev,"fail for insert_isp_fw_cmd camId (0x%08x)\n" , + cmd_id); +if (cmd_ele) { +isp4if_rm_cmd_from_cmdq (ispif, cmd_ele->seq_num, + cmd_ele->cmd_id); +kfree (cmd_ele);
drivers/media/platform/amd/isp4/isp4_interface.c line 568
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ } + } + +return ret; +} + +static int isp4if_send_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_info *buf_info) +{ +struct isp4fw_cmd_send_buffer cmd;
= { };
And you can remove the memset.
Quoted 103 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +103
-0+ +memset (&cmd,0 ,sizeof (cmd)); + cmd.buffer_type =BUFFER_TYPE_PREVIEW ; + cmd.buffer.vmid_space.bit.vmid =0 ; + cmd.buffer.vmid_space.bit.space =ADDR_SPACE_TYPE_GPU_VA ; +isp4if_split_addr64 (buf_info->planes[0 ].mc_addr, + &cmd.buffer.buf_base_a_lo, + &cmd.buffer.buf_base_a_hi); + cmd.buffer.buf_size_a = buf_info->planes[0 ].len; + +isp4if_split_addr64 (buf_info->planes[1 ].mc_addr, + &cmd.buffer.buf_base_b_lo, + &cmd.buffer.buf_base_b_hi); + cmd.buffer.buf_size_b = buf_info->planes[1 ].len; + +isp4if_split_addr64 (buf_info->planes[2 ].mc_addr, + &cmd.buffer.buf_base_c_lo, + &cmd.buffer.buf_base_c_hi); + cmd.buffer.buf_size_c = buf_info->planes[2 ].len; + +return isp4if_send_fw_cmd (ispif,CMD_ID_SEND_BUFFER , &cmd, +sizeof (cmd),NULL ,NULL ,NULL ); +} + +static void isp4if_init_rb_config (struct isp4_interface *ispif, +struct isp4if_rb_config *rb_config) +{ +u32 lo; +u32 hi; + +isp4if_split_addr64 (rb_config->base_mc_addr, &lo, &hi); + +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_rptr,0x0 ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_wptr,0x0 ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_base_lo, lo); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_base_hi, hi); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rb_config->reg_size, rb_config->val_size); +} + +static int isp4if_fw_init (struct isp4_interface *ispif) +{ +struct isp4if_rb_config *rb_config; +u32 offset; +int i; + +/* initialize CMD_RB streams */ +for (i =0 ; i <ISP4IF_STREAM_ID_MAX ; i++) { + rb_config = (isp4if_cmd_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->cmd_rb_base_index); + + rb_config->val_size =ISP4IF_FW_CMD_BUF_SIZE ; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + +isp4if_init_rb_config (ispif, rb_config); + } + +/* initialize RESP_RB streams */ +for (i =0 ; i <ISP4IF_STREAM_ID_MAX ; i++) { + rb_config = (isp4if_resp_rb_config + i); + offset = ispif->aligned_rb_chunk_size * + (rb_config->index + ispif->resp_rb_base_index); + + rb_config->val_size =ISP4IF_FW_CMD_BUF_SIZE ; + rb_config->base_sys_addr = + (u8 *)ispif->fw_cmd_resp_buf->sys_addr + offset; + rb_config->base_mc_addr = + ispif->fw_cmd_resp_buf->gpu_mc_addr + offset; + +isp4if_init_rb_config (ispif, rb_config); + } + +/* initialize LOG_RB stream */ + rb_config = &isp4if_log_rb_config; + rb_config->val_size =ISP4IF_FW_LOG_RINGBUF_SIZE ; + rb_config->base_mc_addr = ispif->fw_log_buf->gpu_mc_addr; + rb_config->base_sys_addr = ispif->fw_log_buf->sys_addr; + +isp4if_init_rb_config (ispif, rb_config); + +return 0 ; +} + +static int isp4if_wait_fw_ready (struct isp4_interface *ispif, +u32 isp_status_addr) +{ +struct device *dev = ispif->dev; +u32 fw_ready_timeout; +u32 timeout_ms =100 ; +u32 interval_ms =1 ; +u32 timeout =0 ; +u32 reg_val; + + fw_ready_timeout = timeout_ms / interval_ms; +
drivers/media/platform/amd/isp4/isp4_interface.c line 681
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+/* wait for FW initialize done! */ +while (timeout < fw_ready_timeout) { + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), + isp_status_addr); +if (reg_val &ISP_STATUS__CCPU_REPORT_MASK ) +return 0 ; + +msleep (interval_ms); + timeout++; + }
read_poll_timeout()?
Quoted 171 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +171
-0+ +dev_err (dev,"ISP CCPU FW boot failed\n" ); + +return -ETIME ; +} + +static void isp4if_enable_ccpu (struct isp4_interface *ispif) +{ +u32 reg_val; + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET ); + reg_val &= (~ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET , reg_val); + +usleep_range (100 ,150 ); + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL ); + reg_val &= (~ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK ); +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL , reg_val); +} + +static void isp4if_disable_ccpu (struct isp4_interface *ispif) +{ +u32 reg_val; + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL ); + reg_val |=ISP_CCPU_CNTL__CCPU_HOST_SOFT_RST_MASK ; +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_CCPU_CNTL , reg_val); + +usleep_range (100 ,150 ); + + reg_val =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET ); + reg_val |=ISP_SOFT_RESET__CCPU_SOFT_RESET_MASK ; +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SOFT_RESET , reg_val); +} + +static int isp4if_fw_boot (struct isp4_interface *ispif) +{ +struct device *dev = ispif->dev; + +if (ispif->status !=ISP4IF_STATUS_PWR_ON ) { +dev_err (dev,"invalid isp power status %d\n" , ispif->status); +return -EINVAL ; + } + +isp4if_disable_ccpu (ispif); + +isp4if_fw_init (ispif); + +/* clear ccpu status */ +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_STATUS ,0x0 ); + +isp4if_enable_ccpu (ispif); + +if (isp4if_wait_fw_ready (ispif,ISP_STATUS )) { +isp4if_disable_ccpu (ispif); +return -EINVAL ; + } + +/* enable interrupts */ +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif),ISP_SYS_INT0_EN , +ISP4IF_FW_RESP_RB_IRQ_EN_MASK ); + + ispif->status =ISP4IF_STATUS_FW_RUNNING ; + +dev_dbg (dev,"ISP CCPU FW boot success\n" ); + +return 0 ; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +void *resp) +{ +struct isp4fw_resp *response = resp; +struct isp4if_rb_config *rb_config; +struct device *dev = ispif->dev; +u32 rd_ptr_dbg; +u32 wr_ptr_dbg; +void *mem_sys; +u64 mem_addr; +u32 checksum; +u32 rd_ptr; +u32 wr_ptr; +u32 rreg; +u32 wreg; +u32 len; + + rb_config = &isp4if_resp_rb_config[stream]; + rreg = rb_config->reg_rptr; + wreg = rb_config->reg_wptr; + mem_sys = rb_config->base_sys_addr; + mem_addr = rb_config->base_mc_addr; + len = rb_config->val_size; + + rd_ptr =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), rreg); + wr_ptr =isp4hw_rreg (GET_ISP4IF_REG_BASE (ispif), wreg); + rd_ptr_dbg = rd_ptr; + wr_ptr_dbg = wr_ptr; + +if (rd_ptr > len) { +dev_err (dev,"fail (%u),rd_ptr %u(should<=%u),wr_ptr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + +if (wr_ptr > len) { +dev_err (dev,"fail (%u),wr_ptr %u(should<=%u), rd_ptr %u\n" , + stream, wr_ptr, len, rd_ptr); +return -EINVAL ; + } + +if (rd_ptr < wr_ptr) { +if ((wr_ptr - rd_ptr) >= (sizeof (struct isp4fw_resp ))) { +memcpy ((u8 *)response, (u8 *)mem_sys + rd_ptr, +sizeof (struct isp4fw_resp )); + + rd_ptr +=sizeof (struct isp4fw_resp ); +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { +dev_err (dev,"(%u),rd %u(should<=%u),wr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + + }else { +dev_err (dev,"sth wrong with wptr and rptr\n" ); +return -EINVAL ; + } + }else if (rd_ptr > wr_ptr) { +u32 size; +u8 *dst; + + dst = (u8 *)response; + + size = len - rd_ptr; +if (size >sizeof (struct isp4fw_resp )) { + mem_addr += rd_ptr; +memcpy ((u8 *)response, + (u8 *)(mem_sys) + rd_ptr, +sizeof (struct isp4fw_resp )); + rd_ptr +=sizeof (struct isp4fw_resp ); +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { +dev_err (dev,"(%u),rd %u(should<=%u),wr %u\n" , + stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + + }else { +if ((size + wr_ptr) < (sizeof (struct isp4fw_resp ))) { +dev_err (dev,"sth wrong with wptr and rptr1\n" ); +return -EINVAL ; + } + +memcpy (dst, (u8 *)(mem_sys) + rd_ptr, size); + + dst += size; + size =sizeof (struct isp4fw_resp ) - size; +if (size) +memcpy (dst, (u8 *)(mem_sys), size); + rd_ptr = size; +if (rd_ptr < len) { +isp4hw_wreg (GET_ISP4IF_REG_BASE (ispif), + rreg, rd_ptr); + }else { + dev_err(dev, "(%u),rd %u(should<=%u),wr %u\n",
drivers/media/platform/amd/isp4/isp4_interface.c line 862
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ stream, rd_ptr, len, wr_ptr); +return -EINVAL ; + } + } + }else { +return -ETIME ; + } + + checksum =isp4if_compute_check_sum ((u8 *)response, + (sizeof (struct isp4fw_resp ) -4 ));
Redundant parentheses again.
drivers/media/platform/amd/isp4/isp4_interface.c line 872
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ +if (checksum != response->resp_check_sum) { +dev_err (dev,"resp checksum 0x%x,should 0x%x,rptr %u,wptr %u\n" , + checksum, response->resp_check_sum, + rd_ptr_dbg, wr_ptr_dbg); + +dev_err (dev,"(%u), seqNo %u, resp_id (0x%x)\n" , + stream, + response->resp_seq_num, + response->resp_id);
Fits on fewer lines.
drivers/media/platform/amd/isp4/isp4_interface.c line 883
Quoted 11 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +11
-0+ +return -EINVAL ; + } + +return 0 ; +} + +int isp4if_send_command (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size)
Ditto.
drivers/media/platform/amd/isp4/isp4_interface.c line 887
Quoted 4 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +4
-0+{ +return isp4if_send_fw_cmd (ispif, + cmd_id, package, + package_size,NULL ,NULL ,NULL );
Ditto.
drivers/media/platform/amd/isp4/isp4_interface.c line 894
Quoted 7 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +7
-0+} + +int isp4if_send_command_sync (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +u32 timeout)
Ditto.
drivers/media/platform/amd/isp4/isp4_interface.c line 903
Quoted 9 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +9
-0+{ +struct device *dev = ispif->dev; +DECLARE_WAIT_QUEUE_HEAD (cmd_wq); +u32 wq_cond =0 ; +int ret; +u32 seq; + + ret = isp4if_send_fw_cmd(ispif, + cmd_id, package,
Ditto.
drivers/media/platform/amd/isp4/isp4_interface.c line 913
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ package_size, &cmd_wq, &wq_cond, &seq); + +if (ret) { +dev_err (dev,"send fw cmd fail %d\n" , ret); +return ret; + } + + ret =wait_event_timeout (cmd_wq, wq_cond !=0 , +msecs_to_jiffies (timeout)); +
Extra newline.
drivers/media/platform/amd/isp4/isp4_interface.c line 914
Quoted 1 line
drivers/media/platform/amd/isp4/isp4_interface.c new file +1
-0+/* timeout occurred */
Redundant comment.
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+if (ret ==0 ) { +struct isp4if_cmd_element *ele; + + ele =isp4if_rm_cmd_from_cmdq (ispif, seq, cmd_id); +kfree (ele); +return -ETIMEDOUT ; + } + +return 0 ; +}
drivers/media/platform/amd/isp4/isp4_interface.c line 934
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ +void isp4if_clear_bufq (struct isp4_interface *ispif) +{ +struct isp4if_img_buf_node *buf_node =NULL ; +struct isp4if_img_buf_node *tmp_node =NULL ; + +guard (mutex)(&ispif->bufq_mutex); + +list_for_each_entry_safe (buf_node, tmp_node, &ispif->bufq, + node) {
Please rewrap.
Quoted 22 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +22
-0+list_del (&buf_node->node); +kfree (buf_node); + } +} + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node) +{ +kfree (buf_node); +} + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info) +{ +struct isp4if_img_buf_node *node =NULL ; + + node =kmalloc (sizeof (*node),GFP_KERNEL ); +if (node) + node->buf_info = *buf_info; + +return node; +}; +
drivers/media/platform/amd/isp4/isp4_interface.c line 966
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+struct isp4if_img_buf_node * +isp4if_dequeue_buffer (struct isp4_interface *ispif) +{ +struct isp4if_img_buf_node *buf_node =NULL ; + +guard (mutex)(&ispif->bufq_mutex); + + buf_node =list_first_entry_or_null (&ispif->bufq, +typeof (*buf_node), + node);
Ditto.
Quoted 37 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +37
-0+if (buf_node) +list_del (&buf_node->node); + +return buf_node; +} + +int isp4if_queue_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_node *buf_node) +{ +int ret; + + ret =isp4if_send_buffer (ispif, &buf_node->buf_info); +if (ret) +return ret; + +guard (mutex)(&ispif->bufq_mutex); + +list_add_tail (&buf_node->node, &ispif->bufq); + +return 0 ; +} + +int isp4if_stop (struct isp4_interface *ispif) +{ +isp4if_disable_ccpu (ispif); + +isp4if_dealloc_fw_gpumem (ispif); + +return 0 ; +} + +int isp4if_start (struct isp4_interface *ispif) +{ +int ret; + + ret =isp4if_alloc_fw_gpumem (ispif); +if (ret)
drivers/media/platform/amd/isp4/isp4_interface.c line 1013
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +10
-0+ goto failed_gpumem_alloc; + + ret =isp4if_fw_boot (ispif); +if (ret) + goto failed_fw_boot; + +return 0 ; + +failed_gpumem_alloc: +return -ENOMEM ;
No label needed for this.
Quoted 146 lines
drivers/media/platform/amd/isp4/isp4_interface.c new file +39
-0+ +failed_fw_boot: +isp4if_dealloc_fw_gpumem (ispif); +return ret; +} + +int isp4if_deinit (struct isp4_interface *ispif) +{ +isp4if_clear_cmdq (ispif); + +isp4if_clear_bufq (ispif); + +mutex_destroy (&ispif->cmdq_mutex); +mutex_destroy (&ispif->bufq_mutex); +mutex_destroy (&ispif->isp4if_mutex); + +return 0 ; +} + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, +void *amdgpu_dev,void __iomem *isp_mmip) +{ + ispif->dev = dev; + ispif->adev = amdgpu_dev; + ispif->mmio = isp_mmip; + + ispif->cmd_rb_base_index =0 ; + ispif->resp_rb_base_index =ISP4IF_RESP_CHAN_TO_RB_OFFSET -1 ; + ispif->aligned_rb_chunk_size =ISP4IF_RB_PMBMAP_MEM_CHUNK &0xffffffc0 ; + +mutex_init (&ispif->cmdq_mutex);/* used for cmdq access */ +mutex_init (&ispif->bufq_mutex);/* used for bufq access */ +mutex_init (&ispif->isp4if_mutex);/* used for commands sent to ispfw */ + +INIT_LIST_HEAD (&ispif->cmdq); +INIT_LIST_HEAD (&ispif->bufq); + +return 0 ; +}drivers/media/platform/amd/isp4/isp4_interface.h new file +101
-0@@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2025 Advanced Micro Devices, Inc. +*/ + +#ifndef _ISP4_INTERFACE_ +#define _ISP4_INTERFACE_ + +#define ISP4IF_RB_MAX (25) +#define ISP4IF_RESP_CHAN_TO_RB_OFFSET (9) +#define ISP4IF_RB_PMBMAP_MEM_SIZE (16 * 1024 * 1024 - 1) +#define ISP4IF_RB_PMBMAP_MEM_CHUNK (ISP4IF_RB_PMBMAP_MEM_SIZE \ + / (ISP4IF_RB_MAX - 1)) +#define ISP4IF_ISP_MC_ADDR_ALIGN (1024 * 32) +#define ISP4IF_HOST2FW_COMMAND_SIZE (sizeof(struct isp4fw_cmd)) +#define ISP4IF_FW_CMD_BUF_COUNT 4 +#define ISP4IF_FW_RESP_BUF_COUNT 4 +#define ISP4IF_MAX_NUM_HOST2FW_COMMAND (40) +#define ISP4IF_FW_CMD_BUF_SIZE (ISP4IF_MAX_NUM_HOST2FW_COMMAND \ + * ISP4IF_HOST2FW_COMMAND_SIZE) +#define ISP4IF_MAX_SLEEP_COUNT (10) +#define ISP4IF_MAX_SLEEP_TIME (33) + +#define ISP4IF_META_INFO_BUF_SIZE ALIGN(sizeof(struct isp4fw_meta_info), 0x8000) +#define ISP4IF_MAX_STREAM_META_BUF_COUNT 6 + +#define ISP4IF_FW_LOG_RINGBUF_SIZE (2 * 1024 * 1024) + +#define ISP4IF_MAX_CMD_RESPONSE_BUF_SIZE (4 * 1024) + +#define GET_ISP4IF_REG_BASE(ispif) (((ispif))->mmio) + +enum isp4if_stream_id { + ISP4IF_STREAM_ID_GLOBAL = 0, + ISP4IF_STREAM_ID_1 = 1, + ISP4IF_STREAM_ID_MAX = 4 +}; + +enum isp4if_status { + ISP4IF_STATUS_PWR_OFF, + ISP4IF_STATUS_PWR_ON, + ISP4IF_STATUS_FW_RUNNING, + ISP4IF_FSM_STATUS_MAX +}; + +struct isp4if_gpu_mem_info { + u32 mem_domain; + u64 mem_size; + u32 mem_align; + u64 gpu_mc_addr; + void *sys_addr; + void *mem_handle; +}; + +struct isp4if_img_buf_info { + struct { + void *sys_addr; + u64 mc_addr; + u32 len; + } planes[3]; +}; + +struct isp4if_img_buf_node { + struct list_head node; + struct isp4if_img_buf_info buf_info; +}; + +struct isp4if_cmd_element { + struct list_head list; + u32 seq_num; + u32 cmd_id; + enum isp4if_stream_id stream; + u64 mc_addr; + wait_queue_head_t *wq; + u32 *wq_cond; + struct isp4if_gpu_mem_info *gpu_pkg; +}; + +struct isp4_interface { + struct amdgpu_device *adev; + + struct device *dev; + void __iomem *mmio; + + struct mutex cmdq_mutex; /* used for cmdq access */ + struct mutex bufq_mutex; /* used for bufq access */ + struct mutex isp4if_mutex; /* used to send fw cmd and read fw log */ + + struct list_head cmdq; /* commands sent to fw */ + struct list_head bufq; /* buffers sent to fw */ + + enum isp4if_status status; + u32 host2fw_seq_num; + + /* FW ring buffer configs */ + u32 cmd_rb_base_index; + u32 resp_rb_base_index; + u32 aligned_rb_chunk_size; + + /* ISP fw buffers */ + struct isp4if_gpu_mem_info *fw_log_buf;
drivers/media/platform/amd/isp4/isp4_interface.h line 111
Quoted 10 lines
drivers/media/platform/amd/isp4/isp4_interface.h new file +10
-0+struct isp4if_gpu_mem_info *fw_cmd_resp_buf; +struct isp4if_gpu_mem_info *fw_mem_pool; +struct isp4if_gpu_mem_info * + metainfo_buf_pool[ISP4IF_MAX_STREAM_META_BUF_COUNT ]; +}; + +static inline void isp4if_split_addr64 (u64 addr,u32 *lo,u32 *hi) +{ +if (lo) + *lo = (u32)(addr &0xffffffff );
Redundant and and cast, too.
drivers/media/platform/amd/isp4/isp4_interface.h line 113
Quoted 2 lines
drivers/media/platform/amd/isp4/isp4_interface.h new file +2
-0+if (hi) + *hi = (u32)(addr >>32 );
Redundant cast.
Quoted 51 lines
drivers/media/platform/amd/isp4/isp4_interface.h new file +51
-0+} + +static inline u64 isp4if_join_addr64 (u32 lo,u32 hi) +{ +return (((u64 )hi) <<32 ) | (u64 )lo; +} + +int isp4if_f2h_resp (struct isp4_interface *ispif, +enum isp4if_stream_id stream, +void *response); + +int isp4if_send_command (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size); + +int isp4if_send_command_sync (struct isp4_interface *ispif, +u32 cmd_id, +void *package, +u32 package_size, +u32 timeout); + +struct isp4if_cmd_element * +isp4if_rm_cmd_from_cmdq (struct isp4_interface *ispif, +u32 seq_num, +u32 cmd_id); + +void isp4if_clear_cmdq (struct isp4_interface *ispif); + +void isp4if_clear_bufq (struct isp4_interface *ispif); + +void isp4if_dealloc_buffer_node (struct isp4if_img_buf_node *buf_node); + +struct isp4if_img_buf_node * +isp4if_alloc_buffer_node (struct isp4if_img_buf_info *buf_info); + +struct isp4if_img_buf_node *isp4if_dequeue_buffer (struct isp4_interface *ispif); + +int isp4if_queue_buffer (struct isp4_interface *ispif, +struct isp4if_img_buf_node *buf_node); + +int isp4if_stop (struct isp4_interface *ispif); + +int isp4if_start (struct isp4_interface *ispif); + +int isp4if_deinit (struct isp4_interface *ispif); + +int isp4if_init (struct isp4_interface *ispif,struct device *dev, +void *amdgpu_dev,void __iomem *isp_mmip); + +#endif
Signature · 3 lines
Kind regards, Sakari Ailus