diff options
author | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2013-11-16 18:21:00 +0400 |
---|---|---|
committer | Andrew Ryabinin <ryabinin.a.a@gmail.com> | 2013-12-16 00:45:18 +0400 |
commit | 5b5f0755d6d7fd9e3fdfdb479caeb7fafd0a9960 (patch) | |
tree | 4b9c567df8a5aefb46ace938a034988b7fdb045d /firmware/target | |
parent | 04c59b8a15f96812081ea8730337825af679fbce (diff) | |
download | rockbox-5b5f0755d6d7fd9e3fdfdb479caeb7fafd0a9960.tar.gz rockbox-5b5f0755d6d7fd9e3fdfdb479caeb7fafd0a9960.zip |
Introduce IHIFI760/960 targets.
Change-Id: Ie36e48742c0ed9aa3fd6f49aa034a11d2492327c
Diffstat (limited to 'firmware/target')
-rw-r--r-- | firmware/target/arm/rk27xx/backlight-rk27xx.c | 7 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/debug-rk27xx.c | 3 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/button-ihifi.c | 53 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/button-target.h | 40 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c | 224 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/lcd-target.h | 26 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/power-ihifi.c | 51 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c | 65 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c | 65 | ||||
-rw-r--r-- | firmware/target/arm/rk27xx/sd-rk27xx.c | 3 |
10 files changed, 536 insertions, 1 deletions
diff --git a/firmware/target/arm/rk27xx/backlight-rk27xx.c b/firmware/target/arm/rk27xx/backlight-rk27xx.c index 5d92cd827b..361d18c948 100644 --- a/firmware/target/arm/rk27xx/backlight-rk27xx.c +++ b/firmware/target/arm/rk27xx/backlight-rk27xx.c @@ -68,6 +68,13 @@ static const unsigned short lin_brightness[] = { 198, 227, 260, 295, 334, 376, 421, 470, 522, 578, 638, 702, 770, 842, 918, 1000 }; +#elif defined(IHIFI760) || defined(IHIFI960) +static const unsigned short lin_brightness[] = { + 700, 701, 702, 703, 704, 706, 708, 711, + 714, 717, 721, 726, 731, 737, 743, 751, + 759, 768, 778, 788, 800, 812, 826, 841, + 856, 873, 891, 910, 931, 952, 975, 1000 +}; #endif bool _backlight_init(void) diff --git a/firmware/target/arm/rk27xx/debug-rk27xx.c b/firmware/target/arm/rk27xx/debug-rk27xx.c index 79c779461b..83bc1a5af6 100644 --- a/firmware/target/arm/rk27xx/debug-rk27xx.c +++ b/firmware/target/arm/rk27xx/debug-rk27xx.c @@ -32,7 +32,8 @@ #ifdef RK27_GENERIC #define DEBUG_CANCEL BUTTON_VOL -#elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) +#elif defined(HM60X) || defined(HM801) || (CONFIG_KEYPAD == MA_PAD) || \ + (CONFIG_KEYPAD == IHIFI_PAD) #define DEBUG_CANCEL BUTTON_LEFT #endif diff --git a/firmware/target/arm/rk27xx/ihifi/button-ihifi.c b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c new file mode 100644 index 0000000000..6477400255 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/button-ihifi.c @@ -0,0 +1,53 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 Andrew Ryabinin + * + * 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" +#include "adc.h" +#include "backlight.h" + +void button_init_device(void) { + /* setup button gpio as input */ + GPIO_PCCON &= ~(POWEROFF_BUTTON); +} + +int button_read_device(void) { + int adc_val = adc_read(ADC_BUTTONS); + int gpio_btn = GPIO_PCDR & BUTTON_PLAY; + + if (adc_val < 270) { + if (adc_val < 110) { /* 0 - 109 */ + return BUTTON_RETURN | gpio_btn; + } else { /* 110 - 269 */ + return BUTTON_MENU |gpio_btn; + } + } else { + if (adc_val < 420) { /* 270 - 419 */ + return BUTTON_BWD | gpio_btn; + } else if (adc_val < 580) { /* 420 - 579 */ + return BUTTON_FWD | gpio_btn; + } + } + return gpio_btn; +} + + diff --git a/firmware/target/arm/rk27xx/ihifi/button-target.h b/firmware/target/arm/rk27xx/ihifi/button-target.h new file mode 100644 index 0000000000..f78727b0f5 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/button-target.h @@ -0,0 +1,40 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 Andrew Ryabinin + * + * 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_ + +#define BUTTON_FWD 0x00000001 +#define BUTTON_PLAY 0x00000002 +#define BUTTON_BWD 0x00000004 +#define BUTTON_RETURN 0x00000008 +#define BUTTON_MENU 0x00000010 + +#define BUTTON_LEFT BUTTON_RETURN +#define BUTTON_RIGHT BUTTON_MENU + +#define BUTTON_MAIN (BUTTON_FWD|BUTTON_PLAY| \ + BUTTON_BWD|BUTTON_RETURN| \ + BUTTON_MENU) + +#define POWEROFF_BUTTON BUTTON_PLAY +#define POWEROFF_COUNT 30 + +#endif /* _BUTTON_TARGET_H_ */ diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c new file mode 100644 index 0000000000..d5906b9dd5 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/lcd-ihifi.c @@ -0,0 +1,224 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2013 Andrew Ryabinin + * + * + * 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 "kernel.h" +#include "lcd.h" +#include "system.h" +#include "cpu.h" +#include "lcdif-rk27xx.h" + +static bool display_on = false; + +void lcd_display_init(void) +{ + unsigned int x, y; + + lcd_cmd(0xEF); + lcd_data(0x03); + lcd_data(0x80); + lcd_data(0x02); + + lcd_cmd(0x00CF); + lcd_data(0x00); + lcd_data(0xC1); + lcd_data(0x30); + + lcd_cmd(0xED); + lcd_data(0x67); + lcd_data(0x03); + lcd_data(0x12); + lcd_data(0x81); + + lcd_cmd(0xE8); + lcd_data(0x85); + lcd_data(0x11); + lcd_data(0x79); + + lcd_cmd(0xCB); + lcd_data(0x39); + lcd_data(0x2C); + lcd_data(0x00); + lcd_data(0x34); + lcd_data(0x06); + + lcd_cmd(0xF7); + lcd_data(0x20); + + lcd_cmd(0xEA); + lcd_data(0x00); + lcd_data(0x00); + + lcd_cmd(0xC0); + lcd_data(0x1D); + + lcd_cmd(0xC1); + lcd_data(0x12); + + lcd_cmd(0xC5); + lcd_data(0x44); + lcd_data(0x3C); + + lcd_cmd(0xC7); + lcd_data(0x88); + + lcd_cmd(0x3A); + lcd_data(0x55); + + lcd_cmd(0x36); + lcd_data(0xA8); + + lcd_cmd(0xB1); + lcd_data(0x00); + lcd_data(0x17); + + lcd_cmd(0xB6); + lcd_data(0x0A); + lcd_data(0xA2); + + lcd_cmd(0xF2); + lcd_data(0x00); + + lcd_cmd(0x26); + lcd_data(0x01); + + lcd_cmd(0xE0); + lcd_data(0x0F); + lcd_data(0x22); + lcd_data(0x1C); + lcd_data(0x1B); + lcd_data(0x08); + lcd_data(0x0F); + lcd_data(0x48); + lcd_data(0xB8); + lcd_data(0x34); + lcd_data(0x05); + lcd_data(0x0C); + lcd_data(0x09); + lcd_data(0x0F); + lcd_data(0x07); + lcd_data(0x00); + + lcd_cmd(0xE1); + lcd_data(0x00); + lcd_data(0x23); + lcd_data(0x24); + lcd_data(0x07); + lcd_data(0x10); + lcd_data(0x07); + lcd_data(0x38); + lcd_data(0x47); + lcd_data(0x4B); + lcd_data(0x0A); + lcd_data(0x13); + lcd_data(0x06); + lcd_data(0x30); + lcd_data(0x38); + lcd_data(0x0F); + + lcd_cmd(0x2A); + lcd_data(0x00); + lcd_data(0x00); + lcd_data(0x01); + lcd_data(0x3F); + + lcd_cmd(0x2B); + lcd_data(0x00); + lcd_data(0x00); + lcd_data(0x00); + lcd_data(0xEF); + + lcd_cmd(0x11); + + udelay(120000); + + lcd_cmd(0x29); + lcd_cmd(0x2C); + + for (x = 0; x < LCD_WIDTH; x++) + for(y=0; y < LCD_HEIGHT; y++) + lcd_data(0x00); + + display_on = true; +} + +void lcd_enable (bool on) +{ + if (on == display_on) + return; + + lcdctrl_bypass(1); + LCDC_CTRL |= RGB24B; + + if (on) { + lcd_cmd(0x11); + udelay(120000); + lcd_cmd(0x29); + lcd_cmd(0x2C); + } else { + lcd_cmd(0x28); + } + + display_on = on; + LCDC_CTRL &= ~RGB24B; +} + +void lcd_set_gram_area(int x_start, int y_start, + int x_end, int y_end) +{ + lcdctrl_bypass(1); + LCDC_CTRL |= RGB24B; + lcd_cmd(0x002A); + lcd_data((x_start&0xff00)>>8); + lcd_data(x_start&0x00ff); + lcd_data((x_end&0xff00)>>8); + lcd_data(x_end&0x00ff); + lcd_cmd(0x002B); + lcd_data((y_start&0xff00)>>8); + lcd_data(y_start&0x00ff); + lcd_data((y_end&0xff00)>>8); + lcd_data(y_end&0x00ff); + + lcd_cmd(0x2C); + LCDC_CTRL &= ~RGB24B; + +} + +bool lcd_active() +{ + return display_on; +} + +/* Blit a YUV bitmap directly to the LCD */ +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) +{ + (void)src; + (void)src_x; + (void)src_y; + (void)stride; + (void)x; + (void)y; + (void)width; + (void)height; +} diff --git a/firmware/target/arm/rk27xx/ihifi/lcd-target.h b/firmware/target/arm/rk27xx/ihifi/lcd-target.h new file mode 100644 index 0000000000..0d245c888b --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/lcd-target.h @@ -0,0 +1,26 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2012 Andrew Ryabinin + * + * + * 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 LCD_TARGET_H +#define LCD_TARGET_H + +#define LCD_DATABUS_WIDTH LCDIF_16BIT +#endif diff --git a/firmware/target/arm/rk27xx/ihifi/power-ihifi.c b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c new file mode 100644 index 0000000000..780d476112 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/power-ihifi.c @@ -0,0 +1,51 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2013 Andrew Ryabinin + * + * 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 <stdbool.h> +#include "config.h" +#include "inttypes.h" +#include "power.h" +#include "panic.h" +#include "system.h" +#include "usb_core.h" /* for usb_charging_maxcurrent_change */ + +void power_off(void) +{ + GPIO_PCCON &= ~(1<<0); + while(1); +} + +void power_init(void) +{ + GPIO_PCDR |= (1<<0); + GPIO_PCCON |= (1<<0); +} + +unsigned int power_input_status(void) +{ + unsigned int status = POWER_INPUT_NONE; + /* TODO: implement */ + return status; +} + +bool charging_state(void) +{ + return true; +} diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c new file mode 100644 index 0000000000..c849bc27e6 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi760.c @@ -0,0 +1,65 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2013 Andrew Ryabinin + * + * 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 "adc.h" +#include "adc-target.h" +#include "powermgmt.h" + +/* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x. + + Battery voltage is calculated under the assumption that the adc full-scale + readout represents 3.00V and that the battery ADC channel is fed with + exactly half of the battery voltage (through a resistive divider). + Charge curve have not been calibrated yet. +*/ + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + /* TODO: this is just an initial guess */ + 3350, +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 3300, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* FIXME: Uncalibrated curve */ + { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 } +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = + /* TODO: simple copy of discharge curve */ + { 3300, 3350, 3433, 3516, 3600, 3683, 3767, 3850, 3933, 4017, 4100 }; + +/* full-scale ADC readout (2^10) in millivolt */ +#define BATTERY_SCALE_FACTOR 6100 + +/* Returns battery voltage from ADC [millivolts] */ +int _battery_voltage(void) +{ + return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; +} diff --git a/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c new file mode 100644 index 0000000000..c8797c0a32 --- /dev/null +++ b/firmware/target/arm/rk27xx/ihifi/powermgmt-ihifi960.c @@ -0,0 +1,65 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright © 2013 Andrew Ryabinin + * + * 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 "adc.h" +#include "adc-target.h" +#include "powermgmt.h" + +/* Battery voltage calculation and discharge/charge curves for the HiFiMAN HM-60x. + + Battery voltage is calculated under the assumption that the adc full-scale + readout represents 3.00V and that the battery ADC channel is fed with + exactly half of the battery voltage (through a resistive divider). + Charge curve have not been calibrated yet. +*/ + +const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = +{ + /* TODO: this is just an initial guess */ + 7050, +}; + +const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] = +{ + 7000, +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */ +const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] = +{ + /* FIXME: Uncalibrated curve */ + { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 } +}; + +/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */ +const unsigned short percent_to_volt_charge[11] = + /* TODO: simple copy of discharge curve */ + { 7000, 7050, 7100, 7150, 7200, 7250, 7300, 7350, 7400, 7450, 7500 }; + +/* full-scale ADC readout (2^10) in millivolt */ +#define BATTERY_SCALE_FACTOR 13000 + +/* Returns battery voltage from ADC [millivolts] */ +int _battery_voltage(void) +{ + return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10; +} diff --git a/firmware/target/arm/rk27xx/sd-rk27xx.c b/firmware/target/arm/rk27xx/sd-rk27xx.c index 9f6ba467b7..deca8a1fa7 100644 --- a/firmware/target/arm/rk27xx/sd-rk27xx.c +++ b/firmware/target/arm/rk27xx/sd-rk27xx.c @@ -134,6 +134,9 @@ static inline bool card_detect_target(void) return !(GPIO_PFDR & (1<<2)); #elif defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) return (GPIO_PCDR & 0x80); +#elif defined(IHIFI760) || defined(IHIFI960) + /* TODO: find out pin */ + return true; #else #error "Unknown target" #endif |