FreeBSD/sys/dev/cadence/if_cgem.c
/* Call to set reference clock and network config bits according to media. */
Call to set reference clock and network config bits according to media.
Call to set reference clock and network config bits according to media .
static void
cgem_mediachange(struct cgem_softc *sc,	struct mii_data *mii)
{
	uint32_t net_cfg;
	int ref_clk_freq;
	CGEM_ASSERT_LOCKED(sc);
	net_cfg = RD4(sc, CGEM_NET_CFG);
	net_cfg &= ~(CGEM_NET_CFG_SPEED100 | CGEM_NET_CFG_GIGE_EN |
		     CGEM_NET_CFG_FULL_DUPLEX);
	switch (IFM_SUBTYPE(mii->mii_media_active)) {
	case IFM_1000_T:
		net_cfg |= (CGEM_NET_CFG_SPEED100 |
			    CGEM_NET_CFG_GIGE_EN);
		ref_clk_freq = 125000000;
		break;
	case IFM_100_TX:
		net_cfg |= CGEM_NET_CFG_SPEED100;
		ref_clk_freq = 25000000;
		break;
	default:
		ref_clk_freq = 2500000;
	}
	if ((mii->mii_media_active & IFM_FDX) != 0)
		net_cfg |= CGEM_NET_CFG_FULL_DUPLEX;
	WR4(sc, CGEM_NET_CFG, net_cfg);
	if (cgem_set_ref_clk(sc->ref_clk_num, ref_clk_freq))
		device_printf(sc->dev, "cgem_mediachange: "
			      "could not set ref clk%d to %d.\n",
			      sc->ref_clk_num, ref_clk_freq);
	sc->mii_media_active = mii->mii_media_active;
}
static void cgem_mediachange ( struct cgem_softc * sc , struct mii_data * mii ) { uint32_t net_cfg ; int ref_clk_freq ; CGEM_ASSERT_LOCKED ( sc ) ; net_cfg = RD4 ( sc , CGEM_NET_CFG ) ; net_cfg &= ~ ( CGEM_NET_CFG_SPEED100 | CGEM_NET_CFG_GIGE_EN | CGEM_NET_CFG_FULL_DUPLEX ) ; switch ( IFM_SUBTYPE ( mii -> mii_media_active ) ) { case IFM_1000_T : net_cfg |= ( CGEM_NET_CFG_SPEED100 | CGEM_NET_CFG_GIGE_EN ) ; ref_clk_freq = 125000000 ; break ; case IFM_100_TX : net_cfg |= CGEM_NET_CFG_SPEED100 ; ref_clk_freq = 25000000 ; break ; default : ref_clk_freq = 2500000 ; } if ( ( mii -> mii_media_active & IFM_FDX ) != 0 ) net_cfg |= CGEM_NET_CFG_FULL_DUPLEX ; WR4 ( sc , CGEM_NET_CFG , net_cfg ) ; if ( cgem_set_ref_clk ( sc -> ref_clk_num , ref_clk_freq ) ) device_printf ( sc -> dev , " " " \n " , sc -> ref_clk_num , ref_clk_freq ) ; sc -> mii_media_active = mii -> mii_media_active ; }
Call to set reference clock and network config bits according to media.
Call to set reference clock and network config bits according to media .
/* Update hardware to reflect media. */ /* Set the reference clock if necessary. */