OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [pcmcia/] [sa1100_freebird.c] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 * drivers/pcmcia/sa1100_freebird.c
3
 *
4
 * Created by Eric Peng <ericpeng@coventive.com>
5
 *
6
 */
7
#include <linux/kernel.h>
8
#include <linux/sched.h>
9
 
10
#include <asm/hardware.h>
11
#include <asm/irq.h>
12
#include "sa1100_generic.h"
13
 
14
 
15
static int freebird_pcmcia_init(struct pcmcia_init *init){
16
  int irq, res;
17
 
18
  /* Enable Linkup CF card */
19
  LINKUP_PRC = 0xc0;
20
  mdelay(100);
21
  LINKUP_PRC = 0xc1;
22
  mdelay(100);
23
  LINKUP_PRC = 0xd1;
24
  mdelay(100);
25
  LINKUP_PRC = 0xd1;
26
  mdelay(100);
27
  LINKUP_PRC = 0xc0;
28
 
29
  /* Set transition detect */
30
  //set_GPIO_IRQ_edge( GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1, GPIO_BOTH_EDGES );
31
  //set_GPIO_IRQ_edge( GPIO_CF_IRQ, GPIO_FALLING_EDGE );
32
  set_GPIO_IRQ_edge(GPIO_FREEBIRD_CF_CD|GPIO_FREEBIRD_CF_BVD,GPIO_NO_EDGES);
33
  set_GPIO_IRQ_edge(GPIO_FREEBIRD_CF_IRQ, GPIO_FALLING_EDGE);
34
 
35
  /* Register interrupts */
36
  irq = IRQ_GPIO_FREEBIRD_CF_CD;
37
  res = request_irq( irq, init->handler, SA_INTERRUPT, "CF_CD", NULL );
38
  if( res < 0 ) goto irq_err;
39
  irq = IRQ_GPIO_FREEBIRD_CF_BVD;
40
  res = request_irq( irq, init->handler, SA_INTERRUPT, "CF_BVD1", NULL );
41
  if( res < 0 ) goto irq_err;
42
 
43
  /* There's only one slot, but it's "Slot 1": */
44
  return 2;
45
 
46
irq_err:
47
  printk( KERN_ERR "%s: Request for IRQ %lu failed\n", __FUNCTION__, irq );
48
  return -1;
49
}
50
 
51
static int freebird_pcmcia_shutdown(void)
52
{
53
  /* disable IRQs */
54
  free_irq( IRQ_GPIO_FREEBIRD_CF_CD, NULL );
55
  free_irq( IRQ_GPIO_FREEBIRD_CF_BVD, NULL );
56
 
57
  /* Disable CF card */
58
  LINKUP_PRC = 0x40;  /* SSP=1   SOE=0 */
59
  mdelay(100);
60
 
61
  return 0;
62
}
63
 
64
static int freebird_pcmcia_socket_state(struct pcmcia_state_array
65
                                       *state_array){
66
  unsigned long levels;
67
 
68
  if(state_array->size<2) return -1;
69
 
70
  memset(state_array->state, 0,
71
         (state_array->size)*sizeof(struct pcmcia_state));
72
 
73
  levels = LINKUP_PRS;
74
//printk("LINKUP_PRS=%x \n",levels);
75
 
76
  state_array->state[0].detect=
77
    ((levels & (LINKUP_CD1 | LINKUP_CD2))==0)?1:0;
78
 
79
  state_array->state[0].ready=(levels & LINKUP_RDY)?1:0;
80
 
81
  state_array->state[0].bvd1=(levels & LINKUP_BVD1)?1:0;
82
 
83
  state_array->state[0].bvd2=(levels & LINKUP_BVD2)?1:0;
84
 
85
  state_array->state[0].wrprot=0; /* Not available on Assabet. */
86
 
87
  state_array->state[0].vs_3v=1;  /* Can only apply 3.3V on Assabet. */
88
 
89
  state_array->state[0].vs_Xv=0;
90
 
91
  return 1;
92
}
93
 
94
static int freebird_pcmcia_get_irq_info(struct pcmcia_irq_info *info){
95
 
96
  if(info->sock>1) return -1;
97
 
98
  if(info->sock==0)
99
    info->irq=IRQ_GPIO_FREEBIRD_CF_IRQ;
100
 
101
  return 0;
102
}
103
 
104
static int freebird_pcmcia_configure_socket(const struct pcmcia_configure
105
                                           *configure)
106
{
107
  unsigned long value, flags;
108
 
109
  if(configure->sock>1) return -1;
110
 
111
  if(configure->sock==1) return 0;
112
 
113
  save_flags_cli(flags);
114
 
115
  value = 0xc0;   /* SSP=1  SOE=1  CFE=1 */
116
 
117
  switch(configure->vcc){
118
  case 0:
119
 
120
    break;
121
 
122
  case 50:
123
    printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n",
124
           __FUNCTION__);
125
 
126
  case 33:  /* Can only apply 3.3V to the CF slot. */
127
    value |= LINKUP_S1;
128
    break;
129
 
130
  default:
131
    printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __FUNCTION__,
132
           configure->vcc);
133
    restore_flags(flags);
134
    return -1;
135
  }
136
 
137
  if (configure->reset)
138
  value = (configure->reset) ? (value | LINKUP_RESET) : (value & ~LINKUP_RESET);
139
 
140
  /* Silently ignore Vpp, output enable, speaker enable. */
141
 
142
  LINKUP_PRC = value;
143
//printk("LINKUP_PRC=%x\n",value);
144
  restore_flags(flags);
145
 
146
  return 0;
147
}
148
 
149
static int freebird_pcmcia_socket_init(int sock)
150
{
151
  set_GPIO_IRQ_edge(GPIO_FREEBIRD_CF_CD|GPIO_FREEBIRD_CF_BVD, GPIO_BOTH_EDGES);
152
  return 0;
153
}
154
 
155
static int freebird_pcmcia_socket_suspend(int sock)
156
{
157
  set_GPIO_IRQ_edge(GPIO_FREEBIRD_CF_CD|GPIO_FREEBIRD_CF_BVD, GPIO_NO_EDGES);
158
  return 0;
159
}
160
 
161
struct pcmcia_low_level freebird_pcmcia_ops = {
162
  init:                 freebird_pcmcia_init,
163
  shutdown:             freebird_pcmcia_shutdown,
164
  socket_state:         freebird_pcmcia_socket_state,
165
  get_irq_info:         freebird_pcmcia_get_irq_info,
166
  configure_socket:     freebird_pcmcia_configure_socket,
167
 
168
  socket_init:          freebird_pcmcia_socket_init,
169
  socket_suspend:       freebird_pcmcia_socket_suspend,
170
};
171
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.