blob: c3f67363f6a138433da4270f8bd39dec3f24910d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * drivers/pcmcia/sa1100_cerf.c
3 *
4 * PCMCIA implementation routines for CerfBoard
5 * Based off the Assabet.
6 *
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#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>
12#include <linux/delay.h>
Russell Kingbbb58a12012-01-18 12:32:37 +000013#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
Russell Kinga09e64f2008-08-05 16:14:15 +010015#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/mach-types.h>
17#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010018#include <mach/cerf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include "sa1100_generic.h"
20
21#define CERF_SOCKET 1
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
24{
Russell Kingbbb58a12012-01-18 12:32:37 +000025 int ret;
26
27 ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, "CF_RESET");
28 if (ret)
29 return ret;
30
Russell Kingf793e3a2012-01-13 23:03:57 +000031 skt->stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD;
32 skt->stat[SOC_STAT_CD].name = "CF_CD";
33 skt->stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1;
34 skt->stat[SOC_STAT_BVD1].name = "CF_BVD1";
35 skt->stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2;
36 skt->stat[SOC_STAT_BVD2].name = "CF_BVD2";
37 skt->stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ;
38 skt->stat[SOC_STAT_RDY].name = "CF_IRQ";
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Russell Kingf793e3a2012-01-13 23:03:57 +000040 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
Russell Kingbbb58a12012-01-18 12:32:37 +000043static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
44{
45 gpio_free(CERF_GPIO_CF_RESET);
46}
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048static int
49cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
50 const socket_state_t *state)
51{
52 switch (state->Vcc) {
53 case 0:
54 case 50:
55 case 33:
56 break;
57
58 default:
59 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070060 __func__, state->Vcc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 return -1;
62 }
63
Russell Kingbbb58a12012-01-18 12:32:37 +000064 gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET));
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66 return 0;
67}
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069static struct pcmcia_low_level cerf_pcmcia_ops = {
70 .owner = THIS_MODULE,
71 .hw_init = cerf_pcmcia_hw_init,
Russell Kingbbb58a12012-01-18 12:32:37 +000072 .hw_shutdown = cerf_pcmcia_hw_shutdown,
Russell Kinga1d05002016-08-31 08:49:46 +010073 .socket_state = soc_common_cf_socket_state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 .configure_socket = cerf_pcmcia_configure_socket,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075};
76
Bill Pemberton34cdf252012-11-19 13:23:12 -050077int pcmcia_cerf_init(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
79 int ret = -ENODEV;
80
81 if (machine_is_cerf())
82 ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
83
84 return ret;
85}