summaryrefslogtreecommitdiff
path: root/firmware/target/arm/s5l8700/uart-s5l8700.c
diff options
context:
space:
mode:
authorCástor Muñoz <cmvidal@gmail.com>2016-05-12 02:14:48 +0200
committerCástor Muñoz <cmvidal@gmail.com>2016-05-13 23:23:01 +0200
commit5017523a6b1ea9d230d8b8cf801ad3adbe7f43f5 (patch)
treedb521d53b171dde30f8b083177bb3c322cd43cf6 /firmware/target/arm/s5l8700/uart-s5l8700.c
parent8fb67f48ab57770c3233352de17846a8a773192a (diff)
downloadrockbox-5017523a6b1ea9d230d8b8cf801ad3adbe7f43f5.tar.gz
rockbox-5017523a6b1ea9d230d8b8cf801ad3adbe7f43f5.zip
Add UART suuport for s5l8700 and s5l8701
Add UART support for s5l8700/1 using the UC870X UART controller, actually the functionallity is disabled and must be enabled for each individual target. Tested on iPod Nano 2G (s5l8701), not tested on s5l8700. Change-Id: Ic0f216bb871502d355a70e4b658e536a2c0976a9
Diffstat (limited to 'firmware/target/arm/s5l8700/uart-s5l8700.c')
-rw-r--r--firmware/target/arm/s5l8700/uart-s5l8700.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/firmware/target/arm/s5l8700/uart-s5l8700.c b/firmware/target/arm/s5l8700/uart-s5l8700.c
new file mode 100644
index 0000000000..80207e94df
--- /dev/null
+++ b/firmware/target/arm/s5l8700/uart-s5l8700.c
@@ -0,0 +1,129 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 by Cástor Muñoz
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include <stdint.h>
22#include <stdbool.h>
23
24#include "config.h"
25#include "system.h"
26
27#include "s5l8700.h"
28#include "uc870x.h"
29
30
31/*
32 * XXX: This code is based on datasheets and NEVER TESTED !!!
33 */
34
35
36/*
37 * s5l8700 UC870X HW: 1 UARTC, 2 ports
38 */
39static struct uartc_port *uartc_port_l[UARTC_N_PORTS];
40const struct uartc s5l8700_uartc =
41{
42 .id = 0,
43 .baddr = UARTC_BASE_ADDR,
44 .port_off = UARTC_PORT_OFFSET,
45 .n_ports = UARTC_N_PORTS,
46 .port_l = uartc_port_l,
47};
48
49static int intmsk_uart[S5L8700_N_PORTS] = { INTMSK_UART0, INTMSK_UART1 };
50
51/*
52 * Device level functions specific to S5L8700
53 */
54void uart_target_enable_gpio(int uart_id, int port_id)
55{
56 (void) uart_id;
57 switch (port_id) {
58 /* configure UARTx Tx/Rx GPIO ports */
59 case 0:
60 PCON0 = (PCON0 & 0x0fff) | 0xa000;
61 break;
62 case 1:
63 PCON6 = (PCON6 & 0xfff00fff) | 0x00044000;
64 break;
65 }
66}
67
68void uart_target_disable_gpio(int uart_id, int port_id)
69{
70 (void) uart_id;
71 switch (port_id) {
72 /* configure default reset values */
73 case 0:
74 PCON0 = (PCON0 & 0x0fff) | 0x0000;
75 break;
76 case 1:
77 PCON6 = (PCON6 & 0xfff00fff) | 0x00000000;
78 break;
79 }
80}
81
82void uart_target_enable_irq(int uart_id, int port_id)
83{
84 (void) uart_id;
85 INTMSK |= intmsk_uart[port_id];
86}
87
88void uart_target_disable_irq(int uart_id, int port_id)
89{
90 (void) uart_id;
91 INTMSK &= ~intmsk_uart[port_id];
92}
93
94void uart_target_clear_irq(int uart_id, int port_id)
95{
96 (void) uart_id;
97 SRCPND |= intmsk_uart[port_id];
98}
99
100void uart_target_enable_clocks(int uart_id)
101{
102 (void) uart_id;
103 PWRCON &= ~(1 << CLOCKGATE_UARTC);
104}
105
106void uart_target_disable_clocks(int uart_id)
107{
108 (void) uart_id;
109 PWRCON |= (1 << CLOCKGATE_UARTC);
110}
111
112/*
113 * ISRs
114 */
115void ICODE_ATTR INT_UART0(void)
116{
117 uartc_callback(&s5l8700_uartc, 0);
118}
119
120void ICODE_ATTR INT_UART1(void)
121{
122 uartc_callback(&s5l8700_uartc, 1);
123}
124
125/* Main init */
126void uart_init(void)
127{
128 uartc_open(&s5l8700_uartc);
129}