summaryrefslogtreecommitdiff
path: root/board/MAI/AmigaOneG3SE/board_asm_init.S
blob: a421c5dc435483a39ea37a782df03ee7de549ecc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
	#include	"macros.h"
	
	

#define GLOBALINFO0	      0x50	
#define GLOBALINFO0_BO        (1<<7)
#define GLOBALINFO2_B1ARBITER (1<<6)
#define HBUSACR0              0x5c
#define HBUSACR2_BURST        (1<<0)
#define HBUSACR2_LAT          (1<<1)
	
#define RECEIVER_HOLDING 0
#define TRANSMITTER_HOLDING 0
#define INTERRUPT_ENABLE 1
#define INTERRUPT_STATUS 2
#define FIFO_CONTROL 2
#define LINE_CONTROL 3
#define MODEM_CONTROL 4
#define LINE_STATUS 5
#define MODEM_STATUS 6
#define SCRATCH_PAD 7

#define DIVISOR_LATCH_LSB 0
#define DIVISOR_LATCH_MSB 1
#define PRESCALER_DIVISION 5

#define UART(x) (0x3f8+(x))

#define GLOBALINFO0           0x50
#define GLOBALINFO0_BO        (1<<7)
#define GLOBALINFO2_B1ARBITER (1<<6)
#define HBUSACR0              0x5c
#define HBUSACR2_BURST        (1<<0)
#define HBUSACR2_LAT          (1<<1)

#define SUPERIO_1               ((7 << 3) | (0))
#define SUPERIO_2               ((7 << 3) | (1))
	
	.globl	board_asm_init
	
board_asm_init:
	mflr	r29
	/* Set 'Must-set' register */
	li	r3, 0
	li	r4, 0
	li	r5, 0x5e
	bl	pci_read_cfg_byte
	ori	r3, r3, (1<<1)
	xori	r6, r3, (1<<1)
	li	r3, 0
	bl	pci_write_cfg_byte

	li	r3, 0
	li	r5, 0x52
	bl	pci_read_cfg_byte
	ori	r6, r3, (1<<6)
	li	r3, 0
	bl	pci_write_cfg_byte

	li	r3, 0
	li	r4, 0x08
	li	r5, 0xd2
	bl	pci_read_cfg_byte
	ori	r6, r3, (1<<2)
	li	r3, 0
	bl	pci_write_cfg_byte


	/* Do PCI reset */
/*	li	r3, 0
	li	r4, 0x38
	li	r5, 0x47
	bl	pci_read_cfg_byte
	ori	r6, r3, 0x01
	li	r3, 0
	li	r4, 0x38
	li	r5, 0x47
	bl	pci_write_cfg_byte*/

	
	/* Enable NVRAM for environment */
	li	r3, 0
	li	r4, 0
	li	r5, 0x56
	li	r6, 0x0B
	bl	pci_write_cfg_byte


	/* Init Super-I/O chips */

	siowb	0x40, 0x08
	siowb	0x41, 0x01
	siowb	0x45, 0x80
	siowb	0x46, 0x60	
	siowb	0x47, 0x20
	siowb	0x48, 0x01
	siowb	0x4a, 0xc4
	siowb	0x50, 0x0e
	siowb	0x51, 0x76
	siowb	0x52, 0x34
	siowb	0x54, 0x00
	siowb	0x55, 0x90
	siowb	0x56, 0x99
	siowb	0x57, 0x90
	siowb	0x85, 0x01
		
	/* Enable configuration mode for SuperIO */
	li	r3, 0
	li	r4, (7<<3)
	li	r5, 0x85
	bl	pci_read_cfg_byte
	ori	r6, r3, 0x02
	mr	r31, r6
	li	r3,0
	bl	pci_write_cfg_byte

	/* COM1 as 3f8 */
	outb	0x3f0, 0xe7
	outb	0x3f1, 0xfe

	/* COM2 as 2f8 */
	outb	0x3f0, 0xe8
	outb	0x3f1, 0xeb

	/* Enable */
	outb	0x3f0, 0xe2
	inb	r3, 0x3f1
	ori	r3, r3, 0x0c
	outb	0x3f0, 0xe2
	outbr	0x3f1, r3
	
	/* Disable configuration mode */
	li	r3, 0
	li	r4, (7<<3)
	li	r5, 0x85
	mr	r6, r31
	bl	pci_write_cfg_byte

	/* Set line control */
	outb	UART(LINE_CONTROL), 0x83
	outb	UART(DIVISOR_LATCH_LSB), 0x0c
	outb	UART(DIVISOR_LATCH_MSB), 0x00
	outb	UART(LINE_CONTROL), 0x3

	mtlr	r29
	blr

		
	.globl	new_reset
	.globl	new_reset_end
new_reset:
	li	r0, 0x100
	oris	r0, r0, 0xFFF0
	mtlr	r0
	blr
	
new_reset_end: