1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * I/O Processor (IOP) defines and structures, mostly snagged from A/UX 4*4882a593Smuzhiyun * header files. 5*4882a593Smuzhiyun * 6*4882a593Smuzhiyun * The original header from which this was taken is copyrighted. I've done some 7*4882a593Smuzhiyun * rewriting (in fact my changes make this a bit more readable, IMHO) but some 8*4882a593Smuzhiyun * more should be done. 9*4882a593Smuzhiyun */ 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun /* 12*4882a593Smuzhiyun * This is the base address of the IOPs. Use this as the address of 13*4882a593Smuzhiyun * a "struct iop" (see below) to see where the actual registers fall. 14*4882a593Smuzhiyun */ 15*4882a593Smuzhiyun 16*4882a593Smuzhiyun #define SCC_IOP_BASE_IIFX (0x50F04000) 17*4882a593Smuzhiyun #define ISM_IOP_BASE_IIFX (0x50F12000) 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun #define SCC_IOP_BASE_QUADRA (0x50F0C000) 20*4882a593Smuzhiyun #define ISM_IOP_BASE_QUADRA (0x50F1E000) 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /* IOP status/control register bits: */ 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun #define IOP_BYPASS 0x01 /* bypass-mode hardware access */ 25*4882a593Smuzhiyun #define IOP_AUTOINC 0x02 /* allow autoincrement of ramhi/lo */ 26*4882a593Smuzhiyun #define IOP_RUN 0x04 /* set to 0 to reset IOP chip */ 27*4882a593Smuzhiyun #define IOP_IRQ 0x08 /* generate IRQ to IOP if 1 */ 28*4882a593Smuzhiyun #define IOP_INT0 0x10 /* intr priority from IOP to host */ 29*4882a593Smuzhiyun #define IOP_INT1 0x20 /* intr priority from IOP to host */ 30*4882a593Smuzhiyun #define IOP_HWINT 0x40 /* IRQ from hardware; bypass mode only */ 31*4882a593Smuzhiyun #define IOP_DMAINACTIVE 0x80 /* no DMA request active; bypass mode only */ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun #define NUM_IOPS 2 34*4882a593Smuzhiyun #define NUM_IOP_CHAN 7 35*4882a593Smuzhiyun #define NUM_IOP_MSGS NUM_IOP_CHAN*8 36*4882a593Smuzhiyun #define IOP_MSG_LEN 32 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun /* IOP reference numbers, used by the globally-visible iop_xxx functions */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun #define IOP_NUM_SCC 0 41*4882a593Smuzhiyun #define IOP_NUM_ISM 1 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun /* IOP channel states */ 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun #define IOP_MSG_IDLE 0 /* idle */ 46*4882a593Smuzhiyun #define IOP_MSG_NEW 1 /* new message sent */ 47*4882a593Smuzhiyun #define IOP_MSG_RCVD 2 /* message received; processing */ 48*4882a593Smuzhiyun #define IOP_MSG_COMPLETE 3 /* message processing complete */ 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun /* IOP message status codes */ 51*4882a593Smuzhiyun 52*4882a593Smuzhiyun #define IOP_MSGSTATUS_UNUSED 0 /* Unused message structure */ 53*4882a593Smuzhiyun #define IOP_MSGSTATUS_WAITING 1 /* waiting for channel */ 54*4882a593Smuzhiyun #define IOP_MSGSTATUS_SENT 2 /* message sent, awaiting reply */ 55*4882a593Smuzhiyun #define IOP_MSGSTATUS_COMPLETE 3 /* message complete and reply rcvd */ 56*4882a593Smuzhiyun #define IOP_MSGSTATUS_UNSOL 6 /* message is unsolicited */ 57*4882a593Smuzhiyun 58*4882a593Smuzhiyun /* IOP memory addresses of the members of the mac_iop_kernel structure. */ 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun #define IOP_ADDR_MAX_SEND_CHAN 0x0200 61*4882a593Smuzhiyun #define IOP_ADDR_SEND_STATE 0x0201 62*4882a593Smuzhiyun #define IOP_ADDR_PATCH_CTRL 0x021F 63*4882a593Smuzhiyun #define IOP_ADDR_SEND_MSG 0x0220 64*4882a593Smuzhiyun #define IOP_ADDR_MAX_RECV_CHAN 0x0300 65*4882a593Smuzhiyun #define IOP_ADDR_RECV_STATE 0x0301 66*4882a593Smuzhiyun #define IOP_ADDR_ALIVE 0x031F 67*4882a593Smuzhiyun #define IOP_ADDR_RECV_MSG 0x0320 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun #ifndef __ASSEMBLY__ 70*4882a593Smuzhiyun 71*4882a593Smuzhiyun /* 72*4882a593Smuzhiyun * IOP Control registers, staggered because in usual Apple style they were 73*4882a593Smuzhiyun * too lazy to decode the A0 bit. This structure is assumed to begin at 74*4882a593Smuzhiyun * one of the xxx_IOP_BASE addresses given above. 75*4882a593Smuzhiyun */ 76*4882a593Smuzhiyun 77*4882a593Smuzhiyun struct mac_iop { 78*4882a593Smuzhiyun __u8 ram_addr_hi; /* shared RAM address hi byte */ 79*4882a593Smuzhiyun __u8 pad0; 80*4882a593Smuzhiyun __u8 ram_addr_lo; /* shared RAM address lo byte */ 81*4882a593Smuzhiyun __u8 pad1; 82*4882a593Smuzhiyun __u8 status_ctrl; /* status/control register */ 83*4882a593Smuzhiyun __u8 pad2[3]; 84*4882a593Smuzhiyun __u8 ram_data; /* RAM data byte at ramhi/lo */ 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun __u8 pad3[23]; 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /* Bypass-mode hardware access registers */ 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun union { 91*4882a593Smuzhiyun struct { /* SCC registers */ 92*4882a593Smuzhiyun __u8 sccb_cmd; /* SCC B command reg */ 93*4882a593Smuzhiyun __u8 pad4; 94*4882a593Smuzhiyun __u8 scca_cmd; /* SCC A command reg */ 95*4882a593Smuzhiyun __u8 pad5; 96*4882a593Smuzhiyun __u8 sccb_data; /* SCC B data */ 97*4882a593Smuzhiyun __u8 pad6; 98*4882a593Smuzhiyun __u8 scca_data; /* SCC A data */ 99*4882a593Smuzhiyun } scc_regs; 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun struct { /* ISM registers */ 102*4882a593Smuzhiyun __u8 wdata; /* write a data byte */ 103*4882a593Smuzhiyun __u8 pad7; 104*4882a593Smuzhiyun __u8 wmark; /* write a mark byte */ 105*4882a593Smuzhiyun __u8 pad8; 106*4882a593Smuzhiyun __u8 wcrc; /* write 2-byte crc to disk */ 107*4882a593Smuzhiyun __u8 pad9; 108*4882a593Smuzhiyun __u8 wparams; /* write the param regs */ 109*4882a593Smuzhiyun __u8 pad10; 110*4882a593Smuzhiyun __u8 wphase; /* write the phase states & dirs */ 111*4882a593Smuzhiyun __u8 pad11; 112*4882a593Smuzhiyun __u8 wsetup; /* write the setup register */ 113*4882a593Smuzhiyun __u8 pad12; 114*4882a593Smuzhiyun __u8 wzeroes; /* mode reg: 1's clr bits, 0's are x */ 115*4882a593Smuzhiyun __u8 pad13; 116*4882a593Smuzhiyun __u8 wones; /* mode reg: 1's set bits, 0's are x */ 117*4882a593Smuzhiyun __u8 pad14; 118*4882a593Smuzhiyun __u8 rdata; /* read a data byte */ 119*4882a593Smuzhiyun __u8 pad15; 120*4882a593Smuzhiyun __u8 rmark; /* read a mark byte */ 121*4882a593Smuzhiyun __u8 pad16; 122*4882a593Smuzhiyun __u8 rerror; /* read the error register */ 123*4882a593Smuzhiyun __u8 pad17; 124*4882a593Smuzhiyun __u8 rparams; /* read the param regs */ 125*4882a593Smuzhiyun __u8 pad18; 126*4882a593Smuzhiyun __u8 rphase; /* read the phase states & dirs */ 127*4882a593Smuzhiyun __u8 pad19; 128*4882a593Smuzhiyun __u8 rsetup; /* read the setup register */ 129*4882a593Smuzhiyun __u8 pad20; 130*4882a593Smuzhiyun __u8 rmode; /* read the mode register */ 131*4882a593Smuzhiyun __u8 pad21; 132*4882a593Smuzhiyun __u8 rhandshake; /* read the handshake register */ 133*4882a593Smuzhiyun } ism_regs; 134*4882a593Smuzhiyun } b; 135*4882a593Smuzhiyun }; 136*4882a593Smuzhiyun 137*4882a593Smuzhiyun /* This structure is used to track IOP messages in the Linux kernel */ 138*4882a593Smuzhiyun 139*4882a593Smuzhiyun struct iop_msg { 140*4882a593Smuzhiyun struct iop_msg *next; /* next message in queue or NULL */ 141*4882a593Smuzhiyun uint iop_num; /* IOP number */ 142*4882a593Smuzhiyun uint channel; /* channel number */ 143*4882a593Smuzhiyun void *caller_priv; /* caller private data */ 144*4882a593Smuzhiyun int status; /* status of this message */ 145*4882a593Smuzhiyun __u8 message[IOP_MSG_LEN]; /* the message being sent/received */ 146*4882a593Smuzhiyun __u8 reply[IOP_MSG_LEN]; /* the reply to the message */ 147*4882a593Smuzhiyun void (*handler)(struct iop_msg *); 148*4882a593Smuzhiyun /* function to call when reply recvd */ 149*4882a593Smuzhiyun }; 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun extern int iop_scc_present,iop_ism_present; 152*4882a593Smuzhiyun 153*4882a593Smuzhiyun extern int iop_listen(uint, uint, 154*4882a593Smuzhiyun void (*handler)(struct iop_msg *), 155*4882a593Smuzhiyun const char *); 156*4882a593Smuzhiyun extern int iop_send_message(uint, uint, void *, uint, __u8 *, 157*4882a593Smuzhiyun void (*)(struct iop_msg *)); 158*4882a593Smuzhiyun extern void iop_complete_message(struct iop_msg *); 159*4882a593Smuzhiyun extern void iop_upload_code(uint, __u8 *, uint, __u16); 160*4882a593Smuzhiyun extern void iop_download_code(uint, __u8 *, uint, __u16); 161*4882a593Smuzhiyun extern __u8 *iop_compare_code(uint, __u8 *, uint, __u16); 162*4882a593Smuzhiyun extern void iop_ism_irq_poll(uint); 163*4882a593Smuzhiyun 164*4882a593Smuzhiyun extern void iop_register_interrupts(void); 165*4882a593Smuzhiyun 166*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */ 167