blob: 2a54081d161d4a64769ddfa429dc04e95c9070f7 [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_cerf.c
4 *
5 * PCMCIA implementation routines for CerfBoard
6 * Based off the Assabet.
7 *
8 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#include <linux/module.h>
10#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/device.h>
12#include <linux/init.h>
13#include <linux/delay.h>
Russell Kingbbb58a12012-01-18 12:32:37 +000014#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015
Russell Kinga09e64f2008-08-05 16:14:15 +010016#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/mach-types.h>
18#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010019#include <mach/cerf.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include "sa1100_generic.h"
21
22#define CERF_SOCKET 1
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25{
Russell Kingbbb58a12012-01-18 12:32:37 +000026 int ret;
27
28 ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, "CF_RESET");
29 if (ret)
30 return ret;
31
Russell Kingf793e3a2012-01-13 23:03:57 +000032 skt->stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD;
33 skt->stat[SOC_STAT_CD].name = "CF_CD";
34 skt->stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1;
35 skt->stat[SOC_STAT_BVD1].name = "CF_BVD1";
36 skt->stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2;
37 skt->stat[SOC_STAT_BVD2].name = "CF_BVD2";
38 skt->stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ;
39 skt->stat[SOC_STAT_RDY].name = "CF_IRQ";
Linus Torvalds1da177e2005-04-16 15:20:36 -070040
Russell Kingf793e3a2012-01-13 23:03:57 +000041 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -070042}
43
Russell Kingbbb58a12012-01-18 12:32:37 +000044static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
45{
46 gpio_free(CERF_GPIO_CF_RESET);
47}
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049static int
50cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
51 const socket_state_t *state)
52{
53 switch (state->Vcc) {
54 case 0:
55 case 50:
56 case 33:
57 break;
58
59 default:
60 printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
Harvey Harrison2e11cb42008-05-01 04:34:54 -070061 __func__, state->Vcc);
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 return -1;
63 }
64
Russell Kingbbb58a12012-01-18 12:32:37 +000065 gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET));
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 return 0;
68}
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070static struct pcmcia_low_level cerf_pcmcia_ops = {
71 .owner = THIS_MODULE,
72 .hw_init = cerf_pcmcia_hw_init,
Russell Kingbbb58a12012-01-18 12:32:37 +000073 .hw_shutdown = cerf_pcmcia_hw_shutdown,
Russell Kinga1d05002016-08-31 08:49:46 +010074 .socket_state = soc_common_cf_socket_state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 .configure_socket = cerf_pcmcia_configure_socket,
Linus Torvalds1da177e2005-04-16 15:20:36 -070076};
77
Bill Pemberton34cdf252012-11-19 13:23:12 -050078int pcmcia_cerf_init(struct device *dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
80 int ret = -ENODEV;
81
82 if (machine_is_cerf())
83 ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
84
85 return ret;
86}