summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCástor Muñoz <cmvidal@gmail.com>2016-05-12 03:16:27 +0200
committerCástor Muñoz <cmvidal@gmail.com>2016-05-13 23:23:35 +0200
commitd405026ca8bc4c63d8fcd5d63cef02341182774b (patch)
tree82fb19edcd02b68d0d336ca80f1c3ee4bd3be13c
parent5017523a6b1ea9d230d8b8cf801ad3adbe7f43f5 (diff)
downloadrockbox-d405026ca8bc4c63d8fcd5d63cef02341182774b.tar.gz
rockbox-d405026ca8bc4c63d8fcd5d63cef02341182774b.zip
iPod Nano2G: add HAVE_SERIAL
Change-Id: I46dca69c6708d3e6189f66e70badf0a594bac00b
-rw-r--r--firmware/SOURCES5
-rw-r--r--firmware/export/config/ipodnano2g.h4
-rw-r--r--firmware/target/arm/s5l8700/debug-s5l8700.c39
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c96
4 files changed, 143 insertions, 1 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 098eca427f..70729bcfa3 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1582,6 +1582,11 @@ target/arm/s5l8700/ipodnano2g/nand-nano2g.c
1582target/arm/s5l8700/ipodnano2g/pmu-nano2g.c 1582target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
1583target/arm/s5l8700/ipodnano2g/rtc-nano2g.c 1583target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
1584target/arm/s5l8700/usb-nano2g-6g.c 1584target/arm/s5l8700/usb-nano2g-6g.c
1585#ifdef HAVE_SERIAL
1586target/arm/uc870x.c
1587target/arm/s5l8700/uart-s5l8701.c
1588target/arm/s5l8700/ipodnano2g/serial-nano2g.c
1589#endif
1585#ifndef BOOTLOADER 1590#ifndef BOOTLOADER
1586target/arm/s5l8700/ipodnano2g/audio-nano2g.c 1591target/arm/s5l8700/ipodnano2g/audio-nano2g.c
1587target/arm/s5l8700/ipodnano2g/piezo-nano2g.c 1592target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
diff --git a/firmware/export/config/ipodnano2g.h b/firmware/export/config/ipodnano2g.h
index 5ad41a16c1..a9c7239056 100644
--- a/firmware/export/config/ipodnano2g.h
+++ b/firmware/export/config/ipodnano2g.h
@@ -232,7 +232,9 @@
232/* Define this if you can switch on/off the accessory power supply */ 232/* Define this if you can switch on/off the accessory power supply */
233#define HAVE_ACCESSORY_SUPPLY 233#define HAVE_ACCESSORY_SUPPLY
234//#define IPOD_ACCESSORY_PROTOCOL 234//#define IPOD_ACCESSORY_PROTOCOL
235//#define HAVE_SERIAL 235#ifdef LOGF_SERIAL
236#define HAVE_SERIAL
237#endif
236 238
237/* Define this, if you can switch on/off the lineout */ 239/* Define this, if you can switch on/off the lineout */
238#define HAVE_LINEOUT_POWEROFF 240#define HAVE_LINEOUT_POWEROFF
diff --git a/firmware/target/arm/s5l8700/debug-s5l8700.c b/firmware/target/arm/s5l8700/debug-s5l8700.c
index e318dbf2da..ecb15df5d0 100644
--- a/firmware/target/arm/s5l8700/debug-s5l8700.c
+++ b/firmware/target/arm/s5l8700/debug-s5l8700.c
@@ -32,6 +32,10 @@
32#include "pmu-target.h" 32#include "pmu-target.h"
33#include "nand-target.h" 33#include "nand-target.h"
34#endif 34#endif
35#ifdef HAVE_SERIAL
36#include "uart-target.h"
37#include "uc870x.h"
38#endif
35 39
36#define DEBUG_CANCEL BUTTON_MENU 40#define DEBUG_CANCEL BUTTON_MENU
37 41
@@ -49,7 +53,11 @@ bool dbg_hw_info(void)
49 int i; 53 int i;
50#ifdef IPOD_NANO2G 54#ifdef IPOD_NANO2G
51 unsigned int state = 0; 55 unsigned int state = 0;
56#ifdef UC870X_DEBUG
57 const unsigned int max_states=3;
58#else
52 const unsigned int max_states=2; 59 const unsigned int max_states=2;
60#endif
53 int nand_bank_count; 61 int nand_bank_count;
54 struct storage_info info; 62 struct storage_info info;
55 const struct nand_device_info_type *nand_devicetype[4]; 63 const struct nand_device_info_type *nand_devicetype[4];
@@ -123,6 +131,37 @@ bool dbg_hw_info(void)
123 _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off"); 131 _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
124 _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28)); 132 _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
125 } 133 }
134#ifdef UC870X_DEBUG
135 else if(state==2)
136 {
137 extern struct uartc_port ser_port;
138 int tx_stat, rx_stat, tx_speed, rx_speed;
139 char line_cfg[4];
140 int abr_stat;
141 uint32_t abr_cnt;
142 char *abrstatus[] = {"Idle", "Launched", "Counting", "Abnormal"};
143
144 uartc_port_get_line_info(&ser_port,
145 &tx_stat, &rx_stat, &tx_speed, &rx_speed, line_cfg);
146 abr_stat = uartc_port_get_abr_info(&ser_port, &abr_cnt);
147
148 _DEBUG_PRINTF("UART %d:", ser_port.id);
149 line++;
150 _DEBUG_PRINTF("line: %s", line_cfg);
151 _DEBUG_PRINTF("Tx: %s, speed: %d", tx_stat ? "On":"Off", tx_speed);
152 _DEBUG_PRINTF("Rx: %s, speed: %d", rx_stat ? "On":"Off", rx_speed);
153 _DEBUG_PRINTF("ABR: %s, cnt: %u", abrstatus[abr_stat], abr_cnt);
154 line++;
155 _DEBUG_PRINTF("n_tx_bytes: %u", ser_port.n_tx_bytes);
156 _DEBUG_PRINTF("n_rx_bytes: %u", ser_port.n_rx_bytes);
157 _DEBUG_PRINTF("n_ovr_err: %u", ser_port.n_ovr_err);
158 _DEBUG_PRINTF("n_parity_err: %u", ser_port.n_parity_err);
159 _DEBUG_PRINTF("n_frame_err: %u", ser_port.n_frame_err);
160 _DEBUG_PRINTF("n_break_detect: %u", ser_port.n_break_detect);
161 _DEBUG_PRINTF("ABR n_abnormal: %u %u",
162 ser_port.n_abnormal0, ser_port.n_abnormal1);
163 }
164#endif
126 else 165 else
127 { 166 {
128 state=0; 167 state=0;
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c
new file mode 100644
index 0000000000..487984fbe3
--- /dev/null
+++ b/firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c
@@ -0,0 +1,96 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Cástor Muñoz
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 <stdint.h>
22#include <stdbool.h>
23
24#include "config.h"
25#include "cpu.h"
26#include "system.h"
27#include "serial.h"
28
29#include "s5l8700.h"
30#include "uc870x.h"
31
32/* Define LOGF_ENABLE to enable logf output in this file */
33#define LOGF_ENABLE
34#include "logf.h"
35
36
37/* shall include serial HW configuracion for specific target */
38#define NANO2G_UART_CLK_HZ 24000000 /* external OSC0 ??? */
39
40/* This values below are valid with a UCLK of 24MHz */
41#define BRDATA_9600 (155) /* 9615 */
42#define BRDATA_19200 (77) /* 19231 */
43#define BRDATA_28800 (51) /* 28846 */
44#define BRDATA_38400 (38) /* 38462 */
45#define BRDATA_57600 (25) /* 57692 */
46#define BRDATA_115200 (12) /* 115385 */
47
48
49extern const struct uartc s5l8701_uartc0;
50
51struct uartc_port ser_port IDATA_ATTR =
52{
53 /* location */
54 .uartc = &s5l8701_uartc0,
55 .id = 0,
56
57 /* configuration */
58 .rx_trg = UFCON_RX_FIFO_TRG_4,
59 .tx_trg = UFCON_TX_FIFO_TRG_EMPTY,
60 .clksel = UCON_CLKSEL_ECLK,
61 .clkhz = NANO2G_UART_CLK_HZ,
62
63 /* interrupt callbacks */
64 .rx_cb = NULL,
65 .tx_cb = NULL, /* polling */
66};
67
68/*
69 * serial driver API
70 */
71void serial_setup(void)
72{
73 uartc_port_open(&ser_port);
74
75 /* set a default configuration, Tx and Rx modes are
76 disabled when the port is initialized */
77 uartc_port_config(&ser_port, ULCON_DATA_BITS_8,
78 ULCON_PARITY_NONE, ULCON_STOP_BITS_1);
79 uartc_port_set_bitrate_raw(&ser_port, BRDATA_115200);
80
81 /* enable Tx interrupt request or POLLING mode */
82 uartc_port_set_tx_mode(&ser_port, UCON_MODE_INTREQ);
83
84 logf("[%lu] "MODEL_NAME" port %d ready!",
85 (uint32_t)USEC_TIMER, ser_port.id);
86}
87
88int tx_rdy(void)
89{
90 return uartc_port_tx_ready(&ser_port) ? 1 : 0;
91}
92
93void tx_writec(unsigned char c)
94{
95 uartc_port_tx_byte(&ser_port, c);
96}