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 <linux/kernel.h>
22 #include <linux/i2c.h>
24 #include <linux/signal.h>
25 #include <linux/sched.h>
26 #include <linux/interrupt.h>
30 #include "dvb_demux.h"
31 #include "dvb_frontend.h"
34 #include "mantis_common.h"
35 #include "mantis_reg.h"
36 #include "mantis_ioc.h"
38 static int read_eeprom_bytes(struct mantis_pci
*mantis
, u8 reg
, u8
*data
, u8 length
)
40 struct i2c_adapter
*adapter
= &mantis
->adapter
;
44 struct i2c_msg msg
[] = {
45 { .addr
= 0x50, .flags
= 0, .buf
= &buf
, .len
= 1 },
46 { .addr
= 0x50, .flags
= I2C_M_RD
, .buf
= data
, .len
= length
},
49 err
= i2c_transfer(adapter
, msg
, 2);
51 dprintk(MANTIS_ERROR
, 1, "ERROR: i2c read: < err=%i d0=0x%02x d1=0x%02x >",
52 err
, data
[0], data
[1]);
59 int mantis_get_mac(struct mantis_pci
*mantis
)
64 err
= read_eeprom_bytes(mantis
, 0x08, mac_addr
, 6);
66 dprintk(MANTIS_ERROR
, 1, "ERROR: Mantis EEPROM read error <%d>", err
);
71 dprintk(MANTIS_ERROR
, 0,
72 " MAC Address=[%02x:%02x:%02x:%02x:%02x:%02x]\n",
82 EXPORT_SYMBOL_GPL(mantis_get_mac
);
84 /* Turn the given bit on or off. */
85 void gpio_set_bits(struct mantis_pci
*mantis
, u32 bitpos
, u8 value
)
89 dprintk(MANTIS_DEBUG
, 1, "Set Bit <%d> to <%d>", bitpos
, value
);
90 cur
= mmread(MANTIS_GPIF_ADDR
);
92 mantis
->gpio_status
= cur
| (1 << bitpos
);
94 mantis
->gpio_status
= cur
& (~(1 << bitpos
));
96 dprintk(MANTIS_DEBUG
, 1, "GPIO Value <%02x>", mantis
->gpio_status
);
97 mmwrite(mantis
->gpio_status
, MANTIS_GPIF_ADDR
);
98 mmwrite(0x00, MANTIS_GPIF_DOUT
);
100 EXPORT_SYMBOL_GPL(gpio_set_bits
);
102 int mantis_stream_control(struct mantis_pci
*mantis
, enum mantis_stream_control stream_ctl
)
106 reg
= mmread(MANTIS_CONTROL
);
107 switch (stream_ctl
) {
109 dprintk(MANTIS_DEBUG
, 1, "Set stream to HIF");
110 reg
&= 0xff - MANTIS_BYPASS
;
111 mmwrite(reg
, MANTIS_CONTROL
);
112 reg
|= MANTIS_BYPASS
;
113 mmwrite(reg
, MANTIS_CONTROL
);
117 dprintk(MANTIS_DEBUG
, 1, "Set stream to CAM");
118 reg
|= MANTIS_BYPASS
;
119 mmwrite(reg
, MANTIS_CONTROL
);
120 reg
&= 0xff - MANTIS_BYPASS
;
121 mmwrite(reg
, MANTIS_CONTROL
);
124 dprintk(MANTIS_ERROR
, 1, "Unknown MODE <%02x>", stream_ctl
);
130 EXPORT_SYMBOL_GPL(mantis_stream_control
);