[commit] r2419 - in trunk/linux-2.6.x: arch/arm/mach-nds arch/arm/mach-nds/arm7 drivers/video include/asm-arm/arch-nds

dslinux_sonny_jim at dslinux.in-berlin.de dslinux_sonny_jim at dslinux.in-berlin.de
Wed Jun 24 00:55:50 CEST 2009


Author: dslinux_sonny_jim
Date: Wed Jun 24 00:55:50 2009
New Revision: 2419

Log:
Patch to fix bug where speakers are turned off with screen blank.  Rather than writing to ARM9 4000304h bit0, it uses the power management chip on the ARM7 SPI bus.  With contributions from Ludo6431 and stsp.

Modified:
   trunk/linux-2.6.x/arch/arm/mach-nds/arch.c
   trunk/linux-2.6.x/arch/arm/mach-nds/arm7/main.c
   trunk/linux-2.6.x/arch/arm/mach-nds/fifo.c
   trunk/linux-2.6.x/drivers/video/ndsfb.c
   trunk/linux-2.6.x/include/asm-arm/arch-nds/fifo.h
   trunk/linux-2.6.x/include/asm-arm/arch-nds/power.h

Modified: trunk/linux-2.6.x/arch/arm/mach-nds/arch.c
==============================================================================
--- trunk/linux-2.6.x/arch/arm/mach-nds/arch.c	(original)
+++ trunk/linux-2.6.x/arch/arm/mach-nds/arch.c	Wed Jun 24 00:55:50 2009
@@ -53,12 +53,12 @@
 
 static void poweroff(void)
 {
-	nds_fifo_send(FIFO_POWER);
+	nds_fifo_send(FIFO_POWER_CMD(FIFO_POWER_CMD_SYSTEM_POWER, 0));
 }
 
 static void nds_machine_init(void)
 {
-	POWER_CR = POWER_2D | POWER_2D_SUB | POWER_LCD_TOP | POWER_LCD_BOTTOM | POWER_SWAP_LCDS ;
+	POWER_CR = POWER_2D | POWER_2D_SUB | POWER_LCD | POWER_SWAP_LCDS ;
 
 	/* Note: initial setup of wait_cr in head.S */
 

Modified: trunk/linux-2.6.x/arch/arm/mach-nds/arm7/main.c
==============================================================================
--- trunk/linux-2.6.x/arch/arm/mach-nds/arm7/main.c	(original)
+++ trunk/linux-2.6.x/arch/arm/mach-nds/arm7/main.c	Wed Jun 24 00:55:50 2009
@@ -24,6 +24,7 @@
 	u32 fifo_recv;
 	u32 data;
 	u32 seconds = 0;
+	u32 power;
 	int cmd;
 	struct nds_tx_packet *tx_packet = NULL;
 
@@ -49,8 +50,24 @@
 			}
 			break;
 		case FIFO_POWER:
-			power_write(POWER_CONTROL, POWER0_SYSTEM_POWER);
-			break;
+			cmd = FIFO_POWER_GET_CMD(data);
+			switch (cmd) {
+			case FIFO_POWER_CMD_BACKLIGHT_ENABLE:
+	 				power = power_read(POWER_CONTROL);
+		        		power_write(POWER_CONTROL, power | POWER0_LOWER_BACKLIGHT | POWER0_UPPER_BACKLIGHT);
+					
+				break;
+			case FIFO_POWER_CMD_BACKLIGHT_DISABLE:
+					power = power_read(POWER_CONTROL);
+					power &= ~(POWER0_LOWER_BACKLIGHT | POWER0_UPPER_BACKLIGHT);
+					power_write(POWER_CONTROL, power);
+				
+				break;
+			case FIFO_POWER_CMD_SYSTEM_POWER:
+					power_write(POWER_CONTROL, POWER0_SYSTEM_POWER);
+				break;
+				}
+	 		break;
 		case FIFO_TIME:
 			seconds = nds_get_time7();
 			nds_fifo_send(FIFO_TIME | FIFO_HIGH_BITS |

Modified: trunk/linux-2.6.x/arch/arm/mach-nds/fifo.c
==============================================================================
--- trunk/linux-2.6.x/arch/arm/mach-nds/fifo.c	(original)
+++ trunk/linux-2.6.x/arch/arm/mach-nds/fifo.c	Wed Jun 24 00:55:50 2009
@@ -65,6 +65,10 @@
 				case FIFO_MIC:
 					cb -> handler.mic_handler();
 					break;
+				case FIFO_POWER:
+					cb->handler.power_handler(
+					    FIFO_POWER_GET_CMD(data));
+					break;
 				default:
 					break;
 				}

Modified: trunk/linux-2.6.x/drivers/video/ndsfb.c
==============================================================================
--- trunk/linux-2.6.x/drivers/video/ndsfb.c	(original)
+++ trunk/linux-2.6.x/drivers/video/ndsfb.c	Wed Jun 24 00:55:50 2009
@@ -24,6 +24,7 @@
 
 #include <asm/arch/power.h>
 #include <asm/io.h>
+#include <asm/arch/fifo.h>
 
 #define	VCOUNT  	 (*(volatile u16*)0x04000006)
 #define DISPLAY_CR       (*(volatile u32*)0x04000000)
@@ -287,7 +288,7 @@
 		if (info->par != 0) {
 			var->xres_virtual = 256;
 			var->yres_virtual = 256;
-		
+
 			if (var->bits_per_pixel != 16 && var->bits_per_pixel != 8)
 				return -EINVAL;
 
@@ -469,11 +470,9 @@
 static int ndsfb_blank(int blank_mode, struct fb_info *info)
 {
 	if (blank_mode) {
-		//POWER_CR &= ~ ( POWER_2D | POWER_2D_SUB | POWER_LCD_TOP | POWER_LCD_TOP ) ;
-		POWER_CR &= ~(POWER_LCD_TOP | POWER_LCD_TOP);
+		nds_fifo_send(FIFO_POWER_CMD(FIFO_POWER_CMD_BACKLIGHT_DISABLE, 0));
 	} else {
-		POWER_CR |=
-		    (POWER_2D | POWER_2D_SUB | POWER_LCD_TOP | POWER_LCD_TOP);
+		nds_fifo_send(FIFO_POWER_CMD(FIFO_POWER_CMD_BACKLIGHT_ENABLE, 0));
 	}
 	return 0;
 }

Modified: trunk/linux-2.6.x/include/asm-arm/arch-nds/fifo.h
==============================================================================
--- trunk/linux-2.6.x/include/asm-arm/arch-nds/fifo.h	(original)
+++ trunk/linux-2.6.x/include/asm-arm/arch-nds/fifo.h	Wed Jun 24 00:55:50 2009
@@ -43,6 +43,23 @@
 #define FIFO_LOW_BITS   (1<<17)
 
 /* 
+ * Fifo commands for power management chip
+ * +-------------------------------------------------------------------------+
+ * |3 bits FIFO_FIRMWARE | 5 bits FIFO_CMD_FIRMWARE_x | 24 bits command data |
+ * +-------------------------------------------------------------------------+
+*/
+#define FIFO_POWER_CMD(c, d) (FIFO_POWER | ((c & 0x1f) << 24) | (d & 0x00ffffff))
+#define FIFO_POWER_GET_CMD(c) ((c >> 24) & 0x1f)
+#define FIFO_POWER_GET_DATA(d) (d & 0x00ffffff)
+#define FIFO_POWER_DECODE_ADDRESS(a) ((a) + 0x02000000)
+
+enum FIFO_POWER_CMDS {
+		FIFO_POWER_CMD_BACKLIGHT_ENABLE,
+		FIFO_POWER_CMD_BACKLIGHT_DISABLE,
+		FIFO_POWER_CMD_SYSTEM_POWER
+};
+
+/* 
  * Fifo commands for firmware dumper.
  * +-------------------------------------------------------------------------+
  * |3 bits FIFO_FIRMWARE | 5 bits FIFO_CMD_FIRMWARE_x | 24 bits command data |
@@ -166,7 +183,8 @@
 		void (*touch_handler)(u8 pressed, u8 x, u8 y);
 		void (*time_handler)(u32 seconds);
 		void (*wifi_handler)(u8 cmd, u32 data);
-		void (*mic_handler)(void); 
+		void (*mic_handler)(void);
+		void (*power_handler)(u8 cmd);
 		/* ... */
 	} handler;
 };

Modified: trunk/linux-2.6.x/include/asm-arm/arch-nds/power.h
==============================================================================
--- trunk/linux-2.6.x/include/asm-arm/arch-nds/power.h	(original)
+++ trunk/linux-2.6.x/include/asm-arm/arch-nds/power.h	Wed Jun 24 00:55:50 2009
@@ -1,11 +1,10 @@
 
 #define POWER_CR       (*(volatile u16*)0x04000304)
 
-#define POWER_LCD_TOP    (1<<0)
+#define POWER_LCD	 (1<<0)
 #define POWER_2D         (1<<1)
 #define POWER_MATRIX     (1<<2)
 #define POWER_3D_CORE    (1<<3)
-#define POWER_LCD_BOTTOM (1<<8)
 #define POWER_2D_SUB     (1<<9)
 #define POWER_SWAP_LCDS  (1<<15)
 


More information about the dslinux-commit mailing list