diff options
author | Cástor Muñoz <cmvidal@gmail.com> | 2014-12-06 22:33:39 +0100 |
---|---|---|
committer | Cástor Muñoz <cmvidal@gmail.com> | 2015-10-07 06:15:03 +0200 |
commit | 38ae0d53e834e6538e3820c3fd1977c971a81c15 (patch) | |
tree | 9e7d8568350fc7f40178cf2d8202ba537b942556 | |
parent | 9f27dc210337e015113776dd5a24b96aabefd70c (diff) | |
download | rockbox-38ae0d53e834e6538e3820c3fd1977c971a81c15.tar.gz rockbox-38ae0d53e834e6538e3820c3fd1977c971a81c15.zip |
iPod Classic: implement HAVE_SERIAL
Change-Id: I24a861cd45095d858d1a7db39969f6eda17cc563
-rw-r--r-- | firmware/SOURCES | 4 | ||||
-rw-r--r-- | firmware/export/config/ipod6g.h | 2 | ||||
-rw-r--r-- | firmware/export/s5l8702.h | 14 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/debug-s5l8702.c | 42 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c | 87 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/system-s5l8702.c | 16 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/uart-s5l8702.c | 127 | ||||
-rw-r--r-- | firmware/target/arm/s5l8702/uart-s5l8702.h | 32 |
8 files changed, 317 insertions, 7 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 543958ea85..091b3b1da7 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -1608,7 +1608,11 @@ target/arm/s5l8702/postmortemstub.S | |||
1608 | target/arm/s5l8702/ipod6g/pmu-ipod6g.c | 1608 | target/arm/s5l8702/ipod6g/pmu-ipod6g.c |
1609 | target/arm/s5l8702/ipod6g/rtc-ipod6g.c | 1609 | target/arm/s5l8702/ipod6g/rtc-ipod6g.c |
1610 | target/arm/s5l8700/usb-nano2g-6g.c | 1610 | target/arm/s5l8700/usb-nano2g-6g.c |
1611 | #ifdef HAVE_SERIAL | ||
1611 | target/arm/s5l8702/uc8702.c | 1612 | target/arm/s5l8702/uc8702.c |
1613 | target/arm/s5l8702/uart-s5l8702.c | ||
1614 | target/arm/s5l8702/ipod6g/serial-ipod6g.c | ||
1615 | #endif | ||
1612 | #ifndef BOOTLOADER | 1616 | #ifndef BOOTLOADER |
1613 | target/arm/s5l8702/timer-s5l8702.c | 1617 | target/arm/s5l8702/timer-s5l8702.c |
1614 | target/arm/s5l8702/debug-s5l8702.c | 1618 | target/arm/s5l8702/debug-s5l8702.c |
diff --git a/firmware/export/config/ipod6g.h b/firmware/export/config/ipod6g.h index 3eae08edce..a885a11144 100644 --- a/firmware/export/config/ipod6g.h +++ b/firmware/export/config/ipod6g.h | |||
@@ -250,7 +250,7 @@ | |||
250 | /* Define this if you can switch on/off the accessory power supply */ | 250 | /* Define this if you can switch on/off the accessory power supply */ |
251 | #define HAVE_ACCESSORY_SUPPLY | 251 | #define HAVE_ACCESSORY_SUPPLY |
252 | //#define IPOD_ACCESSORY_PROTOCOL | 252 | //#define IPOD_ACCESSORY_PROTOCOL |
253 | //#define HAVE_SERIAL | 253 | #define HAVE_SERIAL |
254 | 254 | ||
255 | /* Define this, if you can switch on/off the lineout */ | 255 | /* Define this, if you can switch on/off the lineout */ |
256 | #define HAVE_LINEOUT_POWEROFF | 256 | #define HAVE_LINEOUT_POWEROFF |
diff --git a/firmware/export/s5l8702.h b/firmware/export/s5l8702.h index 34b6da874b..1a59d47036 100644 --- a/firmware/export/s5l8702.h +++ b/firmware/export/s5l8702.h | |||
@@ -669,11 +669,18 @@ | |||
669 | #define I2SCLKDIV (*((volatile uint32_t*)(0x3CA00040))) | 669 | #define I2SCLKDIV (*((volatile uint32_t*)(0x3CA00040))) |
670 | 670 | ||
671 | 671 | ||
672 | /////UART///// | ||
673 | /* UC8702 uart controller */ | ||
674 | #define S5L8702_UART_BASE 0x3cc00000 | ||
675 | #define S5L8702_UART_PORT_MAX 4 | ||
676 | |||
677 | |||
672 | /////CLOCK GATES///// | 678 | /////CLOCK GATES///// |
673 | #define CLOCKGATE_USB_1 2 | 679 | #define CLOCKGATE_USB_1 2 |
674 | #define CLOCKGATE_USB_2 35 | 680 | #define CLOCKGATE_USB_2 35 |
675 | #define CLOCKGATE_DMAC0 25 | 681 | #define CLOCKGATE_DMAC0 25 |
676 | #define CLOCKGATE_DMAC1 26 | 682 | #define CLOCKGATE_DMAC1 26 |
683 | #define CLOCKGATE_UART 41 | ||
677 | 684 | ||
678 | 685 | ||
679 | /////INTERRUPTS///// | 686 | /////INTERRUPTS///// |
@@ -687,6 +694,13 @@ | |||
687 | #define IRQ_ATA 29 | 694 | #define IRQ_ATA 29 |
688 | #define IRQ_MMC 44 | 695 | #define IRQ_MMC 44 |
689 | 696 | ||
697 | #define IRQ_UART(i) (24+i) | ||
698 | #define IRQ_UART0 24 | ||
699 | #define IRQ_UART1 25 | ||
700 | #define IRQ_UART2 26 | ||
701 | #define IRQ_UART3 27 | ||
702 | #define IRQ_UART4 28 /* obsolete/not implemented on s5l8702 ??? */ | ||
703 | |||
690 | #define IRQ_EXT0 0 | 704 | #define IRQ_EXT0 0 |
691 | #define IRQ_EXT1 1 | 705 | #define IRQ_EXT1 1 |
692 | #define IRQ_EXT2 2 | 706 | #define IRQ_EXT2 2 |
diff --git a/firmware/target/arm/s5l8702/debug-s5l8702.c b/firmware/target/arm/s5l8702/debug-s5l8702.c index c49737756c..a2c6c0b193 100644 --- a/firmware/target/arm/s5l8702/debug-s5l8702.c +++ b/firmware/target/arm/s5l8702/debug-s5l8702.c | |||
@@ -30,6 +30,9 @@ | |||
30 | #include "power.h" | 30 | #include "power.h" |
31 | #include "pmu-target.h" | 31 | #include "pmu-target.h" |
32 | #include "pcm-target.h" | 32 | #include "pcm-target.h" |
33 | #ifdef HAVE_SERIAL | ||
34 | #include "uc8702.h" | ||
35 | #endif | ||
33 | 36 | ||
34 | #define DEBUG_CANCEL BUTTON_MENU | 37 | #define DEBUG_CANCEL BUTTON_MENU |
35 | 38 | ||
@@ -46,7 +49,11 @@ bool dbg_hw_info(void) | |||
46 | int line; | 49 | int line; |
47 | int i; | 50 | int i; |
48 | unsigned int state = 0; | 51 | unsigned int state = 0; |
52 | #ifdef UC8702_DEBUG | ||
53 | const unsigned int max_states=3; | ||
54 | #else | ||
49 | const unsigned int max_states=2; | 55 | const unsigned int max_states=2; |
56 | #endif | ||
50 | 57 | ||
51 | lcd_clear_display(); | 58 | lcd_clear_display(); |
52 | lcd_setfont(FONT_SYSFIXED); | 59 | lcd_setfont(FONT_SYSFIXED); |
@@ -100,6 +107,41 @@ bool dbg_hw_info(void) | |||
100 | _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off"); | 107 | _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off"); |
101 | _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28)); | 108 | _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28)); |
102 | } | 109 | } |
110 | #ifdef UC8702_DEBUG | ||
111 | else if(state==2) | ||
112 | { | ||
113 | extern struct uartc_port ser_port; | ||
114 | int tx_stat, rx_stat, tx_speed, rx_speed; | ||
115 | char line_cfg[4]; | ||
116 | int abr_stat; | ||
117 | unsigned int abr_cnt; | ||
118 | |||
119 | char *abrstatus[] = {"Idle", "Launched", "Counting", "Abnormal"}; | ||
120 | |||
121 | uartc_port_get_line_info(&ser_port, &tx_stat, &rx_stat, | ||
122 | &tx_speed, &rx_speed, line_cfg); | ||
123 | |||
124 | abr_stat = uartc_port_get_abr_info(&ser_port, &abr_cnt); | ||
125 | |||
126 | _DEBUG_PRINTF("UART %d:", ser_port.id); | ||
127 | line++; | ||
128 | _DEBUG_PRINTF("line: %s", line_cfg); | ||
129 | _DEBUG_PRINTF("Tx: %s, speed: %d", tx_stat ? "On":"Off", tx_speed); | ||
130 | _DEBUG_PRINTF("Rx: %s, speed: %d", rx_stat ? "On":"Off", rx_speed); | ||
131 | _DEBUG_PRINTF("ABR: %s, cnt: %d", abrstatus[abr_stat], abr_cnt); | ||
132 | line++; | ||
133 | _DEBUG_PRINTF("n_tx_bytes: %u", ser_port.n_tx_bytes); | ||
134 | _DEBUG_PRINTF("n_rx_bytes: %u", ser_port.n_rx_bytes); | ||
135 | _DEBUG_PRINTF("n_ovr_err: %u", ser_port.n_ovr_err); | ||
136 | _DEBUG_PRINTF("n_parity_err: %u", ser_port.n_parity_err); | ||
137 | _DEBUG_PRINTF("n_frame_err: %u", ser_port.n_frame_err); | ||
138 | _DEBUG_PRINTF("n_break_detect: %u", ser_port.n_break_detect); | ||
139 | _DEBUG_PRINTF("n_abnormal0: %u", ser_port.n_abnormal0); | ||
140 | _DEBUG_PRINTF("n_abnormal1: %u", ser_port.n_abnormal1); | ||
141 | |||
142 | sleep(HZ/20); | ||
143 | } | ||
144 | #endif | ||
103 | else | 145 | else |
104 | { | 146 | { |
105 | state=0; | 147 | state=0; |
diff --git a/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c new file mode 100644 index 0000000000..c03ba9bc24 --- /dev/null +++ b/firmware/target/arm/s5l8702/ipod6g/serial-ipod6g.c | |||
@@ -0,0 +1,87 @@ | |||
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 <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <stdarg.h> | ||
24 | |||
25 | #include "config.h" | ||
26 | #include "cpu.h" | ||
27 | #include "system.h" | ||
28 | #include "kernel.h" | ||
29 | |||
30 | #include "serial.h" | ||
31 | #include "s5l8702.h" | ||
32 | #include "uc8702.h" | ||
33 | #include "uart-s5l8702.h" | ||
34 | |||
35 | /* Define LOGF_ENABLE to enable logf output in this file */ | ||
36 | #define LOGF_ENABLE | ||
37 | #include "logf.h" | ||
38 | |||
39 | |||
40 | /* shall include serial HW configuracion for specific target */ | ||
41 | #define IPOD6G_UART_CLK_HZ 12000000 /* external OSC0 ??? */ | ||
42 | |||
43 | extern struct uartc s5l8702_uart; | ||
44 | |||
45 | struct uartc_port ser_port IDATA_ATTR = { | ||
46 | /* location */ | ||
47 | .uartc = &s5l8702_uart, | ||
48 | .id = 0, | ||
49 | |||
50 | /* configuration */ | ||
51 | .rx_trg = UFCON_RX_FIFO_TRG_4, | ||
52 | .tx_trg = UFCON_TX_FIFO_TRG_EMPTY, | ||
53 | .clksel = UCON_CLKSEL_ECLK, | ||
54 | .clkhz = IPOD6G_UART_CLK_HZ, | ||
55 | |||
56 | /* interrupt callbacks */ | ||
57 | .rx_cb = NULL, | ||
58 | .tx_cb = NULL, /* polling */ | ||
59 | }; | ||
60 | |||
61 | /* | ||
62 | * serial driver API | ||
63 | */ | ||
64 | void serial_setup(void) | ||
65 | { | ||
66 | uart_port_init(&ser_port); | ||
67 | |||
68 | /* set a default configuration, Tx and Rx modes are | ||
69 | disabled when the port is initialized */ | ||
70 | uartc_port_config(&ser_port, 115200, ULCON_DATA_BITS_8, | ||
71 | ULCON_PARITY_NONE, ULCON_STOP_BITS_1); | ||
72 | |||
73 | /* enable Tx interrupt request or POLLING mode */ | ||
74 | uartc_port_set_tx_mode(&ser_port, UCON_MODE_INTREQ); | ||
75 | |||
76 | logf("[%lu] serial_setup(): port %d ready!", USEC_TIMER, ser_port.id); | ||
77 | } | ||
78 | |||
79 | int tx_rdy(void) | ||
80 | { | ||
81 | return uartc_port_tx_ready(&ser_port) ? 1 : 0; | ||
82 | } | ||
83 | |||
84 | void tx_writec(unsigned char c) | ||
85 | { | ||
86 | uartc_port_tx_byte(&ser_port, c); | ||
87 | } | ||
diff --git a/firmware/target/arm/s5l8702/system-s5l8702.c b/firmware/target/arm/s5l8702/system-s5l8702.c index a9db7e1b8d..014ed910de 100644 --- a/firmware/target/arm/s5l8702/system-s5l8702.c +++ b/firmware/target/arm/s5l8702/system-s5l8702.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "pmu-target.h" | 26 | #include "pmu-target.h" |
27 | #include "gpio-s5l8702.h" | 27 | #include "gpio-s5l8702.h" |
28 | #include "dma-s5l8702.h" | 28 | #include "dma-s5l8702.h" |
29 | #include "uart-s5l8702.h" | ||
29 | 30 | ||
30 | #define default_interrupt(name) \ | 31 | #define default_interrupt(name) \ |
31 | extern __attribute__((weak,alias("UIRQ"))) void name (void) | 32 | extern __attribute__((weak,alias("UIRQ"))) void name (void) |
@@ -64,11 +65,11 @@ default_interrupt(INT_IRQ20); | |||
64 | default_interrupt(INT_IRQ21); | 65 | default_interrupt(INT_IRQ21); |
65 | default_interrupt(INT_IRQ22); | 66 | default_interrupt(INT_IRQ22); |
66 | default_interrupt(INT_WHEEL); | 67 | default_interrupt(INT_WHEEL); |
67 | default_interrupt(INT_IRQ24); | 68 | default_interrupt(INT_UART0); |
68 | default_interrupt(INT_IRQ25); | 69 | default_interrupt(INT_UART1); |
69 | default_interrupt(INT_IRQ26); | 70 | default_interrupt(INT_UART2); |
70 | default_interrupt(INT_IRQ27); | 71 | default_interrupt(INT_UART3); |
71 | default_interrupt(INT_IRQ28); | 72 | default_interrupt(INT_IRQ28); /* obsolete/not implemented UART4 ??? */ |
72 | default_interrupt(INT_ATA); | 73 | default_interrupt(INT_ATA); |
73 | default_interrupt(INT_IRQ30); | 74 | default_interrupt(INT_IRQ30); |
74 | default_interrupt(INT_EXT4); /* GPIOIC group 2 (not used) */ | 75 | default_interrupt(INT_EXT4); /* GPIOIC group 2 (not used) */ |
@@ -133,7 +134,7 @@ static void (* const irqvector[])(void) = | |||
133 | INT_EXT0,INT_EXT1,INT_EXT2,INT_EXT3,INT_IRQ4,INT_IRQ5,INT_IRQ6,INT_TIMER32, | 134 | INT_EXT0,INT_EXT1,INT_EXT2,INT_EXT3,INT_IRQ4,INT_IRQ5,INT_IRQ6,INT_TIMER32, |
134 | INT_TIMER,INT_IRQ9,INT_IRQ10,INT_IRQ11,INT_IRQ12,INT_IRQ13,INT_IRQ14,INT_IRQ15, | 135 | INT_TIMER,INT_IRQ9,INT_IRQ10,INT_IRQ11,INT_IRQ12,INT_IRQ13,INT_IRQ14,INT_IRQ15, |
135 | INT_DMAC0,INT_DMAC1,INT_IRQ18,INT_USB_FUNC,INT_IRQ20,INT_IRQ21,INT_IRQ22,INT_WHEEL, | 136 | INT_DMAC0,INT_DMAC1,INT_IRQ18,INT_USB_FUNC,INT_IRQ20,INT_IRQ21,INT_IRQ22,INT_WHEEL, |
136 | INT_IRQ24,INT_IRQ25,INT_IRQ26,INT_IRQ27,INT_IRQ28,INT_ATA,INT_IRQ30,INT_EXT4, | 137 | INT_UART0,INT_UART1,INT_UART2,INT_UART3,INT_IRQ28,INT_ATA,INT_IRQ30,INT_EXT4, |
137 | INT_EXT5,INT_EXT6,INT_IRQ34,INT_IRQ35,INT_IRQ36,INT_IRQ37,INT_IRQ38,INT_IRQ39, | 138 | INT_EXT5,INT_EXT6,INT_IRQ34,INT_IRQ35,INT_IRQ36,INT_IRQ37,INT_IRQ38,INT_IRQ39, |
138 | INT_IRQ40,INT_IRQ41,INT_IRQ42,INT_IRQ43,INT_MMC,INT_IRQ45,INT_IRQ46,INT_IRQ47, | 139 | INT_IRQ40,INT_IRQ41,INT_IRQ42,INT_IRQ43,INT_MMC,INT_IRQ45,INT_IRQ46,INT_IRQ47, |
139 | INT_IRQ48,INT_IRQ49,INT_IRQ50,INT_IRQ51,INT_IRQ52,INT_IRQ53,INT_IRQ54,INT_IRQ55, | 140 | INT_IRQ48,INT_IRQ49,INT_IRQ50,INT_IRQ51,INT_IRQ52,INT_IRQ53,INT_IRQ54,INT_IRQ55, |
@@ -185,6 +186,9 @@ void system_init(void) | |||
185 | gpio_init(); | 186 | gpio_init(); |
186 | pmu_init(); | 187 | pmu_init(); |
187 | dma_init(); | 188 | dma_init(); |
189 | #ifdef HAVE_SERIAL | ||
190 | uart_init(); | ||
191 | #endif | ||
188 | VIC0INTENABLE = 1 << IRQ_WHEEL; | 192 | VIC0INTENABLE = 1 << IRQ_WHEEL; |
189 | VIC0INTENABLE = 1 << IRQ_ATA; | 193 | VIC0INTENABLE = 1 << IRQ_ATA; |
190 | VIC1INTENABLE = 1 << (IRQ_MMC - 32); | 194 | VIC1INTENABLE = 1 << (IRQ_MMC - 32); |
diff --git a/firmware/target/arm/s5l8702/uart-s5l8702.c b/firmware/target/arm/s5l8702/uart-s5l8702.c new file mode 100644 index 0000000000..45d61ba627 --- /dev/null +++ b/firmware/target/arm/s5l8702/uart-s5l8702.c | |||
@@ -0,0 +1,127 @@ | |||
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 | |||
22 | /* Include Standard files */ | ||
23 | #include <stdlib.h> | ||
24 | #include <stdio.h> | ||
25 | #include <stdarg.h> | ||
26 | |||
27 | #include "config.h" | ||
28 | #include "cpu.h" | ||
29 | #include "system.h" | ||
30 | #include "kernel.h" | ||
31 | |||
32 | #include "s5l8702.h" | ||
33 | #include "uc8702.h" | ||
34 | #include "uart-s5l8702.h" | ||
35 | |||
36 | |||
37 | /* s5l8702 UART configuration */ | ||
38 | struct uartc s5l8702_uart = { | ||
39 | .baddr = S5L8702_UART_BASE | ||
40 | }; | ||
41 | |||
42 | /* | ||
43 | * Device level functions specific to S5L8702 | ||
44 | */ | ||
45 | void uart_gpio_control(int port_id, bool onoff) | ||
46 | { | ||
47 | if (onoff) { | ||
48 | switch (port_id) { | ||
49 | case 0: | ||
50 | /* configure UART0 Tx/Rx GPIO ports */ | ||
51 | PCON0 = (PCON0 & 0xff00ffff) | 0x00220000; | ||
52 | break; | ||
53 | case 1: | ||
54 | /* configure UART1 GPIO ports, including RTS/CTS signals */ | ||
55 | PCOND = (PCOND & 0xff0000ff) | 0x00222200; | ||
56 | break; | ||
57 | case 2: | ||
58 | case 3: | ||
59 | /* unknown, probably UART3/4 not routed on s5l8702 */ | ||
60 | default: | ||
61 | break; | ||
62 | } | ||
63 | } | ||
64 | else { | ||
65 | /* configure minimal power consumption */ | ||
66 | switch (port_id) { | ||
67 | case 0: | ||
68 | PCON0 = (PCON0 & 0xff00ffff) | 0x00ee0000; | ||
69 | break; | ||
70 | case 1: | ||
71 | PCOND = (PCOND & 0xff0000ff) | 0x00eeee00; | ||
72 | break; | ||
73 | case 2: | ||
74 | case 3: | ||
75 | default: | ||
76 | break; | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | |||
81 | /* reset s5l8702 uart related hardware */ | ||
82 | static void s5l8702_uart_hw_init(void) | ||
83 | { | ||
84 | for (int id = 0; id < S5L8702_UART_PORT_MAX; id++) { | ||
85 | VIC0INTENCLEAR = 1 << IRQ_UART(id); /* mask INT */ | ||
86 | uart_gpio_control(id, 0); | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void uart_init(void) | ||
91 | { | ||
92 | s5l8702_uart_hw_init(); | ||
93 | PWRCON(1) &= ~(1 << (CLOCKGATE_UART - 32)); /* on */ | ||
94 | uartc_open(&s5l8702_uart); | ||
95 | } | ||
96 | |||
97 | void uart_close(void) | ||
98 | { | ||
99 | uartc_close(&s5l8702_uart); | ||
100 | PWRCON(1) |= (1 << (CLOCKGATE_UART - 32)); /* off */ | ||
101 | s5l8702_uart_hw_init(); | ||
102 | } | ||
103 | |||
104 | void uart_port_init(struct uartc_port *port) | ||
105 | { | ||
106 | uart_gpio_control(port->id, 1); | ||
107 | uartc_port_open(port); | ||
108 | VIC0INTENABLE = 1 << IRQ_UART(port->id); /* unmask INT */ | ||
109 | } | ||
110 | |||
111 | void uart_port_close(struct uartc_port *port) | ||
112 | { | ||
113 | VIC0INTENCLEAR = 1 << IRQ_UART(port->id); /* mask INT */ | ||
114 | uartc_port_close(port); | ||
115 | uart_gpio_control(port->id, 0); | ||
116 | } | ||
117 | |||
118 | /* ISRs */ | ||
119 | void ICODE_ATTR INT_UART0(void) | ||
120 | { | ||
121 | uartc_callback(&s5l8702_uart, 0); | ||
122 | } | ||
123 | |||
124 | void ICODE_ATTR INT_UART1(void) | ||
125 | { | ||
126 | uartc_callback(&s5l8702_uart, 1); | ||
127 | } | ||
diff --git a/firmware/target/arm/s5l8702/uart-s5l8702.h b/firmware/target/arm/s5l8702/uart-s5l8702.h new file mode 100644 index 0000000000..c7ec684284 --- /dev/null +++ b/firmware/target/arm/s5l8702/uart-s5l8702.h | |||
@@ -0,0 +1,32 @@ | |||
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 | #ifndef __UART_S5L8702_H__ | ||
22 | #define __UART_S5L8702_H__ | ||
23 | |||
24 | #include "uc8702.h" | ||
25 | |||
26 | /* s5l8702 low level routines */ | ||
27 | void uart_init (void); | ||
28 | void uart_close(void); | ||
29 | void uart_port_init (struct uartc_port *port); | ||
30 | void uart_port_close (struct uartc_port *port); | ||
31 | |||
32 | #endif /* __UART_S5L8702_H__ */ | ||