	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sja1105_static_config_upload   ## -- Begin function sja1105_static_config_upload
	.p2align	4, 0x90
_sja1105_static_config_upload:          ## @sja1105_static_config_upload
	.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
	subq	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	movq	_SJA1105_NUM_PORTS@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	decq	%rdi
	xorl	%r13d, %r13d
	xorl	%esi, %esi
	callq	_GENMASK_ULL
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	leaq	16(%rbx), %rdi
	movq	(%rbx), %rax
	movq	8(%rbx), %r15
	movq	8(%rax), %rax
	movq	%rax, -64(%rbp)                 ## 8-byte Spill
	movq	_RETRIES@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	callq	_sja1105_static_config_get_length
	movl	%eax, %r12d
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	%r12d, %edi
	movl	$1, %esi
	callq	_kcalloc
	testq	%rax, %rax
	je	LBB0_1
## %bb.2:
	movq	%rbx, %rdi
	movq	%rax, -48(%rbp)                 ## 8-byte Spill
	movq	%rax, %rsi
	movl	%r12d, %edx
	callq	_static_config_buf_prepare_for_upload
	testl	%eax, %eax
	js	LBB0_3
## %bb.5:
	movq	%rbx, %rdi
	movq	-56(%rbp), %rsi                 ## 8-byte Reload
	movl	$1, %edx
	callq	_sja1105_inhibit_tx
	testl	%eax, %eax
	js	LBB0_6
## %bb.7:
	movl	$500, %edi                      ## imm = 0x1F4
	movl	$1000, %esi                     ## imm = 0x3E8
	callq	_usleep_range
	movq	_SPI_WRITE@GOTPCREL(%rip), %r13
	jmp	LBB0_8
	.p2align	4, 0x90
LBB0_9:                                 ##   in Loop: Header=BB0_8 Depth=1
	movq	%r15, %rdi
	leaq	L_.str.2(%rip), %rsi
LBB0_21:                                ##   in Loop: Header=BB0_8 Depth=1
	xorl	%eax, %eax
	callq	_dev_err
LBB0_22:                                ##   in Loop: Header=BB0_8 Depth=1
	decl	%r14d
	je	LBB0_24
LBB0_8:                                 ## =>This Inner Loop Header: Depth=1
	movq	%rbx, %rdi
	callq	_sja1105_cold_reset
	testl	%eax, %eax
	js	LBB0_9
## %bb.10:                              ##   in Loop: Header=BB0_8 Depth=1
	movl	$1000, %edi                     ## imm = 0x3E8
	movl	$5000, %esi                     ## imm = 0x1388
	callq	_usleep_range
	movl	(%r13), %esi
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edx
	movq	%rbx, %rdi
	movq	-48(%rbp), %rcx                 ## 8-byte Reload
	movl	%r12d, %r8d
	callq	_sja1105_spi_send_long_packed_buf
	testl	%eax, %eax
	js	LBB0_11
## %bb.12:                              ##   in Loop: Header=BB0_8 Depth=1
	movq	%rbx, %rdi
	leaq	-88(%rbp), %rsi
	callq	_sja1105_status_get
	testl	%eax, %eax
	js	LBB0_22
## %bb.13:                              ##   in Loop: Header=BB0_8 Depth=1
	cmpl	$1, -88(%rbp)
	jne	LBB0_15
## %bb.14:                              ##   in Loop: Header=BB0_8 Depth=1
	movl	16(%rbx), %edx
	movq	(%rbx), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	leaq	L_.str.4(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_22
	.p2align	4, 0x90
LBB0_11:                                ##   in Loop: Header=BB0_8 Depth=1
	movq	%r15, %rdi
	leaq	L_.str.3(%rip), %rsi
	jmp	LBB0_21
LBB0_15:                                ##   in Loop: Header=BB0_8 Depth=1
	cmpl	$1, -84(%rbp)
	jne	LBB0_17
## %bb.16:                              ##   in Loop: Header=BB0_8 Depth=1
	movq	%r15, %rdi
	leaq	L_.str.5(%rip), %rsi
	jmp	LBB0_21
LBB0_17:                                ##   in Loop: Header=BB0_8 Depth=1
	cmpl	$1, -80(%rbp)
	jne	LBB0_19
## %bb.18:                              ##   in Loop: Header=BB0_8 Depth=1
	movq	%r15, %rdi
	leaq	L_.str.6(%rip), %rsi
	jmp	LBB0_21
LBB0_19:                                ##   in Loop: Header=BB0_8 Depth=1
	cmpq	$0, -72(%rbp)
	jne	LBB0_23
## %bb.20:                              ##   in Loop: Header=BB0_8 Depth=1
	movq	%r15, %rdi
	leaq	L_.str.7(%rip), %rsi
	jmp	LBB0_21
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_31
LBB0_3:
	leaq	L_.str(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_30
LBB0_6:
	leaq	L_.str.1(%rip), %rsi
	xorl	%r13d, %r13d
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_err
	movq	_ENXIO@GOTPCREL(%rip), %rax
	subl	(%rax), %r13d
	jmp	LBB0_30
LBB0_23:
	testl	%r14d, %r14d
	je	LBB0_24
## %bb.25:
	movq	_RETRIES@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	subl	%r14d, %edx
	je	LBB0_27
## %bb.26:
	leaq	L_.str.9(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_info
LBB0_27:
	movq	%rbx, %rdi
	callq	_sja1105_ptp_reset
	movl	%eax, %r13d
	testl	%eax, %eax
	jns	LBB0_29
## %bb.28:
	leaq	L_.str.10(%rip), %rsi
	movq	%r15, %rdi
	movl	%r13d, %edx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_29:
	leaq	L_.str.11(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_info
	jmp	LBB0_30
LBB0_24:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%r13d, %r13d
	subl	(%rax), %r13d
	leaq	L_.str.8(%rip), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	callq	_dev_err
LBB0_30:
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_kfree
LBB0_31:
	movl	%r13d, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SJA1105_NUM_PORTS,8,3          ## @SJA1105_NUM_PORTS
	.comm	_RETRIES,4,2                    ## @RETRIES
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Invalid config, cannot upload\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.1:                               ## @.str.1
	.asciz	"Failed to inhibit Tx on ports\n"

	.comm	_ENXIO,4,2                      ## @ENXIO
L_.str.2:                               ## @.str.2
	.asciz	"Failed to reset switch, retrying...\n"

	.comm	_SPI_WRITE,4,2                  ## @SPI_WRITE
L_.str.3:                               ## @.str.3
	.asciz	"Failed to upload config, retrying...\n"

L_.str.4:                               ## @.str.4
	.asciz	"Mismatch between hardware and static config device id. Wrote 0x%llx, wants 0x%llx\n"

L_.str.5:                               ## @.str.5
	.asciz	"Switch reported invalid local CRC on the uploaded config, retrying...\n"

L_.str.6:                               ## @.str.6
	.asciz	"Switch reported invalid global CRC on the uploaded config, retrying...\n"

L_.str.7:                               ## @.str.7
	.asciz	"Switch reported that configuration is invalid, retrying...\n"

	.comm	_EIO,4,2                        ## @EIO
L_.str.8:                               ## @.str.8
	.asciz	"Failed to upload config to device, giving up\n"

L_.str.9:                               ## @.str.9
	.asciz	"Succeeded after %d tried\n"

L_.str.10:                              ## @.str.10
	.asciz	"Failed to reset PTP clock: %d\n"

L_.str.11:                              ## @.str.11
	.asciz	"Reset switch and programmed static config\n"

.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_sja1105_static_config_upload   ; -- Begin function sja1105_static_config_upload
	.p2align	2
_sja1105_static_config_upload:          ; @sja1105_static_config_upload
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #144
	.cfi_def_cfa_offset 144
	stp	x28, x27, [sp, #48]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #64]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #80]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #96]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #112]            ; 16-byte Folded Spill
	stp	x29, x30, [sp, #128]            ; 16-byte Folded Spill
	add	x29, sp, #128
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x21, x0
Lloh0:
	adrp	x8, _SJA1105_NUM_PORTS@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SJA1105_NUM_PORTS@GOTPAGEOFF]
Lloh2:
	ldr	x8, [x8]
	sub	x0, x8, #1
	mov	w1, #0
	bl	_GENMASK_ULL
	mov	x23, x0
	add	x0, x21, #16
	ldp	x8, x20, [x21]
	ldr	x26, [x8, #8]
Lloh3:
	adrp	x27, _RETRIES@GOTPAGE
Lloh4:
	ldr	x27, [x27, _RETRIES@GOTPAGEOFF]
	ldr	w28, [x27]
	bl	_sja1105_static_config_get_length
	mov	x22, x0
Lloh5:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh6:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh7:
	ldr	w2, [x8]
	mov	w1, #1
	bl	_kcalloc
	cbz	x0, LBB0_19
; %bb.1:
	mov	x19, x0
	mov	x0, x21
	mov	x1, x19
	mov	x2, x22
	bl	_static_config_buf_prepare_for_upload
	tbnz	w0, #31, LBB0_20
; %bb.2:
	mov	x0, x21
	mov	x1, x23
	mov	w2, #1
	bl	_sja1105_inhibit_tx
	tbnz	w0, #31, LBB0_21
; %bb.3:
	mov	w0, #500
	mov	w1, #1000
	bl	_usleep_range
Lloh8:
	adrp	x23, l_.str.2@PAGE
Lloh9:
	add	x23, x23, l_.str.2@PAGEOFF
Lloh10:
	adrp	x25, _SPI_WRITE@GOTPAGE
Lloh11:
	ldr	x25, [x25, _SPI_WRITE@GOTPAGEOFF]
Lloh12:
	adrp	x24, l_.str.3@PAGE
Lloh13:
	add	x24, x24, l_.str.3@PAGEOFF
	b	LBB0_7
LBB0_4:                                 ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
	mov	x1, x23
LBB0_5:                                 ;   in Loop: Header=BB0_7 Depth=1
	bl	_dev_err
LBB0_6:                                 ;   in Loop: Header=BB0_7 Depth=1
	subs	w28, w28, #1
	b.eq	LBB0_29
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x21
	bl	_sja1105_cold_reset
	tbnz	w0, #31, LBB0_4
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	w0, #1000
	mov	w1, #5000
	bl	_usleep_range
	ldr	w1, [x25]
	ldr	w2, [x26]
	mov	x0, x21
	mov	x3, x19
	mov	x4, x22
	bl	_sja1105_spi_send_long_packed_buf
	tbnz	w0, #31, LBB0_12
; %bb.9:                                ;   in Loop: Header=BB0_7 Depth=1
	add	x1, sp, #24
	mov	x0, x21
	bl	_sja1105_status_get
	tbnz	w0, #31, LBB0_6
; %bb.10:                               ;   in Loop: Header=BB0_7 Depth=1
	ldr	w8, [sp, #24]
	cmp	w8, #1
	b.ne	LBB0_13
; %bb.11:                               ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [x21]
	ldr	w9, [x21, #16]
	ldr	w8, [x8]
	stp	x9, x8, [sp]
	mov	x0, x20
Lloh14:
	adrp	x1, l_.str.4@PAGE
Lloh15:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_5
LBB0_12:                                ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
	mov	x1, x24
	b	LBB0_5
LBB0_13:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w8, [sp, #28]
	cmp	w8, #1
	b.ne	LBB0_15
; %bb.14:                               ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
Lloh16:
	adrp	x1, l_.str.5@PAGE
Lloh17:
	add	x1, x1, l_.str.5@PAGEOFF
	b	LBB0_5
LBB0_15:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	w8, [sp, #32]
	cmp	w8, #1
	b.ne	LBB0_17
; %bb.16:                               ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
Lloh18:
	adrp	x1, l_.str.6@PAGE
Lloh19:
	add	x1, x1, l_.str.6@PAGEOFF
	b	LBB0_5
LBB0_17:                                ;   in Loop: Header=BB0_7 Depth=1
	ldr	x8, [sp, #40]
	cbnz	x8, LBB0_23
; %bb.18:                               ;   in Loop: Header=BB0_7 Depth=1
	mov	x0, x20
Lloh20:
	adrp	x1, l_.str.7@PAGE
Lloh21:
	add	x1, x1, l_.str.7@PAGEOFF
	b	LBB0_5
LBB0_19:
Lloh22:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh23:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh24:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_31
LBB0_20:
Lloh25:
	adrp	x1, l_.str@PAGE
Lloh26:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh27:
	adrp	x8, _EINVAL@GOTPAGE
Lloh28:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
	b	LBB0_22
LBB0_21:
Lloh29:
	adrp	x1, l_.str.1@PAGE
Lloh30:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh31:
	adrp	x8, _ENXIO@GOTPAGE
Lloh32:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
LBB0_22:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_30
LBB0_23:
	cbz	w28, LBB0_29
; %bb.24:
	ldr	w8, [x27]
	subs	w8, w8, w28
	b.eq	LBB0_26
; %bb.25:
	str	x8, [sp]
Lloh33:
	adrp	x1, l_.str.9@PAGE
Lloh34:
	add	x1, x1, l_.str.9@PAGEOFF
	mov	x0, x20
	bl	_dev_info
LBB0_26:
	mov	x0, x21
	bl	_sja1105_ptp_reset
	mov	x21, x0
	tbz	w0, #31, LBB0_28
; %bb.27:
	str	x21, [sp]
Lloh35:
	adrp	x1, l_.str.10@PAGE
Lloh36:
	add	x1, x1, l_.str.10@PAGEOFF
	mov	x0, x20
	bl	_dev_err
LBB0_28:
Lloh37:
	adrp	x1, l_.str.11@PAGE
Lloh38:
	add	x1, x1, l_.str.11@PAGEOFF
	mov	x0, x20
	bl	_dev_info
	b	LBB0_30
LBB0_29:
Lloh39:
	adrp	x8, _EIO@GOTPAGE
Lloh40:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh41:
	ldr	w8, [x8]
	neg	w21, w8
Lloh42:
	adrp	x1, l_.str.8@PAGE
Lloh43:
	add	x1, x1, l_.str.8@PAGEOFF
	mov	x0, x20
	bl	_dev_err
LBB0_30:
	mov	x0, x19
	bl	_kfree
LBB0_31:
	mov	x0, x21
	ldp	x29, x30, [sp, #128]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #112]            ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #96]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #80]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #64]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #144
	ret
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh12, Lloh13
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh27, Lloh28
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh33, Lloh34
	.loh AdrpAdd	Lloh35, Lloh36
	.loh AdrpAdd	Lloh37, Lloh38
	.loh AdrpAdd	Lloh42, Lloh43
	.loh AdrpLdrGotLdr	Lloh39, Lloh40, Lloh41
	.cfi_endproc
                                        ; -- End function
	.comm	_SJA1105_NUM_PORTS,8,3          ; @SJA1105_NUM_PORTS
	.comm	_RETRIES,4,2                    ; @RETRIES
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Invalid config, cannot upload\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.1:                               ; @.str.1
	.asciz	"Failed to inhibit Tx on ports\n"

	.comm	_ENXIO,4,2                      ; @ENXIO
l_.str.2:                               ; @.str.2
	.asciz	"Failed to reset switch, retrying...\n"

	.comm	_SPI_WRITE,4,2                  ; @SPI_WRITE
l_.str.3:                               ; @.str.3
	.asciz	"Failed to upload config, retrying...\n"

l_.str.4:                               ; @.str.4
	.asciz	"Mismatch between hardware and static config device id. Wrote 0x%llx, wants 0x%llx\n"

l_.str.5:                               ; @.str.5
	.asciz	"Switch reported invalid local CRC on the uploaded config, retrying...\n"

l_.str.6:                               ; @.str.6
	.asciz	"Switch reported invalid global CRC on the uploaded config, retrying...\n"

l_.str.7:                               ; @.str.7
	.asciz	"Switch reported that configuration is invalid, retrying...\n"

	.comm	_EIO,4,2                        ; @EIO
l_.str.8:                               ; @.str.8
	.asciz	"Failed to upload config to device, giving up\n"

l_.str.9:                               ; @.str.9
	.asciz	"Succeeded after %d tried\n"

l_.str.10:                              ; @.str.10
	.asciz	"Failed to reset PTP clock: %d\n"

l_.str.11:                              ; @.str.11
	.asciz	"Reset switch and programmed static config\n"

.subsections_via_symbols
