Driver model for sa1101
Matan Ziv-Av
matan@svgalib.org
Sat Jul 10 20:42:04 CEST 2004
OK, so I am talking to myself.
Here's a patch that also solves the interrupt problem. Still PCMCIA does
not work. Patch is relative to current CVS.
--
Matan Ziv-Av. matan@svgalib.org
-------------- next part --------------
diff -ubBr -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 21:29:47.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.10 2004/07/09 14:28:33 oleg820 Exp $
+ * $Id: sa1101.c,v 1.9 2004/07/07 17:26:18 oleg820 Exp $
*/
#include <linux/module.h>
@@ -32,7 +32,7 @@
#include <asm/arch/SA-1101.h>
#include <asm/hardware/sa1101.h>
#include <asm/mach/irq.h>
-#include <asm/arch/irq.h>
+#include <asm/arch/irqs.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -44,6 +44,146 @@
* anchor point for all the other drivers.
*/
+static int sa1101_match(struct device *_dev, struct device_driver *_drv);
+static int sa1101_bus_suspend(struct device *dev, u32 state);
+static int sa1101_bus_resume(struct device *dev);
+
+struct bus_type sa1101_bus_type = {
+ .name = "sa1101-bus",
+ .match = sa1101_match,
+ .suspend = sa1101_bus_suspend,
+ .resume = sa1101_bus_resume,
+};
+
+struct sa1101_dev_info {
+ unsigned long offset;
+ unsigned long skpcr_mask;
+ unsigned int devid;
+ unsigned int irq[6];
+};
+
+static struct sa1101_dev_info sa1101_devices[] = {
+ {
+ .offset = SA1101_USB,
+ .skpcr_mask = SKPCR_UCLKEn,
+ .devid = SA1101_DEVID_USB,
+ .irq = {
+ IRQ_USBPWR,
+ IRQ_HCIM,
+ IRQ_HCIBUFFACC,
+ IRQ_HCIRMTWKP,
+ IRQ_NHCIMFCIR,
+ IRQ_USB_PORT_RESUME
+ },
+ },
+#if 0
+ {
+ .offset = 0x0600,
+ .skpcr_mask = SKPCR_I2SCLKEN | SKPCR_L3CLKEN,
+ .devid = SA1111_DEVID_SAC,
+ .irq = {
+ AUDXMTDMADONEA,
+ AUDXMTDMADONEB,
+ AUDRCVDMADONEA,
+ AUDRCVDMADONEB
+ },
+ },
+ {
+ .offset = 0x0800,
+ .skpcr_mask = SKPCR_SCLKEN,
+ .devid = SA1111_DEVID_SSP,
+ },
+ {
+ .offset = SA1111_KBD,
+ .skpcr_mask = SKPCR_PTCLKEN,
+ .devid = SA1111_DEVID_PS2,
+ .irq = {
+ IRQ_TPRXINT,
+ IRQ_TPTXINT
+ },
+ },
+ {
+ .offset = SA1111_MSE,
+ .skpcr_mask = SKPCR_PMCLKEN,
+ .devid = SA1111_DEVID_PS2,
+ .irq = {
+ IRQ_MSRXINT,
+ IRQ_MSTXINT
+ },
+ },
+#endif
+ {
+ .offset = SA1101_PCMCIA,
+ .skpcr_mask = 0,
+ .devid = SA1101_DEVID_PCMCIA,
+ .irq = {
+ IRQ_S0_READY_NINT,
+ IRQ_S0_CD_VALID,
+ IRQ_S0_BVD1_STSCHG,
+ IRQ_S1_READY_NINT,
+ IRQ_S1_CD_VALID,
+ IRQ_S1_BVD1_STSCHG,
+ },
+ },
+};
+
+static void sa1101_dev_release(struct device *_dev)
+{
+ struct sa1101_dev *dev = SA1101_DEV(_dev);
+
+ release_resource(&dev->res);
+ kfree(dev);
+}
+
+static int
+sa1101_init_one_child(struct device *parent, struct resource *parent_res,
+ struct sa1101_dev_info *info)
+{
+ struct sa1101_dev *dev;
+ int ret;
+
+ dev = kmalloc(sizeof(struct sa1101_dev), GFP_KERNEL);
+ if (!dev) {
+ ret = -ENOMEM;
+ goto out;
+ }
+ memset(dev, 0, sizeof(struct sa1101_dev));
+
+ snprintf(dev->dev.bus_id, sizeof(dev->dev.bus_id),
+ "%4.4lx", info->offset);
+
+ dev->devid = info->devid;
+ dev->dev.parent = parent;
+ dev->dev.bus = &sa1101_bus_type;
+ dev->dev.release = sa1101_dev_release;
+ dev->dev.coherent_dma_mask = 0xffffffff;
+ dev->res.start = 0x18000000 + info->offset;
+ dev->res.end = dev->res.start + 0x1ffff;
+ dev->res.name = dev->dev.bus_id;
+ dev->res.flags = IORESOURCE_MEM;
+ dev->mapbase = (u8 *)0xf4000000 + info->offset;
+ dev->skpcr_mask = info->skpcr_mask;
+ memmove(dev->irq, info->irq, sizeof(dev->irq));
+#if 1
+ ret = request_resource(parent_res, &dev->res);
+ if (ret) {
+ printk("SA1101: failed to allocate resource for %s\n",
+ dev->res.name);
+ kfree(dev);
+ goto out;
+ }
+#endif
+ ret = device_register(&dev->dev);
+ if (ret) {
+ release_resource(&dev->res);
+ kfree(dev);
+ goto out;
+ }
+
+out:
+ return ret;
+}
+
static struct resource sa1101_resource = {
.name = "SA1101"
};
@@ -52,24 +192,24 @@
* Figure out whether we can see the SA1101
*/
-int __init sa1101_probe(unsigned long phys_addr)
+int sa1101_probe(struct device * _dev)
{
- int ret = -ENODEV;
+ struct platform_device *pdev = to_platform_device(_dev);
+ struct sa1101_dev *dev = SA1101_DEV(_dev);
+ /* should check */
+ int i;
+ u32 has_devs;
- sa1101_resource.start = phys_addr;
- sa1101_resource.end = phys_addr + 0x00400000;
+ sa1101_wake();
+ sa1101_init_irq(GPIO_JORNADA820_SA1101_CHAIN_IRQ);
- if (request_resource(&iomem_resource, &sa1101_resource)) {
- printk(KERN_INFO "Failed to map SA1101 chip.\n");
- ret = -EBUSY;
- goto out;
- }
+ has_devs = 0xffffffff;
- printk(KERN_INFO "SA1101 Microprocessor Companion Chip mapped.\n");
- ret=0;
+ for (i = 0; i < ARRAY_SIZE(sa1101_devices); i++)
+ if (has_devs & (1 << i))
+ sa1101_init_one_child(&dev->dev, &pdev->resource[0], &sa1101_devices[i]);
- out:
- return ret;
+ return 0;
}
/*
@@ -94,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) {
@@ -108,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);
@@ -116,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)
@@ -122,7 +269,6 @@
static void sa1101_ack_irq(unsigned int irq)
{
-// printk("Got SA1101 interrupt %d.\n", irq); // DEBUG
}
static void mask_low_irq(unsigned int irq)
@@ -251,10 +397,8 @@
{
unsigned int irq;
- // printk("initializing sa1101...\n"); // DEBUG
-
alloc_irq_space(64); /* XXX - still needed??? */
- request_mem_region(_INTTEST0, 512, "irqs"); // XXX - still needed???
+ request_mem_region(SA1101_INTERRUPT, 0x1ffff, "irqs-1101"); // XXX - still needed???
/* disable all IRQs */
INTENABLE0 = 0;
@@ -290,8 +434,10 @@
*/
// request_irq(sa1101_irq, debug_sa1101_irq_handler, SA_INTERRUPT,
// "SA1101 chain interrupt", NULL); // DEBUG
- set_irq_chained_handler(sa1101_irq, sa1101_irq_handler); // NORMAL
+
set_irq_type(sa1101_irq, IRQT_RISING);
+ set_irq_data(sa1101_irq, (void *)SA1101_INTERRUPT);
+ set_irq_chained_handler(sa1101_irq, sa1101_irq_handler); // NORMAL
}
extern void sa1101_wake(void)
@@ -373,13 +519,99 @@
/*********************************************************************************/
+EXPORT_SYMBOL_GPL(sa1101_wake);
+EXPORT_SYMBOL_GPL(sa1101_doze);
+EXPORT_SYMBOL_GPL(sa1101_usb_init);
+EXPORT_SYMBOL_GPL(sa1101_usb_shutdown);
+EXPORT_SYMBOL_GPL(sa1101_vga_init);
+EXPORT_SYMBOL_GPL(sa1101_vga_shutdown);
+
+#if 0
+EXPORT_SYMBOL_GPL(sa1101_enable_device);
+EXPORT_SYMBOL_GPL(sa1101_disable_device);
+EXPORT_SYMBOL_GPL(sa1101_pll_clock);
+#endif
+
+static int sa1101_match(struct device *_dev, struct device_driver *_drv)
+{
+ struct sa1101_dev *dev = SA1101_DEV(_dev);
+ struct sa1101_driver *drv = SA1101_DRV(_drv);
+
+ return dev->devid == drv->devid;
+}
+
+static int sa1101_bus_suspend(struct device *dev, u32 state)
+{
+ struct sa1101_dev *sadev = SA1101_DEV(dev);
+ struct sa1101_driver *drv = SA1101_DRV(dev->driver);
+ int ret = 0;
+
+ if (drv && drv->suspend)
+ ret = drv->suspend(sadev, state);
+ return ret;
+}
+
+static int sa1101_bus_resume(struct device *dev)
+{
+ struct sa1101_dev *sadev = SA1101_DEV(dev);
+ struct sa1101_driver *drv = SA1101_DRV(dev->driver);
+ int ret = 0;
+
+ if (drv && drv->resume)
+ ret = drv->resume(sadev);
+ return ret;
+}
+
+static int sa1101_bus_probe(struct device *dev)
+{
+ struct sa1101_dev *sadev = SA1101_DEV(dev);
+ struct sa1101_driver *drv = SA1101_DRV(dev->driver);
+ int ret = -ENODEV;
+
+ if (drv->probe)
+ ret = drv->probe(sadev);
+ return ret;
+}
+
+static int sa1101_bus_remove(struct device *dev)
+{
+ struct sa1101_dev *sadev = SA1101_DEV(dev);
+ struct sa1101_driver *drv = SA1101_DRV(dev->driver);
+ int ret = -ENODEV;
+
+ if (drv->remove)
+ ret = drv->remove(sadev);
+ return ret;
+}
+
+static int sa1101_suspend(struct device *dev, u32 state, u32 level) {
+ return 0;
+}
+
+static int sa1101_resume(struct device *dev, u32 level) {
+ return 0;
+}
+
+static int sa1101_remove(struct device *dev)
+{
+ return 0;
+}
+
+static struct device_driver sa1101_device_driver = {
+ .name = "sa1101-bus",
+ .bus = &platform_bus_type,
+ .probe = sa1101_probe,
+ .remove = sa1101_remove,
+ .suspend = sa1101_suspend,
+ .resume = sa1101_resume,
+};
+
int sa1101_driver_register(struct sa1101_driver *driver)
{
-// WARN_ON(driver->drv.suspend || driver->drv.resume || driver->drv.probe || driver->drv.remove);
-// driver->drv.probe = sa1101_bus_probe;
-// driver->drv.remove = sa1101_bus_remove;
-// driver->drv.bus = &sa1101_bus_type;
- printk("registering sa1101 driver %s\n",driver->drv.name);
+ WARN_ON(driver->drv.suspend || driver->drv.resume || driver->drv.probe || driver->drv.remove);
+ driver->drv.probe = sa1101_bus_probe;
+ driver->drv.remove = sa1101_bus_remove;
+ driver->drv.bus = &sa1101_bus_type;
return driver_register(&driver->drv);
}
@@ -388,24 +620,26 @@
driver_unregister(&driver->drv);
}
+static int __init sa1101_init(void)
+{
+ int ret = bus_register(&sa1101_bus_type);
-EXPORT_SYMBOL_GPL(sa1101_wake);
-EXPORT_SYMBOL_GPL(sa1101_doze);
-EXPORT_SYMBOL_GPL(sa1101_usb_init);
-EXPORT_SYMBOL_GPL(sa1101_usb_shutdown);
-EXPORT_SYMBOL_GPL(sa1101_vga_init);
-EXPORT_SYMBOL_GPL(sa1101_vga_shutdown);
+ if (ret == 0)
+ driver_register(&sa1101_device_driver);
+ return ret;
+}
-#if 0
-EXPORT_SYMBOL_GPL(sa1101_enable_device);
-EXPORT_SYMBOL_GPL(sa1101_disable_device);
-EXPORT_SYMBOL_GPL(sa1101_pll_clock);
-EXPORT_SYMBOL_GPL(sa1101_driver_register);
-EXPORT_SYMBOL_GPL(sa1101_driver_unregister);
+static void __exit sa1101_exit(void)
+{
+ driver_unregister(&sa1101_device_driver);
+ bus_unregister(&sa1101_bus_type);
+}
module_init(sa1101_init);
module_exit(sa1101_exit);
-#endif
+
+EXPORT_SYMBOL_GPL(sa1101_driver_register);
+EXPORT_SYMBOL_GPL(sa1101_driver_unregister);
MODULE_DESCRIPTION("Main driver for SA-1101 companion chip.");
MODULE_LICENSE("GPL");
diff -ubBr -x j820_keyb.c -x 'regs-*' -x Kconfig -x CVS kernel26/arch/arm/mach-sa1100/jornada820.c my2/arch/arm/mach-sa1100/jornada820.c
--- kernel26/arch/arm/mach-sa1100/jornada820.c 2004-07-08 19:21:17.000000000 +0300
+++ my2/arch/arm/mach-sa1100/jornada820.c 2004-07-10 20:18:35.000000000 +0300
@@ -16,8 +16,37 @@
#include <asm/irq.h>
#include <asm/hardware.h>
#include <asm/delay.h>
+#include <linux/device.h>
#include "generic.h"
+
+static struct resource sa1101_resources[] = {
+ [0] = {
+ .start = 0x18000000,
+ .end = 0x1bffffff,
+ .flags = IORESOURCE_MEM,
+ },
+/*
+ [1] = {
+ .start = ,
+ .end = IRQ_NEPONSET_SA1111,
+ .flags = IORESOURCE_IRQ,
+ },
+*/
+};
+
+static struct platform_device sa1101_device = {
+ .name = "sa1101-bus",
+ .id = 0,
+ .num_resources = ARRAY_SIZE(sa1101_resources),
+ .resource = sa1101_resources,
+};
+
+static struct platform_device *devices[] __initdata = {
+ &sa1101_device,
+};
+
+
/* *********************************************************************** */
/* Initialize the Jornada 820. */
/* *********************************************************************** */
@@ -58,9 +87,13 @@
/* TODO: remove. */
/* Initialize the 1101. */
- sa1101_probe(SA1101_BASE);
- sa1101_wake();
- sa1101_init_irq(GPIO_JORNADA820_SA1101_CHAIN_IRQ);
+// sa1101_probe(SA1101_BASE);
+// sa1101_wake();
+// sa1101_init_irq(GPIO_JORNADA820_SA1101_CHAIN_IRQ);
+
+
+ return platform_add_devices(devices, ARRAY_SIZE(devices));
+
return 0;
}
diff -ubBr -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 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 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 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-06-30 23:29:48.000000000 +0300
+++ my2/include/asm-arm/arch-sa1100/SA-1101.h 2004-07-10 18:45:20.000000000 +0300
@@ -7,9 +7,7 @@
* support chip for the sa1100
*
*/
-/* Jornada820 version based on SA-1101.h 1.1.1.1 from cvs.handhelds.org
- * $Id: SA-1101.h,v 1.3 2004/06/30 20:29:48 fare Exp $
- */
+
/* Be sure that virtual mapping is defined right */
#ifndef __ASM_ARCH_HARDWARE_H
@@ -28,14 +26,6 @@
# endif
#endif
-/*
- * We have mapped the sa1101 depending on the value of SA1101_BASE.
- * It then appears from 0xf4000000.
- */
-
-#define SA1101_p2v( x ) ((x) - SA1101_BASE + 0xf4000000)
-#define SA1101_v2p( x ) ((x) - 0xf4000000 + SA1101_BASE)
-
#ifndef SA1101_p2v
#define SA1101_p2v(PhAdd) (PhAdd)
#endif
@@ -68,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
*/
@@ -634,72 +628,173 @@
/*
* PS/2 Trackpad and Mouse Interfaces
*
- * Registers
- * PS2CR Control Register
- * PS2STAT Status Register
- * PS2DATA Transmit/Receive Data register
- * PS2CLKDIV Clock Division Register
- * PS2PRECNT Clock Precount Register
- * PS2TEST1 Test register 1
- * PS2TEST2 Test register 2
- * PS2TEST3 Test register 3
- * PS2TEST4 Test register 4
+ * Registers (prefix kbd applies to trackpad interface, mse to mouse)
+ * KBDCR Control Register
+ * KBDSTAT Status Register
+ * KBDDATA Transmit/Receive Data register
+ * KBDCLKDIV Clock Division Register
+ * KBDPRECNT Clock Precount Register
+ * KBDTEST1 Test register 1
+ * KBDTEST2 Test register 2
+ * KBDTEST3 Test register 3
+ * KBDTEST4 Test register 4
+ * MSECR
+ * MSESTAT
+ * MSEDATA
+ * MSECLKDIV
+ * MSEPRECNT
+ * MSETEST1
+ * MSETEST2
+ * MSETEST3
+ * MSETEST4
+ *
*/
-/*
- * These are offsets from the above bases.
- * e.g. __MOUSE_INTERFACE + SA1101_PS2CR
- */
+#define _KBD( x ) _SA1101( ( x ) + __TRACK_INTERFACE )
+#define _MSE( x ) _SA1101( ( x ) + __MOUSE_INTERFACE )
+
+#define _KBDCR _KBD( 0x0000 )
+#define _KBDSTAT _KBD( 0x0400 )
+#define _KBDDATA _KBD( 0x0800 )
+#define _KBDCLKDIV _KBD( 0x0c00 )
+#define _KBDPRECNT _KBD( 0x1000 )
+#define _KBDTEST1 _KBD( 0x2000 )
+#define _KBDTEST2 _KBD( 0x2400 )
+#define _KBDTEST3 _KBD( 0x2800 )
+#define _KBDTEST4 _KBD( 0x2c00 )
+#define _MSECR _MSE( 0x0000 )
+#define _MSESTAT _MSE( 0x0400 )
+#define _MSEDATA _MSE( 0x0800 )
+#define _MSECLKDIV _MSE( 0x0c00 )
+#define _MSEPRECNT _MSE( 0x1000 )
+#define _MSETEST1 _MSE( 0x2000 )
+#define _MSETEST2 _MSE( 0x2400 )
+#define _MSETEST3 _MSE( 0x2800 )
+#define _MSETEST4 _MSE( 0x2c00 )
+
+#if ( LANGUAGE == C )
+
+#define KBDCR (*((volatile Word *) SA1101_p2v (_KBDCR)))
+#define KBDSTAT (*((volatile Word *) SA1101_p2v (_KBDSTAT)))
+#define KBDDATA (*((volatile Word *) SA1101_p2v (_KBDDATA)))
+#define KBDCLKDIV (*((volatile Word *) SA1101_p2v (_KBDCLKDIV)))
+#define KBDPRECNT (*((volatile Word *) SA1101_p2v (_KBDPRECNT)))
+#define KBDTEST1 (*((volatile Word *) SA1101_p2v (_KBDTEST1)))
+#define KBDTEST2 (*((volatile Word *) SA1101_p2v (_KBDTEST2)))
+#define KBDTEST3 (*((volatile Word *) SA1101_p2v (_KBDTEST3)))
+#define KBDTEST4 (*((volatile Word *) SA1101_p2v (_KBDTEST4)))
+#define MSECR (*((volatile Word *) SA1101_p2v (_MSECR)))
+#define MSESTAT (*((volatile Word *) SA1101_p2v (_MSESTAT)))
+#define MSEDATA (*((volatile Word *) SA1101_p2v (_MSEDATA)))
+#define MSECLKDIV (*((volatile Word *) SA1101_p2v (_MSECLKDIV)))
+#define MSEPRECNT (*((volatile Word *) SA1101_p2v (_MSEPRECNT)))
+#define MSETEST1 (*((volatile Word *) SA1101_p2v (_MSETEST1)))
+#define MSETEST2 (*((volatile Word *) SA1101_p2v (_MSETEST2)))
+#define MSETEST3 (*((volatile Word *) SA1101_p2v (_MSETEST3)))
+#define MSETEST4 (*((volatile Word *) SA1101_p2v (_MSETEST4)))
+
+
+#define KBDCR_ENA 0x08
+#define KBDCR_FKD 0x02
+#define KBDCR_FKC 0x01
+
+#define KBDSTAT_TXE 0x80
+#define KBDSTAT_TXB 0x40
+#define KBDSTAT_RXF 0x20
+#define KBDSTAT_RXB 0x10
+#define KBDSTAT_ENA 0x08
+#define KBDSTAT_RXP 0x04
+#define KBDSTAT_KBD 0x02
+#define KBDSTAT_KBC 0x01
+
+#define KBDCLKDIV_DivVal Fld(4,0)
+
+#define MSECR_ENA 0x08
+#define MSECR_FKD 0x02
+#define MSECR_FKC 0x01
+
+#define MSESTAT_TXE 0x80
+#define MSESTAT_TXB 0x40
+#define MSESTAT_RXF 0x20
+#define MSESTAT_RXB 0x10
+#define MSESTAT_ENA 0x08
+#define MSESTAT_RXP 0x04
+#define MSESTAT_MSD 0x02
+#define MSESTAT_MSC 0x01
+
+#define MSECLKDIV_DivVal Fld(4,0)
+
+#define KBDTEST1_CD 0x80
+#define KBDTEST1_RC1 0x40
+#define KBDTEST1_MC 0x20
+#define KBDTEST1_C Fld(2,3)
+#define KBDTEST1_T2 0x40
+#define KBDTEST1_T1 0x20
+#define KBDTEST1_T0 0x10
+#define KBDTEST2_TICBnRES 0x08
+#define KBDTEST2_RKC 0x04
+#define KBDTEST2_RKD 0x02
+#define KBDTEST2_SEL 0x01
+#define KBDTEST3_ms_16 0x80
+#define KBDTEST3_us_64 0x40
+#define KBDTEST3_us_16 0x20
+#define KBDTEST3_DIV8 0x10
+#define KBDTEST3_DIn 0x08
+#define KBDTEST3_CIn 0x04
+#define KBDTEST3_KD 0x02
+#define KBDTEST3_KC 0x01
+#define KBDTEST4_BC12 0x80
+#define KBDTEST4_BC11 0x40
+#define KBDTEST4_TRES 0x20
+#define KBDTEST4_CLKOE 0x10
+#define KBDTEST4_CRES 0x08
+#define KBDTEST4_RXB 0x04
+#define KBDTEST4_TXB 0x02
+#define KBDTEST4_SRX 0x01
+
+#define MSETEST1_CD 0x80
+#define MSETEST1_RC1 0x40
+#define MSETEST1_MC 0x20
+#define MSETEST1_C Fld(2,3)
+#define MSETEST1_T2 0x40
+#define MSETEST1_T1 0x20
+#define MSETEST1_T0 0x10
+#define MSETEST2_TICBnRES 0x08
+#define MSETEST2_RKC 0x04
+#define MSETEST2_RKD 0x02
+#define MSETEST2_SEL 0x01
+#define MSETEST3_ms_16 0x80
+#define MSETEST3_us_64 0x40
+#define MSETEST3_us_16 0x20
+#define MSETEST3_DIV8 0x10
+#define MSETEST3_DIn 0x08
+#define MSETEST3_CIn 0x04
+#define MSETEST3_KD 0x02
+#define MSETEST3_KC 0x01
+#define MSETEST4_BC12 0x80
+#define MSETEST4_BC11 0x40
+#define MSETEST4_TRES 0x20
+#define MSETEST4_CLKOE 0x10
+#define MSETEST4_CRES 0x08
+#define MSETEST4_RXB 0x04
+#define MSETEST4_TXB 0x02
+#define MSETEST4_SRX 0x01
+
+/* For sa1111ps2: */
#define SA1101_PS2CR 0x000000
#define SA1101_PS2STAT 0x000400
#define SA1101_PS2DATA 0x000800
#define SA1101_PS2CLKDIV 0x000c00
#define SA1101_PS2PRECNT 0x001000
-#if ( LANGUAGE == C )
-
-#define PS2CR_ENA 0x08
-#define PS2CR_FKD 0x02
-#define PS2CR_FKC 0x01
-
-#define PS2STAT_TXE 0x80
-#define PS2STAT_TXB 0x40
-#define PS2STAT_RXF 0x20
-#define PS2STAT_RXB 0x10
-#define PS2STAT_ENA 0x08
-#define PS2STAT_RXP 0x04
-#define PS2STAT_KBD 0x02
-#define PS2STAT_KBC 0x01
-
-#define PS2CLKDIV_DivVal Fld(4,0)
-
-#define PS2TEST1_CD 0x80
-#define PS2TEST1_RC1 0x40
-#define PS2TEST1_MC 0x20
-#define PS2TEST1_C Fld(2,3)
-#define PS2TEST1_T2 0x40
-#define PS2TEST1_T1 0x20
-#define PS2TEST1_T0 0x10
-#define PS2TEST2_TICBnRES 0x08
-#define PS2TEST2_RKC 0x04
-#define PS2TEST2_RKD 0x02
-#define PS2TEST2_SEL 0x01
-#define PS2TEST3_ms_16 0x80
-#define PS2TEST3_us_64 0x40
-#define PS2TEST3_us_16 0x20
-#define PS2TEST3_DIV8 0x10
-#define PS2TEST3_DIn 0x08
-#define PS2TEST3_CIn 0x04
-#define PS2TEST3_KD 0x02
-#define PS2TEST3_KC 0x01
-#define PS2TEST4_BC12 0x80
-#define PS2TEST4_BC11 0x40
-#define PS2TEST4_TRES 0x20
-#define PS2TEST4_CLKOE 0x10
-#define PS2TEST4_CRES 0x08
-#define PS2TEST4_RXB 0x04
-#define PS2TEST4_TXB 0x02
-#define PS2TEST4_SRX 0x01
+#define PS2STAT_RXF KBDSTAT_RXF
+#define PS2STAT_RXP KBDSTAT_RXP
+#define PS2STAT_TXE KBDSTAT_TXE
+#define PS2STAT_KBC KBDSTAT_KBC
+#define PS2STAT_KBD KBDSTAT_KBD
+#define PS2CR_ENA KBDCR_ENA
+#define PS2CR_FKC KBDCR_FKC
+#define PS2CR_FKD KBDCR_FKD
#endif /* LANGUAGE == C */
@@ -708,11 +803,11 @@
* General-Purpose I/O Interface
*
* Registers
- * PS2WR Port A Data Write Register
+ * PADWR Port A Data Write Register
* PBDWR Port B Data Write Register
- * PS2RR Port A Data Read Register
+ * PADRR Port A Data Read Register
* PBDRR Port B Data Read Register
- * PS2DR Port A Data Direction Register
+ * PADDR Port A Data Direction Register
* PBDDR Port B Data Direction Register
* PASSR Port A Sleep State Register
* PBSSR Port B Sleep State Register
@@ -721,11 +816,11 @@
#define _PIO( x ) _SA1101( ( x ) + __GPIO_INTERFACE )
-#define _PS2WR _PIO( 0x0000 )
+#define _PADWR _PIO( 0x0000 )
#define _PBDWR _PIO( 0x0400 )
-#define _PS2RR _PIO( 0x0000 )
+#define _PADRR _PIO( 0x0000 )
#define _PBDRR _PIO( 0x0400 )
-#define _PS2DR _PIO( 0x0800 )
+#define _PADDR _PIO( 0x0800 )
#define _PBDDR _PIO( 0x0c00 )
#define _PASSR _PIO( 0x1000 )
#define _PBSSR _PIO( 0x1400 )
@@ -733,11 +828,12 @@
#if ( LANGUAGE == C )
-#define PS2WR (*((volatile Word *) SA1101_p2v (_PS2WR)))
+
+#define PADWR (*((volatile Word *) SA1101_p2v (_PADWR)))
#define PBDWR (*((volatile Word *) SA1101_p2v (_PBDWR)))
-#define PS2RR (*((volatile Word *) SA1101_p2v (_PS2RR)))
+#define PADRR (*((volatile Word *) SA1101_p2v (_PADRR)))
#define PBDRR (*((volatile Word *) SA1101_p2v (_PBDRR)))
-#define PS2DR (*((volatile Word *) SA1101_p2v (_PS2DR)))
+#define PADDR (*((volatile Word *) SA1101_p2v (_PADDR)))
#define PBDDR (*((volatile Word *) SA1101_p2v (_PBDDR)))
#define PASSR (*((volatile Word *) SA1101_p2v (_PASSR)))
#define PBSSR (*((volatile Word *) SA1101_p2v (_PBSSR)))
@@ -788,9 +884,9 @@
#define _CARD( x ) _SA1101( ( x ) + __PCMCIA_INTERFACE )
-#define _PCSR _CARD( 0x0000 )
-#define _PCCR _CARD( 0x0400 )
-#define _PCSSR _CARD( 0x0800 )
+#define _PCCR _CARD( 0x0000 )
+#define _PCSSR _CARD( 0x0400 )
+#define _PCSR _CARD( 0x0800 )
#if ( LANGUAGE == C )
#define PCSR (*((volatile Word *) SA1101_p2v (_PCSR)))
diff -ubBr -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-08 13:02:59.000000000 +0300
+++ my2/include/asm-arm/hardware/sa1101.h 2004-07-10 21:38:19.000000000 +0300
@@ -14,7 +14,7 @@
/* TODO: driver interface */
/*------------------------*/
-extern int sa1101_probe(unsigned long phys_addr);
+extern int sa1101_probe(struct device *dev);
extern void sa1101_wake(void);
extern void sa1101_doze(void);
@@ -53,7 +53,6 @@
void *mapbase;
unsigned int skpcr_mask;
unsigned int irq[6];
- u64 dma_mask;
};
#define SA1101_DEV(_d) container_of((_d), struct sa1101_dev, dev)
More information about the Jornada820
mailing list