DC Patches Jul 17, 2018
Subsystems (3)
cover DC Patches Jul 17, 2018
From: "Leo (Sunpeng) Li" <[email protected]>
Summary of change:
* De-midlayering work on AUX engine
* Fix S3 resume blackscreen for DCE10
* De-spamming of log for DCE10
Bhawanpreet Lakha (1):
drm/amd/display: Decouple aux from i2c
David Francis (1):
drm/amd/display: On dce100, set clocks to 0 on suspend
Harry Wentland (1):
drm/amd/display: dal 3.1.58
Jun Lei (1):
drm/amd/display: separate dc_debug into dc_debug_options and dc_debug
data
Mikita Lipski (1):
drm/amd/display: Remove unnecessary warning
Tony Cheng (1):
drm/amd/display: allow diags to skip initial link training
vikrant mhaske (1):
drm/amd/display: DPP CM ICSC AYCRCB8888 format support
drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 22 +- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 9 +- drivers/gpu/drm/amd/display/dc/dc.h | 22 +- drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 2 +- drivers/gpu/drm/amd/display/dc/dce/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 942 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_aux.h | 111 +++ drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | 4 +- .../amd/display/dc/dce100/dce100_hw_sequencer.c | 4 - .../drm/amd/display/dc/dce100/dce100_resource.c | 61 +- .../drm/amd/display/dc/dce110/dce110_resource.c | 45 + .../drm/amd/display/dc/dce112/dce112_resource.c | 47 + .../drm/amd/display/dc/dce120/dce120_resource.c | 44 +- .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 44 + drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 4 + .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 48 +- drivers/gpu/drm/amd/display/dc/i2caux/engine.h | 1 + drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +- drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h | 2 +- drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h | 113 +++ drivers/gpu/drm/amd/display/dc/inc/hw/engine.h | 106 +++ 23 files changed, 1598 insertions(+), 41 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/engine.h
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1531834174-4052-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org
PATCH 1/7 drm/amd/display: Remove unnecessary warning
From: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have a pix_clk set to zero, when there is no display connected.
[how]
remove the assert
--- drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0 -4
@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 ); -return max_pix_clk; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1531834174-4052-2-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/7] drm/amd/display: Remove unnecessary warning
Quoted 23 lines · On 2018-07-17 03:29 PM, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have apix_clkset to zero, when there is no display connected.
[how]
remove the assertChange-Id I4ca1e42439369b2305694b403457b5de60fc4ab1Signed-off-by Mikita Lipski <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-0
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c static uint32_t get_max_pixel_clock_for_all_paths( · line 154
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-4@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 ); -return max_pix_clk; }
On my development system, max_pix_clk == 0 even though there's a display connected via HDMI. Is that expected as well?
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 9387462a-e9d8-8270-d421-5bcacc27beec-otUistvHUpPR7s880joybQ@public.gmane.org
Re: [PATCH 1/7] drm/amd/display: Remove unnecessary warning
Quoted 29 lines · Michel Dänzer
Quoted 28 lines · On 2018-07-17 03:29 PM, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have apix_clkset to zero, when there is no display connected.
[how]
remove the assertChange-Id I4ca1e42439369b2305694b403457b5de60fc4ab1Signed-off-by Mikita Lipski <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-3@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 );
Quoted 9 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c static uint32_t get_max_pixel_clock_for_all_paths( · line 154
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-1-return max_pix_clk; }On my development system,
max_pix_clk== 0 even though there's a display connected via HDMI. Is that expected as well?
It's not really expected. Does it happen on mode set, hotplug, randomly? Do you have a stack trace?
Harry
Quoted 1 line
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 79ca3d0a-6309-18dd-bdf8-8ca474e5b9ca-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 1/7] drm/amd/display: Remove unnecessary warning
Quoted 40 lines · Harry Wentland
Quoted 29 lines · Michel Dänzer
Quoted 28 lines · On 2018-07-17 03:29 PM, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have apix_clkset to zero, when there is no display connected.
[how]
remove the assertChange-Id I4ca1e42439369b2305694b403457b5de60fc4ab1Signed-off-by Mikita Lipski <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-3@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 );Quoted 9 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c static uint32_t get_max_pixel_clock_for_all_paths( · line 154
Quoted 5 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-1-return max_pix_clk; }On my development system,
max_pix_clk== 0 even though there's a display connected via HDMI. Is that expected as well?
Quoted 1 line
It's not really expected. Does it happen on mode set, hotplug, randomly?
Seems to happen when the display is turned off, e.g. via DPMS.
Quoted 1 line
Do you have a stack trace?
Yep, attached.
Signature · 2 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer
[ 2367.329074] WARNING: CPU: 8 PID: 16019 at drivers/gpu/drm//amd/amdgpu/../display/dc/dce100/dce100_hw_sequencer.c:154 dce100_set_bandwidth+0x154/0x300 [amdgpu] [ 2367.329086] Modules linked in: lz4(E) lz4_compress(E) cpufreq_powersave(E) cpufreq_userspace(E) cpufreq_conservative(E) binfmt_misc(E) nls_ascii(E) nls_cp437(E) vfat(E) edac_mce_amd(E) fat(E) amdkfd(OE) kvm(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) ghash_clmulni_intel(E) pcbc(E) radeon(OE) wmi_bmof(E) amdgpu(OE) snd_hda_codec_realtek(E) snd_hda_codec_generic(E) chash(OE) gpu_sched(OE) snd_hda_codec_hdmi(E) ttm(OE) aesni_intel(E) aes_x86_64(E) crypto_simd(E) drm_kms_helper(OE) cryptd(E) snd_hda_intel(E) efi_pstore(E) glue_helper(E) r8169(E) pcspkr(E) snd_hda_codec(E) drm(OE) mii(E) snd_hda_core(E) efivars(E) sg(E) i2c_algo_bit(E) snd_hwdep(E) fb_sys_fops(E) syscopyarea(E) snd_pcm(E) sysfillrect(E) sp5100_tco(E) snd_timer(E) sysimgblt(E) i2c_piix4(E) k10temp(E) wmi(E) ccp(E) snd(E) soundcore(E) [ 2367.329232] rng_core(E) button(E) acpi_cpufreq(E) tcp_bbr(E) sch_fq(E) nct6775(E) hwmon_vid(E) sunrpc(E) efivarfs(E) ip_tables(E) x_tables(E) ext4(E) crc32c_generic(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) dm_mod(E) raid10(E) raid1(E) raid0(E) multipath(E) linear(E) md_mod(E) sd_mod(E) evdev(E) hid_generic(E) usbhid(E) hid(E) ahci(E) xhci_pci(E) libahci(E) xhci_hcd(E) libata(E) crc32c_intel(E) usbcore(E) scsi_mod(E) gpio_amdpt(E) gpio_generic(E) [ 2367.329337] CPU: 8 PID: 16019 Comm: Xorg Tainted: G W OE 4.18.0-rc1+ #110 [ 2367.329344] Hardware name: Micro-Star International Co., Ltd. MS-7A34/B350 TOMAHAWK (MS-7A34), BIOS 1.80 09/13/2017 [ 2367.329532] RIP: 0010:dce100_set_bandwidth+0x154/0x300 [amdgpu] [ 2367.329538] Code: 84 c0 74 08 3c 03 0f 8e 7d 01 00 00 8b 83 10 01 00 00 41 39 c6 44 0f 42 f0 48 81 c3 30 04 00 00 48 39 d3 75 90 45 85 f6 75 02 <0f> 0b 49 8d 9d 48 01 00 00 48 b8 00 00 00 00 00 fc ff df 44 89 74 [ 2367.329663] RSP: 0018:ffff88028cc2f338 EFLAGS: 00010246 [ 2367.329672] RAX: 1ffff1007b1652d0 RBX: ffff8803d8b29ab0 RCX: 0000000000000000 [ 2367.329678] RDX: ffff8803d8b29ab0 RSI: 0000000000000000 RDI: ffff8803d8b29c5c [ 2367.329684] RBP: dffffc0000000000 R08: ffffed007a55d632 R09: ffffed007a55d632 [ 2367.329690] R10: ffff88028cc2f140 R11: ffffed007a55d631 R12: 1ffff10051985e69 [ 2367.329695] R13: ffff8803c8bee600 R14: 0000000000000000 R15: ffff8803d8b28000 [ 2367.329703] FS: 00007f3ad605f940(0000) GS:ffff8803ee200000(0000) knlGS:0000000000000000 [ 2367.329709] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 2367.329714] CR2: 000055720e2bb560 CR3: 00000003c1418000 CR4: 00000000003406e0 [ 2367.329720] Call Trace: [ 2367.329882] ? dce100_pplib_apply_display_requirements+0x1b0/0x1b0 [amdgpu] [ 2367.330041] ? bios_is_accelerated_mode+0xdb/0x140 [amdgpu] [ 2367.330201] dc_commit_state+0xd1e/0x1520 [amdgpu] [ 2367.330364] ? dc_destroy+0x90/0x90 [amdgpu] [ 2367.330403] ? drm_dev_dbg+0x1a0/0x1a0 [drm] [ 2367.330571] amdgpu_dm_atomic_commit_tail+0x968/0x3fa0 [amdgpu] [ 2367.330592] ? do_raw_spin_unlock+0x54/0x220 [ 2367.330602] ? _raw_spin_unlock_irq+0x29/0x40 [ 2367.330751] ? amdgpu_dm_do_flip+0xab0/0xab0 [amdgpu] [ 2367.330774] ? drm_atomic_helper_swap_state+0x7a2/0x15b0 [drm_kms_helper] [ 2367.330784] ? wait_for_completion_io_timeout+0x390/0x390 [ 2367.330793] ? lock_downgrade+0x5e0/0x5e0 [ 2367.330815] ? drm_atomic_helper_swap_state+0x6b5/0x15b0 [drm_kms_helper] [ 2367.330964] ? dm_plane_helper_prepare_fb+0x291/0xb00 [amdgpu] [ 2367.330990] ? drm_atomic_helper_wait_for_dependencies+0x3ee/0x7d0 [drm_kms_helper] [ 2367.331017] commit_tail+0x9a/0xf0 [drm_kms_helper] [ 2367.331041] drm_atomic_helper_commit+0x179/0x240 [drm_kms_helper] [ 2367.331086] drm_atomic_connector_commit_dpms+0x311/0x490 [drm] [ 2367.331097] ? ww_mutex_lock+0x34/0xa0 [ 2367.331138] ? drm_modeset_backoff+0x1b1/0x4f0 [drm] [ 2367.331181] set_property_atomic+0x1ad/0x2b0 [drm] [ 2367.331224] ? drm_object_property_get_value+0xf0/0xf0 [drm] [ 2367.331277] drm_mode_obj_set_property_ioctl+0x371/0x590 [drm] [ 2367.331318] ? drm_mode_obj_find_prop_id+0x180/0x180 [drm] [ 2367.331362] ? drm_mode_connector_set_obj_prop+0x150/0x150 [drm] [ 2367.331401] drm_mode_connector_property_set_ioctl+0xe8/0x170 [drm] [ 2367.331441] ? drm_mode_connector_set_obj_prop+0x150/0x150 [drm] [ 2367.331475] ? drm_is_current_master+0x5f/0x110 [drm] [ 2367.331510] ? drm_ioctl_permit+0x148/0x190 [drm] [ 2367.331545] drm_ioctl_kernel+0x197/0x220 [drm] [ 2367.331582] ? drm_setversion+0x7d0/0x7d0 [drm] [ 2367.331594] ? __check_object_size+0x149/0x360 [ 2367.331631] drm_ioctl+0x60a/0x970 [drm] [ 2367.331672] ? drm_mode_connector_set_obj_prop+0x150/0x150 [drm] [ 2367.331708] ? drm_ioctl_kernel+0x220/0x220 [drm] [ 2367.331723] ? lock_downgrade+0x5e0/0x5e0 [ 2367.331732] ? __pm_runtime_resume+0x79/0x100 [ 2367.331742] ? debug_check_no_locks_freed+0x2c0/0x2c0 [ 2367.331751] ? do_raw_spin_unlock+0x54/0x220 [ 2367.331867] amdgpu_drm_ioctl+0xcc/0x1a0 [amdgpu] [ 2367.331880] do_vfs_ioctl+0x192/0xf30 [ 2367.331889] ? __kasan_slab_free+0x145/0x180 [ 2367.331899] ? ioctl_preallocate+0x1b0/0x1b0 [ 2367.331909] ? __fget+0x1c8/0x300 [ 2367.331919] ? lock_downgrade+0x5e0/0x5e0 [ 2367.331927] ? __fget+0x49/0x300 [ 2367.331940] ? __fget+0x1e0/0x300 [ 2367.331955] ksys_ioctl+0x70/0x80 [ 2367.331966] __x64_sys_ioctl+0x6f/0xb0 [ 2367.331975] do_syscall_64+0xa5/0x3f0 [ 2367.331985] entry_SYSCALL_64_after_hwframe+0x49/0xbe [ 2367.331994] RIP: 0033:0x7f3ad700c097 [ 2367.331998] Code: b3 66 90 48 8b 05 f1 7d 0c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d c1 7d 0c 00 f7 d8 64 89 01 48 [ 2367.332123] RSP: 002b:00007fff0a5fe478 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 2367.332133] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f3ad700c097 [ 2367.332139] RDX: 00007fff0a5fe4b0 RSI: 00000000c01064ab RDI: 000000000000000d [ 2367.332144] RBP: 00007fff0a5fe4a0 R08: 00007fff0a5fe438 R09: 00007fff0a5fe434 [ 2367.332150] R10: 00007fff0a5fe340 R11: 0000000000000246 R12: 00007fff0a5fe4b0 [ 2367.332156] R13: 00000000c01064ab R14: 000000000000000d R15: 000055720f3058f0 [ 2367.332171] irq event stamp: 0 [ 2367.332178] hardirqs last enabled at (0): [<0000000000000000>] (null) [ 2367.332189] hardirqs last disabled at (0): [<ffffffff8411642c>] copy_process.part.32+0x109c/0x60d0 [ 2367.332198] softirqs last enabled at (0): [<ffffffff841164ca>] copy_process.part.32+0x113a/0x60d0 [ 2367.332204] softirqs last disabled at (0): [<0000000000000000>] (null)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 34b91034-9847-2fc8-0bad-aacf599c3078-otUistvHUpPR7s880joybQ@public.gmane.org
Re: [PATCH 1/7] drm/amd/display: Remove unnecessary warning
Quoted 41 lines · Michel Dänzer
Quoted 40 lines · Harry Wentland
Quoted 38 lines · Michel Dänzer
Quoted 23 lines · On 2018-07-17 03:29 PM, [email protected] wrote:
From: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have apix_clkset to zero, when there is no display connected.
[how]
remove the assertChange-Id I4ca1e42439369b2305694b403457b5de60fc4ab1Signed-off-by Mikita Lipski <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-0drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c static uint32_t get_max_pixel_clock_for_all_paths( · line 154
Quoted 10 lines
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0
-4@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 ); -return max_pix_clk; }On my development system,
max_pix_clk== 0 even though there's a display connected via HDMI. Is that expected as well?
Quoted 9 lines
Quoted 1 line
It's not really expected. Does it happen on mode set, hotplug, randomly?
Seems to happen when the display is turned off, e.g. via DPMS.
Quoted 1 line
Do you have a stack trace?
Yep, attached.
Thanks. It makes sense now. DPMS will turn off all displays and hit the same codepath.
Leo, Nick, please update the commit message to say "when no pipes are active" or something similar instead of "when there is no display connected".
Harry
Quoted 1 line
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH v2 1/7 drm/amd/display: Remove unnecessary warning
In reply to a message not in the archiveFrom: Mikita Lipski <[email protected]>
[why]
The warning message floods the dmesg log on Tonga even though it is expected to have a pix_clk set to zero, when the pipe is not active.
[how]
remove the assert
---
v2: Change 'when there is no display connected' > 'when the pipe is not active'
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dce100/dce100_hw_sequencer.c +0 -4
@@ -149,10 +149,6 @@ static uint32_t get_max_pixel_clock_for_all_paths( max_pix_clk = pipe_ctx->stream_res.pix_clk_params.requested_pix_clk; } - -if (max_pix_clk ==0 ) -ASSERT (0 ); -return max_pix_clk; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/7 drm/amd/display: allow diags to skip initial link training
In reply to a message not in the archiveFrom: Tony Cheng <[email protected]>
[why]
diag specify what the full config and is only concerned about pass/fail at the end
having inter-op code like verifiying we can actually train at reported link rate slows down diag test and add complexity we don't need
[how]
add dc_debug option to skip capability link trianing
also remove hbr in function name as verify is not specific to hbr
--- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 7 ++++++- drivers/gpu/drm/amd/display/dc/dc.h | 1 + drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +1 -1
@@ -760,7 +760,7 @@ bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason)*/ /* deal with non-mst cases */ -dp_hbr_verify_link_cap (link, &link->reported_link_cap); +dp_verify_link_cap (link, &link->reported_link_cap); }/* HDMI-DVI Dongle */
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +6 -1
@@ -1086,7 +1086,7 @@ static struct dc_link_settings get_max_link_cap(struct dc_link *link)return max_link_cap; } -bool dp_hbr_verify_link_cap ( +bool dp_verify_link_cap (struct dc_link *link,struct dc_link_settings *known_limit_link_setting) {
@@ -1101,6 +1101,11 @@ bool dp_hbr_verify_link_cap(enum clock_source_id dp_cs_id =CLOCK_SOURCE_ID_EXTERNAL ;enum link_training_result status; +if (link->dc->debug.skip_detection_link_training) { + link->verified_link_cap = *known_limit_link_setting; +return true; + } + success = false; skip_link_training = false;
drivers/gpu/drm/amd/display/dc/dc.h +1 -0
@@ -258,6 +258,7 @@ struct dc_debug {bool avoid_vbios_exec_table;bool scl_reset_length10;bool hdmi20_disable; +bool skip_detection_link_training;struct {uint32_t ltFailCount;
drivers/gpu/drm/amd/display/dc/inc/dc_link_dp.h +1 -1
@@ -33,7 +33,7 @@ struct dc_link;struct dc_stream_state ;struct dc_link_settings ; -bool dp_hbr_verify_link_cap ( +bool dp_verify_link_cap (struct dc_link *link,struct dc_link_settings *known_limit_link_setting);
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/7 drm/amd/display: On dce100, set clocks to 0 on suspend
In reply to a message not in the archiveFrom: David Francis <[email protected]>
[Why]
When a dce100 asic was suspended, the clocks were not set to 0. Upon resume, the new clock was compared to the existing clock, they were found to be the same, and so the clock was not set. This resulted in a pernicious blackscreen.
[How]
In atomic commit, check to see if there are any active pipes. If no, set clocks to 0
--- .../gpu/drm/amd/display/dc/dce100/dce100_resource.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +16 -3
@@ -678,9 +678,22 @@ bool dce100_validate_bandwidth(struct dc *dc, struct dc_state *context) { -/* TODO implement when needed but for now hardcode max value*/ - context->bw.dce.dispclk_khz = 681000; - context->bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER ; + int i; +bool at_least_one_pipe = false; + +for (i =0 ; i < dc->res_pool->pipe_count; i++) { +if (context->res_ctx.pipe_ctx[i].stream) + at_least_one_pipe = true; + } + +if (at_least_one_pipe) { +/* TODO implement when needed but for now hardcode max value*/ + context->bw.dce.dispclk_khz =681000 ; + context->bw.dce.yclk_khz =250000 *MEMORY_TYPE_MULTIPLIER ; + }else { + context->bw.dce.dispclk_khz =0 ; + context->bw.dce.yclk_khz =0 ; + }return true; }
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/7 drm/amd/display: DPP CM ICSC AYCRCB8888 format support
In reply to a message not in the archiveFrom: vikrant mhaske <[email protected]>
[why]
Diags has POR to run the video workload using AYCRCB8888 through DCN; capture it through DWB and send it to VCN hardware to encode
[how]
added the code to support this format so that DPP ICSC will be able to convert it from YUV444 to internal RGB and DWB OCSC will be able to convert from internal RGB to YUV420
--- drivers/gpu/drm/amd/display/dc/dc_hw_types.h | 2 +- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc_hw_types.h +1 -1
@@ -192,7 +192,7 @@ enum surface_pixel_format {/*swaped & float*/ SURFACE_PIXEL_FORMAT_GRPH_ABGR16161616F ,/*grow graphics here if necessary */ - + SURFACE_PIXEL_FORMAT_VIDEO_AYCrCb8888,SURFACE_PIXEL_FORMAT_VIDEO_BEGIN , SURFACE_PIXEL_FORMAT_VIDEO_420_YCbCr = SURFACE_PIXEL_FORMAT_VIDEO_BEGIN,
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c +4 -0
@@ -294,6 +294,10 @@ void hubp1_program_pixel_format(REG_UPDATE (DCSURF_SURFACE_CONFIG ,SURFACE_PIXEL_FORMAT ,66 );break ; +case SURFACE_PIXEL_FORMAT_VIDEO_AYCrCb8888: +REG_UPDATE (DCSURF_SURFACE_CONFIG , +SURFACE_PIXEL_FORMAT ,12 ); +break ;default :BREAK_TO_DEBUGGER ();break ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 5/7 drm/amd/display: Decouple aux from i2c
In reply to a message not in the archiveFrom: Bhawanpreet Lakha <[email protected]>
[Why]
Aux engine is created from i2caux layer. We want to remove this layer and use the engine directly.
[How]
Decouple aux engine from i2caux. Move aux engine related code to dce folder and use dc resource pool to manage the engine. And use the engine functions directly
--- drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 22 +- drivers/gpu/drm/amd/display/dc/dce/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 942 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_aux.h | 111 +++ .../drm/amd/display/dc/dce100/dce100_resource.c | 42 + .../drm/amd/display/dc/dce110/dce110_resource.c | 45 + .../drm/amd/display/dc/dce112/dce112_resource.c | 47 + .../drm/amd/display/dc/dce120/dce120_resource.c | 42 + .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 44 + .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 44 + drivers/gpu/drm/amd/display/dc/i2caux/engine.h | 1 + drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +- drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h | 113 +++ drivers/gpu/drm/amd/display/dc/inc/hw/engine.h | 106 +++ 14 files changed, 1549 insertions(+), 14 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/engine.h
drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +10 -12
@@ -33,10 +33,8 @@#include "include/vector.h" #include "core_types.h" #include "dc_link_ddc.h" -#include "i2caux/engine.h" -#include "i2caux/i2c_engine.h" -#include "i2caux/aux_engine.h" -#include "i2caux/i2caux.h" +#include "engine.h" +#include "aux_engine.h" #define AUX_POWER_UP_WA_DELAY 500#define I2C_OVER_AUX_DEFER_WA_DELAY 70
@@ -641,9 +639,9 @@ int dc_link_aux_transfer(struct ddc_service *ddc,enum aux_transaction_type type, enum i2caux_transaction_action action) { - struct i2caux *i2caux = ddc->ctx->i2caux; struct ddc *ddc_pin = ddc->ddc_pin; -struct aux_engine *engine; +struct engine *engine; +struct aux_engine *aux_engine;enum aux_channel_operation_result operation_result;struct aux_request_transaction_data aux_req;struct aux_reply_transaction_data aux_rep;
@@ -654,7 +652,8 @@ int dc_link_aux_transfer(struct ddc_service *ddc,memset (&aux_req,0 ,sizeof (aux_req));memset (&aux_rep,0 ,sizeof (aux_rep)); - engine = i2caux->funcs->acquire_aux_engine (i2caux, ddc_pin); + engine = ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]; + aux_engine = engine->funcs->acquire (engine, ddc_pin); aux_req.type = type; aux_req.action = action;
@@ -664,15 +663,15 @@ int dc_link_aux_transfer(struct ddc_service *ddc, aux_req.length = size; aux_req.data = buffer; - engine->funcs->submit_channel_request (engine, &aux_req); - operation_result = engine->funcs->get_channel_status (engine, &returned_bytes); + aux_engine->funcs->submit_channel_request (aux_engine, &aux_req); + operation_result = aux_engine->funcs->get_channel_status (aux_engine, &returned_bytes);switch (operation_result) {case AUX_CHANNEL_OPERATION_SUCCEEDED : res = returned_bytes;if (res <= size && res >=0 ) - res = engine->funcs->read_channel_reply (engine, size, + res = aux_engine->funcs->read_channel_reply (aux_engine, size, buffer, reply, &status);
@@ -686,8 +685,7 @@ int dc_link_aux_transfer(struct ddc_service *ddc, res =-1 ;break ; } - - i2caux->funcs->release_engine (i2caux, &engine->base); + aux_engine->base.funcs->release_engine (&aux_engine->base);return res; }
drivers/gpu/drm/amd/display/dc/dce/Makefile +1 -1
@@ -28,7 +28,7 @@ DCE = dce_audio.o dce_stream_encoder.o dce_link_encoder.o dce_hwseq.o \ dce_mem_input.o dce_clock_source.o dce_scl_filters.o dce_transform.o \ -dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o +dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o dce_aux.o AMD_DAL_DCE = $(addprefix $(AMDDALPATH)/dc/dce/,$(DCE))
drivers/gpu/drm/amd/display/dc/dce/dce_aux.c new file +942 -0
942 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce/dce_aux.h new file +111 -0
111 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +42 -0
73 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +45 -0
75 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +47 -0
83 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +42 -0
72 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +44 -0
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +44 -0
74 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/i2caux/engine.h +1 -0
@@ -96,6 +96,7 @@ struct engine_funcs {struct engine {const struct engine_funcs *funcs; +uint32_t inst;struct ddc *ddc;struct dc_context *ctx; };
drivers/gpu/drm/amd/display/dc/inc/core_types.h +1 -1
@@ -138,7 +138,7 @@ struct resource_pool {struct output_pixel_processor *opps[MAX_PIPES ];struct timing_generator *timing_generators[MAX_PIPES ];struct stream_encoder *stream_enc[MAX_PIPES *2 ]; - +struct engine *engines[MAX_PIPES ];struct hubbub *hubbub;struct mpc *mpc;struct pp_smu_funcs_rv *pp_smu;
drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h new file +113 -0
113 lines not on this page · raw message
drivers/gpu/drm/amd/display/dc/inc/hw/engine.h new file +106 -0
106 lines not on this page · raw message
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1531834174-4052-6-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 5/7] drm/amd/display: Decouple aux from i2c
Quoted 10 lines · On Tue, Jul 17, 2018 at 9:29 AM, <[email protected]> wrote:
From: Bhawanpreet Lakha <[email protected]>
[Why]
Aux engine is created from i2caux layer. We want to remove this layer and use the engine directly.[How]
Decouple aux engine from i2caux. Move aux engine related code to dce folder and use dc resource pool to manage the engine. And use the engine functions directly
Don't i2c and aux share the same physical pins? If so, do you have appropriate locking to arbitrate access to the pins from either engine?
Alex
Quoted 1,936 lines
Change-Id Iecb609fe815dab31ed6b6100916c4b49ed6539a0Signed-off-by Bhawanpreet Lakha <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 22 +- drivers/gpu/drm/amd/display/dc/dce/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 942 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_aux.h | 111 +++ .../drm/amd/display/dc/dce100/dce100_resource.c | 42 + .../drm/amd/display/dc/dce110/dce110_resource.c | 45 + .../drm/amd/display/dc/dce112/dce112_resource.c | 47 + .../drm/amd/display/dc/dce120/dce120_resource.c | 42 + .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 44 + .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 44 + drivers/gpu/drm/amd/display/dc/i2caux/engine.h | 1 + drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +- drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h | 113 +++ drivers/gpu/drm/amd/display/dc/inc/hw/engine.h | 106 +++ 14 files changed, 1549 insertions(+), 14 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/engine.hdrivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +10
-12@@ -33,10 +33,8 @@#include "include/vector.h" #include "core_types.h" #include "dc_link_ddc.h" -#include "i2caux/engine.h" -#include "i2caux/i2c_engine.h" -#include "i2caux/aux_engine.h" -#include "i2caux/i2caux.h" +#include "engine.h" +#include "aux_engine.h" #define AUX_POWER_UP_WA_DELAY 500#define I2C_OVER_AUX_DEFER_WA_DELAY 70@@ -641,9 +639,9 @@ int dc_link_aux_transfer(struct ddc_service *ddc,enum aux_transaction_type type, enum i2caux_transaction_action action) { - struct i2caux *i2caux = ddc->ctx->i2caux; struct ddc *ddc_pin = ddc->ddc_pin; -struct aux_engine *engine; +struct engine *engine; +struct aux_engine *aux_engine;enum aux_channel_operation_result operation_result;struct aux_request_transaction_data aux_req;struct aux_reply_transaction_data aux_rep;@@ -654,7 +652,8 @@ int dc_link_aux_transfer(struct ddc_service *ddc,memset (&aux_req,0 ,sizeof (aux_req));memset (&aux_rep,0 ,sizeof (aux_rep)); - engine = i2caux->funcs->acquire_aux_engine (i2caux, ddc_pin); + engine = ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]; + aux_engine = engine->funcs->acquire (engine, ddc_pin); aux_req.type = type; aux_req.action = action;@@ -664,15 +663,15 @@ int dc_link_aux_transfer(struct ddc_service *ddc, aux_req.length = size; aux_req.data = buffer; - engine->funcs->submit_channel_request (engine, &aux_req); - operation_result = engine->funcs->get_channel_status (engine, &returned_bytes); + aux_engine->funcs->submit_channel_request (aux_engine, &aux_req); + operation_result = aux_engine->funcs->get_channel_status (aux_engine, &returned_bytes);switch (operation_result) {case AUX_CHANNEL_OPERATION_SUCCEEDED : res = returned_bytes;if (res <= size && res >=0 ) - res = engine->funcs->read_channel_reply (engine, size, + res = aux_engine->funcs->read_channel_reply (aux_engine, size, buffer, reply, &status);@@ -686,8 +685,7 @@ int dc_link_aux_transfer(struct ddc_service *ddc, res =-1 ;break ; } - - i2caux->funcs->release_engine (i2caux, &engine->base); + aux_engine->base.funcs->release_engine (&aux_engine->base);return res; }drivers/gpu/drm/amd/display/dc/dce/Makefile +1
-1@@ -28,7 +28,7 @@ DCE = dce_audio.o dce_stream_encoder.o dce_link_encoder.o dce_hwseq.o \ dce_mem_input.o dce_clock_source.o dce_scl_filters.o dce_transform.o \ -dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o +dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o dce_aux.o AMD_DAL_DCE = $(addprefix $(AMDDALPATH)/dc/dce/,$(DCE))drivers/gpu/drm/amd/display/dc/dce/dce_aux.c new file +942
-0@@ -0,0 +1,942 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#include "dm_services.h" +#include "dce_aux.h" +#include "dce/dce_11_0_sh_mask.h" + +#define CTX \ + aux110->base.base.ctx +#define REG (reg_name)\ + (aux110->regs->reg_name) + +#define DC_LOGGER \ + engine->base.ctx->logger + +#include "reg_helper.h" + +#define FROM_AUX_ENGINE (ptr) \ + container_of((ptr), struct aux_engine_dce110, base) + +#define FROM_ENGINE (ptr) \ + FROM_AUX_ENGINE(container_of((ptr), struct aux_engine, base)) + +#define FROM_AUX_ENGINE_ENGINE (ptr) \ + container_of((ptr), struct aux_engine, base) +enum { +AUX_INVALID_REPLY_RETRY_COUNTER =1 , +AUX_TIMED_OUT_RETRY_COUNTER =2 , +AUX_DEFER_RETRY_COUNTER =6 +}; +static void release_engine ( +struct engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_ENGINE (engine); + +dal_ddc_close (engine->ddc); + + engine->ddc =NULL ; + +REG_UPDATE (AUX_ARB_CONTROL ,AUX_SW_DONE_USING_AUX_REG ,1 ); +} + +#define SW_CAN_ACCESS_AUX 1 +#define DMCU_CAN_ACCESS_AUX 2 + +static bool is_engine_available ( +struct aux_engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value =REG_READ (AUX_ARB_CONTROL ); +uint32_t field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); + +return (field !=DMCU_CAN_ACCESS_AUX ); +} +static bool acquire_engine ( +struct aux_engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value =REG_READ (AUX_ARB_CONTROL ); +uint32_t field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); +if (field ==DMCU_CAN_ACCESS_AUX ) +return false; +/* enable AUX before request SW to access AUX */ + value =REG_READ (AUX_CONTROL ); + field =get_reg_field_value (value, +AUX_CONTROL , +AUX_EN ); + +if (field ==0 ) { +set_reg_field_value ( + value, +1 , +AUX_CONTROL , +AUX_EN ); + +if (REG (AUX_RESET_MASK )) { +/*DP_AUX block as part of the enable sequence*/ +set_reg_field_value ( + value, +1 , +AUX_CONTROL , +AUX_RESET ); + } + +REG_WRITE (AUX_CONTROL , value); + +if (REG (AUX_RESET_MASK )) { +/*poll HW to make sure reset it done*/ + +REG_WAIT (AUX_CONTROL ,AUX_RESET_DONE ,1 , +1 ,11 ); + +set_reg_field_value ( + value, +0 , +AUX_CONTROL , +AUX_RESET ); + +REG_WRITE (AUX_CONTROL , value); + +REG_WAIT (AUX_CONTROL ,AUX_RESET_DONE ,0 , +1 ,11 ); + } + }/*if (field)*/ + +/* request SW to access AUX */ +REG_UPDATE (AUX_ARB_CONTROL ,AUX_SW_USE_AUX_REG_REQ ,1 ); + + value =REG_READ (AUX_ARB_CONTROL ); + field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); + +return (field ==SW_CAN_ACCESS_AUX ); +} + +#define COMPOSE_AUX_SW_DATA_16_20 (command, address) \ + ((command) | ((0xF0000 & (address)) >> 16)) + +#define COMPOSE_AUX_SW_DATA_8_15 (address) \ + ((0xFF00 & (address)) >> 8) + +#define COMPOSE_AUX_SW_DATA_0_7 (address) \ + (0xFF & (address)) + +static void submit_channel_request ( +struct aux_engine *engine, +struct aux_request_transaction_data *request) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); +uint32_t value; +uint32_t length; + +bool is_write = + ((request->type ==AUX_TRANSACTION_TYPE_DP ) && + (request->action ==I2CAUX_TRANSACTION_ACTION_DP_WRITE )) || + ((request->type ==AUX_TRANSACTION_TYPE_I2C ) && + ((request->action ==I2CAUX_TRANSACTION_ACTION_I2C_WRITE ) || + (request->action ==I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT ))); +if (REG (AUXN_IMPCAL )) { +/* clear_aux_error */ +REG_UPDATE_SEQ (AUXN_IMPCAL ,AUXN_CALOUT_ERROR_AK , +1 , +0 ); + +REG_UPDATE_SEQ (AUXP_IMPCAL ,AUXP_CALOUT_ERROR_AK , +1 , +0 ); + +/* force_default_calibrate */ +REG_UPDATE_1BY1_2 (AUXN_IMPCAL , +AUXN_IMPCAL_ENABLE ,1 , +AUXN_IMPCAL_OVERRIDE_ENABLE ,0 ); + +/* bug? why AUXN update EN and OVERRIDE_EN 1 by 1 while AUX P toggles OVERRIDE? */ + +REG_UPDATE_SEQ (AUXP_IMPCAL ,AUXP_IMPCAL_OVERRIDE_ENABLE , +1 , +0 ); + } +/* set the delay and the number of bytes to write */ + +/* The length include +* the 4 bit header and the 20 bit address +* (that is 3 byte). +* If the requested length is non zero this means +* an addition byte specifying the length is required. +*/ + + length = request->length ?4 :3 ; +if (is_write) + length += request->length; + +REG_UPDATE_2 (AUX_SW_CONTROL , +AUX_SW_START_DELAY , request->delay, +AUX_SW_WR_BYTES , length); + +/* program action and address and payload data (if 'is_write') */ + value =REG_UPDATE_4 (AUX_SW_DATA , +AUX_SW_INDEX ,0 , +AUX_SW_DATA_RW ,0 , +AUX_SW_AUTOINCREMENT_DISABLE ,1 , +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_16_20 (request->action, request->address)); + + value =REG_SET_2 (AUX_SW_DATA , value, +AUX_SW_AUTOINCREMENT_DISABLE ,0 , +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_8_15 (request->address)); + + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_0_7 (request->address)); + +if (request->length) { + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA , request->length -1 ); + } + +if (is_write) { +/* Load the HW buffer with the Data to be sent. +* This is relevant for write operation. +* For read, the data recived data will be +* processed in process_channel_reply(). +*/ +uint32_t i =0 ; + +while (i < request->length) { + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA , request->data[i]); + + ++i; + } + } + +REG_UPDATE (AUX_INTERRUPT_CONTROL ,AUX_SW_DONE_ACK ,1 ); +REG_WAIT (AUX_SW_STATUS ,AUX_SW_DONE ,0 , +10 , aux110->timeout_period/10 ); +REG_UPDATE (AUX_SW_CONTROL ,AUX_SW_GO ,1 ); +} + +static int read_channel_reply (struct aux_engine *engine,uint32_t size, +uint8_t *buffer,uint8_t *reply_result, +uint32_t *sw_status) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); +uint32_t bytes_replied; +uint32_t reply_result_32; + + *sw_status =REG_GET (AUX_SW_STATUS ,AUX_SW_REPLY_BYTE_COUNT , + &bytes_replied); + +/* In case HPD is LOW, exit AUX transaction */ +if ((*sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) +return -1 ; + +/* Need at least the status byte */ +if (!bytes_replied) +return -1 ; + +REG_UPDATE_1BY1_3 (AUX_SW_DATA , +AUX_SW_INDEX ,0 , +AUX_SW_AUTOINCREMENT_DISABLE ,1 , +AUX_SW_DATA_RW ,1 ); + +REG_GET (AUX_SW_DATA ,AUX_SW_DATA , &reply_result_32); + reply_result_32 = reply_result_32 >>4 ; + *reply_result = (uint8_t )reply_result_32; + +if (reply_result_32 ==0 ) {/* ACK */ +uint32_t i =0 ; + +/* First byte was already used to get the command status */ + --bytes_replied; + +/* Do not overflow buffer */ +if (bytes_replied > size) +return -1 ; + +while (i < bytes_replied) { +uint32_t aux_sw_data_val; + +REG_GET (AUX_SW_DATA ,AUX_SW_DATA , &aux_sw_data_val); + buffer[i] = aux_sw_data_val; + ++i; + } + +return i; + } + +return 0 ; +} + +static void process_channel_reply ( +struct aux_engine *engine, +struct aux_reply_transaction_data *reply) +{ +int bytes_replied; +uint8_t reply_result; +uint32_t sw_status; + + bytes_replied =read_channel_reply (engine, reply->length, reply->data, + &reply_result, &sw_status); + +/* in case HPD is LOW, exit AUX transaction */ +if ((sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) { + reply->status =AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON ; +return ; + } + +if (bytes_replied <0 ) { +/* Need to handle an error case... +* Hopefully, upper layer function won't call this function if +* the number of bytes in the reply was 0, because there was +* surely an error that was asserted that should have been +* handled for hot plug case, this could happens +*/ +if (!(sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) { + reply->status =AUX_TRANSACTION_REPLY_INVALID ; +ASSERT_CRITICAL (false); +return ; + } + }else { + +switch (reply_result) { +case 0 :/* ACK */ + reply->status =AUX_TRANSACTION_REPLY_AUX_ACK ; +break ; +case 1 :/* NACK */ + reply->status =AUX_TRANSACTION_REPLY_AUX_NACK ; +break ; +case 2 :/* DEFER */ + reply->status =AUX_TRANSACTION_REPLY_AUX_DEFER ; +break ; +case 4 :/* AUX ACK / I2C NACK */ + reply->status =AUX_TRANSACTION_REPLY_I2C_NACK ; +break ; +case 8 :/* AUX ACK / I2C DEFER */ + reply->status =AUX_TRANSACTION_REPLY_I2C_DEFER ; +break ; +default : + reply->status =AUX_TRANSACTION_REPLY_INVALID ; + } + } +} + +static enum aux_channel_operation_result get_channel_status ( +struct aux_engine *engine, +uint8_t *returned_bytes) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value; + +if (returned_bytes ==NULL ) { +/*caller pass NULL pointer*/ +ASSERT_CRITICAL (false); +return AUX_CHANNEL_OPERATION_FAILED_REASON_UNKNOWN ; + } + *returned_bytes =0 ; + +/* poll to make sure that SW_DONE is asserted */ + value =REG_WAIT (AUX_SW_STATUS ,AUX_SW_DONE ,1 , +10 , aux110->timeout_period/10 ); + +/* in case HPD is LOW, exit AUX transaction */ +if ((value &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON ; + +/* Note that the following bits are set in 'status.bits' +* during CTS 4.2.1.2 (FW 3.3.1): +* AUX_SW_RX_MIN_COUNT_VIOL, AUX_SW_RX_INVALID_STOP, +* AUX_SW_RX_RECV_NO_DET, AUX_SW_RX_RECV_INVALID_H. +* +* AUX_SW_RX_MIN_COUNT_VIOL is an internal, +* HW debugging bit and should be ignored. +*/ +if (value &AUX_SW_STATUS__AUX_SW_DONE_MASK ) { +if ((value &AUX_SW_STATUS__AUX_SW_RX_TIMEOUT_STATE_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_TIMEOUT_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_TIMEOUT ; + +else if ((value &AUX_SW_STATUS__AUX_SW_RX_INVALID_STOP_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_RECV_NO_DET_MASK ) || + (value & +AUX_SW_STATUS__AUX_SW_RX_RECV_INVALID_H_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_RECV_INVALID_L_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY ; + + *returned_bytes =get_reg_field_value (value, +AUX_SW_STATUS , +AUX_SW_REPLY_BYTE_COUNT ); + +if (*returned_bytes ==0 ) +return +AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY ; +else { + *returned_bytes -=1 ; +return AUX_CHANNEL_OPERATION_SUCCEEDED ; + } + }else { +/*time_elapsed >= aux_engine->timeout_period +* AUX_SW_STATUS__AUX_SW_HPD_DISCON = at this point +*/ +ASSERT_CRITICAL (false); +return AUX_CHANNEL_OPERATION_FAILED_TIMEOUT ; + } +} +static void process_read_reply ( +struct aux_engine *engine, +struct read_command_context *ctx) +{ + engine->funcs->process_channel_reply (engine, &ctx->reply); + +switch (ctx->reply.status) { +case AUX_TRANSACTION_REPLY_AUX_ACK : + ctx->defer_retry_aux =0 ; +if (ctx->returned_byte > ctx->current_read_length) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else if (ctx->returned_byte < ctx->current_read_length) { + ctx->current_read_length -= ctx->returned_byte; + + ctx->offset += ctx->returned_byte; + + ++ctx->invalid_reply_retry_aux_on_ack; + +if (ctx->invalid_reply_retry_aux_on_ack > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + } + }else { + ctx->status =I2CAUX_TRANSACTION_STATUS_SUCCEEDED ; + ctx->transaction_complete = true; + ctx->operation_succeeded = true; + } +break ; +case AUX_TRANSACTION_REPLY_AUX_NACK : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_NACK ; + ctx->operation_succeeded = false; +break ; +case AUX_TRANSACTION_REPLY_AUX_DEFER : + ++ctx->defer_retry_aux; + +if (ctx->defer_retry_aux >AUX_DEFER_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_I2C_DEFER : + ctx->defer_retry_aux =0 ; + + ++ctx->defer_retry_i2c; + +if (ctx->defer_retry_i2c >AUX_DEFER_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static void process_read_request ( +struct aux_engine *engine, +struct read_command_context *ctx) +{ +enum aux_channel_operation_result operation_result; + + engine->funcs->submit_channel_request (engine, &ctx->request); + + operation_result = engine->funcs->get_channel_status ( + engine, &ctx->returned_byte); + +switch (operation_result) { +case AUX_CHANNEL_OPERATION_SUCCEEDED : +if (ctx->returned_byte > ctx->current_read_length) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else { + ctx->timed_out_retry_aux =0 ; + ctx->invalid_reply_retry_aux =0 ; + + ctx->reply.length = ctx->returned_byte; + ctx->reply.data = ctx->buffer; + +process_read_reply (engine, ctx); + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY : + ++ctx->invalid_reply_retry_aux; + +if (ctx->invalid_reply_retry_aux > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else +udelay (400 ); +break ; +case AUX_CHANNEL_OPERATION_FAILED_TIMEOUT : + ++ctx->timed_out_retry_aux; + +if (ctx->timed_out_retry_aux >AUX_TIMED_OUT_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else { +/* DP 1.2a, table 2-58: +* "S3: AUX Request CMD PENDING: +* retry 3 times, with 400usec wait on each" +* The HW timeout is set to 550usec, +* so we should not wait here +*/ + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static bool read_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct read_command_context ctx; + + ctx.buffer = request->payload.data; + ctx.current_read_length = request->payload.length; + ctx.offset =0 ; + ctx.timed_out_retry_aux =0 ; + ctx.invalid_reply_retry_aux =0 ; + ctx.defer_retry_aux =0 ; + ctx.defer_retry_i2c =0 ; + ctx.invalid_reply_retry_aux_on_ack =0 ; + ctx.transaction_complete = false; + ctx.operation_succeeded = true; + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { + ctx.request.type =AUX_TRANSACTION_TYPE_DP ; + ctx.request.action =I2CAUX_TRANSACTION_ACTION_DP_READ ; + ctx.request.address = request->payload.address; + }else if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) { + ctx.request.type =AUX_TRANSACTION_TYPE_I2C ; + ctx.request.action = middle_of_transaction ? +I2CAUX_TRANSACTION_ACTION_I2C_READ_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_READ ; + ctx.request.address = request->payload.address >>1 ; + }else { +/* in DAL2, there was no return in such case */ +BREAK_TO_DEBUGGER (); +return false; + } + + ctx.request.delay =0 ; + +do { +memset (ctx.buffer + ctx.offset,0 , ctx.current_read_length); + + ctx.request.data = ctx.buffer + ctx.offset; + ctx.request.length = ctx.current_read_length; + +process_read_request (engine, &ctx); + + request->status = ctx.status; + +if (ctx.operation_succeeded && !ctx.transaction_complete) +if (ctx.request.type ==AUX_TRANSACTION_TYPE_I2C ) +msleep (engine->delay); + }while (ctx.operation_succeeded && !ctx.transaction_complete); + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { +DC_LOG_I2C_AUX ("READ: addr:0x%x value:0x%x Result:%d" , + request->payload.address, + request->payload.data[0 ], + ctx.operation_succeeded); + } + +return ctx.operation_succeeded; +} + +static void process_write_reply ( +struct aux_engine *engine, +struct write_command_context *ctx) +{ + engine->funcs->process_channel_reply (engine, &ctx->reply); + +switch (ctx->reply.status) { +case AUX_TRANSACTION_REPLY_AUX_ACK : + ctx->operation_succeeded = true; + +if (ctx->returned_byte) { + ctx->request.action = ctx->mot ? +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST ; + + ctx->current_write_length =0 ; + + ++ctx->ack_m_retry; + +if (ctx->ack_m_retry >AUX_DEFER_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else +udelay (300 ); + }else { + ctx->status =I2CAUX_TRANSACTION_STATUS_SUCCEEDED ; + ctx->defer_retry_aux =0 ; + ctx->ack_m_retry =0 ; + ctx->transaction_complete = true; + } +break ; +case AUX_TRANSACTION_REPLY_AUX_NACK : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_NACK ; + ctx->operation_succeeded = false; +break ; +case AUX_TRANSACTION_REPLY_AUX_DEFER : + ++ctx->defer_retry_aux; + +if (ctx->defer_retry_aux > ctx->max_defer_retry) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_I2C_DEFER : + ctx->defer_retry_aux =0 ; + ctx->current_write_length =0 ; + + ctx->request.action = ctx->mot ? +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST ; + + ++ctx->defer_retry_i2c; + +if (ctx->defer_retry_i2c > ctx->max_defer_retry) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static void process_write_request ( +struct aux_engine *engine, +struct write_command_context *ctx) +{ +enum aux_channel_operation_result operation_result; + + engine->funcs->submit_channel_request (engine, &ctx->request); + + operation_result = engine->funcs->get_channel_status ( + engine, &ctx->returned_byte); + +switch (operation_result) { +case AUX_CHANNEL_OPERATION_SUCCEEDED : + ctx->timed_out_retry_aux =0 ; + ctx->invalid_reply_retry_aux =0 ; + + ctx->reply.length = ctx->returned_byte; + ctx->reply.data = ctx->reply_data; + +process_write_reply (engine, ctx); +break ; +case AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY : + ++ctx->invalid_reply_retry_aux; + +if (ctx->invalid_reply_retry_aux > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else +udelay (400 ); +break ; +case AUX_CHANNEL_OPERATION_FAILED_TIMEOUT : + ++ctx->timed_out_retry_aux; + +if (ctx->timed_out_retry_aux >AUX_TIMED_OUT_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else { +/* DP 1.2a, table 2-58: +* "S3: AUX Request CMD PENDING: +* retry 3 times, with 400usec wait on each" +* The HW timeout is set to 550usec, +* so we should not wait here +*/ + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static bool write_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct write_command_context ctx; + + ctx.mot = middle_of_transaction; + ctx.buffer = request->payload.data; + ctx.current_write_length = request->payload.length; + ctx.timed_out_retry_aux =0 ; + ctx.invalid_reply_retry_aux =0 ; + ctx.defer_retry_aux =0 ; + ctx.defer_retry_i2c =0 ; + ctx.ack_m_retry =0 ; + ctx.transaction_complete = false; + ctx.operation_succeeded = true; + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { + ctx.request.type =AUX_TRANSACTION_TYPE_DP ; + ctx.request.action =I2CAUX_TRANSACTION_ACTION_DP_WRITE ; + ctx.request.address = request->payload.address; + }else if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) { + ctx.request.type =AUX_TRANSACTION_TYPE_I2C ; + ctx.request.action = middle_of_transaction ? +I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_WRITE ; + ctx.request.address = request->payload.address >>1 ; + }else { +/* in DAL2, there was no return in such case */ +BREAK_TO_DEBUGGER (); +return false; + } + + ctx.request.delay =0 ; + + ctx.max_defer_retry = + (engine->max_defer_write_retry >AUX_DEFER_RETRY_COUNTER ) ? + engine->max_defer_write_retry :AUX_DEFER_RETRY_COUNTER ; + +do { + ctx.request.data = ctx.buffer; + ctx.request.length = ctx.current_write_length; + +process_write_request (engine, &ctx); + + request->status = ctx.status; + +if (ctx.operation_succeeded && !ctx.transaction_complete) +if (ctx.request.type ==AUX_TRANSACTION_TYPE_I2C ) +msleep (engine->delay); + }while (ctx.operation_succeeded && !ctx.transaction_complete); + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { +DC_LOG_I2C_AUX ("WRITE: addr:0x%x value:0x%x Result:%d" , + request->payload.address, + request->payload.data[0 ], + ctx.operation_succeeded); + } + +return ctx.operation_succeeded; +} +static bool end_of_transaction_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request) +{ +struct i2caux_transaction_request dummy_request; +uint8_t dummy_data; + +/* [tcheng] We only need to send the stop (read with MOT = 0) +* for I2C-over-Aux, not native AUX +*/ + +if (request->payload.address_space != +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) +return false; + + dummy_request.operation = request->operation; + dummy_request.payload.address_space = request->payload.address_space; + dummy_request.payload.address = request->payload.address; + +/* +* Add a dummy byte due to some receiver quirk +* where one byte is sent along with MOT = 0. +* Ideally this should be 0. +*/ + + dummy_request.payload.length =0 ; + dummy_request.payload.data = &dummy_data; + +if (request->operation ==I2CAUX_TRANSACTION_READ ) +return read_command (engine, &dummy_request, false); +else +return write_command (engine, &dummy_request, false); + +/* according Syed, it does not need now DoDummyMOT */ +} +bool submit_request ( +struct engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct aux_engine *aux_engine =FROM_AUX_ENGINE_ENGINE (engine); + +bool result; +bool mot_used = true; + +switch (request->operation) { +case I2CAUX_TRANSACTION_READ : + result =read_command (aux_engine, request, mot_used); +break ; +case I2CAUX_TRANSACTION_WRITE : + result =write_command (aux_engine, request, mot_used); +break ; +default : + result = false; + } + +/* [tcheng] +* need to send stop for the last transaction to free up the AUX +* if the above command fails, this would be the last transaction +*/ + +if (!middle_of_transaction || !result) +end_of_transaction_command (aux_engine, request); + +/* mask AUX interrupt */ + +return result; +} +enum i2caux_engine_type get_engine_type ( +const struct engine *engine) +{ +return I2CAUX_ENGINE_TYPE_AUX ; +} + +static struct aux_engine *acquire ( +struct engine *engine, +struct ddc *ddc) +{ +struct aux_engine *aux_engine =FROM_AUX_ENGINE_ENGINE (engine); +enum gpio_result result; + +if (aux_engine->funcs->is_engine_available) { +/*check whether SW could use the engine*/ +if (!aux_engine->funcs->is_engine_available (aux_engine)) +return NULL ; + } + + result =dal_ddc_open (ddc,GPIO_MODE_HARDWARE , +GPIO_DDC_CONFIG_TYPE_MODE_AUX ); + +if (result !=GPIO_RESULT_OK ) +return NULL ; + +if (!aux_engine->funcs->acquire_engine (aux_engine)) { +dal_ddc_close (ddc); +return NULL ; + } + + engine->ddc = ddc; + +return aux_engine; +} + +static const struct aux_engine_funcs aux_engine_funcs = { + .acquire_engine = acquire_engine, + .submit_channel_request = submit_channel_request, + .process_channel_reply = process_channel_reply, + .read_channel_reply = read_channel_reply, + .get_channel_status = get_channel_status, + .is_engine_available = is_engine_available, +}; + +static const struct engine_funcs engine_funcs = { + .release_engine = release_engine, + .destroy_engine = dce110_engine_destroy, + .submit_request = submit_request, + .get_engine_type = get_engine_type, + .acquire = acquire, +}; + +void dce110_engine_destroy (struct engine **engine) +{ + +struct aux_engine_dce110 *engine110 =FROM_ENGINE (*engine); + +kfree (engine110); + *engine =NULL ; + +} +struct aux_engine *dce110_aux_engine_construct (struct aux_engine_dce110 *aux_engine110, +struct dc_context *ctx, +uint32_t inst, +uint32_t timeout_period, +const struct dce110_aux_registers *regs) +{ + aux_engine110->base.base.ddc =NULL ; + aux_engine110->base.base.ctx = ctx; + aux_engine110->base.delay =0 ; + aux_engine110->base.max_defer_write_retry =0 ; + aux_engine110->base.base.funcs = &engine_funcs; + aux_engine110->base.funcs = &aux_engine_funcs; + aux_engine110->base.base.inst = inst; + aux_engine110->timeout_period = timeout_period; + aux_engine110->regs = regs; + +return &aux_engine110->base; +} +drivers/gpu/drm/amd/display/dc/dce/dce_aux.h new file +111
-0@@ -0,0 +1,111 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_AUX_ENGINE_DCE110_H__ +#define __DAL_AUX_ENGINE_DCE110_H__ +#include "aux_engine.h" + +#define AUX_COMMON_REG_LIST (id)\ + SRI(AUX_CONTROL, DP_AUX, id), \ + SRI(AUX_ARB_CONTROL, DP_AUX, id), \ + SRI(AUX_SW_DATA, DP_AUX, id), \ + SRI(AUX_SW_CONTROL, DP_AUX, id), \ + SRI(AUX_INTERRUPT_CONTROL, DP_AUX, id), \ + SRI(AUX_SW_STATUS, DP_AUX, id), \ + SR(AUXN_IMPCAL), \ + SR(AUXP_IMPCAL) + +struct dce110_aux_registers { +uint32_t AUX_CONTROL; +uint32_t AUX_ARB_CONTROL; +uint32_t AUX_SW_DATA; +uint32_t AUX_SW_CONTROL; +uint32_t AUX_INTERRUPT_CONTROL; +uint32_t AUX_SW_STATUS; +uint32_t AUXN_IMPCAL; +uint32_t AUXP_IMPCAL; + +uint32_t AUX_RESET_MASK; +}; + +enum {/* This is the timeout as defined in DP 1.2a, +* 2.3.4 "Detailed uPacket TX AUX CH State Description". +*/ +AUX_TIMEOUT_PERIOD =400 , + +/* Ideally, the SW timeout should be just above 550usec +* which is programmed in HW. +* But the SW timeout of 600usec is not reliable, +* because on some systems, delay_in_microseconds() +* returns faster than it should. +* EPR #379763: by trial-and-error on different systems, +* 700usec is the minimum reliable SW timeout for polling +* the AUX_SW_STATUS.AUX_SW_DONE bit. +* This timeout expires *only* when there is +* AUX Error or AUX Timeout conditions - not during normal operation. +* During normal operation, AUX_SW_STATUS.AUX_SW_DONE bit is set +* at most within ~240usec. That means, +* increasing this timeout will not affect normal operation, +* and we'll timeout after +* SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD = 1600usec. +* This timeout is especially important for +* resume from S3 and CTS. +*/ +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER =4 +}; +struct aux_engine_dce110 { +struct aux_engine base; +const struct dce110_aux_registers *regs; +struct { +uint32_t aux_control; +uint32_t aux_arb_control; +uint32_t aux_sw_data; +uint32_t aux_sw_control; +uint32_t aux_interrupt_control; +uint32_t aux_sw_status; + } addr; +uint32_t timeout_period; +}; + +struct aux_engine_dce110_init_data { +uint32_t engine_id; +uint32_t timeout_period; +struct dc_context *ctx; +const struct dce110_aux_registers *regs; +}; + +struct aux_engine *dce110_aux_engine_construct ( +struct aux_engine_dce110 *aux_engine110, +struct dc_context *ctx, +uint32_t inst, +uint32_t timeout_period, +const struct dce110_aux_registers *regs); + +void dce110_engine_destroy (struct engine **engine); + +bool dce110_aux_engine_acquire ( +struct engine *aux_engine, +struct ddc *ddc); +#endif drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +42
-0@@ -52,6 +52,7 @@#include "dce/dce_10_0_sh_mask.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" #ifndef mmMC_HUB_RDREQ_DMIF_LIMIT@@ -279,7 +280,20 @@ static const struct dce_opp_shift opp_shift = {static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_100 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +};#define audio_regs (id)\ [id] = {\@@ -572,6 +586,23 @@ struct output_pixel_processor *dce100_opp_create(return &opp->base; } +struct engine *dce100_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce100_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -624,6 +655,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -928,6 +963,13 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.engines[i] =dce100_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count;drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +45
-0@@ -49,6 +49,7 @@#include "dce/dce_clock_source.h" #include "dce/dce_hwseq.h" #include "dce110/dce110_hw_sequencer.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" @@ -306,6 +307,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_110 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -588,6 +604,23 @@ static struct output_pixel_processor *dce110_opp_create(return &opp->base; } +struct engine *dce110_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce110_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -651,6 +684,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -1258,6 +1295,14 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + + pool->base.engines[i] =dce110_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->fbc_compressor =dce110_compressor_create (ctx);drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +47
-0@@ -49,6 +49,7 @@#include "dce112/dce112_hw_sequencer.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "reg_helper.h" @@ -314,6 +315,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_112 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -588,6 +604,23 @@ struct output_pixel_processor *dce112_opp_create(return &opp->base; } +struct engine *dce112_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce112_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -625,6 +658,9 @@ static void destruct(struct dce110_resource_pool *pool)if (pool->base.opps[i] !=NULL )dce110_opp_destroy (&pool->base.opps[i]); +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); +if (pool->base.transforms[i] !=NULL )dce112_transform_destroy (&pool->base.transforms[i]);@@ -640,6 +676,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -1208,6 +1248,13 @@ static bool construct( "DC:failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.engines[i] =dce112_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } if (!resource_construct(num_virtual_links, dc, &pool->base,drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +42
-0@@ -53,6 +53,7 @@#include "dce/dce_hwseq.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_12_0_offset.h" #include "dce/dce_12_0_sh_mask.h" @@ -297,6 +298,20 @@ static const struct dce_opp_shift opp_shift = {static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_120 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +};#define audio_regs (id)\ [id] = {\@@ -361,6 +376,22 @@ struct output_pixel_processor *dce120_opp_create( ctx, inst, &opp_regs[inst], &opp_shift, &opp_mask);return &opp->base; } +struct engine *dce120_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +}static const struct bios_registers bios_regs = { .BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6 +NBIO_BASE (mmBIOS_SCRATCH_6_BASE_IDX)@@ -467,6 +498,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.audio_count; i++) {@@ -984,6 +1019,13 @@ static bool construct(dm_error ("DC: failed to create output pixel processor!\n" ); } + pool->base.engines[i] =dce120_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + }/* check next valid pipe */ j++;drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +44
-0@@ -54,6 +54,7 @@#include "reg_helper.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" /* TODO remove this include */ @@ -298,6 +299,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_80 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -448,6 +464,23 @@ static struct output_pixel_processor *dce80_opp_create(return &opp->base; } +struct engine *dce80_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} +static struct stream_encoder *dce80_stream_encoder_create (enum engine_id eng_id,struct dc_context *ctx)@@ -655,6 +688,9 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -899,6 +935,14 @@ static bool dce80_construct(dm_error ("DC: failed to create output pixel processor!\n" ); goto res_create_fail; } + + pool->base.engines[i] =dce80_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count;drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +44
-0@@ -64,6 +64,7 @@#include "reg_helper.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" const struct _vcs_dpi_ip_params_st dcn1_0_ip = { .rob_buffer_size_kbytes =64 ,@@ -356,6 +357,21 @@ static const struct dcn10_opp_mask opp_mask = { OPP_MASK_SH_LIST_DCN10(_MASK), }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define tf_regs (id)\ [id] = {\ TF_REG_LIST_DCN10(id),\@@ -578,6 +594,23 @@ static struct output_pixel_processor *dcn10_opp_create(return &opp->base; } +struct engine *dcn10_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} +static struct mpc *dcn10_mpc_create (struct dc_context *ctx) { struct dcn10_mpc *mpc10 = kzalloc(sizeof(struct dcn10_mpc),@@ -826,6 +859,9 @@ static void destruct(struct dcn10_resource_pool *pool)kfree (DCN10TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) + pool->base.engines[i]->funcs->destroy_engine (&pool->base.engines[i]); }for (i =0 ; i < pool->base.stream_enc_count; i++)@@ -1255,6 +1291,14 @@ static bool construct( goto fail; } + pool->base.engines[i] =dcn10_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto fail; + } +/* check next valid pipe */ j++; }drivers/gpu/drm/amd/display/dc/i2caux/engine.h +1
-0@@ -96,6 +96,7 @@ struct engine_funcs {struct engine {const struct engine_funcs *funcs; +uint32_t inst;struct ddc *ddc;struct dc_context *ctx; };drivers/gpu/drm/amd/display/dc/inc/core_types.h +1
-1@@ -138,7 +138,7 @@ struct resource_pool {struct output_pixel_processor *opps[MAX_PIPES ];struct timing_generator *timing_generators[MAX_PIPES ];struct stream_encoder *stream_enc[MAX_PIPES *2 ]; - +struct engine *engines[MAX_PIPES ];struct hubbub *hubbub;struct mpc *mpc;struct pp_smu_funcs_rv *pp_smu;drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h new file +113
-0@@ -0,0 +1,113 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_AUX_ENGINE_H__ +#define __DAL_AUX_ENGINE_H__ + +#include "engine.h" +#include "include/i2caux_interface.h" + +struct aux_engine ; +union aux_config ; +struct aux_engine_funcs { +void (*destroy)( +struct aux_engine **ptr); +bool (*acquire_engine)( +struct aux_engine *engine); +void (*configure)( +struct aux_engine *engine, +union aux_config cfg); +void (*submit_channel_request)( +struct aux_engine *engine, +struct aux_request_transaction_data *request); +void (*process_channel_reply)( +struct aux_engine *engine, +struct aux_reply_transaction_data *reply); +int (*read_channel_reply)( +struct aux_engine *engine, +uint32_t size, +uint8_t *buffer, +uint8_t *reply_result, +uint32_t *sw_status); +enum aux_channel_operation_result (*get_channel_status)( +struct aux_engine *engine, +uint8_t *returned_bytes); +bool (*is_engine_available)(struct aux_engine *engine); +}; +struct engine ; +struct aux_engine { +struct engine base; +const struct aux_engine_funcs *funcs; +/* following values are expressed in milliseconds */ +uint32_t delay; +uint32_t max_defer_write_retry; + +bool acquire_reset; +}; +struct read_command_context { +uint8_t *buffer; +uint32_t current_read_length; +uint32_t offset; +enum i2caux_transaction_status status; + +struct aux_request_transaction_data request; +struct aux_reply_transaction_data reply; + +uint8_t returned_byte; + +uint32_t timed_out_retry_aux; +uint32_t invalid_reply_retry_aux; +uint32_t defer_retry_aux; +uint32_t defer_retry_i2c; +uint32_t invalid_reply_retry_aux_on_ack; + +bool transaction_complete; +bool operation_succeeded; +}; +struct write_command_context { +bool mot; + +uint8_t *buffer; +uint32_t current_write_length; +enum i2caux_transaction_status status; + +struct aux_request_transaction_data request; +struct aux_reply_transaction_data reply; + +uint8_t returned_byte; + +uint32_t timed_out_retry_aux; +uint32_t invalid_reply_retry_aux; +uint32_t defer_retry_aux; +uint32_t defer_retry_i2c; +uint32_t max_defer_retry; +uint32_t ack_m_retry; + +uint8_t reply_data[DEFAULT_AUX_MAX_DATA_SIZE ]; + +bool transaction_complete; +bool operation_succeeded; +}; +#endif drivers/gpu/drm/amd/display/dc/inc/hw/engine.h new file +106
-1@@ -0,0 +1,106 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_ENGINE_H__ +#define __DAL_ENGINE_H__ + +#include "dc_ddc_types.h" + +enum i2caux_transaction_operation { +I2CAUX_TRANSACTION_READ , +I2CAUX_TRANSACTION_WRITE +}; + +enum i2caux_transaction_address_space { +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C =1 , +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD +}; + +struct i2caux_transaction_payload { +enum i2caux_transaction_address_space address_space; +uint32_t address; +uint32_t length; +uint8_t *data; +}; + +enum i2caux_transaction_status { +I2CAUX_TRANSACTION_STATUS_UNKNOWN = (-1L ), +I2CAUX_TRANSACTION_STATUS_SUCCEEDED , +I2CAUX_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY , +I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT , +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR , +I2CAUX_TRANSACTION_STATUS_FAILED_NACK , +I2CAUX_TRANSACTION_STATUS_FAILED_INCOMPLETE , +I2CAUX_TRANSACTION_STATUS_FAILED_OPERATION , +I2CAUX_TRANSACTION_STATUS_FAILED_INVALID_OPERATION , +I2CAUX_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW , +I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON +}; + +struct i2caux_transaction_request { +enum i2caux_transaction_operation operation; +struct i2caux_transaction_payload payload; +enum i2caux_transaction_status status; +}; + +enum i2caux_engine_type { +I2CAUX_ENGINE_TYPE_UNKNOWN = (-1L ), +I2CAUX_ENGINE_TYPE_AUX , +I2CAUX_ENGINE_TYPE_I2C_DDC_HW , +I2CAUX_ENGINE_TYPE_I2C_GENERIC_HW , +I2CAUX_ENGINE_TYPE_I2C_SW +}; + +enum i2c_default_speed { +I2CAUX_DEFAULT_I2C_HW_SPEED =50 , +I2CAUX_DEFAULT_I2C_SW_SPEED =50 +}; + +struct engine ; + +struct engine_funcs { +enum i2caux_engine_type (*get_engine_type)( +const struct engine *engine); +struct aux_engine * (*acquire)( +struct engine *engine, +struct ddc *ddc); +bool (*submit_request)( +struct engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction); +void (*release_engine)( +struct engine *engine); +void (*destroy_engine)( +struct engine **engine); +}; + +struct engine { +const struct engine_funcs *funcs; +uint32_t inst; +struct ddc *ddc; +struct dc_context *ctx; +}; + +#endif --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): CADnq5_M+TzVYtgJM=a_RxHLCDTHOwBU9obpLaqaJEO+iZ3X=3A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Re: [PATCH 5/7] drm/amd/display: Decouple aux from i2c
In this patch, i2c is still using the old code path (nothing is changed for i2c). For aux, locking is already done in drm (i2c also uses drm locks).
The new code for aux is same as the old one. Only difference is that some i2c code is removed from aux and aux is put in a different location to match our other HW resources. As for the logic/behavior, it is exactly the same as before.
Bhawan
________________________________
From: Alex Deucher <[email protected]>
Sent: July 17, 2018 12:07:30 PM
To: Li, Sun peng (Leo)
Cc: amd-gfx list; Lakha, Bhawanpreet
Subject: Re: [PATCH 5/7] drm/amd/display: Decouple aux from i2c
Quoted 10 lines · On Tue, Jul 17, 2018 at 9:29 AM, <[email protected]>…
From: Bhawanpreet Lakha <[email protected]>
[Why]
Aux engine is created from i2caux layer. We want to remove this layer and use the engine directly.[How]
Decouple aux engine from i2caux. Move aux engine related code to dce folder and use dc resource pool to manage the engine. And use the engine functions directly
Don't i2c and aux share the same physical pins? If so, do you have appropriate locking to arbitrate access to the pins from either engine?
Alex
Quoted 1,936 lines
Change-Id Iecb609fe815dab31ed6b6100916c4b49ed6539a0Signed-off-by Bhawanpreet Lakha <[email protected]>Reviewed-by Harry Wentland <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c | 22 +- drivers/gpu/drm/amd/display/dc/dce/Makefile | 2 +- drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 942 +++++++++++++++++++++ drivers/gpu/drm/amd/display/dc/dce/dce_aux.h | 111 +++ .../drm/amd/display/dc/dce100/dce100_resource.c | 42 + .../drm/amd/display/dc/dce110/dce110_resource.c | 45 + .../drm/amd/display/dc/dce112/dce112_resource.c | 47 + .../drm/amd/display/dc/dce120/dce120_resource.c | 42 + .../gpu/drm/amd/display/dc/dce80/dce80_resource.c | 44 + .../gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 44 + drivers/gpu/drm/amd/display/dc/i2caux/engine.h | 1 + drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +- drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h | 113 +++ drivers/gpu/drm/amd/display/dc/inc/hw/engine.h | 106 +++ 14 files changed, 1549 insertions(+), 14 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c create mode 100644 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h create mode 100644 drivers/gpu/drm/amd/display/dc/inc/hw/engine.hdrivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c +10
-12@@ -33,10 +33,8 @@#include "include/vector.h" #include "core_types.h" #include "dc_link_ddc.h" -#include "i2caux/engine.h" -#include "i2caux/i2c_engine.h" -#include "i2caux/aux_engine.h" -#include "i2caux/i2caux.h" +#include "engine.h" +#include "aux_engine.h" #define AUX_POWER_UP_WA_DELAY 500#define I2C_OVER_AUX_DEFER_WA_DELAY 70@@ -641,9 +639,9 @@ int dc_link_aux_transfer(struct ddc_service *ddc,enum aux_transaction_type type, enum i2caux_transaction_action action) { - struct i2caux *i2caux = ddc->ctx->i2caux; struct ddc *ddc_pin = ddc->ddc_pin; -struct aux_engine *engine; +struct engine *engine; +struct aux_engine *aux_engine;enum aux_channel_operation_result operation_result;struct aux_request_transaction_data aux_req;struct aux_reply_transaction_data aux_rep;@@ -654,7 +652,8 @@ int dc_link_aux_transfer(struct ddc_service *ddc,memset (&aux_req,0 ,sizeof (aux_req));memset (&aux_rep,0 ,sizeof (aux_rep)); - engine = i2caux->funcs->acquire_aux_engine (i2caux, ddc_pin); + engine = ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]; + aux_engine = engine->funcs->acquire (engine, ddc_pin); aux_req.type = type; aux_req.action = action;@@ -664,15 +663,15 @@ int dc_link_aux_transfer(struct ddc_service *ddc, aux_req.length = size; aux_req.data = buffer; - engine->funcs->submit_channel_request (engine, &aux_req); - operation_result = engine->funcs->get_channel_status (engine, &returned_bytes); + aux_engine->funcs->submit_channel_request (aux_engine, &aux_req); + operation_result = aux_engine->funcs->get_channel_status (aux_engine, &returned_bytes);switch (operation_result) {case AUX_CHANNEL_OPERATION_SUCCEEDED : res = returned_bytes;if (res <= size && res >=0 ) - res = engine->funcs->read_channel_reply (engine, size, + res = aux_engine->funcs->read_channel_reply (aux_engine, size, buffer, reply, &status);@@ -686,8 +685,7 @@ int dc_link_aux_transfer(struct ddc_service *ddc, res =-1 ;break ; } - - i2caux->funcs->release_engine (i2caux, &engine->base); + aux_engine->base.funcs->release_engine (&aux_engine->base);return res; }drivers/gpu/drm/amd/display/dc/dce/Makefile +1
-1@@ -28,7 +28,7 @@ DCE = dce_audio.o dce_stream_encoder.o dce_link_encoder.o dce_hwseq.o \ dce_mem_input.o dce_clock_source.o dce_scl_filters.o dce_transform.o \ -dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o +dce_clocks.o dce_opp.o dce_dmcu.o dce_abm.o dce_ipp.o dce_aux.o AMD_DAL_DCE = $(addprefix $(AMDDALPATH)/dc/dce/,$(DCE))drivers/gpu/drm/amd/display/dc/dce/dce_aux.c new file +942
-0@@ -0,0 +1,942 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#include "dm_services.h" +#include "dce_aux.h" +#include "dce/dce_11_0_sh_mask.h" + +#define CTX \ + aux110->base.base.ctx +#define REG (reg_name)\ + (aux110->regs->reg_name) + +#define DC_LOGGER \ + engine->base.ctx->logger + +#include "reg_helper.h" + +#define FROM_AUX_ENGINE (ptr) \ + container_of((ptr), struct aux_engine_dce110, base) + +#define FROM_ENGINE (ptr) \ + FROM_AUX_ENGINE(container_of((ptr), struct aux_engine, base)) + +#define FROM_AUX_ENGINE_ENGINE (ptr) \ + container_of((ptr), struct aux_engine, base) +enum { +AUX_INVALID_REPLY_RETRY_COUNTER =1 , +AUX_TIMED_OUT_RETRY_COUNTER =2 , +AUX_DEFER_RETRY_COUNTER =6 +}; +static void release_engine ( +struct engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_ENGINE (engine); + +dal_ddc_close (engine->ddc); + + engine->ddc =NULL ; + +REG_UPDATE (AUX_ARB_CONTROL ,AUX_SW_DONE_USING_AUX_REG ,1 ); +} + +#define SW_CAN_ACCESS_AUX 1 +#define DMCU_CAN_ACCESS_AUX 2 + +static bool is_engine_available ( +struct aux_engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value =REG_READ (AUX_ARB_CONTROL ); +uint32_t field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); + +return (field !=DMCU_CAN_ACCESS_AUX ); +} +static bool acquire_engine ( +struct aux_engine *engine) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value =REG_READ (AUX_ARB_CONTROL ); +uint32_t field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); +if (field ==DMCU_CAN_ACCESS_AUX ) +return false; +/* enable AUX before request SW to access AUX */ + value =REG_READ (AUX_CONTROL ); + field =get_reg_field_value (value, +AUX_CONTROL , +AUX_EN ); + +if (field ==0 ) { +set_reg_field_value ( + value, +1 , +AUX_CONTROL , +AUX_EN ); + +if (REG (AUX_RESET_MASK )) { +/*DP_AUX block as part of the enable sequence*/ +set_reg_field_value ( + value, +1 , +AUX_CONTROL , +AUX_RESET ); + } + +REG_WRITE (AUX_CONTROL , value); + +if (REG (AUX_RESET_MASK )) { +/*poll HW to make sure reset it done*/ + +REG_WAIT (AUX_CONTROL ,AUX_RESET_DONE ,1 , +1 ,11 ); + +set_reg_field_value ( + value, +0 , +AUX_CONTROL , +AUX_RESET ); + +REG_WRITE (AUX_CONTROL , value); + +REG_WAIT (AUX_CONTROL ,AUX_RESET_DONE ,0 , +1 ,11 ); + } + }/*if (field)*/ + +/* request SW to access AUX */ +REG_UPDATE (AUX_ARB_CONTROL ,AUX_SW_USE_AUX_REG_REQ ,1 ); + + value =REG_READ (AUX_ARB_CONTROL ); + field =get_reg_field_value ( + value, +AUX_ARB_CONTROL , +AUX_REG_RW_CNTL_STATUS ); + +return (field ==SW_CAN_ACCESS_AUX ); +} + +#define COMPOSE_AUX_SW_DATA_16_20 (command, address) \ + ((command) | ((0xF0000 & (address)) >> 16)) + +#define COMPOSE_AUX_SW_DATA_8_15 (address) \ + ((0xFF00 & (address)) >> 8) + +#define COMPOSE_AUX_SW_DATA_0_7 (address) \ + (0xFF & (address)) + +static void submit_channel_request ( +struct aux_engine *engine, +struct aux_request_transaction_data *request) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); +uint32_t value; +uint32_t length; + +bool is_write = + ((request->type ==AUX_TRANSACTION_TYPE_DP ) && + (request->action ==I2CAUX_TRANSACTION_ACTION_DP_WRITE )) || + ((request->type ==AUX_TRANSACTION_TYPE_I2C ) && + ((request->action ==I2CAUX_TRANSACTION_ACTION_I2C_WRITE ) || + (request->action ==I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT ))); +if (REG (AUXN_IMPCAL )) { +/* clear_aux_error */ +REG_UPDATE_SEQ (AUXN_IMPCAL ,AUXN_CALOUT_ERROR_AK , +1 , +0 ); + +REG_UPDATE_SEQ (AUXP_IMPCAL ,AUXP_CALOUT_ERROR_AK , +1 , +0 ); + +/* force_default_calibrate */ +REG_UPDATE_1BY1_2 (AUXN_IMPCAL , +AUXN_IMPCAL_ENABLE ,1 , +AUXN_IMPCAL_OVERRIDE_ENABLE ,0 ); + +/* bug? why AUXN update EN and OVERRIDE_EN 1 by 1 while AUX P toggles OVERRIDE? */ + +REG_UPDATE_SEQ (AUXP_IMPCAL ,AUXP_IMPCAL_OVERRIDE_ENABLE , +1 , +0 ); + } +/* set the delay and the number of bytes to write */ + +/* The length include +* the 4 bit header and the 20 bit address +* (that is 3 byte). +* If the requested length is non zero this means +* an addition byte specifying the length is required. +*/ + + length = request->length ?4 :3 ; +if (is_write) + length += request->length; + +REG_UPDATE_2 (AUX_SW_CONTROL , +AUX_SW_START_DELAY , request->delay, +AUX_SW_WR_BYTES , length); + +/* program action and address and payload data (if 'is_write') */ + value =REG_UPDATE_4 (AUX_SW_DATA , +AUX_SW_INDEX ,0 , +AUX_SW_DATA_RW ,0 , +AUX_SW_AUTOINCREMENT_DISABLE ,1 , +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_16_20 (request->action, request->address)); + + value =REG_SET_2 (AUX_SW_DATA , value, +AUX_SW_AUTOINCREMENT_DISABLE ,0 , +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_8_15 (request->address)); + + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA ,COMPOSE_AUX_SW_DATA_0_7 (request->address)); + +if (request->length) { + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA , request->length -1 ); + } + +if (is_write) { +/* Load the HW buffer with the Data to be sent. +* This is relevant for write operation. +* For read, the data recived data will be +* processed in process_channel_reply(). +*/ +uint32_t i =0 ; + +while (i < request->length) { + value =REG_SET (AUX_SW_DATA , value, +AUX_SW_DATA , request->data[i]); + + ++i; + } + } + +REG_UPDATE (AUX_INTERRUPT_CONTROL ,AUX_SW_DONE_ACK ,1 ); +REG_WAIT (AUX_SW_STATUS ,AUX_SW_DONE ,0 , +10 , aux110->timeout_period/10 ); +REG_UPDATE (AUX_SW_CONTROL ,AUX_SW_GO ,1 ); +} + +static int read_channel_reply (struct aux_engine *engine,uint32_t size, +uint8_t *buffer,uint8_t *reply_result, +uint32_t *sw_status) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); +uint32_t bytes_replied; +uint32_t reply_result_32; + + *sw_status =REG_GET (AUX_SW_STATUS ,AUX_SW_REPLY_BYTE_COUNT , + &bytes_replied); + +/* In case HPD is LOW, exit AUX transaction */ +if ((*sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) +return -1 ; + +/* Need at least the status byte */ +if (!bytes_replied) +return -1 ; + +REG_UPDATE_1BY1_3 (AUX_SW_DATA , +AUX_SW_INDEX ,0 , +AUX_SW_AUTOINCREMENT_DISABLE ,1 , +AUX_SW_DATA_RW ,1 ); + +REG_GET (AUX_SW_DATA ,AUX_SW_DATA , &reply_result_32); + reply_result_32 = reply_result_32 >>4 ; + *reply_result = (uint8_t )reply_result_32; + +if (reply_result_32 ==0 ) {/* ACK */ +uint32_t i =0 ; + +/* First byte was already used to get the command status */ + --bytes_replied; + +/* Do not overflow buffer */ +if (bytes_replied > size) +return -1 ; + +while (i < bytes_replied) { +uint32_t aux_sw_data_val; + +REG_GET (AUX_SW_DATA ,AUX_SW_DATA , &aux_sw_data_val); + buffer[i] = aux_sw_data_val; + ++i; + } + +return i; + } + +return 0 ; +} + +static void process_channel_reply ( +struct aux_engine *engine, +struct aux_reply_transaction_data *reply) +{ +int bytes_replied; +uint8_t reply_result; +uint32_t sw_status; + + bytes_replied =read_channel_reply (engine, reply->length, reply->data, + &reply_result, &sw_status); + +/* in case HPD is LOW, exit AUX transaction */ +if ((sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) { + reply->status =AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON ; +return ; + } + +if (bytes_replied <0 ) { +/* Need to handle an error case... +* Hopefully, upper layer function won't call this function if +* the number of bytes in the reply was 0, because there was +* surely an error that was asserted that should have been +* handled for hot plug case, this could happens +*/ +if (!(sw_status &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) { + reply->status =AUX_TRANSACTION_REPLY_INVALID ; +ASSERT_CRITICAL (false); +return ; + } + }else { + +switch (reply_result) { +case 0 :/* ACK */ + reply->status =AUX_TRANSACTION_REPLY_AUX_ACK ; +break ; +case 1 :/* NACK */ + reply->status =AUX_TRANSACTION_REPLY_AUX_NACK ; +break ; +case 2 :/* DEFER */ + reply->status =AUX_TRANSACTION_REPLY_AUX_DEFER ; +break ; +case 4 :/* AUX ACK / I2C NACK */ + reply->status =AUX_TRANSACTION_REPLY_I2C_NACK ; +break ; +case 8 :/* AUX ACK / I2C DEFER */ + reply->status =AUX_TRANSACTION_REPLY_I2C_DEFER ; +break ; +default : + reply->status =AUX_TRANSACTION_REPLY_INVALID ; + } + } +} + +static enum aux_channel_operation_result get_channel_status ( +struct aux_engine *engine, +uint8_t *returned_bytes) +{ +struct aux_engine_dce110 *aux110 =FROM_AUX_ENGINE (engine); + +uint32_t value; + +if (returned_bytes ==NULL ) { +/*caller pass NULL pointer*/ +ASSERT_CRITICAL (false); +return AUX_CHANNEL_OPERATION_FAILED_REASON_UNKNOWN ; + } + *returned_bytes =0 ; + +/* poll to make sure that SW_DONE is asserted */ + value =REG_WAIT (AUX_SW_STATUS ,AUX_SW_DONE ,1 , +10 , aux110->timeout_period/10 ); + +/* in case HPD is LOW, exit AUX transaction */ +if ((value &AUX_SW_STATUS__AUX_SW_HPD_DISCON_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON ; + +/* Note that the following bits are set in 'status.bits' +* during CTS 4.2.1.2 (FW 3.3.1): +* AUX_SW_RX_MIN_COUNT_VIOL, AUX_SW_RX_INVALID_STOP, +* AUX_SW_RX_RECV_NO_DET, AUX_SW_RX_RECV_INVALID_H. +* +* AUX_SW_RX_MIN_COUNT_VIOL is an internal, +* HW debugging bit and should be ignored. +*/ +if (value &AUX_SW_STATUS__AUX_SW_DONE_MASK ) { +if ((value &AUX_SW_STATUS__AUX_SW_RX_TIMEOUT_STATE_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_TIMEOUT_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_TIMEOUT ; + +else if ((value &AUX_SW_STATUS__AUX_SW_RX_INVALID_STOP_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_RECV_NO_DET_MASK ) || + (value & +AUX_SW_STATUS__AUX_SW_RX_RECV_INVALID_H_MASK ) || + (value &AUX_SW_STATUS__AUX_SW_RX_RECV_INVALID_L_MASK )) +return AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY ; + + *returned_bytes =get_reg_field_value (value, +AUX_SW_STATUS , +AUX_SW_REPLY_BYTE_COUNT ); + +if (*returned_bytes ==0 ) +return +AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY ; +else { + *returned_bytes -=1 ; +return AUX_CHANNEL_OPERATION_SUCCEEDED ; + } + }else { +/*time_elapsed >= aux_engine->timeout_period +* AUX_SW_STATUS__AUX_SW_HPD_DISCON = at this point +*/ +ASSERT_CRITICAL (false); +return AUX_CHANNEL_OPERATION_FAILED_TIMEOUT ; + } +} +static void process_read_reply ( +struct aux_engine *engine, +struct read_command_context *ctx) +{ + engine->funcs->process_channel_reply (engine, &ctx->reply); + +switch (ctx->reply.status) { +case AUX_TRANSACTION_REPLY_AUX_ACK : + ctx->defer_retry_aux =0 ; +if (ctx->returned_byte > ctx->current_read_length) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else if (ctx->returned_byte < ctx->current_read_length) { + ctx->current_read_length -= ctx->returned_byte; + + ctx->offset += ctx->returned_byte; + + ++ctx->invalid_reply_retry_aux_on_ack; + +if (ctx->invalid_reply_retry_aux_on_ack > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + } + }else { + ctx->status =I2CAUX_TRANSACTION_STATUS_SUCCEEDED ; + ctx->transaction_complete = true; + ctx->operation_succeeded = true; + } +break ; +case AUX_TRANSACTION_REPLY_AUX_NACK : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_NACK ; + ctx->operation_succeeded = false; +break ; +case AUX_TRANSACTION_REPLY_AUX_DEFER : + ++ctx->defer_retry_aux; + +if (ctx->defer_retry_aux >AUX_DEFER_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_I2C_DEFER : + ctx->defer_retry_aux =0 ; + + ++ctx->defer_retry_i2c; + +if (ctx->defer_retry_i2c >AUX_DEFER_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static void process_read_request ( +struct aux_engine *engine, +struct read_command_context *ctx) +{ +enum aux_channel_operation_result operation_result; + + engine->funcs->submit_channel_request (engine, &ctx->request); + + operation_result = engine->funcs->get_channel_status ( + engine, &ctx->returned_byte); + +switch (operation_result) { +case AUX_CHANNEL_OPERATION_SUCCEEDED : +if (ctx->returned_byte > ctx->current_read_length) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else { + ctx->timed_out_retry_aux =0 ; + ctx->invalid_reply_retry_aux =0 ; + + ctx->reply.length = ctx->returned_byte; + ctx->reply.data = ctx->buffer; + +process_read_reply (engine, ctx); + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY : + ++ctx->invalid_reply_retry_aux; + +if (ctx->invalid_reply_retry_aux > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else +udelay (400 ); +break ; +case AUX_CHANNEL_OPERATION_FAILED_TIMEOUT : + ++ctx->timed_out_retry_aux; + +if (ctx->timed_out_retry_aux >AUX_TIMED_OUT_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else { +/* DP 1.2a, table 2-58: +* "S3: AUX Request CMD PENDING: +* retry 3 times, with 400usec wait on each" +* The HW timeout is set to 550usec, +* so we should not wait here +*/ + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static bool read_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct read_command_context ctx; + + ctx.buffer = request->payload.data; + ctx.current_read_length = request->payload.length; + ctx.offset =0 ; + ctx.timed_out_retry_aux =0 ; + ctx.invalid_reply_retry_aux =0 ; + ctx.defer_retry_aux =0 ; + ctx.defer_retry_i2c =0 ; + ctx.invalid_reply_retry_aux_on_ack =0 ; + ctx.transaction_complete = false; + ctx.operation_succeeded = true; + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { + ctx.request.type =AUX_TRANSACTION_TYPE_DP ; + ctx.request.action =I2CAUX_TRANSACTION_ACTION_DP_READ ; + ctx.request.address = request->payload.address; + }else if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) { + ctx.request.type =AUX_TRANSACTION_TYPE_I2C ; + ctx.request.action = middle_of_transaction ? +I2CAUX_TRANSACTION_ACTION_I2C_READ_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_READ ; + ctx.request.address = request->payload.address >>1 ; + }else { +/* in DAL2, there was no return in such case */ +BREAK_TO_DEBUGGER (); +return false; + } + + ctx.request.delay =0 ; + +do { +memset (ctx.buffer + ctx.offset,0 , ctx.current_read_length); + + ctx.request.data = ctx.buffer + ctx.offset; + ctx.request.length = ctx.current_read_length; + +process_read_request (engine, &ctx); + + request->status = ctx.status; + +if (ctx.operation_succeeded && !ctx.transaction_complete) +if (ctx.request.type ==AUX_TRANSACTION_TYPE_I2C ) +msleep (engine->delay); + }while (ctx.operation_succeeded && !ctx.transaction_complete); + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { +DC_LOG_I2C_AUX ("READ: addr:0x%x value:0x%x Result:%d" , + request->payload.address, + request->payload.data[0 ], + ctx.operation_succeeded); + } + +return ctx.operation_succeeded; +} + +static void process_write_reply ( +struct aux_engine *engine, +struct write_command_context *ctx) +{ + engine->funcs->process_channel_reply (engine, &ctx->reply); + +switch (ctx->reply.status) { +case AUX_TRANSACTION_REPLY_AUX_ACK : + ctx->operation_succeeded = true; + +if (ctx->returned_byte) { + ctx->request.action = ctx->mot ? +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST ; + + ctx->current_write_length =0 ; + + ++ctx->ack_m_retry; + +if (ctx->ack_m_retry >AUX_DEFER_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else +udelay (300 ); + }else { + ctx->status =I2CAUX_TRANSACTION_STATUS_SUCCEEDED ; + ctx->defer_retry_aux =0 ; + ctx->ack_m_retry =0 ; + ctx->transaction_complete = true; + } +break ; +case AUX_TRANSACTION_REPLY_AUX_NACK : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_NACK ; + ctx->operation_succeeded = false; +break ; +case AUX_TRANSACTION_REPLY_AUX_DEFER : + ++ctx->defer_retry_aux; + +if (ctx->defer_retry_aux > ctx->max_defer_retry) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_I2C_DEFER : + ctx->defer_retry_aux =0 ; + ctx->current_write_length =0 ; + + ctx->request.action = ctx->mot ? +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_STATUS_REQUEST ; + + ++ctx->defer_retry_i2c; + +if (ctx->defer_retry_i2c > ctx->max_defer_retry) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + } +break ; +case AUX_TRANSACTION_REPLY_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static void process_write_request ( +struct aux_engine *engine, +struct write_command_context *ctx) +{ +enum aux_channel_operation_result operation_result; + + engine->funcs->submit_channel_request (engine, &ctx->request); + + operation_result = engine->funcs->get_channel_status ( + engine, &ctx->returned_byte); + +switch (operation_result) { +case AUX_CHANNEL_OPERATION_SUCCEEDED : + ctx->timed_out_retry_aux =0 ; + ctx->invalid_reply_retry_aux =0 ; + + ctx->reply.length = ctx->returned_byte; + ctx->reply.data = ctx->reply_data; + +process_write_reply (engine, ctx); +break ; +case AUX_CHANNEL_OPERATION_FAILED_INVALID_REPLY : + ++ctx->invalid_reply_retry_aux; + +if (ctx->invalid_reply_retry_aux > +AUX_INVALID_REPLY_RETRY_COUNTER ) { + ctx->status = +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR ; + ctx->operation_succeeded = false; + }else +udelay (400 ); +break ; +case AUX_CHANNEL_OPERATION_FAILED_TIMEOUT : + ++ctx->timed_out_retry_aux; + +if (ctx->timed_out_retry_aux >AUX_TIMED_OUT_RETRY_COUNTER ) { + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT ; + ctx->operation_succeeded = false; + }else { +/* DP 1.2a, table 2-58: +* "S3: AUX Request CMD PENDING: +* retry 3 times, with 400usec wait on each" +* The HW timeout is set to 550usec, +* so we should not wait here +*/ + } +break ; +case AUX_CHANNEL_OPERATION_FAILED_HPD_DISCON : + ctx->status =I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON ; + ctx->operation_succeeded = false; +break ; +default : + ctx->status =I2CAUX_TRANSACTION_STATUS_UNKNOWN ; + ctx->operation_succeeded = false; + } +} +static bool write_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct write_command_context ctx; + + ctx.mot = middle_of_transaction; + ctx.buffer = request->payload.data; + ctx.current_write_length = request->payload.length; + ctx.timed_out_retry_aux =0 ; + ctx.invalid_reply_retry_aux =0 ; + ctx.defer_retry_aux =0 ; + ctx.defer_retry_i2c =0 ; + ctx.ack_m_retry =0 ; + ctx.transaction_complete = false; + ctx.operation_succeeded = true; + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { + ctx.request.type =AUX_TRANSACTION_TYPE_DP ; + ctx.request.action =I2CAUX_TRANSACTION_ACTION_DP_WRITE ; + ctx.request.address = request->payload.address; + }else if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) { + ctx.request.type =AUX_TRANSACTION_TYPE_I2C ; + ctx.request.action = middle_of_transaction ? +I2CAUX_TRANSACTION_ACTION_I2C_WRITE_MOT : +I2CAUX_TRANSACTION_ACTION_I2C_WRITE ; + ctx.request.address = request->payload.address >>1 ; + }else { +/* in DAL2, there was no return in such case */ +BREAK_TO_DEBUGGER (); +return false; + } + + ctx.request.delay =0 ; + + ctx.max_defer_retry = + (engine->max_defer_write_retry >AUX_DEFER_RETRY_COUNTER ) ? + engine->max_defer_write_retry :AUX_DEFER_RETRY_COUNTER ; + +do { + ctx.request.data = ctx.buffer; + ctx.request.length = ctx.current_write_length; + +process_write_request (engine, &ctx); + + request->status = ctx.status; + +if (ctx.operation_succeeded && !ctx.transaction_complete) +if (ctx.request.type ==AUX_TRANSACTION_TYPE_I2C ) +msleep (engine->delay); + }while (ctx.operation_succeeded && !ctx.transaction_complete); + +if (request->payload.address_space == +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD ) { +DC_LOG_I2C_AUX ("WRITE: addr:0x%x value:0x%x Result:%d" , + request->payload.address, + request->payload.data[0 ], + ctx.operation_succeeded); + } + +return ctx.operation_succeeded; +} +static bool end_of_transaction_command ( +struct aux_engine *engine, +struct i2caux_transaction_request *request) +{ +struct i2caux_transaction_request dummy_request; +uint8_t dummy_data; + +/* [tcheng] We only need to send the stop (read with MOT = 0) +* for I2C-over-Aux, not native AUX +*/ + +if (request->payload.address_space != +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C ) +return false; + + dummy_request.operation = request->operation; + dummy_request.payload.address_space = request->payload.address_space; + dummy_request.payload.address = request->payload.address; + +/* +* Add a dummy byte due to some receiver quirk +* where one byte is sent along with MOT = 0. +* Ideally this should be 0. +*/ + + dummy_request.payload.length =0 ; + dummy_request.payload.data = &dummy_data; + +if (request->operation ==I2CAUX_TRANSACTION_READ ) +return read_command (engine, &dummy_request, false); +else +return write_command (engine, &dummy_request, false); + +/* according Syed, it does not need now DoDummyMOT */ +} +bool submit_request ( +struct engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction) +{ +struct aux_engine *aux_engine =FROM_AUX_ENGINE_ENGINE (engine); + +bool result; +bool mot_used = true; + +switch (request->operation) { +case I2CAUX_TRANSACTION_READ : + result =read_command (aux_engine, request, mot_used); +break ; +case I2CAUX_TRANSACTION_WRITE : + result =write_command (aux_engine, request, mot_used); +break ; +default : + result = false; + } + +/* [tcheng] +* need to send stop for the last transaction to free up the AUX +* if the above command fails, this would be the last transaction +*/ + +if (!middle_of_transaction || !result) +end_of_transaction_command (aux_engine, request); + +/* mask AUX interrupt */ + +return result; +} +enum i2caux_engine_type get_engine_type ( +const struct engine *engine) +{ +return I2CAUX_ENGINE_TYPE_AUX ; +} + +static struct aux_engine *acquire ( +struct engine *engine, +struct ddc *ddc) +{ +struct aux_engine *aux_engine =FROM_AUX_ENGINE_ENGINE (engine); +enum gpio_result result; + +if (aux_engine->funcs->is_engine_available) { +/*check whether SW could use the engine*/ +if (!aux_engine->funcs->is_engine_available (aux_engine)) +return NULL ; + } + + result =dal_ddc_open (ddc,GPIO_MODE_HARDWARE , +GPIO_DDC_CONFIG_TYPE_MODE_AUX ); + +if (result !=GPIO_RESULT_OK ) +return NULL ; + +if (!aux_engine->funcs->acquire_engine (aux_engine)) { +dal_ddc_close (ddc); +return NULL ; + } + + engine->ddc = ddc; + +return aux_engine; +} + +static const struct aux_engine_funcs aux_engine_funcs = { + .acquire_engine = acquire_engine, + .submit_channel_request = submit_channel_request, + .process_channel_reply = process_channel_reply, + .read_channel_reply = read_channel_reply, + .get_channel_status = get_channel_status, + .is_engine_available = is_engine_available, +}; + +static const struct engine_funcs engine_funcs = { + .release_engine = release_engine, + .destroy_engine = dce110_engine_destroy, + .submit_request = submit_request, + .get_engine_type = get_engine_type, + .acquire = acquire, +}; + +void dce110_engine_destroy (struct engine **engine) +{ + +struct aux_engine_dce110 *engine110 =FROM_ENGINE (*engine); + +kfree (engine110); + *engine =NULL ; + +} +struct aux_engine *dce110_aux_engine_construct (struct aux_engine_dce110 *aux_engine110, +struct dc_context *ctx, +uint32_t inst, +uint32_t timeout_period, +const struct dce110_aux_registers *regs) +{ + aux_engine110->base.base.ddc =NULL ; + aux_engine110->base.base.ctx = ctx; + aux_engine110->base.delay =0 ; + aux_engine110->base.max_defer_write_retry =0 ; + aux_engine110->base.base.funcs = &engine_funcs; + aux_engine110->base.funcs = &aux_engine_funcs; + aux_engine110->base.base.inst = inst; + aux_engine110->timeout_period = timeout_period; + aux_engine110->regs = regs; + +return &aux_engine110->base; +} +drivers/gpu/drm/amd/display/dc/dce/dce_aux.h new file +111
-0@@ -0,0 +1,111 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_AUX_ENGINE_DCE110_H__ +#define __DAL_AUX_ENGINE_DCE110_H__ +#include "aux_engine.h" + +#define AUX_COMMON_REG_LIST (id)\ + SRI(AUX_CONTROL, DP_AUX, id), \ + SRI(AUX_ARB_CONTROL, DP_AUX, id), \ + SRI(AUX_SW_DATA, DP_AUX, id), \ + SRI(AUX_SW_CONTROL, DP_AUX, id), \ + SRI(AUX_INTERRUPT_CONTROL, DP_AUX, id), \ + SRI(AUX_SW_STATUS, DP_AUX, id), \ + SR(AUXN_IMPCAL), \ + SR(AUXP_IMPCAL) + +struct dce110_aux_registers { +uint32_t AUX_CONTROL; +uint32_t AUX_ARB_CONTROL; +uint32_t AUX_SW_DATA; +uint32_t AUX_SW_CONTROL; +uint32_t AUX_INTERRUPT_CONTROL; +uint32_t AUX_SW_STATUS; +uint32_t AUXN_IMPCAL; +uint32_t AUXP_IMPCAL; + +uint32_t AUX_RESET_MASK; +}; + +enum {/* This is the timeout as defined in DP 1.2a, +* 2.3.4 "Detailed uPacket TX AUX CH State Description". +*/ +AUX_TIMEOUT_PERIOD =400 , + +/* Ideally, the SW timeout should be just above 550usec +* which is programmed in HW. +* But the SW timeout of 600usec is not reliable, +* because on some systems, delay_in_microseconds() +* returns faster than it should. +* EPR #379763: by trial-and-error on different systems, +* 700usec is the minimum reliable SW timeout for polling +* the AUX_SW_STATUS.AUX_SW_DONE bit. +* This timeout expires *only* when there is +* AUX Error or AUX Timeout conditions - not during normal operation. +* During normal operation, AUX_SW_STATUS.AUX_SW_DONE bit is set +* at most within ~240usec. That means, +* increasing this timeout will not affect normal operation, +* and we'll timeout after +* SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD = 1600usec. +* This timeout is especially important for +* resume from S3 and CTS. +*/ +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER =4 +}; +struct aux_engine_dce110 { +struct aux_engine base; +const struct dce110_aux_registers *regs; +struct { +uint32_t aux_control; +uint32_t aux_arb_control; +uint32_t aux_sw_data; +uint32_t aux_sw_control; +uint32_t aux_interrupt_control; +uint32_t aux_sw_status; + } addr; +uint32_t timeout_period; +}; + +struct aux_engine_dce110_init_data { +uint32_t engine_id; +uint32_t timeout_period; +struct dc_context *ctx; +const struct dce110_aux_registers *regs; +}; + +struct aux_engine *dce110_aux_engine_construct ( +struct aux_engine_dce110 *aux_engine110, +struct dc_context *ctx, +uint32_t inst, +uint32_t timeout_period, +const struct dce110_aux_registers *regs); + +void dce110_engine_destroy (struct engine **engine); + +bool dce110_aux_engine_acquire ( +struct engine *aux_engine, +struct ddc *ddc); +#endif drivers/gpu/drm/amd/display/dc/dce100/dce100_resource.c +42
-0@@ -52,6 +52,7 @@#include "dce/dce_10_0_sh_mask.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" #ifndef mmMC_HUB_RDREQ_DMIF_LIMIT@@ -279,7 +280,20 @@ static const struct dce_opp_shift opp_shift = {static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_100 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +};#define audio_regs (id)\ [id] = {\@@ -572,6 +586,23 @@ struct output_pixel_processor *dce100_opp_create(return &opp->base; } +struct engine *dce100_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce100_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -624,6 +655,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -928,6 +963,13 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.engines[i] =dce100_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count;drivers/gpu/drm/amd/display/dc/dce110/dce110_resource.c +45
-0@@ -49,6 +49,7 @@#include "dce/dce_clock_source.h" #include "dce/dce_hwseq.h" #include "dce110/dce110_hw_sequencer.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" @@ -306,6 +307,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_110 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -588,6 +604,23 @@ static struct output_pixel_processor *dce110_opp_create(return &opp->base; } +struct engine *dce110_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce110_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -651,6 +684,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -1258,6 +1295,14 @@ static bool construct( "DC: failed to create output pixel processor!\n"); goto res_create_fail; } + + pool->base.engines[i] =dce110_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->fbc_compressor =dce110_compressor_create (ctx);drivers/gpu/drm/amd/display/dc/dce112/dce112_resource.c +47
-0@@ -49,6 +49,7 @@#include "dce112/dce112_hw_sequencer.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "reg_helper.h" @@ -314,6 +315,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_112 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -588,6 +604,23 @@ struct output_pixel_processor *dce112_opp_create(return &opp->base; } +struct engine *dce112_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} + struct clock_source *dce112_clock_source_create( struct dc_context *ctx, struct dc_bios *bios,@@ -625,6 +658,9 @@ static void destruct(struct dce110_resource_pool *pool)if (pool->base.opps[i] !=NULL )dce110_opp_destroy (&pool->base.opps[i]); +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); +if (pool->base.transforms[i] !=NULL )dce112_transform_destroy (&pool->base.transforms[i]);@@ -640,6 +676,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -1208,6 +1248,13 @@ static bool construct( "DC:failed to create output pixel processor!\n"); goto res_create_fail; } + pool->base.engines[i] =dce112_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } if (!resource_construct(num_virtual_links, dc, &pool->base,drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +42
-0@@ -53,6 +53,7 @@#include "dce/dce_hwseq.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_12_0_offset.h" #include "dce/dce_12_0_sh_mask.h" @@ -297,6 +298,20 @@ static const struct dce_opp_shift opp_shift = {static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_120 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +};#define audio_regs (id)\ [id] = {\@@ -361,6 +376,22 @@ struct output_pixel_processor *dce120_opp_create( ctx, inst, &opp_regs[inst], &opp_shift, &opp_mask);return &opp->base; } +struct engine *dce120_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +}static const struct bios_registers bios_regs = { .BIOS_SCRATCH_6 = mmBIOS_SCRATCH_6 +NBIO_BASE (mmBIOS_SCRATCH_6_BASE_IDX)@@ -467,6 +498,10 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); + }for (i =0 ; i < pool->base.audio_count; i++) {@@ -984,6 +1019,13 @@ static bool construct(dm_error ("DC: failed to create output pixel processor!\n" ); } + pool->base.engines[i] =dce120_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + }/* check next valid pipe */ j++;drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c +44
-0@@ -54,6 +54,7 @@#include "reg_helper.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" #include "dce/dce_abm.h" /* TODO remove this include */ @@ -298,6 +299,21 @@ static const struct dce_opp_mask opp_mask = {OPP_COMMON_MASK_SH_LIST_DCE_80 (_MASK) }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define audio_regs (id)\ [id] = {\ AUD_COMMON_REG_LIST(id)\@@ -448,6 +464,23 @@ static struct output_pixel_processor *dce80_opp_create(return &opp->base; } +struct engine *dce80_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} +static struct stream_encoder *dce80_stream_encoder_create (enum engine_id eng_id,struct dc_context *ctx)@@ -655,6 +688,9 @@ static void destruct(struct dce110_resource_pool *pool)kfree (DCE110TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) +dce110_engine_destroy (&pool->base.engines[i]); }for (i =0 ; i < pool->base.stream_enc_count; i++) {@@ -899,6 +935,14 @@ static bool dce80_construct(dm_error ("DC: failed to create output pixel processor!\n" ); goto res_create_fail; } + + pool->base.engines[i] =dce80_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto res_create_fail; + } } dc->caps.max_planes = pool->base.pipe_count;drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +44
-0@@ -64,6 +64,7 @@#include "reg_helper.h" #include "dce/dce_abm.h" #include "dce/dce_dmcu.h" +#include "dce/dce_aux.h" const struct _vcs_dpi_ip_params_st dcn1_0_ip = { .rob_buffer_size_kbytes =64 ,@@ -356,6 +357,21 @@ static const struct dcn10_opp_mask opp_mask = { OPP_MASK_SH_LIST_DCN10(_MASK), }; +#define aux_engine_regs (id)\ +[id] = {\ + AUX_COMMON_REG_LIST(id), \ + .AUX_RESET_MASK = 0 \ +} + +static const struct dce110_aux_registers aux_engine_regs[] = { +aux_engine_regs (0 ), +aux_engine_regs (1 ), +aux_engine_regs (2 ), +aux_engine_regs (3 ), +aux_engine_regs (4 ), +aux_engine_regs (5 ) +}; +#define tf_regs (id)\ [id] = {\ TF_REG_LIST_DCN10(id),\@@ -578,6 +594,23 @@ static struct output_pixel_processor *dcn10_opp_create(return &opp->base; } +struct engine *dcn10_aux_engine_create ( +struct dc_context *ctx, +uint32_t inst) +{ +struct aux_engine_dce110 *aux_engine = +kzalloc (sizeof (struct aux_engine_dce110 ),GFP_KERNEL ); + +if (!aux_engine) +return NULL ; + +dce110_aux_engine_construct (aux_engine, ctx, inst, +SW_AUX_TIMEOUT_PERIOD_MULTIPLIER *AUX_TIMEOUT_PERIOD , + &aux_engine_regs[inst]); + +return &aux_engine->base.base; +} +static struct mpc *dcn10_mpc_create (struct dc_context *ctx) { struct dcn10_mpc *mpc10 = kzalloc(sizeof(struct dcn10_mpc),@@ -826,6 +859,9 @@ static void destruct(struct dcn10_resource_pool *pool)kfree (DCN10TG_FROM_TG (pool->base.timing_generators[i])); pool->base.timing_generators[i] =NULL ; } + +if (pool->base.engines[i] !=NULL ) + pool->base.engines[i]->funcs->destroy_engine (&pool->base.engines[i]); }for (i =0 ; i < pool->base.stream_enc_count; i++)@@ -1255,6 +1291,14 @@ static bool construct( goto fail; } + pool->base.engines[i] =dcn10_aux_engine_create (ctx, i); +if (pool->base.engines[i] ==NULL ) { +BREAK_TO_DEBUGGER (); +dm_error ( +"DC:failed to create aux engine!!\n" ); + goto fail; + } +/* check next valid pipe */ j++; }drivers/gpu/drm/amd/display/dc/i2caux/engine.h +1
-0@@ -96,6 +96,7 @@ struct engine_funcs {struct engine {const struct engine_funcs *funcs; +uint32_t inst;struct ddc *ddc;struct dc_context *ctx; };drivers/gpu/drm/amd/display/dc/inc/core_types.h +1
-1@@ -138,7 +138,7 @@ struct resource_pool {struct output_pixel_processor *opps[MAX_PIPES ];struct timing_generator *timing_generators[MAX_PIPES ];struct stream_encoder *stream_enc[MAX_PIPES *2 ]; - +struct engine *engines[MAX_PIPES ];struct hubbub *hubbub;struct mpc *mpc;struct pp_smu_funcs_rv *pp_smu;drivers/gpu/drm/amd/display/dc/inc/hw/aux_engine.h new file +113
-0@@ -0,0 +1,113 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_AUX_ENGINE_H__ +#define __DAL_AUX_ENGINE_H__ + +#include "engine.h" +#include "include/i2caux_interface.h" + +struct aux_engine ; +union aux_config ; +struct aux_engine_funcs { +void (*destroy)( +struct aux_engine **ptr); +bool (*acquire_engine)( +struct aux_engine *engine); +void (*configure)( +struct aux_engine *engine, +union aux_config cfg); +void (*submit_channel_request)( +struct aux_engine *engine, +struct aux_request_transaction_data *request); +void (*process_channel_reply)( +struct aux_engine *engine, +struct aux_reply_transaction_data *reply); +int (*read_channel_reply)( +struct aux_engine *engine, +uint32_t size, +uint8_t *buffer, +uint8_t *reply_result, +uint32_t *sw_status); +enum aux_channel_operation_result (*get_channel_status)( +struct aux_engine *engine, +uint8_t *returned_bytes); +bool (*is_engine_available)(struct aux_engine *engine); +}; +struct engine ; +struct aux_engine { +struct engine base; +const struct aux_engine_funcs *funcs; +/* following values are expressed in milliseconds */ +uint32_t delay; +uint32_t max_defer_write_retry; + +bool acquire_reset; +}; +struct read_command_context { +uint8_t *buffer; +uint32_t current_read_length; +uint32_t offset; +enum i2caux_transaction_status status; + +struct aux_request_transaction_data request; +struct aux_reply_transaction_data reply; + +uint8_t returned_byte; + +uint32_t timed_out_retry_aux; +uint32_t invalid_reply_retry_aux; +uint32_t defer_retry_aux; +uint32_t defer_retry_i2c; +uint32_t invalid_reply_retry_aux_on_ack; + +bool transaction_complete; +bool operation_succeeded; +}; +struct write_command_context { +bool mot; + +uint8_t *buffer; +uint32_t current_write_length; +enum i2caux_transaction_status status; + +struct aux_request_transaction_data request; +struct aux_reply_transaction_data reply; + +uint8_t returned_byte; + +uint32_t timed_out_retry_aux; +uint32_t invalid_reply_retry_aux; +uint32_t defer_retry_aux; +uint32_t defer_retry_i2c; +uint32_t max_defer_retry; +uint32_t ack_m_retry; + +uint8_t reply_data[DEFAULT_AUX_MAX_DATA_SIZE ]; + +bool transaction_complete; +bool operation_succeeded; +}; +#endif drivers/gpu/drm/amd/display/dc/inc/hw/engine.h new file +106
-1@@ -0,0 +1,106 @@ +/* +* Copyright 2012-15 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __DAL_ENGINE_H__ +#define __DAL_ENGINE_H__ + +#include "dc_ddc_types.h" + +enum i2caux_transaction_operation { +I2CAUX_TRANSACTION_READ , +I2CAUX_TRANSACTION_WRITE +}; + +enum i2caux_transaction_address_space { +I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C =1 , +I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD +}; + +struct i2caux_transaction_payload { +enum i2caux_transaction_address_space address_space; +uint32_t address; +uint32_t length; +uint8_t *data; +}; + +enum i2caux_transaction_status { +I2CAUX_TRANSACTION_STATUS_UNKNOWN = (-1L ), +I2CAUX_TRANSACTION_STATUS_SUCCEEDED , +I2CAUX_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY , +I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT , +I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR , +I2CAUX_TRANSACTION_STATUS_FAILED_NACK , +I2CAUX_TRANSACTION_STATUS_FAILED_INCOMPLETE , +I2CAUX_TRANSACTION_STATUS_FAILED_OPERATION , +I2CAUX_TRANSACTION_STATUS_FAILED_INVALID_OPERATION , +I2CAUX_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW , +I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON +}; + +struct i2caux_transaction_request { +enum i2caux_transaction_operation operation; +struct i2caux_transaction_payload payload; +enum i2caux_transaction_status status; +}; + +enum i2caux_engine_type { +I2CAUX_ENGINE_TYPE_UNKNOWN = (-1L ), +I2CAUX_ENGINE_TYPE_AUX , +I2CAUX_ENGINE_TYPE_I2C_DDC_HW , +I2CAUX_ENGINE_TYPE_I2C_GENERIC_HW , +I2CAUX_ENGINE_TYPE_I2C_SW +}; + +enum i2c_default_speed { +I2CAUX_DEFAULT_I2C_HW_SPEED =50 , +I2CAUX_DEFAULT_I2C_SW_SPEED =50 +}; + +struct engine ; + +struct engine_funcs { +enum i2caux_engine_type (*get_engine_type)( +const struct engine *engine); +struct aux_engine * (*acquire)( +struct engine *engine, +struct ddc *ddc); +bool (*submit_request)( +struct engine *engine, +struct i2caux_transaction_request *request, +bool middle_of_transaction); +void (*release_engine)( +struct engine *engine); +void (*destroy_engine)( +struct engine **engine); +}; + +struct engine { +const struct engine_funcs *funcs; +uint32_t inst; +struct ddc *ddc; +struct dc_context *ctx; +}; + +#endif --2.7.4
Quoted 4 lines
_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 6/7 drm/amd/display: separate dc_debug into dc_debug_options and dc_debug data
In reply to a message not in the archiveFrom: Jun Lei <[email protected]>
[why]
confusing as to which part of debug is informational, and which part causes behavioral change
--- drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c | 2 +- drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +- drivers/gpu/drm/amd/display/dc/dc.h | 19 +++++++++++-------- drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c | 4 ++-- .../gpu/drm/amd/display/dc/dce120/dce120_resource.c | 2 +- drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c | 4 ++-- 6 files changed, 18 insertions(+), 15 deletions(-)
drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +1 -1
@@ -676,7 +676,7 @@ static void hack_force_pipe_split(struct dcn_bw_internal_vars *v, }static void hack_bounding_box (struct dcn_bw_internal_vars *v, -struct dc_debug *dbg, +struct dc_debug_options *dbg,struct dc_state *context) {if (dbg->pipe_split_policy ==MPC_SPLIT_AVOID )
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c +1 -1
@@ -1029,7 +1029,7 @@ enum link_training_result dc_link_dp_perform_link_training( lt_settings.lane_settings[0].PRE_EMPHASIS);if (status !=LINK_TRAINING_SUCCESS ) - link->ctx->dc->debug.debug_data.ltFailCount++; + link->ctx->dc->debug_data.ltFailCount++;return status; }
drivers/gpu/drm/amd/display/dc/dc.h +11 -8
@@ -207,7 +207,7 @@ struct dc_clocks {int phyclk_khz; }; -struct dc_debug { +struct dc_debug_options {enum visual_confirm visual_confirm;bool sanity_checks;bool max_disp_clk;
@@ -259,13 +259,15 @@ struct dc_debug {bool scl_reset_length10;bool hdmi20_disable;bool skip_detection_link_training; +}; -struct { -uint32_t ltFailCount; -uint32_t i2cErrorCount; -uint32_t auxErrorCount; - } debug_data; +struct dc_debug_data { +uint32_t ltFailCount; +uint32_t i2cErrorCount; +uint32_t auxErrorCount; }; + +struct dc_state ;struct resource_pool ;struct dce_hwseq ;
@@ -274,8 +276,7 @@ struct dc {struct dc_caps caps;struct dc_cap_funcs cap_funcs;struct dc_config config; -struct dc_debug debug; - +struct dc_debug_options debug;struct dc_context *ctx;uint8_t link_count;
@@ -311,6 +312,8 @@ struct dc {/* FBC compressor */ struct compressor *fbc_compressor; + +struct dc_debug_data debug_data; };enum frame_buffer_mode {
drivers/gpu/drm/amd/display/dc/dce/dce_clocks.c +2 -2
@@ -337,7 +337,7 @@ static int dce112_set_clock(static void dce_clock_read_integrated_info (struct dce_dccg *clk_dce) { -struct dc_debug *debug = &clk_dce->base.ctx->dc->debug; +struct dc_debug_options *debug = &clk_dce->base.ctx->dc->debug;struct dc_bios *bp = clk_dce->base.ctx->dc_bios;struct integrated_info info = { { {0 } } };struct dc_firmware_info fw_info = { {0 } };
@@ -824,7 +824,7 @@ struct dccg *dce120_dccg_create(struct dc_context *ctx)#ifdef CONFIG_DRM_AMD_DC_DCN1_0 struct dccg *dcn1_dccg_create (struct dc_context *ctx) { -struct dc_debug *debug = &ctx->dc->debug; +struct dc_debug_options *debug = &ctx->dc->debug;struct dc_bios *bp = ctx->dc_bios;struct dc_firmware_info fw_info = { {0 } };struct dce_dccg *clk_dce =kzalloc (sizeof (*clk_dce),GFP_KERNEL );
drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c +1 -1
@@ -404,7 +404,7 @@ static const struct resource_caps res_cap = { .num_pll = 6, }; -static const struct dc_debug debug_defaults = { +static const struct dc_debug_options debug_defaults = { .disable_clock_gate = true, };
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c +2 -2
@@ -502,7 +502,7 @@ static const struct resource_caps res_cap = { .num_pll = 4, }; -static const struct dc_debug debug_defaults_drv = { +static const struct dc_debug_options debug_defaults_drv = { .sanity_checks = true, .disable_dmcu = true, .force_abm_enable = false,
@@ -530,7 +530,7 @@ static const struct dc_debug debug_defaults_drv = { .max_downscale_src_width = 3840, }; -static const struct dc_debug debug_defaults_diags = { +static const struct dc_debug_options debug_defaults_diags = { .disable_dmcu = true, .force_abm_enable = false, .timing_trace = true,
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 7/7 drm/amd/display: dal 3.1.58
In reply to a message not in the archiveFrom: Harry Wentland <[email protected]>
--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dc.h +1 -1
@@ -38,7 +38,7 @@#include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.56" +#define DC_VER "3.1.58"#define MAX_SURFACES 3#define MAX_STREAMS 6
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1531834174-4052-8-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org
Re: [PATCH 7/7] drm/amd/display: dal 3.1.58
Dear AMDGPU folks,
Quoted 15 lines · On 07/17/18 15:29, [email protected] wrote:
From: Harry Wentland <[email protected]>
Change-Id I788210abbb33e0a38267c9bfd3656f51c844d5acSigned-off-by Harry Wentland <[email protected]>Reviewed-by Aric Cyr <[email protected]>Acked-by Leo Li <[email protected]>--- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/display/dc/dc.h +0
-0
drivers/gpu/drm/amd/display/dc/dc.h line 44
Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dc.h +1
-1@@ -38,7 +38,7 @@#include "inc/compressor.h" #include "dml/display_mode_lib.h" -#define DC_VER "3.1.56" +#define DC_VER "3.1.58"#define MAX_SURFACES 3#define MAX_STREAMS 6
Being new, and trying to get everything to work on a new board looking through the commits, I am clueless what DAL is.
Searching the Web, I found [1]:
Quoted 2 lines
DAL name is somewhat historic. We're trying to get away from it to. Avoid confusion and. Set right direction. Maybe just “Display Core”
Has the goal changed? If not, could the commit message please be revised?
Quoted 1 line
Increase Display Core version to 3.1.58
Also it’s not clear to me, why 3.1.57 is left out (unstable/stable scheme)?
Kind regards,
Paul
[1]: https://www.x.org/wiki/Events/XDC2016/Program/amd_dal.pdf
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx