2 Mantis PCI bridge driver
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
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.
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.
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.
21 #include "mantis_common.h"
22 #include "mantis_core.h"
23 #include "mantis_vp1033.h"
24 #include "mantis_vp1034.h"
25 #include "mantis_vp1041.h"
26 #include "mantis_vp2033.h"
27 #include "mantis_vp2040.h"
28 #include "mantis_vp3030.h"
30 static int read_eeprom_byte(struct mantis_pci
*mantis
, u8
*data
, u8 length
)
33 struct i2c_msg msg
[] = {
47 err
= i2c_transfer(&mantis
->adapter
, msg
, 2);
49 dprintk(verbose
, MANTIS_ERROR
, 1,
50 "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >",
51 err
, data
[0], data
[1]);
59 static int get_mac_address(struct mantis_pci
*mantis
)
63 mantis
->mac_address
[0] = 0x08;
64 err
= read_eeprom_byte(mantis
, &mantis
->mac_address
[0], 6);
66 dprintk(verbose
, MANTIS_ERROR
, 1, "Mantis EEPROM read error");
70 dprintk(verbose
, MANTIS_ERROR
, 0,
71 " MAC Address=[%pM]\n", mantis
->mac_address
);
76 #define MANTIS_MODEL_UNKNOWN "UNKNOWN"
77 #define MANTIS_DEV_UNKNOWN "UNKNOWN"
79 struct mantis_hwconfig unknown_device
= {
80 .model_name
= MANTIS_MODEL_UNKNOWN
,
81 .dev_type
= MANTIS_DEV_UNKNOWN
,
84 static void mantis_load_config(struct mantis_pci
*mantis
)
86 switch (mantis
->subsystem_device
) {
87 case MANTIS_VP_1033_DVB_S
: /* VP-1033 */
88 mantis
->hwconfig
= &vp1033_mantis_config
;
90 case MANTIS_VP_1034_DVB_S
: /* VP-1034 */
91 mantis
->hwconfig
= &vp1034_mantis_config
;
93 case MANTIS_VP_1041_DVB_S2
: /* VP-1041 */
94 case TECHNISAT_SKYSTAR_HD2
:
95 mantis
->hwconfig
= &vp1041_mantis_config
;
97 case MANTIS_VP_2033_DVB_C
: /* VP-2033 */
98 mantis
->hwconfig
= &vp2033_mantis_config
;
100 case MANTIS_VP_2040_DVB_C
: /* VP-2040 */
101 case CINERGY_C
: /* VP-2040 clone */
102 case TECHNISAT_CABLESTAR_HD2
:
103 mantis
->hwconfig
= &vp2040_mantis_config
;
105 case MANTIS_VP_3030_DVB_T
: /* VP-3030 */
106 mantis
->hwconfig
= &vp3030_mantis_config
;
109 mantis
->hwconfig
= &unknown_device
;
114 int mantis_core_init(struct mantis_pci
*mantis
)
118 mantis_load_config(mantis
);
119 dprintk(verbose
, MANTIS_ERROR
, 0, "found a %s PCI %s device on (%02x:%02x.%x),\n",
120 mantis
->hwconfig
->model_name
, mantis
->hwconfig
->dev_type
,
121 mantis
->pdev
->bus
->number
, PCI_SLOT(mantis
->pdev
->devfn
), PCI_FUNC(mantis
->pdev
->devfn
));
122 dprintk(verbose
, MANTIS_ERROR
, 0, " Mantis Rev %d [%04x:%04x], ",
124 mantis
->subsystem_vendor
, mantis
->subsystem_device
);
125 dprintk(verbose
, MANTIS_ERROR
, 0,
126 "irq: %d, latency: %d\n memory: 0x%lx, mmio: 0x%p\n",
127 mantis
->pdev
->irq
, mantis
->latency
,
128 mantis
->mantis_addr
, mantis
->mantis_mmio
);
130 err
= mantis_i2c_init(mantis
);
132 dprintk(verbose
, MANTIS_ERROR
, 1, "Mantis I2C init failed");
135 err
= get_mac_address(mantis
);
137 dprintk(verbose
, MANTIS_ERROR
, 1, "get MAC address failed");
140 err
= mantis_dma_init(mantis
);
142 dprintk(verbose
, MANTIS_ERROR
, 1, "Mantis DMA init failed");
145 err
= mantis_dvb_init(mantis
);
147 dprintk(verbose
, MANTIS_DEBUG
, 1, "Mantis DVB init failed");
150 err
= mantis_uart_init(mantis
);
152 dprintk(verbose
, MANTIS_DEBUG
, 1, "Mantis UART init failed");
159 int mantis_core_exit(struct mantis_pci
*mantis
)
161 mantis_dma_stop(mantis
);
162 dprintk(verbose
, MANTIS_ERROR
, 1, "DMA engine stopping");
164 mantis_uart_exit(mantis
);
165 dprintk(verbose
, MANTIS_ERROR
, 1, "UART exit failed");
167 if (mantis_dma_exit(mantis
) < 0)
168 dprintk(verbose
, MANTIS_ERROR
, 1, "DMA exit failed");
169 if (mantis_dvb_exit(mantis
) < 0)
170 dprintk(verbose
, MANTIS_ERROR
, 1, "DVB exit failed");
171 if (mantis_i2c_exit(mantis
) < 0)
172 dprintk(verbose
, MANTIS_ERROR
, 1, "I2C adapter delete.. failed");
177 /* Turn the given bit on or off. */
178 void gpio_set_bits(struct mantis_pci
*mantis
, u32 bitpos
, u8 value
)
182 cur
= mmread(MANTIS_GPIF_ADDR
);
184 mantis
->gpio_status
= cur
| (1 << bitpos
);
186 mantis
->gpio_status
= cur
& (~(1 << bitpos
));
188 mmwrite(mantis
->gpio_status
, MANTIS_GPIF_ADDR
);
189 mmwrite(0x00, MANTIS_GPIF_DOUT
);
193 /* direction = 0 , no CI passthrough ; 1 , CI passthrough */
194 void mantis_set_direction(struct mantis_pci
*mantis
, int direction
)
199 dprintk(verbose
, MANTIS_DEBUG
, 1, "TS direction setup");
200 if (direction
== 0x01) {