add cmmb moudle file directory.
[firefly-linux-kernel-4.4.55.git] / drivers / cmmb / siano / smsspicommon.h
1 /****************************************************************
2
3 Siano Mobile Silicon, Inc.
4 MDTV receiver kernel modules.
5 Copyright (C) 2006-2008, Uri Shkolnik
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 2 of the License, or
10 (at your option) any later version.
11
12  This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 ****************************************************************/
21 #ifndef _SMS_SPI_COMMON_H_
22 #define _SMS_SPI_COMMON_H_
23
24 #define RX_PACKET_SIZE                  0x1000
25 #define SPI_PACKET_SIZE_BITS            8
26 #define SPI_PACKET_SIZE                 (1<<SPI_PACKET_SIZE_BITS)
27 #define SPI_MAX_CTRL_MSG_SIZE           0x100
28
29 #define MSG_HDR_FLAG_SPLIT_MSG_HDR      0x0004
30 #define MSG_HDR_LEN                     8
31
32 enum _spi_rx_state {
33         RxsWait_a5 = 0,
34         RxsWait_5a,
35         RxsWait_e7,
36         RxsWait_7e,
37         RxsTypeH,
38         RxsTypeL,
39         RxsGetSrcId,
40         RxsGetDstId,
41         RxsGetLenL,
42         RxsGetLenH,
43         RxsFlagsL,
44         RxsFlagsH,
45         RxsData
46 };
47
48 struct _rx_buffer_st {
49         void *ptr;
50         unsigned long phy_addr;
51 };
52
53 struct _rx_packet_request {
54         struct _rx_buffer_st *msg_buf;
55         int msg_offset;
56         int msg_len;
57         int msg_flags;
58 };
59
60 struct _spi_dev_cb_st{
61         void (*transfer_data_cb) (void *context, unsigned char *, unsigned long,
62                                   unsigned char *, unsigned long, int);
63         void (*msg_found_cb) (void *, void *, int, int);
64         struct _rx_buffer_st *(*allocate_rx_buf) (void *, int);
65         void (*free_rx_buf) (void *, struct _rx_buffer_st *);
66 };
67
68 struct _spi_dev {
69         void *context;
70         void *phy_context;
71         struct _spi_dev_cb_st cb;
72         char *rxbuf;
73         enum _spi_rx_state rxState;
74         struct _rx_packet_request rxPacket;
75         char *internal_tx_buf;
76 };
77
78 struct _spi_msg {
79         char *buf;
80         unsigned long buf_phy_addr;
81         int len;
82 };
83
84 void smsspi_common_transfer_msg(struct _spi_dev *dev, struct _spi_msg *txmsg,
85                                 int padding_allowed);
86 int smsspicommon_init(struct _spi_dev *dev, void *contex, void *phy_context,
87                       struct _spi_dev_cb_st *cb);
88
89 #if defined HEXDUMP_DEBUG && defined SPIBUS_DEBUG
90 /*! dump a human readable print of a binary buffer */
91 void smsspi_khexdump(char *buf, int len);
92 #else
93 #define smsspi_khexdump(buf, len)
94 #endif
95
96 #endif /*_SMS_SPI_COMMON_H_*/