aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/mantis/mantis_uart.c
diff options
context:
space:
mode:
authorManu Abraham <abraham.manu@gmail.com>2009-12-11 18:41:07 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-01-17 08:55:44 -0500
commita1497357dce240880d984f4b657b54245f739dbc (patch)
tree1c041b7b1859f18a964228e099e58a01f2d0c113 /drivers/media/dvb/mantis/mantis_uart.c
parentc5e598a6f89ca7335db9f327e24e3abd13d137cf (diff)
V4L/DVB (13806): Register and Initialize Remote control
Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/mantis/mantis_uart.c')
-rw-r--r--drivers/media/dvb/mantis/mantis_uart.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/drivers/media/dvb/mantis/mantis_uart.c b/drivers/media/dvb/mantis/mantis_uart.c
index 03b47cf15f8d..7d2f2398fa8b 100644
--- a/drivers/media/dvb/mantis/mantis_uart.c
+++ b/drivers/media/dvb/mantis/mantis_uart.c
@@ -1,7 +1,26 @@
1/*
2 Mantis PCI bridge driver
3
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
1#include <linux/kernel.h> 21#include <linux/kernel.h>
2#include <linux/spinlock.h> 22#include <linux/spinlock.h>
3 23
4#include <asm/irq.h>
5#include <linux/signal.h> 24#include <linux/signal.h>
6#include <linux/sched.h> 25#include <linux/sched.h>
7#include <linux/interrupt.h> 26#include <linux/interrupt.h>
@@ -21,6 +40,24 @@ struct mantis_uart_params {
21 enum mantis_parity parity; 40 enum mantis_parity parity;
22}; 41};
23 42
43static struct {
44 char string[7];
45} rates[5] = {
46 { "9600" },
47 { "19200" },
48 { "38400" },
49 { "57600" },
50 { "115200" }
51};
52
53static struct {
54 char string[5];
55} parity[3] = {
56 { "NONE" },
57 { "ODD" },
58 { "EVEN" }
59};
60
24#define UART_MAX_BUF 16 61#define UART_MAX_BUF 16
25 62
26int mantis_uart_read(struct mantis_pci *mantis, u8 *data) 63int mantis_uart_read(struct mantis_pci *mantis, u8 *data)
@@ -60,12 +97,10 @@ static void mantis_uart_work(struct work_struct *work)
60 u8 buf[16]; 97 u8 buf[16];
61 int i; 98 int i;
62 99
63 dprintk(MANTIS_DEBUG, 1, "UART read");
64 mantis_uart_read(mantis, buf); 100 mantis_uart_read(mantis, buf);
65 101
66 dprintk(MANTIS_DEBUG, 1, "UART: ");
67 for (i = 0; i < (config->bytes + 1); i++) 102 for (i = 0; i < (config->bytes + 1); i++)
68 dprintk(MANTIS_DEBUG, 0, "<%02x> ", buf[i]); 103 dprintk(MANTIS_INFO, 1, "UART BUF:%d <%02x> ", i, buf[i]);
69 104
70 dprintk(MANTIS_DEBUG, 0, "\n"); 105 dprintk(MANTIS_DEBUG, 0, "\n");
71} 106}
@@ -73,15 +108,8 @@ static void mantis_uart_work(struct work_struct *work)
73static int mantis_uart_setup(struct mantis_pci *mantis, 108static int mantis_uart_setup(struct mantis_pci *mantis,
74 struct mantis_uart_params *params) 109 struct mantis_uart_params *params)
75{ 110{
76 char* rates[] = { "B_9600", "B_19200", "B_38400", "B_57600", "B_115200" };
77 char* parity[] = { "NONE", "ODD", "EVEN" };
78
79 u32 reg; 111 u32 reg;
80 112
81 dprintk(MANTIS_DEBUG, 1, "Set Parity <%s> Baud Rate <%s>",
82 parity[params->parity],
83 rates[params->baud_rate]);
84
85 mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL); 113 mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL);
86 114
87 reg = mmread(MANTIS_UART_BAUD); 115 reg = mmread(MANTIS_UART_BAUD);
@@ -116,10 +144,12 @@ int mantis_uart_init(struct mantis_pci *mantis)
116 struct mantis_hwconfig *config = mantis->hwconfig; 144 struct mantis_hwconfig *config = mantis->hwconfig;
117 struct mantis_uart_params params; 145 struct mantis_uart_params params;
118 146
119 dprintk(MANTIS_DEBUG, 1, "Initializing UART ..");
120 /* default parity: */ 147 /* default parity: */
121 params.baud_rate = config->baud_rate; 148 params.baud_rate = config->baud_rate;
122 params.parity = config->parity; 149 params.parity = config->parity;
150 dprintk(MANTIS_INFO, 1, "Initializing UART @ %sbps parity:%s",
151 rates[params.baud_rate].string,
152 parity[params.parity].string);
123 153
124 init_waitqueue_head(&mantis->uart_wq); 154 init_waitqueue_head(&mantis->uart_wq);
125 spin_lock_init(&mantis->uart_lock); 155 spin_lock_init(&mantis->uart_lock);
@@ -142,6 +172,7 @@ int mantis_uart_init(struct mantis_pci *mantis)
142 mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL); 172 mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL);
143 173
144 schedule_work(&mantis->uart_work); 174 schedule_work(&mantis->uart_work);
175 dprintk(MANTIS_DEBUG, 1, "UART succesfully initialized");
145 176
146 return 0; 177 return 0;
147} 178}