	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function a5xx_gpmu_init
_a5xx_gpmu_init:                        ## @a5xx_gpmu_init
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	callq	_to_adreno_gpu
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	_to_a5xx_gpu
	cmpl	$0, (%rax)
	je	LBB0_1
## %bb.2:
	movq	%rax, %r13
	movq	16(%r12), %rax
	movq	(%rax), %rbx
	movq	_CP_SET_PROTECTED_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	$1, %edx
	callq	_OUT_PKT7
	xorl	%r14d, %r14d
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_OUT_RING
	movq	_CP_INDIRECT_BUFFER_PFE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	$3, %edx
	callq	_OUT_PKT7
	movl	4(%r13), %edi
	callq	_lower_32_bits
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_OUT_RING
	movl	4(%r13), %edi
	callq	_upper_32_bits
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_OUT_RING
	movl	(%r13), %esi
	movq	%rbx, %rdi
	callq	_OUT_RING
	movq	_CP_SET_PROTECTED_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%rbx, %rdi
	movl	$1, %edx
	callq	_OUT_PKT7
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_OUT_RING
	movq	8(%r12), %rax
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	*(%rax)
	movq	%r12, %rdi
	movq	%rbx, %rsi
	callq	_a5xx_idle
	testl	%eax, %eax
	je	LBB0_3
## %bb.4:
	movq	%r15, %rdi
	callq	_adreno_is_a530
	testq	%rax, %rax
	je	LBB0_6
## %bb.5:
	movq	_REG_A5XX_GPMU_WFI_CONFIG@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	movl	$16404, %edx                    ## imm = 0x4014
	callq	_gpu_write
LBB0_6:
	movq	_REG_A5XX_GPMU_CM3_SYSRESET@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	xorl	%r14d, %r14d
	movq	%r12, %rdi
	xorl	%edx, %edx
	callq	_gpu_write
	movq	_REG_A5XX_GPMU_GENERAL_0@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	movl	$25, %esi
	movl	$-1, %ecx
	movl	$-1161889074, %r8d              ## imm = 0xBABEFACE
	callq	_spin_usecs
	testq	%rax, %rax
	je	LBB0_8
## %bb.7:
	movl	(%r12), %esi
	leaq	L_.str.1(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_ERROR
LBB0_8:
	movq	%r15, %rdi
	callq	_adreno_is_a530
	testq	%rax, %rax
	jne	LBB0_11
## %bb.9:
	movq	_REG_A5XX_GPMU_GENERAL_1@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r12, %rdi
	callq	_gpu_read
	testq	%rax, %rax
	je	LBB0_11
## %bb.10:
	movl	(%r12), %esi
	leaq	L_.str.2(%rip), %rdi
	xorl	%r14d, %r14d
	movq	%rax, %rdx
	xorl	%eax, %eax
	callq	_DRM_ERROR
	jmp	LBB0_11
LBB0_1:
	xorl	%r14d, %r14d
	jmp	LBB0_11
LBB0_3:
	movl	(%r12), %esi
	leaq	L_.str(%rip), %rdi
	xorl	%eax, %eax
	callq	_DRM_ERROR
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %r14d
LBB0_11:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CP_SET_PROTECTED_MODE,4,2      ## @CP_SET_PROTECTED_MODE
	.comm	_CP_INDIRECT_BUFFER_PFE,4,2     ## @CP_INDIRECT_BUFFER_PFE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"%s: Unable to load GPMU firmware. GPMU will not be active\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_REG_A5XX_GPMU_WFI_CONFIG,4,2   ## @REG_A5XX_GPMU_WFI_CONFIG
	.comm	_REG_A5XX_GPMU_CM3_SYSRESET,4,2 ## @REG_A5XX_GPMU_CM3_SYSRESET
	.comm	_REG_A5XX_GPMU_GENERAL_0,4,2    ## @REG_A5XX_GPMU_GENERAL_0
L_.str.1:                               ## @.str.1
	.asciz	"%s: GPMU firmware initialization timed out\n"

	.comm	_REG_A5XX_GPMU_GENERAL_1,4,2    ## @REG_A5XX_GPMU_GENERAL_1
L_.str.2:                               ## @.str.2
	.asciz	"%s: GPMU firmware initialization failed: %d\n"

	.no_dead_strip	_a5xx_gpmu_init
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function a5xx_gpmu_init
_a5xx_gpmu_init:                        ; @a5xx_gpmu_init
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x19, x0
	bl	_to_adreno_gpu
	mov	x20, x0
	bl	_to_a5xx_gpu
	ldr	w8, [x0]
	cbz	w8, LBB0_9
; %bb.1:
	mov	x22, x0
	ldr	x8, [x19, #16]
	ldr	x21, [x8]
Lloh0:
	adrp	x23, _CP_SET_PROTECTED_MODE@GOTPAGE
Lloh1:
	ldr	x23, [x23, _CP_SET_PROTECTED_MODE@GOTPAGEOFF]
	ldr	w1, [x23]
	mov	x0, x21
	mov	w2, #1
	bl	_OUT_PKT7
	mov	x0, x21
	mov	w1, #0
	bl	_OUT_RING
Lloh2:
	adrp	x8, _CP_INDIRECT_BUFFER_PFE@GOTPAGE
Lloh3:
	ldr	x8, [x8, _CP_INDIRECT_BUFFER_PFE@GOTPAGEOFF]
Lloh4:
	ldr	w1, [x8]
	mov	x0, x21
	mov	w2, #3
	bl	_OUT_PKT7
	ldr	w0, [x22, #4]
	bl	_lower_32_bits
	mov	x1, x0
	mov	x0, x21
	bl	_OUT_RING
	ldr	w0, [x22, #4]
	bl	_upper_32_bits
	mov	x1, x0
	mov	x0, x21
	bl	_OUT_RING
	ldr	w1, [x22]
	mov	x0, x21
	bl	_OUT_RING
	ldr	w1, [x23]
	mov	x0, x21
	mov	w2, #1
	bl	_OUT_PKT7
	mov	x0, x21
	mov	w1, #1
	bl	_OUT_RING
	ldr	x8, [x19, #8]
	ldr	x8, [x8]
	mov	x0, x19
	mov	x1, x21
	blr	x8
	mov	x0, x19
	mov	x1, x21
	bl	_a5xx_idle
	cbz	w0, LBB0_10
; %bb.2:
	mov	x0, x20
	bl	_adreno_is_a530
	cbz	x0, LBB0_4
; %bb.3:
Lloh5:
	adrp	x8, _REG_A5XX_GPMU_WFI_CONFIG@GOTPAGE
Lloh6:
	ldr	x8, [x8, _REG_A5XX_GPMU_WFI_CONFIG@GOTPAGEOFF]
Lloh7:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #16404
	bl	_gpu_write
LBB0_4:
Lloh8:
	adrp	x8, _REG_A5XX_GPMU_CM3_SYSRESET@GOTPAGE
Lloh9:
	ldr	x8, [x8, _REG_A5XX_GPMU_CM3_SYSRESET@GOTPAGEOFF]
Lloh10:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #0
	bl	_gpu_write
Lloh11:
	adrp	x8, _REG_A5XX_GPMU_GENERAL_0@GOTPAGE
Lloh12:
	ldr	x8, [x8, _REG_A5XX_GPMU_GENERAL_0@GOTPAGEOFF]
Lloh13:
	ldr	w2, [x8]
	mov	x0, x19
	mov	w1, #25
	mov	w3, #-1
	mov	w4, #64206
	movk	w4, #47806, lsl #16
	bl	_spin_usecs
	cbz	x0, LBB0_6
; %bb.5:
	ldr	w1, [x19]
Lloh14:
	adrp	x0, l_.str.1@PAGE
Lloh15:
	add	x0, x0, l_.str.1@PAGEOFF
	bl	_DRM_ERROR
LBB0_6:
	mov	x0, x20
	bl	_adreno_is_a530
	cbnz	x0, LBB0_9
; %bb.7:
Lloh16:
	adrp	x8, _REG_A5XX_GPMU_GENERAL_1@GOTPAGE
Lloh17:
	ldr	x8, [x8, _REG_A5XX_GPMU_GENERAL_1@GOTPAGEOFF]
Lloh18:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_gpu_read
	cbz	x0, LBB0_11
; %bb.8:
	ldr	w1, [x19]
	str	x0, [sp]
Lloh19:
	adrp	x0, l_.str.2@PAGE
Lloh20:
	add	x0, x0, l_.str.2@PAGEOFF
	bl	_DRM_ERROR
LBB0_9:
	mov	w0, #0
	b	LBB0_11
LBB0_10:
	ldr	w1, [x19]
Lloh21:
	adrp	x0, l_.str@PAGE
Lloh22:
	add	x0, x0, l_.str@PAGEOFF
	bl	_DRM_ERROR
Lloh23:
	adrp	x8, _EINVAL@GOTPAGE
Lloh24:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh25:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_11:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpAdd	Lloh21, Lloh22
	.cfi_endproc
                                        ; -- End function
	.comm	_CP_SET_PROTECTED_MODE,4,2      ; @CP_SET_PROTECTED_MODE
	.comm	_CP_INDIRECT_BUFFER_PFE,4,2     ; @CP_INDIRECT_BUFFER_PFE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"%s: Unable to load GPMU firmware. GPMU will not be active\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_REG_A5XX_GPMU_WFI_CONFIG,4,2   ; @REG_A5XX_GPMU_WFI_CONFIG
	.comm	_REG_A5XX_GPMU_CM3_SYSRESET,4,2 ; @REG_A5XX_GPMU_CM3_SYSRESET
	.comm	_REG_A5XX_GPMU_GENERAL_0,4,2    ; @REG_A5XX_GPMU_GENERAL_0
l_.str.1:                               ; @.str.1
	.asciz	"%s: GPMU firmware initialization timed out\n"

	.comm	_REG_A5XX_GPMU_GENERAL_1,4,2    ; @REG_A5XX_GPMU_GENERAL_1
l_.str.2:                               ; @.str.2
	.asciz	"%s: GPMU firmware initialization failed: %d\n"

	.no_dead_strip	_a5xx_gpmu_init
.subsections_via_symbols
