1 /*
2  * ddbridge-regs.h: Digital Devices PCIe bridge driver
3  *
4  * Copyright (C) 2010-2017 Digital Devices GmbH
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * version 2 only, as published by the Free Software Foundation.
9  *
10  *
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.
15  *
16  * To obtain the license, point your browser to
17  * http://www.gnu.org/copyleft/gpl.html
18  */
19 
20 /* ------------------------------------------------------------------------- */
21 /* SPI Controller */
22 
23 #define SPI_CONTROL     0x10
24 #define SPI_DATA        0x14
25 
26 /* ------------------------------------------------------------------------- */
27 /* GPIO */
28 
29 #define GPIO_OUTPUT      0x20
30 #define GPIO_INPUT       0x24
31 #define GPIO_DIRECTION   0x28
32 
33 /* ------------------------------------------------------------------------- */
34 /* MDIO */
35 
36 #define MDIO_CTRL        0x20
37 #define MDIO_ADR         0x24
38 #define MDIO_REG         0x28
39 #define MDIO_VAL         0x2C
40 
41 /* ------------------------------------------------------------------------- */
42 
43 #define BOARD_CONTROL    0x30
44 
45 /* ------------------------------------------------------------------------- */
46 
47 /* Interrupt controller
48  * How many MSI's are available depends on HW (Min 2 max 8)
49  * How many are usable also depends on Host platform
50  */
51 
52 #define INTERRUPT_BASE   (0x40)
53 
54 #define INTERRUPT_ENABLE (INTERRUPT_BASE + 0x00)
55 #define MSI1_ENABLE      (INTERRUPT_BASE + 0x04)
56 #define MSI2_ENABLE      (INTERRUPT_BASE + 0x08)
57 #define MSI3_ENABLE      (INTERRUPT_BASE + 0x0C)
58 #define MSI4_ENABLE      (INTERRUPT_BASE + 0x10)
59 #define MSI5_ENABLE      (INTERRUPT_BASE + 0x14)
60 #define MSI6_ENABLE      (INTERRUPT_BASE + 0x18)
61 #define MSI7_ENABLE      (INTERRUPT_BASE + 0x1C)
62 
63 #define INTERRUPT_STATUS (INTERRUPT_BASE + 0x20)
64 #define INTERRUPT_ACK    (INTERRUPT_BASE + 0x20)
65 
66 /* Temperature Monitor ( 2x LM75A @ 0x90,0x92 I2c ) */
67 #define TEMPMON_BASE			(0x1c0)
68 #define TEMPMON_CONTROL			(TEMPMON_BASE + 0x00)
69 
70 #define TEMPMON_CONTROL_AUTOSCAN	(0x00000002)
71 #define TEMPMON_CONTROL_INTENABLE	(0x00000004)
72 #define TEMPMON_CONTROL_OVERTEMP	(0x00008000)
73 
74 /* SHORT Temperature in Celsius x 256 */
75 #define TEMPMON_SENSOR0			(TEMPMON_BASE + 0x04)
76 #define TEMPMON_SENSOR1			(TEMPMON_BASE + 0x08)
77 
78 #define TEMPMON_FANCONTROL		(TEMPMON_BASE + 0x10)
79 
80 /* ------------------------------------------------------------------------- */
81 /* I2C Master Controller */
82 
83 #define I2C_COMMAND     (0x00)
84 #define I2C_TIMING      (0x04)
85 #define I2C_TASKLENGTH  (0x08)     /* High read, low write */
86 #define I2C_TASKADDRESS (0x0C)     /* High read, low write */
87 #define I2C_MONITOR     (0x1C)
88 
89 #define I2C_SPEED_400   (0x04030404)
90 #define I2C_SPEED_100   (0x13121313)
91 
92 /* ------------------------------------------------------------------------- */
93 /* DMA  Controller */
94 
95 #define DMA_BASE_WRITE        (0x100)
96 #define DMA_BASE_READ         (0x140)
97 
98 #define TS_CONTROL(_io)         (_io->regs + 0x00)
99 #define TS_CONTROL2(_io)        (_io->regs + 0x04)
100 
101 /* ------------------------------------------------------------------------- */
102 /* DMA  Buffer */
103 
104 #define DMA_BUFFER_CONTROL(_dma)       (_dma->regs + 0x00)
105 #define DMA_BUFFER_ACK(_dma)           (_dma->regs + 0x04)
106 #define DMA_BUFFER_CURRENT(_dma)       (_dma->regs + 0x08)
107 #define DMA_BUFFER_SIZE(_dma)          (_dma->regs + 0x0c)
108 
109 /* ------------------------------------------------------------------------- */
110 /* CI Interface (only CI-Bridge) */
111 
112 #define CI_BASE                     (0x400)
113 #define CI_CONTROL(i)               (CI_BASE + (i) * 32 + 0x00)
114 
115 #define CI_DO_ATTRIBUTE_RW(i)       (CI_BASE + (i) * 32 + 0x04)
116 #define CI_DO_IO_RW(i)              (CI_BASE + (i) * 32 + 0x08)
117 #define CI_READDATA(i)              (CI_BASE + (i) * 32 + 0x0c)
118 #define CI_DO_READ_ATTRIBUTES(i)    (CI_BASE + (i) * 32 + 0x10)
119 
120 #define CI_RESET_CAM                    (0x00000001)
121 #define CI_POWER_ON                     (0x00000002)
122 #define CI_ENABLE                       (0x00000004)
123 #define CI_BYPASS_DISABLE               (0x00000010)
124 
125 #define CI_CAM_READY                    (0x00010000)
126 #define CI_CAM_DETECT                   (0x00020000)
127 #define CI_READY                        (0x80000000)
128 
129 #define CI_READ_CMD                     (0x40000000)
130 #define CI_WRITE_CMD                    (0x80000000)
131 
132 #define CI_BUFFER_BASE                  (0x3000)
133 #define CI_BUFFER_SIZE                  (0x0800)
134 
135 #define CI_BUFFER(i)                  (CI_BUFFER_BASE + (i) * CI_BUFFER_SIZE)
136 
137 /* ------------------------------------------------------------------------- */
138 /* LNB commands (mxl5xx / Max S8) */
139 
140 #define LNB_BASE			(0x400)
141 #define LNB_CONTROL(i)			(LNB_BASE + (i) * 0x20 + 0x00)
142 
143 #define LNB_CMD				(7ULL <<  0)
144 #define LNB_CMD_NOP			0
145 #define LNB_CMD_INIT			1
146 #define LNB_CMD_LOW			3
147 #define LNB_CMD_HIGH			4
148 #define LNB_CMD_OFF			5
149 #define LNB_CMD_DISEQC			6
150 
151 #define LNB_BUSY			(1ULL <<  4)
152 #define LNB_TONE			(1ULL << 15)
153 
154 #define LNB_BUF_LEVEL(i)		(LNB_BASE + (i) * 0x20 + 0x10)
155 #define LNB_BUF_WRITE(i)		(LNB_BASE + (i) * 0x20 + 0x14)
156 
157