Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 	on20.c	(c) 1996-8  Grant R. Guenther <grant@torque.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 		            Under the terms of the GNU General Public License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)         on20.c is a low-level protocol driver for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)         Onspec 90c20 parallel to IDE adapter. 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) /* Changes:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)         1.01    GRG 1998.05.06 init_proto, release_proto
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define	ON20_VERSION	"1.01"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include "paride.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define op(f)	w2(4);w0(f);w2(5);w2(0xd);w2(5);w2(0xd);w2(5);w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define vl(v)	w2(4);w0(v);w2(5);w2(7);w2(5);w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define j44(a,b)  (((a>>4)&0x0f)|(b&0xf0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /* cont = 0 - access the IDE register file 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)    cont = 1 - access the IDE command set 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) static int on20_read_regr( PIA *pi, int cont, int regr )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) {	int h,l, r ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)         r = (regr<<2) + 1 + cont;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42)         op(1); vl(r); op(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	switch (pi->mode)  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46)         case 0:  w2(4); w2(6); l = r1();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47)                  w2(4); w2(6); h = r1();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48)                  w2(4); w2(6); w2(4); w2(6); w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		 return j44(l,h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	case 1:  w2(4); w2(0x26); r = r0(); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52)                  w2(4); w2(0x26); w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		 return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) }	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static void on20_write_regr( PIA *pi, int cont, int regr, int val )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) {	int r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	r = (regr<<2) + 1 + cont;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	op(1); vl(r); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	op(0); vl(val); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	op(0); vl(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) static void on20_connect ( PIA *pi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) {	pi->saved_r0 = r0();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73)         pi->saved_r2 = r2();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	w2(4);w0(0);w2(0xc);w2(4);w2(6);w2(4);w2(6);w2(4); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (pi->mode) { op(2); vl(8); op(2); vl(9); }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	       else   { op(2); vl(0); op(2); vl(8); }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) static void on20_disconnect ( PIA *pi )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {	w2(4);w0(7);w2(4);w2(0xc);w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)         w0(pi->saved_r0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)         w2(pi->saved_r2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) } 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static void on20_read_block( PIA *pi, char * buf, int count )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) {	int     k, l, h; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	op(1); vl(1); op(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	for (k=0;k<count;k++) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	    if (pi->mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		w2(4); w2(0x26); buf[k] = r0();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	    } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		w2(6); l = r1(); w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		w2(6); h = r1(); w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		buf[k] = j44(l,h);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	    }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static void on20_write_block(  PIA *pi, char * buf, int count )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) {	int	k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	op(1); vl(1); op(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	for (k=0;k<count;k++) { w2(5); w0(buf[k]); w2(7); }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	w2(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) static void on20_log_adapter( PIA *pi, char * scratch, int verbose )
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {       char    *mode_string[2] = {"4-bit","8-bit"};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)         printk("%s: on20 %s, OnSpec 90c20 at 0x%x, ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)                 pi->device,ON20_VERSION,pi->port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)         printk("mode %d (%s), delay %d\n",pi->mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		mode_string[pi->mode],pi->delay);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) static struct pi_protocol on20 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	.name		= "on20",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	.max_mode	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	.epp_first	= 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	.default_delay	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	.max_units	= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	.write_regr	= on20_write_regr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	.read_regr	= on20_read_regr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	.write_block	= on20_write_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	.read_block	= on20_read_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	.connect	= on20_connect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	.disconnect	= on20_disconnect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	.log_adapter	= on20_log_adapter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static int __init on20_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	return paride_register(&on20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static void __exit on20_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	paride_unregister(&on20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) module_init(on20_init)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) module_exit(on20_exit)