px4,7508: expand the 7508 code a bit further
authorAlan Cox <alan@linux.intel.com>
Sat, 28 Mar 2015 23:24:12 +0000 (23:24 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 28 Mar 2015 23:24:12 +0000 (23:24 +0000)
Still much to do including things like the keyboard decoding. Also not
clear what we should do with a lot of the events.

Kernel/platform-px4plus/7508.h [new file with mode: 0644]
Kernel/platform-px4plus/cpu7508.s

diff --git a/Kernel/platform-px4plus/7508.h b/Kernel/platform-px4plus/7508.h
new file mode 100644 (file)
index 0000000..eb21ca6
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef _7508_H
+#define _7508_H
+
+extern void c7508_power_off(void);
+extern void c7508_interrupt(void);
+extern void c7508_msg(uint8_t *buf);
+
+extern uint8_t rtc_clock;              /* Rolling 1 second timer */
+
+#endif
\ No newline at end of file
index 92abf6f..267ab6a 100644 (file)
@@ -5,6 +5,13 @@
 
                .area _CODE
 
+
+               .globl _c7508_msg
+               .globl c7508_power_off
+               .globl c7508_interrupt
+
+               .globl _rtc_clock
+
 c7508_cmdbyte:
                ; Wait for the 7508 to go ready
                in a, (0x05)
@@ -18,13 +25,21 @@ c7508_cmdbyte:
                out (0x01), a
                ret
 
-c7508_waitrsp:
+;
+;      Wait for a byte of response from the 7508 and return it in D.
+;
+c7508_replybyte:
                in a, (0x05)
                and 4
                jr z, c7508_waitrsp
+               in a, (0x06)
+               ld d, a
+               ld a, #2
+               out (0x01), a
                ret
 
-c7508_int:     ; The 7508 wants us to ask it for status
+c7508_interrupt:
+               ; The 7508 wants us to ask it for status
                ld c, #0x02
                call c7508_cmdbyte
                call c7508_waitrsp
@@ -61,9 +76,77 @@ c7508_1sec:
                pop af
                ret
 
+;
+;      Keyboard event - punt out to C
+;
 c7508_keyin:
-               ; FIXME
+               ld l, a
+               ld h, #0
+               push af
+               call _key_pressed
+               pop af
                ret
 
+;
+;      Turn off the 7508 as an interrupt source
+;
+c7508_irqoff:
+               ld a, #0x0a
+               out (4), a
+               ret
+
+;
+;      Turn on the 7508 as an interrupt source
+;
+c7508_irqon:
+               ld a, #0x0b
+               out (4), a
+               ret
+;
+;      Send a command. HL points to the start of the command B holds the
+;      number of bytes to send, the reply will be placed in the memory
+;      following the command and E bytes are expected
+;
+c7508_docmd:
+               call c7508_irqoff
+               ld c, (hl)
+               inc hl
+               call c7508_cmdbyte
+               djnz c7508_docmd
+               ld b, e
+               xor a
+               cp b
+               jp z, c7508_irqon
+c7508_doreply:
+               call c7508_replybyte
+               ld (hl), d
+               djnz c7508_doreply
+               call c7508_irqon
+               ret
+
+_c7508_power_off:
+               ld c, #1
+               call c7508_cmdbyte              ; won't return !
+               di
+               hlt
+
+;
+;      General purpose C interface to 7508 commands. Pass a buffer that
+;      holds the length to send, length to receive, send data, space for
+;      receive data.
+;
+_c7508_msg:
+               pop bc
+               pop de
+               pop hl                  ; Parameter
+               push hl
+               push de
+               push bc
+               ld b, (hl)
+               inc hl
+               ld e,(hl)
+               inc hl
+               jr c7508_docmd
+
                .area _DATA
 _rtc_clock:    .db 0