162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _DVB_USB_M920X_H_
362306a36Sopenharmony_ci#define _DVB_USB_M920X_H_
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#define DVB_USB_LOG_PREFIX "m920x"
662306a36Sopenharmony_ci#include "dvb-usb.h"
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#define deb(args...)   dprintk(dvb_usb_m920x_debug,0x01,args)
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define M9206_CORE	0x22
1162306a36Sopenharmony_ci#define M9206_RC_STATE	0xff51
1262306a36Sopenharmony_ci#define M9206_RC_KEY	0xff52
1362306a36Sopenharmony_ci#define M9206_RC_INIT1	0xff54
1462306a36Sopenharmony_ci#define M9206_RC_INIT2	0xff55
1562306a36Sopenharmony_ci#define M9206_FW_GO	0xff69
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define M9206_I2C	0x23
1862306a36Sopenharmony_ci#define M9206_FILTER	0x25
1962306a36Sopenharmony_ci#define M9206_FW	0x30
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define M9206_MAX_FILTERS 8
2262306a36Sopenharmony_ci#define M9206_MAX_ADAPTERS 4
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci/*
2562306a36Sopenharmony_cisequences found in logs:
2662306a36Sopenharmony_ci[index value]
2762306a36Sopenharmony_ci0x80 write addr
2862306a36Sopenharmony_ci(0x00 out byte)*
2962306a36Sopenharmony_ci0x40 out byte
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci0x80 write addr
3262306a36Sopenharmony_ci(0x00 out byte)*
3362306a36Sopenharmony_ci0x80 read addr
3462306a36Sopenharmony_ci(0x21 in byte)*
3562306a36Sopenharmony_ci0x60 in byte
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_cithis sequence works:
3862306a36Sopenharmony_ci0x80 read addr
3962306a36Sopenharmony_ci(0x21 in byte)*
4062306a36Sopenharmony_ci0x60 in byte
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciGuess at API of the I2C function:
4362306a36Sopenharmony_ciI2C operation is done one byte at a time with USB control messages.  The
4462306a36Sopenharmony_ciindex the messages is sent to is made up of a set of flags that control
4562306a36Sopenharmony_cithe I2C bus state:
4662306a36Sopenharmony_ci0x80:  Send START condition.  After a START condition, one would normally
4762306a36Sopenharmony_ci       always send the 7-bit slave I2C address as the 7 MSB, followed by
4862306a36Sopenharmony_ci       the read/write bit as the LSB.
4962306a36Sopenharmony_ci0x40:  Send STOP condition.  This should be set on the last byte of an
5062306a36Sopenharmony_ci       I2C transaction.
5162306a36Sopenharmony_ci0x20:  Read a byte from the slave.  As opposed to writing a byte to the
5262306a36Sopenharmony_ci       slave.  The slave will normally not produce any data unless you
5362306a36Sopenharmony_ci       set the R/W bit to 1 when sending the slave's address after the
5462306a36Sopenharmony_ci       START condition.
5562306a36Sopenharmony_ci0x01:  Respond with ACK, as opposed to a NACK.  For a multi-byte read,
5662306a36Sopenharmony_ci       the master should send an ACK, that is pull SDA low during the 9th
5762306a36Sopenharmony_ci       clock cycle, after every byte but the last.  This flags only makes
5862306a36Sopenharmony_ci       sense when bit 0x20 is set, indicating a read.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciWhat any other bits might mean, or how to get the slave's ACK/NACK
6162306a36Sopenharmony_ciresponse to a write, is unknown.
6262306a36Sopenharmony_ci*/
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cistruct m920x_state {
6562306a36Sopenharmony_ci	u16 filters[M9206_MAX_ADAPTERS][M9206_MAX_FILTERS];
6662306a36Sopenharmony_ci	int filtering_enabled[M9206_MAX_ADAPTERS];
6762306a36Sopenharmony_ci	int rep_count;
6862306a36Sopenharmony_ci};
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* Initialisation data for the m920x
7162306a36Sopenharmony_ci */
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_cistruct m920x_inits {
7462306a36Sopenharmony_ci	u16 address;
7562306a36Sopenharmony_ci	u8  data;
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#endif
79