Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bff713b5 authored by Benjamin Herrenschmidt's avatar Benjamin Herrenschmidt Committed by Jeff Garzik
Browse files

ibm_newemac: Cleanup/fix support for STACR register variants



There are a few variants of the STACR register that affect more than
just the "AXON" version of EMAC. Replace the current test of various
chip models with tests for generic properties in the device-tree.

Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: default avatarStefan Roese <sr@denx.de>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 1f57877a
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -274,6 +274,8 @@
				zmii-channel = <0>;
				zmii-channel = <0>;
				rgmii-device = <&RGMII0>;
				rgmii-device = <&RGMII0>;
				rgmii-channel = <0>;
				rgmii-channel = <0>;
				has-inverted-stacr-oc;
				has-new-stacr-staopc;
			};
			};


			EMAC1: ethernet@ef600f00 {
			EMAC1: ethernet@ef600f00 {
@@ -302,6 +304,8 @@
				zmii-channel = <1>;
				zmii-channel = <1>;
				rgmii-device = <&RGMII0>;
				rgmii-device = <&RGMII0>;
				rgmii-channel = <1>;
				rgmii-channel = <1>;
				has-inverted-stacr-oc;
				has-new-stacr-staopc;
			};
			};
		};
		};
	};
	};
+13 −10
Original line number Original line Diff line number Diff line
@@ -711,7 +711,7 @@ static int __emac_mdio_read(struct emac_instance *dev, u8 id, u8 reg)
		r = EMAC_STACR_BASE(dev->opb_bus_freq);
		r = EMAC_STACR_BASE(dev->opb_bus_freq);
	if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT))
	if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT))
		r |= EMAC_STACR_OC;
		r |= EMAC_STACR_OC;
	if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR))
	if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR))
		r |= EMACX_STACR_STAC_READ;
		r |= EMACX_STACR_STAC_READ;
	else
	else
		r |= EMAC_STACR_STAC_READ;
		r |= EMAC_STACR_STAC_READ;
@@ -783,7 +783,7 @@ static void __emac_mdio_write(struct emac_instance *dev, u8 id, u8 reg,
		r = EMAC_STACR_BASE(dev->opb_bus_freq);
		r = EMAC_STACR_BASE(dev->opb_bus_freq);
	if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT))
	if (emac_has_feature(dev, EMAC_FTR_STACR_OC_INVERT))
		r |= EMAC_STACR_OC;
		r |= EMAC_STACR_OC;
	if (emac_has_feature(dev, EMAC_FTR_HAS_AXON_STACR))
	if (emac_has_feature(dev, EMAC_FTR_HAS_NEW_STACR))
		r |= EMACX_STACR_STAC_WRITE;
		r |= EMACX_STACR_STAC_WRITE;
	else
	else
		r |= EMAC_STACR_STAC_WRITE;
		r |= EMAC_STACR_STAC_WRITE;
@@ -2480,16 +2480,19 @@ static int __devinit emac_init_config(struct emac_instance *dev)
	/* Check EMAC version */
	/* Check EMAC version */
	if (of_device_is_compatible(np, "ibm,emac4"))
	if (of_device_is_compatible(np, "ibm,emac4"))
		dev->features |= EMAC_FTR_EMAC4;
		dev->features |= EMAC_FTR_EMAC4;
	if (of_device_is_compatible(np, "ibm,emac-axon")

	    || of_device_is_compatible(np, "ibm,emac-440epx"))
	/* Fixup some feature bits based on the device tree */
		dev->features |= EMAC_FTR_HAS_AXON_STACR
	if (of_get_property(np, "has-inverted-stacr-oc", NULL))
			| EMAC_FTR_STACR_OC_INVERT;
	if (of_device_is_compatible(np, "ibm,emac-440spe"))
		dev->features |= EMAC_FTR_STACR_OC_INVERT;
		dev->features |= EMAC_FTR_STACR_OC_INVERT;
	if (of_get_property(np, "has-new-stacr-staopc", NULL))
		dev->features |= EMAC_FTR_HAS_NEW_STACR;


	/* Fixup some feature bits based on the device tree and verify
	/* CAB lacks the appropriate properties */
	 * we have support for them compiled in
	if (of_device_is_compatible(np, "ibm,emac-axon"))
	 */
		dev->features |= EMAC_FTR_HAS_NEW_STACR |
			EMAC_FTR_STACR_OC_INVERT;

	/* Enable TAH/ZMII/RGMII features as found */
	if (dev->tah_ph != 0) {
	if (dev->tah_ph != 0) {
#ifdef CONFIG_IBM_NEW_EMAC_TAH
#ifdef CONFIG_IBM_NEW_EMAC_TAH
		dev->features |= EMAC_FTR_HAS_TAH;
		dev->features |= EMAC_FTR_HAS_TAH;
+3 −3
Original line number Original line Diff line number Diff line
@@ -293,9 +293,9 @@ struct emac_instance {
 */
 */
#define EMAC_FTR_HAS_RGMII		0x00000020
#define EMAC_FTR_HAS_RGMII		0x00000020
/*
/*
 * Set if we have axon-type STACR
 * Set if we have new type STACR with STAOPC
 */
 */
#define EMAC_FTR_HAS_AXON_STACR		0x00000040
#define EMAC_FTR_HAS_NEW_STACR		0x00000040




/* Right now, we don't quite handle the always/possible masks on the
/* Right now, we don't quite handle the always/possible masks on the
@@ -307,7 +307,7 @@ enum {


	EMAC_FTRS_POSSIBLE	=
	EMAC_FTRS_POSSIBLE	=
#ifdef CONFIG_IBM_NEW_EMAC_EMAC4
#ifdef CONFIG_IBM_NEW_EMAC_EMAC4
	    EMAC_FTR_EMAC4	| EMAC_FTR_HAS_AXON_STACR	|
	    EMAC_FTR_EMAC4	| EMAC_FTR_HAS_NEW_STACR	|
	    EMAC_FTR_STACR_OC_INVERT	|
	    EMAC_FTR_STACR_OC_INVERT	|
#endif
#endif
#ifdef CONFIG_IBM_NEW_EMAC_TAH
#ifdef CONFIG_IBM_NEW_EMAC_TAH