License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[linux-block.git] / drivers / pcmcia / sa1100_cerf.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
1da177e4
LT
2/*
3 * drivers/pcmcia/sa1100_cerf.c
4 *
5 * PCMCIA implementation routines for CerfBoard
6 * Based off the Assabet.
7 *
8 */
1da177e4
LT
9#include <linux/module.h>
10#include <linux/kernel.h>
1da177e4
LT
11#include <linux/device.h>
12#include <linux/init.h>
13#include <linux/delay.h>
bbb58a12 14#include <linux/gpio.h>
1da177e4 15
a09e64fb 16#include <mach/hardware.h>
1da177e4
LT
17#include <asm/mach-types.h>
18#include <asm/irq.h>
a09e64fb 19#include <mach/cerf.h>
1da177e4
LT
20#include "sa1100_generic.h"
21
22#define CERF_SOCKET 1
23
1da177e4
LT
24static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
25{
bbb58a12
RK
26 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
f793e3ab
RK
32 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";
1da177e4 40
f793e3ab 41 return 0;
1da177e4
LT
42}
43
bbb58a12
RK
44static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
45{
46 gpio_free(CERF_GPIO_CF_RESET);
47}
48
1da177e4
LT
49static 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",
2e11cb4c 61 __func__, state->Vcc);
1da177e4
LT
62 return -1;
63 }
64
bbb58a12 65 gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET));
1da177e4
LT
66
67 return 0;
68}
69
1da177e4
LT
70static struct pcmcia_low_level cerf_pcmcia_ops = {
71 .owner = THIS_MODULE,
72 .hw_init = cerf_pcmcia_hw_init,
bbb58a12 73 .hw_shutdown = cerf_pcmcia_hw_shutdown,
a1d05002 74 .socket_state = soc_common_cf_socket_state,
1da177e4 75 .configure_socket = cerf_pcmcia_configure_socket,
1da177e4
LT
76};
77
34cdf25a 78int pcmcia_cerf_init(struct device *dev)
1da177e4
LT
79{
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}