blob: 0e52a575986e0be6e8acf9a228717dbe4026787a [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * drivers/pcmcia/sa1100_shannon.c
4 *
5 * PCMCIA implementation routines for Shannon
6 *
7 */
8#include <linux/module.h>
9#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <linux/device.h>
11#include <linux/init.h>
Russell King31696632012-06-06 11:42:36 +010012#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Russell Kinga09e64f2008-08-05 16:14:15 +010014#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/mach-types.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010016#include <mach/shannon.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/irq.h>
18#include "sa1100_generic.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020static int shannon_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
21{
22 /* All those are inputs */
Russell King3b614362012-01-13 23:06:09 +000023 GAFR &= ~(GPIO_GPIO(SHANNON_GPIO_EJECT_0) |
24 GPIO_GPIO(SHANNON_GPIO_EJECT_1) |
25 GPIO_GPIO(SHANNON_GPIO_RDY_0) |
26 GPIO_GPIO(SHANNON_GPIO_RDY_1));
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Russell King3b614362012-01-13 23:06:09 +000028 if (skt->nr == 0) {
29 skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_0;
30 skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_0";
31 skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_0;
32 skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_0";
33 } else {
34 skt->stat[SOC_STAT_CD].gpio = SHANNON_GPIO_EJECT_1;
35 skt->stat[SOC_STAT_CD].name = "PCMCIA_CD_1";
36 skt->stat[SOC_STAT_RDY].gpio = SHANNON_GPIO_RDY_1;
37 skt->stat[SOC_STAT_RDY].name = "PCMCIA_RDY_1";
38 }
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Russell King3b614362012-01-13 23:06:09 +000040 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
43static void
44shannon_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
45 struct pcmcia_state *state)
46{
Linus Torvalds1da177e2005-04-16 15:20:36 -070047 switch (skt->nr) {
48 case 0:
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 state->bvd1 = 1;
50 state->bvd2 = 1;
51 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
52 state->vs_Xv = 0;
53 break;
54
55 case 1:
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 state->bvd1 = 1;
57 state->bvd2 = 1;
58 state->vs_3v = 1; /* FIXME Can only apply 3.3V on Shannon. */
59 state->vs_Xv = 0;
60 break;
61 }
62}
63
64static int
65shannon_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
66 const socket_state_t *state)
67{
68 switch (state->Vcc) {
69 case 0: /* power off */
Harvey Harrison2e11cb42008-05-01 04:34:54 -070070 printk(KERN_WARNING "%s(): CS asked for 0V, still applying 3.3V..\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 break;
72 case 50:
Harvey Harrison2e11cb42008-05-01 04:34:54 -070073 printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V..\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 case 33:
75 break;
76 default:
77 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070078 __func__, state->Vcc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 return -1;
80 }
81
Harvey Harrison2e11cb42008-05-01 04:34:54 -070082 printk(KERN_WARNING "%s(): Warning, Can't perform reset\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083
84 /* Silently ignore Vpp, output enable, speaker enable. */
85
86 return 0;
87}
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089static struct pcmcia_low_level shannon_pcmcia_ops = {
90 .owner = THIS_MODULE,
91 .hw_init = shannon_pcmcia_hw_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 .socket_state = shannon_pcmcia_socket_state,
93 .configure_socket = shannon_pcmcia_configure_socket,
Linus Torvalds1da177e2005-04-16 15:20:36 -070094};
95
Bill Pemberton34cdf252012-11-19 13:23:12 -050096int pcmcia_shannon_init(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
98 int ret = -ENODEV;
99
100 if (machine_is_shannon())
101 ret = sa11xx_drv_pcmcia_probe(dev, &shannon_pcmcia_ops, 0, 2);
102
103 return ret;
104}