zynq: serial: Simplify serial driver initialization
Define both serial uarts in the driver and return default uart based on board configuration. - Move baseaddresses to hardware.h - Define default baudrate and clock values Signed-off-by: Michal Simek <michal.simek@xilinx.com>
This commit is contained in:
parent
627981213a
commit
bf83495040
@ -7,6 +7,8 @@
|
||||
#ifndef _ASM_ARCH_HARDWARE_H
|
||||
#define _ASM_ARCH_HARDWARE_H
|
||||
|
||||
#define ZYNQ_SERIAL_BASEADDR0 0xE0000000
|
||||
#define ZYNQ_SERIAL_BASEADDR1 0xE0001000
|
||||
#define ZYNQ_SYS_CTRL_BASEADDR 0xF8000000
|
||||
#define ZYNQ_DEV_CFG_APB_BASEADDR 0xF8007000
|
||||
#define ZYNQ_SCU_BASEADDR 0xF8F00000
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <asm/io.h>
|
||||
#include <linux/compiler.h>
|
||||
#include <serial.h>
|
||||
#include <asm/arch/hardware.h>
|
||||
|
||||
#define ZYNQ_UART_SR_TXFULL 0x00000010 /* TX FIFO full */
|
||||
#define ZYNQ_UART_SR_RXEMPTY 0x00000002 /* RX FIFO empty */
|
||||
@ -33,28 +34,34 @@ struct uart_zynq {
|
||||
};
|
||||
|
||||
static struct uart_zynq *uart_zynq_ports[2] = {
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_BASEADDR0
|
||||
[0] = (struct uart_zynq *)CONFIG_ZYNQ_SERIAL_BASEADDR0,
|
||||
#endif
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_BASEADDR1
|
||||
[1] = (struct uart_zynq *)CONFIG_ZYNQ_SERIAL_BASEADDR1,
|
||||
#endif
|
||||
[0] = (struct uart_zynq *)ZYNQ_SERIAL_BASEADDR0,
|
||||
[1] = (struct uart_zynq *)ZYNQ_SERIAL_BASEADDR1,
|
||||
};
|
||||
|
||||
#if !defined(CONFIG_ZYNQ_SERIAL_BAUDRATE0)
|
||||
# define CONFIG_ZYNQ_SERIAL_BAUDRATE0 CONFIG_BAUDRATE
|
||||
#endif
|
||||
#if !defined(CONFIG_ZYNQ_SERIAL_BAUDRATE1)
|
||||
# define CONFIG_ZYNQ_SERIAL_BAUDRATE1 CONFIG_BAUDRATE
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_ZYNQ_SERIAL_CLOCK0)
|
||||
# define CONFIG_ZYNQ_SERIAL_CLOCK0 50000000
|
||||
#endif
|
||||
#if !defined(CONFIG_ZYNQ_SERIAL_CLOCK1)
|
||||
# define CONFIG_ZYNQ_SERIAL_CLOCK1 50000000
|
||||
#endif
|
||||
|
||||
struct uart_zynq_params {
|
||||
u32 baudrate;
|
||||
u32 clock;
|
||||
};
|
||||
|
||||
static struct uart_zynq_params uart_zynq_ports_param[2] = {
|
||||
#if defined(CONFIG_ZYNQ_SERIAL_BAUDRATE0) && defined(CONFIG_ZYNQ_SERIAL_CLOCK0)
|
||||
[0].baudrate = CONFIG_ZYNQ_SERIAL_BAUDRATE0,
|
||||
[0].clock = CONFIG_ZYNQ_SERIAL_CLOCK0,
|
||||
#endif
|
||||
#if defined(CONFIG_ZYNQ_SERIAL_BAUDRATE1) && defined(CONFIG_ZYNQ_SERIAL_CLOCK1)
|
||||
[1].baudrate = CONFIG_ZYNQ_SERIAL_BAUDRATE1,
|
||||
[1].clock = CONFIG_ZYNQ_SERIAL_CLOCK1,
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Set up the baud rate in gd struct */
|
||||
@ -186,20 +193,19 @@ struct serial_device uart_zynq_serial1_device =
|
||||
|
||||
__weak struct serial_device *default_serial_console(void)
|
||||
{
|
||||
#if defined(CONFIG_ZYNQ_SERIAL_UART0)
|
||||
if (uart_zynq_ports[0])
|
||||
return &uart_zynq_serial0_device;
|
||||
#endif
|
||||
#if defined(CONFIG_ZYNQ_SERIAL_UART1)
|
||||
if (uart_zynq_ports[1])
|
||||
return &uart_zynq_serial1_device;
|
||||
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void zynq_serial_initalize(void)
|
||||
{
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_BASEADDR0
|
||||
serial_register(&uart_zynq_serial0_device);
|
||||
#endif
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_BASEADDR1
|
||||
serial_register(&uart_zynq_serial1_device);
|
||||
#endif
|
||||
}
|
||||
|
@ -35,27 +35,12 @@
|
||||
#define CONFIG_SYS_BAUDRATE_TABLE \
|
||||
{300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
|
||||
|
||||
/* Zynq Serial driver */
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_UART0
|
||||
# define CONFIG_ZYNQ_SERIAL_BASEADDR0 0xE0000000
|
||||
# define CONFIG_ZYNQ_SERIAL_BAUDRATE0 CONFIG_BAUDRATE
|
||||
# define CONFIG_ZYNQ_SERIAL_CLOCK0 50000000
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ZYNQ_SERIAL_UART1
|
||||
# define CONFIG_ZYNQ_SERIAL_BASEADDR1 0xE0001000
|
||||
# define CONFIG_ZYNQ_SERIAL_BAUDRATE1 CONFIG_BAUDRATE
|
||||
# define CONFIG_ZYNQ_SERIAL_CLOCK1 50000000
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_ZYNQ_SERIAL_UART0) || defined(CONFIG_ZYNQ_SERIAL_UART1)
|
||||
# define CONFIG_ZYNQ_SERIAL
|
||||
#endif
|
||||
|
||||
/* DCC driver */
|
||||
#if defined(CONFIG_ZYNQ_DCC)
|
||||
# define CONFIG_ARM_DCC
|
||||
# define CONFIG_CPU_V6 /* Required by CONFIG_ARM_DCC */
|
||||
#else
|
||||
# define CONFIG_ZYNQ_SERIAL
|
||||
#endif
|
||||
|
||||
/* Ethernet driver */
|
||||
|
Loading…
Reference in New Issue
Block a user