18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _DVB_USB_M920X_H_ 38c2ecf20Sopenharmony_ci#define _DVB_USB_M920X_H_ 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#define DVB_USB_LOG_PREFIX "m920x" 68c2ecf20Sopenharmony_ci#include "dvb-usb.h" 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#define deb(args...) dprintk(dvb_usb_m920x_debug,0x01,args) 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci#define M9206_CORE 0x22 118c2ecf20Sopenharmony_ci#define M9206_RC_STATE 0xff51 128c2ecf20Sopenharmony_ci#define M9206_RC_KEY 0xff52 138c2ecf20Sopenharmony_ci#define M9206_RC_INIT1 0xff54 148c2ecf20Sopenharmony_ci#define M9206_RC_INIT2 0xff55 158c2ecf20Sopenharmony_ci#define M9206_FW_GO 0xff69 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define M9206_I2C 0x23 188c2ecf20Sopenharmony_ci#define M9206_FILTER 0x25 198c2ecf20Sopenharmony_ci#define M9206_FW 0x30 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci#define M9206_MAX_FILTERS 8 228c2ecf20Sopenharmony_ci#define M9206_MAX_ADAPTERS 4 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci/* 258c2ecf20Sopenharmony_cisequences found in logs: 268c2ecf20Sopenharmony_ci[index value] 278c2ecf20Sopenharmony_ci0x80 write addr 288c2ecf20Sopenharmony_ci(0x00 out byte)* 298c2ecf20Sopenharmony_ci0x40 out byte 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci0x80 write addr 328c2ecf20Sopenharmony_ci(0x00 out byte)* 338c2ecf20Sopenharmony_ci0x80 read addr 348c2ecf20Sopenharmony_ci(0x21 in byte)* 358c2ecf20Sopenharmony_ci0x60 in byte 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cithis sequence works: 388c2ecf20Sopenharmony_ci0x80 read addr 398c2ecf20Sopenharmony_ci(0x21 in byte)* 408c2ecf20Sopenharmony_ci0x60 in byte 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ciGuess at API of the I2C function: 438c2ecf20Sopenharmony_ciI2C operation is done one byte at a time with USB control messages. The 448c2ecf20Sopenharmony_ciindex the messages is sent to is made up of a set of flags that control 458c2ecf20Sopenharmony_cithe I2C bus state: 468c2ecf20Sopenharmony_ci0x80: Send START condition. After a START condition, one would normally 478c2ecf20Sopenharmony_ci always send the 7-bit slave I2C address as the 7 MSB, followed by 488c2ecf20Sopenharmony_ci the read/write bit as the LSB. 498c2ecf20Sopenharmony_ci0x40: Send STOP condition. This should be set on the last byte of an 508c2ecf20Sopenharmony_ci I2C transaction. 518c2ecf20Sopenharmony_ci0x20: Read a byte from the slave. As opposed to writing a byte to the 528c2ecf20Sopenharmony_ci slave. The slave will normally not produce any data unless you 538c2ecf20Sopenharmony_ci set the R/W bit to 1 when sending the slave's address after the 548c2ecf20Sopenharmony_ci START condition. 558c2ecf20Sopenharmony_ci0x01: Respond with ACK, as opposed to a NACK. For a multi-byte read, 568c2ecf20Sopenharmony_ci the master should send an ACK, that is pull SDA low during the 9th 578c2ecf20Sopenharmony_ci clock cycle, after every byte but the last. This flags only makes 588c2ecf20Sopenharmony_ci sense when bit 0x20 is set, indicating a read. 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ciWhat any other bits might mean, or how to get the slave's ACK/NACK 618c2ecf20Sopenharmony_ciresponse to a write, is unknown. 628c2ecf20Sopenharmony_ci*/ 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_cistruct m920x_state { 658c2ecf20Sopenharmony_ci u16 filters[M9206_MAX_ADAPTERS][M9206_MAX_FILTERS]; 668c2ecf20Sopenharmony_ci int filtering_enabled[M9206_MAX_ADAPTERS]; 678c2ecf20Sopenharmony_ci int rep_count; 688c2ecf20Sopenharmony_ci}; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci/* Initialisation data for the m920x 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistruct m920x_inits { 748c2ecf20Sopenharmony_ci u16 address; 758c2ecf20Sopenharmony_ci u8 data; 768c2ecf20Sopenharmony_ci}; 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci#endif 79