···1+/*
2+ * This config file is for HiFiMAN HM-60x reference design
3+ */
4+5+/* For Rolo and boot loader */
6+#define MODEL_NUMBER 83
7+8+#define MODEL_NAME "HiFi E.T. MA9"
9+10+/* define the bitmask of hardware sample rates */
11+#define HW_SAMPR_CAPS (SAMPR_CAP_96 | SAMPR_CAP_48 | SAMPR_CAP_44 | \
12+ SAMPR_CAP_32 | SAMPR_CAP_24 | SAMPR_CAP_22 | \
13+ SAMPR_CAP_16 | SAMPR_CAP_12 | SAMPR_CAP_11 | SAMPR_CAP_8)
14+15+#define HAVE_DF1704_CODEC
16+17+#define CODEC_SLAVE
18+/* define this if you have a bitmap LCD display */
19+#define HAVE_LCD_BITMAP
20+21+/* define this if you can flip your LCD */
22+/* #define HAVE_LCD_FLIP */
23+24+/* define this if you have a colour LCD */
25+#define HAVE_LCD_COLOR
26+27+/* define this if you want album art for this target */
28+#define HAVE_ALBUMART
29+30+/* define this to enable bitmap scaling */
31+#define HAVE_BMP_SCALING
32+33+/* define this to enable JPEG decoding */
34+#define HAVE_JPEG
35+36+/* define this if you can invert the colours on your LCD */
37+/* #define HAVE_LCD_INVERT */
38+39+/* define this if you have access to the quickscreen */
40+#define HAVE_QUICKSCREEN
41+42+/* define this if you would like tagcache to build on this target */
43+#define HAVE_TAGCACHE
44+45+/* define this if you have a flash memory storage */
46+#define HAVE_FLASH_STORAGE
47+48+#define CONFIG_STORAGE (STORAGE_SD | STORAGE_NAND)
49+50+#define CONFIG_NAND NAND_RK27XX
51+#define HAVE_SW_TONE_CONTROLS
52+53+/* commented for now */
54+/* #define HAVE_HOTSWAP */
55+56+#define NUM_DRIVES 2
57+#define SECTOR_SIZE 512
58+59+/* for small(ish) SD cards */
60+#define HAVE_FAT16SUPPORT
61+62+/* LCD dimensions */
63+#define LCD_WIDTH 320
64+#define LCD_HEIGHT 240
65+#define LCD_DEPTH 16 /* pseudo 262.144 colors */
66+#define LCD_PIXELFORMAT RGB565 /* rgb565 */
67+68+/* Define this if your LCD can be enabled/disabled */
69+#define HAVE_LCD_ENABLE
70+71+#define CONFIG_KEYPAD MA_PAD
72+73+/* Define this to enable morse code input */
74+#define HAVE_MORSE_INPUT
75+76+/* Define this if you do software codec */
77+#define CONFIG_CODEC SWCODEC
78+79+#define CONFIG_LCD LCD_ILI9342
80+81+/* Define this for LCD backlight available */
82+#define HAVE_BACKLIGHT
83+#define HAVE_BACKLIGHT_BRIGHTNESS
84+#define MIN_BRIGHTNESS_SETTING 0
85+#define MAX_BRIGHTNESS_SETTING 31
86+#define DEFAULT_BRIGHTNESS_SETTING 31
87+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG
88+89+/* Define this if you have a software controlled poweroff */
90+#define HAVE_SW_POWEROFF
91+92+/* The number of bytes reserved for loadable codecs */
93+#define CODEC_SIZE 0x100000
94+95+/* The number of bytes reserved for loadable plugins */
96+#define PLUGIN_BUFFER_SIZE 0x80000
97+98+/* TODO: Figure out real values */
99+#define BATTERY_CAPACITY_DEFAULT 600 /* default battery capacity */
100+#define BATTERY_CAPACITY_MIN 300 /* min. capacity selectable */
101+#define BATTERY_CAPACITY_MAX 600 /* max. capacity selectable */
102+#define BATTERY_CAPACITY_INC 10 /* capacity increment */
103+#define BATTERY_TYPES_COUNT 1 /* only one type */
104+105+#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
106+107+/* Hardware controlled charging with monitoring */
108+#define CONFIG_CHARGING CHARGING_MONITOR
109+110+/* USB On-the-go */
111+#define CONFIG_USBOTG USBOTG_RK27XX
112+113+/* enable these for the experimental usb stack */
114+#define HAVE_USBSTACK
115+116+#define USE_ROCKBOX_USB
117+#define USB_VENDOR_ID 0x071b
118+#define USB_PRODUCT_ID 0x3202
119+#define HAVE_BOOTLOADER_USB_MODE
120+121+/* Define this if your LCD can set contrast */
122+/* #define HAVE_LCD_CONTRAST */
123+124+/* The exact type of CPU */
125+#define CONFIG_CPU RK27XX
126+127+/* I2C interface */
128+#define CONFIG_I2C I2C_RK27XX
129+130+/* Define this to the CPU frequency */
131+#define CPU_FREQ 200000000
132+133+/* define this if the hardware can be powered off while charging */
134+/* #define HAVE_POWEROFF_WHILE_CHARGING */
135+136+/* Offset ( in the firmware file's header ) to the file CRC */
137+#define FIRMWARE_OFFSET_FILE_CRC 0
138+139+/* Offset ( in the firmware file's header ) to the real data */
140+#define FIRMWARE_OFFSET_FILE_DATA 8
141+142+#define STORAGE_NEEDS_ALIGN
143+144+/* Define this if you have adjustable CPU frequency */
145+#define HAVE_ADJUSTABLE_CPU_FREQ
146+147+/* Virtual LED (icon) */
148+#define CONFIG_LED LED_VIRTUAL
149+150+#define RKW_FORMAT
151+#define BOOTFILE_EXT "rkw"
152+#define BOOTFILE "rockbox." BOOTFILE_EXT
153+#define BOOTDIR "/.rockbox"
···1+/***************************************************************************
2+ * __________ __ ___.
3+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7+ * \/ \/ \/ \/ \/
8+ * $Id$
9+ *
10+ * Copyright (C) 2013 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+static bool display_on = false;
31+32+33+void lcd_display_init(void)
34+{
35+ int i;
36+ unsigned int x, y;
37+38+ lcd_cmd(0x00B9);
39+ lcd_data(0x00FF);
40+ lcd_data(0x0093);
41+ lcd_data(0x0042);
42+43+ lcd_cmd(0x0021); /* display inversion on ??? */
44+45+ /* memory access control */
46+ lcd_cmd(0x0036);
47+ lcd_data(0x00C9);
48+49+ /* set 16-bit pixel format */
50+ lcd_cmd(0x003A);
51+ lcd_data(0x0005);
52+53+ /* Setup color depth conversion lookup table */
54+ lcd_cmd(0x002D);
55+ /* red */
56+ for(i = 0; i < 32; i++)
57+ lcd_data(2*i);
58+ /* green */
59+ for(i = 0; i < 64; i++)
60+ lcd_data(1*i);
61+ /* blue */
62+ for(i = 0; i < 32; i++)
63+ lcd_data(2*i);
64+65+ /* power control settings */
66+ lcd_cmd(0x00C0);
67+ lcd_data(0x0025); /* VREG1OUT 4.70V */
68+ lcd_data(0x000A); /* VCOM 2.8V */
69+70+ lcd_cmd(0x00C1);
71+ lcd_data(0x0001);
72+73+ lcd_cmd(0x00C5);
74+ lcd_data(0x002F);
75+ lcd_data(0x0027);
76+77+ lcd_cmd(0x00C7);
78+ lcd_data(0x00D3);
79+80+ lcd_cmd(0x00B8);
81+ lcd_data(0x000B);
82+83+ /* Positive gamma correction */
84+ lcd_cmd(0x00E0);
85+ lcd_data(0x000F);
86+ lcd_data(0x0022);
87+ lcd_data(0x001D);
88+ lcd_data(0x000B);
89+ lcd_data(0x000F);
90+ lcd_data(0x0007);
91+ lcd_data(0x004C);
92+ lcd_data(0x0076);
93+ lcd_data(0x003C);
94+ lcd_data(0x0009);
95+ lcd_data(0x0016);
96+ lcd_data(0x0007);
97+ lcd_data(0x0012);
98+ lcd_data(0x000B);
99+ lcd_data(0x0008);
100+101+ /* Negative Gamma Correction */
102+ lcd_cmd(0x00E1);
103+ lcd_data(0x0008);
104+ lcd_data(0x001F);
105+ lcd_data(0x0024);
106+ lcd_data(0x0003);
107+ lcd_data(0x000E);
108+ lcd_data(0x0003);
109+ lcd_data(0x0035);
110+ lcd_data(0x0023);
111+ lcd_data(0x0045);
112+ lcd_data(0x0001);
113+ lcd_data(0x000B);
114+ lcd_data(0x0007);
115+ lcd_data(0x002F);
116+ lcd_data(0x0036);
117+ lcd_data(0x000F);
118+119+ lcd_cmd(0x00F2);
120+ lcd_data(0x0000);
121+122+ /* exit sleep */
123+ lcd_cmd(0x0011);
124+ udelay(5000);
125+ lcd_cmd(0x0029);
126+127+ lcd_cmd(0x002C);
128+ for (x = 0; x < LCD_WIDTH; x++)
129+ for(y=0; y < LCD_HEIGHT; y++)
130+ lcd_data(0x00);
131+132+ display_on = true;
133+}
134+135+void lcd_enable (bool on)
136+{
137+ if (on == display_on)
138+ return;
139+140+ lcdctrl_bypass(1);
141+ LCDC_CTRL |= RGB24B;
142+143+ if (on) {
144+ lcd_cmd(0x11);
145+ } else {
146+ lcd_cmd(0x10);
147+ }
148+ udelay(5000);
149+150+ display_on = on;
151+ LCDC_CTRL &= ~RGB24B;
152+}
153+154+void lcd_set_gram_area(int x, int y, int width, int height)
155+{
156+ lcdctrl_bypass(1);
157+ LCDC_CTRL |= RGB24B;
158+159+ lcd_cmd(0x002A);
160+ lcd_data((x&0xff00)>>8);
161+ lcd_data(x&0x00ff);
162+ lcd_data(((width-1)&0xff00)>>8);
163+ lcd_data((width-1)&0x00ff);
164+ lcd_cmd(0x002B);
165+ lcd_data((y&0xff00)>>8);
166+ lcd_data(y&0x00ff);
167+ lcd_data(((height-1)&0xff00)>>8);
168+ lcd_data((height-1)&0x00ff);
169+170+ lcd_cmd(0x2c);
171+ LCDC_CTRL &= ~RGB24B;
172+}
173+174+void lcd_update_rect(int x, int y, int width, int height)
175+{
176+ int px = x, py = y;
177+ int pxmax = x + width, pymax = y + height;
178+179+ lcd_set_gram_area(x, y, pxmax, pymax);
180+181+ for (py = y; py < pymax; py++)
182+ for (px = x; px < pxmax; px++)
183+ LCD_DATA = (*FBADDR(px, py));
184+185+}
186+187+188+bool lcd_active()
189+{
190+ return display_on;
191+}
192+193+/* Blit a YUV bitmap directly to the LCD */
194+void lcd_blit_yuv(unsigned char * const src[3],
195+ int src_x, int src_y, int stride,
196+ int x, int y, int width, int height)
197+{
198+ (void)src;
199+ (void)src_x;
200+ (void)src_y;
201+ (void)stride;
202+ (void)x;
203+ (void)y;
204+ (void)width;
205+ (void)height;
206+}
+27
firmware/target/arm/rk27xx/ma/lcd-target.h
···000000000000000000000000000
···1+/***************************************************************************
2+ * __________ __ ___.
3+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7+ * \/ \/ \/ \/ \/
8+ * $Id$
9+ *
10+ * Copyright (C) 2013 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+#ifndef LCD_TARGET_H
23+#define LCD_TARGET_H
24+25+#define LCD_DATABUS_WIDTH LCDIF_16BIT
26+27+#endif
···1+/***************************************************************************
2+ * __________ __ ___.
3+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7+ * \/ \/ \/ \/ \/
8+ * $Id$
9+ *
10+ * Copyright (C) 2013 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 "system.h"
23+#include "i2c-rk27xx.h"
24+#include "pca9555.h"
25+26+static struct semaphore pca9555_sem;
27+static char pca9555_thread_stack[DEFAULT_STACK_SIZE];
28+volatile unsigned short pca9555_in_ports;
29+30+void INT_GPIO1(void)
31+{
32+ if (GPIO1_ISR & (1<<10)) { /* GPIO F2 pin */
33+ GPIO_IEF &= ~(1<<2);
34+ GPIO_ICF |= (1<<2);
35+ semaphore_release(&pca9555_sem);
36+ }
37+}
38+39+static void pca9555_read_thread(void)
40+{
41+ while(1) {
42+ if ((GPIO_PFDR&(1<<2)) == 0) {
43+ pca9555_in_ports = pca9555_read_input();
44+ } else {
45+ pca9555_in_ports = (1<<15)|(1<<11); /* restore defaults */
46+ }
47+ sleep(HZ/20);
48+ GPIO_IEF |= (1<<2);
49+ semaphore_wait(&pca9555_sem, TIMEOUT_BLOCK);
50+ }
51+}
52+53+static void pca9555_ports_init(void)
54+{
55+ unsigned short data = 0;
56+57+ data = 0xf800; /* port0 - pins 0-7 output, port1 - pins 0-2 output, pins 3-7 input */
58+ pca9555_write_config(data, 0xffff);
59+60+ /*
61+ * IO0-7 IO0-6 IO0-5 IO0_4 IO0_3 IO0_2 IO0_1 IO0_0
62+ * USB_SEL KP_LED POP DAC_EN AMP_EN SPI_CS SPI_CLK SPI_DATA
63+ * 1:MSD 1:OFF 1 0 0 1 1 1
64+ */
65+ data = ((1<<7)|(1<<6)|(1<<5)|(0<<4)|(0<<3)|(1<<2)|(1<<1)|(1<<0));
66+67+ /*
68+ * IO1-2 IO1_1 IO1_0
69+ * CHG_EN DAC_EN DF1704_CS
70+ * 1 0 1
71+ */
72+ data |= ((1<<10)|(0<<9)|(1<<8));
73+ pca9555_write_output(data, 0xffff);
74+}
75+76+void pca9555_target_init(void)
77+{
78+ GPIO_PFCON &= ~(1<<2); /* PF2 for PCA9555 input INT */
79+80+ pca9555_ports_init();
81+ semaphore_init(&pca9555_sem, 1, 0);
82+83+ INTC_IMR |= IRQ_ARM_GPIO1;
84+ INTC_IECR |= IRQ_ARM_GPIO1;
85+ GPIO_ISF |= (1<<2);
86+87+ create_thread(pca9555_read_thread,
88+ pca9555_thread_stack,
89+ sizeof(pca9555_thread_stack),
90+ 0,
91+ "pca9555_read" IF_PRIO(, PRIORITY_SYSTEM)
92+ IF_COP(, CPU));
93+}
+27
firmware/target/arm/rk27xx/ma/pca9555-target.h
···000000000000000000000000000
···1+/***************************************************************************
2+ * __________ __ ___.
3+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7+ * \/ \/ \/ \/ \/
8+ * $Id$
9+ *
10+ * Copyright (C) 2013 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+#ifndef _PCA9555_TARGET_H
23+#define _PCA9555_TARGET_H
24+25+#define PCA9555_I2C_ADDR 0x40
26+27+#endif