]> rtime.felk.cvut.cz Git - rtems-devel.git/blob - rtems-patches/current/0004-rtems-m9328-pimx1-uart1to3.patch
Add set of patches for RTEMS 4.11 release.
[rtems-devel.git] / rtems-patches / current / 0004-rtems-m9328-pimx1-uart1to3.patch
1 From 0755f39962e25fe1924633716a59027971c8fc67 Mon Sep 17 00:00:00 2001
2 Message-Id: <0755f39962e25fe1924633716a59027971c8fc67.1460800109.git.ppisa@pikron.com>
3 In-Reply-To: <fa0cd7f188055c9ee2daac4f933cfa023e369dea.1460800109.git.ppisa@pikron.com>
4 References: <fa0cd7f188055c9ee2daac4f933cfa023e369dea.1460800109.git.ppisa@pikron.com>
5 From: ppisa <ppisa@pikron.com>
6 Date: Sun, 9 Nov 2008 11:03:17 +0100
7 Subject: [PATCH 4/4] rtems-m9328-pimx1-uart1to3
8 To: rtems-devel@rtems.org
9
10 ---
11  c/src/lib/libbsp/arm/csb336/console/uart.c         | 49 ++++++++++++++++++++++
12  c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h | 41 ++++++++++++++++++
13  2 files changed, 90 insertions(+)
14
15 diff --git a/c/src/lib/libbsp/arm/csb336/console/uart.c b/c/src/lib/libbsp/arm/csb336/console/uart.c
16 index 841a00c..540f1b9 100644
17 --- a/c/src/lib/libbsp/arm/csb336/console/uart.c
18 +++ b/c/src/lib/libbsp/arm/csb336/console/uart.c
19 @@ -22,6 +22,13 @@
20  /* Define this to use interrupt driver UART driver */
21  #define USE_INTERRUPTS 1
22  
23 +/* Define this to use interrupt driver UART driver */
24 +#define WITH_IRDA_UART1TO3 1
25 +
26 +#ifdef WITH_IRDA_UART1TO3
27 +int bsp_uart1_switched_to_3 = 0;
28 +#endif /*WITH_IRDA_UART1TO3*/
29 +
30  /* How many serial ports? */
31  #define NUM_DEVS       2
32  #define poll_write(c)  imx_uart_poll_write_char(0, c)
33 @@ -181,6 +188,38 @@ static void imx_uart_init(int minor)
34      imx_uart_data[minor].len   = 0;
35      imx_uart_data[minor].idx   = 0;
36  
37 +#ifdef WITH_IRDA_UART1TO3
38 +    if (minor == 0) {
39 +        if((MC9328MXL_GPIOC_SSR & (1<<9))==0)
40 +            bsp_uart1_switched_to_3 = 1;
41 +    }
42 +
43 +    if ((minor == 0) && bsp_uart1_switched_to_3)  {
44 +        /* GPIO port C */
45 +        rtems_interrupt_level flags;
46 +        unsigned long mask;
47 +        unsigned long iconfa2_clr;
48 +        unsigned long ocr2_set;
49 +        unsigned long ocr2_clr;
50 +        unsigned long ddir_set;
51 +        mask = (1<<31) | (1<<30);        /* RxD and TxD */
52 +        ddir_set = (1<<30);
53 +        iconfa2_clr = (1<<31) | (1<<30);
54 +        ocr2_set = (1<<28);
55 +        ocr2_clr =(1<<29);
56 +        rtems_interrupt_disable(flags);
57 +        MC9328MXL_GPIOC_ICONFA2 &=~ iconfa2_clr;
58 +        MC9328MXL_GPIOC_OCR2 |=  ocr2_set;
59 +        MC9328MXL_GPIOC_OCR2 &=~ ocr2_clr;
60 +        MC9328MXL_GPIOC_GIUS |= mask ;        /* GIUS_C */
61 +        MC9328MXL_GPIOC_DDIR |= ddir_set;
62 +        MC9328MXL_PLL_GCCR |= MC9328MXL_PLL_GCCR_UART3_CLK_EN;
63 +        rtems_interrupt_enable(flags);
64 +
65 +        imx_uart_data[minor].regs =
66 +            (mc9328mxl_uart_regs_t *) MC9328MXL_UART3_BASE;
67 +    } else
68 +#endif /*WITH_IRDA_UART1TO3*/
69      if (minor == 0) {
70          imx_uart_data[minor].regs =
71              (mc9328mxl_uart_regs_t *) MC9328MXL_UART1_BASE;
72 @@ -374,6 +413,11 @@ static void imx_uart_tx_isr(void * param)
73  
74  static rtems_vector_number imx_uart_name_transmit(int minor)
75  {
76 +#ifdef WITH_IRDA_UART1TO3
77 +    if ((minor == 0) && bsp_uart1_switched_to_3) {
78 +        return BSP_INT_UART3_TX;
79 +    } else
80 +#endif /*WITH_IRDA_UART1TO3*/
81      if (minor == 0) {
82          return BSP_INT_UART1_TX;
83      } else if (minor == 1) {
84 @@ -385,6 +429,11 @@ static rtems_vector_number imx_uart_name_transmit(int minor)
85  
86  static rtems_vector_number imx_uart_name_receive(int minor)
87  {
88 +#ifdef WITH_IRDA_UART1TO3
89 +    if ((minor == 0) && bsp_uart1_switched_to_3) {
90 +        return BSP_INT_UART3_RX;
91 +    } else
92 +#endif /*WITH_IRDA_UART1TO3*/
93      if (minor == 0) {
94          return BSP_INT_UART1_RX;
95      } else if (minor == 1) {
96 diff --git a/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h b/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h
97 index dd05162..098caf3 100644
98 --- a/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h
99 +++ b/c/src/lib/libcpu/arm/mc9328mxl/include/mc9328mxl.h
100 @@ -28,6 +28,7 @@
101  #define MC9328MXL_LCDC_BASE     0x00205000
102  #define MC9328MXL_UART1_BASE    0x00206000
103  #define MC9328MXL_UART2_BASE    0x00207000
104 +#define MC9328MXL_UART3_BASE    0x0020A000
105  #define MC9328MXL_PWM_BASE      0x00208000
106  #define MC9328MXL_DMAC_BASE     0x00209000
107  #define MC9328MXL_USBD_BASE     0x00212000
108 @@ -128,6 +129,30 @@
109  #define MC9328MXL_UART2_MPR4  (*((volatile uint32_t *)((MC9328MXL_UART2_BASE) + 0xcc)))
110  #define MC9328MXL_UART2_TS    (*((volatile uint32_t *)((MC9328MXL_UART2_BASE) + 0xd0)))
111  
112 +#define MC9328MXL_UART3_RXD   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x00)))
113 +#define MC9328MXL_UART3_TXD   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x40)))
114 +#define MC9328MXL_UART3_CR1   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x80)))
115 +#define MC9328MXL_UART3_CR2   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x84)))
116 +#define MC9328MXL_UART3_CR3   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x88)))
117 +#define MC9328MXL_UART3_CR4   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x8c)))
118 +#define MC9328MXL_UART3_FCR   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x90)))
119 +#define MC9328MXL_UART3_SR1   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x94)))
120 +#define MC9328MXL_UART3_SR2   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x98)))
121 +#define MC9328MXL_UART3_ESC   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0x9c)))
122 +#define MC9328MXL_UART3_TIM   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xa0)))
123 +#define MC9328MXL_UART3_BIR   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xa4)))
124 +#define MC9328MXL_UART3_BMR   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xa8)))
125 +#define MC9328MXL_UART3_BRC   (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xac)))
126 +#define MC9328MXL_UART3_IPR1  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xb0)))
127 +#define MC9328MXL_UART3_IPR2  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xb4)))
128 +#define MC9328MXL_UART3_IPR3  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xb8)))
129 +#define MC9328MXL_UART3_IPR4  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xbc)))
130 +#define MC9328MXL_UART3_MPR1  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xc0)))
131 +#define MC9328MXL_UART3_MPR2  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xc4)))
132 +#define MC9328MXL_UART3_MPR3  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xc8)))
133 +#define MC9328MXL_UART3_MPR4  (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xcc)))
134 +#define MC9328MXL_UART3_TS    (*((volatile uint32_t *)((MC9328MXL_UART3_BASE) + 0xd0)))
135 +
136  typedef struct {
137      volatile uint32_t rxd;
138      volatile uint32_t _res0[15];
139 @@ -271,6 +296,12 @@ typedef struct {
140  #define MC9328MXL_PLL_SPCTL1 (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x10)))
141  #define MC9328MXL_PLL_PCDR   (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x20)))
142  
143 +#define MC9328MXL_PLL_RSR    (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x800)))
144 +#define MC9328MXL_PLL_SIDR   (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x804)))
145 +#define MC9328MXL_PLL_FMCR   (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x808)))
146 +#define MC9328MXL_PLL_GPCR   (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x80C)))
147 +#define MC9328MXL_PLL_GCCR   (*((volatile uint32_t *)((MC9328MXL_PLL_BASE) + 0x810)))
148 +
149  #define MC9328MXL_PLL_CSCR_CLKOSEL_PERCLK1 (0 << 29)
150  #define MC9328MXL_PLL_CSCR_CLKOSEL_HCLK    (1 << 29)
151  #define MC9328MXL_PLL_CSCR_CLKOSEL_CLK48M  (2 << 29)
152 @@ -301,6 +332,16 @@ typedef struct {
153  #define MC9328MXL_PLL_PCDR_PCLK3_MASK      (0x007f0000)
154  #define MC9328MXL_PLL_PCDR_PCLK3_SHIFT     (16)
155  
156 +#define MC9328MXL_PLL_RSR_WDR              (bit(1))
157 +#define MC9328MXL_PLL_RSR_EXR              (bit(0))
158 +
159 +#define MC9328MXL_PLL_GCCR_UART3_CLK_EN    (bit(6))
160 +#define MC9328MXL_PLL_GCCR_SSI2_CLK_EN     (bit(5))
161 +#define MC9328MXL_PLL_GCCR_BROM_CLK_EN     (bit(4))
162 +#define MC9328MXL_PLL_GCCR_DMA_CLK_EN      (bit(3))
163 +#define MC9328MXL_PLL_GCCR_CSI_CLK_EN      (bit(2))
164 +#define MC9328MXL_PLL_GCCR_MMA_CLK_EN      (bit(1))
165 +#define MC9328MXL_PLL_GCCR_USBD_CLK_EN     (bit(0))
166  
167  #define MC9328MXL_PLL_SPCTL_PD_MASK        (0x3c000000)
168  #define MC9328MXL_PLL_SPCTL_PD_SHIFT       (26)
169 -- 
170 1.9.1
171