mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 10:04:12 +08:00
22e743898d
This huge patch bumps the ddbridge driver to version 0.9.29. Compared to the vendor driver package, DD OctoNET including GTL link support, and all DVB-C Modulator card support has been removed since this requires large changes to the underlying DVB core API, which should eventually be done separately, and, after that, the functionality/device support can be added back rather easy. While the diff is rather large, the bump is mostly a big refactor of all data structures. Yet, the MSI support (message signaled interrupts) is greatly improved, also all currently available CI single/duo bridge cards are fully supported. More changes compared to the upstream driver: - the DDB_USE_WORKER flag/define was removed, kernel worker functionality will be used. - coding style is properly fixed (zero complaints from checkpatch) - all (not much though) CamelCase has been fixed to kernel_case - (private) IOCTLs temporarily removed (which are mainly used to provide rarely-used FPGA update functionality) Great care has been taken to keep all previous changes and fixes (e.g. kernel logging via dev_*(), pointer annotations and such) intact. Permission to reuse and mainline the driver code was formally granted by Ralph Metzler <rjkm@metzlerbros.de>. Signed-off-by: Daniel Scheller <d.scheller@gmx.net> Tested-by: Richard Scobie <r.scobie@clear.net.nz> Tested-by: Jasmin Jessich <jasmin@anw.at> Tested-by: Dietmar Spingler <d_spingler@freenet.de> Tested-by: Manfred Knick <Manfred.Knick@t-online.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
113 lines
3.2 KiB
C
113 lines
3.2 KiB
C
/*
|
|
* ddbridge-i2c.c: Digital Devices bridge i2c driver
|
|
*
|
|
* Copyright (C) 2010-2017 Digital Devices GmbH
|
|
* Ralph Metzler <rjkm@metzlerbros.de>
|
|
* Marcus Metzler <mocm@metzlerbros.de>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* version 2 only, as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#ifndef __DDBRIDGE_I2C_H__
|
|
#define __DDBRIDGE_I2C_H__
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include "ddbridge.h"
|
|
|
|
/******************************************************************************/
|
|
|
|
void ddb_i2c_release(struct ddb *dev);
|
|
int ddb_i2c_init(struct ddb *dev);
|
|
|
|
/******************************************************************************/
|
|
|
|
static int __maybe_unused i2c_io(struct i2c_adapter *adapter, u8 adr,
|
|
u8 *wbuf, u32 wlen, u8 *rbuf, u32 rlen)
|
|
{
|
|
struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
|
|
.buf = wbuf, .len = wlen },
|
|
{ .addr = adr, .flags = I2C_M_RD,
|
|
.buf = rbuf, .len = rlen } };
|
|
|
|
return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
|
|
}
|
|
|
|
static int __maybe_unused i2c_write(struct i2c_adapter *adap, u8 adr,
|
|
u8 *data, int len)
|
|
{
|
|
struct i2c_msg msg = { .addr = adr, .flags = 0,
|
|
.buf = data, .len = len };
|
|
|
|
return (i2c_transfer(adap, &msg, 1) == 1) ? 0 : -1;
|
|
}
|
|
|
|
static int __maybe_unused i2c_read(struct i2c_adapter *adapter, u8 adr, u8 *val)
|
|
{
|
|
struct i2c_msg msgs[1] = { { .addr = adr, .flags = I2C_M_RD,
|
|
.buf = val, .len = 1 } };
|
|
|
|
return (i2c_transfer(adapter, msgs, 1) == 1) ? 0 : -1;
|
|
}
|
|
|
|
static int __maybe_unused i2c_read_regs(struct i2c_adapter *adapter,
|
|
u8 adr, u8 reg, u8 *val, u8 len)
|
|
{
|
|
struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
|
|
.buf = ®, .len = 1 },
|
|
{ .addr = adr, .flags = I2C_M_RD,
|
|
.buf = val, .len = len } };
|
|
|
|
return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
|
|
}
|
|
|
|
static int __maybe_unused i2c_read_regs16(struct i2c_adapter *adapter,
|
|
u8 adr, u16 reg, u8 *val, u8 len)
|
|
{
|
|
u8 msg[2] = { reg >> 8, reg & 0xff };
|
|
struct i2c_msg msgs[2] = { { .addr = adr, .flags = 0,
|
|
.buf = msg, .len = 2 },
|
|
{ .addr = adr, .flags = I2C_M_RD,
|
|
.buf = val, .len = len } };
|
|
|
|
return (i2c_transfer(adapter, msgs, 2) == 2) ? 0 : -1;
|
|
}
|
|
|
|
static int __maybe_unused i2c_write_reg16(struct i2c_adapter *adap,
|
|
u8 adr, u16 reg, u8 val)
|
|
{
|
|
u8 msg[3] = { reg >> 8, reg & 0xff, val };
|
|
|
|
return i2c_write(adap, adr, msg, 3);
|
|
}
|
|
|
|
static int __maybe_unused i2c_write_reg(struct i2c_adapter *adap,
|
|
u8 adr, u8 reg, u8 val)
|
|
{
|
|
u8 msg[2] = { reg, val };
|
|
|
|
return i2c_write(adap, adr, msg, 2);
|
|
}
|
|
|
|
static int __maybe_unused i2c_read_reg16(struct i2c_adapter *adapter,
|
|
u8 adr, u16 reg, u8 *val)
|
|
{
|
|
return i2c_read_regs16(adapter, adr, reg, val, 1);
|
|
}
|
|
|
|
static int __maybe_unused i2c_read_reg(struct i2c_adapter *adapter,
|
|
u8 adr, u8 reg, u8 *val)
|
|
{
|
|
return i2c_read_regs(adapter, adr, reg, val, 1);
|
|
}
|
|
|
|
#endif /* __DDBRIDGE_I2C_H__ */
|