From d462a64a918117991e11dade2d7fa3a28196e07a Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Sat, 6 Sep 2008 17:50:59 +0000 Subject: Initial commit of iaudio 7 port by Vitja Makarov (FS#9245). Port is at quite an advanced stage, but is troubled by the lack of a reliable NAND driver (similar to the Cowon D2 port) and is not yet suitable for non-developers. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18435 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/tcc77x/iaudio7/adc-target.h | 28 +++ firmware/target/arm/tcc77x/iaudio7/ata2501.c | 124 ++++++++++ firmware/target/arm/tcc77x/iaudio7/ata2501.h | 27 +++ firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c | 99 ++++++++ .../target/arm/tcc77x/iaudio7/backlight-target.h | 46 ++++ .../target/arm/tcc77x/iaudio7/button-iaudio7.c | 81 +++++++ firmware/target/arm/tcc77x/iaudio7/button-target.h | 57 +++++ firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c | 252 +++++++++++++++++++++ firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c | 146 ++++++++++++ 9 files changed, 860 insertions(+) create mode 100644 firmware/target/arm/tcc77x/iaudio7/adc-target.h create mode 100644 firmware/target/arm/tcc77x/iaudio7/ata2501.c create mode 100644 firmware/target/arm/tcc77x/iaudio7/ata2501.h create mode 100644 firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c create mode 100644 firmware/target/arm/tcc77x/iaudio7/backlight-target.h create mode 100644 firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c create mode 100644 firmware/target/arm/tcc77x/iaudio7/button-target.h create mode 100644 firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c create mode 100644 firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c (limited to 'firmware/target/arm/tcc77x/iaudio7') diff --git a/firmware/target/arm/tcc77x/iaudio7/adc-target.h b/firmware/target/arm/tcc77x/iaudio7/adc-target.h new file mode 100644 index 0000000000..1916d93598 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/adc-target.h @@ -0,0 +1,28 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 Dave Chapman + * + * 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 _ADC_TARGET_H_ +#define _ADC_TARGET_H_ + +#define NUM_ADC_CHANNELS 8 + +#define ADC_BUTTONS 0 + +#endif /* _ADC_TARGET_H_ */ diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.c b/firmware/target/arm/tcc77x/iaudio7/ata2501.c new file mode 100644 index 0000000000..fa165d9d0d --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.c @@ -0,0 +1,124 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 "cpu.h" +#include "button.h" + +#include "ata2501.h" + +#define STB (1<<5) +#define SDATA (1<<4) +#define RESET (1<<6) +#define SIFMD (1<<7) +#define STB_DELAY 200 + +#define udelay _udelay + +/* do we really need it? */ +static void _udelay(int cycles) +{ + cycles /= 8; + while (cycles--) { + asm("nop;nop;"); + } +} + +/* + TODO: sensitivity using GPIOS +*/ +void ata2501_init(void) +{ + GPIOD_DIR |= (RESET | STB | SIFMD | (1 << 8) | (1 << 9)); + GPIOD_DIR &= ~(SDATA); + + GPIOD &= ~RESET; + udelay(1000); + + GPIOD |= RESET; + + GPIOD &= ~STB; + +#if 1 + GPIOD &= ~((1 << 9) | (1 << 8)); + GPIOD |= ((1 << 8) | SIFMD) | (1 << 9); +#else + GPIOD |= ((1 << 9) | (1 << 8)); + GPIOD &= ~(SIFMD); +#endif +} + +unsigned short ata2501_read(void) +{ + unsigned short ret = 0; + int i; + + for (i = 0; i < 12; i++) { + GPIOD |= STB; + udelay(50); + + ret <<= 1; + if (GPIOD & SDATA) + ret |= 1; + udelay(50); + GPIOD &= ~STB; + udelay(100); + } + + return ret; +} + +#define ATA2501_TEST +#ifdef ATA2501_TEST +#include "lcd.h" +#include "sprintf.h" + +static +void bits(char *str, unsigned short val) +{ + int i; + + for (i = 0; i < 12; i++) + str[i] = (val & (1 << i)) ? '1' : '0'; + str[i] = 0; +} + +void ata2501_test(void) +{ + char buf[100]; + ata2501_init(); + + while (1) { + unsigned short data; + int i, line = 0; + + data = ata2501_read(); + lcd_clear_display(); + lcd_puts(0, line++, "ATA2501 test"); + + bits(buf, data); + lcd_puts(0, line++, buf); + + lcd_update(); + udelay(2000); + } +} +#endif diff --git a/firmware/target/arm/tcc77x/iaudio7/ata2501.h b/firmware/target/arm/tcc77x/iaudio7/ata2501.h new file mode 100644 index 0000000000..465d0b199c --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/ata2501.h @@ -0,0 +1,27 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 _ATA2501_H_ +#define _ATA2501_H_ + +void ata2501_init(void); +unsigned short ata2501_read(void); + +#endif /* _ATA2501_H_ */ diff --git a/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c new file mode 100644 index 0000000000..4e7f58df47 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/audio-iaudio7.c @@ -0,0 +1,99 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007 by Michael Sevakis + * + * 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 "system.h" +#include "cpu.h" +#include "audio.h" +#include "sound.h" + +int audio_channels = 2; +int audio_output_source = AUDIO_SRC_PLAYBACK; + +void audiohw_enable_output(bool on) +{ + (void) on; +} + +void audio_set_output_source(int source) +{ + int oldmode = set_fiq_status(FIQ_DISABLED); + + if ((unsigned)source >= AUDIO_NUM_SOURCES) + source = AUDIO_SRC_PLAYBACK; + + audio_output_source = source; + set_fiq_status(oldmode); +} + +void audio_input_mux(int source, unsigned flags) +{ + static int last_source = AUDIO_SRC_PLAYBACK; + static bool last_recording = false; + bool recording = flags & SRCF_RECORDING; + + switch (source) + { + default: /* playback - no recording */ + source = AUDIO_SRC_PLAYBACK; + case AUDIO_SRC_PLAYBACK: + audio_channels = 2; + if (source != last_source) + { + audiohw_set_monitor(false); + /* audiohw_disable_recording();*/ + } + break; + + case AUDIO_SRC_MIC: /* recording only */ + GPIOD |= 0x1; + + audio_channels = 1; + if (source != last_source) + { + /*audiohw_set_monitor(false); + audiohw_enable_recording(true); /. source mic */ + } + break; + + case AUDIO_SRC_FMRADIO: /* recording and playback */ + GPIOD &= ~0x1; + + audio_channels = 2; + + if (source == last_source && recording == last_recording) + break; + + last_recording = recording; + + if (recording) + { + /*audiohw_set_monitor(false); + audiohw_enable_recording(false);*/ + } + else + { + /*audiohw_disable_recording(); */ + audiohw_set_monitor(true); /* line 1 analog audio path */ + } + break; + } /* end switch */ + + last_source = source; +} /* audio_input_mux */ diff --git a/firmware/target/arm/tcc77x/iaudio7/backlight-target.h b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h new file mode 100644 index 0000000000..597583b16f --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/backlight-target.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 + +#include +#include "tcc77x.h" + +void power_touch_panel(bool on); + +static inline bool _backlight_init(void) +{ + GPIOD_DIR |= 0x2; + return true; +} + +static inline void _backlight_on(void) +{ + GPIOD |= 0x2; + power_touch_panel(true); +} + +static inline void _backlight_off(void) +{ + GPIOD &= ~0x2; + power_touch_panel(false); +} +#endif /* BACKLIGHT_TARGET_H */ diff --git a/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c new file mode 100644 index 0000000000..3aad4f75a4 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/button-iaudio7.c @@ -0,0 +1,81 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 "cpu.h" +#include "button.h" +#include "adc.h" + +#include "button-target.h" +#include "ata2501.h" + +void button_init_device(void) +{ + ata2501_init(); +} + +/* + touchpad: + 0: stop + 1-8: between next & prev + 9: play + 10: next + 11: prev +*/ + +int button_read_device(void) +{ + int btn = BUTTON_NONE; + int adc; + int sensor; + + if (button_hold()) + return BUTTON_NONE; + + adc = adc_read(0); + sensor = ata2501_read(); + + if (0 == (GPIOA & 4)) + btn |= BUTTON_POWER; + + /* seems they can't be hold together */ + if (adc < 0x120) + btn |= BUTTON_VOLUP; + else if (adc < 0x270) + btn |= BUTTON_VOLDOWN; + else if (adc < 0x300) + btn |= BUTTON_MENU; + + if (sensor & (1 << 0)) + btn |= BUTTON_STOP; + if (sensor & (1 << 9)) + btn |= BUTTON_PLAY; + if (sensor & ((1 << 10) | 0x1c0)) + btn |= BUTTON_RIGHT; + if (sensor & ((1 << 11) | 0xe)) + btn |= BUTTON_LEFT; + + return btn; +} + +bool button_hold(void) +{ + return !(GPIOA & 0x2); +} diff --git a/firmware/target/arm/tcc77x/iaudio7/button-target.h b/firmware/target/arm/tcc77x/iaudio7/button-target.h new file mode 100644 index 0000000000..fafaf4a303 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/button-target.h @@ -0,0 +1,57 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 _IAUDIO7_BUTTON_TARGET_H_ +#define _IAUDIO7_BUTTON_TARGET_H_ + +#include +#include "config.h" + +#define HAS_BUTTON_HOLD + +bool button_hold(void); +void button_init_device(void); +int button_read_device(void); + +/* Main unit's buttons */ +#define BUTTON_POWER 0x00000001 +#define BUTTON_VOLUP 0x00000002 +#define BUTTON_VOLDOWN 0x00000004 +#define BUTTON_MENU 0x00000008 + +#define BUTTON_LEFT 0x00000010 +#define BUTTON_RIGHT 0x00000020 +#define BUTTON_PLAY 0x00000040 +#define BUTTON_STOP 0x00000080 + +#define BUTTON_ON BUTTON_POWER + +#define BUTTON_MAIN (BUTTON_POWER|BUTTON_VOLUP|BUTTON_VOLDOWN| \ + BUTTON_MENU|BUTTON_LEFT|BUTTON_RIGHT| \ + BUTTON_PLAY|BUTTON_STOP) + +/* No remote */ +#define BUTTON_REMOTE 0 + +/* Software power-off */ +#define POWEROFF_BUTTON BUTTON_POWER +#define POWEROFF_COUNT 10 + +#endif /* _IAUDIO7_BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c new file mode 100644 index 0000000000..bbc20b6860 --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c @@ -0,0 +1,252 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2004 by Linus Nielsen Feltzing + * + * 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. + * + ****************************************************************************/ + +/* + Thanks Hein-Pieter van Braam for initial work. + + Mostly based on lcd-h300.c, adapted for the iaudio 7 by Vitja Makarov + */ + +#include + +#include +#include +#include +#include + +#include "hd66789r.h" + +static bool display_on = false; /* is the display turned on? */ + +static inline void lcd_write_reg(int reg, int data) +{ + GPIOA &= ~0x400; + outw(0, 0x50010000); + outw(reg << 1, 0x50010000); + GPIOA |= 0x400; + + outw((data & 0xff00) >> 7, 0x50010008); + outw((data << 24) >> 23, 0x50010008); +} + +static void lcd_write_cmd(int reg) +{ + GPIOA &= ~0x400; + outw(0, 0x50010000); + outw(reg << 1, 0x50010000); + GPIOA |= 0x400; +} + +/* Do what OF do */ +static void lcd_delay(int x) +{ + int i; + + x *= 0xc35; + for (i = 0; i < x * 8; i++) { + } +} + + +static void _display_on(void) +{ + GPIOA_DIR |= 0x8000 | 0x400; + GPIOA |= 0x8000; + + /* power setup */ + lcd_write_reg(R_START_OSC, 0x0001); + lcd_delay(0xf); + lcd_write_reg(R_DISP_CONTROL1, 0x000); + lcd_delay(0xa); + lcd_write_reg(R_POWER_CONTROL2, 0x0002); + lcd_write_reg(R_POWER_CONTROL3, 0x000a); + lcd_write_reg(R_POWER_CONTROL4, 0xc5a); + lcd_write_reg(R_POWER_CONTROL1, 0x0004); + lcd_write_reg(R_POWER_CONTROL1, 0x0134); + lcd_write_reg(R_POWER_CONTROL2, 0x0111); + lcd_write_reg(R_POWER_CONTROL3, 0x001c); + lcd_delay(0x28); + lcd_write_reg(R_POWER_CONTROL4, 0x2c40); + lcd_write_reg(R_POWER_CONTROL1, 0x0510); + lcd_delay(0x3c); + + /* lcd init 2 */ + lcd_write_reg(R_DRV_OUTPUT_CONTROL, 0x0113); + lcd_write_reg(R_DRV_WAVEFORM_CONTROL, 0x0700); + lcd_write_reg(R_ENTRY_MODE, 0x1038); + lcd_write_reg(R_DISP_CONTROL2, 0x0508); // 0x3c8, TMM + lcd_write_reg(R_DISP_CONTROL3, 0x0000); + lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0003); + lcd_write_reg(R_RAM_ADDR_SET, 0x0000); + lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0406); + lcd_write_reg(R_GAMMA_FINE_ADJ_POS2, 0x0303); + lcd_write_reg(R_GAMMA_FINE_ADJ_POS3, 0x0000); + lcd_write_reg(R_GAMMA_GRAD_ADJ_POS, 0x0305); + lcd_write_reg(R_GAMMA_FINE_ADJ_NEG1, 0x0404); + lcd_write_reg(R_GAMMA_FINE_ADJ_NEG2, 0x0000); + lcd_write_reg(R_GAMMA_FINE_ADJ_NEG3, 0x0000); + lcd_write_reg(R_GAMMA_GRAD_ADJ_NEG, 0x0503); + lcd_write_reg(R_GAMMA_AMP_ADJ_RES_POS, 0x1d05); + lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x1d05); + lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000); + lcd_write_reg(R_1ST_SCR_DRV_POS, 0x9f00); + lcd_write_reg(R_2ND_SCR_DRV_POS, 0x9f00); + lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 0x7f00); + lcd_write_reg(R_VERT_RAM_ADDR_POS, 0x9f00); + + /* lcd init 3 */ + lcd_write_reg(R_POWER_CONTROL1, 0x4510); + lcd_write_reg(R_DISP_CONTROL1, 0x0005); + lcd_delay(0x28); + lcd_write_reg(R_DISP_CONTROL1, 0x0025); + lcd_write_reg(R_DISP_CONTROL1, 0x0027); + lcd_delay(0x28); + lcd_write_reg(R_DISP_CONTROL1, 0x0037); + + display_on = true; +} + +void lcd_init_device(void) +{ + /* Configure external memory banks */ + CSCFG1 = 0x3d500023; + + /* may be reset */ + GPIOA |= 0x8000; + + _display_on(); +} + +void lcd_enable(bool on) +{ + if (display_on == on) + return; + + if (on) { + _display_on(); +// lcd_call_enable_hook(); + } else { + /** Off sequence according to datasheet, p. 130 **/ + lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */ + lcd_write_reg(R_DISP_CONTROL1, 0x0036); /* GON=1, DTE=1, REV=1, D1-0=10 */ + sleep(2); + + lcd_write_reg(R_DISP_CONTROL1, 0x0026); /* GON=1, DTE=0, REV=1, D1-0=10 */ + sleep(2); + + lcd_write_reg(R_DISP_CONTROL1, 0x0000); /* GON=0, DTE=0, D1-0=00 */ + + lcd_write_reg(R_POWER_CONTROL1, 0x0000); /* SAP2-0=000, AP2-0=000 */ + lcd_write_reg(R_POWER_CONTROL3, 0x0000); /* PON=0 */ + lcd_write_reg(R_POWER_CONTROL4, 0x0000); /* VCOMG=0 */ + + /* datasheet p. 131 */ + lcd_write_reg(R_POWER_CONTROL1, 0x0001); /* STB=1: standby mode */ + + display_on = false; + } +} + +bool lcd_enabled(void) +{ + return display_on; +} + + +#define RGB(r,g,b) ((((r)&0x3f) << 12)|(((g)&0x3f) << 6)|(((b)&0x3f))) + + +void lcd_update(void) +{ + lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); +} + +/* todo: need tests */ +void lcd_update_rect(int sx, int sy, int width, int height) +{ + int x, y; + + if (!display_on) + return; + + if (width <= 0 || height <= 0) /* nothing to do */ + return; + + width += sx; + height += sy; + + if (width > LCD_WIDTH) + width = LCD_WIDTH; + if (height > LCD_HEIGHT) + height = LCD_HEIGHT; + + lcd_write_reg(R_ENTRY_MODE, 0x1028); + /* set update window */ + lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8); + lcd_write_reg(R_VERT_RAM_ADDR_POS, ((width - 1) << 8) | sx); + lcd_write_reg(R_RAM_ADDR_SET, (sx << 8) | (LCD_HEIGHT - sy - 1)); + lcd_write_cmd(R_WRITE_DATA_2_GRAM); + + for (y = sy; y < height; y++) { + for (x = sx; x < width; x++) { + fb_data c; + unsigned long color; + + c = lcd_framebuffer[y][x]; + color = + ((c & 0x1f) << 1) | ((c & 0x7e0) << 1) | ((c & 0xf800) << + 2); + + /* TODO: our color is 18-bit */ + outw((color >> 9) & 0x1ff, 0x50010008); + outw((color) & 0x1ff, 0x50010008); + } + } +} + +void lcd_set_contrast(int val) +{ + (void) val; +} + +void lcd_set_invert_display(bool yesno) +{ + (void) yesno; +} + +void lcd_set_flip(bool yesno) +{ + (void) yesno; +} + +/* TODO: implement me */ +void lcd_blit_yuv(unsigned char *const src[3], + int src_x, int src_y, int stride, + int x, int y, int width, int height) +{ + if (!display_on) + return; + + width &= ~1; /* stay on the safe side */ + height &= ~1; + + panicf("%s", __func__); +} diff --git a/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c new file mode 100644 index 0000000000..ef012cbbdf --- /dev/null +++ b/firmware/target/arm/tcc77x/iaudio7/power-iaudio7.c @@ -0,0 +1,146 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2008 Vitja Makarov + * + * 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 + +#include "config.h" +#include "cpu.h" +#include "kernel.h" +#include "system.h" +#include "power.h" + +#include "pcf50606.h" + +void power_init(void) +{ + pcf50606_write(PCF5060X_DCDC1, 0x90); + pcf50606_write(PCF5060X_DCDC2, 0x48); + pcf50606_write(PCF5060X_DCDC3, 0xfc); + pcf50606_write(PCF5060X_DCDC4, 0xb1); + + pcf50606_write(PCF5060X_IOREGC, 0xe9); + /* 3.3V, touch-panel */ + pcf50606_write(PCF5060X_D1REGC1, 0xf8); + pcf50606_write(PCF5060X_D2REGC1, 0xf2); + pcf50606_write(PCF5060X_D3REGC1, 0xf5); + + pcf50606_write(PCF5060X_LPREGC1, 0x00); + pcf50606_write(PCF5060X_LPREGC2, 0x02); + + pcf50606_write(PCF5060X_DCUDC1, 0xe6); + pcf50606_write(PCF5060X_DCUDC2, 0x30); + + pcf50606_write(PCF5060X_DCDEC1, 0xe7); + pcf50606_write(PCF5060X_DCDEC2, 0x02); + + pcf50606_write(PCF5060X_INT1M, 0x5b); + pcf50606_write(PCF5060X_INT1M, 0xaf); + pcf50606_write(PCF5060X_INT1M, 0x8f); + + pcf50606_write(PCF5060X_OOCC1, 0x40); + pcf50606_write(PCF5060X_OOCC2, 0x05); + + pcf50606_write(PCF5060X_MBCC3, 0x3a); + pcf50606_write(PCF5060X_GPOC1, 0x00); + pcf50606_write(PCF5060X_BBCC, 0xf8); +} + +/* Control leds on ata2501 board */ +void power_touch_panel(bool on) +{ + if (on) + pcf50606_write(PCF5060X_D1REGC1, 0xf8); + else + pcf50606_write(PCF5060X_D1REGC1, 0x00); +} + +void ide_power_enable(bool on) +{ +} + +bool ide_powered(void) +{ + return true; +} + +void power_off(void) +{ + /* Forcibly cut power to SoC & peripherals by putting the PCF to sleep */ + pcf50606_write(PCF5060X_OOCC1, GOSTDBY | CHGWAK | EXTONWAK); +} + +#if CONFIG_TUNER +#include "tuner.h" + +/** Tuner **/ +static bool powered = false; + +#define TUNNER_CLK (1 << 5) +#define TUNNER_DATA (1 << 6) +#define TUNNER_NR_W (1 << 7) + +bool tuner_power(bool status) +{ + bool old_status; + lv24020lp_lock(); + + old_status = powered; + + if (status != old_status) + { + if (status) + { + /* When power up, host should initialize the 3-wire bus + in host read mode: */ + + /* 1. Set direction of the DATA-line to input-mode. */ + GPIOA_DIR &= ~TUNNER_DATA; + + /* 2. Drive NR_W low */ + GPIOA &= ~TUNNER_NR_W; + GPIOA_DIR |= TUNNER_NR_W; + + /* 3. Drive CLOCK high */ + GPIOA |= TUNNER_CLK; + GPIOA_DIR |= TUNNER_CLK; + + lv24020lp_power(true); + } + else + { + lv24020lp_power(false); + + /* set all as inputs */ + GPIOC_DIR &= ~(TUNNER_CLK | TUNNER_DATA | TUNNER_NR_W); + } + + powered = status; + } + + lv24020lp_unlock(); + return old_status; +} + +#endif /* CONFIG_TUNER */ + +bool charger_inserted(void) +{ + return (GPIOA & 0x1) ? true : false; +} -- cgit v1.2.3