summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/tsc2100.c19
-rw-r--r--firmware/target/arm/tms320dm320/app.lds2
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c29
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c2
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c5
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c17
-rw-r--r--firmware/target/arm/tms320dm320/system-dm320.c22
7 files changed, 33 insertions, 63 deletions
diff --git a/firmware/drivers/tsc2100.c b/firmware/drivers/tsc2100.c
index 09017996dc..b8edb7d52d 100644
--- a/firmware/drivers/tsc2100.c
+++ b/firmware/drivers/tsc2100.c
@@ -28,9 +28,6 @@
28/* adc_data contains the last readings from the tsc2100 */ 28/* adc_data contains the last readings from the tsc2100 */
29static short adc_data[10]; 29static short adc_data[10];
30static short adc_status; 30static short adc_status;
31static long adc_last_read=0;
32static long adc_last_touch_read=0;
33static long adc_last_volt_read=0;
34 31
35void tsc2100_read_data(void) 32void tsc2100_read_data(void)
36{ 33{
@@ -42,8 +39,6 @@ void tsc2100_read_data(void)
42 39
43 adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS); 40 adc_status|=tsc2100_readreg(TSSTAT_PAGE, TSSTAT_ADDRESS);
44 41
45 adc_last_read=current_tick;
46
47 spi_block_transfer(SPI_target_TSC2100, 42 spi_block_transfer(SPI_target_TSC2100,
48 out, sizeof(out), (char *)adc_data, sizeof(adc_data)); 43 out, sizeof(out), (char *)adc_data, sizeof(adc_data));
49 44
@@ -54,11 +49,7 @@ void tsc2100_read_data(void)
54/* Read X, Y, Z1, Z2 touchscreen coordinates. */ 49/* Read X, Y, Z1, Z2 touchscreen coordinates. */
55bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2) 50bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
56{ 51{
57 /* Note: This could cause problems if the current tick is not reset in ~1.3 52 if( adc_status&(3<<9) ) {
58 * years. Noting this in the event that a suspend/resume function
59 * is added.
60 */
61 if( (adc_status&(3<<9)) && (adc_last_read - adc_last_touch_read>=0) ) {
62 *x = adc_data[0]; 53 *x = adc_data[0];
63 *y = adc_data[1]; 54 *y = adc_data[1];
64 *z1 = adc_data[2]; 55 *z1 = adc_data[2];
@@ -66,8 +57,6 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
66 57
67 adc_status&=~(3<<9); 58 adc_status&=~(3<<9);
68 59
69 adc_last_touch_read=current_tick;
70
71 return true; 60 return true;
72 } else { 61 } else {
73 return false; 62 return false;
@@ -76,13 +65,12 @@ bool tsc2100_read_touch(short *x, short* y, short *z1, short *z2)
76 65
77bool tsc2100_read_volt(short *bat1, short *bat2, short *aux) 66bool tsc2100_read_volt(short *bat1, short *bat2, short *aux)
78{ 67{
79 if( (adc_status&(7<<4)) && TIME_BEFORE(adc_last_volt_read, adc_last_read)) { 68 if( adc_status&(7<<4) ) {
80 *bat1 = adc_data[5]; 69 *bat1 = adc_data[5];
81 *bat2 = adc_data[6]; 70 *bat2 = adc_data[6];
82 *aux = adc_data[7]; 71 *aux = adc_data[7];
83 72
84 adc_status&=~(7<<4); 73 adc_status&=~(7<<4);
85 adc_last_volt_read=current_tick;
86 return true; 74 return true;
87 } else { 75 } else {
88 return false; 76 return false;
@@ -110,7 +98,7 @@ void tsc2100_set_mode(bool poweron, unsigned char scan_mode)
110void tsc2100_adc_init(void) 98void tsc2100_adc_init(void)
111{ 99{
112 /* Set the TSC2100 to read touchscreen */ 100 /* Set the TSC2100 to read touchscreen */
113 tsc2100_set_mode(true, 0x01); 101 tsc2100_set_mode(true, 0x02);
114 102
115 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS, 103 tsc2100_writereg(TSSTAT_PAGE, TSSTAT_ADDRESS,
116 (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */ 104 (0x1<<TSSTAT_PINTDAV_SHIFT) /* Data available only */
@@ -132,7 +120,6 @@ short tsc2100_readreg(int page, int address)
132 return (in[0]<<8)|in[1]; 120 return (in[0]<<8)|in[1];
133} 121}
134 122
135
136void tsc2100_writereg(int page, int address, short value) 123void tsc2100_writereg(int page, int address, short value)
137{ 124{
138 unsigned short command = (page << 11)|(address << 5); 125 unsigned short command = (page << 11)|(address << 5);
diff --git a/firmware/target/arm/tms320dm320/app.lds b/firmware/target/arm/tms320dm320/app.lds
index 3437984f55..4e23b533a9 100644
--- a/firmware/target/arm/tms320dm320/app.lds
+++ b/firmware/target/arm/tms320dm320/app.lds
@@ -126,7 +126,7 @@ SECTIONS
126 .fiqstack (NOLOAD) : 126 .fiqstack (NOLOAD) :
127 { 127 {
128 *(.stack) 128 *(.stack)
129 . += 0x100; 129 . += 0x400;
130 fiq_stack = .; 130 fiq_stack = .;
131 } > IRAM 131 } > IRAM
132 132
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
index 5df764620d..2acce7a695 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
@@ -42,6 +42,9 @@ void adc_init(void)
42 42
43 /* Enable the tsc2100 interrupt */ 43 /* Enable the tsc2100 interrupt */
44 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */ 44 IO_INTC_EINT2 |= (1<<3); /* IRQ_GIO14 */
45
46 /* Read all registers to make sure they are clear */
47 tsc2100_read_data();
45} 48}
46 49
47/* Touchscreen data available interupt */ 50/* Touchscreen data available interupt */
@@ -49,31 +52,11 @@ void GIO14(void)
49{ 52{
50 /* Interrupts work properly when cleared first */ 53 /* Interrupts work properly when cleared first */
51 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */ 54 IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */
52 55
53 short tsadc = tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
54 short adscm = (tsadc&TSADC_ADSCM_MASK)>>TSADC_ADSCM_SHIFT;
55
56 /* Always read all registers in one go to clear any missed flags */ 56 /* Always read all registers in one go to clear any missed flags */
57 tsc2100_read_data(); 57 tsc2100_read_data();
58 58
59 switch (adscm) 59 /* Stop the scan, firmware will initiate another scan with a mode set */
60 { 60 tsc2100_set_mode(true, 0x00);
61 case 0x01:
62 case 0x02:
63 case 0x03:
64 case 0x04:
65 case 0x05:
66 /* do a battery read - this will shutdown the adc till the next tick
67 */
68// tsc2100_set_mode(true, 0x0B);
69 break;
70 case 0x06:
71 case 0x07:
72 case 0x08:
73 case 0x09:
74 case 0x0B:
75 tsc2100_set_mode(true, 0x01);
76 break;
77 }
78} 61}
79 62
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
index 7d9a43f902..3aa6009c9e 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -128,7 +128,7 @@ int button_read_device(int *data)
128 button_read |= touchscreen_to_pixels(touch_x, touch_y, data); 128 button_read |= touchscreen_to_pixels(touch_x, touch_y, data);
129 } 129 }
130 130
131 tsc2100_set_mode(true, 0x01); 131 tsc2100_set_mode(true, 0x02);
132 132
133 /* Handle power button */ 133 /* Handle power button */
134 if ((IO_GIO_BITSET0&0x01) == 0) { 134 if ((IO_GIO_BITSET0&0x01) == 0) {
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
index cdec2ab77c..02294100ac 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/pcm-mr500.c
@@ -61,6 +61,9 @@ void pcm_play_dma_init(void)
61 IO_INTC_IRQ0 = 1 << 11; 61 IO_INTC_IRQ0 = 1 << 11;
62 IO_INTC_EINT0 |= 1 << 11; 62 IO_INTC_EINT0 |= 1 << 11;
63 63
64 /* Set this as a FIQ */
65 IO_INTC_FISEL0 |= 1 << 11;
66
64 IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0; 67 IO_DSPC_HPIB_CONTROL = 1 << 10 | 1 << 9 | 1 << 8 | 1 << 7 | 1 << 3 | 1 << 0;
65 68
66 dsp_reset(); 69 dsp_reset();
@@ -133,7 +136,7 @@ void DSPHINT(void)
133 136
134 unsigned int i; 137 unsigned int i;
135 138
136 IO_INTC_IRQ0 = 1 << 11; 139 IO_INTC_FIQ0 = 1 << 11;
137 140
138 switch (dsp_message.msg) 141 switch (dsp_message.msg)
139 { 142 {
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index 6e361aac15..d0f1a0bf59 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -68,17 +68,14 @@ unsigned int battery_adc_voltage(void)
68 current_bat2=((short)((int)(bat2<<10)/4096*6*2.5)); 68 current_bat2=((short)((int)(bat2<<10)/4096*6*2.5));
69 current_aux=((short)((int)(aux<<10)/4096*6*2.5)); 69 current_aux=((short)((int)(aux<<10)/4096*6*2.5));
70 } 70 }
71 71
72 if (TIME_BEFORE(last_tick+2*HZ, current_tick) || last_tick==0) 72 tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS);
73
74 /* Set the TSC2100 to read voltages if not busy with pen */
75 if(!(tsadc & TSADC_PSTCM))
73 { 76 {
74 tsadc=tsc2100_readreg(TSADC_PAGE, TSADC_ADDRESS); 77 tsc2100_set_mode(true, 0x0B);
75 78 last_tick = current_tick;
76 /* Set the TSC2100 to read voltages if not busy with pen */
77 if(!(tsadc & TSADC_PSTCM))
78 {
79 tsc2100_set_mode(true, 0x0B);
80 last_tick = current_tick;
81 }
82 } 79 }
83 80
84 return current_voltage; 81 return current_voltage;
diff --git a/firmware/target/arm/tms320dm320/system-dm320.c b/firmware/target/arm/tms320dm320/system-dm320.c
index 434b0065a5..9dff1afc20 100644
--- a/firmware/target/arm/tms320dm320/system-dm320.c
+++ b/firmware/target/arm/tms320dm320/system-dm320.c
@@ -155,17 +155,17 @@ void fiq_handler(void)
155 * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c 155 * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
156 */ 156 */
157 157
158 asm volatile ( 158 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */
159 "sub lr, lr, #4 \r\n" 159 "sub sp, sp, #8 \n"); /* Reserve stack */
160 "stmfd sp!, {r0-r3, ip, lr} \r\n" 160 unsigned short addr = IO_INTC_FIQENTRY0>>2;
161 "mov r0, #0x00030000 \r\n" 161 if(addr != 0)
162 "ldr r0, [r0, #0x510] \r\n" /* Fetch value from IO_INTC_FIQENTRY0 */ 162 {
163 "sub r0, r0, #1 \r\n" 163 addr--;
164 "ldr r1, =irqvector \r\n" 164 irqvector[addr]();
165 "ldr r1, [r1, r0, lsl #2] \r\n" /* Divide value by 4 (TBA0/TBA1 is set to 0) and load appropriate pointer from the vector list */ 165 }
166 "blx r1 \r\n" /* Jump to handler */ 166 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */
167 "ldmfd sp!, {r0-r3, ip, pc}^ \r\n" /* Return from FIQ */ 167 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */
168 ); 168 "subs pc, lr, #4 \n"); /* Return from FIQ */
169} 169}
170 170
171void system_reboot(void) 171void system_reboot(void)