summaryrefslogtreecommitdiff
path: root/firmware/target/arm/tms320dm320
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-09-30 08:57:49 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-09-30 08:57:49 +0000
commit80f1688423eaad7a2ad9e4809331e192bcd0047d (patch)
tree716c8e3160daaa7f462cfe6cf6f848c41b61b2e6 /firmware/target/arm/tms320dm320
parenta5e788fe8533f6172b3d6b52d2430fe163f7a6fd (diff)
downloadrockbox-80f1688423eaad7a2ad9e4809331e192bcd0047d.tar.gz
rockbox-80f1688423eaad7a2ad9e4809331e192bcd0047d.zip
I got bullied in IRC by linuxstb and markun...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14909 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320')
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c46
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/adc-target.h38
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c131
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/ata-target.h70
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c50
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h31
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c96
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/button-target.h63
-rwxr-xr-xfirmware/target/arm/tms320dm320/mrobe-500/crt0.S206
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c63
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c206
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h21
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c95
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c77
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/spi-target.h29
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c210
-rwxr-xr-xfirmware/target/arm/tms320dm320/mrobe-500/system-target.h32
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c106
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/timer-target.h39
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c172
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/uart-target.h33
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c55
22 files changed, 1869 insertions, 0 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
new file mode 100644
index 0000000000..39d92d67b0
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-mr500.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "cpu.h"
21#include "adc-target.h"
22#include "kernel.h"
23
24/* prototypes */
25static void adc_tick(void);
26
27void adc_init(void)
28{
29 /* attach the adc reading to the tick */
30 tick_add_task(adc_tick);
31}
32
33/* Called to get the recent ADC reading */
34inline unsigned short adc_read(int channel)
35{
36 return (short)channel;
37}
38
39/* add this to the tick so that the ADC converts are done in the background */
40static void adc_tick(void)
41{
42}
43
44
45
46
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h b/firmware/target/arm/tms320dm320/mrobe-500/adc-target.h
new file mode 100644
index 0000000000..7d4713a186
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/adc-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 Karl Kurbjun
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 _ADC_TARGET_H_
21#define _ADC_TARGET_H_
22
23/* only two channels used by the Gigabeat */
24#define NUM_ADC_CHANNELS 2
25
26#define ADC_BATTERY 0
27#define ADC_HPREMOTE 1
28#define ADC_UNKNOWN_3 2
29#define ADC_UNKNOWN_4 3
30#define ADC_UNKNOWN_5 4
31#define ADC_UNKNOWN_6 5
32#define ADC_UNKNOWN_7 6
33#define ADC_UNKNOWN_8 7
34
35#define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */
36#define ADC_READ_ERROR 0xFFFF
37
38#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c
new file mode 100644
index 0000000000..47a8c61a45
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/ata-mr500.c
@@ -0,0 +1,131 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include "kernel.h"
23#include "thread.h"
24#include "system.h"
25#include "power.h"
26#include "panic.h"
27#include "pcf50606.h"
28#include "ata-target.h"
29#include "backlight-target.h"
30
31/* ARESET on C7C68300 and RESET on ATA interface (Active Low) */
32#define ATA_RESET_ENABLE (IO_GIO_BITCLR0 = 1 << 10)
33#define ATA_RESET_DISABLE (IO_GIO_BITSET0 = 1 << 10)
34
35/* ATA_EN on C7C68300 */
36#define USB_ATA_ENABLE (IO_GIO_BITSET0 = 1 << 2)
37#define USB_ATA_DISABLE (IO_GIO_BITCLR0 = 1 << 2)
38
39void ata_reset(void)
40{
41 ATA_RESET_ENABLE;
42 sleep(1); /* > 25us */
43 ATA_RESET_DISABLE;
44 sleep(1); /* > 2ms */
45}
46
47/* This function is called before enabling the USB bus */
48void ata_enable(bool on)
49{
50 if(on)
51 USB_ATA_DISABLE;
52 else
53 USB_ATA_ENABLE;
54}
55
56bool ata_is_coldstart(void)
57{
58 return true;
59}
60
61void ata_device_init(void)
62{
63 /* ATA reset */
64 ATA_RESET_DISABLE; /* Set the pin to disable an active low reset */
65 IO_GIO_DIR0&=~(1<<10);
66}
67
68#if 0
69void copy_read_sectors(unsigned char* buf, int wordcount)
70{
71 __buttonlight_trigger();
72
73 /* Unaligned transfer - slow copy */
74 if ( (unsigned long)buf & 1)
75 { /* not 16-bit aligned, copy byte by byte */
76 unsigned short tmp = 0;
77 unsigned char* bufend = buf + wordcount*2;
78 do
79 {
80 tmp = ATA_DATA;
81 *buf++ = tmp & 0xff; /* I assume big endian */
82 *buf++ = tmp >> 8; /* and don't use the SWAB16 macro */
83 } while (buf < bufend); /* tail loop is faster */
84 return;
85 }
86 /* This should never happen, but worth watching for */
87 if(wordcount > (1 << 18))
88 panicf("atd-meg-fx.c: copy_read_sectors: too many sectors per read!");
89
90//#define GIGABEAT_DEBUG_ATA
91#ifdef GIGABEAT_DEBUG_ATA
92 static int line = 0;
93 static char str[256];
94 snprintf(str, sizeof(str), "ODD DMA to %08x, %d", buf, wordcount);
95 lcd_puts(10, line, str);
96 line = (line+1) % 32;
97 lcd_update();
98#endif
99 /* Reset the channel */
100 DMASKTRIG0 |= 4;
101 /* Wait for DMA controller to be ready */
102 while(DMASKTRIG0 & 0x2)
103 ;
104 while(DSTAT0 & (1 << 20))
105 ;
106 /* Source is ATA_DATA, on AHB Bus, Fixed */
107 DISRC0 = (int) 0x18000000;
108 DISRCC0 = 0x1;
109 /* Dest mapped to physical address, on AHB bus, increment */
110 DIDST0 = (int) buf;
111 if(DIDST0 < 0x30000000)
112 DIDST0 += 0x30000000;
113 DIDSTC0 = 0;
114
115 /* DACK/DREQ Sync to AHB, Whole service, No reload, 16-bit transfers */
116 DCON0 = ((1 << 30) | (1<<27) | (1<<22) | (1<<20)) | wordcount;
117
118 /* Activate the channel */
119 DMASKTRIG0 = 0x2;
120
121 invalidate_dcache_range((void *)buf, wordcount*2);
122
123 /* Start DMA */
124 DMASKTRIG0 |= 0x1;
125
126 /* Wait for transfer to complete */
127 while((DSTAT0 & 0x000fffff))
128 priority_yield();
129 /* Dump cache for the buffer */
130}
131#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/ata-target.h b/firmware/target/arm/tms320dm320/mrobe-500/ata-target.h
new file mode 100644
index 0000000000..97b6f62c86
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/ata-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 Karl Kurbjun
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 ATA_TARGET_H
21#define ATA_TARGET_H
22
23/* Plain C read & write loops */
24#define PREFER_C_READING
25#define PREFER_C_WRITING
26
27#define ATA_IOBASE 0x50000000
28#define REGISTER_OFFSET (ATA_IOBASE+0x00400000) /* A21 = High */
29#define CONTROL_OFFSET (ATA_IOBASE+0x00800000) /* A22 = High */
30#define IDE_SHIFT 17
31#define ATA_DATA (*((volatile unsigned short*)(REGISTER_OFFSET + (0x00 << IDE_SHIFT))))
32#define ATA_ERROR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x01 << IDE_SHIFT))))
33#define ATA_NSECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x02 << IDE_SHIFT))))
34#define ATA_SECTOR (*((volatile unsigned char*)(REGISTER_OFFSET + (0x03 << IDE_SHIFT))))
35#define ATA_LCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x04 << IDE_SHIFT))))
36#define ATA_HCYL (*((volatile unsigned char*)(REGISTER_OFFSET + (0x05 << IDE_SHIFT))))
37#define ATA_SELECT (*((volatile unsigned char*)(REGISTER_OFFSET + (0x06 << IDE_SHIFT))))
38#define ATA_COMMAND (*((volatile unsigned char*)(REGISTER_OFFSET + (0x07 << IDE_SHIFT))))
39#define ATA_CONTROL (*((volatile unsigned char*)(CONTROL_OFFSET + (0x06 << IDE_SHIFT))))
40
41#define STATUS_BSY 0x80
42#define STATUS_RDY 0x40
43#define STATUS_DF 0x20
44#define STATUS_DRQ 0x08
45#define STATUS_ERR 0x01
46#define ERROR_ABRT 0x04
47
48#define WRITE_PATTERN1 0xa5
49#define WRITE_PATTERN2 0x5a
50#define WRITE_PATTERN3 0xaa
51#define WRITE_PATTERN4 0x55
52
53#define READ_PATTERN1 0xa5
54#define READ_PATTERN2 0x5a
55#define READ_PATTERN3 0xaa
56#define READ_PATTERN4 0x55
57
58#define READ_PATTERN1_MASK 0xff
59#define READ_PATTERN2_MASK 0xff
60#define READ_PATTERN3_MASK 0xff
61#define READ_PATTERN4_MASK 0xff
62
63#define SET_REG(reg,val) reg = (val)
64#define SET_16BITREG(reg,val) reg = (val)
65
66void ata_reset(void);
67void ata_device_init(void);
68bool ata_is_coldstart(void);
69
70#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
new file mode 100644
index 0000000000..3c80ede00d
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
@@ -0,0 +1,50 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "backlight-target.h"
24#include "backlight.h"
25#include "lcd.h"
26#include "power.h"
27
28void __backlight_on(void)
29{
30}
31
32void __backlight_off(void)
33{
34}
35
36/* Assumes that the backlight has been initialized */
37void __backlight_set_brightness(int brightness)
38{
39 (void) brightness;
40}
41
42void __backlight_dim(bool dim_now)
43{
44 (void) dim_now;
45}
46
47bool __backlight_init(void)
48{
49 return true;
50}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h b/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h
new file mode 100644
index 0000000000..783b9e1320
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 BACKLIGHT_TARGET_H
21#define BACKLIGHT_TARGET_H
22
23bool __backlight_init(void);
24void __backlight_on(void);
25void __backlight_off(void);
26void __backlight_set_brightness(int brightness);
27
28/* true: backlight fades off - false: backlight fades on */
29void __backlight_dim(bool dim);
30
31#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
new file mode 100644
index 0000000000..1d0d2714a8
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c
@@ -0,0 +1,96 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "button.h"
24#include "kernel.h"
25#include "backlight.h"
26#include "adc.h"
27#include "system.h"
28#include "backlight-target.h"
29#include "uart-target.h"
30
31#define BUTTON_TIMEOUT 50
32
33#define BUTTON_START_BYTE 0xF0
34#define BUTTON_START_BYTE2 0xF4 /* not sure why, but sometimes you get F0 or F4, */
35 /* but always the same one for the session? */
36
37void button_init_device(void)
38{
39 /* GIO is the power button, set as input */
40 IO_GIO_DIR0 |= 0x01;
41}
42
43inline bool button_hold(void)
44{
45 return false;
46}
47
48int button_read_device(void)
49{
50 char data[5], c;
51 int i = 0;
52 int btn = BUTTON_NONE;
53
54 if ((IO_GIO_BITSET0&0x01) == 0)
55 btn |= BUTTON_POWER;
56
57 uart1_heartbeat();
58 while (uartAvailable())
59 {
60 if (uart1_getch(&c))
61 {
62 if (i && (data[0] == BUTTON_START_BYTE || data[0] == BUTTON_START_BYTE2))
63 {
64 data[i++] = c;
65 }
66 else if (c == BUTTON_START_BYTE ||
67 c == BUTTON_START_BYTE2)
68 {
69 data[0] = c;
70 i = 1;
71 }
72
73 if (i == 5)
74 {
75 if (data[1]& (1<<7))
76 btn |= BUTTON_RC_HEART;
77 if (data[1]& (1<<6))
78 btn |= BUTTON_RC_MODE;
79 if (data[1]& (1<<5))
80 btn |= BUTTON_RC_VOL_DOWN;
81 if (data[1]& (1<<4))
82 btn |= BUTTON_RC_VOL_UP;
83 if (data[1]& (1<<3))
84 btn |= BUTTON_RC_REW;
85 if (data[1]& (1<<2))
86 btn |= BUTTON_RC_FF;
87 if (data[1]& (1<<1))
88 btn |= BUTTON_RC_DOWN;
89 if (data[1]& (1<<0))
90 btn |= BUTTON_RC_PLAY;
91 break;
92 }
93 }
94 }
95 return btn;
96}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
new file mode 100644
index 0000000000..f574321717
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Jonathan Gordon
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#define HAS_BUTTON_HOLD
27
28bool button_hold(void);
29void button_init_device(void);
30int button_read_device(void);
31
32/* m:robe 500 specific button codes */
33
34#define BUTTON_POWER 0x00000001
35
36/* Remote control buttons */
37
38#define BUTTON_RC_HEART 0x00000002
39#define BUTTON_RC_MODE 0x00000004
40#define BUTTON_RC_VOL_DOWN 0x00000008
41#define BUTTON_RC_VOL_UP 0x00000010
42
43
44#define BUTTON_RC_PLAY 0x00000020
45#define BUTTON_RC_REW 0x00000040
46#define BUTTON_RC_FF 0x00000080
47#define BUTTON_RC_DOWN 0x00000100
48#define BUTTON_TOUCH 0x00000200
49
50/* compatibility hacks */
51#define BUTTON_LEFT BUTTON_RC_REW
52#define BUTTON_RIGHT BUTTON_RC_FF
53#define POWEROFF_BUTTON BUTTON_POWER
54#define POWEROFF_COUNT 40
55
56#define BUTTON_MAIN BUTTON_POWER
57
58#define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \
59 BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \
60 BUTTON_RC_PLAY|BUTTON_RC_DOWN| \
61 BUTTON_RC_REW|BUTTON_RC_FF)
62
63#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/crt0.S b/firmware/target/arm/tms320dm320/mrobe-500/crt0.S
new file mode 100755
index 0000000000..193470fd4a
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/crt0.S
@@ -0,0 +1,206 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Linus Nielsen Feltzing
11 *
12 * Arm bootloader and startup code based on startup.s from the iPodLinux loader
13 *
14 * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org)
15 * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org>
16 *
17 * All files in this archive are subject to the GNU General Public License.
18 * See the file COPYING in the source tree root for full license agreement.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24#include "config.h"
25#include "cpu.h"
26
27 .section .init.text,"ax",%progbits
28
29 .global start
30start:
31 msr cpsr, #0xd3 /* enter supervisor mode, disable IRQ */
32
33#if !defined(DEBUG)
34 /* Copy exception handler code to address 0 */
35 ldr r2, =_vectorsstart
36 ldr r3, =_vectorsend
37 ldr r4, =_vectorscopy
381:
39 cmp r3, r2
40 ldrhi r5, [r4], #4
41 strhi r5, [r2], #4
42 bhi 1b
43#else
44 ldr r1, =vectors
45 ldr r0, =irq_handler
46 str r0, [r1, #24]
47 ldr r0, =fiq_handler
48 str r0, [r1, #28]
49#endif
50
51 /* Disable high vectors (at 0xffff0000 instead of 0x00000000) */
52 mrc p15, 0, r0, c1, c0
53 and r0, r0, #~(1<<13)
54 mcr p15, 0, r0, c1, c0
55
56#if !defined(BOOTLOADER)
57
58#if !defined(STUB)
59 /* Zero out IBSS */
60 ldr r2, =_iedata
61 ldr r3, =_iend
62 mov r4, #0
631:
64 cmp r3, r2
65 strhi r4, [r2], #4
66 bhi 1b
67
68 /* Copy the IRAM */
69 ldr r2, =_iramcopy
70 ldr r3, =_iramstart
71 ldr r4, =_iramend
721:
73 cmp r4, r3
74 ldrhi r5, [r2], #4
75 strhi r5, [r3], #4
76 bhi 1b
77#endif /* !STUB */
78#endif /* !BOOTLOADER */
79
80 /* Initialise bss section to zero */
81 ldr r2, =_edata
82 ldr r3, =_end
83 mov r4, #0
841:
85 cmp r3, r2
86 strhi r4, [r2], #4
87 bhi 1b
88
89 /* Set up some stack and munge it with 0xdeadbeef */
90 ldr r3, =stackend
91 ldr r2, =stackbegin
92 ldr r4, =0xdeadbeef
931:
94 cmp r3, r2
95 strhi r4, [r2], #4
96 bhi 1b
97
98 /* Set up stack for IRQ mode */
99 msr cpsr_c, #0xd2
100 ldr sp, =irq_stack
101 /* Set up stack for FIQ mode */
102 msr cpsr_c, #0xd1
103 ldr sp, =fiq_stack
104
105 /* Let abort and undefined modes use IRQ stack */
106 msr cpsr_c, #0xd7
107 ldr sp, =irq_stack
108 msr cpsr_c, #0xdb
109 ldr sp, =irq_stack
110 /* Switch to supervisor mode (no IRQ) */
111 msr cpsr_c, #0xd3
112 ldr sp, =stackend
113
114#ifdef BOOTLOADER
115 /* get the high part of our execute address */
116 ldr r2, =0xffffff00
117 and r4, pc, r2
118
119 /* Copy bootloader to safe area - 0x01900000 */
120 mov r5, #0x00900000
121 add r5, r5, #0x01000000
122 ldr r6, = _dataend
123 sub r0, r6, r5 /* length of loader */
124 add r0, r4, r0 /* r0 points to start of loader */
1251:
126 cmp r5, r6
127 ldrcc r2, [r4], #4
128 strcc r2, [r5], #4
129 bcc 1b
130
131 ldr pc, =start_loc /* jump to the relocated start_loc: */
132
133#endif
134
135start_loc:
136 bl main
137 /* main() should never return */
138
139/* Exception handlers. Will be copied to address 0 after memory remapping */
140 .section .vectors,"aw"
141 ldr pc, [pc, #24]
142 ldr pc, [pc, #24]
143 ldr pc, [pc, #24]
144 ldr pc, [pc, #24]
145 ldr pc, [pc, #24]
146 ldr pc, [pc, #24]
147 ldr pc, [pc, #24]
148 ldr pc, [pc, #24]
149
150 /* Exception vectors */
151 .global vectors
152vectors:
153 .word start
154 .word undef_instr_handler
155 .word software_int_handler
156 .word prefetch_abort_handler
157 .word data_abort_handler
158 .word reserved_handler
159 .word irq_handler
160 .word fiq_handler
161
162 .text
163
164#if !defined(STUB)
165 .global irq
166 .global fiq
167 .global UIE
168#endif
169
170/* All illegal exceptions call into UIE with exception address as first
171 parameter. This is calculated differently depending on which exception
172 we're in. Second parameter is exception number, used for a string lookup
173 in UIE.
174 */
175undef_instr_handler:
176 mov r0, lr
177 mov r1, #0
178 b UIE
179
180/* We run supervisor mode most of the time, and should never see a software
181 exception being thrown. Perhaps make it illegal and call UIE?
182 */
183software_int_handler:
184reserved_handler:
185 movs pc, lr
186
187prefetch_abort_handler:
188 sub r0, lr, #4
189 mov r1, #1
190 b UIE
191
192data_abort_handler:
193 sub r0, lr, #8
194 mov r1, #2
195 b UIE
196
197UIE:
198 b UIE
199
200/* 256 words of IRQ stack */
201 .space 256*4
202irq_stack:
203
204/* 256 words of FIQ stack */
205 .space 256*4
206fiq_stack:
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c
new file mode 100644
index 0000000000..be2b14b3cb
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/kernel-mr500.c
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "system.h"
22#include "kernel.h"
23#include "timer.h"
24#include "thread.h"
25
26extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
27
28void tick_start(unsigned int interval_in_ms)
29{
30 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
31
32 /* Setup the Prescalar (Divide by 10)
33 * Based on linux/include/asm-arm/arch-integrator/timex.h
34 */
35 IO_TIMER1_TMPRSCL = 0x000A;
36
37 /* Setup the Divisor */
38 IO_TIMER1_TMDIV = (TIMER_FREQ / (10*1000))*interval_in_ms;
39
40 /* Turn Timer1 to Free Run mode */
41 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_FREE_RUN;
42
43 /* Enable the interrupt */
44 IO_INTC_EINT0 |= 1<<IRQ_TIMER1;
45}
46
47void TIMER1(void)
48{
49 int i;
50
51 /* Run through the list of tick tasks */
52 for(i = 0; i < MAX_NUM_TICK_TASKS; i++)
53 {
54 if(tick_funcs[i])
55 {
56 tick_funcs[i]();
57 }
58 }
59
60 current_tick++;
61
62 IO_INTC_IRQ0 = 1<<IRQ_TIMER1;
63}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
new file mode 100644
index 0000000000..6c06e070f9
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -0,0 +1,206 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
12 * Some of this is based on the Cowon A2 Firmware release:
13 * http://www.cowonglobal.com/download/gnu/cowon_pmp_a2_src_1.59_GPL.tar.gz
14 *
15 * All files in this archive are subject to the GNU General Public License.
16 * See the file COPYING in the source tree root for full license agreement.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ****************************************************************************/
22
23#include "config.h"
24#include "cpu.h"
25#include "string.h"
26#include "lcd.h"
27#include "kernel.h"
28#include "memory.h"
29#include "system-target.h"
30
31static volatile bool lcd_on = true;
32volatile bool lcd_poweroff = false;
33/*
34** These are imported from lcd-16bit.c
35*/
36extern unsigned fg_pattern;
37extern unsigned bg_pattern;
38
39bool lcd_enabled(void)
40{
41 return lcd_on;
42}
43
44/* LCD init - based on code from ingenient-bsp/bootloader/board/dm320/splash.c
45 * and code by Catalin Patulea from the M:Robe 500i linux port
46 */
47void lcd_init_device(void)
48{
49 unsigned int addr;
50
51 /* Clear the Frame */
52 memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT);
53
54 outw(0x00ff, IO_OSD_MODE);
55 outw(0x0002, IO_OSD_VIDWINMD);
56 outw(0x2001, IO_OSD_OSDWINMD0);
57 outw(0x0002, IO_OSD_OSDWINMD1);
58 outw(0x0000, IO_OSD_ATRMD);
59 outw(0x0000, IO_OSD_RECTCUR);
60
61 outw((480*2) / 32, IO_OSD_OSDWIN0OFST);
62 addr = ((int)FRAME-CONFIG_SDRAM_START) / 32;
63 outw(addr >> 16, IO_OSD_OSDWINADH);
64 outw(addr & 0xFFFF, IO_OSD_OSDWIN0ADL);
65
66 outw(80, IO_OSD_BASEPX);
67 outw(2, IO_OSD_BASEPY);
68
69 outw(0, IO_OSD_OSDWIN0XP);
70 outw(0, IO_OSD_OSDWIN0YP);
71 outw(480, IO_OSD_OSDWIN0XL);
72 outw(640, IO_OSD_OSDWIN0YL);
73}
74
75/* Update a fraction of the display. */
76void lcd_update_rect(int x, int y, int width, int height)
77{
78 fb_data *dst, *src;
79
80 if (!lcd_on)
81 return;
82
83 if (x + width > LCD_WIDTH)
84 width = LCD_WIDTH - x; /* Clip right */
85 if (x < 0)
86 width += x, x = 0; /* Clip left */
87 if (width <= 0)
88 return; /* nothing left to do */
89
90 if (y + height > LCD_HEIGHT)
91 height = LCD_HEIGHT - y; /* Clip bottom */
92 if (y < 0)
93 height += y, y = 0; /* Clip top */
94 if (height <= 0)
95 return; /* nothing left to do */
96
97 dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
98 src = &lcd_framebuffer[y][x];
99
100 /* Copy part of the Rockbox framebuffer to the second framebuffer */
101 if (width < LCD_WIDTH)
102 {
103 int y;
104 /* Not full width - do line-by-line */
105 for(y=0;y<height;y++)
106 {
107 memcpy(dst, src, width*sizeof(fb_data));
108 dst+=LCD_WIDTH;
109 src+=LCD_WIDTH;
110 }
111 }
112 else
113 {
114 /* Full width - copy as one line */
115 memcpy(dst, src, LCD_WIDTH*height*sizeof(fb_data));
116 }
117}
118
119void lcd_enable(bool state)
120{
121 (void)state;
122}
123
124/* Update the display.
125 This must be called after all other LCD functions that change the display. */
126void lcd_update(void)
127{
128 if (!lcd_on)
129 return;
130
131 memcpy((fb_data *)FRAME, &lcd_framebuffer[0][0],
132 LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data));
133}
134
135/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
136extern void lcd_write_yuv420_lines(fb_data *dst,
137 unsigned char chroma_buf[LCD_HEIGHT/2*3],
138 unsigned char const * const src[3],
139 int width,
140 int stride);
141/* Performance function to blit a YUV bitmap directly to the LCD */
142/* For the Gigabeat - show it rotated */
143/* So the LCD_WIDTH is now the height */
144void lcd_yuv_blit(unsigned char * const src[3],
145 int src_x, int src_y, int stride,
146 int x, int y, int width, int height)
147{
148 /* Caches for chroma data so it only need be recaculated every other
149 line */
150 unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */
151 unsigned char const * yuv_src[3];
152 off_t z;
153
154 if (!lcd_on)
155 return;
156
157 /* Sorry, but width and height must be >= 2 or else */
158 width &= ~1;
159 height >>= 1;
160
161 fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
162
163 z = stride*src_y;
164 yuv_src[0] = src[0] + z + src_x;
165 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
166 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
167
168 do
169 {
170 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
171 stride);
172 yuv_src[0] += stride << 1; /* Skip down two luma lines */
173 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
174 yuv_src[2] += stride >> 1;
175 dst -= 2;
176 }
177 while (--height > 0);
178}
179
180void lcd_set_contrast(int val) {
181 (void) val;
182 // TODO:
183}
184
185void lcd_set_invert_display(bool yesno) {
186 (void) yesno;
187 // TODO:
188}
189
190void lcd_blit(const fb_data* data, int bx, int y, int bwidth,
191 int height, int stride)
192{
193 (void) data;
194 (void) bx;
195 (void) y;
196 (void) bwidth;
197 (void) height;
198 (void) stride;
199 //TODO:
200}
201
202void lcd_set_flip(bool yesno) {
203 (void) yesno;
204 // TODO:
205}
206
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h b/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h
new file mode 100644
index 0000000000..c64cc56276
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-target.h
@@ -0,0 +1,21 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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
20extern void lcd_enable(bool state);
21
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
new file mode 100644
index 0000000000..3a6dad77f4
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
@@ -0,0 +1,95 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include <stdbool.h>
23#include "kernel.h"
24#include "system.h"
25#include "power.h"
26#include "pcf50606.h"
27#include "backlight.h"
28#include "backlight-target.h"
29
30#ifndef SIMULATOR
31
32void power_init(void)
33{
34 /* Initialize IDE power pin */
35 /* set GIO17 (ATA power) on and output */
36 ide_power_enable(true);
37 IO_GIO_DIR1&=~(1<<1);
38 /* Charger detect */
39}
40
41bool charger_inserted(void)
42{
43 return false;
44}
45
46/* Returns true if the unit is charging the batteries. */
47bool charging_state(void) {
48 return false;
49}
50
51void ide_power_enable(bool on)
52{
53 if (on)
54 IO_GIO_BITCLR1=(1<<1);
55 else
56 IO_GIO_BITSET1=(1<<1);
57}
58
59bool ide_powered(void)
60{
61 return !(IO_GIO_BITSET1&(1<<1));
62}
63
64void power_off(void)
65{
66 /* turn off backlight and wait for 1 second */
67 __backlight_off();
68 sleep(HZ);
69 /* Hard shutdown */
70 IO_GIO_BITSET1|=1<<10;
71}
72
73#else /* SIMULATOR */
74
75bool charger_inserted(void)
76{
77 return false;
78}
79
80void charger_enable(bool on)
81{
82 (void)on;
83}
84
85void power_off(void)
86{
87}
88
89void ide_power_enable(bool on)
90{
91 (void)on;
92}
93
94#endif /* SIMULATOR */
95
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c
new file mode 100644
index 0000000000..c47ab8f6ed
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/spi-mr500.c
@@ -0,0 +1,77 @@
1/*
2 * SPI interface driver for the DM320 SoC
3 *
4 * Copyright (C) 2007 shirour <mrobefan@gmail.com>
5 * Copyright (C) 2007 Catalin Patulea <cat@vv.carleton.ca>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
13 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
15 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
18 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
19 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 675 Mass Ave, Cambridge, MA 02139, USA.
26 */
27
28#include "system.h"
29
30#define GIO_TS_ENABLE (1<<2)
31#define clr_gio_enable() IO_GIO_BITSET1=GIO_TS_ENABLE
32#define set_gio_enable() IO_GIO_BITCLR1=GIO_TS_ENABLE
33
34int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
35 uint8_t *rx_bytes, unsigned int rx_size)
36{
37 /* Activate the slave select pin */
38 set_gio_enable();
39
40 while (tx_size--)
41 {
42 /* Send one byte */
43 IO_SERIAL0_TX_DATA = *tx_bytes++;
44
45 /* Wait until transfer finished */
46 while (IO_SERIAL0_RX_DATA & 0x100);
47 }
48
49 while (rx_size--)
50 {
51 /* Make the clock tick */
52 IO_SERIAL0_TX_DATA = 0;
53
54 /* Wait until transfer finished */
55 unsigned short data;
56 while ((data = IO_SERIAL0_RX_DATA) & 0x100);
57
58 *rx_bytes++ = data & 0xff;
59 }
60
61 clr_gio_enable();
62
63 return 0;
64}
65
66void spi_init(void)
67{
68 /* Set SCLK idle level = 0 */
69 IO_SERIAL0_MODE |= (1<<10);
70
71 /* Enable TX */
72 IO_SERIAL0_TX_ENABLE = 0x0001;
73
74 /* Set GIO 18 to output for touch screen slave enable */
75 IO_GIO_DIR1&=~GIO_TS_ENABLE;
76 clr_gio_enable();
77}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h b/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h
new file mode 100644
index 0000000000..866919dc27
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/spi-target.h
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Catalin Patulea
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 SPI_TARGET_H
21#define SPI_TARGET_H
22
23#include <inttypes.h>
24
25void spi_init(void);
26int spi_block_transfer(const uint8_t *tx_bytes, unsigned int tx_size,
27 uint8_t *rx_bytes, unsigned int rx_size);
28
29#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c
new file mode 100644
index 0000000000..fad2d4331e
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/system-mr500.c
@@ -0,0 +1,210 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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
24#define default_interrupt(name) \
25 extern __attribute__((weak,alias("UIRQ"))) void name (void)
26
27default_interrupt(TIMER0);
28default_interrupt(TIMER1);
29default_interrupt(TIMER2);
30default_interrupt(TIMER3);
31default_interrupt(CCD_VD0);
32default_interrupt(CCD_VD1);
33default_interrupt(CCD_WEN);
34default_interrupt(VENC);
35default_interrupt(SERIAL0);
36default_interrupt(SERIAL1);
37default_interrupt(EXT_HOST);
38default_interrupt(DSPHINT);
39default_interrupt(UART0);
40default_interrupt(UART1);
41default_interrupt(USB_DMA);
42default_interrupt(USB_CORE);
43default_interrupt(VLYNQ);
44default_interrupt(MTC0);
45default_interrupt(MTC1);
46default_interrupt(SD_MMC);
47default_interrupt(SDIO_MS);
48default_interrupt(GIO0);
49default_interrupt(GIO1);
50default_interrupt(GIO2);
51default_interrupt(GIO3);
52default_interrupt(GIO4);
53default_interrupt(GIO5);
54default_interrupt(GIO6);
55default_interrupt(GIO7);
56default_interrupt(GIO8);
57default_interrupt(GIO9);
58default_interrupt(GIO10);
59default_interrupt(GIO11);
60default_interrupt(GIO12);
61default_interrupt(GIO13);
62default_interrupt(GIO14);
63default_interrupt(GIO15);
64default_interrupt(PREVIEW0);
65default_interrupt(PREVIEW1);
66default_interrupt(WATCHDOG);
67default_interrupt(I2C);
68default_interrupt(CLKC);
69default_interrupt(ICE);
70default_interrupt(ARMCOM_RX);
71default_interrupt(ARMCOM_TX);
72default_interrupt(RESERVED);
73
74static void (* const irqvector[])(void) =
75{
76 TIMER0,TIMER1,TIMER2,TIMER3,CCD_VD0,CCD_VD1,
77 CCD_WEN,VENC,SERIAL0,SERIAL1,EXT_HOST,DSPHINT,
78 UART0,UART1,USB_DMA,USB_CORE,VLYNQ,MTC0,MTC1,
79 SD_MMC,SDIO_MS,GIO0,GIO1,GIO2,GIO3,GIO4,GIO5,
80 GIO6,GIO7,GIO8,GIO9,GIO10,GIO11,GIO12,GIO13,
81 GIO14,GIO15,PREVIEW0,PREVIEW1,WATCHDOG,I2C,CLKC,
82 ICE,ARMCOM_RX,ARMCOM_TX,RESERVED
83};
84
85static const char * const irqname[] =
86{
87 "TIMER0","TIMER1","TIMER2","TIMER3","CCD_VD0","CCD_VD1",
88 "CCD_WEN","VENC","SERIAL0","SERIAL1","EXT_HOST","DSPHINT",
89 "UART0","UART1","USB_DMA","USB_CORE","VLYNQ","MTC0","MTC1",
90 "SD_MMC","SDIO_MS","GIO0","GIO1","GIO2","GIO3","GIO4","GIO5",
91 "GIO6","GIO7","GIO8","GIO9","GIO10","GIO11","GIO12","GIO13",
92 "GIO14","GIO15","PREVIEW0","PREVIEW1","WATCHDOG","I2C","CLKC",
93 "ICE","ARMCOM_RX","ARMCOM_TX","RESERVED"
94};
95
96static void UIRQ(void)
97{
98 unsigned int offset = (IO_INTC_IRQENTRY0>>2)-1;
99 panicf("Unhandled IRQ %02X: %s", offset, irqname[offset]);
100}
101
102void irq_handler(void) __attribute__((interrupt ("IRQ"), naked));
103void irq_handler(void)
104{
105 /*
106 * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
107 */
108
109 asm volatile( "stmfd sp!, {r0-r7, ip, lr} \n" /* Store context */
110 "sub sp, sp, #8 \n"); /* Reserve stack */
111 irqvector[(IO_INTC_IRQENTRY0>>2)-1]();
112 asm volatile( "add sp, sp, #8 \n" /* Cleanup stack */
113 "ldmfd sp!, {r0-r7, ip, lr} \n" /* Restore context */
114 "subs pc, lr, #4 \n"); /* Return from FIQ */
115}
116
117void fiq_handler(void) __attribute__((interrupt ("FIQ"), naked));
118void fiq_handler(void)
119{
120 /*
121 * Based on: linux/arch/arm/kernel/entry-armv.S and system-meg-fx.c
122 */
123
124 asm volatile (
125 "sub lr, lr, #4 \r\n"
126 "stmfd sp!, {r0-r3, ip, lr} \r\n"
127 "mov r0, #0x00030000 \r\n"
128 "ldr r0, [r0, #0x518] \r\n"
129 "ldr r1, =irqvector \r\n"
130 "ldr r1, [r1, r0, lsl #2] \r\n"
131 "mov lr, pc \r\n"
132 "bx r1 \r\n"
133 "ldmfd sp!, {r0-r3, ip, pc}^ \r\n"
134 );
135}
136
137void system_reboot(void)
138{
139
140}
141
142void enable_interrupts (void)
143{
144 asm volatile ("msr cpsr_c, #0x13" );
145}
146
147void system_init(void)
148{
149 /* taken from linux/arch/arm/mach-itdm320-20/irq.c */
150
151 /* Clearing all FIQs and IRQs. */
152 IO_INTC_IRQ0 = 0xFFFF;
153 IO_INTC_IRQ1 = 0xFFFF;
154 IO_INTC_IRQ2 = 0xFFFF;
155
156 IO_INTC_FIQ0 = 0xFFFF;
157 IO_INTC_FIQ1 = 0xFFFF;
158 IO_INTC_FIQ2 = 0xFFFF;
159
160 /* Masking all Interrupts. */
161 IO_INTC_EINT0 = 0;
162 IO_INTC_EINT1 = 0;
163 IO_INTC_EINT2 = 0;
164
165 /* Setting INTC to all IRQs. */
166 IO_INTC_FISEL0 = 0;
167 IO_INTC_FISEL1 = 0;
168 IO_INTC_FISEL2 = 0;
169
170 IO_INTC_ENTRY_TBA0 =
171 IO_INTC_ENTRY_TBA1 = 0;
172
173 /* set GIO26 (reset pin) to output and low */
174 IO_GIO_BITCLR1=(1<<10);
175 IO_GIO_DIR1&=~(1<<10);
176
177 enable_interrupts();
178}
179
180int system_memory_guard(int newmode)
181{
182 (void)newmode;
183 return 0;
184}
185
186#ifdef HAVE_ADJUSTABLE_CPU_FREQ
187
188void set_cpu_frequency(long frequency)
189{
190 if (frequency == CPUFREQ_MAX)
191 {
192 asm volatile("mov r0, #0\n"
193 "mrc p15, 0, r0, c1, c0, 0\n"
194 "orr r0, r0, #3<<30\n" /* set to Asynchronous mode*/
195 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
196
197 FREQ = CPUFREQ_MAX;
198 }
199 else
200 {
201 asm volatile("mov r0, #0\n"
202 "mrc p15, 0, r0, c1, c0, 0\n"
203 "bic r0, r0, #3<<30\n" /* set to FastBus mode*/
204 "mcr p15, 0, r0, c1, c0, 0" : : : "r0");
205
206 FREQ = CPUFREQ_NORMAL;
207 }
208}
209
210#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/system-target.h b/firmware/target/arm/tms320dm320/mrobe-500/system-target.h
new file mode 100755
index 0000000000..7adfda6f7d
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/system-target.h
@@ -0,0 +1,32 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Karl Kurbjun
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_SLEEP 32768
25#define CPUFREQ_DEFAULT 24000000
26#define CPUFREQ_NORMAL 30000000
27#define CPUFREQ_MAX 80000000
28
29#define inw(p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)))
30#define outw(v,p) (*((volatile unsigned short*)((p) + PHY_IO_BASE)) = (v))
31
32#endif /* SYSTEM_TARGET_H */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c
new file mode 100644
index 0000000000..21449ed19f
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/timer-mr500.c
@@ -0,0 +1,106 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "timer.h"
24#include "logf.h"
25
26/* GPB0/TOUT0 should already have been configured as output so that pin
27 should not be a functional pin and TIMER0 output unseen there */
28void TIMER0(void)
29{
30 if (pfn_timer != NULL)
31 pfn_timer();
32 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
33}
34
35static void stop_timer(void)
36{
37 IO_INTC_EINT0 &= ~(1<<IRQ_TIMER0);
38
39 IO_INTC_IRQ0 |= 1<<IRQ_TIMER0;
40
41 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
42}
43
44bool __timer_set(long cycles, bool start)
45{
46 int oldlevel;
47 unsigned int divider;
48 /* taken from linux/arch/arm/mach-itdm320-20/time.c and timer-meg-fx.c */
49
50 /* Turn off all timers */
51 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_STOP;
52 IO_TIMER1_TMMD = CONFIG_TIMER1_TMMD_STOP;
53 IO_TIMER2_TMMD = CONFIG_TIMER2_TMMD_STOP;
54 IO_TIMER3_TMMD = CONFIG_TIMER3_TMMD_STOP;
55
56 /* Find the minimum factor that puts the counter in range 1-65535 */
57 unsigned int prescaler = (cycles + 65534) / 65535;
58
59 /* Test this by writing 1's to registers to see how many bits we have */
60 /* Maximum divider setting is x / 1024 / 65536 = x / 67108864 */
61 if (start && pfn_unregister != NULL)
62 {
63 pfn_unregister();
64 pfn_unregister = NULL;
65 }
66
67 oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
68
69 /* Max prescale is 1023+1 */
70 for (divider = 0; prescaler > 1024; prescaler >>= 1, divider++);
71
72 /* Setup the Prescalar */
73 IO_TIMER0_TMPRSCL = prescaler;
74
75 /* Setup the Divisor */
76 IO_TIMER0_TMDIV = divider;
77
78 set_irq_level(oldlevel);
79
80 return true;
81}
82
83bool __timer_register(void)
84{
85 bool retval = true;
86
87 int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS);
88
89 stop_timer();
90
91 /* Turn Timer0 to Free Run mode */
92 IO_TIMER0_TMMD = CONFIG_TIMER0_TMMD_FREE_RUN;
93
94 IO_INTC_EINT0 |= 1<<IRQ_TIMER0;
95
96 set_interrupt_status(oldstatus, IRQ_FIQ_STATUS);
97
98 return retval;
99}
100
101void __timer_unregister(void)
102{
103 int oldstatus = set_interrupt_status(IRQ_FIQ_DISABLED, IRQ_FIQ_STATUS);
104 stop_timer();
105 set_interrupt_status(oldstatus, IRQ_FIQ_STATUS);
106}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/timer-target.h b/firmware/target/arm/tms320dm320/mrobe-500/timer-target.h
new file mode 100644
index 0000000000..4abe75ad82
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/timer-target.h
@@ -0,0 +1,39 @@
1/***************************************************************************
2* __________ __ ___.
3* Open \______ \ ____ ____ | | _\_ |__ _______ ___
4* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7* \/ \/ \/ \/ \/
8* $Id$
9*
10* Copyright (C) 2007 by Karl Kurbjun
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 TIMER_TARGET_H
20#define TIMER_TARGET_H
21
22/* timer is based on PCLK and minimum division is 2 */
23#define TIMER_FREQ (27000000)
24
25bool __timer_set(long cycles, bool set);
26bool __timer_register(void);
27void __timer_unregister(void);
28
29#define __TIMER_SET(cycles, set) \
30 __timer_set(cycles, set)
31
32#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
33 int_prio, timer_callback) \
34 __timer_register()
35
36#define __TIMER_UNREGISTER(...) \
37 __timer_unregister()
38
39#endif /* TIMER_TARGET_H */
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c
new file mode 100644
index 0000000000..66e59eaaac
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/uart-mr500.c
@@ -0,0 +1,172 @@
1/*
2 * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 *
19 */
20#include "config.h"
21#include "cpu.h"
22#include "system.h"
23
24/* UART 0/1 */
25
26#define CONFIG_UART_BRSR 87
27#define MAX_UART_BUFFER 32
28static unsigned char uart1buffer[MAX_UART_BUFFER];
29int uart1read = 0, uart1write = 0, uart1count = 0;
30
31void do_checksums(char *data, int len, char *xor, char *add)
32{
33 int i;
34 *xor = data[0];
35 *add = data[0];
36 for(i=1;i<len;i++)
37 {
38 *xor ^= data[i];
39 *add += data[i];
40 }
41}
42
43void uart_init(void)
44{
45 // 8-N-1
46 IO_UART1_MSR=0x8000;
47 IO_UART1_BRSR=CONFIG_UART_BRSR;
48 IO_UART1_RFCR = 0x8000;
49 /* gio 27 is input, uart1 rx
50 gio 28 is output, uart1 tx */
51 IO_GIO_DIR1 |= (1<<11); /* gio 27 */
52 IO_GIO_DIR1 &= ~(1<<12); /* gio 28 */
53
54 /* init the recieve buffer */
55 uart1read = 0;
56 uart1write = 0;
57 uart1count = 0;
58
59 /* Enable the interrupt */
60 IO_INTC_EINT0 |= (1<<IRQ_UART1);
61}
62
63void uartPutc(char ch) {
64 // Wait for room in FIFO
65 while ((IO_UART1_TFCR & 0x3f) >= 0x20);
66
67 // Write character
68 IO_UART1_DTRR=ch;
69}
70
71// Unsigned integer to ASCII hexadecimal conversion
72void uartPutHex(unsigned int n) {
73 unsigned int i;
74
75 for (i = 8; i != 0; i--) {
76 unsigned int digit = n >> 28;
77 uartPutc(digit >= 10 ? digit - 10 + 'A' : digit + '0');
78 n <<= 4;
79 }
80}
81
82void uartPuts(const char *str) {
83 char ch;
84 while ((ch = *str++) != '\0') {
85 uartPutc(ch);
86 }
87}
88
89void uartGets(char *str, unsigned int size) {
90 for (;;) {
91 char ch;
92
93 // Wait for FIFO to contain something
94 while ((IO_UART1_RFCR & 0x3f) == 0);
95
96 // Read character
97 ch = (char)IO_UART1_DTRR;
98
99 // Echo character back
100 IO_UART1_DTRR=ch;
101
102 // If CR, also echo LF, null-terminate, and return
103 if (ch == '\r') {
104 IO_UART1_DTRR='\n';
105 if (size) {
106 *str++ = '\0';
107 }
108 return;
109 }
110
111 // Append to buffer
112 if (size) {
113 *str++ = ch;
114 --size;
115 }
116 }
117}
118
119int uartPollch(unsigned int ticks) {
120 while (ticks--) {
121 if (IO_UART1_RFCR & 0x3f) {
122 return IO_UART1_DTRR & 0xff;
123 }
124 }
125
126 return -1;
127}
128
129bool uartAvailable(void)
130{
131 return uart1count > 0;
132}
133
134void uart1_heartbeat(void)
135{
136 char data[5] = {0x11, 0x30, 0x11^0x30, 0x11+0x30, '\0'};
137 uartPuts(data);
138}
139
140void uartSendData(char* data, int len)
141{
142 int i;
143 for(i=0;i<len;i++)
144 uartPutc(data[i]);
145}
146
147bool uart1_getch(char *c)
148{
149 if (uart1count > 0)
150 {
151 *c = uart1buffer[uart1read];
152 uart1read = (uart1read+1) % MAX_UART_BUFFER;
153 uart1count--;
154 return true;
155 }
156 return false;
157}
158
159/* UART1 receive intterupt handler */
160void UART1(void)
161{
162 if (IO_UART1_RFCR & 0x3f)
163 {
164 if (uart1count >= MAX_UART_BUFFER)
165 panicf("UART1 buffer overflow");
166 uart1buffer[uart1write] = IO_UART1_DTRR & 0xff;
167 uart1write = (uart1write+1) % MAX_UART_BUFFER;
168 uart1count++;
169 }
170
171 IO_INTC_IRQ0 = (1<<IRQ_UART1);
172}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/uart-target.h b/firmware/target/arm/tms320dm320/mrobe-500/uart-target.h
new file mode 100644
index 0000000000..f077dc1025
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/uart-target.h
@@ -0,0 +1,33 @@
1/*
2 * (C) Copyright 2007 Catalin Patulea <cat@vv.carleton.ca>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 *
19 */
20#ifndef UART_H
21#define UART_H
22
23void uart_init(void);
24bool uart1_getch(char *c);
25void uart1_heartbeat(void);
26
27void uartPuts(const char *str);
28void uartGets(char *str, unsigned int size);
29int uartPollch(unsigned int ticks);
30void uartPutc(char ch);
31void uartPutHex(unsigned int n);
32
33#endif
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c
new file mode 100644
index 0000000000..6063ed3727
--- /dev/null
+++ b/firmware/target/arm/tms320dm320/mrobe-500/usb-mr500.c
@@ -0,0 +1,55 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
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 "config.h"
21#include "cpu.h"
22#include "system.h"
23#include "kernel.h"
24#include "ata.h"
25
26#define USB_RST_ASSERT
27#define USB_RST_DEASSERT
28
29#define USB_VPLUS_PWR_ASSERT
30#define USB_VPLUS_PWR_DEASSERT
31
32#define USB_UNIT_IS_PRESENT false
33
34/* The usb detect is one pin to the cpu active low */
35inline bool usb_detect(void)
36{
37 return USB_UNIT_IS_PRESENT;
38}
39
40void usb_init_device(void)
41{
42// ata_enable(true);
43}
44
45void usb_enable(bool on)
46{
47 if (on)
48 {
49 USB_VPLUS_PWR_ASSERT;
50 }
51 else
52 {
53 USB_VPLUS_PWR_DEASSERT;
54 }
55}