[components][drivers] fix posix tty, and add more baudrate (#8683)
* serial-tty fix * v2
This commit is contained in:
parent
1ea7ddfa9a
commit
d856f77a55
@ -26,10 +26,16 @@
|
|||||||
#define BAUD_RATE_230400 230400
|
#define BAUD_RATE_230400 230400
|
||||||
#define BAUD_RATE_460800 460800
|
#define BAUD_RATE_460800 460800
|
||||||
#define BAUD_RATE_500000 500000
|
#define BAUD_RATE_500000 500000
|
||||||
|
#define BAUD_RATE_576000 576000
|
||||||
#define BAUD_RATE_921600 921600
|
#define BAUD_RATE_921600 921600
|
||||||
|
#define BAUD_RATE_1000000 1000000
|
||||||
|
#define BAUD_RATE_1152000 1152000
|
||||||
|
#define BAUD_RATE_1500000 1500000
|
||||||
#define BAUD_RATE_2000000 2000000
|
#define BAUD_RATE_2000000 2000000
|
||||||
#define BAUD_RATE_2500000 2500000
|
#define BAUD_RATE_2500000 2500000
|
||||||
#define BAUD_RATE_3000000 3000000
|
#define BAUD_RATE_3000000 3000000
|
||||||
|
#define BAUD_RATE_3500000 3500000
|
||||||
|
#define BAUD_RATE_4000000 4000000
|
||||||
|
|
||||||
#define DATA_BITS_5 5
|
#define DATA_BITS_5 5
|
||||||
#define DATA_BITS_6 6
|
#define DATA_BITS_6 6
|
||||||
|
@ -640,6 +640,11 @@ static rt_err_t rt_serial_open(struct rt_device *dev, rt_uint16_t oflag)
|
|||||||
/* get open flags */
|
/* get open flags */
|
||||||
dev->open_flag = oflag & 0xff;
|
dev->open_flag = oflag & 0xff;
|
||||||
|
|
||||||
|
#ifdef RT_USING_PINCTRL
|
||||||
|
/* initialize iomux in DM */
|
||||||
|
rt_pin_ctrl_confs_apply_by_name(dev, RT_NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* initialize the Rx/Tx structure according to open flag */
|
/* initialize the Rx/Tx structure according to open flag */
|
||||||
if (serial->serial_rx == RT_NULL)
|
if (serial->serial_rx == RT_NULL)
|
||||||
{
|
{
|
||||||
@ -909,7 +914,7 @@ static rt_ssize_t rt_serial_write(struct rt_device *dev,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_SMART)
|
#if defined(RT_USING_POSIX_TERMIOS)
|
||||||
struct speed_baudrate_item
|
struct speed_baudrate_item
|
||||||
{
|
{
|
||||||
speed_t speed;
|
speed_t speed;
|
||||||
@ -928,9 +933,16 @@ static const struct speed_baudrate_item _tbl[] =
|
|||||||
{B230400, BAUD_RATE_230400},
|
{B230400, BAUD_RATE_230400},
|
||||||
{B460800, BAUD_RATE_460800},
|
{B460800, BAUD_RATE_460800},
|
||||||
{B500000, BAUD_RATE_500000},
|
{B500000, BAUD_RATE_500000},
|
||||||
|
{B576000, BAUD_RATE_576000},
|
||||||
{B921600, BAUD_RATE_921600},
|
{B921600, BAUD_RATE_921600},
|
||||||
|
{B1000000, BAUD_RATE_1000000},
|
||||||
|
{B1152000, BAUD_RATE_1152000},
|
||||||
|
{B1500000, BAUD_RATE_1500000},
|
||||||
{B2000000, BAUD_RATE_2000000},
|
{B2000000, BAUD_RATE_2000000},
|
||||||
|
{B2500000, BAUD_RATE_2500000},
|
||||||
{B3000000, BAUD_RATE_3000000},
|
{B3000000, BAUD_RATE_3000000},
|
||||||
|
{B3500000, BAUD_RATE_3500000},
|
||||||
|
{B4000000, BAUD_RATE_4000000},
|
||||||
};
|
};
|
||||||
|
|
||||||
static speed_t _get_speed(int baudrate)
|
static speed_t _get_speed(int baudrate)
|
||||||
@ -1002,6 +1014,32 @@ static void _tc_flush(struct rt_serial_device *serial, int queue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int _termio_to_termios(const struct termio *termio,
|
||||||
|
struct termios *termios)
|
||||||
|
{
|
||||||
|
termios->c_iflag = termio->c_iflag;
|
||||||
|
termios->c_oflag = termio->c_oflag;
|
||||||
|
termios->c_cflag = termio->c_cflag;
|
||||||
|
termios->c_lflag = termio->c_lflag;
|
||||||
|
termios->c_line = termio->c_line;
|
||||||
|
rt_memcpy(termios->c_cc, termio->c_cc, NCC);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int _termios_to_termio(const struct termios *termios,
|
||||||
|
struct termio *termio)
|
||||||
|
{
|
||||||
|
termio->c_iflag = (unsigned short)termios->c_iflag;
|
||||||
|
termio->c_oflag = (unsigned short)termios->c_oflag;
|
||||||
|
termio->c_cflag = (unsigned short)termios->c_cflag;
|
||||||
|
termio->c_lflag = (unsigned short)termios->c_lflag;
|
||||||
|
termio->c_line = termios->c_line;
|
||||||
|
rt_memcpy(termio->c_cc, termios->c_cc, NCC);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* RT_USING_POSIX_TERMIOS */
|
#endif /* RT_USING_POSIX_TERMIOS */
|
||||||
|
|
||||||
static rt_err_t rt_serial_control(struct rt_device *dev,
|
static rt_err_t rt_serial_control(struct rt_device *dev,
|
||||||
@ -1058,10 +1096,21 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#ifdef RT_USING_POSIX_STDIO
|
#ifdef RT_USING_POSIX_STDIO
|
||||||
#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_SMART)
|
#if defined(RT_USING_POSIX_TERMIOS)
|
||||||
case TCGETA:
|
case TCGETA:
|
||||||
|
case TCGETS:
|
||||||
{
|
{
|
||||||
struct termios *tio = (struct termios*)args;
|
struct termios *tio, tmp;
|
||||||
|
|
||||||
|
if (cmd == TCGETS)
|
||||||
|
{
|
||||||
|
tio = (struct termios*)args;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tio = &tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (tio == RT_NULL) return -RT_EINVAL;
|
if (tio == RT_NULL) return -RT_EINVAL;
|
||||||
|
|
||||||
tio->c_iflag = 0;
|
tio->c_iflag = 0;
|
||||||
@ -1092,17 +1141,34 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
|||||||
tio->c_cflag |= (PARODD | PARENB);
|
tio->c_cflag |= (PARODD | PARENB);
|
||||||
|
|
||||||
cfsetospeed(tio, _get_speed(serial->config.baud_rate));
|
cfsetospeed(tio, _get_speed(serial->config.baud_rate));
|
||||||
|
|
||||||
|
if (cmd == TCGETA)
|
||||||
|
{
|
||||||
|
_termios_to_termio(tio, args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TCSETAW:
|
case TCSETAW:
|
||||||
case TCSETAF:
|
case TCSETAF:
|
||||||
case TCSETA:
|
case TCSETA:
|
||||||
|
case TCSETSW:
|
||||||
|
case TCSETSF:
|
||||||
|
case TCSETS:
|
||||||
{
|
{
|
||||||
int baudrate;
|
int baudrate;
|
||||||
struct serial_configure config;
|
struct serial_configure config;
|
||||||
|
struct termios *tio, tmp;
|
||||||
|
|
||||||
|
if ((cmd >= TCSETA) && (cmd <= TCSETA + 2))
|
||||||
|
{
|
||||||
|
_termio_to_termios(args, &tmp);
|
||||||
|
tio = &tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tio = (struct termios*)args;
|
||||||
|
}
|
||||||
|
|
||||||
struct termios *tio = (struct termios*)args;
|
|
||||||
if (tio == RT_NULL) return -RT_EINVAL;
|
if (tio == RT_NULL) return -RT_EINVAL;
|
||||||
|
|
||||||
config = serial->config;
|
config = serial->config;
|
||||||
@ -1139,6 +1205,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
|||||||
serial->ops->configure(serial, &config);
|
serial->ops->configure(serial, &config);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#ifndef RT_USING_TTY
|
||||||
case TCFLSH:
|
case TCFLSH:
|
||||||
{
|
{
|
||||||
int queue = (int)(rt_ubase_t)args;
|
int queue = (int)(rt_ubase_t)args;
|
||||||
@ -1149,6 +1216,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
|
|||||||
break;
|
break;
|
||||||
case TCXONC:
|
case TCXONC:
|
||||||
break;
|
break;
|
||||||
|
#endif /*RT_USING_TTY*/
|
||||||
#endif /*RT_USING_POSIX_TERMIOS*/
|
#endif /*RT_USING_POSIX_TERMIOS*/
|
||||||
case TIOCSWINSZ:
|
case TIOCSWINSZ:
|
||||||
{
|
{
|
||||||
|
@ -212,6 +212,15 @@ static int serial_tty_ioctl(struct lwp_tty *tp, rt_ubase_t cmd, rt_caddr_t data,
|
|||||||
int error;
|
int error;
|
||||||
switch (cmd)
|
switch (cmd)
|
||||||
{
|
{
|
||||||
|
case TCSETS:
|
||||||
|
case TCSETSW:
|
||||||
|
case TCSETSF:
|
||||||
|
RT_ASSERT(tp->t_devswsoftc);
|
||||||
|
struct serial_tty_context *softc = (struct serial_tty_context *)(tp->t_devswsoftc);
|
||||||
|
struct rt_serial_device *serial = softc->parent;
|
||||||
|
struct termios *termios = (struct termios *)data;
|
||||||
|
rt_device_control(&(serial->parent), cmd, termios);
|
||||||
|
error = -ENOIOCTL;
|
||||||
default:
|
default:
|
||||||
/**
|
/**
|
||||||
* Note: for the most case, we don't let serial layer handle ioctl,
|
* Note: for the most case, we don't let serial layer handle ioctl,
|
||||||
|
@ -12,7 +12,7 @@ if GetDepend('RT_USING_OFW') == False:
|
|||||||
SrcRemove(src, ['setup.c', 'cpu_psci.c', 'psci.c'])
|
SrcRemove(src, ['setup.c', 'cpu_psci.c', 'psci.c'])
|
||||||
|
|
||||||
if GetDepend('RT_USING_PIC') == True:
|
if GetDepend('RT_USING_PIC') == True:
|
||||||
SrcRemove(src, ['gicv3.c', 'gic.c', 'gtimer.c'])
|
SrcRemove(src, ['gicv3.c', 'gic.c', 'gtimer.c', 'interrupt.c'])
|
||||||
|
|
||||||
group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH)
|
group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
@ -19,6 +19,14 @@
|
|||||||
#include "asm-fpu.h"
|
#include "asm-fpu.h"
|
||||||
#include "armv8.h"
|
#include "armv8.h"
|
||||||
|
|
||||||
|
#ifndef RT_USING_SMP
|
||||||
|
.bss
|
||||||
|
.align 3
|
||||||
|
rt_interrupt_from_thread: .comm 8, 8
|
||||||
|
rt_interrupt_to_thread: .comm 8, 8
|
||||||
|
rt_thread_switch_interrupt_flag: .comm 8, 8
|
||||||
|
#endif
|
||||||
|
|
||||||
.text
|
.text
|
||||||
.weak rt_hw_cpu_id_set
|
.weak rt_hw_cpu_id_set
|
||||||
.type rt_hw_cpu_id_set, @function
|
.type rt_hw_cpu_id_set, @function
|
||||||
|
@ -16,15 +16,6 @@
|
|||||||
#include "gicv3.h"
|
#include "gicv3.h"
|
||||||
#include "ioremap.h"
|
#include "ioremap.h"
|
||||||
|
|
||||||
#ifndef RT_USING_SMP
|
|
||||||
/* Those variables will be accessed in ISR, so we need to share them. */
|
|
||||||
rt_ubase_t rt_interrupt_from_thread = 0;
|
|
||||||
rt_ubase_t rt_interrupt_to_thread = 0;
|
|
||||||
rt_ubase_t rt_thread_switch_interrupt_flag = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RT_USING_PIC
|
|
||||||
|
|
||||||
/* exception and interrupt handler table */
|
/* exception and interrupt handler table */
|
||||||
struct rt_irq_desc isr_table[MAX_HANDLERS];
|
struct rt_irq_desc isr_table[MAX_HANDLERS];
|
||||||
|
|
||||||
@ -87,9 +78,6 @@ void rt_hw_interrupt_init(void)
|
|||||||
|
|
||||||
/* init interrupt nest, and context in thread sp */
|
/* init interrupt nest, and context in thread sp */
|
||||||
rt_atomic_store(&rt_interrupt_nest, 0);
|
rt_atomic_store(&rt_interrupt_nest, 0);
|
||||||
rt_interrupt_from_thread = 0;
|
|
||||||
rt_interrupt_to_thread = 0;
|
|
||||||
rt_thread_switch_interrupt_flag = 0;
|
|
||||||
#else
|
#else
|
||||||
rt_uint64_t gic_cpu_base;
|
rt_uint64_t gic_cpu_base;
|
||||||
rt_uint64_t gic_dist_base;
|
rt_uint64_t gic_dist_base;
|
||||||
@ -417,8 +405,6 @@ void rt_hw_ipi_handler_install(int ipi_vector, rt_isr_handler_t ipi_isr_handler)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* RT_USING_PIC */
|
|
||||||
|
|
||||||
#if defined(FINSH_USING_MSH) && defined(RT_USING_INTERRUPT_INFO)
|
#if defined(FINSH_USING_MSH) && defined(RT_USING_INTERRUPT_INFO)
|
||||||
int list_isr()
|
int list_isr()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user