Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (13794): [Mantis/VP-3028] Initial go at Serial interface implementation, add support for VP-3028

Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Manu Abraham and committed by
Mauro Carvalho Chehab
add20636 ec1b6ff1

+253 -2
+2
drivers/media/dvb/mantis/Makefile
··· 1 1 mantis-objs = mantis_core.o \ 2 + mantis_uart.o \ 2 3 mantis_dma.o \ 3 4 mantis_pci.o \ 4 5 mantis_i2c.o \ ··· 13 12 mantis_vp1041.o \ 14 13 mantis_vp2033.o \ 15 14 mantis_vp2040.o \ 15 + mantis_vp3028.o \ 16 16 mantis_vp3030.o 17 17 18 18 obj-$(CONFIG_DVB_MANTIS) += mantis.o
+10
drivers/media/dvb/mantis/mantis_common.h
··· 26 26 #include <linux/kernel.h> 27 27 #include <linux/pci.h> 28 28 #include <linux/mutex.h> 29 + #include <linux/workqueue.h> 29 30 30 31 #include "dvbdev.h" 31 32 #include "dvb_demux.h" ··· 35 34 #include "dvb_net.h" 36 35 #include <linux/i2c.h> 37 36 #include "mantis_reg.h" 37 + #include "mantis_uart.h" 38 38 39 39 #include "mantis_link.h" 40 40 ··· 76 74 char *model_name; 77 75 char *dev_type; 78 76 u32 ts_size; 77 + 78 + enum mantis_baud baud_rate; 79 + enum mantis_parity parity; 80 + u32 bytes; 79 81 }; 80 82 81 83 struct mantis_pci { ··· 148 142 u32 gpif_status; 149 143 150 144 struct mantis_ca *mantis_ca; 145 + 146 + wait_queue_head_t uart_wq; 147 + struct work_struct uart_work; 148 + spinlock_t uart_lock; 151 149 }; 152 150 153 151 #define MANTIS_HIF_STATUS (mantis->gpio_status)
+8
drivers/media/dvb/mantis/mantis_core.c
··· 165 165 dprintk(verbose, MANTIS_DEBUG, 1, "Mantis DVB init failed"); 166 166 return err; 167 167 } 168 + if ((err = mantis_uart_init(mantis)) < 0) { 169 + dprintk(verbose, MANTIS_DEBUG, 1, "Mantis UART init failed"); 170 + return err; 171 + } 168 172 169 173 return 0; 170 174 } ··· 177 173 { 178 174 mantis_dma_stop(mantis); 179 175 dprintk(verbose, MANTIS_ERROR, 1, "DMA engine stopping"); 176 + 177 + mantis_uart_exit(mantis); 178 + dprintk(verbose, MANTIS_ERROR, 1, "UART exit failed"); 179 + 180 180 if (mantis_dma_exit(mantis) < 0) 181 181 dprintk(verbose, MANTIS_ERROR, 1, "DMA exit failed"); 182 182 if (mantis_dvb_exit(mantis) < 0)
+2
drivers/media/dvb/mantis/mantis_pci.c
··· 27 27 #include <linux/device.h> 28 28 #include "mantis_common.h" 29 29 #include "mantis_core.h" 30 + #include "mantis_uart.h" 30 31 31 32 #include <asm/irq.h> 32 33 #include <linux/signal.h> ··· 95 94 } 96 95 if (stat & MANTIS_INT_IRQ1) { 97 96 dprintk(verbose, MANTIS_DEBUG, 0, "* INT IRQ-1 *"); 97 + schedule_work(&mantis->uart_work); 98 98 } 99 99 if (stat & MANTIS_INT_OCERR) { 100 100 dprintk(verbose, MANTIS_DEBUG, 0, "* INT OCERR *");
+139
drivers/media/dvb/mantis/mantis_uart.c
··· 1 + #include <linux/spinlock.h> 2 + #include "mantis_common.h" 3 + 4 + struct mantis_uart_params { 5 + enum mantis_baud baud_rate; 6 + enum mantis_parity parity; 7 + }; 8 + 9 + #define UART_MAX_BUF 16 10 + 11 + int mantis_uart_read(struct mantis_pci *mantis, u8 *data) 12 + { 13 + struct mantis_hwconfig *config = mantis->hwconfig; 14 + u32 stat, i; 15 + unsigned long flags; 16 + 17 + /* get data */ 18 + for (i = 0; i < (config->bytes + 1); i++) { 19 + 20 + if (stat & MANTIS_UART_RXFIFO_FULL) { 21 + dprintk(verbose, MANTIS_ERROR, 1, "RX Fifo FULL"); 22 + } 23 + data[i] = mmread(MANTIS_UART_RXD) & 0x3f; 24 + 25 + stat = mmread(MANTIS_UART_STAT); 26 + 27 + dprintk(verbose, MANTIS_DEBUG, 1, "Reading ... <%02x>", data[i] & 0x3f); 28 + 29 + if (data[i] & (1 << 7)) { 30 + dprintk(verbose, MANTIS_ERROR, 1, "UART framing error"); 31 + return -EINVAL; 32 + } 33 + if (data[i] & (1 << 6)) { 34 + dprintk(verbose, MANTIS_ERROR, 1, "UART parity error"); 35 + return -EINVAL; 36 + } 37 + } 38 + 39 + return 0; 40 + } 41 + 42 + static void mantis_uart_work(struct work_struct *work) 43 + { 44 + struct mantis_pci *mantis = container_of(work, struct mantis_pci, uart_work); 45 + struct mantis_hwconfig *config = mantis->hwconfig; 46 + u8 buf[16]; 47 + int i; 48 + 49 + dprintk(verbose, MANTIS_DEBUG, 1, "UART read"); 50 + mantis_uart_read(mantis, buf); 51 + 52 + dprintk(verbose, MANTIS_DEBUG, 1, "UART: "); 53 + for (i = 0; i < (config->bytes + 1); i++) 54 + dprintk(verbose, MANTIS_DEBUG, 0, "<%02x> ", buf[i]); 55 + 56 + dprintk(verbose, MANTIS_DEBUG, 0, "\n"); 57 + } 58 + 59 + static int mantis_uart_setup(struct mantis_pci *mantis, 60 + struct mantis_uart_params *params) 61 + { 62 + char* rates[] = { "B_9600", "B_19200", "B_38400", "B_57600", "B_115200" }; 63 + char* parity[] = { "NONE", "ODD", "EVEN" }; 64 + 65 + u32 reg; 66 + 67 + dprintk(verbose, MANTIS_DEBUG, 1, "Set Parity <%s> Baud Rate <%s>", 68 + parity[params->parity], 69 + rates[params->baud_rate]); 70 + 71 + mmwrite((mmread(MANTIS_UART_CTL) | (params->parity & 0x3)), MANTIS_UART_CTL); 72 + 73 + reg = mmread(MANTIS_UART_BAUD); 74 + 75 + switch (params->baud_rate) { 76 + case MANTIS_BAUD_9600: 77 + reg |= 0xd8; 78 + break; 79 + case MANTIS_BAUD_19200: 80 + reg |= 0x6c; 81 + break; 82 + case MANTIS_BAUD_38400: 83 + reg |= 0x36; 84 + break; 85 + case MANTIS_BAUD_57600: 86 + reg |= 0x23; 87 + break; 88 + case MANTIS_BAUD_115200: 89 + reg |= 0x11; 90 + break; 91 + default: 92 + return -EINVAL; 93 + } 94 + 95 + mmwrite(reg, MANTIS_UART_BAUD); 96 + 97 + return 0; 98 + } 99 + 100 + int mantis_uart_init(struct mantis_pci *mantis) 101 + { 102 + struct mantis_hwconfig *config = mantis->hwconfig; 103 + struct mantis_uart_params params; 104 + 105 + dprintk(verbose, MANTIS_DEBUG, 1, "Initializing UART .."); 106 + /* default parity: */ 107 + params.baud_rate = config->baud_rate; 108 + params.parity = config->parity; 109 + 110 + init_waitqueue_head(&mantis->uart_wq); 111 + spin_lock_init(&mantis->uart_lock); 112 + 113 + INIT_WORK(&mantis->uart_work, mantis_uart_work); 114 + 115 + /* disable interrupt */ 116 + mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL); 117 + 118 + mantis_uart_setup(mantis, &params); 119 + 120 + /* default 1 byte */ 121 + mmwrite((mmread(MANTIS_UART_BAUD) | (config->bytes << 8)), MANTIS_UART_BAUD); 122 + 123 + /* flush buffer */ 124 + mmwrite((mmread(MANTIS_UART_CTL) | MANTIS_UART_RXFLUSH), MANTIS_UART_CTL); 125 + 126 + /* enable interrupt */ 127 + mmwrite(mmread(MANTIS_INT_MASK) | 0x800, MANTIS_INT_MASK); 128 + mmwrite(mmread(MANTIS_UART_CTL) | MANTIS_UART_RXINT, MANTIS_UART_CTL); 129 + 130 + schedule_work(&mantis->uart_work); 131 + 132 + return 0; 133 + } 134 + 135 + void mantis_uart_exit(struct mantis_pci *mantis) 136 + { 137 + /* disable interrupt */ 138 + mmwrite(mmread(MANTIS_UART_CTL) & 0xffef, MANTIS_UART_CTL); 139 + }
+23 -2
drivers/media/dvb/mantis/mantis_uart.h
··· 21 21 #ifndef __MANTIS_UART_H 22 22 #define __MANTIS_UART_H 23 23 24 + #define MANTIS_UART_CTL 0xe0 25 + #define MANTIS_UART_RXINT (1 << 4) 26 + #define MANTIS_UART_RXFLUSH (1 << 2) 27 + 28 + #define MANTIS_UART_RXD 0xe8 29 + #define MANTIS_UART_BAUD 0xec 30 + 31 + #define MANTIS_UART_STAT 0xf0 32 + #define MANTIS_UART_RXFIFO_DATA (1 << 7) 33 + #define MANTIS_UART_RXFIFO_EMPTY (1 << 6) 34 + #define MANTIS_UART_RXFIFO_FULL (1 << 3) 35 + #define MANTIS_UART_FRAME_ERR (1 << 2) 36 + #define MANTIS_UART_PARITY_ERR (1 << 1) 37 + #define MANTIS_UART_RXTHRESH_INT (1 << 0) 38 + 24 39 enum mantis_baud { 25 40 MANTIS_BAUD_9600 = 0, 26 41 MANTIS_BAUD_19200, ··· 45 30 }; 46 31 47 32 enum mantis_parity { 48 - MANTIS_PARITY_NONE = 0, 33 + MANTIS_PARITY_UNDEFINED = 0, 49 34 MANTIS_PARITY_EVEN, 50 - MANTIS_PARITY_ODD 35 + MANTIS_PARITY_ODD, 36 + MANTIS_PARITY_NONE 51 37 }; 38 + 39 + struct mantis_pci; 40 + 41 + extern int mantis_uart_init(struct mantis_pci *mantis); 42 + extern void mantis_uart_exit(struct mantis_pci *mantis); 52 43 53 44 #endif // __MANTIS_UART_H
+3
drivers/media/dvb/mantis/mantis_vp1033.c
··· 88 88 .model_name = MANTIS_MODEL_NAME, 89 89 .dev_type = MANTIS_DEV_TYPE, 90 90 .ts_size = MANTIS_TS_204, 91 + .baud_rate = MANTIS_BAUD_9600, 92 + .parity = MANTIS_PARITY_NONE, 93 + .bytes = 0, 91 94 }; 92 95 93 96 int lgtdqcs001f_tuner_set(struct dvb_frontend *fe,
+3
drivers/media/dvb/mantis/mantis_vp1034.c
··· 33 33 .model_name = MANTIS_MODEL_NAME, 34 34 .dev_type = MANTIS_DEV_TYPE, 35 35 .ts_size = MANTIS_TS_204, 36 + .baud_rate = MANTIS_BAUD_9600, 37 + .parity = MANTIS_PARITY_NONE, 38 + .bytes = 0, 36 39 }; 37 40 38 41 int vp1034_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
+3
drivers/media/dvb/mantis/mantis_vp1041.c
··· 31 31 .model_name = MANTIS_MODEL_NAME, 32 32 .dev_type = MANTIS_DEV_TYPE, 33 33 .ts_size = MANTIS_TS_188, 34 + .baud_rate = MANTIS_BAUD_9600, 35 + .parity = MANTIS_PARITY_NONE, 36 + .bytes = 0, 34 37 }; 35 38 36 39 static const struct stb0899_s1_reg vp1041_stb0899_s1_init_1[] = {
+3
drivers/media/dvb/mantis/mantis_vp2033.c
··· 28 28 .model_name = MANTIS_MODEL_NAME, 29 29 .dev_type = MANTIS_DEV_TYPE, 30 30 .ts_size = MANTIS_TS_204, 31 + .baud_rate = MANTIS_BAUD_9600, 32 + .parity = MANTIS_PARITY_NONE, 33 + .bytes = 0, 31 34 }; 32 35 33 36 struct tda1002x_config philips_cu1216_config = {
+3
drivers/media/dvb/mantis/mantis_vp2040.c
··· 28 28 .model_name = MANTIS_MODEL_NAME, 29 29 .dev_type = MANTIS_DEV_TYPE, 30 30 .ts_size = MANTIS_TS_204, 31 + .baud_rate = MANTIS_BAUD_9600, 32 + .parity = MANTIS_PARITY_NONE, 33 + .bytes = 0, 31 34 }; 32 35 33 36 struct tda10023_config tda10023_cu1216_config = {
+38
drivers/media/dvb/mantis/mantis_vp3028.c
··· 1 + /* 2 + Mantis VP-3028 driver 3 + 4 + Copyright (C) 2005, 2006 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 + 21 + #include "mantis_common.h" 22 + #include "mantis_vp3028.h" 23 + 24 + struct zl10353_config mantis_vp3028_config = { 25 + .demod_address = 0x0f, 26 + }; 27 + 28 + #define MANTIS_MODEL_NAME "VP-3028" 29 + #define MANTIS_DEV_TYPE "DVB-T" 30 + 31 + struct mantis_hwconfig vp3028_mantis_config = { 32 + .model_name = MANTIS_MODEL_NAME, 33 + .dev_type = MANTIS_DEV_TYPE, 34 + .ts_size = MANTIS_TS_188, 35 + .baud_rate = MANTIS_BAUD_9600, 36 + .parity = MANTIS_PARITY_NONE, 37 + .bytes = 0, 38 + };
+13
drivers/media/dvb/mantis/mantis_vp3028.h
··· 1 + #ifndef __MANTIS_VP3028_H 2 + #define __MANTIS_VP3028_H 3 + 4 + #include "dvb_frontend.h" 5 + #include "mantis_common.h" 6 + #include "zl10353.h" 7 + 8 + #define MANTIS_VP_3028_DVB_T 0x0028 9 + 10 + extern struct zl10353_config mantis_vp3028_config; 11 + extern struct mantis_hwconfig vp3028_mantis_config; 12 + 13 + #endif /* __MANTIS_VP3028_H */
+3
drivers/media/dvb/mantis/mantis_vp3030.c
··· 32 32 .model_name = MANTIS_MODEL_NAME, 33 33 .dev_type = MANTIS_DEV_TYPE, 34 34 .ts_size = MANTIS_TS_188, 35 + .baud_rate = MANTIS_BAUD_9600, 36 + .parity = MANTIS_PARITY_NONE, 37 + .bytes = 0, 35 38 }; 36 39 37 40 int panasonic_en57h12d5_set_params(struct dvb_frontend *fe,