18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * include/asm-mips/txx9/tx4927pcic.h
38c2ecf20Sopenharmony_ci * TX4927 PCI controller definitions.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
68c2ecf20Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
78c2ecf20Sopenharmony_ci * for more details.
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci#ifndef __ASM_TXX9_TX4927PCIC_H
108c2ecf20Sopenharmony_ci#define __ASM_TXX9_TX4927PCIC_H
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/pci.h>
138c2ecf20Sopenharmony_ci#include <linux/irqreturn.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct tx4927_pcic_reg {
168c2ecf20Sopenharmony_ci	u32 pciid;
178c2ecf20Sopenharmony_ci	u32 pcistatus;
188c2ecf20Sopenharmony_ci	u32 pciccrev;
198c2ecf20Sopenharmony_ci	u32 pcicfg1;
208c2ecf20Sopenharmony_ci	u32 p2gm0plbase;		/* +10 */
218c2ecf20Sopenharmony_ci	u32 p2gm0pubase;
228c2ecf20Sopenharmony_ci	u32 p2gm1plbase;
238c2ecf20Sopenharmony_ci	u32 p2gm1pubase;
248c2ecf20Sopenharmony_ci	u32 p2gm2pbase;		/* +20 */
258c2ecf20Sopenharmony_ci	u32 p2giopbase;
268c2ecf20Sopenharmony_ci	u32 unused0;
278c2ecf20Sopenharmony_ci	u32 pcisid;
288c2ecf20Sopenharmony_ci	u32 unused1;		/* +30 */
298c2ecf20Sopenharmony_ci	u32 pcicapptr;
308c2ecf20Sopenharmony_ci	u32 unused2;
318c2ecf20Sopenharmony_ci	u32 pcicfg2;
328c2ecf20Sopenharmony_ci	u32 g2ptocnt;		/* +40 */
338c2ecf20Sopenharmony_ci	u32 unused3[15];
348c2ecf20Sopenharmony_ci	u32 g2pstatus;		/* +80 */
358c2ecf20Sopenharmony_ci	u32 g2pmask;
368c2ecf20Sopenharmony_ci	u32 pcisstatus;
378c2ecf20Sopenharmony_ci	u32 pcimask;
388c2ecf20Sopenharmony_ci	u32 p2gcfg;		/* +90 */
398c2ecf20Sopenharmony_ci	u32 p2gstatus;
408c2ecf20Sopenharmony_ci	u32 p2gmask;
418c2ecf20Sopenharmony_ci	u32 p2gccmd;
428c2ecf20Sopenharmony_ci	u32 unused4[24];		/* +a0 */
438c2ecf20Sopenharmony_ci	u32 pbareqport;		/* +100 */
448c2ecf20Sopenharmony_ci	u32 pbacfg;
458c2ecf20Sopenharmony_ci	u32 pbastatus;
468c2ecf20Sopenharmony_ci	u32 pbamask;
478c2ecf20Sopenharmony_ci	u32 pbabm;		/* +110 */
488c2ecf20Sopenharmony_ci	u32 pbacreq;
498c2ecf20Sopenharmony_ci	u32 pbacgnt;
508c2ecf20Sopenharmony_ci	u32 pbacstate;
518c2ecf20Sopenharmony_ci	u64 g2pmgbase[3];		/* +120 */
528c2ecf20Sopenharmony_ci	u64 g2piogbase;
538c2ecf20Sopenharmony_ci	u32 g2pmmask[3];		/* +140 */
548c2ecf20Sopenharmony_ci	u32 g2piomask;
558c2ecf20Sopenharmony_ci	u64 g2pmpbase[3];		/* +150 */
568c2ecf20Sopenharmony_ci	u64 g2piopbase;
578c2ecf20Sopenharmony_ci	u32 pciccfg;		/* +170 */
588c2ecf20Sopenharmony_ci	u32 pcicstatus;
598c2ecf20Sopenharmony_ci	u32 pcicmask;
608c2ecf20Sopenharmony_ci	u32 unused5;
618c2ecf20Sopenharmony_ci	u64 p2gmgbase[3];		/* +180 */
628c2ecf20Sopenharmony_ci	u64 p2giogbase;
638c2ecf20Sopenharmony_ci	u32 g2pcfgadrs;		/* +1a0 */
648c2ecf20Sopenharmony_ci	u32 g2pcfgdata;
658c2ecf20Sopenharmony_ci	u32 unused6[8];
668c2ecf20Sopenharmony_ci	u32 g2pintack;
678c2ecf20Sopenharmony_ci	u32 g2pspc;
688c2ecf20Sopenharmony_ci	u32 unused7[12];		/* +1d0 */
698c2ecf20Sopenharmony_ci	u64 pdmca;		/* +200 */
708c2ecf20Sopenharmony_ci	u64 pdmga;
718c2ecf20Sopenharmony_ci	u64 pdmpa;
728c2ecf20Sopenharmony_ci	u64 pdmctr;
738c2ecf20Sopenharmony_ci	u64 pdmcfg;		/* +220 */
748c2ecf20Sopenharmony_ci	u64 pdmsts;
758c2ecf20Sopenharmony_ci};
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* bits for PCICMD */
788c2ecf20Sopenharmony_ci/* see PCI_COMMAND_XXX in linux/pci_regs.h */
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/* bits for PCISTAT */
818c2ecf20Sopenharmony_ci/* see PCI_STATUS_XXX in linux/pci_regs.h */
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci/* bits for IOBA/MBA */
848c2ecf20Sopenharmony_ci/* see PCI_BASE_ADDRESS_XXX in linux/pci_regs.h */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci/* bits for G2PSTATUS/G2PMASK */
878c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PSTATUS_ALL	0x00000003
888c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PSTATUS_TTOE	0x00000002
898c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PSTATUS_RTOE	0x00000001
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/* bits for PCIMASK (see also PCI_STATUS_XXX in linux/pci_regs.h */
928c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCISTATUS_ALL	0x0000f900
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/* bits for PBACFG */
958c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBACFG_FIXPA	0x00000008
968c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBACFG_RPBA 0x00000004
978c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBACFG_PBAEN	0x00000002
988c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBACFG_BMCEN	0x00000001
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci/* bits for PBASTATUS/PBAMASK */
1018c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBASTATUS_ALL	0x00000001
1028c2ecf20Sopenharmony_ci#define TX4927_PCIC_PBASTATUS_BM	0x00000001
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* bits for G2PMnGBASE */
1058c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PMnGBASE_BSDIS	0x0000002000000000ULL
1068c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PMnGBASE_ECHG	0x0000001000000000ULL
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* bits for G2PIOGBASE */
1098c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PIOGBASE_BSDIS	0x0000002000000000ULL
1108c2ecf20Sopenharmony_ci#define TX4927_PCIC_G2PIOGBASE_ECHG	0x0000001000000000ULL
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci/* bits for PCICSTATUS/PCICMASK */
1138c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_ALL	0x000007b8
1148c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_PME	0x00000400
1158c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_TLB	0x00000200
1168c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_NIB	0x00000100
1178c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_ZIB	0x00000080
1188c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_PERR	0x00000020
1198c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_SERR	0x00000010
1208c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_GBE	0x00000008
1218c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_IWB	0x00000002
1228c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICSTATUS_E2PDONE	0x00000001
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/* bits for PCICCFG */
1258c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_GBWC_MASK	0x0fff0000
1268c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_HRST	0x00000800
1278c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_SRST	0x00000400
1288c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_IRBER	0x00000200
1298c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_G2PMEN(ch)	(0x00000100>>(ch))
1308c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_G2PM0EN	0x00000100
1318c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_G2PM1EN	0x00000080
1328c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_G2PM2EN	0x00000040
1338c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_G2PIOEN	0x00000020
1348c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_TCAR	0x00000010
1358c2ecf20Sopenharmony_ci#define TX4927_PCIC_PCICCFG_ICAEN	0x00000008
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci/* bits for P2GMnGBASE */
1388c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GMnGBASE_TMEMEN	0x0000004000000000ULL
1398c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GMnGBASE_TBSDIS	0x0000002000000000ULL
1408c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GMnGBASE_TECHG	0x0000001000000000ULL
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci/* bits for P2GIOGBASE */
1438c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GIOGBASE_TIOEN	0x0000004000000000ULL
1448c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GIOGBASE_TBSDIS	0x0000002000000000ULL
1458c2ecf20Sopenharmony_ci#define TX4927_PCIC_P2GIOGBASE_TECHG	0x0000001000000000ULL
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ci#define TX4927_PCIC_IDSEL_AD_TO_SLOT(ad)	((ad) - 11)
1488c2ecf20Sopenharmony_ci#define TX4927_PCIC_MAX_DEVNU	TX4927_PCIC_IDSEL_AD_TO_SLOT(32)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* bits for PDMCFG */
1518c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_RSTFIFO	0x00200000
1528c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_EXFER	0x00100000
1538c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_MASK	0x00003800
1548c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_NONE	(0 << 11)
1558c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_16	(1 << 11)
1568c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_32	(2 << 11)
1578c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_64	(3 << 11)
1588c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_128	(4 << 11)
1598c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_256	(5 << 11)
1608c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_512	(6 << 11)
1618c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_REQDLY_1024	(7 << 11)
1628c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_ERRIE	0x00000400
1638c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_NCCMPIE	0x00000200
1648c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_NTCMPIE	0x00000100
1658c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_CHNEN	0x00000080
1668c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRACT	0x00000040
1678c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_BSWAP	0x00000020
1688c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRSIZE_MASK 0x0000000c
1698c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRSIZE_1DW	0x00000000
1708c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRSIZE_1QW	0x00000004
1718c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRSIZE_4QW	0x00000008
1728c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_XFRDIRC	0x00000002
1738c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMCFG_CHRST	0x00000001
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci/* bits for PDMSTS */
1768c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_REQCNT_MASK	0x3f000000
1778c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_FIFOCNT_MASK 0x00f00000
1788c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_FIFOWP_MASK	0x000c0000
1798c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_FIFORP_MASK	0x00030000
1808c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_ERRINT	0x00000800
1818c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_DONEINT	0x00000400
1828c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_CHNEN	0x00000200
1838c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_XFRACT	0x00000100
1848c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_ACCMP	0x00000080
1858c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_NCCMP	0x00000040
1868c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_NTCMP	0x00000020
1878c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_CFGERR	0x00000008
1888c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_PCIERR	0x00000004
1898c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_CHNERR	0x00000002
1908c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_DATAERR	0x00000001
1918c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_ALL_CMP	0x000000e0
1928c2ecf20Sopenharmony_ci#define TX4927_PCIC_PDMSTS_ALL_ERR	0x0000000f
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_cistruct tx4927_pcic_reg __iomem *get_tx4927_pcicptr(
1958c2ecf20Sopenharmony_ci	struct pci_controller *channel);
1968c2ecf20Sopenharmony_civoid tx4927_pcic_setup(struct tx4927_pcic_reg __iomem *pcicptr,
1978c2ecf20Sopenharmony_ci		       struct pci_controller *channel, int extarb);
1988c2ecf20Sopenharmony_civoid tx4927_report_pcic_status(void);
1998c2ecf20Sopenharmony_cichar *tx4927_pcibios_setup(char *str);
2008c2ecf20Sopenharmony_civoid tx4927_dump_pcic_settings(void);
2018c2ecf20Sopenharmony_ciirqreturn_t tx4927_pcierr_interrupt(int irq, void *dev_id);
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci#endif /* __ASM_TXX9_TX4927PCIC_H */
204