Blame view

kernel/linux-imx6_3.14.28/arch/m68k/amiga/pcmcia.c 2.5 KB
6b13f685e   김민수   BSP 최초 추가
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
  /*
  ** asm-m68k/pcmcia.c -- Amiga Linux PCMCIA support
  **                      most information was found by disassembling card.resource
  **                      I'm still looking for an official doc !
  **
  ** Copyright 1997 by Alain Malek
  **
  ** This file is subject to the terms and conditions of the GNU General Public
  ** License.  See the file COPYING in the main directory of this archive
  ** for more details.
  **
  ** Created: 12/10/97 by Alain Malek
  */
  
  #include <linux/types.h>
  #include <linux/jiffies.h>
  #include <linux/timer.h>
  #include <linux/module.h>
  
  #include <asm/amigayle.h>
  #include <asm/amipcmcia.h>
  
  /* gayle config byte for program voltage and access speed */
  static unsigned char cfg_byte = GAYLE_CFG_0V|GAYLE_CFG_150NS;
  
  void pcmcia_reset(void)
  {
  	unsigned long reset_start_time = jiffies;
  	unsigned char b;
  
  	gayle_reset = 0x00;
  	while (time_before(jiffies, reset_start_time + 1*HZ/100));
  	b = gayle_reset;
  }
  EXPORT_SYMBOL(pcmcia_reset);
  
  
  /* copy a tuple, including tuple header. return nb bytes copied */
  /* be careful as this may trigger a GAYLE_IRQ_WR interrupt ! */
  
  int pcmcia_copy_tuple(unsigned char tuple_id, void *tuple, int max_len)
  {
  	unsigned char id, *dest;
  	int cnt, pos, len;
  
  	dest = tuple;
  	pos = 0;
  
  	id = gayle_attribute[pos];
  
  	while((id != CISTPL_END) && (pos < 0x10000)) {
  		len = (int)gayle_attribute[pos+2] + 2;
  		if (id == tuple_id) {
  			len = (len > max_len)?max_len:len;
  			for (cnt = 0; cnt < len; cnt++) {
  				*dest++ = gayle_attribute[pos+(cnt<<1)];
  			}
  
  			return len;
  		}
  		pos += len<<1;
  		id = gayle_attribute[pos];
  	}
  
  	return 0;
  }
  EXPORT_SYMBOL(pcmcia_copy_tuple);
  
  void pcmcia_program_voltage(int voltage)
  {
  	unsigned char v;
  
  	switch (voltage) {
  	case PCMCIA_0V:
  		v = GAYLE_CFG_0V;
  		break;
  	case PCMCIA_5V:
  		v = GAYLE_CFG_5V;
  		break;
  	case PCMCIA_12V:
  		v = GAYLE_CFG_12V;
  		break;
  	default:
  		v = GAYLE_CFG_0V;
  	}
  
  	cfg_byte = (cfg_byte & 0xfc) | v;
  	gayle.config = cfg_byte;
  
  }
  EXPORT_SYMBOL(pcmcia_program_voltage);
  
  void pcmcia_access_speed(int speed)
  {
  	unsigned char s;
  
  	if (speed <= PCMCIA_SPEED_100NS)
  		s = GAYLE_CFG_100NS;
  	else if (speed <= PCMCIA_SPEED_150NS)
  		s = GAYLE_CFG_150NS;
  	else if (speed <= PCMCIA_SPEED_250NS)
  		s = GAYLE_CFG_250NS;
  	else
  		s = GAYLE_CFG_720NS;
  
  	cfg_byte = (cfg_byte & 0xf3) | s;
  	gayle.config = cfg_byte;
  }
  EXPORT_SYMBOL(pcmcia_access_speed);
  
  void pcmcia_write_enable(void)
  {
  	gayle.cardstatus = GAYLE_CS_WR|GAYLE_CS_DA;
  }
  EXPORT_SYMBOL(pcmcia_write_enable);
  
  void pcmcia_write_disable(void)
  {
  	gayle.cardstatus = 0;
  }
  EXPORT_SYMBOL(pcmcia_write_disable);