From ac0bb050ddef753741ff9e05932aad1b6c43ed22 Mon Sep 17 00:00:00 2001 From: Kumar Gala Date: Fri, 28 Apr 2017 11:34:06 -0500 Subject: arm: dts: ti_lm3s6965: Add device tree support for Stellaris UART Converted Stellaris UART driver over to utilize device tree generated defines. Added a yaml description for the uart, and converted over the ti_lm3s6965 SoC & qemu_cortex_m3 board port over to utilize it. Change-Id: Ie20844eb63d2c68eb59ad4160f7f5b5a35e2943b Signed-off-by: Kumar Gala --- arch/arm/soc/ti_lm3s6965/Kconfig.defconfig | 20 ------------- arch/arm/soc/ti_lm3s6965/soc.h | 12 -------- drivers/serial/Kconfig.stellaris | 48 ------------------------------ drivers/serial/uart_stellaris.c | 30 +++++++++---------- dts/arm/qemu_cortex_m3.dts | 21 +++++++++++++ dts/arm/ti/lm3s6965.dtsi | 20 +++++++++++++ dts/arm/yaml/ti,stellaris-uart.yaml | 30 +++++++++++++++++++ 7 files changed, 86 insertions(+), 95 deletions(-) create mode 100644 dts/arm/yaml/ti,stellaris-uart.yaml diff --git a/arch/arm/soc/ti_lm3s6965/Kconfig.defconfig b/arch/arm/soc/ti_lm3s6965/Kconfig.defconfig index 9c3adf300..0ccddbcce 100644 --- a/arch/arm/soc/ti_lm3s6965/Kconfig.defconfig +++ b/arch/arm/soc/ti_lm3s6965/Kconfig.defconfig @@ -26,31 +26,11 @@ if UART_STELLARIS config UART_STELLARIS_PORT_0 def_bool y -if UART_STELLARIS_PORT_0 -config UART_STELLARIS_PORT_0_IRQ_PRI - default 3 -config UART_STELLARIS_PORT_0_BAUD_RATE - default 115200 -endif - config UART_STELLARIS_PORT_1 def_bool y -if UART_STELLARIS_PORT_1 -config UART_STELLARIS_PORT_1_IRQ_PRI - default 3 -config UART_STELLARIS_PORT_1_BAUD_RATE - default 115200 -endif - config UART_STELLARIS_PORT_2 def_bool y -if UART_STELLARIS_PORT_2 -config UART_STELLARIS_PORT_2_IRQ_PRI - default 3 -config UART_STELLARIS_PORT_2_BAUD_RATE - default 115200 -endif endif # UART_STELLARIS diff --git a/arch/arm/soc/ti_lm3s6965/soc.h b/arch/arm/soc/ti_lm3s6965/soc.h index 6ae548ca6..56509edf2 100644 --- a/arch/arm/soc/ti_lm3s6965/soc.h +++ b/arch/arm/soc/ti_lm3s6965/soc.h @@ -32,8 +32,6 @@ extern "C" { #define IRQ_GPIO_PORTC 2 #define IRQ_GPIO_PORTD 3 #define IRQ_GPIO_PORTE 4 -#define IRQ_UART0 5 -#define IRQ_UART1 6 #define IRQ_SSI0 7 #define IRQ_I2C0 8 #define IRQ_PWM_FAULT 9 @@ -60,7 +58,6 @@ extern "C" { #define IRQ_GPIO_PORTF 30 #define IRQ_GPIO_PORTG 31 #define IRQ_RESERVED1 32 -#define IRQ_UART2 33 #define IRQ_RESERVED2 34 #define IRQ_TIMER3A 35 #define IRQ_TIMER3B 36 @@ -83,15 +80,6 @@ extern "C" { #define UART_IRQ_FLAGS 0 -#define UART_STELLARIS_PORT_0_BASE_ADDR 0x4000C000 -#define UART_STELLARIS_PORT_0_IRQ IRQ_UART0 - -#define UART_STELLARIS_PORT_1_BASE_ADDR 0x4000D000 -#define UART_STELLARIS_PORT_1_IRQ IRQ_UART1 - -#define UART_STELLARIS_PORT_2_BASE_ADDR 0x4000E000 -#define UART_STELLARIS_PORT_2_IRQ IRQ_UART2 - #define UART_STELLARIS_CLK_FREQ SYSCLK_DEFAULT_IOSC_HZ #endif /* CONFIG_UART_STELLARIS */ diff --git a/drivers/serial/Kconfig.stellaris b/drivers/serial/Kconfig.stellaris index ad4cd123a..587811ff9 100644 --- a/drivers/serial/Kconfig.stellaris +++ b/drivers/serial/Kconfig.stellaris @@ -25,22 +25,6 @@ config UART_STELLARIS_PORT_0_NAME This is the device name for UART, and is included in the device struct. -config UART_STELLARIS_PORT_0_IRQ_PRI - int "Port 0 Interrupt Priority" - default 0 - depends on UART_STELLARIS_PORT_0 - help - The interrupt priority for UART port. - -config UART_STELLARIS_PORT_0_BAUD_RATE - int "Port 0 Baud Rate" - default 0 - depends on UART_STELLARIS_PORT_0 - help - The baud rate for UART port to be set to at boot. - - Leave at 0 to skip initialization. - # ---------- Port 1 ---------- menuconfig UART_STELLARIS_PORT_1 @@ -59,22 +43,6 @@ config UART_STELLARIS_PORT_1_NAME This is the device name for UART, and is included in the device struct. -config UART_STELLARIS_PORT_1_IRQ_PRI - int "Port 1 Interrupt Priority" - default 0 - depends on UART_STELLARIS_PORT_1 - help - The interrupt priority for UART port. - -config UART_STELLARIS_PORT_1_BAUD_RATE - int "Port 1 Baud Rate" - default 0 - depends on UART_STELLARIS_PORT_1 - help - The baud rate for UART port to be set to at boot. - - Leave at 0 to skip initialization. - # ---------- Port 2 ---------- menuconfig UART_STELLARIS_PORT_2 @@ -92,19 +60,3 @@ config UART_STELLARIS_PORT_2_NAME help This is the device name for UART, and is included in the device struct. - -config UART_STELLARIS_PORT_2_IRQ_PRI - int "Port 2 Interrupt Priority" - default 0 - depends on UART_STELLARIS_PORT_2 - help - The interrupt priority for UART port. - -config UART_STELLARIS_PORT_2_BAUD_RATE - int "Port 2 Baud Rate" - default 0 - depends on UART_STELLARIS_PORT_2 - help - The baud rate for UART port to be set to at boot. - - Leave at 0 to skip initialization. diff --git a/drivers/serial/uart_stellaris.c b/drivers/serial/uart_stellaris.c index c34dbe90e..a95a87a25 100644 --- a/drivers/serial/uart_stellaris.c +++ b/drivers/serial/uart_stellaris.c @@ -630,7 +630,7 @@ static void irq_config_func_0(struct device *port); #endif static const struct uart_device_config uart_stellaris_dev_cfg_0 = { - .base = (u8_t *)UART_STELLARIS_PORT_0_BASE_ADDR, + .base = (u8_t *)TI_STELLARIS_UART_4000C000_BASE_ADDRESS, .sys_clk_freq = UART_STELLARIS_CLK_FREQ, #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -639,7 +639,7 @@ static const struct uart_device_config uart_stellaris_dev_cfg_0 = { }; static struct uart_stellaris_dev_data_t uart_stellaris_dev_data_0 = { - .baud_rate = CONFIG_UART_STELLARIS_PORT_0_BAUD_RATE, + .baud_rate = TI_STELLARIS_UART_4000C000_CURRENT_SPEED, }; DEVICE_AND_API_INIT(uart_stellaris0, CONFIG_UART_STELLARIS_PORT_0_NAME, &uart_stellaris_init, @@ -650,11 +650,11 @@ DEVICE_AND_API_INIT(uart_stellaris0, CONFIG_UART_STELLARIS_PORT_0_NAME, &uart_st #ifdef CONFIG_UART_INTERRUPT_DRIVEN static void irq_config_func_0(struct device *dev) { - IRQ_CONNECT(UART_STELLARIS_PORT_0_IRQ, - CONFIG_UART_STELLARIS_PORT_0_IRQ_PRI, + IRQ_CONNECT(TI_STELLARIS_UART_4000C000_IRQ_0, + TI_STELLARIS_UART_4000C000_IRQ_0_PRIORITY, uart_stellaris_isr, DEVICE_GET(uart_stellaris0), UART_IRQ_FLAGS); - irq_enable(UART_STELLARIS_PORT_0_IRQ); + irq_enable(TI_STELLARIS_UART_4000C000_IRQ_0); } #endif @@ -667,7 +667,7 @@ static void irq_config_func_1(struct device *port); #endif static struct uart_device_config uart_stellaris_dev_cfg_1 = { - .base = (u8_t *)UART_STELLARIS_PORT_1_BASE_ADDR, + .base = (u8_t *)TI_STELLARIS_UART_4000D000_BASE_ADDRESS, .sys_clk_freq = UART_STELLARIS_CLK_FREQ, #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -676,7 +676,7 @@ static struct uart_device_config uart_stellaris_dev_cfg_1 = { }; static struct uart_stellaris_dev_data_t uart_stellaris_dev_data_1 = { - .baud_rate = CONFIG_UART_STELLARIS_PORT_1_BAUD_RATE, + .baud_rate = TI_STELLARIS_UART_4000D000_CURRENT_SPEED, }; DEVICE_AND_API_INIT(uart_stellaris1, CONFIG_UART_STELLARIS_PORT_1_NAME, &uart_stellaris_init, @@ -687,11 +687,11 @@ DEVICE_AND_API_INIT(uart_stellaris1, CONFIG_UART_STELLARIS_PORT_1_NAME, &uart_st #ifdef CONFIG_UART_INTERRUPT_DRIVEN static void irq_config_func_1(struct device *dev) { - IRQ_CONNECT(UART_STELLARIS_PORT_1_IRQ, - CONFIG_UART_STELLARIS_PORT_1_IRQ_PRI, + IRQ_CONNECT(TI_STELLARIS_UART_4000D000_IRQ_0, + TI_STELLARIS_UART_4000D000_IRQ_0_PRIORITY, uart_stellaris_isr, DEVICE_GET(uart_stellaris1), UART_IRQ_FLAGS); - irq_enable(UART_STELLARIS_PORT_1_IRQ); + irq_enable(TI_STELLARIS_UART_4000D000_IRQ_0); } #endif @@ -704,7 +704,7 @@ static void irq_config_func_2(struct device *port); #endif static const struct uart_device_config uart_stellaris_dev_cfg_2 = { - .base = (u8_t *)UART_STELLARIS_PORT_2_BASE_ADDR, + .base = (u8_t *)TI_STELLARIS_UART_4000E000_BASE_ADDRESS, .sys_clk_freq = UART_STELLARIS_CLK_FREQ, #ifdef CONFIG_UART_INTERRUPT_DRIVEN @@ -713,7 +713,7 @@ static const struct uart_device_config uart_stellaris_dev_cfg_2 = { }; static struct uart_stellaris_dev_data_t uart_stellaris_dev_data_2 = { - .baud_rate = CONFIG_UART_STELLARIS_PORT_2_BAUD_RATE, + .baud_rate = TI_STELLARIS_UART_4000E000_CURRENT_SPEED, }; DEVICE_AND_API_INIT(uart_stellaris2, CONFIG_UART_STELLARIS_PORT_2_NAME, &uart_stellaris_init, @@ -724,11 +724,11 @@ DEVICE_AND_API_INIT(uart_stellaris2, CONFIG_UART_STELLARIS_PORT_2_NAME, &uart_st #ifdef CONFIG_UART_INTERRUPT_DRIVEN static void irq_config_func_2(struct device *dev) { - IRQ_CONNECT(UART_STELLARIS_PORT_2_IRQ, - CONFIG_UART_STELLARIS_PORT_2_IRQ_PRI, + IRQ_CONNECT(TI_STELLARIS_UART_4000E000_IRQ_0, + TI_STELLARIS_UART_4000E000_IRQ_0_PRIORITY, uart_stellaris_isr, DEVICE_GET(uart_stellaris2), UART_IRQ_FLAGS); - irq_enable(UART_STELLARIS_PORT_2_IRQ); + irq_enable(TI_STELLARIS_UART_4000E000_IRQ_0); } #endif diff --git a/dts/arm/qemu_cortex_m3.dts b/dts/arm/qemu_cortex_m3.dts index cc7b45cf3..ad2cb626a 100644 --- a/dts/arm/qemu_cortex_m3.dts +++ b/dts/arm/qemu_cortex_m3.dts @@ -6,8 +6,29 @@ model = "QEMU Cortex-M3"; compatible = "ti,lm3s6965evb-qemu", "ti,lm3s6965"; + aliases { + uart_0 = &uart0; + uart_1 = &uart1; + uart_2 = &uart2; + }; + chosen { zephyr,sram = &sram0; zephyr,flash = &flash0; }; }; + +&uart0 { + status = "ok"; + current-speed = <115200>; +}; + +&uart1 { + status = "ok"; + current-speed = <115200>; +}; + +&uart2 { + status = "ok"; + current-speed = <115200>; +}; diff --git a/dts/arm/ti/lm3s6965.dtsi b/dts/arm/ti/lm3s6965.dtsi index 308694cb8..007c6a26e 100644 --- a/dts/arm/ti/lm3s6965.dtsi +++ b/dts/arm/ti/lm3s6965.dtsi @@ -17,6 +17,26 @@ }; soc { + uart0: uart@4000C000 { + compatible = "ti,stellaris-uart"; + reg = <0x4000C000 0x4c>; + interrupts = <5 3>; + status = "disabled"; + }; + + uart1: uart@4000D000 { + compatible = "ti,stellaris-uart"; + reg = <0x4000D000 0x4c>; + interrupts = <6 3>; + status = "disabled"; + }; + + uart2: uart@4000E000 { + compatible = "ti,stellaris-uart"; + reg = <0x4000E000 0x4c>; + interrupts = <33 3>; + status = "disabled"; + }; }; }; diff --git a/dts/arm/yaml/ti,stellaris-uart.yaml b/dts/arm/yaml/ti,stellaris-uart.yaml new file mode 100644 index 000000000..281a908e8 --- /dev/null +++ b/dts/arm/yaml/ti,stellaris-uart.yaml @@ -0,0 +1,30 @@ +--- +title: TI Stellaris UART +id: ti,stellaris-uart +version: 0.1 + +description: > + This binding gives a base representation of the TI Stellaris UART + +inherits: + - !include uart.yaml + +properties: + - compatible: + type: string + category: required + description: compatible strings + constraint: "ti,stellaris-uart" + + - reg: + type: array + description: mmio register space + generation: define + category: required + + - interrupts: + type: array + category: required + description: required interrupts + generation: define +... -- cgit v1.2.3