Rev 5558 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5558 | Rev 6878 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2015-2017. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line -... | ||
7 | - | ||
8 | ;driver sceletone |
- | |
9 | 7 | ||
10 | format PE DLL native 0.05 |
8 | format PE DLL native 0.05 |
Line 11... | Line 9... | ||
11 | entry START |
9 | entry START |
12 | 10 | ||
Line 21... | Line 19... | ||
21 | 19 | ||
Line 22... | Line 20... | ||
22 | SRV_GETVERSION = 0 |
20 | SRV_GETVERSION = 0 |
Line 23... | Line 21... | ||
23 | 21 | ||
24 | section '.flat' code readable writable executable |
22 | section '.flat' code readable writable executable |
25 | 23 | ||
26 | include 'proc32.inc' |
24 | include '../proc32.inc' |
27 | include 'struct.inc' |
25 | include '../struct.inc' |
- | 26 | include '../macros.inc' |
|
- | 27 | include '../peimport.inc' |
|
- | 28 | include '../fdo.inc' |
|
- | 29 | ||
Line 28... | Line 30... | ||
28 | include 'macros.inc' |
30 | GPIO_PORT_CONFIG_ADDR = 0xF100 |
Line 29... | Line 31... | ||
29 | include 'peimport.inc' |
31 | GPIO_DATA_ADDR = 0xF200 |
30 | include 'fdo.inc' |
32 | ADC_ADDR = 0xFE00 |
Line 41... | Line 43... | ||
41 | pop esi |
43 | pop esi |
42 | test eax, eax |
44 | test eax, eax |
43 | jz .fail |
45 | jz .fail |
Line 44... | Line 46... | ||
44 | 46 | ||
45 | ; Set crossbar base address register in southbridge |
47 | ; Set crossbar base address register in southbridge |
Line 46... | Line 48... | ||
46 | invoke PciWrite16, [bus], [dev], 64h, 0x0A00 or 1 |
48 | invoke PciWrite16, [bus], [dev], 0x64, 0x0A00 or 1 |
- | 49 | ||
- | 50 | ; Set GPIO base address register in southbridge |
|
- | 51 | invoke PciWrite16, [bus], [dev], 0x62, GPIO_PORT_CONFIG_ADDR or 1 |
|
- | 52 | ||
- | 53 | DEBUGF 1,"Setting up ADC\n" |
|
- | 54 | ||
- | 55 | ; Enable ADC |
|
47 | 56 | invoke PciRead32, [bus], [dev], 0xBC |
|
- | 57 | and eax, not (1 shl 28) |
|
- | 58 | invoke PciWrite32, [bus], [dev], 0xBC, eax |
|
- | 59 | ||
- | 60 | DEBUGF 1,"1\n" |
|
- | 61 | ||
- | 62 | ; Set ADC base address |
|
- | 63 | mov ebx, [dev] |
|
- | 64 | inc ebx |
|
- | 65 | invoke PciRead16, [bus], ebx, 0xDE |
|
- | 66 | or ax, 0x02 |
|
- | 67 | invoke PciWrite16, [bus], ebx, 0xDE, eax |
|
- | 68 | ||
- | 69 | invoke PciWrite32, [bus], ebx, 0xE0, 0x00500000 or ADC_ADDR |
|
- | 70 | ||
- | 71 | DEBUGF 1,"2\n" |
|
- | 72 | ||
- | 73 | ; set up ADC |
|
- | 74 | mov dx, ADC_ADDR + 1 |
|
- | 75 | xor al, al |
|
- | 76 | out dx, al |
|
- | 77 | ||
- | 78 | DEBUGF 1,"3\n" |
|
- | 79 | ||
- | 80 | ; Empty FIFO |
|
- | 81 | @@: |
|
- | 82 | mov dx, ADC_ADDR + 2 ; Status register |
|
- | 83 | in al, dx |
|
- | 84 | test al, 0x01 ; FIFO ready |
|
- | 85 | jz @f |
|
- | 86 | mov dx, ADC_ADDR + 4 |
|
- | 87 | in ax, dx |
|
- | 88 | jmp @r |
|
- | 89 | @@: |
|
Line 48... | Line 90... | ||
48 | ; Set GPIO base address register in southbridge |
90 | |
49 | invoke PciWrite16, [bus], [dev], 62h, 0xF100 or 1 |
91 | DEBUGF 1,"4\n" |
50 | 92 | ||
51 | ; Enable GPIO0-9 |
93 | ; Enable GPIO0-9 |
Line 52... | Line 94... | ||
52 | mov dx, 0xf100 |
94 | mov dx, GPIO_PORT_CONFIG_ADDR + 0 ; General-Purpose I/O Data & Direction Decode Enable |
53 | mov eax, 0x000001ff |
95 | mov eax, 0x000001ff |
54 | out dx, eax |
96 | out dx, eax |
55 | 97 | ||
56 | mov ecx, 10 |
98 | mov ecx, 10 ; 10 GPIO ports total |
57 | mov dx, 0xf104 |
99 | mov dx, GPIO_PORT_CONFIG_ADDR + 4 ; General-Purpose I/O Port0 Data & Direction Decode Address |
58 | mov ax, 0xf200 |
100 | mov ax, GPIO_DATA_ADDR |
59 | .gpio_init: |
101 | .gpio_init: |
Line 69... | Line 111... | ||
69 | dec ecx |
111 | dec ecx |
70 | jnz .gpio_init |
112 | jnz .gpio_init |
Line 71... | Line 113... | ||
71 | 113 | ||
72 | ; Set GPIO0 pin 0 as output |
114 | ; Set GPIO0 pin 0 as output |
73 | mov al, 0x01 |
115 | mov al, 0x01 |
74 | mov dx, 0xf202 |
- | |
75 | out dx, al |
- | |
76 | - | ||
77 | ; Set GPIO4 pin 0 as output |
- | |
78 | mov al, 0x01 |
- | |
79 | mov dx, 0xf212 |
116 | mov dx, GPIO_DATA_ADDR + 0*4 + 2 |
Line 80... | Line 117... | ||
80 | out dx, al |
117 | out dx, al |
81 | 118 | ||
82 | invoke RegService, my_service, service_proc |
119 | invoke RegService, my_service, service_proc |
Line 100... | Line 137... | ||
100 | mov dword [eax], API_VERSION |
137 | mov dword [eax], API_VERSION |
101 | xor eax, eax |
138 | xor eax, eax |
102 | ret |
139 | ret |
103 | @@: |
140 | @@: |
104 | cmp eax, 1 ; read GPIO P0 |
141 | cmp eax, 1 ; read GPIO P0 |
105 | jne @f |
142 | jne .no_gpioread |
106 | mov dx, 0xf200 |
143 | mov dx, GPIO_DATA_ADDR + 0x00 |
107 | in al, dx |
144 | in al, dx |
108 | ret |
145 | ret |
109 | @@: |
146 | .no_gpioread: |
110 | cmp eax, 2 ; write GPIO P0 |
147 | cmp eax, 2 ; write GPIO P0 |
111 | jne @f |
148 | jne .no_gpiowrite |
Line 112... | Line 149... | ||
112 | 149 | ||
113 | mov eax, [ebx + IOCTL.input] |
150 | mov eax, [ebx + IOCTL.input] |
114 | mov dx, 0xf200 |
151 | mov dx, GPIO_DATA_ADDR + 0x00 |
115 | out dx, al |
152 | out dx, al |
116 | xor eax, eax |
153 | xor eax, eax |
- | 154 | ret |
|
- | 155 | .no_gpiowrite: |
|
- | 156 | cmp eax, 3 ; read ADC channel 0 |
|
- | 157 | jne .no_adcread |
|
- | 158 | ||
- | 159 | mov dx, ADC_ADDR + 1 |
|
- | 160 | mov al, 1 shl 3 ; Power down ADC |
|
- | 161 | out dx, al |
|
- | 162 | ||
- | 163 | mov dx, ADC_ADDR + 0 ; AUX channel select register |
|
- | 164 | mov al, 1 shl 0 ; Enable AUX0 scan |
|
- | 165 | out dx, al |
|
- | 166 | ||
- | 167 | mov dx, ADC_ADDR + 1 |
|
- | 168 | mov al, 1 shl 0 ; Single shot, no interrupts, start |
|
- | 169 | out dx, al |
|
- | 170 | ||
117 | ret |
171 | mov dx, ADC_ADDR + 2 |
- | 172 | @@: |
|
- | 173 | in al, dx |
|
- | 174 | test al, 1 shl 0 ; data ready? |
|
- | 175 | jz @r |
|
- | 176 | ||
- | 177 | mov dx, ADC_ADDR + 4 |
|
- | 178 | in ax, dx ; read the data and return to user call |
|
- | 179 | DEBUGF 1, "ADC read: 0x%x\n", eax:4 |
|
- | 180 | ret |
|
118 | @@: |
181 | .no_adcread: |
119 | .fail: |
182 | .fail: |
120 | or eax, -1 |
183 | or eax, -1 |
121 | ret |
184 | ret |