ds1302: unify all the code and banked versions too
authorAlan Cox <alan@linux.intel.com>
Fri, 15 Mar 2019 22:01:47 +0000 (22:01 +0000)
committerAlan Cox <alan@linux.intel.com>
Fri, 15 Mar 2019 22:01:47 +0000 (22:01 +0000)
Kernel/dev/ds1302_common.s [new file with mode: 0644]
Kernel/dev/ds1302_rbc-banked.s [new file with mode: 0644]
Kernel/dev/ds1302_rbc.s
Kernel/dev/ds1302_rc2014.s

diff --git a/Kernel/dev/ds1302_common.s b/Kernel/dev/ds1302_common.s
new file mode 100644 (file)
index 0000000..199030e
--- /dev/null
@@ -0,0 +1,76 @@
+; 2015-02-19 Sergey Kiselev
+; 2014-12-31 William R Sowerbutts
+; N8VEM SBC / Zeta SBC / RC2014 DS1302 real time clock interface code
+;
+;
+
+        .module ds1302-n8vem
+
+        ; exported symbols
+        .globl _ds1302_set_pin_ce
+        .globl _ds1302_set_pin_clk
+        .globl _ds1302_set_pin_data
+        .globl _ds1302_set_pin_data_driven
+        .globl _ds1302_get_pin_data
+
+        .include "kernel.def"
+        .include "../kernel-z80.def"
+
+; -----------------------------------------------------------------------------
+; DS1302 interface
+; -----------------------------------------------------------------------------
+
+N8VEM_RTC       = 0x70
+PIN_CE          = 0x10
+PIN_DATA_HIZ    = 0x20
+PIN_CLK         = 0x40
+PIN_DATA_OUT    = 0x80
+PIN_DATA_IN     = 0x01
+
+_ds1302_get_pin_data:
+        in a, (RTC)            ; read input register
+        and #PIN_DATA_IN        ; mask off data pin
+        ld l, a                 ; return result in L
+        ret
+
+_ds1302_set_pin_data_driven:
+        ld hl, #STACKOFF        ; get address of function argument
+        add hl, sp
+        ld b, (hl)              ; load argument from stack
+        ld a, (rtc_shadow)
+        and #~PIN_DATA_HIZ      ; 0 - output pin
+        bit 0, b                ; test bit
+        jr nz, writereg
+        or #PIN_DATA_HIZ
+        jr writereg
+
+_ds1302_set_pin_data:
+        ld bc, #(((~PIN_DATA_OUT) << 8) | PIN_DATA_OUT)
+        jr setpin
+
+_ds1302_set_pin_ce:
+        ld bc, #(((~PIN_CE) << 8) | PIN_CE)
+        jr setpin
+
+_ds1302_set_pin_clk:
+        ld bc, #(((~PIN_CLK) << 8) | PIN_CLK)
+        jr setpin
+
+setpin:
+        ld a, (rtc_shadow)      ; load current register contents
+        and b                   ; unset the pin
+        ld hl, #STACKOFF        ; get address of function argument
+        add hl, sp
+        ld b, (hl)              ; load argument from stack
+        bit 0, b                ; test bit
+        jr z, writereg          ; arg is false
+        or c                    ; arg is true
+writereg:
+        out (RTC), a           ; write out new register contents
+        ld (rtc_shadow), a      ; update our shadow copy
+        ret
+
+.area _DATA
+
+rtc_shadow:     .db 0           ; we can't read back the latch contents, so we must keep a copy
+
diff --git a/Kernel/dev/ds1302_rbc-banked.s b/Kernel/dev/ds1302_rbc-banked.s
new file mode 100644 (file)
index 0000000..2a6b6f1
--- /dev/null
@@ -0,0 +1,13 @@
+       STACKOFF        .equ    4
+
+       .area _CODE1
+
+RTC             = 0x70
+PIN_CE          = 0x10
+PIN_DATA_HIZ    = 0x20
+PIN_CLK         = 0x40
+PIN_DATA_OUT    = 0x80
+PIN_DATA_IN     = 0x01
+
+
+       .include "ds1302_common.s"
index df0e41b..0b9d706 100644 (file)
@@ -1,79 +1,13 @@
-; 2015-02-19 Sergey Kiselev
-; 2014-12-31 William R Sowerbutts
-; N8VEM SBC / Zeta SBC DS1302 real time clock interface code
-;
-;      FIXME: belongs in dev/
-;
+       STACKOFF        .equ    2
 
-        .module ds1302-n8vem
+       .area _CODE
 
-        ; exported symbols
-        .globl _ds1302_set_pin_ce
-        .globl _ds1302_set_pin_clk
-        .globl _ds1302_set_pin_data
-        .globl _ds1302_set_pin_data_driven
-        .globl _ds1302_get_pin_data
-
-        .include "kernel.def"
-        .include "../kernel-z80.def"
-
-; -----------------------------------------------------------------------------
-; DS1302 interface
-; -----------------------------------------------------------------------------
-
-N8VEM_RTC       = 0x70
+RTC             = 0x70
 PIN_CE          = 0x10
 PIN_DATA_HIZ    = 0x20
 PIN_CLK         = 0x40
 PIN_DATA_OUT    = 0x80
 PIN_DATA_IN     = 0x01
 
-.area _DATA
-
-rtc_shadow:     .db 0           ; we can't read back the latch contents, so we must keep a copy
-
-.area _CODE
-
-_ds1302_get_pin_data:
-        in a, (N8VEM_RTC)       ; read input register
-        and #PIN_DATA_IN        ; mask off data pin
-        ld l, a                 ; return result in L
-        ret
-
-_ds1302_set_pin_data_driven:
-        ld hl, #2               ; get address of function argument
-        add hl, sp
-        ld b, (hl)              ; load argument from stack
-        ld a, (rtc_shadow)
-        and #~PIN_DATA_HIZ      ; 0 - output pin
-        bit 0, b                ; test bit
-        jr nz, writereg
-        or #PIN_DATA_HIZ
-        jr writereg
-
-_ds1302_set_pin_data:
-        ld bc, #(((~PIN_DATA_OUT) << 8) | PIN_DATA_OUT)
-        jr setpin
-
-_ds1302_set_pin_ce:
-        ld bc, #(((~PIN_CE) << 8) | PIN_CE)
-        jr setpin
-
-_ds1302_set_pin_clk:
-        ld bc, #(((~PIN_CLK) << 8) | PIN_CLK)
-        jr setpin
-
-setpin:
-        ld a, (rtc_shadow)      ; load current register contents
-        and b                   ; unset the pin
-        ld hl, #2               ; get address of function argument
-        add hl, sp
-        ld b, (hl)              ; load argument from stack
-        bit 0, b                ; test bit
-        jr z, writereg          ; arg is false
-        or c                    ; arg is true
-writereg:
-        out (N8VEM_RTC), a      ; write out new register contents
-        ld (rtc_shadow), a      ; update our shadow copy
-        ret
 
+       .include "ds1302_common.s"
index bd82908..208b918 100644 (file)
@@ -1,80 +1,13 @@
-; 2015-02-19 Sergey Kiselev
-; 2014-12-31 William R Sowerbutts
-; RC2014 real time clock interface code
-;
+       STACKOFF        .equ    2
 
-        .module ds1302-rc2014
+       .area _CODE
 
-        ; exported symbols
-        .globl _ds1302_set_pin_ce
-        .globl _ds1302_set_pin_clk
-        .globl _ds1302_set_pin_data
-        .globl _ds1302_set_pin_data_driven
-        .globl _ds1302_get_pin_data
-
-        .include "kernel.def"
-        .include "../kernel-z80.def"
-
-; -----------------------------------------------------------------------------
-; DS1302 interface
-; -----------------------------------------------------------------------------
-
-;
-;      Same layout as N8VEM but different default port (sigh).
-;
-RC2014_RTC      = 0xC0
+RTC            = 0xC0
 PIN_CE          = 0x10
 PIN_DATA_HIZ    = 0x20
 PIN_CLK         = 0x40
 PIN_DATA_OUT    = 0x80
 PIN_DATA_IN     = 0x01
 
-.area _DATA
-
-rtc_shadow:     .db 0           ; we can't read back the latch contents, so we must keep a copy
-
-.area _CODE
-
-_ds1302_get_pin_data:
-        in a, (RC2014_RTC)       ; read input register
-        and #PIN_DATA_IN        ; mask off data pin
-        ld l, a                 ; return result in L
-        ret
-
-_ds1302_set_pin_data_driven:
-        ld hl, #2               ; get address of function argument
-        add hl, sp
-        ld b, (hl)              ; load argument from stack
-        ld a, (rtc_shadow)
-        and #~PIN_DATA_HIZ      ; 0 - output pin
-        bit 0, b                ; test bit
-        jr nz, writereg
-        or #PIN_DATA_HIZ
-        jr writereg
-
-_ds1302_set_pin_data:
-        ld bc, #(((~PIN_DATA_OUT) << 8) | PIN_DATA_OUT)
-        jr setpin
-
-_ds1302_set_pin_ce:
-        ld bc, #(((~PIN_CE) << 8) | PIN_CE)
-        jr setpin
-
-_ds1302_set_pin_clk:
-        ld bc, #(((~PIN_CLK) << 8) | PIN_CLK)
-        jr setpin
-
-setpin:
-        ld a, (rtc_shadow)      ; load current register contents
-        and b                   ; unset the pin
-        ld hl, #2               ; get address of function argument
-        add hl, sp
-        ld b, (hl)              ; load argument from stack
-        bit 0, b                ; test bit
-        jr z, writereg          ; arg is false
-        or c                    ; arg is true
-writereg:
-        out (RC2014_RTC), a      ; write out new register contents
-        ld (rtc_shadow), a      ; update our shadow copy
-        ret
 
+       .include "ds1302_common.s"