rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * drivers/pcmcia/sa1100_assabet.c |
| 4 | * |
| 5 | * PCMCIA implementation routines for Assabet |
| 6 | * |
| 7 | */ |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/interrupt.h> |
| 12 | #include <linux/device.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/gpio.h> |
| 15 | |
| 16 | #include <asm/mach-types.h> |
| 17 | #include <mach/assabet.h> |
| 18 | |
| 19 | #include "sa1100_generic.h" |
| 20 | |
| 21 | static int assabet_pcmcia_hw_init(struct soc_pcmcia_socket *skt) |
| 22 | { |
| 23 | skt->stat[SOC_STAT_CD].gpio = ASSABET_GPIO_CF_CD; |
| 24 | skt->stat[SOC_STAT_CD].name = "CF CD"; |
| 25 | skt->stat[SOC_STAT_BVD1].gpio = ASSABET_GPIO_CF_BVD1; |
| 26 | skt->stat[SOC_STAT_BVD1].name = "CF BVD1"; |
| 27 | skt->stat[SOC_STAT_BVD2].gpio = ASSABET_GPIO_CF_BVD2; |
| 28 | skt->stat[SOC_STAT_BVD2].name = "CF BVD2"; |
| 29 | skt->stat[SOC_STAT_RDY].gpio = ASSABET_GPIO_CF_IRQ; |
| 30 | skt->stat[SOC_STAT_RDY].name = "CF RDY"; |
| 31 | |
| 32 | return 0; |
| 33 | } |
| 34 | |
| 35 | static int |
| 36 | assabet_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state) |
| 37 | { |
| 38 | unsigned int mask; |
| 39 | |
| 40 | switch (state->Vcc) { |
| 41 | case 0: |
| 42 | mask = 0; |
| 43 | break; |
| 44 | |
| 45 | case 50: |
| 46 | printk(KERN_WARNING "%s(): CS asked for 5V, applying 3.3V...\n", |
| 47 | __func__); |
| 48 | |
| 49 | case 33: /* Can only apply 3.3V to the CF slot. */ |
| 50 | mask = ASSABET_BCR_CF_PWR; |
| 51 | break; |
| 52 | |
| 53 | default: |
| 54 | printk(KERN_ERR "%s(): unrecognized Vcc %u\n", __func__, |
| 55 | state->Vcc); |
| 56 | return -1; |
| 57 | } |
| 58 | |
| 59 | /* Silently ignore Vpp, speaker enable. */ |
| 60 | |
| 61 | if (state->flags & SS_RESET) |
| 62 | mask |= ASSABET_BCR_CF_RST; |
| 63 | if (!(state->flags & SS_OUTPUT_ENA)) |
| 64 | mask |= ASSABET_BCR_CF_BUS_OFF; |
| 65 | |
| 66 | ASSABET_BCR_frob(ASSABET_BCR_CF_RST | ASSABET_BCR_CF_PWR | |
| 67 | ASSABET_BCR_CF_BUS_OFF, mask); |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * Disable card status IRQs on suspend. |
| 74 | */ |
| 75 | static void assabet_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) |
| 76 | { |
| 77 | /* |
| 78 | * Tristate the CF bus signals. Also assert CF |
| 79 | * reset as per user guide page 4-11. |
| 80 | */ |
| 81 | ASSABET_BCR_set(ASSABET_BCR_CF_BUS_OFF | ASSABET_BCR_CF_RST); |
| 82 | } |
| 83 | |
| 84 | static struct pcmcia_low_level assabet_pcmcia_ops = { |
| 85 | .owner = THIS_MODULE, |
| 86 | .hw_init = assabet_pcmcia_hw_init, |
| 87 | .socket_state = soc_common_cf_socket_state, |
| 88 | .configure_socket = assabet_pcmcia_configure_socket, |
| 89 | .socket_suspend = assabet_pcmcia_socket_suspend, |
| 90 | }; |
| 91 | |
| 92 | int pcmcia_assabet_init(struct device *dev) |
| 93 | { |
| 94 | int ret = -ENODEV; |
| 95 | |
| 96 | if (machine_is_assabet() && !machine_has_neponset()) |
| 97 | ret = sa11xx_drv_pcmcia_probe(dev, &assabet_pcmcia_ops, 1, 1); |
| 98 | |
| 99 | return ret; |
| 100 | } |