static void set_multicast_start(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); fcc_enet_t __iomem *ep = fep->fcc.ep; W32(ep, fen_gaddrh, 0); W32(ep, fen_gaddrl, 0); }
static inline int fcc_cr_cmd(struct fs_enet_private *fep, u32 mcn, u32 op) { const struct fs_platform_info *fpi = fep->fpi; cpm2_map_t *immap = fs_enet_immap; cpm_cpm2_t *cpmp = &immap->im_cpm; u32 v; int i; /* Currently I don't know what feature call will look like. But I guess there'd be something like do_cpm_cmd() which will require page & sblock */ v = mk_cr_cmd(fpi->cp_page, fpi->cp_block, mcn, op); W32(cpmp, cp_cpcr, v | CPM_CR_FLG); for (i = 0; i < MAX_CR_CMD_LOOPS; i++) if ((R32(cpmp, cp_cpcr) & CPM_CR_FLG) == 0) break; if (i >= MAX_CR_CMD_LOOPS) { printk(KERN_ERR "%s(): Not able to issue CPM command\n", __FUNCTION__); return 1; } return 0; }
static void set_multicast_finish(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); fcc_t __iomem *fccp = fep->fcc.fccp; fcc_enet_t __iomem *ep = fep->fcc.ep; /* clear promiscuous always */ C32(fccp, fcc_fpsmr, FCC_PSMR_PRO); /* if all multi or too many multicasts; just enable all */ if ((dev->flags & IFF_ALLMULTI) != 0 || dev->mc_count > FCC_MAX_MULTICAST_ADDRS) { W32(ep, fen_gaddrh, 0xffffffff); W32(ep, fen_gaddrl, 0xffffffff); } /* read back */ fep->fcc.gaddrh = R32(ep, fen_gaddrh); fep->fcc.gaddrl = R32(ep, fen_gaddrl); }
/* Some transmit errors cause the transmitter to shut * down. We now issue a restart transmit. * Also, to workaround 8260 device erratum CPM37, we must * disable and then re-enable the transmitterfollowing a * Late Collision, Underrun, or Retry Limit error. * In addition, tbptr may point beyond BDs beyond still marked * as ready due to internal pipelining, so we need to look back * through the BDs and adjust tbptr to point to the last BD * marked as ready. This may result in some buffers being * retransmitted. */ static void tx_restart(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); fcc_t __iomem *fccp = fep->fcc.fccp; const struct fs_platform_info *fpi = fep->fpi; fcc_enet_t __iomem *ep = fep->fcc.ep; cbd_t __iomem *curr_tbptr; cbd_t __iomem *recheck_bd; cbd_t __iomem *prev_bd; cbd_t __iomem *last_tx_bd; last_tx_bd = fep->tx_bd_base + (fpi->tx_ring * sizeof(cbd_t)); /* get the current bd held in TBPTR and scan back from this point */ recheck_bd = curr_tbptr = (cbd_t __iomem *) ((R32(ep, fen_genfcc.fcc_tbptr) - fep->ring_mem_addr) + fep->ring_base); prev_bd = (recheck_bd == fep->tx_bd_base) ? last_tx_bd : recheck_bd - 1; /* Move through the bds in reverse, look for the earliest buffer * that is not ready. Adjust TBPTR to the following buffer */ while ((CBDR_SC(prev_bd) & BD_ENET_TX_READY) != 0) { /* Go back one buffer */ recheck_bd = prev_bd; /* update the previous buffer */ prev_bd = (prev_bd == fep->tx_bd_base) ? last_tx_bd : prev_bd - 1; /* We should never see all bds marked as ready, check anyway */ if (recheck_bd == curr_tbptr) break; } /* Now update the TBPTR and dirty flag to the current buffer */ W32(ep, fen_genfcc.fcc_tbptr, (uint) (((void *)recheck_bd - fep->ring_base) + fep->ring_mem_addr)); fep->dirty_tx = recheck_bd; C32(fccp, fcc_gfmr, FCC_GFMR_ENT); udelay(10); S32(fccp, fcc_gfmr, FCC_GFMR_ENT); fcc_cr_cmd(fep, CPM_CR_RESTART_TX); }
static void restart(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); const struct fs_platform_info *fpi = fep->fpi; fcc_t __iomem *fccp = fep->fcc.fccp; fcc_c_t __iomem *fcccp = fep->fcc.fcccp; fcc_enet_t __iomem *ep = fep->fcc.ep; dma_addr_t rx_bd_base_phys, tx_bd_base_phys; u16 paddrh, paddrm, paddrl; const unsigned char *mac; int i; C32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT); /* clear everything (slow & steady does it) */ for (i = 0; i < sizeof(*ep); i++) out_8((u8 __iomem *)ep + i, 0); /* get physical address */ rx_bd_base_phys = fep->ring_mem_addr; tx_bd_base_phys = rx_bd_base_phys + sizeof(cbd_t) * fpi->rx_ring; /* point to bds */ W32(ep, fen_genfcc.fcc_rbase, rx_bd_base_phys); W32(ep, fen_genfcc.fcc_tbase, tx_bd_base_phys); /* Set maximum bytes per receive buffer. * It must be a multiple of 32. */ W16(ep, fen_genfcc.fcc_mrblr, PKT_MAXBLR_SIZE); W32(ep, fen_genfcc.fcc_rstate, (CPMFCR_GBL | CPMFCR_EB) << 24); W32(ep, fen_genfcc.fcc_tstate, (CPMFCR_GBL | CPMFCR_EB) << 24); /* Allocate space in the reserved FCC area of DPRAM for the * internal buffers. No one uses this space (yet), so we * can do this. Later, we will add resource management for * this area. */ W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset); W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32); W16(ep, fen_padptr, fpi->dpram_offset + 64); /* fill with special symbol... */ memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32); W32(ep, fen_genfcc.fcc_rbptr, 0); W32(ep, fen_genfcc.fcc_tbptr, 0); W32(ep, fen_genfcc.fcc_rcrc, 0); W32(ep, fen_genfcc.fcc_tcrc, 0); W16(ep, fen_genfcc.fcc_res1, 0); W32(ep, fen_genfcc.fcc_res2, 0); /* no CAM */ W32(ep, fen_camptr, 0); /* Set CRC preset and mask */ W32(ep, fen_cmask, 0xdebb20e3); W32(ep, fen_cpres, 0xffffffff); W32(ep, fen_crcec, 0); /* CRC Error counter */ W32(ep, fen_alec, 0); /* alignment error counter */ W32(ep, fen_disfc, 0); /* discard frame counter */ W16(ep, fen_retlim, 15); /* Retry limit threshold */ W16(ep, fen_pper, 0); /* Normal persistence */ /* set group address */ W32(ep, fen_gaddrh, fep->fcc.gaddrh); W32(ep, fen_gaddrl, fep->fcc.gaddrh); /* Clear hash filter tables */ W32(ep, fen_iaddrh, 0); W32(ep, fen_iaddrl, 0); /* Clear the Out-of-sequence TxBD */ W16(ep, fen_tfcstat, 0); W16(ep, fen_tfclen, 0); W32(ep, fen_tfcptr, 0); W16(ep, fen_mflr, PKT_MAXBUF_SIZE); /* maximum frame length register */ W16(ep, fen_minflr, PKT_MINBUF_SIZE); /* minimum frame length register */ /* set address */ mac = dev->dev_addr; paddrh = ((u16)mac[5] << 8) | mac[4]; paddrm = ((u16)mac[3] << 8) | mac[2]; paddrl = ((u16)mac[1] << 8) | mac[0]; W16(ep, fen_paddrh, paddrh); W16(ep, fen_paddrm, paddrm); W16(ep, fen_paddrl, paddrl); W16(ep, fen_taddrh, 0); W16(ep, fen_taddrm, 0); W16(ep, fen_taddrl, 0); W16(ep, fen_maxd1, 1520); /* maximum DMA1 length */ W16(ep, fen_maxd2, 1520); /* maximum DMA2 length */ /* Clear stat counters, in case we ever enable RMON */ W32(ep, fen_octc, 0); W32(ep, fen_colc, 0); W32(ep, fen_broc, 0); W32(ep, fen_mulc, 0); W32(ep, fen_uspc, 0); W32(ep, fen_frgc, 0); W32(ep, fen_ospc, 0); W32(ep, fen_jbrc, 0); W32(ep, fen_p64c, 0); W32(ep, fen_p65c, 0); W32(ep, fen_p128c, 0); W32(ep, fen_p256c, 0); W32(ep, fen_p512c, 0); W32(ep, fen_p1024c, 0); W16(ep, fen_rfthr, 0); /* Suggested by manual */ W16(ep, fen_rfcnt, 0); W16(ep, fen_cftype, 0); fs_init_bds(dev); /* adjust to speed (for RMII mode) */ if (fpi->use_rmii) { if (fep->phydev->speed == 100) C8(fcccp, fcc_gfemr, 0x20); else S8(fcccp, fcc_gfemr, 0x20); } fcc_cr_cmd(fep, CPM_CR_INIT_TRX); /* clear events */ W16(fccp, fcc_fcce, 0xffff); /* Enable interrupts we wish to service */ W16(fccp, fcc_fccm, FCC_ENET_TXE | FCC_ENET_RXF | FCC_ENET_TXB); /* Set GFMR to enable Ethernet operating mode */ W32(fccp, fcc_gfmr, FCC_GFMR_TCI | FCC_GFMR_MODE_ENET); /* set sync/delimiters */ W16(fccp, fcc_fdsr, 0xd555); W32(fccp, fcc_fpsmr, FCC_PSMR_ENCRC); if (fpi->use_rmii) S32(fccp, fcc_fpsmr, FCC_PSMR_RMII); /* adjust to duplex mode */ if (fep->phydev->duplex) S32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB); else C32(fccp, fcc_fpsmr, FCC_PSMR_FDE | FCC_PSMR_LPB); /* Restore multicast and promiscuous settings */ set_multicast_list(dev); S32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT); }
/* * This function is called to start or restart the FEC during a link * change. This only happens when switching between half and full * duplex. */ static void restart(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); scc_t __iomem *sccp = fep->scc.sccp; scc_enet_t __iomem *ep = fep->scc.ep; const struct fs_platform_info *fpi = fep->fpi; u16 paddrh, paddrm, paddrl; const unsigned char *mac; int i; C32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); /* clear everything (slow & steady does it) */ for (i = 0; i < sizeof(*ep); i++) __fs_out8((u8 __iomem *)ep + i, 0); /* point to bds */ W16(ep, sen_genscc.scc_rbase, fep->ring_mem_addr); W16(ep, sen_genscc.scc_tbase, fep->ring_mem_addr + sizeof(cbd_t) * fpi->rx_ring); /* Initialize function code registers for big-endian. */ #ifndef CONFIG_NOT_COHERENT_CACHE W8(ep, sen_genscc.scc_rfcr, SCC_EB | SCC_GBL); W8(ep, sen_genscc.scc_tfcr, SCC_EB | SCC_GBL); #else W8(ep, sen_genscc.scc_rfcr, SCC_EB); W8(ep, sen_genscc.scc_tfcr, SCC_EB); #endif /* Set maximum bytes per receive buffer. * This appears to be an Ethernet frame size, not the buffer * fragment size. It must be a multiple of four. */ W16(ep, sen_genscc.scc_mrblr, 0x5f0); /* Set CRC preset and mask. */ W32(ep, sen_cpres, 0xffffffff); W32(ep, sen_cmask, 0xdebb20e3); W32(ep, sen_crcec, 0); /* CRC Error counter */ W32(ep, sen_alec, 0); /* alignment error counter */ W32(ep, sen_disfc, 0); /* discard frame counter */ W16(ep, sen_pads, 0x8888); /* Tx short frame pad character */ W16(ep, sen_retlim, 15); /* Retry limit threshold */ W16(ep, sen_maxflr, 0x5ee); /* maximum frame length register */ W16(ep, sen_minflr, PKT_MINBUF_SIZE); /* minimum frame length register */ W16(ep, sen_maxd1, 0x000005f0); /* maximum DMA1 length */ W16(ep, sen_maxd2, 0x000005f0); /* maximum DMA2 length */ /* Clear hash tables. */ W16(ep, sen_gaddr1, 0); W16(ep, sen_gaddr2, 0); W16(ep, sen_gaddr3, 0); W16(ep, sen_gaddr4, 0); W16(ep, sen_iaddr1, 0); W16(ep, sen_iaddr2, 0); W16(ep, sen_iaddr3, 0); W16(ep, sen_iaddr4, 0); /* set address */ mac = dev->dev_addr; paddrh = ((u16) mac[5] << 8) | mac[4]; paddrm = ((u16) mac[3] << 8) | mac[2]; paddrl = ((u16) mac[1] << 8) | mac[0]; W16(ep, sen_paddrh, paddrh); W16(ep, sen_paddrm, paddrm); W16(ep, sen_paddrl, paddrl); W16(ep, sen_pper, 0); W16(ep, sen_taddrl, 0); W16(ep, sen_taddrm, 0); W16(ep, sen_taddrh, 0); fs_init_bds(dev); scc_cr_cmd(fep, CPM_CR_INIT_TRX); W16(sccp, scc_scce, 0xffff); /* Enable interrupts we wish to service. */ W16(sccp, scc_sccm, SCCE_ENET_TXE | SCCE_ENET_RXF | SCCE_ENET_TXB); /* Set GSMR_H to enable all normal operating modes. * Set GSMR_L to enable Ethernet to MC68160. */ W32(sccp, scc_gsmrh, 0); W32(sccp, scc_gsmrl, SCC_GSMRL_TCI | SCC_GSMRL_TPL_48 | SCC_GSMRL_TPP_10 | SCC_GSMRL_MODE_ENET); /* Set sync/delimiters. */ W16(sccp, scc_dsr, 0xd555); /* Set processing mode. Use Ethernet CRC, catch broadcast, and * start frame search 22 bit times after RENA. */ W16(sccp, scc_psmr, SCC_PSMR_ENCRC | SCC_PSMR_NIB22); /* Set full duplex mode if needed */ if (fep->phydev->duplex) S16(sccp, scc_psmr, SCC_PSMR_LPB | SCC_PSMR_FDE); S32(sccp, scc_gsmrl, SCC_GSMRL_ENR | SCC_GSMRL_ENT); }
void Io::Write32 (uint32_t add, uint32_t val) { //debug ("IO Write32 at " << IOS_ADD << add << " of " << IOS_ADD << val); switch (add & 0xFF) { case DMA1DAD: case DMA0SAD: case DMA1SAD: case DMA2SAD: case DMA3SAD: case DMA0DAD: case DMA2DAD: case DMA3DAD: W32(add, val); break; case BG0HOFS: case BG1HOFS: case BG2HOFS: case BG3HOFS: Write16(add, val & 0xFFFF); Write16(add+2, val >> 16); break; case BG2X_L: W32(add, val & 0x0FFFFFFF); LCD.UpdateBg2RefX(IO.DRead32(Io::BG2X_L)); break; case BG2Y_L: W32(add, val & 0x0FFFFFFF); LCD.UpdateBg2RefY(IO.DRead32(Io::BG2Y_L)); break; case BG3X_L: W32(add, val & 0x0FFFFFFF); LCD.UpdateBg3RefX(IO.DRead32(Io::BG3X_L)); break; case BG3Y_L: W32(add, val & 0x0FFFFFFF); LCD.UpdateBg3RefY(IO.DRead32(Io::BG3Y_L)); break; case BG2PA: case BG2PC: case BG3PA: case BG3PC: case WIN0H: case WIN0V: case WININ: Write16(add, val & 0xFFFF); Write16(add+2, val >> 16); break; case DMA0CNT_L: case DMA1CNT_L: case DMA2CNT_L: case DMA3CNT_L: Write16(add, val & 0xFFFF); Write16(add+2, val >> 16); break; case FIFO_A: case FIFO_B: // TODO break; default: //met_abort("Unknown IO at " << IOS_ADD << add); //*(uint32_t*)(m_iomem + (add & 0xFFF)) = val; Write16(add, val & 0xFFFF); Write16(add+2, val >> 16); break; } }
void GCAMUpdateRegisters( void ) { u32 i; u32 *GInterface = (u32*)(GCAM_BASE); u32 *GInterfaceS = (u32*)(GCAM_SHADOW); sync_before_read( (void*)GCAM_BASE, 0x40 ); if( read32(GCAM_CONTROL) != 0xdeadbeef ) { if( read32( GCAM_CONTROL ) & (~3) ) { write32( GCAM_CONTROL, 0xdeadbeef ); sync_after_write( (void*)GCAM_BASE, 0x40 ); return; } /*write32( GCAM_SCONTROL, read32(GCAM_CONTROL) & 3 ); clear32( GCAM_SSTATUS, 0x14 ); write32( GCAM_CONTROL, 0xdeadbeef ); write32( GCAM_RETURN, 0xdeadbeef ); write32( GCAM_STATUS, 0xdeadbeef ); sync_after_write( (void*)GCAM_BASE, 0x40 );*/ for( i=0; i < 5; ++i ) { if( GInterface[i] != 0xdeadbeef ) { GInterfaceS[i] = GInterface[i]; GInterface[i] = 0xdeadbeef; } } switch( read32(GCAM_SCMD) >> 24 ) { case 0x00: { //dbgprintf("CARD:Warning unknown command!\n"); } break; case 0x50: { char *datain = (char*)P2C( read32(GCAM_SCMD_1) ); u32 lenin = read32(GCAM_SCMD_2); char *dataout = (char*)P2C( read32(GCAM_SCMD_3) ); u32 lenout = read32(GCAM_SCMD_4); #ifdef DEBUG_GCAM dbgprintf("SI:Transfer( %p, %u, %p, %u )\n", datain, lenin, dataout, lenout ); hexdump( datain, lenin ); #endif sync_before_read_align32(datain, lenin); switch( datain[0] ) { // dbgprintf("[%02X]", datain[0] ); case 0x00: { W32( (u32)dataout, 0x10110800 ); // dbgprintf("Reset(0x%p)\n", dataout ); } break; default: // CMD_DIRECT case 0x40: // CMD_ORIGIN case 0x41: // CMD_RECALIBRATE case 0x42: { memset( dataout, 0, lenout ); } break; } sync_after_write_align32(dataout, lenout); //hexdump( dataout, lenout ); //while( read32(GCAM_CONTROL) & 1 ) // clear32( GCAM_CONTROL, 1 ); //while( (read32(GCAM_SSTATUS) & 0x10) != 0x10 ) // set32( GCAM_SSTATUS, 0x10 ); } break; case 0x70: { char *datain = (char*)P2C( read32(GCAM_SCMD_1) ); char *dataout = (char*)P2C( read32(GCAM_SCMD_2) ); //dbgprintf("GC-AM:Command( %p, %u, %p, %u )\n", datain, 0x80, dataout, 0x80 ); sync_before_read_align32(datain, 0x80); memcpy( Bufi, datain, 0x80 ); GCAMCommand( Bufi, Buf ); if( FirstCMD == 0 ) { memset32( dataout, 0, 0x80 ); FirstCMD = 1; } else { memcpy( dataout, Bufo, 0x80 ); memcpy( Bufo, Buf, 0x80 ); } sync_after_write_align32(dataout, 0x80); //hexdump( dataout, 0x10 ); //while( read32(GCAM_CONTROL) & 1 ) // clear32( GCAM_CONTROL, 1 ); //while( (read32(GCAM_SSTATUS) & 0x10) != 0x10 ) // set32( GCAM_SSTATUS, 0x10 ); } break; default: { dbgprintf("Unhandled cmd:%02X\n", read32(GCAM_SCMD) ); Shutdown(); } break; } //to be 100% sure we dont ever read a still cached block in ppc write32( GCAM_CONTROL, 0xdeadbeef ); sync_after_write( (void*)GCAM_BASE, 0x40 ); } }
static void restart(struct net_device *dev) { struct fs_enet_private *fep = netdev_priv(dev); const struct fs_platform_info *fpi = fep->fpi; fcc_t __iomem *fccp = fep->fcc.fccp; fcc_c_t __iomem *fcccp = fep->fcc.fcccp; fcc_enet_t __iomem *ep = fep->fcc.ep; dma_addr_t rx_bd_base_phys, tx_bd_base_phys; u16 paddrh, paddrm, paddrl; const unsigned char *mac; int i; C32(fccp, fcc_gfmr, FCC_GFMR_ENR | FCC_GFMR_ENT); /* clear everything (slow & steady does it) */ for (i = 0; i < sizeof(*ep); i++) out_8((u8 __iomem *)ep + i, 0); /* get physical address */ rx_bd_base_phys = fep->ring_mem_addr; tx_bd_base_phys = rx_bd_base_phys + sizeof(cbd_t) * fpi->rx_ring; /* point to bds */ W32(ep, fen_genfcc.fcc_rbase, rx_bd_base_phys); W32(ep, fen_genfcc.fcc_tbase, tx_bd_base_phys); /* Set maximum bytes per receive buffer. * It must be a multiple of 32. */ W16(ep, fen_genfcc.fcc_mrblr, PKT_MAXBLR_SIZE); W32(ep, fen_genfcc.fcc_rstate, (CPMFCR_GBL | CPMFCR_EB) << 24); W32(ep, fen_genfcc.fcc_tstate, (CPMFCR_GBL | CPMFCR_EB) << 24); /* Allocate space in the reserved FCC area of DPRAM for the * internal buffers. No one uses this space (yet), so we * can do this. Later, we will add resource management for * this area. */ W16(ep, fen_genfcc.fcc_riptr, fpi->dpram_offset); W16(ep, fen_genfcc.fcc_tiptr, fpi->dpram_offset + 32); W16(ep, fen_padptr, fpi->dpram_offset + 64); /* fill with special symbol... */ memset_io(fep->fcc.mem + fpi->dpram_offset + 64, 0x88, 32); W32(ep, fen_genfcc.fcc_rbptr, 0); W32(ep, fen_genfcc.fcc_tbptr, 0); W32(ep, fen_genfcc.fcc_rcrc, 0); W32(ep, fen_genfcc.fcc_tcrc, 0); W16(ep, fen_genfcc.fcc_res1, 0); W32(ep, fen_genfcc.fcc_res2, 0); /* no CAM */ W32(ep, fen_camptr, 0); /* Set CRC preset and mask */ W32(ep, fen_cmask, 0xdebb20e3); W32(ep, fen_cpres, 0xffffffff); W32(ep, fen_crcec, 0); /* CRC Error counter */ W32(ep, fen_alec, 0); /* alignment error counte
static void pl192_end_interrupt(phantom_device_t *dev) { // EIO W32( dev->iobase + VIC_REG_VECTOR_ADDR, 0 ); }
static void pl192_unmask_irq(phantom_device_t *dev, unsigned int irq) { irq &= 31; W32( dev->iobase + VIC_REG_INTENABLE, 1 << irq); }