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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [drivers/] [pcmcia/] [sa1100_yopy.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_yopy.c
3
 *
4
 * PCMCIA implementation routines for Yopy
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 inline void pcmcia_power(int on) {
16
        /* high for power up */
17
        yopy_gpio_set(GPIO_CF_POWER, on);
18
}
19
 
20
static inline void pcmcia_reset(int reset)
21
{
22
        /* high for reset */
23
        yopy_gpio_set(GPIO_CF_RESET, reset);
24
}
25
 
26
static int yopy_pcmcia_init(struct pcmcia_init *init)
27
{
28
        int irq, res;
29
 
30
        pcmcia_power(0);
31
        pcmcia_reset(1);
32
 
33
        /* Set transition detect */
34
        set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
35
                          GPIO_NO_EDGES);
36
        set_GPIO_IRQ_edge( GPIO_CF_IREQ, GPIO_FALLING_EDGE );
37
 
38
        /* Register interrupts */
39
        irq = IRQ_CF_CD;
40
        res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_CD", NULL);
41
        if (res < 0) goto irq_err;
42
        irq = IRQ_CF_BVD2;
43
        res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_BVD2", NULL);
44
        if (res < 0) goto irq_err;
45
        irq = IRQ_CF_BVD1;
46
        res = request_irq(irq, init->handler, SA_INTERRUPT, "CF_BVD1", NULL);
47
        if (res < 0) goto irq_err;
48
 
49
        return 1;
50
irq_err:
51
        printk(KERN_ERR "%s: Request for IRQ %d failed\n", __FUNCTION__, irq);
52
        return -1;
53
}
54
 
55
static int yopy_pcmcia_shutdown(void)
56
{
57
        /* disable IRQs */
58
        free_irq( IRQ_CF_CD, NULL );
59
        free_irq( IRQ_CF_BVD2, NULL );
60
        free_irq( IRQ_CF_BVD1, NULL );
61
 
62
        /* Disable CF */
63
        pcmcia_reset(1);
64
        pcmcia_power(0);
65
 
66
        return 0;
67
}
68
 
69
static int yopy_pcmcia_socket_state(struct pcmcia_state_array *state_array)
70
{
71
        unsigned long levels;
72
 
73
        if (state_array->size != 1)
74
                return -1;
75
 
76
        memset(state_array->state, 0,
77
               state_array->size * sizeof(struct pcmcia_state));
78
 
79
        levels = GPLR;
80
 
81
        state_array->state[0].detect = (levels & GPIO_CF_CD)    ? 0 : 1;
82
        state_array->state[0].ready  = (levels & GPIO_CF_READY) ? 1 : 0;
83
        state_array->state[0].bvd1   = (levels & GPIO_CF_BVD1)  ? 1 : 0;
84
        state_array->state[0].bvd2   = (levels & GPIO_CF_BVD2)  ? 1 : 0;
85
        state_array->state[0].wrprot = 0; /* Not available on Yopy. */
86
        state_array->state[0].vs_3v  = 0; /* FIXME Can only apply 3.3V on Yopy. */
87
        state_array->state[0].vs_Xv  = 0;
88
 
89
        return 1;
90
}
91
 
92
static int yopy_pcmcia_get_irq_info(struct pcmcia_irq_info *info)
93
{
94
        if (info->sock != 0)
95
                return -1;
96
 
97
        info->irq = IRQ_CF_IREQ;
98
 
99
        return 0;
100
}
101
 
102
static int yopy_pcmcia_configure_socket(const struct pcmcia_configure *configure)
103
{
104
        if (configure->sock != 0)
105
                return -1;
106
 
107
        switch (configure->vcc) {
108
        case 0:  /* power off */;
109
                pcmcia_power(0);
110
                break;
111
        case 50:
112
                printk(KERN_WARNING __FUNCTION__"(): CS asked for 5V, applying 3.3V..\n");
113
        case 33:
114
                pcmcia_power(1);
115
                break;
116
        default:
117
                printk(KERN_ERR __FUNCTION__"(): unrecognized Vcc %u\n",
118
                       configure->vcc);
119
                return -1;
120
        }
121
 
122
        pcmcia_reset(configure->reset);
123
 
124
        /* Silently ignore Vpp, output enable, speaker enable. */
125
 
126
        return 0;
127
}
128
 
129
static int yopy_pcmcia_socket_init(int sock)
130
{
131
        set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
132
                          GPIO_BOTH_EDGES);
133
        return 0;
134
}
135
 
136
static int yopy_pcmcia_socket_suspend(int sock)
137
{
138
        set_GPIO_IRQ_edge(GPIO_CF_CD|GPIO_CF_BVD2|GPIO_CF_BVD1,
139
                          GPIO_NO_EDGES);
140
        return 0;
141
}
142
 
143
struct pcmcia_low_level yopy_pcmcia_ops = {
144
        init:                   yopy_pcmcia_init,
145
        shutdown:               yopy_pcmcia_shutdown,
146
        socket_state:           yopy_pcmcia_socket_state,
147
        get_irq_info:           yopy_pcmcia_get_irq_info,
148
        configure_socket:       yopy_pcmcia_configure_socket,
149
 
150
        socket_init:            yopy_pcmcia_socket_init,
151
        socket_suspend:         yopy_pcmcia_socket_suspend,
152
};

powered by: WebSVN 2.1.0

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