Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/pcmcia/pxa2xx_cm_x270.c (Version 2.6.25.8) and /linux/drivers/pcmcia/pxa2xx_cm_x270.c (Version 2.6.31.13)


  1 /*                                                  1 /*
  2  * linux/drivers/pcmcia/pxa/pxa_cm_x270.c           2  * linux/drivers/pcmcia/pxa/pxa_cm_x270.c
  3  *                                                  3  *
  4  * This program is free software; you can redi      4  * This program is free software; you can redistribute it and/or modify
  5  * it under the terms of the GNU General Publi      5  * it under the terms of the GNU General Public License version 2 as
  6  * published by the Free Software Foundation.       6  * published by the Free Software Foundation.
  7  *                                                  7  *
  8  * Compulab Ltd., 2003, 2007                   !!   8  * Compulab Ltd., 2003, 2007, 2008
  9  * Mike Rapoport <mike@compulab.co.il>              9  * Mike Rapoport <mike@compulab.co.il>
 10  *                                                 10  *
 11  */                                                11  */
 12                                                    12 
 13 #include <linux/kernel.h>                      << 
 14 #include <linux/sched.h>                       << 
 15 #include <linux/platform_device.h>                 13 #include <linux/platform_device.h>
 16 #include <linux/irq.h>                             14 #include <linux/irq.h>
 17 #include <linux/delay.h>                           15 #include <linux/delay.h>
                                                   >>  16 #include <linux/gpio.h>
 18                                                    17 
 19 #include <pcmcia/ss.h>                         !!  18 #include <asm/mach-types.h>
 20 #include <asm/hardware.h>                      << 
 21                                                << 
 22 #include <asm/arch/pxa-regs.h>                 << 
 23 #include <asm/arch/cm-x270.h>                  << 
 24                                                    19 
 25 #include "soc_common.h"                            20 #include "soc_common.h"
 26                                                    21 
                                                   >>  22 #define GPIO_PCMCIA_S0_CD_VALID (84)
                                                   >>  23 #define GPIO_PCMCIA_S0_RDYINT   (82)
                                                   >>  24 #define GPIO_PCMCIA_RESET       (53)
                                                   >>  25 
                                                   >>  26 #define PCMCIA_S0_CD_VALID      IRQ_GPIO(GPIO_PCMCIA_S0_CD_VALID)
                                                   >>  27 #define PCMCIA_S0_RDYINT        IRQ_GPIO(GPIO_PCMCIA_S0_RDYINT)
                                                   >>  28 
                                                   >>  29 
 27 static struct pcmcia_irqs irqs[] = {               30 static struct pcmcia_irqs irqs[] = {
 28         { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD"      31         { 0, PCMCIA_S0_CD_VALID, "PCMCIA0 CD" },
 29         { 1, PCMCIA_S1_CD_VALID, "PCMCIA1 CD"  << 
 30 };                                                 32 };
 31                                                    33 
 32 static int cmx270_pcmcia_hw_init(struct soc_pc     34 static int cmx270_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
 33 {                                                  35 {
 34         GPSR(GPIO48_nPOE) = GPIO_bit(GPIO48_nP !!  36         int ret = gpio_request(GPIO_PCMCIA_RESET, "PCCard reset");
 35                 GPIO_bit(GPIO49_nPWE) |        !!  37         if (ret)
 36                 GPIO_bit(GPIO50_nPIOR) |       !!  38                 return ret;
 37                 GPIO_bit(GPIO51_nPIOW) |       !!  39         gpio_direction_output(GPIO_PCMCIA_RESET, 0);
 38                 GPIO_bit(GPIO85_nPCE_1) |      << 
 39                 GPIO_bit(GPIO54_nPCE_2);       << 
 40                                                << 
 41         pxa_gpio_mode(GPIO48_nPOE_MD);         << 
 42         pxa_gpio_mode(GPIO49_nPWE_MD);         << 
 43         pxa_gpio_mode(GPIO50_nPIOR_MD);        << 
 44         pxa_gpio_mode(GPIO51_nPIOW_MD);        << 
 45         pxa_gpio_mode(GPIO85_nPCE_1_MD);       << 
 46         pxa_gpio_mode(GPIO54_nPCE_2_MD);       << 
 47         pxa_gpio_mode(GPIO55_nPREG_MD);        << 
 48         pxa_gpio_mode(GPIO56_nPWAIT_MD);       << 
 49         pxa_gpio_mode(GPIO57_nIOIS16_MD);      << 
 50                                                << 
 51         /* Reset signal */                     << 
 52         pxa_gpio_mode(GPIO53_nPCE_2 | GPIO_OUT << 
 53         GPCR(GPIO53_nPCE_2) = GPIO_bit(GPIO53_ << 
 54                                                << 
 55         set_irq_type(PCMCIA_S0_CD_VALID, IRQ_T << 
 56         set_irq_type(PCMCIA_S1_CD_VALID, IRQ_T << 
 57                                                << 
 58         /* irq's for slots: */                 << 
 59         set_irq_type(PCMCIA_S0_RDYINT, IRQ_TYP << 
 60         set_irq_type(PCMCIA_S1_RDYINT, IRQ_TYP << 
 61                                                    40 
 62         skt->irq = (skt->nr == 0) ? PCMCIA_S0_ !!  41         skt->irq = PCMCIA_S0_RDYINT;
 63         return soc_pcmcia_request_irqs(skt, ir !!  42         ret = soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
                                                   >>  43         if (!ret)
                                                   >>  44                 gpio_free(GPIO_PCMCIA_RESET);
                                                   >>  45 
                                                   >>  46         return ret;
 64 }                                                  47 }
 65                                                    48 
 66 static void cmx270_pcmcia_shutdown(struct soc_     49 static void cmx270_pcmcia_shutdown(struct soc_pcmcia_socket *skt)
 67 {                                                  50 {
 68         soc_pcmcia_free_irqs(skt, irqs, ARRAY_     51         soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
 69                                                !!  52         gpio_free(GPIO_PCMCIA_RESET);
 70         set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_CD_ << 
 71         set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_CD_ << 
 72                                                << 
 73         set_irq_type(IRQ_TO_GPIO(PCMCIA_S0_RDY << 
 74         set_irq_type(IRQ_TO_GPIO(PCMCIA_S1_RDY << 
 75 }                                                  53 }
 76                                                    54 
 77                                                    55 
 78 static void cmx270_pcmcia_socket_state(struct      56 static void cmx270_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
 79                                        struct      57                                        struct pcmcia_state *state)
 80 {                                                  58 {
 81         state->detect = (PCC_DETECT(skt->nr) = !!  59         state->detect = (gpio_get_value(GPIO_PCMCIA_S0_CD_VALID) == 0) ? 1 : 0;
 82         state->ready  = (PCC_READY(skt->nr) == !!  60         state->ready  = (gpio_get_value(GPIO_PCMCIA_S0_RDYINT) == 0) ? 0 : 1;
 83         state->bvd1   = 1;                         61         state->bvd1   = 1;
 84         state->bvd2   = 1;                         62         state->bvd2   = 1;
 85         state->vs_3v  = 0;                         63         state->vs_3v  = 0;
 86         state->vs_Xv  = 0;                         64         state->vs_Xv  = 0;
 87         state->wrprot = 0;  /* not available *     65         state->wrprot = 0;  /* not available */
 88 }                                                  66 }
 89                                                    67 
 90                                                    68 
 91 static int cmx270_pcmcia_configure_socket(stru     69 static int cmx270_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
 92                                           cons     70                                           const socket_state_t *state)
 93 {                                                  71 {
 94         GPSR(GPIO49_nPWE) = GPIO_bit(GPIO49_nP << 
 95         pxa_gpio_mode(GPIO49_nPWE | GPIO_OUT); << 
 96                                                << 
 97         switch (skt->nr) {                         72         switch (skt->nr) {
 98         case 0:                                    73         case 0:
 99                 if (state->flags & SS_RESET) {     74                 if (state->flags & SS_RESET) {
100                         GPCR(GPIO49_nPWE) = GP !!  75                         gpio_set_value(GPIO_PCMCIA_RESET, 1);
101                         GPSR(GPIO53_nPCE_2) =  << 
102                         udelay(10);            << 
103                         GPCR(GPIO53_nPCE_2) =  << 
104                         GPSR(GPIO49_nPWE) = GP << 
105                 }                              << 
106                 break;                         << 
107         case 1:                                << 
108                 if (state->flags & SS_RESET) { << 
109                         GPCR(GPIO49_nPWE) = GP << 
110                         GPSR(GPIO53_nPCE_2) =  << 
111                         udelay(10);                76                         udelay(10);
112                         GPCR(GPIO53_nPCE_2) =  !!  77                         gpio_set_value(GPIO_PCMCIA_RESET, 0);
113                         GPSR(GPIO49_nPWE) = GP << 
114                 }                                  78                 }
115                 break;                             79                 break;
116         }                                          80         }
117                                                    81 
118         pxa_gpio_mode(GPIO49_nPWE_MD);         << 
119                                                << 
120         return 0;                                  82         return 0;
121 }                                                  83 }
122                                                    84 
123 static void cmx270_pcmcia_socket_init(struct s     85 static void cmx270_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
124 {                                                  86 {
125 }                                                  87 }
126                                                    88 
127 static void cmx270_pcmcia_socket_suspend(struc     89 static void cmx270_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
128 {                                                  90 {
129 }                                                  91 }
130                                                    92 
131                                                    93 
132 static struct pcmcia_low_level cmx270_pcmcia_o !!  94 static struct pcmcia_low_level cmx270_pcmcia_ops __initdata = {
133         .owner                  = THIS_MODULE,     95         .owner                  = THIS_MODULE,
134         .hw_init                = cmx270_pcmci     96         .hw_init                = cmx270_pcmcia_hw_init,
135         .hw_shutdown            = cmx270_pcmci     97         .hw_shutdown            = cmx270_pcmcia_shutdown,
136         .socket_state           = cmx270_pcmci     98         .socket_state           = cmx270_pcmcia_socket_state,
137         .configure_socket       = cmx270_pcmci     99         .configure_socket       = cmx270_pcmcia_configure_socket,
138         .socket_init            = cmx270_pcmci    100         .socket_init            = cmx270_pcmcia_socket_init,
139         .socket_suspend         = cmx270_pcmci    101         .socket_suspend         = cmx270_pcmcia_socket_suspend,
140         .nr                     = 2,           !! 102         .nr                     = 1,
141 };                                                103 };
142                                                   104 
143 static struct platform_device *cmx270_pcmcia_d    105 static struct platform_device *cmx270_pcmcia_device;
144                                                   106 
145 static int __init cmx270_pcmcia_init(void)     !! 107 int __init cmx270_pcmcia_init(void)
146 {                                                 108 {
147         int ret;                                  109         int ret;
148                                                   110 
149         cmx270_pcmcia_device = platform_device    111         cmx270_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
150                                                   112 
151         if (!cmx270_pcmcia_device)                113         if (!cmx270_pcmcia_device)
152                 return -ENOMEM;                   114                 return -ENOMEM;
153                                                   115 
154         cmx270_pcmcia_device->dev.platform_dat !! 116         ret = platform_device_add_data(cmx270_pcmcia_device, &cmx270_pcmcia_ops,
                                                   >> 117                                        sizeof(cmx270_pcmcia_ops));
155                                                   118 
156         printk(KERN_INFO "Registering cm-x270  !! 119         if (ret == 0) {
157         ret = platform_device_add(cmx270_pcmci !! 120                 printk(KERN_INFO "Registering cm-x270 PCMCIA interface.\n");
                                                   >> 121                 ret = platform_device_add(cmx270_pcmcia_device);
                                                   >> 122         }
158                                                   123 
159         if (ret)                                  124         if (ret)
160                 platform_device_put(cmx270_pcm    125                 platform_device_put(cmx270_pcmcia_device);
161                                                   126 
162         return ret;                               127         return ret;
163 }                                                 128 }
164                                                   129 
165 static void __exit cmx270_pcmcia_exit(void)    !! 130 void __exit cmx270_pcmcia_exit(void)
166 {                                                 131 {
167         platform_device_unregister(cmx270_pcmc    132         platform_device_unregister(cmx270_pcmcia_device);
168 }                                                 133 }
169                                                << 
170 module_init(cmx270_pcmcia_init);               << 
171 module_exit(cmx270_pcmcia_exit);               << 
172                                                << 
173 MODULE_LICENSE("GPL");                         << 
174 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co << 
175 MODULE_DESCRIPTION("CM-x270 PCMCIA driver");   << 
176                                                   134 
  This page was automatically generated by the LXR engine.