A very crude solution that works as proof of concept:
M561 ; clear any bed transform
; If the printer hasn't been homed, home it
if !move.axes[0].homed || !move.axes[1].homed || !move.axes[2].homed
G28
M574 Z1 S1 P"^!zprobe.in" ; configure active-low endstop for low end on Z via pin probe.in
G90 ; absolute positioning
G1 Z12 F1200
G91 ; use relative positioning
while iterations < 100
G1 H1 X1 Z-0.2 F120
if sensors.endstops[2].triggered
G92 Z10 ; height of touch plate
break
G1 Z25 F1200
G90 ; absolute positioning
; restore endstops
M574 Z2 S1 P"zstop" ; configure active-high endstop for high end on Z via pin zstop