Driver model for sa1101

Matan Ziv-Av matan@svgalib.org
Sat Jul 10 21:32:19 CEST 2004


On Sat, 10 Jul 2004, Francois-Rene Rideau wrote:

> Can you produce a patch relative to what's now there?

Attached.


-- 
Matan Ziv-Av.                         matan@svgalib.org
-------------- next part --------------
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/arch/arm/common/sa1101.c my2/arch/arm/common/sa1101.c
--- kernel26/arch/arm/common/sa1101.c	2004-07-10 22:28:20.000000000 +0300
+++ my2/arch/arm/common/sa1101.c	2004-07-10 21:21:38.000000000 +0300
@@ -12,7 +12,7 @@
  *
  * Created for the Jornada820 port.
  *
- * $Id: sa1101.c,v 1.11 2004/07/10 18:58:19 fare Exp $
+ * $Id: sa1101.c,v 1.9 2004/07/07 17:26:18 oleg820 Exp $
  */
 
 #include <linux/module.h>
@@ -63,11 +63,10 @@
 };
 
 static struct sa1101_dev_info sa1101_devices[] = {
-#if 0
 	{
-		.offset		= SA1111_USB,
-		.skpcr_mask	= SKPCR_UCLKEN,
-		.devid		= SA1111_DEVID_USB,
+		.offset		= SA1101_USB,
+		.skpcr_mask	= SKPCR_UCLKEn,
+		.devid		= SA1101_DEVID_USB,
 		.irq = {
 			IRQ_USBPWR,
 			IRQ_HCIM,
@@ -77,6 +76,7 @@
 			IRQ_USB_PORT_RESUME
 		},
 	},
+#if 0
 	{
 		.offset		= 0x0600,
 		.skpcr_mask	= SKPCR_I2SCLKEN | SKPCR_L3CLKEN,
@@ -113,7 +113,7 @@
 	},
 #endif
 	{
-		.offset		= 0x1e0000,
+		.offset		= SA1101_PCMCIA,
 		.skpcr_mask	= 0,
 		.devid		= SA1101_DEVID_PCMCIA,
 		.irq = {
@@ -164,7 +164,7 @@
 	dev->mapbase     = (u8 *)0xf4000000 + info->offset;
 	dev->skpcr_mask  = info->skpcr_mask;
 	memmove(dev->irq, info->irq, sizeof(dev->irq));
-#if 0
+#if 1
 	ret = request_resource(parent_res, &dev->res);
 	if (ret) {
 		printk("SA1101: failed to allocate resource for %s\n",
@@ -194,6 +194,7 @@
 
 int sa1101_probe(struct device * _dev)
 {
+	struct platform_device *pdev = to_platform_device(_dev);
 	struct sa1101_dev *dev = SA1101_DEV(_dev);
 	/* should check */
 	int i;
@@ -206,7 +207,7 @@
 
 	for (i = 0; i < ARRAY_SIZE(sa1101_devices); i++)
 		if (has_devs & (1 << i))
-			sa1101_init_one_child(&dev->dev, &dev->res, &sa1101_devices[i]);
+			sa1101_init_one_child(&dev->dev, &pdev->resource[0], &sa1101_devices[i]);
 
 	return 0;
 }
@@ -233,13 +234,12 @@
 sa1101_irq_handler(unsigned int irq, struct irqdesc *desc, struct pt_regs *regs)
 {
 	unsigned int stat0, stat1, i;
-//	printk("Got sa1101 interrupt (%d).\n", irq); // DEBUG
 
 	stat0 = INTSTATCLR0;
 	stat1 = INTSTATCLR1;
 	INTSTATCLR0 = stat0;
 	INTSTATCLR1 = stat1;
-
+	desc->chip->mask(irq);
 	desc->chip->ack(irq);
 
 	if (stat0 == 0 && stat1 == 0) {
@@ -247,6 +247,7 @@
 		return;
 	}
 
+	do {
 	for (i = IRQ_SA1101_START; stat0; i++, stat0 >>= 1)
 		if (stat0 & 1)
 			do_edge_IRQ(i, irq_desc + i, regs);
@@ -255,8 +256,15 @@
 		if (stat1 & 1)
 			do_edge_IRQ(i, irq_desc + i, regs);
 
+		stat0 = INTSTATCLR0;
+		stat1 = INTSTATCLR1;	
+		INTSTATCLR0 = stat0;
+		INTSTATCLR1 = stat1;
+	} while (stat0 | stat1); 
+
 	/* For level-based interrupts */
 	desc->chip->unmask(irq);
+
 }
 
 static void sa1101_ack_irq(unsigned int irq)
@@ -390,7 +398,7 @@
 	unsigned int irq;
 
 	alloc_irq_space(64); /* XXX - still needed??? */
-	request_mem_region(_INTTEST0, 512, "irqs-1101"); // XXX - still needed???
+	request_mem_region(SA1101_INTERRUPT, 0x1ffff, "irqs-1101"); // XXX - still needed???
 
 	/* disable all IRQs */
 	INTENABLE0 = 0;
@@ -428,7 +436,7 @@
 //		    "SA1101 chain interrupt", NULL); // DEBUG
 	
 	set_irq_type(sa1101_irq, IRQT_RISING);
-	set_irq_data(sa1101_irq, (void *)_INTTEST0);
+	set_irq_data(sa1101_irq, (void *)SA1101_INTERRUPT);
 	set_irq_chained_handler(sa1101_irq, sa1101_irq_handler); // NORMAL
 }
 
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/drivers/pcmcia/sa1100_jornada820.c my2/drivers/pcmcia/sa1100_jornada820.c
--- kernel26/drivers/pcmcia/sa1100_jornada820.c	2004-07-08 05:44:23.000000000 +0300
+++ my2/drivers/pcmcia/sa1100_jornada820.c	2004-07-09 14:40:48.000000000 +0300
@@ -13,7 +13,7 @@
 
 #include <linux/interrupt.h>
 #include <asm/mach/irq.h>
-#include <asm/arch/irq.h>
+#include <asm/arch/irqs.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/drivers/pcmcia/sa1101.c my2/drivers/pcmcia/sa1101.c
--- kernel26/drivers/pcmcia/sa1101.c	2004-07-06 17:39:26.000000000 +0300
+++ my2/drivers/pcmcia/sa1101.c	2004-07-10 17:21:46.000000000 +0300
@@ -214,7 +214,9 @@
 
 static int pcmcia_probe(struct sa1101_dev *dev)
 {
+	struct sa1101_dev *sadev = SA1101_DEV(dev);
 	printk("sa1101 pcmcia: probe...\n"); // DEBUG
+	if(sadev->devid != SA1101_DEVID_PCMCIA) return -1;
 	return sa11xx_drv_pcmcia_probe(&dev->dev, &sa1101_pcmcia_ops, 0, 2);
 }
 static int __devexit pcmcia_remove(struct sa1101_dev *dev)
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/drivers/pcmcia/sa1101_generic.c my2/drivers/pcmcia/sa1101_generic.c
--- kernel26/drivers/pcmcia/sa1101_generic.c	2004-07-07 19:56:39.000000000 +0300
+++ my2/drivers/pcmcia/sa1101_generic.c	2004-07-09 14:39:55.000000000 +0300
@@ -18,7 +18,7 @@
 
 #include <linux/interrupt.h>
 #include <asm/mach/irq.h>
-#include <asm/arch/irq.h>
+#include <asm/arch/irqs.h>
 
 #include <asm/hardware.h>
 #include <asm/mach-types.h>
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/include/asm-arm/arch-sa1100/SA-1101.h my2/include/asm-arm/arch-sa1100/SA-1101.h
--- kernel26/include/asm-arm/arch-sa1100/SA-1101.h	2004-07-10 22:28:21.000000000 +0300
+++ my2/include/asm-arm/arch-sa1100/SA-1101.h	2004-07-10 18:45:20.000000000 +0300
@@ -58,6 +58,10 @@
 #define	__VGA_CONTROL		0x00200000
 #define __GPIO_INTERFACE	0x00300000
 
+#define SA1101_INTERRUPT	__INTERRUPT_CONTROL
+#define SA1101_USB			__USB_CONTROL
+#define SA1101_PCMCIA		__PCMCIA_INTERFACE
+
 /*
  * Macro that calculates real address for registers in the SA-1101
  */
diff -ubBr -x jornada820.c -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/include/asm-arm/hardware/sa1101.h my2/include/asm-arm/hardware/sa1101.h
--- kernel26/include/asm-arm/hardware/sa1101.h	2004-07-10 22:28:21.000000000 +0300
+++ my2/include/asm-arm/hardware/sa1101.h	2004-07-10 21:38:19.000000000 +0300
@@ -1,6 +1,6 @@
 /*
  * File created for Jornada 820... (?)
- * $Id: sa1101.h,v 1.7 2004/07/10 18:58:19 fare Exp $
+ * $Id: sa1101.h,v 1.6 2004/07/08 10:02:59 oleg820 Exp $
  */
 #ifndef _ASM_ARCH_SA1101
 #define _ASM_ARCH_SA1101
@@ -12,15 +12,6 @@
 
 #ifndef __ASSEMBLY__
 
-struct sa1101_dev {
-	struct device	dev;
-	unsigned int	devid;
-	struct resource	res;
-	void		*mapbase;
-	unsigned int	skpcr_mask;
-	unsigned int	irq[6];
-};
-
 /* TODO: driver interface */
 /*------------------------*/
 extern int sa1101_probe(struct device *dev);
@@ -55,6 +46,15 @@
 #define SA1101_DEVID_PCMCIA	8
 #define SA1101_DEVID_KEYPAD	9
 
+struct sa1101_dev {
+	struct device	dev;
+	unsigned int	devid;
+	struct resource	res;
+	void		*mapbase;
+	unsigned int	skpcr_mask;
+	unsigned int	irq[6];
+};
+
 #define SA1101_DEV(_d)	container_of((_d), struct sa1101_dev, dev)
 
 #define sa1101_get_drvdata(d)	dev_get_drvdata(&(d)->dev)


More information about the Jornada820 mailing list