[PATCH 2/2][RFC] ep93xx pcmcia support for the ads sphere board
Lennert Buytenhek
buytenh at wantstofly.org
Sun Feb 4 19:05:39 EST 2007
Signed-off-by: Lennert Buytenhek <buytenh at wantstofly.org>
Index: linux-2.6.19/drivers/pcmcia/Makefile
===================================================================
--- linux-2.6.19.orig/drivers/pcmcia/Makefile
+++ linux-2.6.19/drivers/pcmcia/Makefile
@@ -55,6 +55,8 @@ au1x00_ss-$(CONFIG_MIPS_DB1500) += au1
au1x00_ss-$(CONFIG_MIPS_DB1550) += au1000_db1x00.o
au1x00_ss-$(CONFIG_MIPS_XXS1500) += au1000_xxs1500.o
+ep93xx_cs-$(CONFIG_MACH_ADSSPHERE) += ep93xx_adssphere.o
+
sa1111_cs-y += sa1111_generic.o
sa1111_cs-$(CONFIG_ASSABET_NEPONSET) += sa1100_neponset.o
sa1111_cs-$(CONFIG_SA1100_BADGE4) += sa1100_badge4.o
Index: linux-2.6.19/drivers/pcmcia/ep93xx_adssphere.c
===================================================================
--- /dev/null
+++ linux-2.6.19/drivers/pcmcia/ep93xx_adssphere.c
@@ -0,0 +1,167 @@
+/*
+ * linux/drivers/pcmcia/ep93xx_adssphere.c
+ * Copyright (C) 2005 Robert Whaley <rwhaley at applieddata.net>
+ *
+ * Adapted from pxa27x_mainstone.c, which is:
+ * Copyright (C) 2004 MontaVista Software Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+#include <pcmcia/ss.h>
+#include <asm/io.h>
+#include <asm/hardware.h>
+#include <asm/irq.h>
+#include <asm/mach-types.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/adssphere.h>
+#include "soc_common.h"
+
+#define EP93XX_GPIO_PFDR EP93XX_GPIO_REG(0x30)
+
+#define PCMCIACNT (EP93XX_PCMCIA_CONTROLLER_BASE + 0x40)
+
+
+static struct pcmcia_irqs irqs[] = {
+ { 0, IRQ_EP93XX_GPIO(EP93XX_GPIO_LINE_MCCD1), "PCMCIA CD1" },
+ { 0, IRQ_EP93XX_GPIO(EP93XX_GPIO_LINE_MCCD2), "PCMCIA CD2" },
+ { 0, IRQ_EP93XX_GPIO(EP93XX_GPIO_LINE_MCBVD1), "PCMCIA STSCHG/BVD1" },
+ { 0, IRQ_EP93XX_GPIO(EP93XX_GPIO_LINE_MCBVD2), "PCMCIA SPKR/BVD2" },
+};
+
+static int adssphere_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
+{
+ if (skt->nr == 0) {
+ skt->irq = IRQ_EP93XX_GPIO(EP93XX_GPIO_LINE_READY);
+ return soc_pcmcia_request_irqs(skt, irqs, ARRAY_SIZE(irqs));
+ }
+
+ return -ENXIO;
+}
+
+static void adssphere_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_free_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void adssphere_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
+ struct pcmcia_state *state)
+{
+ unsigned long status;
+
+ status = readl(EP93XX_GPIO_PFDR);
+ state->detect = (status & 0x06) ? 0 : 1;
+ state->ready = (status & 0x40) ? 1 : 0;
+ state->wrprot = (status & 0x01) ? 0 : 1;
+ state->bvd1 = (status & 0x08) ? 1 : 0;
+ state->bvd2 = (status & 0x10) ? 1 : 0;
+ state->vs_3v = (status & 0x20) ? 0 : 1;
+ state->vs_Xv = (status & 0x80) ? 0 : 1;
+}
+
+static int adssphere_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
+ const socket_state_t *state)
+{
+ unsigned long clrbits;
+ unsigned long setbits;
+
+ if (skt->nr != 0) {
+ printk(KERN_ERR "%s: socket %u invalid\n", __func__, skt->nr);
+ return -1;
+ }
+
+ clrbits = 0;
+ setbits = 0;
+
+ switch (state->Vcc) {
+ case 0:
+ clrbits = ADSSPHERE_CR0_CF_33 | ADSSPHERE_CR0_CF_50;
+ setbits = 0;
+ break;
+
+ case 33:
+ clrbits = ADSSPHERE_CR0_CF_50;
+ setbits = ADSSPHERE_CR0_CF_33;
+ break;
+
+ case 50:
+ clrbits = ADSSPHERE_CR0_CF_33;
+ setbits = ADSSPHERE_CR0_CF_50;
+ break;
+
+ default:
+ printk(KERN_ERR "%s: bad Vcc %u\n", __func__, state->Vcc);
+ return -1;
+ }
+
+ writel((readl(ADSSPHERE_CR0) & ~clrbits) | setbits, ADSSPHERE_CR0);
+
+ if (state->flags & SS_RESET)
+ /* see EP93xx User's Guide */
+ writel(0x15, PCMCIACNT);
+ else
+ /* CF mode - BIT1 for PCMCIA mode */
+ writel(0x11, PCMCIACNT);
+
+ return 0;
+}
+
+static void adssphere_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_enable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static void adssphere_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
+{
+ soc_pcmcia_disable_irqs(skt, irqs, ARRAY_SIZE(irqs));
+}
+
+static struct pcmcia_low_level adssphere_pcmcia_ops = {
+ .owner = THIS_MODULE,
+ .hw_init = adssphere_pcmcia_hw_init,
+ .hw_shutdown = adssphere_pcmcia_hw_shutdown,
+ .socket_state = adssphere_pcmcia_socket_state,
+ .configure_socket = adssphere_pcmcia_configure_socket,
+ .socket_init = adssphere_pcmcia_socket_init,
+ .socket_suspend = adssphere_pcmcia_socket_suspend,
+ .nr = 1,
+};
+
+static struct platform_device adssphere_pcmcia = {
+ .name = "ep93xx-pcmcia",
+ .id = -1,
+ .dev = {
+ .platform_data = &adssphere_pcmcia_ops,
+ },
+};
+
+static int __init adssphere_pcmcia_init(void)
+{
+ int ret;
+
+ ret = 0;
+ if (machine_is_adssphere())
+ ret = platform_device_register(&adssphere_pcmcia);
+
+ return ret;
+}
+
+static void __exit adssphere_pcmcia_exit(void)
+{
+ if (machine_is_adssphere())
+ platform_device_unregister(&adssphere_pcmcia);
+}
+
+module_init(adssphere_pcmcia_init);
+module_exit(adssphere_pcmcia_exit);
+
+MODULE_LICENSE("GPL");
Index: linux-2.6.19/include/asm-arm/arch-ep93xx/adssphere.h
===================================================================
--- linux-2.6.19.orig/include/asm-arm/arch-ep93xx/adssphere.h
+++ linux-2.6.19/include/asm-arm/arch-ep93xx/adssphere.h
@@ -8,6 +8,8 @@
#define ADSSPHERE_CPLD_REG(x) (ADSSPHERE_CPLD_VIRT_BASE + (x))
#define ADSSPHERE_CR0 ADSSPHERE_CPLD_REG(0x00)
+ #define ADSSPHERE_CR0_CF_33 0x01
+ #define ADSSPHERE_CR0_CF_50 0x02
#define ADSSPHERE_CR1 ADSSPHERE_CPLD_REG(0x04)
#define ADSSPHERE_CR1_CODEC_POWER 0x20
#define ADSSPHERE_CR1_AMP_POWER 0x10
More information about the linux-pcmcia
mailing list