summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-03-16 22:38:57 +0000
committerThomas Martitz <kugel@rockbox.org>2010-03-16 22:38:57 +0000
commitb5b2a03ee2257139ca06fc4f29d856f49bf05b5a (patch)
tree5b2534ad793cd30d6c652ee2f3a95f2f844b9ad7
parent25065a6423bc8f21ddbe986e80dc24a6b9889d77 (diff)
downloadrockbox-b5b2a03ee2257139ca06fc4f29d856f49bf05b5a.zip
rockbox-b5b2a03ee2257139ca06fc4f29d856f49bf05b5a.tar.gz
rockbox-b5b2a03ee2257139ca06fc4f29d856f49bf05b5a.tar.bz2
rockbox-b5b2a03ee2257139ca06fc4f29d856f49bf05b5a.tar.xz
A tiny bit more Sansa Fuze v2 work.
- buttonlight works - backlight turns on (quite weak though and no brightness adjustment/backlight off functional) - don't share drivers with e200v2/fuzev1 for now as it's not entirely clear how dbop plays into this - deactivte scrollwheel as it's messing up the timer setup in kernel-as3525.c indicating the dbop input reading doesn't work well - still no working bootloader/no lcd or buttons git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25225 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/SOURCES5
-rw-r--r--firmware/export/config/sansafuzev2.h16
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c86
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h6
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c37
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c111
6 files changed, 242 insertions, 19 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index a6c9e5e..c347ad7 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1298,11 +1298,10 @@ target/arm/as3525/sansa-fuze/powermgmt-fuze.c
#ifdef SANSA_FUZEV2
#ifndef SIMULATOR
-target/arm/as3525/button-e200v2-fuze.c
target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
target/arm/as3525/lcd-as-e200v2-fuze.S
-target/arm/as3525/backlight-e200v2-fuze.c
-target/arm/as3525/dbop-as3525.c
+target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
+target/arm/as3525/sansa-fuzev2/button-fuzev2.c
#ifndef BOOTLOADER
target/arm/powermgmt-ascodec.c
target/arm/as3525/sansa-fuzev2/powermgmt-fuzev2.c
diff --git a/firmware/export/config/sansafuzev2.h b/firmware/export/config/sansafuzev2.h
index bc50bde..a6c2264 100644
--- a/firmware/export/config/sansafuzev2.h
+++ b/firmware/export/config/sansafuzev2.h
@@ -37,9 +37,6 @@
/* define this to enable JPEG decoding */
#define HAVE_JPEG
-/* define this if you have a light associated with the buttons */
-#define HAVE_BUTTON_LIGHT
-
/* define this if you have access to the quickscreen */
#define HAVE_QUICKSCREEN
@@ -123,17 +120,20 @@
#define MAX_BRIGHTNESS_SETTING 12
#define DEFAULT_BRIGHTNESS_SETTING 6
+/* define this if you have a light associated with the buttons */
+#define HAVE_BUTTON_LIGHT
+
/* Which backlight fading type? */
-#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+//#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
/* define this if the unit uses a scrollwheel for navigation */
-#define HAVE_SCROLLWHEEL
+//#define HAVE_SCROLLWHEEL
/* define to activate advanced wheel acceleration code */
-#define HAVE_WHEEL_ACCELERATION
+//#define HAVE_WHEEL_ACCELERATION
/* define from which rotation speed [degree/sec] on the acceleration starts */
-#define WHEEL_ACCEL_START 540
+//#define WHEEL_ACCEL_START 540
/* define type of acceleration (1 = ^2, 2 = ^3, 3 = ^4) */
-#define WHEEL_ACCELERATION 1
+//#define WHEEL_ACCELERATION 1
/* define this if you have a flash memory storage */
#define HAVE_FLASH_STORAGE
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
new file mode 100644
index 0000000..56b375b
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuzev2/backlight-fuzev2.c
@@ -0,0 +1,86 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 "backlight-target.h"
+#include "system.h"
+#include "lcd.h"
+#include "backlight.h"
+#include "ascodec-target.h"
+#include "as3514.h"
+
+int buttonlight_is_on = 0;
+
+static int brightness_internal = 0;
+
+/* not functional */
+void _backlight_set_brightness(int brightness)
+{
+ //ascodec_write(AS3514_DCDC15, brightness);
+ brightness_internal = brightness << 2;
+ brightness_internal += brightness + 5;
+ brightness_internal <<= 25;
+ brightness_internal >>= 24;
+ ascodec_write(27, brightness_internal|0xff);
+}
+
+bool _backlight_init(void)
+{
+ GPIOB_DIR |= 1<<5; /* for buttonlight, stuff below seems to be needed
+ for buttonlight as well*/
+ ascodec_write(0x1c, 8|1);
+ ascodec_write(27, 0xff);
+ return true;
+}
+
+/* not functional */
+void _backlight_on(void)
+{
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(true); /* power on lcd + visible display */
+#endif
+#if (CONFIG_BACKLIGHT_FADING != BACKLIGHT_FADING_SW_SETTING) /* in bootloader/sim */
+ /* if we set the brightness to the settings value, then fading up
+ * is glitchy */
+ ascodec_write(27, brightness_internal);
+#endif
+}
+
+/* not functional */
+void _backlight_off(void)
+{
+ ascodec_write(0x1c, 0);
+ ascodec_write(27, 0);
+#ifdef HAVE_LCD_ENABLE
+ lcd_enable(false); /* power off visible display */
+#endif
+}
+
+void _buttonlight_on(void)
+{
+ GPIOB_PIN(5) = (1<<5);
+ buttonlight_is_on = 1;
+}
+
+void _buttonlight_off(void)
+{
+ GPIOB_PIN(5) = 0;
+ buttonlight_is_on = 0;
+}
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h b/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h
index 2d60ac3..e4ed787 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h
+++ b/firmware/target/arm/as3525/sansa-fuzev2/backlight-target.h
@@ -21,7 +21,11 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define _backlight_init() true
+#include <stdbool.h>
+#include "config.h"
+#include "ascodec.h"
+
+bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
void _backlight_set_brightness(int brightness);
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
new file mode 100644
index 0000000..428f2ca
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-fuzev2/button-fuzev2.c
@@ -0,0 +1,37 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 by Thomas Martitz
+ *
+ * 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 "system.h"
+#include "button.h"
+
+void button_init_device(void)
+{
+}
+
+/*
+ * Get button pressed from hardware
+ */
+int button_read_device(void)
+{
+ return 0;
+}
+
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
index bdf1c70..4a5948a 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
@@ -8,6 +8,7 @@
* $Id$
*
* Copyright (C) 2008 by Dave Chapman
+ * Copyright (C) 2010 by Thomas Martitz
*
* LCD driver for the Sansa Fuze - controller unknown
*
@@ -28,7 +29,6 @@
#include "debug.h"
#include "system.h"
#include "clock-target.h"
-#include "dbop-as3525.h"
/* The controller is unknown, but some registers appear to be the same as the
HD66789R */
@@ -101,8 +101,12 @@ static inline void lcd_delay(int x)
} while (x--);
}
+#define REG(x) (*(volatile unsigned long*)(x))
+typedef unsigned long reg;
+
static void as3525_dbop_init(void)
{
+#if 0
CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;
DBOP_TIMPOL_01 = 0xe167e167;
@@ -122,10 +126,69 @@ static void as3525_dbop_init(void)
DBOP_TIMPOL_23 = 0xa167e06f;
/* TODO: The OF calls some other functions here, but maybe not important */
+#endif
+ REG(0xC810000C) |= 0x1000; /* CCU_IO |= 1<<12 */
+ CGU_DBOP |= /*(1<<3)*/ 0x18 | AS3525_DBOP_DIV;
+ DBOP_TIMPOL_01 = 0xE12FE12F;
+ DBOP_TIMPOL_23 = 0xE12F0036;
+ DBOP_CTRL = 0x41004;
+ DBOP_TIMPOL_23 = 0x60036;
+ DBOP_CTRL = 0x51004;
+ DBOP_TIMPOL_01 = 0x60036;
+ DBOP_TIMPOL_23 = 0xA12FE037;
+ /* OF sets up dma and more after here */
+}
+
+static inline void dbop_set_mode(int mode)
+{
+ int delay = 10;
+ if (mode == 32 && (!(DBOP_CTRL & (1<<13|1<<14))))
+ DBOP_CTRL |= (1<<13|1<<14);
+ else if (mode == 16 && (DBOP_CTRL & (1<<13|1<<14)))
+ DBOP_CTRL &= ~(1<<14|1<<13);
+ else
+ return;
+ while(delay--) asm volatile("nop");
+}
+
+static void dbop_write_data(const int16_t* p_bytes, int count)
+{
+
+ const int32_t *data;
+ if ((intptr_t)p_bytes & 0x3 || count == 1)
+ { /* need to do a single 16bit write beforehand if the address is
+ * not word aligned or count is 1, switch to 16bit mode if needed */
+ dbop_set_mode(16);
+ DBOP_DOUT16 = *p_bytes++;
+ if (!(--count))
+ return;
+ }
+ /* from here, 32bit transfers are save
+ * set it to transfer 4*(outputwidth) units at a time,
+ * if bit 12 is set it only does 2 halfwords though (we never set it)
+ * switch to 32bit output if needed */
+ dbop_set_mode(32);
+ data = (int32_t*)p_bytes;
+ while (count > 1)
+ {
+ DBOP_DOUT32 = *data++;
+ count -= 2;
+
+ /* Wait if push fifo is full */
+ while ((DBOP_STAT & (1<<6)) != 0);
+ }
+ /* While push fifo is not empty */
+ while ((DBOP_STAT & (1<<10)) == 0);
+
+ /* due to the 32bit alignment requirement or uneven count,
+ * we possibly need to do a 16bit transfer at the end also */
+ if (count > 0)
+ dbop_write_data((int16_t*)data, 1);
}
static void lcd_write_cmd(short cmd)
{
+#if 0
/* Write register */
DBOP_TIMPOL_23 = 0xa167006e;
dbop_write_data(&cmd, 1);
@@ -133,12 +196,36 @@ static void lcd_write_cmd(short cmd)
lcd_delay(4);
DBOP_TIMPOL_23 = 0xa167e06f;
+#elif 1
+ volatile int i;
+ for(i=0;i<20;i++) nop;
+
+ int r3 = 0x2000;
+ DBOP_CTRL |= r3;
+ r3 >>= 1;
+ DBOP_CTRL &= ~r3;
+ r3 <<= 2;
+ DBOP_CTRL &= ~r3;
+ DBOP_TIMPOL_23 = 0xA12F0036;
+ cmd = swap16(cmd);
+ DBOP_DOUT16 = cmd;
+
+ while ((DBOP_STAT & (1<<10)) == 0);
+ for(i=0;i<20;i++) nop;
+ DBOP_TIMPOL_23 = 0xA12FE037;
+#else
+ int i;
+ DBOP_TIMPOL_23 = 0xA12F0036;
+ for(i=0;i<20;i++) nop;
+ dbop_write_data(&cmd, 1);
+ for(i=0;i<20;i++) nop;
+ DBOP_TIMPOL_23 = 0xA12FE037;
+#endif
}
static void lcd_write_reg(int reg, int value)
{
int16_t data = value;
-
lcd_write_cmd(reg);
dbop_write_data(&data, 1);
}
@@ -227,11 +314,20 @@ void lcd_init_device(void)
{
as3525_dbop_init();
- GPIOA_DIR |= (1<<5|1<<4|1<<3);
- GPIOA_PIN(5) = 0;
- GPIOA_PIN(3) = (1<<3);
+ GPIOA_DIR |= (0x20|0x1);
+ GPIOA_DIR &= ~(1<<3);
+ GPIOA_PIN(3) = 0;
+ GPIOA_PIN(0) = 1;
GPIOA_PIN(4) = 0;
- GPIOA_PIN(5) = (1<<5);
+
+ CCU_IO &= ~(0x1000);
+ GPIOB_DIR |= 0x2f;
+ GPIOB_PIN(0) = 1<<0;
+ GPIOB_PIN(1) = 1<<1;
+ GPIOB_PIN(2) = 1<<2;
+ GPIOB_PIN(3) = 1<<3;
+ GPIOA_PIN(4) = 1<<4;
+ GPIOA_PIN(5) = 1<<5;
_display_on();
}
@@ -394,7 +490,8 @@ void lcd_update(void)
lcd_write_cmd(R_WRITE_DATA_2_GRAM);
- dbop_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
+ lcd_update_rect(0,0, LCD_WIDTH, LCD_HEIGHT);
+ //dbop_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
}
/* Update a fraction of the display. */