Index: include/asm-arm/arch-nds/fifo.h =================================================================== --- include/asm-arm/arch-nds/fifo.h (revisjon 2036) +++ include/asm-arm/arch-nds/fifo.h (arbeidskopi) @@ -131,6 +131,7 @@ void (*firmware_handler)(u8 cmd); void (*button_handler)(u32 state); void (*touch_handler)(u8 pressed, u8 x, u8 y); + void (*tsc_temp_handler)(u8 temp_i, u8 temp_f); void (*time_handler)(u32 seconds); void (*wifi_handler)(u8 cmd, u32 data); /* ... */ Index: arch/arm/mach-nds/fifo.c =================================================================== --- arch/arm/mach-nds/fifo.c (revisjon 2036) +++ arch/arm/mach-nds/fifo.c (arbeidskopi) @@ -48,10 +48,14 @@ cb->handler.button_handler(data & 0xff); break; case FIFO_TOUCH: - cb->handler.touch_handler( - (data & (1 << 16)) >> 16, - (data & (0xff << 8)) - >> 8, data & 0xff); + if (data & (1 << 28)) + cb->handler.tsc_temp_handler( + data & 0xff, (data >> 8) & 0xff); + else + cb->handler.touch_handler( + (data & (1 << 16)) >> 16, + (data & (0xff << 8)) + >> 8, data & 0xff); break; case FIFO_TIME: cb->handler.time_handler( Index: arch/arm/mach-nds/arm7/spi.h =================================================================== --- arch/arm/mach-nds/arm7/spi.h (revisjon 2036) +++ arch/arm/mach-nds/arm7/spi.h (arbeidskopi) @@ -2,6 +2,7 @@ #define SPI_H s32 touch_read_value(int measure, int retry , int range); +u16 touch_read(u32 command); #define POWER0_SOUND_AMP (1<<0) #define POWER0_LOWER_BACKLIGHT (1<<2) Index: arch/arm/mach-nds/arm7/main.c =================================================================== --- arch/arm/mach-nds/arm7/main.c (revisjon 2036) +++ arch/arm/mach-nds/arm7/main.c (arbeidskopi) @@ -15,6 +15,8 @@ static s32 xscale, yscale; static s32 xoffset, yoffset; +static int temperature = 0; + static struct nds_firmware_block *firmware_block; /* recieve outstanding FIFO commands from ARM9 */ @@ -57,6 +59,10 @@ nds_fifo_send(FIFO_TIME | FIFO_LOW_BITS | (seconds & 0xffff)); break; + case FIFO_TOUCH: /* Send touchscreen controller temperature */ + nds_fifo_send(FIFO_TOUCH | (1 << 28) | (temperature >> 12) | + ((100 * (temperature & 0xfff) >> 12) << 8)); + break; case FIFO_SOUND: switch (data & 0x0f000000) { case FIFO_SOUND_FORMAT: @@ -220,6 +226,7 @@ u16 buttons; static u16 oldbuttons = 0x43; /* default stats */ u32 wif; + int t1, t2; wif = NDS_IF; @@ -243,6 +250,10 @@ sendTouchState(buttons); + t1 = touch_read(TSC_MEASURE_TEMP1); + t2 = touch_read(TSC_MEASURE_TEMP2); + temperature = 8490 * (t2 - t1) - 273*4096; + /* clear FIFO errors (just in case) */ if (NDS_REG_IPCFIFOCNT & (1 << 14)) NDS_REG_IPCFIFOCNT |= (1 << 15) | (1 << 14); Index: arch/arm/mach-nds/arm7/arm7.h =================================================================== --- arch/arm/mach-nds/arm7/arm7.h (revisjon 2036) +++ arch/arm/mach-nds/arm7/arm7.h (arbeidskopi) @@ -142,6 +142,8 @@ #define TSC_MEASURE_Z1 0xB0 #define TSC_MEASURE_Z2 0xC0 #define TSC_MEASURE_X 0xD0 +#define TSC_MEASURE_TEMP1 0x84 +#define TSC_MEASURE_TEMP2 0xF4 #define MIN(x,y) ((x)<(y)?(x):(y)) #define MAX(x,y) ((x)>(y)?(x):(y)) Index: arch/arm/mach-nds/arm7/spi.c =================================================================== --- arch/arm/mach-nds/arm7/spi.c (revisjon 2036) +++ arch/arm/mach-nds/arm7/spi.c (arbeidskopi) @@ -31,7 +31,7 @@ #define WAIT_FOR_NOT_BUSY() {while (REG_SPI_CR & SPI_BUSY) swiDelay(1);} -static u16 touch_read(u32 command) +u16 touch_read(u32 command) { u16 result; Index: arch/arm/mach-nds/Makefile =================================================================== --- arch/arm/mach-nds/Makefile (revisjon 2036) +++ arch/arm/mach-nds/Makefile (arbeidskopi) @@ -4,7 +4,7 @@ # Object file lists. -obj-y += arch.o irq.o time.o button.o fifo.o rtc.o disable-itcm-writes.o +obj-y += arch.o irq.o time.o button.o fifo.o rtc.o disable-itcm-writes.o tsc_temp.o obj-$(CONFIG_NDS_TEXT_CONSOLE) += console.o obj-$(CONFIG_NDS_SOUNDTEST) += soundtest.o --- /dev/null 2007-11-17 13:14:13.448078999 +0100 +++ arch/arm/mach-nds/tsc_temp.c 2007-11-16 01:41:39.000000000 +0100 @@ -0,0 +1,60 @@ +/* Make DS touchscreen controller temperature available in + * /proc/tsc_temp. + * + * Copyright (c) 2007 John S. Skogtvedt + * 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 +#include +#include +#include +#include +#include +#include + +static DECLARE_WAIT_QUEUE_HEAD(tsc_temp_wait); + +static u8 temperature_i; +static u8 temperature_f; + +static void temp_handler(u8 temp_i, u8 temp_f) { + temperature_i = temp_i; + temperature_f = temp_f; +} + +static struct fifo_cb tsc_temp_fifocb = { + .type = FIFO_TOUCH, + .handler.tsc_temp_handler = temp_handler +}; + +static int tsc_temp_read_proc(char *page, char **start, off_t off, + int count, int *eof, void *data) +{ + int len = 8; + + if (count < len) + return -EINVAL; + if (off != 0) + return 0; + + /* Only the first two digits of the fraction are sent from arm7 */ + temperature_f = 0xff; + nds_fifo_send(FIFO_TOUCH); + wait_event_interruptible(tsc_temp_wait, temperature_f != 0xff); + + len = sprintf(page, "%d.%d\n", temperature_i, temperature_f); + *eof = 1; + return len; +} + +static int __init tsc_temp_init(void) { + register_fifocb(&tsc_temp_fifocb); + create_proc_read_entry("tsc_temp", 0, NULL, tsc_temp_read_proc, NULL); + + return 0; +} + +module_init(tsc_temp_init);