From 463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08 Mon Sep 17 00:00:00 2001 From: Bertrik Sikken Date: Sat, 27 Aug 2011 16:21:19 +0000 Subject: [PATCH] Initial framework for the Sandisk Sansa Clip Zip git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30365 a1c6a512-1295-4272-9138-f99709370657 --- apps/bitmaps/native/SOURCES | 2 + apps/bitmaps/native/rockboxlogo.96x30x16.bmp | Bin 0 -> 8814 bytes bootloader/sansa_as3525.c | 2 +- firmware/SOURCES | 14 ++ firmware/export/config.h | 3 + firmware/export/config/sansaclipzip.h | 202 ++++++++++++++++++ .../target/arm/as3525/fmradio-i2c-as3525.c | 3 +- firmware/target/arm/as3525/memory-init.S | 3 +- firmware/target/arm/as3525/powermgmt-target.h | 9 + .../as3525/sansa-clipzip/backlight-clipzip.c | 42 ++++ .../as3525/sansa-clipzip/backlight-target.h | 30 +++ .../arm/as3525/sansa-clipzip/button-clipzip.c | 103 +++++++++ .../arm/as3525/sansa-clipzip/button-target.h | 55 +++++ .../arm/as3525/sansa-clipzip/lcd-clipzip.c | 103 +++++++++ rbutil/mkamsboot/mkamsboot.c | 3 + rbutil/mkamsboot/mkamsboot.h | 1 + tools/configure | 36 +++- tools/scramble.c | 4 +- 18 files changed, 603 insertions(+), 12 deletions(-) create mode 100644 apps/bitmaps/native/rockboxlogo.96x30x16.bmp create mode 100644 firmware/export/config/sansaclipzip.h create mode 100644 firmware/target/arm/as3525/sansa-clipzip/backlight-clipzip.c create mode 100644 firmware/target/arm/as3525/sansa-clipzip/backlight-target.h create mode 100644 firmware/target/arm/as3525/sansa-clipzip/button-clipzip.c create mode 100644 firmware/target/arm/as3525/sansa-clipzip/button-target.h create mode 100644 firmware/target/arm/as3525/sansa-clipzip/lcd-clipzip.c diff --git a/apps/bitmaps/native/SOURCES b/apps/bitmaps/native/SOURCES index 9ce7d89cff..1124543802 100644 --- a/apps/bitmaps/native/SOURCES +++ b/apps/bitmaps/native/SOURCES @@ -9,6 +9,8 @@ rockboxlogo.128x42x1.bmp #else rockboxlogo.112x30x1.bmp #endif +#elif (LCD_WIDTH == 96) && (LCD_DEPTH == 16) +rockboxlogo.96x30x16.bmp #elif (LCD_WIDTH == 128) && (LCD_DEPTH == 2) rockboxlogo.128x42x2.bmp #elif (LCD_WIDTH == 128) && (LCD_DEPTH == 16) diff --git a/apps/bitmaps/native/rockboxlogo.96x30x16.bmp b/apps/bitmaps/native/rockboxlogo.96x30x16.bmp new file mode 100644 index 0000000000000000000000000000000000000000..02e64e52a21f0184739128cb78520ac5edecd943 GIT binary patch literal 8814 zcmeHMc~n-{5g%D1iXko#l^Ttt?nZ>jDxgvgAPB<8Ch=oOK@mhW0Yy~YK!PcP2pU}2 zTtE~=1r=OcYb;6Cq@E;A+mp0Ov$Sc`Ha*>vroZ7n?|XdTr}0ov4}WCN<9+ky&0XgA z=FXkD_%6zDpdNC?eKP(M@HZBJ185ZPMDBS1_T%EONAQ4~v$OL9-ae{V0|pFmcXxkO zz5PG>@%Hwvs;U}1crXTQXlTgH%mm}<>DkfIF=WUP@QI0u@$vCsB$bz!ySTXEaqZf* z1qB6Q?CtGaT3W`A<&Oh>+-+@b^Yin~&CS7gb#=|1I~RtE&TJWo32Y z!i8bOhJkNtYSQU+V3LxODl03+#EOfHlarGn#4FK1ctHsX>=hs}N%SeFfgXg=(b2KH zyLHt zmlx!N1`R4JE3>w?2ESyL=>>x2SGn0MxFxECSdi;0SeGwQq zh$w6oUHQhub?Orn!p7g45SncMFv99PkFvLi8LIi33p9shuuKcN%9A@~9AHSf@|514mfXoS&<63VV3dk4xaSLT<0R9&2y#I{pp z#?e=$DX!H1rD{z3-)O4QR^|Ky$~mMoS+kFotGcPM&C~t4w|>-y>&gFA5Hsi&hQVu(SE|D z0)UWmzmSkw^L(YGAUBIYjLG$N@gLOqAwzcb*Nn)ayL8|-?e3(Cn^b;-irT59ld9gJ z(re@b^9|zB@KL1CQ!#4#Q1zO$Vv60U*lF-%VM!-{$Fsre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GTv?NC1e00Y&V)Tq~ zW%B|?{8bLU#nr>Q1N2H4$7XGF!DE?20UHYf=;_Zm&65`%p~LCbU3Ol1ZEsO`L*ov= zRia>oeSKjv#cksJNQ)8LW29kEvOTCUVse-PiFhph2yy!9X+lg`gMuC(#(5x?r*;Ms zBjgq%Mhis`x97yVP%zT!_Y+>h2;1%Al^l#PEdz`;Hju5oVmUGjpG_ZUe_3^2mM5OQvF3pNeMamd95A!$S| z2aK}!GZ2Chr_o&QeTdnJZsJT1xh0%Y)*`?NCmy!nL%VTf?6cBSvNBRvuUgKThju3Y zgjeH{oRIJ%Q|!ywtIX1R*@{Y$KeOp=uF?Y6AfaDYziiz(`6_5FlPW z*Y-0Y<1x#aSH+7ZGmdwE7ieh!G<6{V>7?hpA)V5lc_Sria540|an1s3CzgNd_39 zH@PrznA@*#(N5-JF~VZOv6EkqsMjHbBp;gP&>R*iH9xtW|U4rP!8;5 ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2011 Bertrik Sikken + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "backlight-target.h" +#include "lcd.h" +#include "as3525v2.h" +#include "ascodec-target.h" + +void _backlight_init() +{ + /* GPIO B2 controls backlight */ + GPIOB_DIR |= (1 << 2); +} + +void _backlight_on(void) +{ + /* TODO */ +} + +void _backlight_off(void) +{ + /* TODO */ +} + 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2011 Bertrik Sikken + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef BACKLIGHT_TARGET_H +#define BACKLIGHT_TARGET_H + +void _backlight_init(void); +void _backlight_on(void); +void _backlight_off(void); + +#define _backlight_panic_on() _backlight_on() + +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 François Dinel + * Copyright © 2008-2009 Rafaël Carré + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "config.h" + +#include "button-target.h" +#include "as3525v2.h" +#include "kernel.h" +#include "system-target.h" + +void button_init_device(void) +{ + /* GPIO A6, A7 and D6 are direct button inputs */ + GPIOA_DIR &= ~(1 << 6); + GPIOA_DIR &= ~(1 << 7); + GPIOD_DIR &= ~(1 << 6); + + /* GPIO C1, C2, C3, C4, C5 are used in a column/row key scan matrix */ + GPIOC_DIR |= ((1 << 1) | (1 << 2)); + GPIOC_DIR &= ~((1 << 3) | (1 << 4) | (1 << 5)); +} + +/* TODO: + Instead of using udelay to wait for buttons to settle, we could use a + simple state machine to alternate between key matrix rows (like we do on + the clip) and this way avoid burning cycles in the udelay. + + TODO: + Figure out the real mappings from GPIOs to buttons. + The current mapping is just an educated guess. +*/ +int button_read_device(void) +{ + int buttons = 0; + + /* power */ + if (GPIOD_PIN(6)) { + buttons |= BUTTON_POWER; + } + + /* volume */ + if (GPIOA_PIN(6)) { + buttons |= BUTTON_VOL_DOWN; + } + if (GPIOA_PIN(7)) { + buttons |= BUTTON_VOL_UP; + } + + /* key matrix buttons, first row */ + GPIOC_PIN(1) = (1 << 1); + GPIOC_PIN(2) = 0; + udelay(500); + + if (GPIOC_PIN(3)) { + buttons |= BUTTON_LEFT; + } + if (GPIOC_PIN(4)) { + buttons |= BUTTON_SELECT; + } + if (GPIOC_PIN(5)) { + buttons |= BUTTON_RIGHT; + } + + /* key matrix buttons, second row */ + GPIOC_PIN(1) = 0; + GPIOC_PIN(2) = (1 << 2); + udelay(500); + + if (GPIOC_PIN(3)) { + buttons |= BUTTON_UP; + } + if (GPIOC_PIN(4)) { + buttons |= BUTTON_HOME; + } + if (GPIOC_PIN(5)) { + buttons |= BUTTON_DOWN; + } + + /* deselect scan rows */ + GPIOC_PIN(2) = 0; + + return buttons; +} + 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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 François Dinel + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#ifndef _BUTTON_TARGET_H_ +#define _BUTTON_TARGET_H_ + +#include "config.h" + +void button_init_device(void); +int button_read_device(void); + +/* Main unit's buttons */ +#define BUTTON_HOME 0x00000001 + +#define BUTTON_VOL_UP 0x00000002 +#define BUTTON_VOL_DOWN 0x00000004 + +#define BUTTON_UP 0x00000008 +#define BUTTON_DOWN 0x00000010 +#define BUTTON_LEFT 0x00000020 +#define BUTTON_RIGHT 0x00000040 + +#define BUTTON_SELECT 0x00000080 + +#define BUTTON_POWER 0x00000100 + +#define BUTTON_MAIN (BUTTON_HOME|BUTTON_VOL_UP|BUTTON_VOL_DOWN\ + |BUTTON_UP|BUTTON_DOWN|BUTTON_LEFT|BUTTON_RIGHT\ + |BUTTON_SELECT|BUTTON_POWER) + +#define BUTTON_REMOTE 0 + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#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 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 François Dinel + * Copyright (C) 2008-2009 Rafaël Carré + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "config.h" + +#include "lcd.h" +#include "lcd-clip.h" +#include "system.h" +#include "cpu.h" + +static int display_type; + +int lcd_hw_init(void) +{ + bitset32(&CGU_PERI, CGU_SSP_CLOCK_ENABLE); + + SSP_CPSR = AS3525_SSP_PRESCALER; /* OF = 0x10 */ + SSP_CR0 = (1<<7) | (1<<6) | 7; /* Motorola SPI frame format, 8 bits */ + SSP_CR1 = (1<<3) | (1<<1); /* SSP Operation enabled */ + SSP_IMSC = 0; /* No interrupts */ + + /* configure GPIO B2 (display D/C#) as output */ + GPIOB_DIR |= (1<<2); + + /* configure GPIO B3 (display type detect) as input */ + GPIOB_DIR &= ~(1<<3); + + /* set GPIO A5 (display RESET# ?) */ + GPIOA_DIR |= (1<<5); + GPIOA_PIN(5) = (1<<5); + + /* detect display type on GPIO B3 */ + return GPIOB_PIN(3) ? 1 : 0; +} + +void lcd_write_command(int byte) +{ + while(SSP_SR & (1<<4)) /* BSY flag */ + ; + + /* LCD command mode */ + GPIOB_PIN(2) = 0; + + SSP_DATA = byte; + while(SSP_SR & (1<<4)) /* BSY flag */ + ; +} + +void lcd_write_data(const fb_data* p_bytes, int count) +{ + /* LCD data mode */ + GPIOB_PIN(2) = (1<<2); + + while (count--) + { + while(!(SSP_SR & (1<<1))) /* wait until transmit FIFO is not full */ + ; + + SSP_DATA = *p_bytes++; + } +} + +void lcd_update(void) +{ + /* TODO */ +} + +void lcd_init_device(void) +{ + /* TODO */ + display_type = lcd_hw_init(); +} + +/* Update a fraction of the display. */ +void lcd_update_rect(int x, int y, int width, int height) +{ + (void) x; + (void) y; + (void) width; + (void) height; + + /* TODO not implemented yet, do a full update instead */ + lcd_update(); +} + diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c index 715e11d0d5..2682b7b19b 100644 --- a/rbutil/mkamsboot/mkamsboot.c +++ b/rbutil/mkamsboot/mkamsboot.c @@ -122,6 +122,7 @@ const struct ams_models ams_identity[] = { [MODEL_FUZEV2] = { 2, 2, "Fuze", dualboot_fuzev2, sizeof(dualboot_fuzev2), "fuz2", 68 }, [MODEL_FUZE] = { 1, 1, "Fuze", dualboot_fuze, sizeof(dualboot_fuze), "fuze", 43 }, [MODEL_M200V4] = { 4, 1, "m200", dualboot_m200v4, sizeof(dualboot_m200v4), "m2v4", 42 }, + [MODEL_CLIPZIP] = { 1, 2, "ClipZip", NULL, 0, "clzp", 79 }, /* TODO */ }; @@ -169,6 +170,8 @@ static struct md5sums sansasums[] = { { MODEL_FUZEV2, "2.02.26", "d4f6f85c3e4a8ea8f2e5acc421641801" }, { MODEL_FUZEV2, "2.03.31", "74fb197ccd51707388f3b233402186a6" }, { MODEL_FUZEV2, "2.03.33", "1599cc73d02ea7fe53fe2d4379c24b66" }, + + { MODEL_CLIPZIP, "1.01.12", "45adea0873326b5af34f096e5c402f78" }, }; #define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0])) diff --git a/rbutil/mkamsboot/mkamsboot.h b/rbutil/mkamsboot/mkamsboot.h index 156315e4e4..263fe9e9c1 100644 --- a/rbutil/mkamsboot/mkamsboot.h +++ b/rbutil/mkamsboot/mkamsboot.h @@ -43,6 +43,7 @@ enum { MODEL_C200V2, MODEL_CLIPPLUS, MODEL_FUZEV2, + MODEL_CLIPZIP, /* new models go here */ NUM_MODELS diff --git a/tools/configure b/tools/configure index b28d3c4c97..3c4145f3da 100755 --- a/tools/configure +++ b/tools/configure @@ -1276,14 +1276,14 @@ cat <