diff -Nur sharp-a300-linux-1_10/arch/arm/config.in sharp-a300-linux-1_20/arch/arm/config.in
--- sharp-a300-linux-1_10/arch/arm/config.in	Fri Jul 12 10:51:12 2002
+++ sharp-a300-linux-1_20/arch/arm/config.in	Fri Nov 15 13:27:18 2002
@@ -553,6 +553,12 @@
 if [ "$CONFIG_DEVICEINFO" = "m" -a "$CONFIG_SABINAL_DISCOVERY" = "y" ]; then
    define_tristate CONFIG_DISCOVERY_DEVICEINFO m
 fi
+if [ "$CONFIG_SABINAL_DISCOVERY" = "y" ]; then
+   dep_bool 'Set APD while idle' CONFIG_DISCOVERY_SET_APD_ON_IDLE $CONFIG_SABINAL_DISCOVERY
+fi
+if [ "$CONFIG_APM_CPU_IDLE" = "y" -a "$CONFIG_SABINAL_DISCOVERY" = "y" ]; then
+   dep_bool 'Use kernel PM idle' CONFIG_DISCOVERY_PM_IDLE $CONFIG_APM_CPU_IDLE
+fi
 endmenu
 
 source drivers/parport/Config.in
diff -Nur sharp-a300-linux-1_10/arch/arm/def-configs/discovery-DVT sharp-a300-linux-1_20/arch/arm/def-configs/discovery-DVT
--- sharp-a300-linux-1_10/arch/arm/def-configs/discovery-DVT	Tue Jul 16 21:16:51 2002
+++ sharp-a300-linux-1_20/arch/arm/def-configs/discovery-DVT	Wed Nov 27 15:40:35 2002
@@ -185,6 +185,8 @@
 CONFIG_OOM_KILL_SURVIVAL=y
 CONFIG_DEVICEINFO=m
 CONFIG_DISCOVERY_DEVICEINFO=m
+CONFIG_DISCOVERY_SET_APD_ON_IDLE=y
+CONFIG_DISCOVERY_PM_IDLE=y
 
 #
 # Parallel port support
@@ -605,7 +607,6 @@
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
 CONFIG_COTULLA_RTC=y
-# CONFIG_COTULLA_TS is not set
 CONFIG_ADS7846_TS=y
 CONFIG_LED=y
 # CONFIG_DTLK is not set
@@ -784,6 +785,7 @@
 # CONFIG_FB_ANAKIN is not set
 # CONFIG_FB_CLPS711X is not set
 # CONFIG_FB_SA1100 is not set
+CONFIG_DISCOVERY_CONSISTENT_ALLOC=y
 # CONFIG_FB_CYBER2000 is not set
 CONFIG_FB_COTULLA=y
 CONFIG_COTULLA_LOGO_SCREEN=y
diff -Nur sharp-a300-linux-1_10/arch/arm/def-configs/discovery-MV sharp-a300-linux-1_20/arch/arm/def-configs/discovery-MV
--- sharp-a300-linux-1_10/arch/arm/def-configs/discovery-MV	Tue Jul 16 21:16:51 2002
+++ sharp-a300-linux-1_20/arch/arm/def-configs/discovery-MV	Fri Nov 15 13:27:18 2002
@@ -185,6 +185,8 @@
 CONFIG_OOM_KILL_SURVIVAL=y
 CONFIG_DEVICEINFO=m
 CONFIG_DISCOVERY_DEVICEINFO=m
+CONFIG_DISCOVERY_SET_APD_ON_IDLE=y
+CONFIG_DISCOVERY_PM_IDLE=y
 
 #
 # Parallel port support
@@ -605,7 +607,6 @@
 # CONFIG_NVRAM is not set
 # CONFIG_RTC is not set
 CONFIG_COTULLA_RTC=y
-# CONFIG_COTULLA_TS is not set
 CONFIG_ADS7846_TS=y
 CONFIG_LED=y
 # CONFIG_DTLK is not set
@@ -784,6 +785,7 @@
 # CONFIG_FB_ANAKIN is not set
 # CONFIG_FB_CLPS711X is not set
 # CONFIG_FB_SA1100 is not set
+CONFIG_DISCOVERY_CONSISTENT_ALLOC=y
 # CONFIG_FB_CYBER2000 is not set
 CONFIG_FB_COTULLA=y
 CONFIG_COTULLA_LOGO_SCREEN=y
diff -Nur sharp-a300-linux-1_10/arch/arm/kernel/process.c sharp-a300-linux-1_20/arch/arm/kernel/process.c
--- sharp-a300-linux-1_10/arch/arm/kernel/process.c	Thu Jun 27 20:35:52 2002
+++ sharp-a300-linux-1_20/arch/arm/kernel/process.c	Fri Nov 15 13:27:18 2002
@@ -47,6 +47,13 @@
 
 #include <asm/arch/system.h>
 
+#if defined(CONFIG_APM_CPU_IDLE) && defined(CONFIG_DISCOVERY_PM_IDLE)
+int get_hlt_counter(void)
+{
+	return hlt_counter;
+}
+#endif
+
 void disable_hlt(void)
 {
 	hlt_counter++;
@@ -89,6 +96,11 @@
 	init_idle();
 	current->nice = 20;
 	current->counter = -100;
+#if defined(CONFIG_APM_CPU_IDLE) && \
+    defined(CONFIG_DISCOVERY_PM_IDLE) && \
+    defined(CONFIG_OOM_KILL_SURVIVAL)
+	current->oom_kill_survival_level = 1;
+#endif
 
 	while (1) {
 		void (*idle)(void) = pm_idle;
diff -Nur sharp-a300-linux-1_10/arch/arm/mach-cotulla/discovery_apm.c sharp-a300-linux-1_20/arch/arm/mach-cotulla/discovery_apm.c
--- sharp-a300-linux-1_10/arch/arm/mach-cotulla/discovery_apm.c	Tue Sep  3 11:08:05 2002
+++ sharp-a300-linux-1_20/arch/arm/mach-cotulla/discovery_apm.c	Fri Dec  6 12:47:55 2002
@@ -1173,7 +1173,7 @@
 		 */
 		set_current_state(TASK_INTERRUPTIBLE);
 		apm_event_handler();
-#ifdef CONFIG_APM_CPU_IDLE
+#if defined(CONFIG_APM_CPU_IDLE) && !defined(CONFIG_DISCOVERY_PM_IDLE)
 		if (!system_idle())
 			continue;
 
@@ -1195,6 +1195,23 @@
 	remove_wait_queue(&apm_waitqueue, &wait);
 }
 
+#if defined(CONFIG_APM_CPU_IDLE) && defined(CONFIG_DISCOVERY_PM_IDLE)
+/* This is the idle process executed by
+ * arch/arm/kernel/process.c:cpu_idle().
+ */
+static void apm_idle(void)
+{
+	extern int get_hlt_counter(void);
+
+	if (get_hlt_counter())
+		return;
+	if (idleCancel)
+		return;
+
+	cpu_xscale_do_idle(0);
+}
+#endif
+
 static int check_apm_user(struct apm_user *as, const char *func)
 {
 	if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) {
@@ -1665,9 +1682,13 @@
 static int discovery_key_check(void *unused)
 {
 
+    daemonize();
+    strcpy(current->comm, "kkeychkd");
+    sigfillset(&current->blocked);
+
     while(1) {
 
-      sleep_on(&fl_key);
+      interruptible_sleep_on(&fl_key);
 
       while(1) {
           interruptible_sleep_on_timeout((wait_queue_head_t*)&queue, KEY_TICK );
@@ -1718,7 +1739,11 @@
 	atomic_inc(&current->files->count);
 	daemonize();
 	
+#if defined(CONFIG_APM_CPU_IDLE) && !defined(CONFIG_DISCOVERY_PM_IDLE)
 	strcpy(current->comm, "kapm-idled");
+#else
+	strcpy(current->comm, "kapm");
+#endif
 	sigfillset(&current->blocked);
 	current->tty = NULL;	/* get rid of controlling tty */
 
@@ -1817,6 +1842,10 @@
 };
 
 
+#if defined(CONFIG_APM_CPU_IDLE) && defined(CONFIG_DISCOVERY_PM_IDLE)
+extern void (*pm_idle)(void);
+void (*pm_idle_save)(void);
+#endif
 /*
  * Just start the APM thread. We do NOT want to do APM BIOS
  * calls from anything but the APM thread, if for no other reason
@@ -1914,12 +1943,21 @@
 
 	misc_register(&apm_device);
 
+#if defined(CONFIG_APM_CPU_IDLE) && defined(CONFIG_DISCOVERY_PM_IDLE)
+	pm_idle_save = pm_idle;
+	pm_idle = apm_idle;
+#endif
+
 	return 0;
 }
 
 static void __exit apm_exit(void)
 {
 	int	error;
+
+#if defined(CONFIG_APM_CPU_IDLE) && defined(CONFIG_DISCOVERY_PM_IDLE)
+	pm_idle = pm_idle_save;
+#endif
 
 	if (((apm_info.bios.flags & APM_BIOS_DISENGAGED) == 0)
 	    && (apm_info.connection_version > 0x0100)) {
diff -Nur sharp-a300-linux-1_10/arch/arm/mach-cotulla/discovery_battery.c sharp-a300-linux-1_20/arch/arm/mach-cotulla/discovery_battery.c
--- sharp-a300-linux-1_10/arch/arm/mach-cotulla/discovery_battery.c	Tue Sep  3 11:08:06 2002
+++ sharp-a300-linux-1_20/arch/arm/mach-cotulla/discovery_battery.c	Fri Dec  6 12:47:55 2002
@@ -456,6 +456,10 @@
 
 static void discovery_minute(void)
 {
+	daemonize();
+	strcpy(current->comm, "kminuted");
+	//sigfillset(&current->blocked);
+
 	while(1)
 	{
 		interruptible_sleep_on_timeout((wait_queue_head_t*)&minute_cnt, DISCOVERY_MINUTE_TICKTIME );
@@ -533,6 +537,10 @@
 	unsigned long	Voltage, Imin, Temper;
 	unsigned long	period;
 	
+	//daemonize();
+	strcpy(current->comm, "kbattd");
+	//sigfillset(&current->blocked);
+
 	while(1) 
 	{
 		short		dTx,nowTx=0,Pd_k; /* maybe negative */
@@ -1358,8 +1366,11 @@
 
 static int backpack_detect_check(void *unused)
 {
+	daemonize();
+	strcpy(current->comm, "kbpchkd");
+	sigfillset(&current->blocked);
 	while(1){
-		sleep_on(&bp_detect);
+		interruptible_sleep_on(&bp_detect);
 		if (need_delay)
 			mdelay(500);
 
diff -Nur sharp-a300-linux-1_10/arch/arm/mm/proc-xscale.S sharp-a300-linux-1_20/arch/arm/mm/proc-xscale.S
--- sharp-a300-linux-1_10/arch/arm/mm/proc-xscale.S	Mon Aug  5 10:24:20 2002
+++ sharp-a300-linux-1_20/arch/arm/mm/proc-xscale.S	Tue Nov 26 18:29:33 2002
@@ -299,11 +299,26 @@
  * XScale supports clock switching, but using idle mode support
  * allows external hardware to react to system state changes.
  */
+#ifdef CONFIG_DISCOVERY_SET_APD_ON_IDLE
+_MDREFR:	.long	0xfd000004		@ 0x48000004
+#endif
 	.align	5
 
 ENTRY(cpu_xscale_do_idle)
+#ifdef CONFIG_DISCOVERY_SET_APD_ON_IDLE
+	ldr	r0, _MDREFR
+	ldr	r1, [r0]
+	orr	r1, r1, #0x00100000		@ MDREFR_APD
+	str	r1, [r0]
+#endif
 	mov	r0, #1
 	mcr	p14, 0, r0, c7, c0, 0		@ Go to IDLE
+#ifdef CONFIG_DISCOVERY_SET_APD_ON_IDLE
+	ldr	r0, _MDREFR
+	ldr	r1, [r0]
+	bic	r1, r1, #0x00100000		@ MDREFR_APD
+	str	r1, [r0]
+#endif
 	mov	pc, lr
 
 /* ================================= CACHE ================================ */
diff -Nur sharp-a300-linux-1_10/drivers/sound/discovery_audio.c sharp-a300-linux-1_20/drivers/sound/discovery_audio.c
--- sharp-a300-linux-1_10/drivers/sound/discovery_audio.c	Thu Sep  5 10:35:11 2002
+++ sharp-a300-linux-1_20/drivers/sound/discovery_audio.c	Thu Dec  5 10:03:27 2002
@@ -210,7 +210,7 @@
 #define WAKE_UP(queue)  (wake_up_interruptible((wait_queue_head_t*)&queue))
 #endif
 
-#define TRACE 1
+#define TRACE 0
 #if TRACE
 #define TRACE_ON    1
 #define TRACE_SEM   0
@@ -472,7 +472,6 @@
 	0xFF,			// -maxdB			//0x3F,			// -maxdB		0x00000000
 };
     
-    
 static inline void ResetDelayAll(void)
 {   
     DelayedFlag = 0;
@@ -822,6 +821,31 @@
  * ++geert: split in even more functions (one per format)
  */
 
+
+static ssize_t discovery_ct_law(const u_char *userPtr, size_t userCount,
+			     u_char frame[], ssize_t *frameUsed,
+			     ssize_t frameLeft)
+{
+	short *table = (sound.soft.format == AFMT_MU_LAW) ? ulaw2dma16: alaw2dma16;
+	ssize_t count, used;
+	short *p = (short *) &frame[*frameUsed];
+	short val;
+	u_char data;
+
+	used = count = userCount;
+	while (count > 0) {
+	  if (get_user(data, userPtr++)) {
+	    return -EFAULT;
+	  }
+	  val = table[data];
+	  *p++ = val;		/* Left Ch. */
+	  *p++ = val;		/* Right Ch. */
+	  count--;
+	}
+	*frameUsed += used * 4;
+	return used;
+}
+
 static ssize_t collie_ct_law(const u_char *userPtr, size_t userCount,
                  u_char frame[], ssize_t *frameUsed,
                  ssize_t frameLeft)
@@ -2705,16 +2729,28 @@
         	//printk("b->size: %x\n",b->size);
 		dest = b->start + b->size;
 		bLeft =  s->fragsize >>2;
-		if ( uLeft < bLeft ) 	bLeft = uLeft;
 		//printk("bLeft: %x\n",bLeft);
-
-		if (copy_from_user(dest, src, bLeft)) {
+		
+		if (sound.soft.format==AFMT_MU_LAW || 
+		    sound.soft.format==AFMT_A_LAW) {
+		    if ( uLeft*4 < bLeft ) bLeft = uLeft*4;
+		    uUsed = bLeft >>2;
+		    bUsed=0;
+		    if (discovery_ct_law(src, uUsed, dest,&bUsed,uUsed)<0) {
+			up(&b->sem);
+			return -EFAULT;
+		    }
+		} else {
+		    if ( uLeft < bLeft ) bLeft = uLeft;
+		    uUsed = bLeft;
+		    if (copy_from_user(dest, src, bLeft)) {
 			up(&b->sem);
 			return -EFAULT;
+		    }
 		}
 
-		src +=  bLeft;
-		uLeft -= bLeft;
+		src +=  uUsed;
+		uLeft -= uUsed;
         cotulla_dma_queue_buffer(COTULLA_SOUND_DMA_CHANNEL,(void *) b, b->dma_addr, bLeft);
 
         NEXT_BUF(s, buf);
@@ -2828,15 +2864,16 @@
         sound.hard = sound.dsp;
         
 	cotulla_op_plv_on = 0;
-	
-        if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO
-             /*|| (MINOR(inode->i_rdev) & 0x0f) == SND_DEV_DSP*/ ) {
+
+        Cotulla_audio_play_power_on();
+	CODEC_SetVolume(sound.volume_left);
+
+        if ((MINOR(inode->i_rdev) & 0x0f) == SND_DEV_AUDIO ) {
             sound_set_speed(8000);
             sound_set_stereo(0);
-            sound_set_format(AFMT_S16_LE);
+            sound_set_format(AFMT_MU_LAW);
         }
-        Cotulla_audio_play_power_on();
-	CODEC_SetVolume(sound.volume_left);
+
  	cotulla_under_playing = 1;
     }
 
diff -Nur sharp-a300-linux-1_10/drivers/video/Config.in sharp-a300-linux-1_20/drivers/video/Config.in
--- sharp-a300-linux-1_10/drivers/video/Config.in	Wed Jun 19 10:09:35 2002
+++ sharp-a300-linux-1_20/drivers/video/Config.in	Thu Nov  7 15:28:15 2002
@@ -45,6 +45,9 @@
      if [ "$CONFIG_FB_SA1100" = "y" -a "$CONFIG_SA1100_CERF_CPLD" = "y" ]; then
        bool 'Cerfboard Backlight (CerfPDA)' CONFIG_SA1100_CERF_LCD_BACKLIGHT
      fi
+     if [ "$CONFIG_SABINAL_DISCOVERY" = "y" ]; then
+	dep_bool '  Cached FB support' CONFIG_DISCOVERY_CONSISTENT_ALLOC $CONFIG_SABINAL_DISCOVERY
+     fi
    fi
    dep_tristate '  CyberPro 2000/2010/5000 support' CONFIG_FB_CYBER2000 $CONFIG_PCI
    if [ "$CONFIG_APOLLO" = "y" ]; then
diff -Nur sharp-a300-linux-1_10/drivers/video/fbmem.c sharp-a300-linux-1_20/drivers/video/fbmem.c
--- sharp-a300-linux-1_10/drivers/video/fbmem.c	Mon Aug  5 10:24:20 2002
+++ sharp-a300-linux-1_20/drivers/video/fbmem.c	Thu Nov  7 15:28:15 2002
@@ -648,6 +648,9 @@
 	pgprot_val(vma->vm_page_prot) |= _CACHE_UNCACHED;
 #elif defined(__arm__)
 	vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
+#ifdef CONFIG_DISCOVERY_CONSISTENT_ALLOC
+	vma->vm_page_prot = __pgprot(pgprot_val(vma->vm_page_prot) | L_PTE_CACHEABLE);
+#endif
 	/* This is an IO map - tell maydump to skip this VMA */
 	vma->vm_flags |= VM_IO;
 #elif defined(__sh__)
diff -Nur sharp-a300-linux-1_10/include/asm-arm/arch-cotulla/cotulla.h sharp-a300-linux-1_20/include/asm-arm/arch-cotulla/cotulla.h
--- sharp-a300-linux-1_10/include/asm-arm/arch-cotulla/cotulla.h	Tue Sep  3 11:08:06 2002
+++ sharp-a300-linux-1_20/include/asm-arm/arch-cotulla/cotulla.h	Fri Nov 15 13:27:18 2002
@@ -19,6 +19,7 @@
 
 #define COTULLA_RAMBASE      0xa0000000
 
+#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 #include <asm/types.h>
 
@@ -60,6 +61,7 @@
 	volatile u32 dcmd;	/* DCMD value for the current transfer */
 } pxa_dma_desc;
 #endif
+#endif	/* __KERNEL__ */
 
 /* 
  * Clock Manager Controle registers
@@ -920,6 +922,42 @@
 #define UICR1		__REG(0x40600054)  /* UDC Interrupt Control Register 1 */
 #define USIR0		__REG(0x40600058)  /* UDC Status Interrupt Register 0 */
 #define USIR1		__REG(0x4060005C)  /* UDC Status Interrupt Register 1 */
+
+/*
+ * Memory controller
+ */
+
+#define MDCNFG		__REG(0x48000000)  /* SDRAM Configuration Register 0 */
+#define MDREFR		__REG(0x48000004)  /* SDRAM Refresh Control Register */
+#define MSC0		__REG(0x48000008)  /* Static Memory Control Register 0 */
+#define MSC1		__REG(0x4800000C)  /* Static Memory Control Register 1 */
+#define MSC2		__REG(0x48000010)  /* Static Memory Control Register 2 */
+#define MECR		__REG(0x48000014)  /* Expansion Memory (PCMCIA/Compact Flash) Bus Configuration */
+#define SXLCR		__REG(0x48000018)  /* LCR value to be written to SDRAM-Timing Synchronous Flash */
+#define SXCNFG		__REG(0x4800001C)  /* Synchronous Static Memory Control Register */
+#define SXMRS		__REG(0x48000024)  /* MRS value to be written to Synchronous Flash or SMROM */
+#define MCMEM0		__REG(0x48000028)  /* Card interface Common Memory Space Socket 0 Timing */
+#define MCMEM1		__REG(0x4800002C)  /* Card interface Common Memory Space Socket 1 Timing */
+#define MCATT0		__REG(0x48000030)  /* Card interface Attribute Space Socket 0 Timing Configuration */
+#define MCATT1		__REG(0x48000034)  /* Card interface Attribute Space Socket 1 Timing Configuration */
+#define MCIO0		__REG(0x48000038)  /* Card interface I/O Space Socket 0 Timing Configuration */
+#define MCIO1		__REG(0x4800003C)  /* Card interface I/O Space Socket 1 Timing Configuration */
+#define MDMRS		__REG(0x48000040)  /* MRS value to be written to SDRAM */
+#define BOOT_DEF	__REG(0x48000044)  /* Read-Only Boot-Time Register. Contains BOOT_SEL and PKG_SEL */
+
+#define MDREFR_K2FREE	(1 << 25)	/* SDRAM Free-Running Control */
+#define MDREFR_K1FREE	(1 << 24)	/* SDRAM Free-Running Control */
+#define MDREFR_K0FREE	(1 << 23)	/* SDRAM Free-Running Control */
+#define MDREFR_SLFRSH	(1 << 22)	/* SDRAM Self-Refresh Control/Status */
+#define MDREFR_APD	(1 << 20)	/* SDRAM/SSRAM Auto-Power-Down Enable */
+#define MDREFR_K2DB2	(1 << 19)	/* SDCLK2 Divide by 2 Control/Status */
+#define MDREFR_K2RUN	(1 << 18)	/* SDCLK2 Run Control/Status */
+#define MDREFR_K1DB2	(1 << 17)	/* SDCLK1 Divide by 2 Control/Status */
+#define MDREFR_K1RUN	(1 << 16)	/* SDCLK1 Run Control/Status */
+#define MDREFR_E1PIN	(1 << 15)	/* SDCKE1 Level Control/Status */
+#define MDREFR_K0DB2	(1 << 14)	/* SDCLK0 Divide by 2 Control/Status */
+#define MDREFR_K0RUN	(1 << 13)	/* SDCLK0 Run Control/Status */
+#define MDREFR_E0PIN	(1 << 12)	/* SDCKE0 Level Control/Status */
 
 #ifndef __ASSEMBLY__
 extern unsigned int cotulla_rev; /* Board revision */
