summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2006-08-03 20:18:31 +0000
committerDaniel Stenberg <daniel@haxx.se>2006-08-03 20:18:31 +0000
commit86bff1cf56d144910f3e2bd84a37ec99c8dca512 (patch)
tree07fff7f569cd82d261115fc520cc30b0be553463
parent1e88be518adafe146704a506aad7f895fffbb240 (diff)
downloadrockbox-86bff1cf56d144910f3e2bd84a37ec99c8dca512.tar.gz
rockbox-86bff1cf56d144910f3e2bd84a37ec99c8dca512.zip
Barry Wardell's initial work for the iriver H10 port
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10447 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/iriver/h10/ata-h10.c51
-rw-r--r--firmware/target/arm/iriver/h10/ata-target.h72
-rw-r--r--firmware/target/arm/iriver/h10/backlight-h10.c44
-rw-r--r--firmware/target/arm/iriver/h10/backlight-target.h28
-rw-r--r--firmware/target/arm/iriver/h10/button-h10.c69
-rw-r--r--firmware/target/arm/iriver/h10/button-target.h58
-rw-r--r--firmware/target/arm/iriver/h10/lcd-h10.c351
-rw-r--r--firmware/target/arm/iriver/h10/power-h10.c99
-rw-r--r--firmware/target/arm/iriver/h10/usb-h10.c107
-rw-r--r--firmware/target/arm/iriver/h10/usb-target.h27
10 files changed, 906 insertions, 0 deletions
diff --git a/firmware/target/arm/iriver/h10/ata-h10.c b/firmware/target/arm/iriver/h10/ata-h10.c
new file mode 100644
index 0000000000..f8ca773132
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/ata-h10.c
@@ -0,0 +1,51 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* ATA stuff was taken from the iPod code */
21
22#include <stdbool.h>
23#include "system.h"
24#include "ata-target.h"
25
26void ata_reset()
27{
28
29}
30
31void ata_enable(bool on)
32{
33 /* TODO: Implement ata_enable() */
34 (void)on;
35}
36
37bool ata_is_coldstart()
38{
39 return false;
40 /* TODO: Implement coldstart variable */
41}
42
43void ata_device_init()
44{
45 /* From ipod-ide.c:ipod_ide_register() */
46 outl(inl(0xc3000028) | (1 << 5), 0xc3000028);
47 outl(inl(0xc3000028) & ~0x10000000, 0xc3000028);
48
49 outl(0x10, 0xc3000000);
50 outl(0x80002150, 0xc3000004);
51}
diff --git a/firmware/target/arm/iriver/h10/ata-target.h b/firmware/target/arm/iriver/h10/ata-target.h
new file mode 100644
index 0000000000..a93af79015
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/ata-target.h
@@ -0,0 +1,72 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* ATA stuff was taken from the iPod code */
21
22/* Plain C read & write loops */
23#define PREFER_C_READING
24#define PREFER_C_WRITING
25
26#if (CONFIG_CPU == PP5002)
27#define ATA_IOBASE 0xc00031e0
28#define ATA_CONTROL (*((volatile unsigned char*)(0xc00033f8)))
29#elif (CONFIG_CPU == PP5020)
30#define ATA_IOBASE 0xc30001e0
31#define ATA_CONTROL (*((volatile unsigned char*)(0xc30003f8)))
32#endif
33
34#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE)))
35#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0x04)))
36#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x08)))
37#define ATA_SECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x0c)))
38#define ATA_LCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x10)))
39#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x14)))
40#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x18)))
41#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x1c)))
42
43#define STATUS_BSY 0x80
44#define STATUS_RDY 0x40
45#define STATUS_DF 0x20
46#define STATUS_DRQ 0x08
47#define STATUS_ERR 0x01
48#define ERROR_ABRT 0x04
49
50#define WRITE_PATTERN1 0xa5
51#define WRITE_PATTERN2 0x5a
52#define WRITE_PATTERN3 0xaa
53#define WRITE_PATTERN4 0x55
54
55#define READ_PATTERN1 0xa5
56#define READ_PATTERN2 0x5a
57#define READ_PATTERN3 0xaa
58#define READ_PATTERN4 0x55
59
60#define READ_PATTERN1_MASK 0xff
61#define READ_PATTERN2_MASK 0xff
62#define READ_PATTERN3_MASK 0xff
63#define READ_PATTERN4_MASK 0xff
64
65#define SET_REG(reg,val) reg = (val)
66#define SET_16BITREG(reg,val) reg = (val)
67
68
69void ata_reset(void);
70void ata_enable(bool on);
71bool ata_is_coldstart(void);
72void ata_device_init(void);
diff --git a/firmware/target/arm/iriver/h10/backlight-h10.c b/firmware/target/arm/iriver/h10/backlight-h10.c
new file mode 100644
index 0000000000..b4221dd60a
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/backlight-h10.c
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* The H10 display (and hence backlight) possibly identical to that of the X5,
21 so that code was used here but left #if 0'ed out for the moment */
22
23#include "config.h"
24#include "cpu.h"
25#include "system.h"
26#include "backlight.h"
27
28void __backlight_on(void)
29{
30#if 0
31 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
32 pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
33 set_irq_level(level);
34#endif
35}
36
37void __backlight_off(void)
38{
39#if 0
40 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
41 pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */
42 set_irq_level(level);
43#endif
44}
diff --git a/firmware/target/arm/iriver/h10/backlight-target.h b/firmware/target/arm/iriver/h10/backlight-target.h
new file mode 100644
index 0000000000..b5fe2f7c5d
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/backlight-target.h
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* Taken from the x5's implementation */
21
22#ifndef BACKLIGHT_TARGET_H
23#define BACKLIGHT_TARGET_H
24
25void __backlight_on(void);
26void __backlight_off(void);
27
28#endif
diff --git a/firmware/target/arm/iriver/h10/button-h10.c b/firmware/target/arm/iriver/h10/button-h10.c
new file mode 100644
index 0000000000..badcd594a1
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/button-h10.c
@@ -0,0 +1,69 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* Custom written for the H10 based on analysis of the GPIO data */
21
22
23#include <stdlib.h>
24#include "config.h"
25#include "cpu.h"
26#include "system.h"
27#include "button.h"
28#include "kernel.h"
29#include "backlight.h"
30#include "adc.h"
31#include "system.h"
32
33
34void button_init_device(void)
35{
36 /* No hardware initialisation required as it is done by the bootloader */
37}
38
39bool button_hold(void)
40{
41 return (GPIOA_INPUT_VAL & 0x40)?false:true;
42}
43
44/*
45 * Get button pressed from hardware
46 */
47int button_read_device(void)
48{
49 int btn = BUTTON_NONE;
50 unsigned char state;
51 static bool hold_button = false;
52#if 0
53 /* light handling */
54 if (hold_button && !button_hold())
55 {
56 backlight_on();
57 }
58#endif
59
60 hold_button = button_hold();
61 state = GPIOA_INPUT_VAL & 0xf8;
62 if ((state & 0x8) == 0) btn |= BUTTON_FF;
63 if ((state & 0x16) == 0) btn |= BUTTON_PLAY;
64 if ((state & 0x32) == 0) btn |= BUTTON_REW;
65 if ((state & 0x64) == 0) btn |= BUTTON_RIGHT;
66 if ((state & 0x128) == 0) btn |= BUTTON_LEFT;
67
68 return btn;
69}
diff --git a/firmware/target/arm/iriver/h10/button-target.h b/firmware/target/arm/iriver/h10/button-target.h
new file mode 100644
index 0000000000..48aa10c124
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/button-target.h
@@ -0,0 +1,58 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* Custom written for the H10 */
21
22#ifndef _BUTTON_TARGET_H_
23#define _BUTTON_TARGET_H_
24
25#include <stdbool.h>
26#include "config.h"
27
28#define HAS_BUTTON_HOLD
29
30bool button_hold(void);
31void button_init_device(void);
32int button_read_device(void);
33
34/* iriver H10 specific button codes */
35
36 /* Main unit's buttons */
37#define BUTTON_POWER 0x00000001
38
39#define BUTTON_LEFT 0x00000002
40#define BUTTON_RIGHT 0x00000004
41
42#define BUTTON_REW 0x00000008
43#define BUTTON_PLAY 0x00000010
44#define BUTTON_FF 0x00000020
45
46#define BUTTON_SCROLL_UP 0x00000040
47#define BUTTON_SCROLL_DOWN 0x00000080
48
49#define BUTTON_MAIN (BUTTON_POWER|BUTTON_O|BUTTON_BACK|BUTTON_REW\
50 |BUTTON_PLAY|BUTTON_FF)
51
52 /* No Remote control */
53#define BUTTON_REMOTE 0
54
55#define POWEROFF_BUTTON BUTTON_POWER
56#define POWEROFF_COUNT 10
57
58#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/iriver/h10/lcd-h10.c b/firmware/target/arm/iriver/h10/lcd-h10.c
new file mode 100644
index 0000000000..c2fa05b05c
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/lcd-h10.c
@@ -0,0 +1,351 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* The H10 display possibly identical to that of the X5, so that code was used here
21 but left #if 0'ed out for the moment */
22
23#include "config.h"
24
25#include "cpu.h"
26#include "lcd.h"
27#include "kernel.h"
28#include "thread.h"
29#include <string.h>
30#include <stdlib.h>
31#include "file.h"
32#include "debug.h"
33#include "system.h"
34#include "font.h"
35#include "bidi.h"
36
37static bool display_on=false; /* is the display turned on? */
38
39#define LCD_CMD *(volatile unsigned short *)0xf0008000
40#define LCD_DATA *(volatile unsigned short *)0xf0008002
41
42/* register defines for the Renesas HD66773R */
43#define R_HORIZ_RAM_ADDR_POS 0x16
44#define R_VERT_RAM_ADDR_POS 0x17
45#define R_RAM_ADDR_SET 0x21
46#define R_WRITE_DATA_2_GRAM 0x22
47
48/*****************************************************
49The table below was generated by the following script:
50
51#!/usr/bin/perl
52
53# high byte table
54print "short high8to9[] = {\n";
55$str = " ";
56for my $m (0 .. 255) {
57 # RRRRRGGG => RRRRR0GGG
58 my $v = (($m & 0xF8) << 1) | ($m & 0x07);
59 if(length($str) > 75) {
60 print "$str\n";
61 $str=" ";
62 }
63 $str .= sprintf("0x%03x, ", $v);
64}
65print "$str\n};\n";
66
67*****************************************************/
68
69/* Lookup table for 16->18bit conversion, high byte. The low byte is just
70 shifted. */
71const short high8to9[] ICONST_ATTR = {
72 0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007, 0x010, 0x011, 0x012,
73 0x013, 0x014, 0x015, 0x016, 0x017, 0x020, 0x021, 0x022, 0x023, 0x024, 0x025,
74 0x026, 0x027, 0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037, 0x040,
75 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047, 0x050, 0x051, 0x052, 0x053,
76 0x054, 0x055, 0x056, 0x057, 0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066,
77 0x067, 0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x077, 0x080, 0x081,
78 0x082, 0x083, 0x084, 0x085, 0x086, 0x087, 0x090, 0x091, 0x092, 0x093, 0x094,
79 0x095, 0x096, 0x097, 0x0a0, 0x0a1, 0x0a2, 0x0a3, 0x0a4, 0x0a5, 0x0a6, 0x0a7,
80 0x0b0, 0x0b1, 0x0b2, 0x0b3, 0x0b4, 0x0b5, 0x0b6, 0x0b7, 0x0c0, 0x0c1, 0x0c2,
81 0x0c3, 0x0c4, 0x0c5, 0x0c6, 0x0c7, 0x0d0, 0x0d1, 0x0d2, 0x0d3, 0x0d4, 0x0d5,
82 0x0d6, 0x0d7, 0x0e0, 0x0e1, 0x0e2, 0x0e3, 0x0e4, 0x0e5, 0x0e6, 0x0e7, 0x0f0,
83 0x0f1, 0x0f2, 0x0f3, 0x0f4, 0x0f5, 0x0f6, 0x0f7, 0x100, 0x101, 0x102, 0x103,
84 0x104, 0x105, 0x106, 0x107, 0x110, 0x111, 0x112, 0x113, 0x114, 0x115, 0x116,
85 0x117, 0x120, 0x121, 0x122, 0x123, 0x124, 0x125, 0x126, 0x127, 0x130, 0x131,
86 0x132, 0x133, 0x134, 0x135, 0x136, 0x137, 0x140, 0x141, 0x142, 0x143, 0x144,
87 0x145, 0x146, 0x147, 0x150, 0x151, 0x152, 0x153, 0x154, 0x155, 0x156, 0x157,
88 0x160, 0x161, 0x162, 0x163, 0x164, 0x165, 0x166, 0x167, 0x170, 0x171, 0x172,
89 0x173, 0x174, 0x175, 0x176, 0x177, 0x180, 0x181, 0x182, 0x183, 0x184, 0x185,
90 0x186, 0x187, 0x190, 0x191, 0x192, 0x193, 0x194, 0x195, 0x196, 0x197, 0x1a0,
91 0x1a1, 0x1a2, 0x1a3, 0x1a4, 0x1a5, 0x1a6, 0x1a7, 0x1b0, 0x1b1, 0x1b2, 0x1b3,
92 0x1b4, 0x1b5, 0x1b6, 0x1b7, 0x1c0, 0x1c1, 0x1c2, 0x1c3, 0x1c4, 0x1c5, 0x1c6,
93 0x1c7, 0x1d0, 0x1d1, 0x1d2, 0x1d3, 0x1d4, 0x1d5, 0x1d6, 0x1d7, 0x1e0, 0x1e1,
94 0x1e2, 0x1e3, 0x1e4, 0x1e5, 0x1e6, 0x1e7, 0x1f0, 0x1f1, 0x1f2, 0x1f3, 0x1f4,
95 0x1f5, 0x1f6, 0x1f7,
96};
97
98/* called very frequently - inline! */
99inline void lcd_write_reg(int reg, int val)
100{
101#if 0
102 LCD_CMD = (reg >> 8) << 1;
103 LCD_CMD = (reg & 0xff) << 1;
104 LCD_DATA = (val >> 8) << 1;
105 LCD_DATA = (val & 0xff) << 1;
106#endif
107 (void)reg;
108 (void)val;
109}
110
111/* called very frequently - inline! */
112inline void lcd_begin_write_gram(void)
113{
114#if 0
115 LCD_CMD = (R_WRITE_DATA_2_GRAM >> 8) << 1;
116 LCD_CMD = (R_WRITE_DATA_2_GRAM & 0xff) << 1;
117#endif
118}
119
120/* called very frequently - inline! */
121inline void lcd_write_data(const unsigned short* p_bytes, int count) ICODE_ATTR;
122inline void lcd_write_data(const unsigned short* p_bytes, int count)
123{
124#if 0
125 unsigned int tmp;
126 unsigned int *ptr = (unsigned int *)p_bytes;
127 bool extra;
128
129 /* if there's on odd number of pixels, remmber this and output the
130 trailing pixel after the loop */
131 extra = (count&1)?true:false;
132
133 count >>= 1;
134 while(count--) {
135 tmp = *ptr++;
136 LCD_DATA = high8to9[tmp >> 24];
137 LCD_DATA = tmp>>15;
138 LCD_DATA = high8to9[(tmp >> 8)&255];
139 LCD_DATA = tmp<<1;
140 }
141 if(extra) {
142 /* the final "spare" pixel */
143 unsigned short read = *(unsigned short *)ptr;
144 LCD_DATA = high8to9[read >> 8];
145 LCD_DATA = read<<1;
146 }
147#endif
148 (void)p_bytes;
149 (void)count;
150}
151
152/*** hardware configuration ***/
153
154int lcd_default_contrast(void)
155{
156 return 16;
157}
158
159void lcd_set_contrast(int val)
160{
161#if 0
162 if (val >= 15) // val must'nt be 15 or 31
163 ++val;
164 if (val > 30)
165 return;
166
167 lcd_write_reg(0x0e, 0x201e + (val << 8));
168#endif
169 (void)val;
170}
171
172void lcd_set_invert_display(bool yesno)
173{
174 (void)yesno;
175}
176
177/* turn the display upside down (call lcd_update() afterwards) */
178void lcd_set_flip(bool yesno)
179{
180 (void)yesno;
181}
182
183/* Rolls up the lcd display by the specified amount of lines.
184 * Lines that are rolled out over the top of the screen are
185 * rolled in from the bottom again. This is a hardware
186 * remapping only and all operations on the lcd are affected.
187 * ->
188 * @param int lines - The number of lines that are rolled.
189 * The value must be 0 <= pixels < LCD_HEIGHT. */
190void lcd_roll(int lines)
191{
192 (void)lines;
193}
194
195/* LCD init
196 * These settings are taken from the original X5 firmware
197 */
198void lcd_init_device(void)
199{
200#if 0
201 display_on=true;
202
203 /* LCD Reset */
204 and_l(~0x00000010, &GPIO1_OUT);
205 or_l(0x00000010, &GPIO1_ENABLE);
206 or_l(0x00000010, &GPIO1_FUNCTION);
207 sleep(HZ/100);
208 or_l(0x00000010, &GPIO1_OUT);
209
210 sleep(HZ/100);
211
212 lcd_write_reg(0, 0x0001);
213
214 sleep(HZ/50);
215
216 lcd_write_reg(0x0d, 0x0401);
217 lcd_write_reg(0x0e, 0x321e);
218 lcd_write_reg(0x01, 0x0313);
219 lcd_write_reg(0x02, 0x0700);
220 lcd_write_reg(0x05, 0x9038);
221 lcd_write_reg(0x06, 0x0000);
222 lcd_write_reg(0x0b, 0x4000);
223
224 sleep(HZ/100);
225
226 lcd_write_reg(0x21,0x0000);
227 lcd_write_reg(0x30,0x0003);
228 lcd_write_reg(0x31,0x0400);
229 lcd_write_reg(0x32,0x0407);
230 lcd_write_reg(0x33,0x0305);
231 lcd_write_reg(0x34,0x0003);
232 lcd_write_reg(0x35,0x0704);
233 lcd_write_reg(0x36,0x0407);
234 lcd_write_reg(0x37,0x0503);
235 lcd_write_reg(0x0f,0x0002);
236 lcd_write_reg(0x11,0x0000);
237 lcd_write_reg(0x14,0x9f00);
238 lcd_write_reg(0x15,0x5c00);
239 lcd_write_reg(0x16,0x7f00);
240 lcd_write_reg(0x17,0x9f00);
241 lcd_write_reg(0x3a,0x1409);
242 lcd_write_reg(0x3b,0x0602);
243
244 lcd_write_reg(0x0c,0x0001);
245
246 sleep(HZ/25);
247
248 lcd_write_reg(0x03,0x002c);
249 lcd_write_reg(0x04,0x8000);
250
251 sleep(HZ/25);
252
253 lcd_write_reg(0x0e,0x3318);
254
255 sleep(HZ/25);
256
257 lcd_write_reg(0x0d,0x0411);
258
259 sleep(HZ/100);
260
261 lcd_write_reg(0x07,0x0006);
262 lcd_write_reg(0x07,0x036);
263 lcd_write_reg(0x07,0x037);
264 lcd_write_reg(0x07,0x0037);
265 return;
266#endif
267}
268
269void lcd_enable(bool on)
270{
271#if 0
272 display_on = on;
273#endif
274 (void)on;
275}
276
277/*** update functions ***/
278
279/* Performance function that works with an external buffer
280 note that by and bheight are in 8-pixel units! */
281void lcd_blit(const fb_data* data, int x, int by, int width,
282 int bheight, int stride)
283{
284 /* TODO: Implement lcd_blit() */
285 (void)data;
286 (void)x;
287 (void)by;
288 (void)width;
289 (void)bheight;
290 (void)stride;
291 /*if(display_on)*/
292}
293
294
295/* Update the display.
296 This must be called after all other LCD functions that change the display. */
297void lcd_update(void) ICODE_ATTR;
298void lcd_update(void)
299{
300#if 0
301 if(display_on){
302
303 /* Copy display bitmap to hardware */
304 lcd_write_reg(R_RAM_ADDR_SET, 0x0000);
305 lcd_begin_write_gram();
306 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
307 }
308#endif
309}
310
311/* Update a fraction of the display. */
312void lcd_update_rect(int, int, int, int) ICODE_ATTR;
313void lcd_update_rect(int x, int y, int width, int height)
314{
315#if 0
316 if(display_on) {
317 int ymax = y + height;
318
319 if(x + width > LCD_WIDTH)
320 width = LCD_WIDTH - x;
321 if (width <= 0)
322 return; /* nothing left to do, 0 is harmful to lcd_write_data() */
323 if(ymax >= LCD_HEIGHT)
324 ymax = LCD_HEIGHT-1;
325
326 /* set update window */
327
328 /* horiz ram addr */
329 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (ymax<<8) | y);
330
331 /* vert ram addr */
332 lcd_write_reg(R_VERT_RAM_ADDR_POS,((x+width-1)<<8) | x);
333 lcd_write_reg(R_RAM_ADDR_SET, (x<<8) | y);
334 lcd_begin_write_gram();
335
336 /* Copy specified rectangle bitmap to hardware */
337 for (; y <= ymax; y++)
338 {
339 lcd_write_data ((unsigned short *)&lcd_framebuffer[y][x], width);
340 }
341
342 /* reset update window */
343 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00);
344 lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00);
345 }
346#endif
347 (void)x;
348 (void)y;
349 (void)width;
350 (void)height;
351}
diff --git a/firmware/target/arm/iriver/h10/power-h10.c b/firmware/target/arm/iriver/h10/power-h10.c
new file mode 100644
index 0000000000..58dd25174f
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/power-h10.c
@@ -0,0 +1,99 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* Created from power.c using some iPod code, and some custom stuff based on
21 GPIO analysis
22*/
23
24#include "config.h"
25#include "cpu.h"
26#include <stdbool.h>
27#include "adc.h"
28#include "kernel.h"
29#include "system.h"
30#include "power.h"
31#include "hwcompat.h"
32#include "logf.h"
33#include "usb.h"
34
35#if CONFIG_CHARGING == CHARGING_CONTROL
36bool charger_enabled;
37#endif
38
39#if 0
40#ifdef CONFIG_TUNER
41
42static bool powered = false;
43
44bool radio_powered()
45{
46 return powered;
47}
48
49bool radio_power(bool status)
50{
51 bool old_status = powered;
52 powered = status;
53#ifdef HAVE_TUNER_PWR_CTRL
54 if (status)
55 {
56 and_b(~0x04, &PADRL); /* drive PA2 low for tuner enable */
57 sleep(1); /* let the voltage settle */
58 }
59 else
60 or_b(0x04, &PADRL); /* drive PA2 high for tuner disable */
61#endif
62 return old_status;
63}
64
65#endif /* #ifdef CONFIG_TUNER */
66#endif
67
68void power_init(void)
69{
70}
71
72bool charger_inserted(void)
73{
74 return (GPIOL_INPUT_VAL & 0x04)?true:false; /* FIXME: This only checks if USB is connected */
75}
76
77void ide_power_enable(bool on)
78{
79 (void)on;
80 /* We do nothing on the iPod */
81}
82
83
84bool ide_powered(void)
85{
86 /* pretend we are always powered - we don't turn it off on the ipod */
87 return true;
88}
89
90void power_off(void)
91{
92 /* set_irq_level(HIGHEST_IRQ_LEVEL);*/
93 #ifndef BOOTLOADER
94 /* We don't turn off the ipod, we put it in a deep sleep */
95 /* pcf50605_standby_mode(); */
96 while(1)
97 yield();
98 #endif
99}
diff --git a/firmware/target/arm/iriver/h10/usb-h10.c b/firmware/target/arm/iriver/h10/usb-h10.c
new file mode 100644
index 0000000000..dccdea81aa
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/usb-h10.c
@@ -0,0 +1,107 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardell
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/* Code from the iPod port but commented out. USB detection custom made based
21 on GPIO analysis */
22
23#include "config.h"
24#include "cpu.h"
25#include "kernel.h"
26#include "thread.h"
27#include "system.h"
28#include "debug.h"
29#include "ata.h"
30#include "fat.h"
31#include "disk.h"
32#include "panic.h"
33#include "lcd.h"
34#include "adc.h"
35#include "usb.h"
36#include "button.h"
37#include "sprintf.h"
38#include "string.h"
39#include "hwcompat.h"
40#ifdef HAVE_MMC
41#include "ata_mmc.h"
42#endif
43
44void usb_init_device(void)
45{
46#if 0
47 int r0;
48 outl(inl(0x70000084) | 0x200, 0x70000084);
49
50 outl(inl(0x7000002C) | 0x3000000, 0x7000002C);
51 outl(inl(0x6000600C) | 0x400000, 0x6000600C);
52
53 outl(inl(0x60006004) | 0x400000, 0x60006004); /* reset usb start */
54 outl(inl(0x60006004) & ~0x400000, 0x60006004); /* reset usb end */
55
56 outl(inl(0x70000020) | 0x80000000, 0x70000020);
57 while ((inl(0x70000028) & 0x80) == 0);
58
59 outl(inl(0xc5000184) | 0x100, 0xc5000184);
60 while ((inl(0xc5000184) & 0x100) != 0);
61
62 outl(inl(0xc50001A4) | 0x5F000000, 0xc50001A4);
63 if ((inl(0xc50001A4) & 0x100) == 0) {
64 outl(inl(0xc50001A8) & ~0x3, 0xc50001A8);
65 outl(inl(0xc50001A8) | 0x2, 0xc50001A8);
66 outl(inl(0x70000028) | 0x4000, 0x70000028);
67 outl(inl(0x70000028) | 0x2, 0x70000028);
68 } else {
69 outl(inl(0xc50001A8) | 0x3, 0xc50001A8);
70 outl(inl(0x70000028) &~0x4000, 0x70000028);
71 outl(inl(0x70000028) | 0x2, 0x70000028);
72 }
73 outl(inl(0xc5000140) | 0x2, 0xc5000140);
74 while((inl(0xc5000140) & 0x2) != 0);
75 r0 = inl(0xc5000184);
76
77 /* Note from IPL source (referring to next 5 lines of code:
78 THIS NEEDS TO BE CHANGED ONCE THERE IS KERNEL USB */
79 outl(inl(0x70000020) | 0x80000000, 0x70000020);
80 outl(inl(0x6000600C) | 0x400000, 0x6000600C);
81 while ((inl(0x70000028) & 0x80) == 0);
82 outl(inl(0x70000028) | 0x2, 0x70000028);
83
84 udelay(0x186A0);
85#endif
86}
87
88bool usb_detect(void)
89{
90 return (GPIOA_INPUT_VAL & 0x04)?true:false;
91}
92
93void usb_enable(bool on)
94{
95 (void)on;
96#if 0
97 /* For the ipod, we can only do one thing with USB mode - reboot
98 into Apple's flash-based disk-mode. This does not return. */
99 if (on)
100 {
101 /* The following code is copied from ipodlinux */
102 unsigned char* storage_ptr = (unsigned char *)0x40017F00;
103 memcpy(storage_ptr, "diskmode\0\0hotstuff\0\0\1", 21);
104 DEV_RS |= 4; /* Reboot */
105 }
106#endif
107}
diff --git a/firmware/target/arm/iriver/h10/usb-target.h b/firmware/target/arm/iriver/h10/usb-target.h
new file mode 100644
index 0000000000..7a17f7bacf
--- /dev/null
+++ b/firmware/target/arm/iriver/h10/usb-target.h
@@ -0,0 +1,27 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Barry Wardelll
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/* Based off x5 version */
21
22#ifndef USB_TARGET_H
23#define USB_TARGET_H
24
25bool usb_init_device(void);
26
27#endif