162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Chip register definitions for PCILynx chipset.  Based on pcilynx.h
462306a36Sopenharmony_ci * from the Linux 1394 drivers, but modified a bit so the names here
562306a36Sopenharmony_ci * match the specification exactly (even though they have weird names,
662306a36Sopenharmony_ci * like xxx_OVER_FLOW, or arbitrary abbreviations like SNTRJ for "sent
762306a36Sopenharmony_ci * reject" etc.)
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#define PCILYNX_MAX_REGISTER     0xfff
1162306a36Sopenharmony_ci#define PCILYNX_MAX_MEMORY       0xffff
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define PCI_LATENCY_CACHELINE             0x0c
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define MISC_CONTROL                      0x40
1662306a36Sopenharmony_ci#define MISC_CONTROL_SWRESET              (1<<0)
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define SERIAL_EEPROM_CONTROL             0x44
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define PCI_INT_STATUS                    0x48
2162306a36Sopenharmony_ci#define PCI_INT_ENABLE                    0x4c
2262306a36Sopenharmony_ci/* status and enable have identical bit numbers */
2362306a36Sopenharmony_ci#define PCI_INT_INT_PEND                  (1<<31)
2462306a36Sopenharmony_ci#define PCI_INT_FRC_INT                   (1<<30)
2562306a36Sopenharmony_ci#define PCI_INT_SLV_ADR_PERR              (1<<28)
2662306a36Sopenharmony_ci#define PCI_INT_SLV_DAT_PERR              (1<<27)
2762306a36Sopenharmony_ci#define PCI_INT_MST_DAT_PERR              (1<<26)
2862306a36Sopenharmony_ci#define PCI_INT_MST_DEV_TO                (1<<25)
2962306a36Sopenharmony_ci#define PCI_INT_INT_SLV_TO                (1<<23)
3062306a36Sopenharmony_ci#define PCI_INT_AUX_TO                    (1<<18)
3162306a36Sopenharmony_ci#define PCI_INT_AUX_INT                   (1<<17)
3262306a36Sopenharmony_ci#define PCI_INT_P1394_INT                 (1<<16)
3362306a36Sopenharmony_ci#define PCI_INT_DMA4_PCL                  (1<<9)
3462306a36Sopenharmony_ci#define PCI_INT_DMA4_HLT                  (1<<8)
3562306a36Sopenharmony_ci#define PCI_INT_DMA3_PCL                  (1<<7)
3662306a36Sopenharmony_ci#define PCI_INT_DMA3_HLT                  (1<<6)
3762306a36Sopenharmony_ci#define PCI_INT_DMA2_PCL                  (1<<5)
3862306a36Sopenharmony_ci#define PCI_INT_DMA2_HLT                  (1<<4)
3962306a36Sopenharmony_ci#define PCI_INT_DMA1_PCL                  (1<<3)
4062306a36Sopenharmony_ci#define PCI_INT_DMA1_HLT                  (1<<2)
4162306a36Sopenharmony_ci#define PCI_INT_DMA0_PCL                  (1<<1)
4262306a36Sopenharmony_ci#define PCI_INT_DMA0_HLT                  (1<<0)
4362306a36Sopenharmony_ci/* all DMA interrupts combined: */
4462306a36Sopenharmony_ci#define PCI_INT_DMA_ALL                   0x3ff
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#define PCI_INT_DMA_HLT(chan)             (1 << (chan * 2))
4762306a36Sopenharmony_ci#define PCI_INT_DMA_PCL(chan)             (1 << (chan * 2 + 1))
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define LBUS_ADDR                         0xb4
5062306a36Sopenharmony_ci#define LBUS_ADDR_SEL_RAM                 (0x0<<16)
5162306a36Sopenharmony_ci#define LBUS_ADDR_SEL_ROM                 (0x1<<16)
5262306a36Sopenharmony_ci#define LBUS_ADDR_SEL_AUX                 (0x2<<16)
5362306a36Sopenharmony_ci#define LBUS_ADDR_SEL_ZV                  (0x3<<16)
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#define GPIO_CTRL_A                       0xb8
5662306a36Sopenharmony_ci#define GPIO_CTRL_B                       0xbc
5762306a36Sopenharmony_ci#define GPIO_DATA_BASE                    0xc0
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define DMA_BREG(base, chan)              (base + chan * 0x20)
6062306a36Sopenharmony_ci#define DMA_SREG(base, chan)              (base + chan * 0x10)
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#define PCL_NEXT_INVALID (1<<0)
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci/* transfer commands */
6562306a36Sopenharmony_ci#define PCL_CMD_RCV            (0x1<<24)
6662306a36Sopenharmony_ci#define PCL_CMD_RCV_AND_UPDATE (0xa<<24)
6762306a36Sopenharmony_ci#define PCL_CMD_XMT            (0x2<<24)
6862306a36Sopenharmony_ci#define PCL_CMD_UNFXMT         (0xc<<24)
6962306a36Sopenharmony_ci#define PCL_CMD_PCI_TO_LBUS    (0x8<<24)
7062306a36Sopenharmony_ci#define PCL_CMD_LBUS_TO_PCI    (0x9<<24)
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci/* aux commands */
7362306a36Sopenharmony_ci#define PCL_CMD_NOP            (0x0<<24)
7462306a36Sopenharmony_ci#define PCL_CMD_LOAD           (0x3<<24)
7562306a36Sopenharmony_ci#define PCL_CMD_STOREQ         (0x4<<24)
7662306a36Sopenharmony_ci#define PCL_CMD_STORED         (0xb<<24)
7762306a36Sopenharmony_ci#define PCL_CMD_STORE0         (0x5<<24)
7862306a36Sopenharmony_ci#define PCL_CMD_STORE1         (0x6<<24)
7962306a36Sopenharmony_ci#define PCL_CMD_COMPARE        (0xe<<24)
8062306a36Sopenharmony_ci#define PCL_CMD_SWAP_COMPARE   (0xf<<24)
8162306a36Sopenharmony_ci#define PCL_CMD_ADD            (0xd<<24)
8262306a36Sopenharmony_ci#define PCL_CMD_BRANCH         (0x7<<24)
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci/* BRANCH condition codes */
8562306a36Sopenharmony_ci#define PCL_COND_DMARDY_SET    (0x1<<20)
8662306a36Sopenharmony_ci#define PCL_COND_DMARDY_CLEAR  (0x2<<20)
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci#define PCL_GEN_INTR           (1<<19)
8962306a36Sopenharmony_ci#define PCL_LAST_BUFF          (1<<18)
9062306a36Sopenharmony_ci#define PCL_LAST_CMD           (PCL_LAST_BUFF)
9162306a36Sopenharmony_ci#define PCL_WAITSTAT           (1<<17)
9262306a36Sopenharmony_ci#define PCL_BIGENDIAN          (1<<16)
9362306a36Sopenharmony_ci#define PCL_ISOMODE            (1<<12)
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci#define DMA0_PREV_PCL                     0x100
9662306a36Sopenharmony_ci#define DMA1_PREV_PCL                     0x120
9762306a36Sopenharmony_ci#define DMA2_PREV_PCL                     0x140
9862306a36Sopenharmony_ci#define DMA3_PREV_PCL                     0x160
9962306a36Sopenharmony_ci#define DMA4_PREV_PCL                     0x180
10062306a36Sopenharmony_ci#define DMA_PREV_PCL(chan)                (DMA_BREG(DMA0_PREV_PCL, chan))
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define DMA0_CURRENT_PCL                  0x104
10362306a36Sopenharmony_ci#define DMA1_CURRENT_PCL                  0x124
10462306a36Sopenharmony_ci#define DMA2_CURRENT_PCL                  0x144
10562306a36Sopenharmony_ci#define DMA3_CURRENT_PCL                  0x164
10662306a36Sopenharmony_ci#define DMA4_CURRENT_PCL                  0x184
10762306a36Sopenharmony_ci#define DMA_CURRENT_PCL(chan)             (DMA_BREG(DMA0_CURRENT_PCL, chan))
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#define DMA0_CHAN_STAT                    0x10c
11062306a36Sopenharmony_ci#define DMA1_CHAN_STAT                    0x12c
11162306a36Sopenharmony_ci#define DMA2_CHAN_STAT                    0x14c
11262306a36Sopenharmony_ci#define DMA3_CHAN_STAT                    0x16c
11362306a36Sopenharmony_ci#define DMA4_CHAN_STAT                    0x18c
11462306a36Sopenharmony_ci#define DMA_CHAN_STAT(chan)               (DMA_BREG(DMA0_CHAN_STAT, chan))
11562306a36Sopenharmony_ci/* CHAN_STATUS registers share bits */
11662306a36Sopenharmony_ci#define DMA_CHAN_STAT_SELFID              (1<<31)
11762306a36Sopenharmony_ci#define DMA_CHAN_STAT_ISOPKT              (1<<30)
11862306a36Sopenharmony_ci#define DMA_CHAN_STAT_PCIERR              (1<<29)
11962306a36Sopenharmony_ci#define DMA_CHAN_STAT_PKTERR              (1<<28)
12062306a36Sopenharmony_ci#define DMA_CHAN_STAT_PKTCMPL             (1<<27)
12162306a36Sopenharmony_ci#define DMA_CHAN_STAT_SPECIALACK          (1<<14)
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci#define DMA0_CHAN_CTRL                    0x110
12462306a36Sopenharmony_ci#define DMA1_CHAN_CTRL                    0x130
12562306a36Sopenharmony_ci#define DMA2_CHAN_CTRL                    0x150
12662306a36Sopenharmony_ci#define DMA3_CHAN_CTRL                    0x170
12762306a36Sopenharmony_ci#define DMA4_CHAN_CTRL                    0x190
12862306a36Sopenharmony_ci#define DMA_CHAN_CTRL(chan)               (DMA_BREG(DMA0_CHAN_CTRL, chan))
12962306a36Sopenharmony_ci/* CHAN_CTRL registers share bits */
13062306a36Sopenharmony_ci#define DMA_CHAN_CTRL_ENABLE              (1<<31)
13162306a36Sopenharmony_ci#define DMA_CHAN_CTRL_BUSY                (1<<30)
13262306a36Sopenharmony_ci#define DMA_CHAN_CTRL_LINK                (1<<29)
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci#define DMA0_READY                        0x114
13562306a36Sopenharmony_ci#define DMA1_READY                        0x134
13662306a36Sopenharmony_ci#define DMA2_READY                        0x154
13762306a36Sopenharmony_ci#define DMA3_READY                        0x174
13862306a36Sopenharmony_ci#define DMA4_READY                        0x194
13962306a36Sopenharmony_ci#define DMA_READY(chan)                   (DMA_BREG(DMA0_READY, chan))
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci#define DMA_GLOBAL_REGISTER               0x908
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci#define FIFO_SIZES                        0xa00
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define FIFO_CONTROL                      0xa10
14662306a36Sopenharmony_ci#define FIFO_CONTROL_GRF_FLUSH            (1<<4)
14762306a36Sopenharmony_ci#define FIFO_CONTROL_ITF_FLUSH            (1<<3)
14862306a36Sopenharmony_ci#define FIFO_CONTROL_ATF_FLUSH            (1<<2)
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci#define FIFO_XMIT_THRESHOLD               0xa14
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci#define DMA0_WORD0_CMP_VALUE              0xb00
15362306a36Sopenharmony_ci#define DMA1_WORD0_CMP_VALUE              0xb10
15462306a36Sopenharmony_ci#define DMA2_WORD0_CMP_VALUE              0xb20
15562306a36Sopenharmony_ci#define DMA3_WORD0_CMP_VALUE              0xb30
15662306a36Sopenharmony_ci#define DMA4_WORD0_CMP_VALUE              0xb40
15762306a36Sopenharmony_ci#define DMA_WORD0_CMP_VALUE(chan)	(DMA_SREG(DMA0_WORD0_CMP_VALUE, chan))
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define DMA0_WORD0_CMP_ENABLE             0xb04
16062306a36Sopenharmony_ci#define DMA1_WORD0_CMP_ENABLE             0xb14
16162306a36Sopenharmony_ci#define DMA2_WORD0_CMP_ENABLE             0xb24
16262306a36Sopenharmony_ci#define DMA3_WORD0_CMP_ENABLE             0xb34
16362306a36Sopenharmony_ci#define DMA4_WORD0_CMP_ENABLE             0xb44
16462306a36Sopenharmony_ci#define DMA_WORD0_CMP_ENABLE(chan)	(DMA_SREG(DMA0_WORD0_CMP_ENABLE, chan))
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci#define DMA0_WORD1_CMP_VALUE              0xb08
16762306a36Sopenharmony_ci#define DMA1_WORD1_CMP_VALUE              0xb18
16862306a36Sopenharmony_ci#define DMA2_WORD1_CMP_VALUE              0xb28
16962306a36Sopenharmony_ci#define DMA3_WORD1_CMP_VALUE              0xb38
17062306a36Sopenharmony_ci#define DMA4_WORD1_CMP_VALUE              0xb48
17162306a36Sopenharmony_ci#define DMA_WORD1_CMP_VALUE(chan)	(DMA_SREG(DMA0_WORD1_CMP_VALUE, chan))
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci#define DMA0_WORD1_CMP_ENABLE             0xb0c
17462306a36Sopenharmony_ci#define DMA1_WORD1_CMP_ENABLE             0xb1c
17562306a36Sopenharmony_ci#define DMA2_WORD1_CMP_ENABLE             0xb2c
17662306a36Sopenharmony_ci#define DMA3_WORD1_CMP_ENABLE             0xb3c
17762306a36Sopenharmony_ci#define DMA4_WORD1_CMP_ENABLE             0xb4c
17862306a36Sopenharmony_ci#define DMA_WORD1_CMP_ENABLE(chan)	(DMA_SREG(DMA0_WORD1_CMP_ENABLE, chan))
17962306a36Sopenharmony_ci/* word 1 compare enable flags */
18062306a36Sopenharmony_ci#define DMA_WORD1_CMP_MATCH_OTHERBUS      (1<<15)
18162306a36Sopenharmony_ci#define DMA_WORD1_CMP_MATCH_BROADCAST     (1<<14)
18262306a36Sopenharmony_ci#define DMA_WORD1_CMP_MATCH_BUS_BCAST     (1<<13)
18362306a36Sopenharmony_ci#define DMA_WORD1_CMP_MATCH_LOCAL_NODE    (1<<12)
18462306a36Sopenharmony_ci#define DMA_WORD1_CMP_MATCH_EXACT         (1<<11)
18562306a36Sopenharmony_ci#define DMA_WORD1_CMP_ENABLE_SELF_ID      (1<<10)
18662306a36Sopenharmony_ci#define DMA_WORD1_CMP_ENABLE_MASTER       (1<<8)
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci#define LINK_ID                           0xf00
18962306a36Sopenharmony_ci#define LINK_ID_BUS(id)                   (id<<22)
19062306a36Sopenharmony_ci#define LINK_ID_NODE(id)                  (id<<16)
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci#define LINK_CONTROL                      0xf04
19362306a36Sopenharmony_ci#define LINK_CONTROL_BUSY                 (1<<29)
19462306a36Sopenharmony_ci#define LINK_CONTROL_TX_ISO_EN            (1<<26)
19562306a36Sopenharmony_ci#define LINK_CONTROL_RX_ISO_EN            (1<<25)
19662306a36Sopenharmony_ci#define LINK_CONTROL_TX_ASYNC_EN          (1<<24)
19762306a36Sopenharmony_ci#define LINK_CONTROL_RX_ASYNC_EN          (1<<23)
19862306a36Sopenharmony_ci#define LINK_CONTROL_RESET_TX             (1<<21)
19962306a36Sopenharmony_ci#define LINK_CONTROL_RESET_RX             (1<<20)
20062306a36Sopenharmony_ci#define LINK_CONTROL_CYCMASTER            (1<<11)
20162306a36Sopenharmony_ci#define LINK_CONTROL_CYCSOURCE            (1<<10)
20262306a36Sopenharmony_ci#define LINK_CONTROL_CYCTIMEREN           (1<<9)
20362306a36Sopenharmony_ci#define LINK_CONTROL_RCV_CMP_VALID        (1<<7)
20462306a36Sopenharmony_ci#define LINK_CONTROL_SNOOP_ENABLE         (1<<6)
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci#define CYCLE_TIMER                       0xf08
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci#define LINK_PHY                          0xf0c
20962306a36Sopenharmony_ci#define LINK_PHY_READ                     (1<<31)
21062306a36Sopenharmony_ci#define LINK_PHY_WRITE                    (1<<30)
21162306a36Sopenharmony_ci#define LINK_PHY_ADDR(addr)               (addr<<24)
21262306a36Sopenharmony_ci#define LINK_PHY_WDATA(data)              (data<<16)
21362306a36Sopenharmony_ci#define LINK_PHY_RADDR(addr)              (addr<<8)
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci#define LINK_INT_STATUS                   0xf14
21662306a36Sopenharmony_ci#define LINK_INT_ENABLE                   0xf18
21762306a36Sopenharmony_ci/* status and enable have identical bit numbers */
21862306a36Sopenharmony_ci#define LINK_INT_LINK_INT                 (1<<31)
21962306a36Sopenharmony_ci#define LINK_INT_PHY_TIME_OUT             (1<<30)
22062306a36Sopenharmony_ci#define LINK_INT_PHY_REG_RCVD             (1<<29)
22162306a36Sopenharmony_ci#define LINK_INT_PHY_BUSRESET             (1<<28)
22262306a36Sopenharmony_ci#define LINK_INT_TX_RDY                   (1<<26)
22362306a36Sopenharmony_ci#define LINK_INT_RX_DATA_RDY              (1<<25)
22462306a36Sopenharmony_ci#define LINK_INT_IT_STUCK                 (1<<20)
22562306a36Sopenharmony_ci#define LINK_INT_AT_STUCK                 (1<<19)
22662306a36Sopenharmony_ci#define LINK_INT_SNTRJ                    (1<<17)
22762306a36Sopenharmony_ci#define LINK_INT_HDR_ERR                  (1<<16)
22862306a36Sopenharmony_ci#define LINK_INT_TC_ERR                   (1<<15)
22962306a36Sopenharmony_ci#define LINK_INT_CYC_SEC                  (1<<11)
23062306a36Sopenharmony_ci#define LINK_INT_CYC_STRT                 (1<<10)
23162306a36Sopenharmony_ci#define LINK_INT_CYC_DONE                 (1<<9)
23262306a36Sopenharmony_ci#define LINK_INT_CYC_PEND                 (1<<8)
23362306a36Sopenharmony_ci#define LINK_INT_CYC_LOST                 (1<<7)
23462306a36Sopenharmony_ci#define LINK_INT_CYC_ARB_FAILED           (1<<6)
23562306a36Sopenharmony_ci#define LINK_INT_GRF_OVER_FLOW            (1<<5)
23662306a36Sopenharmony_ci#define LINK_INT_ITF_UNDER_FLOW           (1<<4)
23762306a36Sopenharmony_ci#define LINK_INT_ATF_UNDER_FLOW           (1<<3)
23862306a36Sopenharmony_ci#define LINK_INT_IARB_FAILED              (1<<0)
239