Exemplo n.º 1
0
static int m88e1149_config_init(struct phy_device *phydev)
{
	int err;

	/* Change address */
	err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
	if (err < 0)
		return err;

	/* Enable 1000 Mbit */
	err = phy_write(phydev, 0x15, 0x1048);
	if (err < 0)
		return err;

	err = marvell_of_reg_init(phydev);
	if (err < 0)
		return err;

	/* Reset address */
	err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
	if (err < 0)
		return err;

	return phy_write(phydev, MII_BMCR, BMCR_RESET);
}
Exemplo n.º 2
0
static int m88e1149_config_init(struct phy_device *phydev)
{
	int err;

	/*                */
	err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
	if (err < 0)
		return err;

	/*                  */
	err = phy_write(phydev, 0x15, 0x1048);
	if (err < 0)
		return err;

	err = marvell_of_reg_init(phydev);
	if (err < 0)
		return err;

	/*               */
	err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
	if (err < 0)
		return err;

	err = phy_write(phydev, MII_BMCR, BMCR_RESET);
	if (err < 0)
		return err;

	return 0;
}
Exemplo n.º 3
0
static int m88e1510_config_aneg(struct phy_device *phydev)
{
	int err;

	err = m88e1318_config_aneg(phydev);
	if (err < 0)
		return err;

	return marvell_of_reg_init(phydev);
}
Exemplo n.º 4
0
static int m88e1118_config_init(struct phy_device *phydev)
{
    int err;

    /* Change address */
    err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
    if (err < 0)
        return err;

    /* Enable 1000 Mbit */
    err = phy_write(phydev, 0x15, 0x1070);
    if (err < 0)
        return err;

    /* Change address */
    err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
    if (err < 0)
        return err;

    /* Adjust LED Control */
    if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
        err = phy_write(phydev, 0x10, 0x1100);
    else
        err = phy_write(phydev, 0x10, 0x021e);
    if (err < 0)
        return err;

    err = marvell_of_reg_init(phydev);
    if (err < 0)
        return err;

    /* Reset address */
    err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
    if (err < 0)
        return err;

    err = phy_write(phydev, MII_BMCR, BMCR_RESET);
    if (err < 0)
        return err;

    return 0;
}
Exemplo n.º 5
0
static int m88e1145_config_init(struct phy_device *phydev)
{
	int err;
	int temp;

	/* Take care of errata E0 & E1 */
	err = phy_write(phydev, 0x1d, 0x001b);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1e, 0x418f);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1d, 0x0016);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1e, 0xa2da);
	if (err < 0)
		return err;

	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
		int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
		if (temp < 0)
			return temp;

		temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);

		err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
		if (err < 0)
			return err;

		if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
			err = phy_write(phydev, 0x1d, 0x0012);
			if (err < 0)
				return err;

			temp = phy_read(phydev, 0x1e);
			if (temp < 0)
				return temp;

			temp &= 0xf03f;
			temp |= 2 << 9;	/* 36 ohm */
			temp |= 2 << 6;	/* 39 ohm */

			err = phy_write(phydev, 0x1e, temp);
			if (err < 0)
				return err;

			err = phy_write(phydev, 0x1d, 0x3);
			if (err < 0)
				return err;

			err = phy_write(phydev, 0x1e, 0x8000);
			if (err < 0)
				return err;
		}
	}

	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
		temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
		if (temp < 0)
			return temp;

		temp &= ~MII_M1145_HWCFG_MODE_MASK;
		temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
		temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;

		err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
		if (err < 0)
			return err;
	}

	err = marvell_of_reg_init(phydev);
	if (err < 0)
		return err;

	return 0;
}
Exemplo n.º 6
0
static int m88e1111_config_init(struct phy_device *phydev)
{
	int err;
	int temp;

	if (phy_interface_is_rgmii(phydev)) {

		temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
		if (temp < 0)
			return temp;

		if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
			temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
		} else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
			temp &= ~MII_M1111_TX_DELAY;
			temp |= MII_M1111_RX_DELAY;
		} else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
			temp &= ~MII_M1111_RX_DELAY;
			temp |= MII_M1111_TX_DELAY;
		}

		err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
		if (err < 0)
			return err;

		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
		if (temp < 0)
			return temp;

		temp &= ~(MII_M1111_HWCFG_MODE_MASK);

		if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
			temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
		else
			temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;

		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
		if (err < 0)
			return err;
	}

	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
		if (temp < 0)
			return temp;

		temp &= ~(MII_M1111_HWCFG_MODE_MASK);
		temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
		temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;

		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
		if (err < 0)
			return err;

		/* make sure copper is selected */
		err = phy_read(phydev, MII_M1145_PHY_EXT_ADDR_PAGE);
		if (err < 0)
			return err;

		err = phy_write(phydev, MII_M1145_PHY_EXT_ADDR_PAGE,
				err & (~0xff));
		if (err < 0)
			return err;
	}

	if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
		temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
		if (temp < 0)
			return temp;
		temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
		err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
		if (err < 0)
			return err;

		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
		if (temp < 0)
			return temp;
		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
		temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
		if (err < 0)
			return err;

		/* soft reset */
		err = phy_write(phydev, MII_BMCR, BMCR_RESET);
		if (err < 0)
			return err;
		do
			temp = phy_read(phydev, MII_BMCR);
		while (temp & BMCR_RESET);

		temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
		if (temp < 0)
			return temp;
		temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
		temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
		err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
		if (err < 0)
			return err;
	}

	err = marvell_of_reg_init(phydev);
	if (err < 0)
		return err;

	return phy_write(phydev, MII_BMCR, BMCR_RESET);
}
Exemplo n.º 7
0
static int marvell_config_init(struct phy_device *phydev)
{
	/* Set registers from marvell,reg-init DT property */
	return marvell_of_reg_init(phydev);
}
Exemplo n.º 8
0
static int m88e1111_config_init(struct phy_device *phydev)
{
    int err;
    int temp;

    /* Enable Fiber/Copper auto selection */
    temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
    temp &= ~MII_M1111_HWCFG_FIBER_COPPER_AUTO;
    phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);

    temp = phy_read(phydev, MII_BMCR);
    temp |= BMCR_RESET;
    phy_write(phydev, MII_BMCR, temp);

    if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
            (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
            (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
            (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {

        temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
        if (temp < 0)
            return temp;

        if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
            temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
        } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
            temp &= ~MII_M1111_TX_DELAY;
            temp |= MII_M1111_RX_DELAY;
        } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
            temp &= ~MII_M1111_RX_DELAY;
            temp |= MII_M1111_TX_DELAY;
        }

        err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
        if (err < 0)
            return err;

        temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
        if (temp < 0)
            return temp;

        temp &= ~(MII_M1111_HWCFG_MODE_MASK);

        if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
            temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
        else
            temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;

        err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
        if (err < 0)
            return err;
    }

    if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
        temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
        if (temp < 0)
            return temp;

        temp &= ~(MII_M1111_HWCFG_MODE_MASK);
        temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
        temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;

        err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
        if (err < 0)
            return err;
    }

    if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
        temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
        if (temp < 0)
            return temp;
        temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
        err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
        if (err < 0)
            return err;

        temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
        if (temp < 0)
            return temp;
        temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
        temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
        err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
        if (err < 0)
            return err;

        /* soft reset */
        err = phy_write(phydev, MII_BMCR, BMCR_RESET);
        if (err < 0)
            return err;
        do
            temp = phy_read(phydev, MII_BMCR);
        while (temp & BMCR_RESET);

        temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
        if (temp < 0)
            return temp;
        temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
        temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
        err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
        if (err < 0)
            return err;
    }

    err = marvell_of_reg_init(phydev);
    if (err < 0)
        return err;

    err = phy_write(phydev, MII_BMCR, BMCR_RESET);
    if (err < 0)
        return err;

    return 0;
}
Exemplo n.º 9
0
static int m88e1145_config_init(struct phy_device *phydev)
{
	int err;

	/*                             */
	err = phy_write(phydev, 0x1d, 0x001b);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1e, 0x418f);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1d, 0x0016);
	if (err < 0)
		return err;

	err = phy_write(phydev, 0x1e, 0xa2da);
	if (err < 0)
		return err;

	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
		int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
		if (temp < 0)
			return temp;

		temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);

		err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
		if (err < 0)
			return err;

		if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
			err = phy_write(phydev, 0x1d, 0x0012);
			if (err < 0)
				return err;

			temp = phy_read(phydev, 0x1e);
			if (temp < 0)
				return temp;

			temp &= 0xf03f;
			temp |= 2 << 9;	/*        */
			temp |= 2 << 6;	/*        */

			err = phy_write(phydev, 0x1e, temp);
			if (err < 0)
				return err;

			err = phy_write(phydev, 0x1d, 0x3);
			if (err < 0)
				return err;

			err = phy_write(phydev, 0x1e, 0x8000);
			if (err < 0)
				return err;
		}
	}

	err = marvell_of_reg_init(phydev);
	if (err < 0)
		return err;

	return 0;
}