xref: /linux/drivers/mcb/mcb-internal.h (revision b71bb8639891827051af88d8dfb17ca608b6ae88)
13764e82eSJohannes Thumshirn #ifndef __MCB_INTERNAL
23764e82eSJohannes Thumshirn #define __MCB_INTERNAL
33764e82eSJohannes Thumshirn 
43764e82eSJohannes Thumshirn #include <linux/types.h>
53764e82eSJohannes Thumshirn 
6*b71bb863SJohannes Thumshirn #define PCI_VENDOR_ID_MEN		0x1a88
7*b71bb863SJohannes Thumshirn #define PCI_DEVICE_ID_MEN_CHAMELEON	0x4d45
83764e82eSJohannes Thumshirn #define CHAMELEON_FILENAME_LEN		12
93764e82eSJohannes Thumshirn #define CHAMELEONV2_MAGIC		0xabce
103764e82eSJohannes Thumshirn 
113764e82eSJohannes Thumshirn enum chameleon_descriptor_type {
123764e82eSJohannes Thumshirn 	CHAMELEON_DTYPE_GENERAL = 0x0,
133764e82eSJohannes Thumshirn 	CHAMELEON_DTYPE_BRIDGE = 0x1,
143764e82eSJohannes Thumshirn 	CHAMELEON_DTYPE_CPU = 0x2,
153764e82eSJohannes Thumshirn 	CHAMELEON_DTYPE_BAR = 0x3,
163764e82eSJohannes Thumshirn 	CHAMELEON_DTYPE_END = 0xf,
173764e82eSJohannes Thumshirn };
183764e82eSJohannes Thumshirn 
193764e82eSJohannes Thumshirn enum chameleon_bus_type {
203764e82eSJohannes Thumshirn 	CHAMELEON_BUS_WISHBONE,
213764e82eSJohannes Thumshirn 	CHAMELEON_BUS_AVALON,
223764e82eSJohannes Thumshirn 	CHAMELEON_BUS_LPC,
233764e82eSJohannes Thumshirn 	CHAMELEON_BUS_ISA,
243764e82eSJohannes Thumshirn };
253764e82eSJohannes Thumshirn 
263764e82eSJohannes Thumshirn /**
273764e82eSJohannes Thumshirn  * struct chameleon_fpga_header
283764e82eSJohannes Thumshirn  *
293764e82eSJohannes Thumshirn  * @revision:	Revison of Chameleon table in FPGA
303764e82eSJohannes Thumshirn  * @model:	Chameleon table model ASCII char
313764e82eSJohannes Thumshirn  * @minor:	Revision minor
323764e82eSJohannes Thumshirn  * @bus_type:	Bus type (usually %CHAMELEON_BUS_WISHBONE)
333764e82eSJohannes Thumshirn  * @magic:	Chameleon header magic number (0xabce for version 2)
343764e82eSJohannes Thumshirn  * @reserved:	Reserved
353764e82eSJohannes Thumshirn  * @filename:	Filename of FPGA bitstream
363764e82eSJohannes Thumshirn  */
373764e82eSJohannes Thumshirn struct chameleon_fpga_header {
383764e82eSJohannes Thumshirn 	u8 revision;
393764e82eSJohannes Thumshirn 	char model;
403764e82eSJohannes Thumshirn 	u8 minor;
413764e82eSJohannes Thumshirn 	u8 bus_type;
423764e82eSJohannes Thumshirn 	u16 magic;
433764e82eSJohannes Thumshirn 	u16 reserved;
443764e82eSJohannes Thumshirn 	/* This one has no '\0' at the end!!! */
453764e82eSJohannes Thumshirn 	char filename[CHAMELEON_FILENAME_LEN];
463764e82eSJohannes Thumshirn } __packed;
473764e82eSJohannes Thumshirn #define HEADER_MAGIC_OFFSET 0x4
483764e82eSJohannes Thumshirn 
493764e82eSJohannes Thumshirn /**
503764e82eSJohannes Thumshirn  * struct chameleon_gdd - Chameleon General Device Descriptor
513764e82eSJohannes Thumshirn  *
523764e82eSJohannes Thumshirn  * @irq:	the position in the FPGA's IRQ controller vector
533764e82eSJohannes Thumshirn  * @rev:	the revision of the variant's implementation
543764e82eSJohannes Thumshirn  * @var:	the variant of the IP core
553764e82eSJohannes Thumshirn  * @dev:	the device  the IP core is
563764e82eSJohannes Thumshirn  * @dtype:	device descriptor type
573764e82eSJohannes Thumshirn  * @bar:	BAR offset that must be added to module offset
583764e82eSJohannes Thumshirn  * @inst:	the instance number of the device, 0 is first instance
593764e82eSJohannes Thumshirn  * @group:	the group the device belongs to (0 = no group)
603764e82eSJohannes Thumshirn  * @reserved:	reserved
613764e82eSJohannes Thumshirn  * @offset:	beginning of the address window of desired module
623764e82eSJohannes Thumshirn  * @size:	size of the module's address window
633764e82eSJohannes Thumshirn  */
643764e82eSJohannes Thumshirn struct chameleon_gdd {
653764e82eSJohannes Thumshirn 	__le32 reg1;
663764e82eSJohannes Thumshirn 	__le32 reg2;
673764e82eSJohannes Thumshirn 	__le32 offset;
683764e82eSJohannes Thumshirn 	__le32 size;
693764e82eSJohannes Thumshirn 
703764e82eSJohannes Thumshirn } __packed;
713764e82eSJohannes Thumshirn 
723764e82eSJohannes Thumshirn /* GDD Register 1 fields */
733764e82eSJohannes Thumshirn #define GDD_IRQ(x) ((x) & 0x1f)
743764e82eSJohannes Thumshirn #define GDD_REV(x) (((x) >> 5) & 0x3f)
753764e82eSJohannes Thumshirn #define GDD_VAR(x) (((x) >> 11) & 0x3f)
763764e82eSJohannes Thumshirn #define GDD_DEV(x) (((x) >> 18) & 0x3ff)
773764e82eSJohannes Thumshirn #define GDD_DTY(x) (((x) >> 28) & 0xf)
783764e82eSJohannes Thumshirn 
793764e82eSJohannes Thumshirn /* GDD Register 2 fields */
803764e82eSJohannes Thumshirn #define GDD_BAR(x) ((x) & 0x7)
813764e82eSJohannes Thumshirn #define GDD_INS(x) (((x) >> 3) & 0x3f)
823764e82eSJohannes Thumshirn #define GDD_GRP(x) (((x) >> 9) & 0x3f)
833764e82eSJohannes Thumshirn 
843764e82eSJohannes Thumshirn /**
853764e82eSJohannes Thumshirn  * struct chameleon_bdd - Chameleon Bridge Device Descriptor
863764e82eSJohannes Thumshirn  *
873764e82eSJohannes Thumshirn  * @irq:	the position in the FPGA's IRQ controller vector
883764e82eSJohannes Thumshirn  * @rev:	the revision of the variant's implementation
893764e82eSJohannes Thumshirn  * @var:	the variant of the IP core
903764e82eSJohannes Thumshirn  * @dev:	the device  the IP core is
913764e82eSJohannes Thumshirn  * @dtype:	device descriptor type
923764e82eSJohannes Thumshirn  * @bar:	BAR offset that must be added to module offset
933764e82eSJohannes Thumshirn  * @inst:	the instance number of the device, 0 is first instance
943764e82eSJohannes Thumshirn  * @dbar:	destination bar from the bus _behind_ the bridge
953764e82eSJohannes Thumshirn  * @chamoff:	offset within the BAR of the source bus
963764e82eSJohannes Thumshirn  * @offset:
973764e82eSJohannes Thumshirn  * @size:
983764e82eSJohannes Thumshirn  */
993764e82eSJohannes Thumshirn struct chameleon_bdd {
1003764e82eSJohannes Thumshirn 	unsigned int irq:6;
1013764e82eSJohannes Thumshirn 	unsigned int rev:6;
1023764e82eSJohannes Thumshirn 	unsigned int var:6;
1033764e82eSJohannes Thumshirn 	unsigned int dev:10;
1043764e82eSJohannes Thumshirn 	unsigned int dtype:4;
1053764e82eSJohannes Thumshirn 	unsigned int bar:3;
1063764e82eSJohannes Thumshirn 	unsigned int inst:6;
1073764e82eSJohannes Thumshirn 	unsigned int dbar:3;
1083764e82eSJohannes Thumshirn 	unsigned int group:6;
1093764e82eSJohannes Thumshirn 	unsigned int reserved:14;
1103764e82eSJohannes Thumshirn 	u32 chamoff;
1113764e82eSJohannes Thumshirn 	u32 offset;
1123764e82eSJohannes Thumshirn 	u32 size;
1133764e82eSJohannes Thumshirn } __packed;
1143764e82eSJohannes Thumshirn 
1153764e82eSJohannes Thumshirn int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
1163764e82eSJohannes Thumshirn 			  void __iomem *base);
1173764e82eSJohannes Thumshirn 
1183764e82eSJohannes Thumshirn #endif
119