summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tcc77x
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/tcc77x')
-rw-r--r--firmware/target/arm/tcc77x/adc-tcc77x.c71
-rw-r--r--firmware/target/arm/tcc77x/ata-nand-tcc77x.c94
-rw-r--r--firmware/target/arm/tcc77x/ata-target.h22
-rw-r--r--firmware/target/arm/tcc77x/crt0.S153
-rw-r--r--firmware/target/arm/tcc77x/logikdax/adc-target.h26
-rw-r--r--firmware/target/arm/tcc77x/logikdax/backlight-target.h38
-rw-r--r--firmware/target/arm/tcc77x/logikdax/button-target.h70
-rw-r--r--firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c253
-rw-r--r--firmware/target/arm/tcc77x/logikdax/power-logikdax.c66
-rw-r--r--firmware/target/arm/tcc77x/system-target.h35
-rw-r--r--firmware/target/arm/tcc77x/system-tcc77x.c136
11 files changed, 964 insertions, 0 deletions
diff --git a/firmware/target/arm/tcc77x/adc-tcc77x.c b/firmware/target/arm/tcc77x/adc-tcc77x.c
new file mode 100644
index 0000000000..d6d97aaf84
--- /dev/null
+++ b/firmware/target/arm/tcc77x/adc-tcc77x.c
@@ -0,0 +1,71 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include "system.h"
22#include "kernel.h"
23#include "thread.h"
24#include "string.h"
25#include "adc.h"
26
27/*
28 TODO: We probably want to do this on the timer interrupt once we get
29 interrupts going - see the sh-adc.c implementation for an example which
30 looks like it should work well with the TCC77x.
31*/
32
33static unsigned short adcdata[8];
34
35static void adc_do_read(void)
36{
37 int i;
38 uint32_t adc_status;
39
40 PCLKCFG6 |= (1<<15); /* Enable ADC clock */
41
42 /* Start converting the first 4 channels */
43 for (i = 0; i < 4; i++)
44 ADCCON = i;
45
46 /* Wait for data to become stable */
47 while ((ADCDATA & 0x1) == 0);
48
49 /* Now read the values back */
50 for (i=0;i < 4; i++) {
51 adc_status = ADCSTATUS;
52 adcdata[(adc_status >> 16) & 0x7] = adc_status & 0x3ff;
53 }
54
55 PCLKCFG6 &= ~(1<<15); /* Disable ADC clock */
56}
57
58unsigned short adc_read(int channel)
59{
60 adc_do_read();
61
62 return adcdata[channel];
63}
64
65void adc_init(void)
66{
67 int i;
68
69 ADCCON = (1<<4); /* Leave standby mode */
70 ADCCFG |= 0x00000003; /* Single-mode, auto power-down */
71}
diff --git a/firmware/target/arm/tcc77x/ata-nand-tcc77x.c b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
new file mode 100644
index 0000000000..dd0ae7a950
--- /dev/null
+++ b/firmware/target/arm/tcc77x/ata-nand-tcc77x.c
@@ -0,0 +1,94 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "ata.h"
20#include "ata-target.h"
21#include "ata_idle_notify.h"
22#include "system.h"
23#include <string.h>
24#include "thread.h"
25#include "led.h"
26#include "disk.h"
27#include "panic.h"
28#include "usb.h"
29
30/* for compatibility */
31int ata_spinup_time = 0;
32
33long last_disk_activity = -1;
34
35/** static, private data **/
36static bool initialized = false;
37
38static long next_yield = 0;
39#define MIN_YIELD_PERIOD 2000
40
41/* API Functions */
42
43void ata_led(bool onoff)
44{
45 led(onoff);
46}
47
48int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount,
49 void* inbuf)
50{
51
52}
53
54int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count,
55 const void* outbuf)
56{
57}
58
59void ata_spindown(int seconds)
60{
61 (void)seconds;
62}
63
64bool ata_disk_is_active(void)
65{
66 return 0;
67}
68
69void ata_sleep(void)
70{
71}
72
73void ata_spin(void)
74{
75}
76
77/* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */
78int ata_hard_reset(void)
79{
80 return 0;
81}
82
83int ata_soft_reset(void)
84{
85 return 0;
86}
87
88void ata_enable(bool on)
89{
90}
91
92int ata_init(void)
93{
94}
diff --git a/firmware/target/arm/tcc77x/ata-target.h b/firmware/target/arm/tcc77x/ata-target.h
new file mode 100644
index 0000000000..79ac638de1
--- /dev/null
+++ b/firmware/target/arm/tcc77x/ata-target.h
@@ -0,0 +1,22 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef ATA_TARGET_H
20#define ATA_TARGET_H
21
22#endif
diff --git a/firmware/target/arm/tcc77x/crt0.S b/firmware/target/arm/tcc77x/crt0.S
new file mode 100644
index 0000000000..e4ecb05a4e
--- /dev/null
+++ b/firmware/target/arm/tcc77x/crt0.S
@@ -0,0 +1,153 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20/* Arm bootloader and startup code based on startup.s from the iPodLinux loader
21 *
22 * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
23 * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
24 *
25 */
26
27#include "config.h"
28#include "cpu.h"
29
30 .section .init.text,"ax",%progbits
31
32 .global start
33
34/* Telechips firmware files start with a 32-byte header, as part of the code. */
35
36start:
37#ifdef TCCBOOT
38 /* Add -DTCCBOOT to EXTRA_DEFINES in the bootloader Makefile to
39 enable building the bootloader to be appended to the end of the
40 original firmware, dual-booting based on a key-press.
41
42 The following two values are filled in by mktccboot.
43 */
44 .word 0 /* Saved entrypoint of original firmware*/
45 .word 0 /* Location in RAM of the start of our bootloader */
46#else
47 ldr pc, =start_loc /* jump to the main entry point */
48
49 .word 0xffff0601 /* Unknown magic */
50 .word 0x3a726556 /* "Ver:" */
51 .word 0x31373030 /* "0071" */
52 .word 0 /* First CRC32 */
53 .word 0 /* Unknown - always 0 */
54 .word 0 /* Second CRC32 */
55 .word 0 /* length of firmware file */
56
57#ifdef LOGIK_DAX
58 /* Some original firmwares have 0x40 bytes of zeroes here - we
59 don't know why, but err on the side of caution and include it
60 here. */
61 .space 0x40
62#endif
63#endif
64
65start_loc:
66
67#ifdef BOOTLOADER
68#ifdef TCCBOOT
69#ifdef LOGIK_DAX
70 mov r0, #0x80000000
71 ldr r0, [r0, #0x300] /* Read GPIO A */
72 tst r0, #0x2
73 ldrne pc, [pc, #-28] /* Jump to original firmware if HOLD button not pressed */
74#else
75 #error No bootup key detection implemented for this target
76#endif
77
78 /* Copy bootloader to safe area - 0x21000000 (DRAM) */
79 /* TODO: Adjust this for other targets - DRAM + DRAMSIZE - 0x100000 */
80 ldr r0, [pc, #-28]
81 mov r1, #0x20000000
82 add r1, r1, #0x100000
83 ldr r2, =_dataend
841:
85 cmp r2, r1
86 ldrhi r3, [r0], #4
87 strhi r3, [r1], #4
88 bhi 1b
89
90 ldr pc, =copied_start /* jump to the relocated start_loc: */
91
92copied_start:
93#endif
94#else
95 /* We don't use interrupts in the bootloader */
96
97 /* Set up stack for IRQ mode */
98 mov r0,#0xd2
99 msr cpsr, r0
100 ldr sp, =irq_stack
101 /* Set up stack for FIQ mode */
102 mov r0,#0xd1
103 msr cpsr, r0
104 ldr sp, =fiq_stack
105
106 /* Let abort and undefined modes use IRQ stack */
107 mov r0,#0xd7
108 msr cpsr, r0
109 ldr sp, =irq_stack
110 mov r0,#0xdb
111 msr cpsr, r0
112 ldr sp, =irq_stack
113#endif
114
115 /* Switch to supervisor mode */
116 mov r0,#0xd3
117 msr cpsr, r0
118 ldr sp, =stackend
119
120 /* Initialise bss section to zero */
121 ldr r2, =_edata
122 ldr r3, =_end
123 mov r4, #0
1241:
125 cmp r3, r2
126 strhi r4, [r2], #4
127 bhi 1b
128
129 /* Set up some stack and munge it with 0xdeadbeef */
130 ldr sp, =stackend
131 mov r3, sp
132 ldr r2, =stackbegin
133 ldr r4, =0xdeadbeef
1341:
135 cmp r3, r2
136 strhi r4, [r2], #4
137 bhi 1b
138
139 bl main
140 /* main() should never return */
141
142#ifndef BOOTLOADER
143 /* We don't use interrupts in the bootloader */
144
145/* 256 words of IRQ stack */
146 .space 256*4
147irq_stack:
148
149/* 256 words of FIQ stack */
150 .space 256*4
151fiq_stack:
152
153#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/adc-target.h b/firmware/target/arm/tcc77x/logikdax/adc-target.h
new file mode 100644
index 0000000000..cfc8117a99
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/adc-target.h
@@ -0,0 +1,26 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef _ADC_TARGET_H_
20#define _ADC_TARGET_H_
21
22#define NUM_ADC_CHANNELS 8
23
24#define ADC_BUTTONS 0
25
26#endif /* _ADC_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
new file mode 100644
index 0000000000..4714f22aa3
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
@@ -0,0 +1,38 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef BACKLIGHT_TARGET_H
20#define BACKLIGHT_TARGET_H
21
22#include "tcc77x.h"
23
24#define __backlight_init() true
25
26static inline void __backlight_on(void)
27{
28 /* Enable backlight */
29 GPIOD |= 0x10;
30}
31
32static inline void __backlight_off(void)
33{
34 /* Disable backlight */
35 GPIOD &= ~0x10;
36}
37
38#endif
diff --git a/firmware/target/arm/tcc77x/logikdax/button-target.h b/firmware/target/arm/tcc77x/logikdax/button-target.h
new file mode 100644
index 0000000000..2925a423b6
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/button-target.h
@@ -0,0 +1,70 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#ifndef _BUTTON_TARGET_H_
21#define _BUTTON_TARGET_H_
22
23#include <stdbool.h>
24#include "config.h"
25
26/*
27
28Results of button testing:
29
30HOLD: GPIOA & 0x0002 (0=pressed, 0x0002 = released)
31POWER: GPIOA & 0x8000 (0=pressed, 0x8000 = released)
32
33ADC[0]: (approx values)
34
35RIGHT - 0x37
36LEFT - 0x7f
37JOYSTICK PRESS - 0xc7
38UP - 0x11e
39DOWN - 0x184
40MODE - 0x1f0/0x1ff
41PRESET - 0x268/0x269
42TIMESHIFT - 0x2dd
43
44Values of ADC[0] tested in OF disassembly: 0x50, 0x96, 0xdc, 0x208, 0x384
45
46*/
47
48
49void button_init_device(void);
50int button_read_device(void);
51
52/* Main unit's buttons */
53#define BUTTON_POWERPLAY 0x00000001
54#define BUTTON_MODE 0x00000002
55#define BUTTON_HOLD 0x00000004
56#define BUTTON_REC 0x00000008
57#define BUTTON_PRESET 0x00000010
58#define BUTTON_LEFT 0x00000020
59#define BUTTON_RIGHT 0x00000040
60#define BUTTON_UP 0x00000080
61#define BUTTON_DOWN 0x00000100
62#define BUTTON_SELECT 0x00000200
63
64#define BUTTON_MAIN (BUTTON_POWERPLAY|BUTTON_MODE|BUTTON_HOLD\
65 |BUTTON_REC|BUTTON_PRESET|BUTTON_LEFT\
66 |BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN|BUTTON_SELECT)
67
68#define BUTTON_REMOTE 0
69
70#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c
new file mode 100644
index 0000000000..973d4cb333
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/lcd-logikdax.c
@@ -0,0 +1,253 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20
21#include "hwcompat.h"
22#include "kernel.h"
23#include "lcd.h"
24#include "system.h"
25#include "cpu.h"
26
27/*** definitions ***/
28
29#define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00)
30#define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10)
31#define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20)
32#define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28)
33#define LCD_SET_DISPLAY_START_LINE ((char)0x40)
34#define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81)
35#define LCD_SET_SEGMENT_REMAP ((char)0xA0)
36#define LCD_SET_LCD_BIAS ((char)0xA2)
37#define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4)
38#define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5)
39#define LCD_SET_NORMAL_DISPLAY ((char)0xA6)
40#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
41#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
42#define LCD_SET_BIAS_TC_OSC ((char)0xA9)
43#define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA)
44#define LCD_SET_INDICATOR_OFF ((char)0xAC)
45#define LCD_SET_INDICATOR_ON ((char)0xAD)
46#define LCD_SET_DISPLAY_OFF ((char)0xAE)
47#define LCD_SET_DISPLAY_ON ((char)0xAF)
48#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
49#define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0)
50#define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2)
51#define LCD_SET_DISPLAY_OFFSET ((char)0xD3)
52#define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0)
53#define LCD_SOFTWARE_RESET ((char)0xE2)
54#define LCD_NOP ((char)0xE3)
55#define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE)
56
57/* LCD command codes */
58#define LCD_CNTL_RESET 0xe2 /* Software reset */
59#define LCD_CNTL_POWER 0x2f /* Power control */
60#define LCD_CNTL_CONTRAST 0x81 /* Contrast */
61#define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */
62#define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */
63#define LCD_CNTL_DISPON 0xaf /* Display on */
64
65#define LCD_CNTL_PAGE 0xb0 /* Page address */
66#define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */
67#define LCD_CNTL_LOWCOL 0x00 /* Lower column address */
68
69/* TCC77x specific defines */
70#define LCD_BASE 0x50000000
71#define LCD_CMD *(volatile unsigned char*)(LCD_BASE)
72#define LCD_DATA *(volatile unsigned char*)(LCD_BASE+1)
73
74void lcd_write_command(int byte)
75{
76 LCD_CMD = byte;
77
78 asm volatile (
79 "nop \n\t"
80 "nop \n\t"
81 "nop \n\t"
82 );
83}
84
85void lcd_write_data(const fb_data* p_bytes, int count)
86{
87 while (count--)
88 {
89 LCD_DATA = *(p_bytes++);
90
91 asm volatile (
92 "nop \n\t"
93 "nop \n\t"
94 "nop \n\t"
95 );
96 }
97}
98
99/* End of TCC77x specific defines */
100
101
102/** globals **/
103
104static int xoffset; /* needed for flip */
105
106/*** hardware configuration ***/
107
108int lcd_default_contrast(void)
109{
110 return 0x1f;
111}
112
113void lcd_set_contrast(int val)
114{
115 lcd_write_command(LCD_CNTL_CONTRAST);
116 lcd_write_command(val);
117}
118
119void lcd_set_invert_display(bool yesno)
120{
121 if (yesno)
122 lcd_write_command(LCD_SET_REVERSE_DISPLAY);
123 else
124 lcd_write_command(LCD_SET_NORMAL_DISPLAY);
125}
126
127/* turn the display upside down (call lcd_update() afterwards) */
128void lcd_set_flip(bool yesno)
129{
130 /* TODO: flip mode isn't working. The commands in the else part of
131 this function are how the original firmware inits the LCD */
132
133 if (yesno)
134 {
135 lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01);
136 lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION);
137 xoffset = 132 - LCD_WIDTH; /* 132 colums minus the 128 we have */
138 }
139 else
140 {
141 lcd_write_command(LCD_SET_SEGMENT_REMAP);
142 lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08);
143 xoffset = 0;
144 }
145}
146
147
148/* LCD init */
149void lcd_init_device(void)
150{
151 uint32_t bus_width;
152
153 /* Telechips init the same as the original firmware */
154 CSCFG1 &= 0xc3ffc000;
155 CSCFG1 |= 0x3400101a;
156 CSCFG1 |= (1 << 21);
157 CSCFG1 &= ~(1 << 21);
158
159 bus_width = ((MCFG >> 11) & 0x3) ^ 3;
160
161 CSCFG1 = (bus_width << 28) |
162 (3 << 26) | /* MTYPE = 3 */
163 ((LCD_BASE >> 28) << 22) | /* CSBASE = 0x5 */
164 (1 << 20) | /* Unknown */
165 (3 << 11) | /* Setup time = 3 cycles */
166 (3 << 3) | /* Pulse width = 3+1 cycles */
167 (1 << 0); /* Hold time = 1 cycle */
168
169 /* SSD1815 inits like the original firmware */
170 lcd_write_command(LCD_SET_DISPLAY_OFF);
171 lcd_set_flip(false);
172 lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO | 5);
173 lcd_set_contrast(lcd_default_contrast());
174 lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER | 7);
175 /* power control register: op-amp=1, regulator=1, booster=1 */
176 lcd_write_command(LCD_SET_BIAS_TC_OSC);
177
178 /* 0xc2 = 110 000 10: Osc. Freq 110 - ???
179 TC value 000 - "-0.01%/C (TC0, POR)"
180 Bias ratio 10 - "1/9, 1/7 (POR)"
181 */
182 lcd_write_command(0xc2);
183 lcd_write_command(LCD_SET_DISPLAY_ON);
184
185 lcd_clear_display();
186 lcd_update();
187}
188
189/*** Update functions ***/
190
191/* Performance function that works with an external buffer
192 note that by and bheight are in 8-pixel units! */
193void lcd_blit(const unsigned char* data, int x, int by, int width,
194 int bheight, int stride)
195{
196 /* Copy display bitmap to hardware */
197 while (bheight--)
198 {
199 lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf));
200 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset)>>4) & 0xf));
201 lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
202
203 lcd_write_data(data, width);
204 data += stride;
205 }
206}
207
208
209/* Update the display.
210 This must be called after all other LCD functions that change the display. */
211void lcd_update(void) ICODE_ATTR;
212void lcd_update(void)
213{
214 int y;
215
216 /* Copy display bitmap to hardware */
217 for (y = 0; y < LCD_FBHEIGHT; y++)
218 {
219 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
220 lcd_write_command (LCD_CNTL_HIGHCOL | ((xoffset >> 4) & 0xf));
221 lcd_write_command (LCD_CNTL_LOWCOL | (xoffset & 0xf));
222
223 lcd_write_data (lcd_framebuffer[y], LCD_WIDTH);
224 }
225}
226
227/* Update a fraction of the display. */
228void lcd_update_rect(int, int, int, int) ICODE_ATTR;
229void lcd_update_rect(int x, int y, int width, int height)
230{
231 int ymax;
232
233 /* The Y coordinates have to work on even 8 pixel rows */
234 ymax = (y + height-1) >> 3;
235 y >>= 3;
236
237 if(x + width > LCD_WIDTH)
238 width = LCD_WIDTH - x;
239 if (width <= 0)
240 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
241 if(ymax >= LCD_FBHEIGHT)
242 ymax = LCD_FBHEIGHT-1;
243
244 /* Copy specified rectange bitmap to hardware */
245 for (; y <= ymax; y++)
246 {
247 lcd_write_command (LCD_CNTL_PAGE | (y & 0xf));
248 lcd_write_command (LCD_CNTL_HIGHCOL | (((x+xoffset) >> 4) & 0xf));
249 lcd_write_command (LCD_CNTL_LOWCOL | ((x+xoffset) & 0xf));
250
251 lcd_write_data (&lcd_framebuffer[y][x], width);
252 }
253}
diff --git a/firmware/target/arm/tcc77x/logikdax/power-logikdax.c b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
new file mode 100644
index 0000000000..df2ee10d6b
--- /dev/null
+++ b/firmware/target/arm/tcc77x/logikdax/power-logikdax.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include "config.h"
20#include "cpu.h"
21#include <stdbool.h>
22#include "kernel.h"
23#include "system.h"
24#include "power.h"
25
26#ifndef SIMULATOR
27
28void power_init(void)
29{
30}
31
32void ide_power_enable(bool on)
33{
34}
35
36bool ide_powered(void)
37{
38 return true;
39}
40
41void power_off(void)
42{
43}
44
45#else /* SIMULATOR */
46
47bool charger_inserted(void)
48{
49 return false;
50}
51
52void charger_enable(bool on)
53{
54 (void)on;
55}
56
57void power_off(void)
58{
59}
60
61void ide_power_enable(bool on)
62{
63 (void)on;
64}
65
66#endif /* SIMULATOR */
diff --git a/firmware/target/arm/tcc77x/system-target.h b/firmware/target/arm/tcc77x/system-target.h
new file mode 100644
index 0000000000..0df92e3263
--- /dev/null
+++ b/firmware/target/arm/tcc77x/system-target.h
@@ -0,0 +1,35 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef SYSTEM_TARGET_H
20#define SYSTEM_TARGET_H
21
22#include "system-arm.h"
23
24#define CPUFREQ_DEFAULT 98784000
25#define CPUFREQ_NORMAL 98784000
26#define CPUFREQ_MAX 120000000
27
28#define inl(a) (*(volatile unsigned long *) (a))
29#define outl(a,b) (*(volatile unsigned long *) (b) = (a))
30#define inb(a) (*(volatile unsigned char *) (a))
31#define outb(a,b) (*(volatile unsigned char *) (b) = (a))
32#define inw(a) (*(volatile unsigned short *) (a))
33#define outw(a,b) (*(volatile unsigned short *) (b) = (a))
34
35#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/tcc77x/system-tcc77x.c b/firmware/target/arm/tcc77x/system-tcc77x.c
new file mode 100644
index 0000000000..baa1641c78
--- /dev/null
+++ b/firmware/target/arm/tcc77x/system-tcc77x.c
@@ -0,0 +1,136 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Dave Chapman
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include "kernel.h"
21#include "system.h"
22#include "panic.h"
23
24void system_reboot(void)
25{
26}
27
28/* TODO - these should live in the target-specific directories and
29 once we understand what all the GPIO pins do, move the init to the
30 specific driver for that hardware. For now, we just perform the
31 same GPIO init as the original firmware - this makes it easier to
32 investigate what the GPIO pins do.
33*/
34
35#ifdef LOGIK_DAX
36static void gpio_init(void)
37{
38 /* Do what the original firmware does */
39 GPIOD_FUNC = 0;
40 GPIOD_DIR = 0x3f0;
41 GPIOD = 0xe0;
42 GPIOE_FUNC = 0;
43 GPIOE_DIR = 0xe0;
44 GPIOE = 0;
45 GPIOA_FUNC = 0;
46 GPIOA_DIR = 0xffff1000; /* 0 - 0xf000 */
47 GPIOA = 0x1080;
48 GPIOB_FUNC = 0x16a3;
49 GPIOB_DIR = 0x6ffff;
50 GPIOB = 0;
51 GPIOC_FUNC = 1;
52 GPIOC_DIR = 0x03ffffff; /* mvn r2, 0xfc000000 */
53 GPIOC = 0;
54}
55#elif defined(IAUDIO_7)
56static void gpio_init(void)
57{
58 /* Do what the original firmware does */
59 GPIOA_FUNC = 0;
60 GPIOB_FUNC = 0x1623;
61 GPIOC_FUNC = 1;
62 GPIOD_FUNC = 0;
63 GPIOE_FUNC = 0;
64 GPIOA = 0x30;
65 GPIOB = 0x80000;
66 GPIOC = 0;
67 GPIOD = 0x180;
68 GPIOE = 0;
69 GPIOA_DIR = 0x84b0
70 GPIOB_DIR = 0x80800;
71 GPIOC_DIR = 0x2000000;
72 GPIOD_DIR = 0x3e3;
73 GPIOE_DIR = 0x88;
74}
75#endif
76
77/* Second function called in the original firmware's startup code - we just
78 set up the clocks in the same way as the original firmware for now. */
79static void clock_init(void)
80{
81 unsigned int i;
82
83 CSCFG3 = (CSCFG3 &~ 0x3fff) | 0x820;
84
85 CLKCTRL = (CLKCTRL & ~0xff) | 0x14;
86
87 if (BMI & 0x20)
88 PCLKCFG0 = 0xc82d7000;
89 else
90 PCLKCFG0 = 0xc8ba7000;
91
92 MCFG |= 0x2000;
93
94#ifdef LOGIK_DAX
95 /* Only seen in the Logik DAX original firmware */
96 SDCFG = (SDCFG & ~0x7000) | 0x2000;
97#endif
98
99 PLL0CFG |= 0x80000000;
100
101 PLL0CFG = 0x0000cf13;
102
103 i = 8000;
104 while (--i) {};
105
106 CLKDIV0 = 0x81000000;
107 CLKCTRL = 0x80000010;
108
109 asm volatile (
110 "nop \n\t"
111 "nop \n\t"
112 );
113}
114
115
116void system_init(void)
117{
118 /* TODO: cache init - the original firmwares have cache init code which
119 is called at the very start of the firmware */
120 clock_init();
121 gpio_init();
122}
123
124int system_memory_guard(int newmode)
125{
126 (void)newmode;
127 return 0;
128}
129
130#ifdef HAVE_ADJUSTABLE_CPU_FREQ
131
132void set_cpu_frequency(long frequency)
133{
134}
135
136#endif