summaryrefslogtreecommitdiff
path: root/firmware/target/arm/rk27xx/hm60x
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2011-10-17 10:32:19 +0000
committerMarcin Bukat <marcin.bukat@gmail.com>2011-10-17 10:32:19 +0000
commit32f763c39a797221a6e850704feb3743bc104d8c (patch)
treec509c38423f2efb76a13119f92c21e5e82476a42 /firmware/target/arm/rk27xx/hm60x
parentf0311d3310e84906a6c1afaf941f2f58e2063c30 (diff)
downloadrockbox-32f763c39a797221a6e850704feb3743bc104d8c.tar.gz
rockbox-32f763c39a797221a6e850704feb3743bc104d8c.zip
Add HiFiMAN HM-60x target(s). FS#12319 by Andrew Ryabinin with some (small) modification by me. This also splits rk27xx lcd driver into lcdif-rk27xx and lcd controller specific part. Some modifications to the pcm driver have been made to allow using codecs in slave mode (as TDA1543 used in hifiman is slave only i2s codec).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30765 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/rk27xx/hm60x')
-rw-r--r--firmware/target/arm/rk27xx/hm60x/button-hm60x.c46
-rw-r--r--firmware/target/arm/rk27xx/hm60x/button-target.h44
-rw-r--r--firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c148
-rw-r--r--firmware/target/arm/rk27xx/hm60x/power-hm60x.c48
-rw-r--r--firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c66
5 files changed, 352 insertions, 0 deletions
diff --git a/firmware/target/arm/rk27xx/hm60x/button-hm60x.c b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c
new file mode 100644
index 0000000000..eaadaa131c
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/button-hm60x.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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 "config.h"
23#include "system.h"
24#include "button.h"
25#include "adc.h"
26
27void button_init_device(void) {
28 /* setup button gpio as input */
29 GPIO_PCCON &= ~(POWEROFF_BUTTON);
30}
31
32int button_read_device(void) {
33 int adc_val = adc_read(ADC_BUTTONS);
34 if (adc_val < 30) {
35 return BUTTON_UP | (GPIO_PCDR & POWEROFF_BUTTON);
36 } else if (adc_val < 250) {
37 return BUTTON_RIGHT | (GPIO_PCDR & POWEROFF_BUTTON);
38 } else if (adc_val < 380) {
39 return BUTTON_LEFT | (GPIO_PCDR & POWEROFF_BUTTON);
40 } else if (adc_val < 450) {
41 return BUTTON_DOWN | (GPIO_PCDR & POWEROFF_BUTTON);
42 } else if (adc_val < 560) {
43 return BUTTON_PLAY | (GPIO_PCDR & POWEROFF_BUTTON);
44 }
45 return (GPIO_PCDR & POWEROFF_BUTTON);
46}
diff --git a/firmware/target/arm/rk27xx/hm60x/button-target.h b/firmware/target/arm/rk27xx/hm60x/button-target.h
new file mode 100644
index 0000000000..0209e0637d
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/button-target.h
@@ -0,0 +1,44 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
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 _BUTTON_TARGET_H_
22#define _BUTTON_TARGET_H_
23
24#include <stdbool.h>
25#include "config.h"
26
27void button_init_device(void);
28int button_read_device(void);
29
30
31#define BUTTON_UP 0x00000001
32#define BUTTON_DOWN 0x00000004
33#define BUTTON_LEFT 0x00000008
34#define BUTTON_RIGHT 0x00000010
35#define BUTTON_PLAY 0x00000020
36
37
38#define BUTTON_REMOTE 0
39
40
41#define POWEROFF_BUTTON 0x02
42#define POWEROFF_COUNT 30
43
44#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c b/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c
new file mode 100644
index 0000000000..932154da8d
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/lcd-hm60x.c
@@ -0,0 +1,148 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 Andrew Ryabinin
11 *
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#include "kernel.h"
25#include "lcd.h"
26#include "system.h"
27#include "cpu.h"
28#include "lcdif-rk27xx.h"
29
30
31/* TODO */
32static void lcd_sleep(unsigned int sleep)
33{
34 (void)sleep;
35}
36
37void lcd_display_init()
38{
39 unsigned int x, y;
40
41 /* Driving ability setting */
42 lcd_write_reg(0x60, 0x00);
43 lcd_write_reg(0x61, 0x06);
44 lcd_write_reg(0x62, 0x00);
45 lcd_write_reg(0x63, 0xC8);
46
47 /* Gamma 2.2 Setting */
48 lcd_write_reg(0x40, 0x00);
49 lcd_write_reg(0x41, 0x40);
50 lcd_write_reg(0x42, 0x45);
51 lcd_write_reg(0x43, 0x01);
52 lcd_write_reg(0x44, 0x60);
53 lcd_write_reg(0x45, 0x05);
54 lcd_write_reg(0x46, 0x0C);
55 lcd_write_reg(0x47, 0xD1);
56 lcd_write_reg(0x48, 0x05);
57
58 lcd_write_reg(0x50, 0x75);
59 lcd_write_reg(0x51, 0x01);
60 lcd_write_reg(0x52, 0x67);
61 lcd_write_reg(0x53, 0x14);
62 lcd_write_reg(0x54, 0xF2);
63 lcd_write_reg(0x55, 0x07);
64 lcd_write_reg(0x56, 0x03);
65 lcd_write_reg(0x57, 0x49);
66
67 /* Power voltage setting */
68 lcd_write_reg(0x1F, 0x03);
69 lcd_write_reg(0x20, 0x00);
70 lcd_write_reg(0x24, 0x28);
71 lcd_write_reg(0x25, 0x45);
72
73 lcd_write_reg(0x23, 0x2F);
74
75 /* Power on setting */
76 lcd_write_reg(0x18, 0x44);
77 lcd_write_reg(0x21, 0x01);
78 lcd_write_reg(0x01, 0x00);
79 lcd_write_reg(0x1C, 0x03);
80 lcd_write_reg(0x19, 0x06);
81 udelay(5);
82
83 /* Display on setting */
84 lcd_write_reg(0x26, 0x84);
85 udelay(40);
86 lcd_write_reg(0x26, 0xB8);
87 udelay(40);
88 lcd_write_reg(0x26, 0xBC);
89 udelay(40);
90
91 /* Memmory access setting */
92 lcd_write_reg(0x16, 0x48);
93 /* Setup 16bit mode */
94 lcd_write_reg(0x17, 0x05);
95
96 /* Set GRAM area */
97 lcd_write_reg(0x02, 0x00);
98 lcd_write_reg(0x03, 0x00);
99 lcd_write_reg(0x04, 0x00);
100 lcd_write_reg(0x05, LCD_HEIGHT - 1);
101 lcd_write_reg(0x06, 0x00);
102 lcd_write_reg(0x07, 0x00);
103 lcd_write_reg(0x08, 0x00);
104 lcd_write_reg(0x09, LCD_WIDTH - 1);
105
106 /* Start GRAM write */
107 lcd_cmd(0x22);
108
109 for (x=0; x<LCD_WIDTH; x++)
110 for(y=0; y<LCD_HEIGHT; y++)
111 lcd_data(0x00);
112
113 lcd_sleep(0);
114}
115
116
117
118void lcd_update_rect(int x, int y, int width, int height)
119{
120 int px = x, py = y;
121 int pxmax = x + width, pymax = y + height;
122
123 lcd_write_reg(0x03, y);
124 lcd_write_reg(0x05, pymax-1);
125 lcd_write_reg(0x07, x);
126 lcd_write_reg(0x09, pxmax-1);
127
128 lcd_cmd(0x22);
129
130 for (px=x; px<pxmax; px++)
131 for (py=y; py<pymax; py++)
132 lcd_data(lcd_framebuffer[py][px]);
133}
134
135/* Blit a YUV bitmap directly to the LCD */
136void lcd_blit_yuv(unsigned char * const src[3],
137 int src_x, int src_y, int stride,
138 int x, int y, int width, int height)
139{
140 (void)src;
141 (void)src_x;
142 (void)src_y;
143 (void)stride;
144 (void)x;
145 (void)y;
146 (void)width;
147 (void)height;
148}
diff --git a/firmware/target/arm/rk27xx/hm60x/power-hm60x.c b/firmware/target/arm/rk27xx/hm60x/power-hm60x.c
new file mode 100644
index 0000000000..5c2abeb121
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/power-hm60x.c
@@ -0,0 +1,48 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 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#include <stdbool.h>
22#include "config.h"
23#include "inttypes.h"
24#include "power.h"
25#include "panic.h"
26#include "system.h"
27#include "usb_core.h" /* for usb_charging_maxcurrent_change */
28
29void power_off(void)
30{
31
32}
33
34void power_init(void)
35{
36 GPIO_PCDR |= (1<<0);
37 GPIO_PCCON |= (1<<0);
38}
39
40unsigned int power_input_status(void)
41{
42 return (usb_detect() == USB_INSERTED) ? POWER_INPUT_MAIN_CHARGER : POWER_INPUT_NONE;
43}
44
45bool charging_state(void)
46{
47 return true;
48}
diff --git a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
new file mode 100644
index 0000000000..7b5b171ccb
--- /dev/null
+++ b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
@@ -0,0 +1,66 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright © 2009 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 "config.h"
23#include "adc.h"
24#include "adc-target.h"
25#include "powermgmt.h"
26
27/* Battery voltage calculation and discharge/charge curves for the Meizu M3.
28
29 Battery voltage is calculated under the assumption that the adc full-scale
30 readout represents 3.00V and that the battery ADC channel is fed with
31 exactly half of the battery voltage (through a resistive divider).
32 Discharge and charge curves have not been calibrated yet.
33*/
34
35const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
36{
37 /* TODO: this is just an initial guess */
38 3400
39};
40
41const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
42{
43 /* TODO: this is just an initial guess */
44 3300
45};
46
47/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
48const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
49{
50 /* TODO: simple uncalibrated curve, linear except for first 10% */
51 { 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 }
52};
53
54/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
55const unsigned short percent_to_volt_charge[11] =
56 /* TODO: simple uncalibrated curve, linear except for first 10% */
57 { 3300, 3600, 3665, 3730, 3795, 3860, 3925, 3990, 4055, 4120, 4185 };
58
59/* full-scale ADC readout (2^10) in millivolt */
60#define BATTERY_SCALE_FACTOR 6000
61
62/* Returns battery voltage from ADC [millivolts] */
63unsigned int battery_adc_voltage(void)
64{
65 return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
66}