Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/drivers/pcmcia/pxa2xx_lubbock.c
0004  *
0005  * Author:  George Davis
0006  * Created: Jan 10, 2002
0007  * Copyright:   MontaVista Software Inc.
0008  *
0009  * Originally based upon linux/drivers/pcmcia/sa1100_neponset.c
0010  *
0011  * Lubbock PCMCIA specific routines.
0012  */
0013 #include <linux/module.h>
0014 #include <linux/kernel.h>
0015 #include <linux/device.h>
0016 #include <linux/errno.h>
0017 #include <linux/init.h>
0018 #include <linux/delay.h>
0019 
0020 #include <asm/hardware/sa1111.h>
0021 #include <asm/mach-types.h>
0022 
0023 #include "sa1111_generic.h"
0024 #include "max1600.h"
0025 
0026 static int lubbock_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
0027 {
0028     struct max1600 *m;
0029     int ret;
0030 
0031     ret = max1600_init(skt->socket.dev.parent, &m,
0032                skt->nr ? MAX1600_CHAN_B : MAX1600_CHAN_A,
0033                MAX1600_CODE_HIGH);
0034     if (ret == 0)
0035         skt->driver_data = m;
0036 
0037     return ret;
0038 }
0039 
0040 static int
0041 lubbock_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
0042                 const socket_state_t *state)
0043 {
0044     struct max1600 *m = skt->driver_data;
0045     int ret = 0;
0046 
0047     /* Lubbock uses the Maxim MAX1602, with the following connections:
0048      *
0049      * Socket 0 (PCMCIA):
0050      *  MAX1602 Lubbock     Register
0051      *  Pin Signal
0052      *  -----   -------     ----------------------
0053      *  A0VPP   S0_PWR0     SA-1111 GPIO A<0>
0054      *  A1VPP   S0_PWR1     SA-1111 GPIO A<1>
0055      *  A0VCC   S0_PWR2     SA-1111 GPIO A<2>
0056      *  A1VCC   S0_PWR3     SA-1111 GPIO A<3>
0057      *  VX  VCC
0058      *  VY  +3.3V
0059      *  12IN    +12V
0060      *  CODE    +3.3V       Cirrus  Code, CODE = High (VY)
0061      *
0062      * Socket 1 (CF):
0063      *  MAX1602 Lubbock     Register
0064      *  Pin Signal
0065      *  -----   -------     ----------------------
0066      *  A0VPP   GND     VPP is not connected
0067      *  A1VPP   GND     VPP is not connected
0068      *  A0VCC   S1_PWR0     MISC_WR<14>
0069      *  A1VCC   S1_PWR1     MISC_WR<15>
0070      *  VX  VCC
0071      *  VY  +3.3V
0072      *  12IN    GND     VPP is not connected
0073      *  CODE    +3.3V       Cirrus  Code, CODE = High (VY)
0074      *
0075      */
0076 
0077  again:
0078     switch (skt->nr) {
0079     case 0:
0080     case 1:
0081         break;
0082 
0083     default:
0084         ret = -1;
0085     }
0086 
0087     if (ret == 0)
0088         ret = sa1111_pcmcia_configure_socket(skt, state);
0089     if (ret == 0)
0090         ret = max1600_configure(m, state->Vcc, state->Vpp);
0091 
0092 #if 1
0093     if (ret == 0 && state->Vcc == 33) {
0094         struct pcmcia_state new_state;
0095 
0096         /*
0097          * HACK ALERT:
0098          * We can't sense the voltage properly on Lubbock before
0099          * actually applying some power to the socket (catch 22).
0100          * Resense the socket Voltage Sense pins after applying
0101          * socket power.
0102          *
0103          * Note: It takes about 2.5ms for the MAX1602 VCC output
0104          * to rise.
0105          */
0106         mdelay(3);
0107 
0108         sa1111_pcmcia_socket_state(skt, &new_state);
0109 
0110         if (!new_state.vs_3v && !new_state.vs_Xv) {
0111             /*
0112              * Switch to 5V,  Configure socket with 5V voltage
0113              */
0114             max1600_configure(m, 0, 0);
0115 
0116             /*
0117              * It takes about 100ms to turn off Vcc.
0118              */
0119             mdelay(100);
0120 
0121             /*
0122              * We need to hack around the const qualifier as
0123              * well to keep this ugly workaround localized and
0124              * not force it to the rest of the code. Barf bags
0125              * available in the seat pocket in front of you!
0126              */
0127             ((socket_state_t *)state)->Vcc = 50;
0128             ((socket_state_t *)state)->Vpp = 50;
0129             goto again;
0130         }
0131     }
0132 #endif
0133 
0134     return ret;
0135 }
0136 
0137 static struct pcmcia_low_level lubbock_pcmcia_ops = {
0138     .owner          = THIS_MODULE,
0139     .hw_init        = lubbock_pcmcia_hw_init,
0140     .configure_socket   = lubbock_pcmcia_configure_socket,
0141     .first          = 0,
0142     .nr         = 2,
0143 };
0144 
0145 #include "pxa2xx_base.h"
0146 
0147 int pcmcia_lubbock_init(struct sa1111_dev *sadev)
0148 {
0149     pxa2xx_drv_pcmcia_ops(&lubbock_pcmcia_ops);
0150     pxa2xx_configure_sockets(&sadev->dev, &lubbock_pcmcia_ops);
0151     return sa1111_pcmcia_add(sadev, &lubbock_pcmcia_ops,
0152                  pxa2xx_drv_pcmcia_add_one);
0153 }
0154 
0155 MODULE_LICENSE("GPL");