summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES17
-rw-r--r--firmware/export/config.h7
-rw-r--r--firmware/export/config/sonynwze360.h183
-rw-r--r--firmware/export/config/sonynwze370.h182
-rw-r--r--firmware/target/arm/imx233/sdmmc-imx233.c9
-rw-r--r--firmware/target/arm/imx233/sony-nwz/adc-nwz.c38
-rw-r--r--firmware/target/arm/imx233/sony-nwz/adc-target.h31
-rw-r--r--firmware/target/arm/imx233/sony-nwz/audio-target.h24
-rw-r--r--firmware/target/arm/imx233/sony-nwz/backlight-nwz.c61
-rw-r--r--firmware/target/arm/imx233/sony-nwz/backlight-target.h29
-rw-r--r--firmware/target/arm/imx233/sony-nwz/button-nwz.c64
-rw-r--r--firmware/target/arm/imx233/sony-nwz/button-target.h62
-rw-r--r--firmware/target/arm/imx233/sony-nwz/debug-nwz.c28
-rw-r--r--firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c40
-rw-r--r--firmware/target/arm/imx233/sony-nwz/lcd-nwze360.c259
-rw-r--r--firmware/target/arm/imx233/sony-nwz/lcd-nwze370.c219
-rw-r--r--firmware/target/arm/imx233/sony-nwz/lcd-target.h24
-rw-r--r--firmware/target/arm/imx233/sony-nwz/power-nwz.c42
-rw-r--r--firmware/target/arm/imx233/sony-nwz/powermgmt-nwze360.c46
-rw-r--r--firmware/target/arm/imx233/sony-nwz/powermgmt-nwze370.c46
-rw-r--r--firmware/target/arm/imx233/sony-nwz/powermgmt-target.h58
21 files changed, 1469 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index f7bd4ed974..86bf746df9 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1184,6 +1184,23 @@ target/arm/imx233/creative-zenxfi3/adc-zenxfi3.c
1184target/arm/imx233/creative-zenxfi3/powermgmt-zenxfi3.c 1184target/arm/imx233/creative-zenxfi3/powermgmt-zenxfi3.c
1185#endif 1185#endif
1186 1186
1187#if defined(SONY_NWZE360) || defined(SONY_NWZE370)
1188target/arm/imx233/button-lradc-imx233.c
1189target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
1190target/arm/imx233/sony-nwz/backlight-nwz.c
1191target/arm/imx233/sony-nwz/button-nwz.c
1192target/arm/imx233/sony-nwz/debug-nwz.c
1193target/arm/imx233/sony-nwz/power-nwz.c
1194target/arm/imx233/sony-nwz/adc-nwz.c
1195# if defined(SONY_NWZE360)
1196target/arm/imx233/sony-nwz/lcd-nwze360.c
1197target/arm/imx233/sony-nwz/powermgmt-nwze360.c
1198# elif defined(SONY_NWZE370)
1199target/arm/imx233/sony-nwz/lcd-nwze370.c
1200target/arm/imx233/sony-nwz/powermgmt-nwze370.c
1201# endif
1202#endif
1203
1187#ifdef SANSA_CONNECT 1204#ifdef SANSA_CONNECT
1188drivers/lcd-memframe.c 1205drivers/lcd-memframe.c
1189target/arm/tms320dm320/sdmmc-dm320.c 1206target/arm/tms320dm320/sdmmc-dm320.c
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 7252d62c5e..497325d845 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -148,6 +148,7 @@
148#define CREATIVE_ZENXFI2_PAD 54 148#define CREATIVE_ZENXFI2_PAD 54
149#define CREATIVE_ZENXFI3_PAD 55 149#define CREATIVE_ZENXFI3_PAD 55
150#define MA_PAD 56 150#define MA_PAD 56
151#define SONY_NWZ_PAD 57
151 152
152/* CONFIG_REMOTE_KEYPAD */ 153/* CONFIG_REMOTE_KEYPAD */
153#define H100_REMOTE 1 154#define H100_REMOTE 1
@@ -250,6 +251,8 @@
250#define LCD_CREATIVEZXFI2 48 /* as used by the Creative Zen X-Fi2 */ 251#define LCD_CREATIVEZXFI2 48 /* as used by the Creative Zen X-Fi2 */
251#define LCD_CREATIVEZXFI3 49 /* as used by the Creative Zen X-Fi3 */ 252#define LCD_CREATIVEZXFI3 49 /* as used by the Creative Zen X-Fi3 */
252#define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */ 253#define LCD_ILI9342 50 /* as used by HiFi E.T MA9/MA8 */
254#define LCD_NWZE370 51 /* as used by Sony NWZ-E370 series */
255#define LCD_NWZE360 52 /* as used by Sony NWZ-E360 series */
253 256
254/* LCD_PIXELFORMAT */ 257/* LCD_PIXELFORMAT */
255#define HORIZONTAL_PACKING 1 258#define HORIZONTAL_PACKING 1
@@ -509,6 +512,10 @@ Lyre prototype 1 */
509#include "config/samsungypr0.h" 512#include "config/samsungypr0.h"
510#elif defined(MA9) 513#elif defined(MA9)
511#include "config/hifietma9.h" 514#include "config/hifietma9.h"
515#elif defined(SONY_NWZE370)
516#include "config/sonynwze370.h"
517#elif defined(SONY_NWZE360)
518#include "config/sonynwze360.h"
512#else 519#else
513/* no known platform */ 520/* no known platform */
514#endif 521#endif
diff --git a/firmware/export/config/sonynwze360.h b/firmware/export/config/sonynwze360.h
new file mode 100644
index 0000000000..d914c1c253
--- /dev/null
+++ b/firmware/export/config/sonynwze360.h
@@ -0,0 +1,183 @@
1/*
2 * This config file is for the Sony NWZ-E360 series
3 */
4#define IMX233_SUBTARGET 3780
5#define IMX233_PACKAGE IMX233_BGA169
6
7/* For Rolo and boot loader */
8#define MODEL_NUMBER 89
9#define MODEL_NAME "Sony NWZ-E360 series"
10
11#define HW_SAMPR_CAPS SAMPR_CAP_ALL
12
13/* Define bitmask of input sources - recordable bitmask can be defined
14 explicitly if different */
15#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
16
17/* define this if you have a bitmap LCD display */
18#define HAVE_LCD_BITMAP
19/* define this if you have a colour LCD */
20#define HAVE_LCD_COLOR
21
22#ifndef BOOTLOADER
23#define HAVE_ALBUMART
24
25/* define this to enable bitmap scaling */
26#define HAVE_BMP_SCALING
27
28/* define this to enable JPEG decoding */
29#define HAVE_JPEG
30
31/* Define this if a programmable hotkey is mapped */
32#define HAVE_HOTKEY
33
34/* define this if you have access to the quickscreen */
35#define HAVE_QUICKSCREEN
36
37/* define this if you have a light associated with the buttons */
38
39/* define this if you would like tagcache to build on this target */
40#define HAVE_TAGCACHE
41
42/* define this if you have LCD enable function */
43#define HAVE_LCD_ENABLE
44
45/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
46 should be defined as well.
47#define HAVE_LCD_SLEEP
48#define HAVE_LCD_SLEEP_SETTING
49*/
50
51/* define this if you can flip your LCD
52#define HAVE_LCD_FLIP
53*/
54
55/* define this if you can invert the colours on your LCD
56#define HAVE_LCD_INVERT
57*/
58
59/* define this if you have a real-time clock */
60#define CONFIG_RTC RTC_IMX233
61
62/* define this if you have a real-time clock with alarm facilities */
63#define HAVE_RTC_ALARM
64
65#endif /* !BOOTLOADER */
66
67/* define this if you have an i.MX23 codec */
68#define HAVE_IMX233_CODEC
69
70#define CONFIG_TUNER STFM1000
71
72/* There is no hardware tone control */
73#define HAVE_SW_TONE_CONTROLS
74
75#define CONFIG_KEYPAD SONY_NWZ_PAD
76
77/* Define this to enable morse code input */
78#define HAVE_MORSE_INPUT
79
80/* Define this if you do software codec */
81#define CONFIG_CODEC SWCODEC
82
83/* LCD dimensions */
84#define LCD_WIDTH 240
85#define LCD_HEIGHT 320
86#define LCD_DEPTH 16 /* 65536 colours */
87#define LCD_PIXELFORMAT RGB565 /* rgb565 */
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#define AB_REPEAT_ENABLE
99
100/* Define this for LCD backlight available */
101#define HAVE_BACKLIGHT
102#define HAVE_BACKLIGHT_BRIGHTNESS
103
104/* Main LCD backlight brightness range and defaults */
105#define MIN_BRIGHTNESS_SETTING 0
106#define MAX_BRIGHTNESS_SETTING 100
107#define DEFAULT_BRIGHTNESS_SETTING 50
108
109/* Which backlight fading type? */
110#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
111
112/* define this if you have a flash memory storage */
113#define HAVE_FLASH_STORAGE
114
115/* define this if the flash memory uses the SecureDigital Memory Card protocol */
116#define CONFIG_STORAGE STORAGE_MMC
117
118/* todo */
119#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
120#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
121#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
122#define BATTERY_CAPACITY_INC 0 /* capacity increment */
123#define BATTERY_TYPES_COUNT 1 /* only one type */
124
125#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
126
127/* Charging implemented in a target-specific algorithm */
128#define CONFIG_CHARGING CHARGING_TARGET
129
130/* define this if the unit can be powered or charged via USB */
131#define HAVE_USB_POWER
132
133/* Define this if you have an IMX233*/
134#define CONFIG_CPU IMX233
135
136/* Define this if you want to use the IMX233 i2c interface */
137#define CONFIG_I2C I2C_IMX233
138
139/* define current usage levels (based on battery bench) */
140#define CURRENT_NORMAL 35
141#define CURRENT_BACKLIGHT 30
142#define CURRENT_RECORD CURRENT_NORMAL
143
144/* maximum charging current */
145#define CURRENT_MAX_CHG 200
146
147/* Define this to the CPU frequency */
148#define CPU_FREQ 454000000
149
150/* Type of LCD */
151#define CONFIG_LCD LCD_NWZE360
152
153/* Offset ( in the firmware file's header ) to the file CRC and data. These are
154 only used when loading the old format rockbox.e200 file */
155#define FIRMWARE_OFFSET_FILE_CRC 0x0
156#define FIRMWARE_OFFSET_FILE_DATA 0x8
157
158/* USB On-the-go */
159#define CONFIG_USBOTG USBOTG_ARC
160
161/* enable these for the experimental usb stack */
162#define HAVE_USBSTACK
163//#define USB_HANDLED_BY_OF
164#define USE_ROCKBOX_USB
165#define USB_VENDOR_ID 0x054c
166#define USB_PRODUCT_ID 0x059b
167#define HAVE_USB_HID_MOUSE
168#define HAVE_BOOTLOADER_USB_MODE
169
170/* The fuze+ actually interesting partition table does not use 512-byte sector
171 * (usually 2048 logical sector size) */
172#define MAX_LOG_SECTOR_SIZE 2048
173
174/* Define this if you have adjustable CPU frequency */
175#define HAVE_ADJUSTABLE_CPU_FREQ
176
177#define BOOTFILE_EXT "sony"
178#define BOOTFILE "rockbox." BOOTFILE_EXT
179#define BOOTDIR "/.rockbox"
180
181#define INCLUDE_TIMEOUT_API
182
183
diff --git a/firmware/export/config/sonynwze370.h b/firmware/export/config/sonynwze370.h
new file mode 100644
index 0000000000..45fa289e0d
--- /dev/null
+++ b/firmware/export/config/sonynwze370.h
@@ -0,0 +1,182 @@
1/*
2 * This config file is for the Sony NWZ-E370 series
3 */
4#define IMX233_SUBTARGET 3780
5#define IMX233_PACKAGE IMX233_BGA169
6
7/* For Rolo and boot loader */
8#define MODEL_NUMBER 88
9#define MODEL_NAME "Sony NWZ-E370 series"
10
11#define HW_SAMPR_CAPS SAMPR_CAP_ALL
12
13/* Define bitmask of input sources - recordable bitmask can be defined
14 explicitly if different */
15#define INPUT_SRC_CAPS SRC_CAP_FMRADIO
16
17/* define this if you have a bitmap LCD display */
18#define HAVE_LCD_BITMAP
19/* define this if you have a colour LCD */
20#define HAVE_LCD_COLOR
21
22#ifndef BOOTLOADER
23#define HAVE_ALBUMART
24
25/* define this to enable bitmap scaling */
26#define HAVE_BMP_SCALING
27
28/* define this to enable JPEG decoding */
29#define HAVE_JPEG
30
31/* Define this if a programmable hotkey is mapped */
32#define HAVE_HOTKEY
33
34/* define this if you have access to the quickscreen */
35#define HAVE_QUICKSCREEN
36
37/* define this if you have a light associated with the buttons */
38
39/* define this if you would like tagcache to build on this target */
40#define HAVE_TAGCACHE
41
42/* define this if you have LCD enable function */
43#define HAVE_LCD_ENABLE
44
45/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
46 should be defined as well.
47#define HAVE_LCD_SLEEP
48#define HAVE_LCD_SLEEP_SETTING
49*/
50
51/* define this if you can flip your LCD
52#define HAVE_LCD_FLIP
53*/
54
55/* define this if you can invert the colours on your LCD
56#define HAVE_LCD_INVERT
57*/
58
59/* define this if you have a real-time clock */
60#define CONFIG_RTC RTC_IMX233
61
62/* define this if you have a real-time clock with alarm facilities */
63#define HAVE_RTC_ALARM
64
65#endif /* !BOOTLOADER */
66
67/* define this if you have an i.MX23 codec */
68#define HAVE_IMX233_CODEC
69
70#define CONFIG_TUNER STFM1000
71
72/* There is no hardware tone control */
73#define HAVE_SW_TONE_CONTROLS
74
75#define CONFIG_KEYPAD SONY_NWZ_PAD
76
77/* Define this to enable morse code input */
78#define HAVE_MORSE_INPUT
79
80/* Define this if you do software codec */
81#define CONFIG_CODEC SWCODEC
82
83/* LCD dimensions */
84#define LCD_WIDTH 128
85#define LCD_HEIGHT 160
86#define LCD_DEPTH 16 /* 65536 colours */
87#define LCD_PIXELFORMAT RGB565 /* rgb565 */
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#define AB_REPEAT_ENABLE
99
100/* Define this for LCD backlight available */
101#define HAVE_BACKLIGHT
102#define HAVE_BACKLIGHT_BRIGHTNESS
103
104/* Main LCD backlight brightness range and defaults */
105#define MIN_BRIGHTNESS_SETTING 0
106#define MAX_BRIGHTNESS_SETTING 100
107#define DEFAULT_BRIGHTNESS_SETTING 50
108
109/* Which backlight fading type? */
110#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
111
112/* define this if you have a flash memory storage */
113#define HAVE_FLASH_STORAGE
114
115/* define this if the flash memory uses the SecureDigital Memory Card protocol */
116#define CONFIG_STORAGE STORAGE_MMC
117
118/* todo */
119#define BATTERY_CAPACITY_DEFAULT 550 /* default battery capacity */
120#define BATTERY_CAPACITY_MIN 550 /* min. capacity selectable */
121#define BATTERY_CAPACITY_MAX 550 /* max. capacity selectable */
122#define BATTERY_CAPACITY_INC 0 /* capacity increment */
123#define BATTERY_TYPES_COUNT 1 /* only one type */
124
125#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
126
127/* Charging implemented in a target-specific algorithm */
128#define CONFIG_CHARGING CHARGING_TARGET
129
130/* define this if the unit can be powered or charged via USB */
131#define HAVE_USB_POWER
132
133/* Define this if you have an IMX233*/
134#define CONFIG_CPU IMX233
135
136/* Define this if you want to use the IMX233 i2c interface */
137#define CONFIG_I2C I2C_IMX233
138
139/* define current usage levels (based on battery bench) */
140#define CURRENT_NORMAL 35
141#define CURRENT_BACKLIGHT 30
142#define CURRENT_RECORD CURRENT_NORMAL
143
144/* maximum charging current */
145#define CURRENT_MAX_CHG 200
146
147/* Define this to the CPU frequency */
148#define CPU_FREQ 454000000
149
150/* Type of LCD */
151#define CONFIG_LCD LCD_NWZE370
152
153/* Offset ( in the firmware file's header ) to the file CRC and data. These are
154 only used when loading the old format rockbox.e200 file */
155#define FIRMWARE_OFFSET_FILE_CRC 0x0
156#define FIRMWARE_OFFSET_FILE_DATA 0x8
157
158/* USB On-the-go */
159#define CONFIG_USBOTG USBOTG_ARC
160
161/* enable these for the experimental usb stack */
162#define HAVE_USBSTACK
163//#define USB_HANDLED_BY_OF
164#define USE_ROCKBOX_USB
165#define USB_VENDOR_ID 0x054c
166#define USB_PRODUCT_ID 0x068a
167#define HAVE_USB_HID_MOUSE
168#define HAVE_BOOTLOADER_USB_MODE
169
170/* The fuze+ actually interesting partition table does not use 512-byte sector
171 * (usually 2048 logical sector size) */
172#define MAX_LOG_SECTOR_SIZE 2048
173
174/* Define this if you have adjustable CPU frequency */
175#define HAVE_ADJUSTABLE_CPU_FREQ
176
177#define BOOTFILE_EXT "sony"
178#define BOOTFILE "rockbox." BOOTFILE_EXT
179#define BOOTDIR "/.rockbox"
180
181#define INCLUDE_TIMEOUT_API
182
diff --git a/firmware/target/arm/imx233/sdmmc-imx233.c b/firmware/target/arm/imx233/sdmmc-imx233.c
index 708e3c2464..c81220166d 100644
--- a/firmware/target/arm/imx233/sdmmc-imx233.c
+++ b/firmware/target/arm/imx233/sdmmc-imx233.c
@@ -124,6 +124,15 @@ struct sdmmc_config_t sdmmc_config[] =
124 .ssp = 1, 124 .ssp = 1,
125 .mode = SD_MODE, 125 .mode = SD_MODE,
126 }, 126 },
127#elif defined(SONY_NWZE370) || defined(SONY_NWZE360)
128 /* The Sony NWZ-E370 uses #B1P29 for power */
129 {
130 .name = "internal/SD",
131 .flags = POWER_PIN | POWER_INVERTED | WINDOW,
132 .power_pin = PIN(1, 29),
133 .ssp = 2,
134 .mode = MMC_MODE
135 },
127#else 136#else
128#error You need to write the sd/mmc config! 137#error You need to write the sd/mmc config!
129#endif 138#endif
diff --git a/firmware/target/arm/imx233/sony-nwz/adc-nwz.c b/firmware/target/arm/imx233/sony-nwz/adc-nwz.c
new file mode 100644
index 0000000000..e53005c082
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/adc-nwz.c
@@ -0,0 +1,38 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "adc-target.h"
22#include "adc-imx233.h"
23
24int imx233_adc_mapping[] =
25{
26 [ADC_BATTERY] = IMX233_ADC_BATTERY,
27 [ADC_DIE_TEMP] = IMX233_ADC_DIE_TEMP,
28 [ADC_VDDIO] = IMX233_ADC_VDDIO,
29 [ADC_5V] = IMX233_ADC_VDD5V,
30};
31
32const char *imx233_adc_channel_name[] =
33{
34 "Battery(raw)",
35 "Die temperature(°C)",
36 "VddIO",
37 "Vdd5V",
38};
diff --git a/firmware/target/arm/imx233/sony-nwz/adc-target.h b/firmware/target/arm/imx233/sony-nwz/adc-target.h
new file mode 100644
index 0000000000..e9c1939941
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/adc-target.h
@@ -0,0 +1,31 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 _ADC_TARGET_H_
22#define _ADC_TARGET_H_
23
24#define NUM_ADC_CHANNELS 4
25
26#define ADC_BATTERY 0
27#define ADC_DIE_TEMP 1
28#define ADC_VDDIO 2
29#define ADC_5V 3
30
31#endif
diff --git a/firmware/target/arm/imx233/sony-nwz/audio-target.h b/firmware/target/arm/imx233/sony-nwz/audio-target.h
new file mode 100644
index 0000000000..afa3d9649b
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/audio-target.h
@@ -0,0 +1,24 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 __audio_target__
22#define __audio_target__
23
24#endif /* __audio_target__ */
diff --git a/firmware/target/arm/imx233/sony-nwz/backlight-nwz.c b/firmware/target/arm/imx233/sony-nwz/backlight-nwz.c
new file mode 100644
index 0000000000..ad3ef484db
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/backlight-nwz.c
@@ -0,0 +1,61 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "lcd.h"
25#include "backlight.h"
26#include "backlight-target.h"
27#include "pwm-imx233.h"
28#include "pinctrl-imx233.h"
29
30void _backlight_set_brightness(int brightness)
31{
32 imx233_pwm_setup_simple(2, 24000, 100 - brightness);
33 imx233_pwm_enable(2, true);
34}
35
36bool _backlight_init(void)
37{
38 imx233_pinctrl_acquire(0, 10, "backlight_enable");
39 imx233_pinctrl_set_function(0, 10, PINCTRL_FUNCTION_GPIO);
40 imx233_pinctrl_enable_gpio(0, 10, true);
41 imx233_pinctrl_set_gpio(0, 10, true);
42 _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
43 return true;
44}
45
46void _backlight_on(void)
47{
48#ifdef HAVE_LCD_ENABLE
49 lcd_enable(true); /* power on lcd + visible display */
50#endif
51 /* don't do anything special, the core will set the brightness */
52}
53
54void _backlight_off(void)
55{
56 /* there is no real on/off but we can set to 0 brightness */
57 _backlight_set_brightness(0);
58#ifdef HAVE_LCD_ENABLE
59 lcd_enable(false); /* power off visible display */
60#endif
61}
diff --git a/firmware/target/arm/imx233/sony-nwz/backlight-target.h b/firmware/target/arm/imx233/sony-nwz/backlight-target.h
new file mode 100644
index 0000000000..78a0a72d85
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/backlight-target.h
@@ -0,0 +1,29 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 BACKLIGHT_TARGET_H
22#define BACKLIGHT_TARGET_H
23
24bool _backlight_init(void);
25void _backlight_on(void);
26void _backlight_off(void);
27void _backlight_set_brightness(int brightness);
28
29#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/arm/imx233/sony-nwz/button-nwz.c b/firmware/target/arm/imx233/sony-nwz/button-nwz.c
new file mode 100644
index 0000000000..93520133e8
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/button-nwz.c
@@ -0,0 +1,64 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "button-target.h"
22#include "system.h"
23#include "system-target.h"
24#include "pinctrl-imx233.h"
25#include "power-imx233.h"
26#include "string.h"
27#include "usb.h"
28#include "button-lradc-imx233.h"
29
30struct imx233_button_lradc_mapping_t imx233_button_lradc_mapping[] =
31{
32#ifdef SONY_NWZE360
33 {195, BUTTON_VOL_DOWN},
34 {810, BUTTON_VOL_UP},
35#endif
36 {1095, BUTTON_BACK},
37 {1470, BUTTON_PLAY},
38 {1845, BUTTON_RIGHT},
39 {2185, BUTTON_LEFT},
40 {2525, BUTTON_UP},
41 {2870, BUTTON_DOWN},
42 {3400, 0},
43 {0, IMX233_BUTTON_LRADC_END},
44};
45
46void button_init_device(void)
47{
48 imx233_button_lradc_init();
49}
50
51#ifdef HAS_BUTTON_HOLD
52bool button_hold(void)
53{
54 return imx233_button_lradc_hold();
55}
56#endif
57
58int button_read_device(void)
59{
60 int res = 0;
61 if(BF_RD(POWER_STS, PSWITCH) == 3)
62 res |= BUTTON_POWER;
63 return imx233_button_lradc_read(res);
64}
diff --git a/firmware/target/arm/imx233/sony-nwz/button-target.h b/firmware/target/arm/imx233/sony-nwz/button-target.h
new file mode 100644
index 0000000000..94d480f575
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/button-target.h
@@ -0,0 +1,62 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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);
29bool button_debug_screen(void);
30
31#ifdef SONY_NWZE360
32// Sony NWZ-E360 has hold detect on B0P09, inverted using pullup
33#define HAS_BUTTON_HOLD
34#define IMX233_BUTTON_LRADC_HOLD_DET BLH_GPIO
35#define BLH_GPIO_BANK 0
36#define BLH_GPIO_PIN 9
37#define BLH_GPIO_INVERTED
38#define BLH_GPIO_PULLUP
39#endif
40
41#define IMX233_BUTTON_LRADC_CHANNEL 0
42
43/* Main unit's buttons */
44#define BUTTON_POWER 0x00000001
45#define BUTTON_BACK 0x00000002
46#define BUTTON_PLAY 0x00000004
47#define BUTTON_LEFT 0x00000008
48#define BUTTON_UP 0x00000010
49#define BUTTON_DOWN 0x00000020
50#define BUTTON_RIGHT 0x00000040
51#ifdef SONY_NWZE360
52#define BUTTON_VOL_DOWN 0x00000080
53#define BUTTON_VOL_UP 0x00000100
54#endif
55
56#define BUTTON_MAIN 0x3ff
57
58/* Software power-off */
59#define POWEROFF_BUTTON BUTTON_POWER
60#define POWEROFF_COUNT 10
61
62#endif /* _BUTTON_TARGET_H_ */
diff --git a/firmware/target/arm/imx233/sony-nwz/debug-nwz.c b/firmware/target/arm/imx233/sony-nwz/debug-nwz.c
new file mode 100644
index 0000000000..acb1cfca37
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/debug-nwz.c
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "button-target.h"
24
25bool dbg_hw_target_info(void)
26{
27 return false;
28}
diff --git a/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c b/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
new file mode 100644
index 0000000000..a1377ce1f2
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/fmradio-i2c-nwz.c
@@ -0,0 +1,40 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "fmradio_i2c.h"
25#include "pinctrl-imx233.h"
26#include "i2c.h"
27
28void fmradio_i2c_init(void)
29{
30}
31
32int fmradio_i2c_write(unsigned char address, const unsigned char* buf, int count)
33{
34 return i2c_write(address, buf, count);
35}
36
37int fmradio_i2c_read(unsigned char address, unsigned char* buf, int count)
38{
39 return i2c_read(address, buf, count);
40}
diff --git a/firmware/target/arm/imx233/sony-nwz/lcd-nwze360.c b/firmware/target/arm/imx233/sony-nwz/lcd-nwze360.c
new file mode 100644
index 0000000000..2a913103c2
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/lcd-nwze360.c
@@ -0,0 +1,259 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2013 by Amaury Pouly
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 <sys/types.h> /* off_t */
22#include <string.h>
23#include "cpu.h"
24#include "system.h"
25#include "backlight-target.h"
26#include "lcd.h"
27#include "lcdif-imx233.h"
28#include "clkctrl-imx233.h"
29#include "pinctrl-imx233.h"
30#include "logf.h"
31
32#ifdef HAVE_LCD_ENABLE
33static bool lcd_on;
34#endif
35
36static void lcd_write_reg(uint8_t reg, uint8_t data)
37{
38 imx233_lcdif_wait_ready();
39 imx233_lcdif_set_data_swizzle(0);
40 imx233_lcdif_set_word_length(8);
41 imx233_lcdif_pio_send(false, 1, &reg);
42 if(reg != 0x22)
43 imx233_lcdif_pio_send(true, 1, &data);
44}
45
46static void lcd_init_seq(void)
47{
48 lcd_write_reg(0xea, 0);
49 lcd_write_reg(0xeb, 0x20);
50 lcd_write_reg(0xec, 0xc);
51 lcd_write_reg(0xed, 0xc4);
52 lcd_write_reg(0xe8, 0x38);
53 lcd_write_reg(0xe9, 0xe);
54 lcd_write_reg(0xf1, 1);
55 lcd_write_reg(0xf2, 8);
56 lcd_write_reg(0x2e, 0x86);
57 lcd_write_reg(0x29, 0xff);
58 lcd_write_reg(0xe4, 1);
59 lcd_write_reg(0xe5, 0x20);
60 lcd_write_reg(0xe7, 1);
61 lcd_write_reg(0x40, 0);
62 lcd_write_reg(0x41, 0);
63 lcd_write_reg(0x42, 0);
64 lcd_write_reg(0x43, 0x14);
65 lcd_write_reg(0x44, 0x14);
66 lcd_write_reg(0x45, 0x28);
67 lcd_write_reg(0x46, 0x11);
68 lcd_write_reg(0x47, 0x57);
69 lcd_write_reg(0x48, 5);
70 lcd_write_reg(0x49, 0x16);
71 lcd_write_reg(0x4a, 0x19);
72 lcd_write_reg(0x4b, 0x1a);
73 lcd_write_reg(0x4c, 0x1a);
74 lcd_write_reg(0x50, 0x17);
75 lcd_write_reg(0x51, 0x2b);
76 lcd_write_reg(0x52, 0x2b);
77 lcd_write_reg(0x53, 0x3f);
78 lcd_write_reg(0x54, 0x3f);
79 lcd_write_reg(0x55, 0x3f);
80 lcd_write_reg(0x56, 0x28);
81 lcd_write_reg(0x57, 0x6e);
82 lcd_write_reg(0x58, 5);
83 lcd_write_reg(0x59, 5);
84 lcd_write_reg(0x5a, 6);
85 lcd_write_reg(0x5b, 9);
86 lcd_write_reg(0x5c, 0x1a);
87 lcd_write_reg(0x5d, 0xcc);
88 lcd_write_reg(0x1b, 0x1b);
89 lcd_write_reg(0x1A, 1);
90 lcd_write_reg(0x24, 0x2f); // something special here
91 lcd_write_reg(0x25, 0x57); // something special here
92 lcd_write_reg(0x23, 0x8a);
93 lcd_write_reg(0x2f, 1);
94 lcd_write_reg(0x60, 0);
95 lcd_write_reg(0x16, 8);
96 lcd_write_reg(0x18, 0x36); // something special here
97 lcd_write_reg(0x19, 1);
98 udelay(5000);
99 lcd_write_reg(1, 0);
100 lcd_write_reg(0x1f, 0x88);
101 udelay(5000);
102 lcd_write_reg(0x1f, 0x80);
103 udelay(5000);
104 lcd_write_reg(0x1f, 0x90);
105 udelay(5000);
106 lcd_write_reg(0x1f, 0xD0);
107 udelay(5000);
108 lcd_write_reg(0x17, 6);
109 lcd_write_reg(0x37, 0);
110 lcd_write_reg(0x28, 0x38);
111 udelay(40000);
112 lcd_write_reg(0x28, 0x3c);
113}
114
115void lcd_init_device(void)
116{
117 /* the LCD seems to work at 24Mhz, so use the xtal clock with no divider */
118 imx233_clkctrl_enable(CLK_PIX, false);
119 imx233_clkctrl_set_div(CLK_PIX, 1);
120 imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */
121 imx233_clkctrl_enable(CLK_PIX, true);
122 imx233_lcdif_init();
123 imx233_lcdif_set_lcd_databus_width(8);
124 imx233_lcdif_set_timings(1, 1, 1, 1);
125 imx233_lcdif_enable_underflow_recover(true);
126 imx233_lcdif_setup_system_pins(8);
127 imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */
128
129 // reset device
130 imx233_lcdif_reset_lcd(true);
131 mdelay(10);
132 imx233_lcdif_reset_lcd(false);
133 mdelay(10);
134 imx233_lcdif_reset_lcd(true);
135 mdelay(150);
136
137 lcd_init_seq();
138#ifdef HAVE_LCD_ENABLE
139 lcd_on = true;
140#endif
141}
142
143#ifdef HAVE_LCD_ENABLE
144bool lcd_active(void)
145{
146 return lcd_on;
147}
148
149static void lcd_enable_seq(bool enable)
150{
151 if(!enable)
152 {
153 lcd_write_reg(0x1f, 0xd1);
154 lcd_write_reg(1, 0x40);
155 lcd_write_reg(1, 0xc0);
156 lcd_write_reg(0x19, 1);
157 }
158 else
159 {
160 lcd_write_reg(0x19, 0x81);
161 udelay(5000);
162 lcd_write_reg(1, 0x40);
163 udelay(20000);
164 lcd_write_reg(1, 0);
165 lcd_write_reg(0x1f, 0xd0);
166 }
167}
168
169void lcd_enable(bool enable)
170{
171 if(lcd_on == enable)
172 return;
173
174 lcd_on = enable;
175
176 if(enable)
177 imx233_lcdif_enable(true);
178 lcd_enable_seq(enable);
179 if(!enable)
180 imx233_lcdif_enable(false);
181 else
182 send_event(LCD_EVENT_ACTIVATION, NULL);
183}
184#endif
185
186void lcd_update(void)
187{
188 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
189}
190
191void lcd_update_rect(int x, int y, int w, int h)
192{
193#ifdef HAVE_LCD_ENABLE
194 if(!lcd_on)
195 return;
196#endif
197 /* make sure the rectangle is included in the screen */
198 x = MIN(x, LCD_WIDTH);
199 y = MIN(y, LCD_HEIGHT);
200 w = MIN(w, LCD_WIDTH - x);
201 h = MIN(h, LCD_HEIGHT - y);
202
203 imx233_lcdif_wait_ready();
204 lcd_write_reg(2, x >> 8);
205 lcd_write_reg(3, x & 0xff);
206 lcd_write_reg(4, (x + w - 1) >> 8);
207 lcd_write_reg(5, (x + w - 1) & 0xff);
208 lcd_write_reg(6, y >> 8);
209 lcd_write_reg(7, y & 0xff);
210 lcd_write_reg(8, (y + h - 1) >> 8);
211 lcd_write_reg(9, (y + h - 1) & 0xff);
212 lcd_write_reg(0x22, 0);
213
214 imx233_lcdif_wait_ready();
215 imx233_lcdif_set_word_length(16);
216 /* there are two cases here:
217 * - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME
218 * and send it
219 * - either width != LCD_WIDTH and we have to build a contiguous copy of the rectangular area
220 * into FRAME before sending it (which is slower and doesn't use the hardware)
221 * In all cases, FRAME just acts as a temporary buffer.
222 * NOTE It's more interesting to do a copy to FRAME in all cases since in system mode
223 * the clock runs at 24MHz which provides barely 10MB/s bandwidth compared to >100MB/s
224 * for memcopy operations
225 */
226 if(w == LCD_WIDTH)
227 {
228 memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data));
229 }
230 else
231 {
232 for(int i = 0; i < h; i++)
233 memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data));
234 }
235 /* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode
236 * (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count
237 * field must be a multiple of 2. Furthermore, it seems the lcd controller doesn't
238 * really like when both w and h are even, probably because the writes to the GRAM
239 * are done on several words and the controller requires dummy writes.
240 * The workaround is to always make sure that we send a number of pixels which is
241 * a multiple of 4 so that both the lcdif and the controller are happy. If any
242 * of w or h is odd, we will send a copy of the first pixels as dummy writes. We will
243 * send at most 3 bytes. We then send (w * h + 3) / 4 x 4 bytes.
244 */
245 if(w % 2 == 1 || h % 2 == 1)
246 {
247 /* copy three pixel after the last one */
248 for(int i = 0; i < 3; i++)
249 *((fb_data *)FRAME + w * h + i) = *((fb_data *)FRAME + i);
250 /* WARNING we need to update w and h to reflect the pixel count BUT it
251 * has no relation to w * h (it can even be 2 * prime). Hopefully, w <= 240 and
252 * h <= 320 so w * h <= 76800 and (w * h + 3) / 4 <= 38400 which fits into
253 * a 16-bit integer (horizontal count). */
254 h = (w * h + 3) / 4;
255 w = 4;
256 }
257 imx233_lcdif_dma_send((void *)FRAME_PHYS_ADDR, w, h);
258}
259
diff --git a/firmware/target/arm/imx233/sony-nwz/lcd-nwze370.c b/firmware/target/arm/imx233/sony-nwz/lcd-nwze370.c
new file mode 100644
index 0000000000..999f4ee525
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/lcd-nwze370.c
@@ -0,0 +1,219 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2013 by Amaury Pouly
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 <sys/types.h> /* off_t */
22#include <string.h>
23#include "cpu.h"
24#include "system.h"
25#include "backlight-target.h"
26#include "lcd.h"
27#include "lcdif-imx233.h"
28#include "clkctrl-imx233.h"
29#include "pinctrl-imx233.h"
30#include "logf.h"
31
32#ifdef HAVE_LCD_ENABLE
33static bool lcd_on;
34#endif
35
36static void lcd_write_reg(uint8_t reg, void *data, int data_len)
37{
38 imx233_lcdif_set_data_swizzle(0);
39 imx233_lcdif_set_word_length(8);
40 imx233_lcdif_pio_send(false, 1, &reg);
41 imx233_lcdif_pio_send(true, data_len, data);
42}
43
44static void lcd_init_seq(void)
45{
46 // seems compatible with ILI9163
47 lcd_write_reg(1, NULL, 0); // software reset
48 lcd_write_reg(0x11, NULL, 0); // sleep out
49 mdelay(150);
50 /* format: (<cmd> <data size> <data0> <dataN>)+ */
51 static uint8_t init_seq[] =
52 {
53 /* cmd sz data... */
54 0x26, 1, 4, /* Gamma Set */
55 0xb1, 2, 9, 0xd, /* Frame Rate */
56 0xc0, 2, 8, 0, /* Power Control 1 */
57 0xc1, 1, 5, /* Power Control 2 */
58 0xc5, 2, 0x31, 0x40, /* VCOM Control 1 */
59 0xc7, 1, 0xc8, /* VCOM Offset Control */
60 0xec, 1, 0xc, /* Unknown */
61 0x3a, 1, 5, /* Interface Pixel Format */
62 0x2a, 4, 0, 0, 0, 0x7f, /* Column Address */
63 0x2b, 4, 0, 0, 0, 0x9f, /* Page Address Set */
64 0x35, 1, 0, /* Tear Effect Line On */
65 0x36, 1, 0xc8, /* Memory access Control */
66 0xb4, 1, 0, /* Display Inversion */
67 0xb7, 1, 0, /* Source Driver Direction Control */
68 0xb8, 1, 0, /* Gate Driver Direction Control */
69 0xf2, 1, 1, /* Gamma Adjustment */
70 0xe0, 15, 0x3f, 0x20, 0x1d, 0x2d, 0x26, 0x0c, 0x4b, 0xb7,
71 0x39, 0x17, 0x1d, 0x16, 0x16, 0x10, 0x00, /* Positive Gamma */
72 0xe1, 15, 0x00, 0x1f, 0x21, 0x12, 0x18, 0x13, 0x34, 0x48,
73 0x46, 0x08, 0x21, 0x29, 0x28, 0x2f, 0x3f, /* Negative Gamma */
74 0x29, 0, /* Display On */
75 };
76
77 for(unsigned i = 0; i < sizeof(init_seq); )
78 {
79 lcd_write_reg(init_seq[i], &init_seq[i + 2], init_seq[i + 1]);
80 i += 2 + init_seq[i + 1];
81 }
82}
83
84void lcd_init_device(void)
85{
86 /* the LCD seems to work at 24Mhz, so use the xtal clock with no divider */
87 imx233_clkctrl_enable(CLK_PIX, false);
88 imx233_clkctrl_set_div(CLK_PIX, 1);
89 imx233_clkctrl_set_bypass(CLK_PIX, true); /* use XTAL */
90 imx233_clkctrl_enable(CLK_PIX, true);
91 imx233_lcdif_init();
92 imx233_lcdif_set_lcd_databus_width(8);
93 imx233_lcdif_set_timings(2, 2, 2, 2);
94 imx233_lcdif_enable_underflow_recover(true);
95 imx233_lcdif_setup_system_pins(8);
96 imx233_lcdif_set_byte_packing_format(0xf); /* two pixels per 32-bit word */
97
98 // reset device
99 imx233_lcdif_reset_lcd(true);
100 mdelay(10);
101 imx233_lcdif_reset_lcd(false);
102 mdelay(10);
103 imx233_lcdif_reset_lcd(true);
104 mdelay(150);
105
106 lcd_init_seq();
107#ifdef HAVE_LCD_ENABLE
108 lcd_on = true;
109#endif
110}
111
112#ifdef HAVE_LCD_ENABLE
113bool lcd_active(void)
114{
115 return lcd_on;
116}
117
118static void lcd_enable_seq(bool enable)
119{
120 if(enable)
121 {
122 lcd_write_reg(0x11, NULL, 0);
123 lcd_write_reg(0x29, NULL, 0);
124 }
125 else
126 {
127 lcd_write_reg(0x28, NULL, 0);
128 lcd_write_reg(0x10, NULL, 0);
129 }
130}
131
132void lcd_enable(bool enable)
133{
134 if(lcd_on == enable)
135 return;
136
137 lcd_on = enable;
138
139 if(enable)
140 imx233_lcdif_enable(true);
141 lcd_enable_seq(enable);
142 if(!enable)
143 imx233_lcdif_enable(false);
144 else
145 send_event(LCD_EVENT_ACTIVATION, NULL);
146}
147#endif
148
149void lcd_update(void)
150{
151 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
152}
153
154void lcd_update_rect(int x, int y, int w, int h)
155{
156#ifdef HAVE_LCD_ENABLE
157 if(!lcd_on)
158 return;
159#endif
160 /* make sure the rectangle is included in the screen */
161 x = MIN(x, LCD_WIDTH);
162 y = MIN(y, LCD_HEIGHT);
163 w = MIN(w, LCD_WIDTH - x);
164 h = MIN(h, LCD_HEIGHT - y);
165
166 imx233_lcdif_wait_ready();
167 uint32_t window = x << 8 | (x + w - 1) << 24;
168 lcd_write_reg(0x2a, &window, sizeof(window));
169 window = y << 8 | (y + h - 1) << 24;
170 lcd_write_reg(0x2b, &window, sizeof(window));
171 lcd_write_reg(0x2c, NULL, 0);
172
173 imx233_lcdif_wait_ready();
174 imx233_lcdif_set_data_swizzle(3);
175 imx233_lcdif_set_word_length(8);
176 /* there are two cases here:
177 * - either width = LCD_WIDTH and we can directly memcopy a part of lcd_framebuffer to FRAME
178 * and send it
179 * - either width != LCD_WIDTH and we have to build a contiguous copy of the rectangular area
180 * into FRAME before sending it (which is slower and doesn't use the hardware)
181 * In all cases, FRAME just acts as a temporary buffer.
182 * NOTE It's more interesting to do a copy to FRAME in all cases since in system mode
183 * the clock runs at 24MHz which provides barely 10MB/s bandwidth compared to >100MB/s
184 * for memcopy operations
185 */
186 if(w == LCD_WIDTH)
187 {
188 memcpy((void *)FRAME, FBADDR(x,y), w * h * sizeof(fb_data));
189 }
190 else
191 {
192 for(int i = 0; i < h; i++)
193 memcpy((fb_data *)FRAME + i * w, FBADDR(x,y + i), w * sizeof(fb_data));
194 }
195 /* WARNING The LCDIF has a limitation on the vertical count ! In 16-bit packed mode
196 * (which we used, ie 16-bit per pixel, 2 pixels per 32-bit words), the v_count
197 * field must be a multiple of 2. Furthermore, it seems the lcd controller doesn't
198 * really like when both w and h are even, probably because the writes to the GRAM
199 * are done on several words and the controller requires dummy writes.
200 * The workaround is to always make sure that we send a number of pixels which is
201 * a multiple of 4 so that both the lcdif and the controller are happy. If any
202 * of w or h is odd, we will send a copy of the first pixels as dummy writes. We will
203 * send at most 3 bytes. We then send (w * h + 3) / 4 x 4 bytes.
204 */
205 if(w % 2 == 1 || h % 2 == 1)
206 {
207 /* copy three pixel after the last one */
208 for(int i = 0; i < 3; i++)
209 *((fb_data *)FRAME + w * h + i) = *((fb_data *)FRAME + i);
210 /* WARNING we need to update w and h to reflect the pixel count BUT it
211 * has no relation to w * h (it can even be 2 * prime). Hopefully, w <= 240 and
212 * h <= 320 so w * h <= 76800 and (w * h + 3) / 4 <= 38400 which fits into
213 * a 16-bit integer (horizontal count). */
214 h = (w * h + 3) / 4;
215 w = 4;
216 }
217 imx233_lcdif_dma_send((void *)FRAME_PHYS_ADDR, w * 2, h);
218}
219
diff --git a/firmware/target/arm/imx233/sony-nwz/lcd-target.h b/firmware/target/arm/imx233/sony-nwz/lcd-target.h
new file mode 100644
index 0000000000..931fcb32a0
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/lcd-target.h
@@ -0,0 +1,24 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (c) 2012 by Amaury Pouly
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 LCD_TARGET_H
22#define LCD_TARGET_H
23
24#endif /* LCD_TARGET_H */
diff --git a/firmware/target/arm/imx233/sony-nwz/power-nwz.c b/firmware/target/arm/imx233/sony-nwz/power-nwz.c
new file mode 100644
index 0000000000..88644919ad
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/power-nwz.c
@@ -0,0 +1,42 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "power.h"
24#include "tuner.h"
25#include "fmradio_i2c.h"
26#include "pinctrl-imx233.h"
27
28static bool tuner_enable = false;
29
30bool tuner_power(bool enable)
31{
32 if(enable != tuner_enable)
33 {
34 tuner_enable = enable;
35 }
36 return tuner_enable;
37}
38
39bool tuner_powered(void)
40{
41 return tuner_enable;
42}
diff --git a/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze360.c b/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze360.c
new file mode 100644
index 0000000000..fd395e30ca
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze360.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "config.h"
22#include "powermgmt-target.h"
23
24const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
25{
26 3659
27};
28
29const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
30{
31 3630
32};
33
34/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
35const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
36{
37 /* Toshiba Gigabeat S Li Ion 700mAH figured from discharge curve */
38 { 3659, 3719, 3745, 3761, 3785, 3813, 3856, 3926, 3984, 4040, 4121 },
39};
40
41/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
42const unsigned short percent_to_volt_charge[11] =
43{
44 /* Toshiba Gigabeat S Li Ion 700mAH figured from charge curve */
45 4028, 4063, 4087, 4111, 4135, 4156, 4173, 4185, 4194, 4202, 4208
46};
diff --git a/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze370.c b/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze370.c
new file mode 100644
index 0000000000..fd395e30ca
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/powermgmt-nwze370.c
@@ -0,0 +1,46 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 "config.h"
22#include "powermgmt-target.h"
23
24const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
25{
26 3659
27};
28
29const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
30{
31 3630
32};
33
34/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
35const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
36{
37 /* Toshiba Gigabeat S Li Ion 700mAH figured from discharge curve */
38 { 3659, 3719, 3745, 3761, 3785, 3813, 3856, 3926, 3984, 4040, 4121 },
39};
40
41/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
42const unsigned short percent_to_volt_charge[11] =
43{
44 /* Toshiba Gigabeat S Li Ion 700mAH figured from charge curve */
45 4028, 4063, 4087, 4111, 4135, 4156, 4173, 4185, 4194, 4202, 4208
46};
diff --git a/firmware/target/arm/imx233/sony-nwz/powermgmt-target.h b/firmware/target/arm/imx233/sony-nwz/powermgmt-target.h
new file mode 100644
index 0000000000..268423b433
--- /dev/null
+++ b/firmware/target/arm/imx233/sony-nwz/powermgmt-target.h
@@ -0,0 +1,58 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2013 by Amaury Pouly
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 POWERMGMT_TARGET_H
22#define POWERMGMT_TARGET_H
23
24#include "config.h"
25#include "powermgmt-imx233.h"
26
27/* Sony NWZ-E360/NWZ-E370 settings:
28 * - current ramp slope:
29 * - conditioning threshold voltage:
30 * - conditioning max voltage:
31 * - conditioning current:
32 * - conditioning timeout:
33 * - charging voltage:
34 * - charging current:
35 * - charging threshold current:
36 * - charging timeout:
37 * - top off period:
38 * - high die temperature:
39 * - low die temperature:
40 * - safe die temperature current:
41 * - battery temperature channel:
42 * - high battery temperature:
43 * - low battery temperature:
44 * - safe battery temperature current:
45 * - low DCDC battery voltage:
46 */
47
48#define IMX233_CHARGE_CURRENT 260
49#define IMX233_STOP_CURRENT 20
50#define IMX233_TOPOFF_TIMEOUT (30 * 60 * HZ)
51#define IMX233_CHARGING_TIMEOUT (4 * 3600 * HZ)
52#define IMX233_DIE_TEMP_HIGH 91
53#define IMX233_DIE_TEMP_LOW 56
54#define IMX233_BATT_TEMP_SENSOR 0
55#define IMX233_BATT_TEMP_HIGH 2400
56#define IMX233_BATT_TEMP_LOW 2300
57
58#endif /* POWERMGMT_TARGET_H */