iPod Nano2G: add HAVE_SERIAL
Change-Id: I46dca69c6708d3e6189f66e70badf0a594bac00b
This commit is contained in:
parent
5017523a6b
commit
d405026ca8
4 changed files with 143 additions and 1 deletions
|
@ -1582,6 +1582,11 @@ target/arm/s5l8700/ipodnano2g/nand-nano2g.c
|
||||||
target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
|
target/arm/s5l8700/ipodnano2g/pmu-nano2g.c
|
||||||
target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
|
target/arm/s5l8700/ipodnano2g/rtc-nano2g.c
|
||||||
target/arm/s5l8700/usb-nano2g-6g.c
|
target/arm/s5l8700/usb-nano2g-6g.c
|
||||||
|
#ifdef HAVE_SERIAL
|
||||||
|
target/arm/uc870x.c
|
||||||
|
target/arm/s5l8700/uart-s5l8701.c
|
||||||
|
target/arm/s5l8700/ipodnano2g/serial-nano2g.c
|
||||||
|
#endif
|
||||||
#ifndef BOOTLOADER
|
#ifndef BOOTLOADER
|
||||||
target/arm/s5l8700/ipodnano2g/audio-nano2g.c
|
target/arm/s5l8700/ipodnano2g/audio-nano2g.c
|
||||||
target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
|
target/arm/s5l8700/ipodnano2g/piezo-nano2g.c
|
||||||
|
|
|
@ -232,7 +232,9 @@
|
||||||
/* Define this if you can switch on/off the accessory power supply */
|
/* Define this if you can switch on/off the accessory power supply */
|
||||||
#define HAVE_ACCESSORY_SUPPLY
|
#define HAVE_ACCESSORY_SUPPLY
|
||||||
//#define IPOD_ACCESSORY_PROTOCOL
|
//#define IPOD_ACCESSORY_PROTOCOL
|
||||||
//#define HAVE_SERIAL
|
#ifdef LOGF_SERIAL
|
||||||
|
#define HAVE_SERIAL
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define this, if you can switch on/off the lineout */
|
/* Define this, if you can switch on/off the lineout */
|
||||||
#define HAVE_LINEOUT_POWEROFF
|
#define HAVE_LINEOUT_POWEROFF
|
||||||
|
|
|
@ -32,6 +32,10 @@
|
||||||
#include "pmu-target.h"
|
#include "pmu-target.h"
|
||||||
#include "nand-target.h"
|
#include "nand-target.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_SERIAL
|
||||||
|
#include "uart-target.h"
|
||||||
|
#include "uc870x.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DEBUG_CANCEL BUTTON_MENU
|
#define DEBUG_CANCEL BUTTON_MENU
|
||||||
|
|
||||||
|
@ -49,7 +53,11 @@ bool dbg_hw_info(void)
|
||||||
int i;
|
int i;
|
||||||
#ifdef IPOD_NANO2G
|
#ifdef IPOD_NANO2G
|
||||||
unsigned int state = 0;
|
unsigned int state = 0;
|
||||||
|
#ifdef UC870X_DEBUG
|
||||||
|
const unsigned int max_states=3;
|
||||||
|
#else
|
||||||
const unsigned int max_states=2;
|
const unsigned int max_states=2;
|
||||||
|
#endif
|
||||||
int nand_bank_count;
|
int nand_bank_count;
|
||||||
struct storage_info info;
|
struct storage_info info;
|
||||||
const struct nand_device_info_type *nand_devicetype[4];
|
const struct nand_device_info_type *nand_devicetype[4];
|
||||||
|
@ -123,6 +131,37 @@ bool dbg_hw_info(void)
|
||||||
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
_DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
|
||||||
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
_DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
|
||||||
}
|
}
|
||||||
|
#ifdef UC870X_DEBUG
|
||||||
|
else if(state==2)
|
||||||
|
{
|
||||||
|
extern struct uartc_port ser_port;
|
||||||
|
int tx_stat, rx_stat, tx_speed, rx_speed;
|
||||||
|
char line_cfg[4];
|
||||||
|
int abr_stat;
|
||||||
|
uint32_t abr_cnt;
|
||||||
|
char *abrstatus[] = {"Idle", "Launched", "Counting", "Abnormal"};
|
||||||
|
|
||||||
|
uartc_port_get_line_info(&ser_port,
|
||||||
|
&tx_stat, &rx_stat, &tx_speed, &rx_speed, line_cfg);
|
||||||
|
abr_stat = uartc_port_get_abr_info(&ser_port, &abr_cnt);
|
||||||
|
|
||||||
|
_DEBUG_PRINTF("UART %d:", ser_port.id);
|
||||||
|
line++;
|
||||||
|
_DEBUG_PRINTF("line: %s", line_cfg);
|
||||||
|
_DEBUG_PRINTF("Tx: %s, speed: %d", tx_stat ? "On":"Off", tx_speed);
|
||||||
|
_DEBUG_PRINTF("Rx: %s, speed: %d", rx_stat ? "On":"Off", rx_speed);
|
||||||
|
_DEBUG_PRINTF("ABR: %s, cnt: %u", abrstatus[abr_stat], abr_cnt);
|
||||||
|
line++;
|
||||||
|
_DEBUG_PRINTF("n_tx_bytes: %u", ser_port.n_tx_bytes);
|
||||||
|
_DEBUG_PRINTF("n_rx_bytes: %u", ser_port.n_rx_bytes);
|
||||||
|
_DEBUG_PRINTF("n_ovr_err: %u", ser_port.n_ovr_err);
|
||||||
|
_DEBUG_PRINTF("n_parity_err: %u", ser_port.n_parity_err);
|
||||||
|
_DEBUG_PRINTF("n_frame_err: %u", ser_port.n_frame_err);
|
||||||
|
_DEBUG_PRINTF("n_break_detect: %u", ser_port.n_break_detect);
|
||||||
|
_DEBUG_PRINTF("ABR n_abnormal: %u %u",
|
||||||
|
ser_port.n_abnormal0, ser_port.n_abnormal1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state=0;
|
state=0;
|
||||||
|
|
96
firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c
Normal file
96
firmware/target/arm/s5l8700/ipodnano2g/serial-nano2g.c
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||||
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||||
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||||
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||||
|
* \/ \/ \/ \/ \/
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2014 by Cástor Muñoz
|
||||||
|
*
|
||||||
|
* 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 <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "system.h"
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
|
#include "s5l8700.h"
|
||||||
|
#include "uc870x.h"
|
||||||
|
|
||||||
|
/* Define LOGF_ENABLE to enable logf output in this file */
|
||||||
|
#define LOGF_ENABLE
|
||||||
|
#include "logf.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* shall include serial HW configuracion for specific target */
|
||||||
|
#define NANO2G_UART_CLK_HZ 24000000 /* external OSC0 ??? */
|
||||||
|
|
||||||
|
/* This values below are valid with a UCLK of 24MHz */
|
||||||
|
#define BRDATA_9600 (155) /* 9615 */
|
||||||
|
#define BRDATA_19200 (77) /* 19231 */
|
||||||
|
#define BRDATA_28800 (51) /* 28846 */
|
||||||
|
#define BRDATA_38400 (38) /* 38462 */
|
||||||
|
#define BRDATA_57600 (25) /* 57692 */
|
||||||
|
#define BRDATA_115200 (12) /* 115385 */
|
||||||
|
|
||||||
|
|
||||||
|
extern const struct uartc s5l8701_uartc0;
|
||||||
|
|
||||||
|
struct uartc_port ser_port IDATA_ATTR =
|
||||||
|
{
|
||||||
|
/* location */
|
||||||
|
.uartc = &s5l8701_uartc0,
|
||||||
|
.id = 0,
|
||||||
|
|
||||||
|
/* configuration */
|
||||||
|
.rx_trg = UFCON_RX_FIFO_TRG_4,
|
||||||
|
.tx_trg = UFCON_TX_FIFO_TRG_EMPTY,
|
||||||
|
.clksel = UCON_CLKSEL_ECLK,
|
||||||
|
.clkhz = NANO2G_UART_CLK_HZ,
|
||||||
|
|
||||||
|
/* interrupt callbacks */
|
||||||
|
.rx_cb = NULL,
|
||||||
|
.tx_cb = NULL, /* polling */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* serial driver API
|
||||||
|
*/
|
||||||
|
void serial_setup(void)
|
||||||
|
{
|
||||||
|
uartc_port_open(&ser_port);
|
||||||
|
|
||||||
|
/* set a default configuration, Tx and Rx modes are
|
||||||
|
disabled when the port is initialized */
|
||||||
|
uartc_port_config(&ser_port, ULCON_DATA_BITS_8,
|
||||||
|
ULCON_PARITY_NONE, ULCON_STOP_BITS_1);
|
||||||
|
uartc_port_set_bitrate_raw(&ser_port, BRDATA_115200);
|
||||||
|
|
||||||
|
/* enable Tx interrupt request or POLLING mode */
|
||||||
|
uartc_port_set_tx_mode(&ser_port, UCON_MODE_INTREQ);
|
||||||
|
|
||||||
|
logf("[%lu] "MODEL_NAME" port %d ready!",
|
||||||
|
(uint32_t)USEC_TIMER, ser_port.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int tx_rdy(void)
|
||||||
|
{
|
||||||
|
return uartc_port_tx_ready(&ser_port) ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tx_writec(unsigned char c)
|
||||||
|
{
|
||||||
|
uartc_port_tx_byte(&ser_port, c);
|
||||||
|
}
|
Loading…
Reference in a new issue