diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2011-08-27 16:21:19 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2011-08-27 16:21:19 +0000 |
commit | 463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08 (patch) | |
tree | 622e101cddcdad0360625efc647cecbd538fb7dd /firmware/target | |
parent | 3aeb7fad9a31666f5762644ebcf2725b15b9241f (diff) | |
download | rockbox-463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08.tar.gz rockbox-463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08.zip |
Initial framework for the Sandisk Sansa Clip Zip
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30365 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
8 files changed, 346 insertions, 2 deletions
diff --git a/firmware/target/arm/as3525/fmradio-i2c-as3525.c b/firmware/target/arm/as3525/fmradio-i2c-as3525.c index 70287c38b8..1dbf2fde24 100644 --- a/firmware/target/arm/as3525/fmradio-i2c-as3525.c +++ b/firmware/target/arm/as3525/fmradio-i2c-as3525.c | |||
@@ -40,7 +40,8 @@ | |||
40 | #define I2C_SCL_PIN 4 | 40 | #define I2C_SCL_PIN 4 |
41 | #define I2C_SDA_PIN 5 | 41 | #define I2C_SDA_PIN 5 |
42 | 42 | ||
43 | #elif defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS) | 43 | #elif defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS) \ |
44 | || defined(SANSA_CLIPZIP) | ||
44 | #define I2C_SCL_GPIO(x) GPIOB_PIN(x) | 45 | #define I2C_SCL_GPIO(x) GPIOB_PIN(x) |
45 | #define I2C_SDA_GPIO(x) GPIOB_PIN(x) | 46 | #define I2C_SDA_GPIO(x) GPIOB_PIN(x) |
46 | #define I2C_SCL_GPIO_DIR GPIOB_DIR | 47 | #define I2C_SCL_GPIO_DIR GPIOB_DIR |
diff --git a/firmware/target/arm/as3525/memory-init.S b/firmware/target/arm/as3525/memory-init.S index e45e28a608..49b05463e7 100644 --- a/firmware/target/arm/as3525/memory-init.S +++ b/firmware/target/arm/as3525/memory-init.S | |||
@@ -30,7 +30,8 @@ | |||
30 | #define MEMORY_MODEL 0x21 | 30 | #define MEMORY_MODEL 0x21 |
31 | 31 | ||
32 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_CLIPV2) \ | 32 | #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_CLIPV2) \ |
33 | || defined(SANSA_CLIPPLUS) || defined(SANSA_FUZEV2) | 33 | || defined(SANSA_CLIPPLUS) || defined(SANSA_FUZEV2) \ |
34 | || defined(SANSA_CLIPZIP) | ||
34 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ | 35 | /* 16 bits external bus, high performance SDRAM, 64 Mbits = 8 Mbytes */ |
35 | #define MEMORY_MODEL 0x5 | 36 | #define MEMORY_MODEL 0x5 |
36 | 37 | ||
diff --git a/firmware/target/arm/as3525/powermgmt-target.h b/firmware/target/arm/as3525/powermgmt-target.h index fd13ec6c7f..f2762f3e47 100644 --- a/firmware/target/arm/as3525/powermgmt-target.h +++ b/firmware/target/arm/as3525/powermgmt-target.h | |||
@@ -78,6 +78,15 @@ | |||
78 | #define BATT_CHG_I CHG_I_200MA | 78 | #define BATT_CHG_I CHG_I_200MA |
79 | #define CHARGER_TOTAL_TIMER (4*3600*2) | 79 | #define CHARGER_TOTAL_TIMER (4*3600*2) |
80 | 80 | ||
81 | #elif defined(SANSA_CLIPZIP) | ||
82 | |||
83 | /* Check if topped-off and monitor voltage while plugged. */ | ||
84 | #define BATT_FULL_VOLTAGE 4160 | ||
85 | #define BATT_VAUTO_RECHARGE 4100 | ||
86 | #define BATT_CHG_V CHG_V_4_20V | ||
87 | #define BATT_CHG_I CHG_I_150MA | ||
88 | #define CHARGER_TOTAL_TIMER (4*3600*2) /* about 1.5 * capacity / current */ | ||
89 | |||
81 | #elif defined(SANSA_C200V2) | 90 | #elif defined(SANSA_C200V2) |
82 | 91 | ||
83 | /* Check if topped-off and monitor voltage while plugged. */ | 92 | /* Check if topped-off and monitor voltage while plugged. */ |
diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c new file mode 100644 index 0000000000..a592715c90 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c | |||
@@ -0,0 +1,42 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2011 Bertrik Sikken | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "backlight-target.h" | ||
23 | #include "lcd.h" | ||
24 | #include "as3525v2.h" | ||
25 | #include "ascodec-target.h" | ||
26 | |||
27 | void _backlight_init() | ||
28 | { | ||
29 | /* GPIO B2 controls backlight */ | ||
30 | GPIOB_DIR |= (1 << 2); | ||
31 | } | ||
32 | |||
33 | void _backlight_on(void) | ||
34 | { | ||
35 | /* TODO */ | ||
36 | } | ||
37 | |||
38 | void _backlight_off(void) | ||
39 | { | ||
40 | /* TODO */ | ||
41 | } | ||
42 | |||
diff --git a/firmware/target/arm/as3525/sansa-clipzip/backlight-target.h b/firmware/target/arm/as3525/sansa-clipzip/backlight-target.h new file mode 100644 index 0000000000..e19334b5c5 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/backlight-target.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright © 2011 Bertrik Sikken | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | void _backlight_init(void); | ||
25 | void _backlight_on(void); | ||
26 | void _backlight_off(void); | ||
27 | |||
28 | #define _backlight_panic_on() _backlight_on() | ||
29 | |||
30 | #endif | ||
diff --git a/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c new file mode 100644 index 0000000000..104c227378 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * Copyright © 2008-2009 Rafaël Carré | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
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 | |||
25 | #include "button-target.h" | ||
26 | #include "as3525v2.h" | ||
27 | #include "kernel.h" | ||
28 | #include "system-target.h" | ||
29 | |||
30 | void button_init_device(void) | ||
31 | { | ||
32 | /* GPIO A6, A7 and D6 are direct button inputs */ | ||
33 | GPIOA_DIR &= ~(1 << 6); | ||
34 | GPIOA_DIR &= ~(1 << 7); | ||
35 | GPIOD_DIR &= ~(1 << 6); | ||
36 | |||
37 | /* GPIO C1, C2, C3, C4, C5 are used in a column/row key scan matrix */ | ||
38 | GPIOC_DIR |= ((1 << 1) | (1 << 2)); | ||
39 | GPIOC_DIR &= ~((1 << 3) | (1 << 4) | (1 << 5)); | ||
40 | } | ||
41 | |||
42 | /* TODO: | ||
43 | Instead of using udelay to wait for buttons to settle, we could use a | ||
44 | simple state machine to alternate between key matrix rows (like we do on | ||
45 | the clip) and this way avoid burning cycles in the udelay. | ||
46 | |||
47 | TODO: | ||
48 | Figure out the real mappings from GPIOs to buttons. | ||
49 | The current mapping is just an educated guess. | ||
50 | */ | ||
51 | int button_read_device(void) | ||
52 | { | ||
53 | int buttons = 0; | ||
54 | |||
55 | /* power */ | ||
56 | if (GPIOD_PIN(6)) { | ||
57 | buttons |= BUTTON_POWER; | ||
58 | } | ||
59 | |||
60 | /* volume */ | ||
61 | if (GPIOA_PIN(6)) { | ||
62 | buttons |= BUTTON_VOL_DOWN; | ||
63 | } | ||
64 | if (GPIOA_PIN(7)) { | ||
65 | buttons |= BUTTON_VOL_UP; | ||
66 | } | ||
67 | |||
68 | /* key matrix buttons, first row */ | ||
69 | GPIOC_PIN(1) = (1 << 1); | ||
70 | GPIOC_PIN(2) = 0; | ||
71 | udelay(500); | ||
72 | |||
73 | if (GPIOC_PIN(3)) { | ||
74 | buttons |= BUTTON_LEFT; | ||
75 | } | ||
76 | if (GPIOC_PIN(4)) { | ||
77 | buttons |= BUTTON_SELECT; | ||
78 | } | ||
79 | if (GPIOC_PIN(5)) { | ||
80 | buttons |= BUTTON_RIGHT; | ||
81 | } | ||
82 | |||
83 | /* key matrix buttons, second row */ | ||
84 | GPIOC_PIN(1) = 0; | ||
85 | GPIOC_PIN(2) = (1 << 2); | ||
86 | udelay(500); | ||
87 | |||
88 | if (GPIOC_PIN(3)) { | ||
89 | buttons |= BUTTON_UP; | ||
90 | } | ||
91 | if (GPIOC_PIN(4)) { | ||
92 | buttons |= BUTTON_HOME; | ||
93 | } | ||
94 | if (GPIOC_PIN(5)) { | ||
95 | buttons |= BUTTON_DOWN; | ||
96 | } | ||
97 | |||
98 | /* deselect scan rows */ | ||
99 | GPIOC_PIN(2) = 0; | ||
100 | |||
101 | return buttons; | ||
102 | } | ||
103 | |||
diff --git a/firmware/target/arm/as3525/sansa-clipzip/button-target.h b/firmware/target/arm/as3525/sansa-clipzip/button-target.h new file mode 100644 index 0000000000..8a93d45daa --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/button-target.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
24 | |||
25 | #include "config.h" | ||
26 | |||
27 | void button_init_device(void); | ||
28 | int button_read_device(void); | ||
29 | |||
30 | /* Main unit's buttons */ | ||
31 | #define BUTTON_HOME 0x00000001 | ||
32 | |||
33 | #define BUTTON_VOL_UP 0x00000002 | ||
34 | #define BUTTON_VOL_DOWN 0x00000004 | ||
35 | |||
36 | #define BUTTON_UP 0x00000008 | ||
37 | #define BUTTON_DOWN 0x00000010 | ||
38 | #define BUTTON_LEFT 0x00000020 | ||
39 | #define BUTTON_RIGHT 0x00000040 | ||
40 | |||
41 | #define BUTTON_SELECT 0x00000080 | ||
42 | |||
43 | #define BUTTON_POWER 0x00000100 | ||
44 | |||
45 | #define BUTTON_MAIN (BUTTON_HOME|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ | ||
46 | |BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|BUTTON_RIGHT\ | ||
47 | |BUTTON_SELECT|BUTTON_POWER) | ||
48 | |||
49 | #define BUTTON_REMOTE 0 | ||
50 | |||
51 | /* Software power-off */ | ||
52 | #define POWEROFF_BUTTON BUTTON_POWER | ||
53 | #define POWEROFF_COUNT 10 | ||
54 | |||
55 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c new file mode 100644 index 0000000000..8efbdf77b9 --- /dev/null +++ b/firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c | |||
@@ -0,0 +1,103 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2008 François Dinel | ||
11 | * Copyright (C) 2008-2009 Rafaël Carré | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or | ||
14 | * modify it under the terms of the GNU General Public License | ||
15 | * as published by the Free Software Foundation; either version 2 | ||
16 | * of the License, or (at your option) any later version. | ||
17 | * | ||
18 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
19 | * KIND, either express or implied. | ||
20 | * | ||
21 | ****************************************************************************/ | ||
22 | #include "config.h" | ||
23 | |||
24 | #include "lcd.h" | ||
25 | #include "lcd-clip.h" | ||
26 | #include "system.h" | ||
27 | #include "cpu.h" | ||
28 | |||
29 | static int display_type; | ||
30 | |||
31 | int lcd_hw_init(void) | ||
32 | { | ||
33 | bitset32(&CGU_PERI, CGU_SSP_CLOCK_ENABLE); | ||
34 | |||
35 | SSP_CPSR = AS3525_SSP_PRESCALER; /* OF = 0x10 */ | ||
36 | SSP_CR0 = (1<<7) | (1<<6) | 7; /* Motorola SPI frame format, 8 bits */ | ||
37 | SSP_CR1 = (1<<3) | (1<<1); /* SSP Operation enabled */ | ||
38 | SSP_IMSC = 0; /* No interrupts */ | ||
39 | |||
40 | /* configure GPIO B2 (display D/C#) as output */ | ||
41 | GPIOB_DIR |= (1<<2); | ||
42 | |||
43 | /* configure GPIO B3 (display type detect) as input */ | ||
44 | GPIOB_DIR &= ~(1<<3); | ||
45 | |||
46 | /* set GPIO A5 (display RESET# ?) */ | ||
47 | GPIOA_DIR |= (1<<5); | ||
48 | GPIOA_PIN(5) = (1<<5); | ||
49 | |||
50 | /* detect display type on GPIO B3 */ | ||
51 | return GPIOB_PIN(3) ? 1 : 0; | ||
52 | } | ||
53 | |||
54 | void lcd_write_command(int byte) | ||
55 | { | ||
56 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
57 | ; | ||
58 | |||
59 | /* LCD command mode */ | ||
60 | GPIOB_PIN(2) = 0; | ||
61 | |||
62 | SSP_DATA = byte; | ||
63 | while(SSP_SR & (1<<4)) /* BSY flag */ | ||
64 | ; | ||
65 | } | ||
66 | |||
67 | void lcd_write_data(const fb_data* p_bytes, int count) | ||
68 | { | ||
69 | /* LCD data mode */ | ||
70 | GPIOB_PIN(2) = (1<<2); | ||
71 | |||
72 | while (count--) | ||
73 | { | ||
74 | while(!(SSP_SR & (1<<1))) /* wait until transmit FIFO is not full */ | ||
75 | ; | ||
76 | |||
77 | SSP_DATA = *p_bytes++; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | void lcd_update(void) | ||
82 | { | ||
83 | /* TODO */ | ||
84 | } | ||
85 | |||
86 | void lcd_init_device(void) | ||
87 | { | ||
88 | /* TODO */ | ||
89 | display_type = lcd_hw_init(); | ||
90 | } | ||
91 | |||
92 | /* Update a fraction of the display. */ | ||
93 | void lcd_update_rect(int x, int y, int width, int height) | ||
94 | { | ||
95 | (void) x; | ||
96 | (void) y; | ||
97 | (void) width; | ||
98 | (void) height; | ||
99 | |||
100 | /* TODO not implemented yet, do a full update instead */ | ||
101 | lcd_update(); | ||
102 | } | ||
103 | |||