forked from Minki/linux
net/fsl_pq_mdio: fix computed address for the TBI register
commitafae5ad78b
"net/fsl_pq_mdio: streamline probing of MDIO nodes" added support for different types of MDIO devices: 1) Gianfar MDIO nodes that only map the MII registers 2) Gianfar MDIO nodes that map the full MDIO register set 3) eTSEC2 MDIO nodes (which map the full MDIO register set) 4) QE MDIO nodes (which map only the MII registers) However, the implementation for types 1 and 4 would mistakenly assume a mapping of the full MDIO register set, thereby computing the address for the TBI register starting from the containing structure. The TBI register would therefore be accessed at a wrong (much bigger) address, not giving the expected result at all. This patch restores the correct behavior we had prior to the above one. The consequences of this bug are apparent when trying to access a PHY with the same address as the value contained in the initial value of the TBI register (normally 0); in that case you'll get answers from the internal TBI device (even though MDIO/MDC pins are actually *also* toggling on the physical bus!). Beware that you also need to add a fake tbi node to your device tree with an unused address. Notice how this fix is related to commit220669495b
"powerpc: Add TBI PHY node to first MDIO bus" which fixed the behavior in kernel 3.3, which was later broken by the above commit on kernel 3.7. Signed-off-by: Gerlando Falauto <gerlando.falauto@keymile.com> Cc: Timur Tabi <timur@tabi.org> Cc: David S. Miller <davem@davemloft.net> Cc: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
3dd03e52a4
commit
3bb35ac497
@ -198,17 +198,28 @@ static int fsl_pq_mdio_reset(struct mii_bus *bus)
|
||||
|
||||
#if defined(CONFIG_GIANFAR) || defined(CONFIG_GIANFAR_MODULE)
|
||||
/*
|
||||
* Return the TBIPA address, starting from the address
|
||||
* of the mapped GFAR MDIO registers (struct gfar)
|
||||
* This is mildly evil, but so is our hardware for doing this.
|
||||
* Also, we have to cast back to struct gfar because of
|
||||
* definition weirdness done in gianfar.h.
|
||||
*/
|
||||
static uint32_t __iomem *get_gfar_tbipa(void __iomem *p)
|
||||
static uint32_t __iomem *get_gfar_tbipa_from_mdio(void __iomem *p)
|
||||
{
|
||||
struct gfar __iomem *enet_regs = p;
|
||||
|
||||
return &enet_regs->tbipa;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the TBIPA address, starting from the address
|
||||
* of the mapped GFAR MII registers (gfar_mii_regs[] within struct gfar)
|
||||
*/
|
||||
static uint32_t __iomem *get_gfar_tbipa_from_mii(void __iomem *p)
|
||||
{
|
||||
return get_gfar_tbipa_from_mdio(container_of(p, struct gfar, gfar_mii_regs));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the TBIPAR address for an eTSEC2 node
|
||||
*/
|
||||
@ -220,11 +231,12 @@ static uint32_t __iomem *get_etsec_tbipa(void __iomem *p)
|
||||
|
||||
#if defined(CONFIG_UCC_GETH) || defined(CONFIG_UCC_GETH_MODULE)
|
||||
/*
|
||||
* Return the TBIPAR address for a QE MDIO node
|
||||
* Return the TBIPAR address for a QE MDIO node, starting from the address
|
||||
* of the mapped MII registers (struct fsl_pq_mii)
|
||||
*/
|
||||
static uint32_t __iomem *get_ucc_tbipa(void __iomem *p)
|
||||
{
|
||||
struct fsl_pq_mdio __iomem *mdio = p;
|
||||
struct fsl_pq_mdio __iomem *mdio = container_of(p, struct fsl_pq_mdio, mii);
|
||||
|
||||
return &mdio->utbipar;
|
||||
}
|
||||
@ -300,14 +312,14 @@ static const struct of_device_id fsl_pq_mdio_match[] = {
|
||||
.compatible = "fsl,gianfar-tbi",
|
||||
.data = &(struct fsl_pq_mdio_data) {
|
||||
.mii_offset = 0,
|
||||
.get_tbipa = get_gfar_tbipa,
|
||||
.get_tbipa = get_gfar_tbipa_from_mii,
|
||||
},
|
||||
},
|
||||
{
|
||||
.compatible = "fsl,gianfar-mdio",
|
||||
.data = &(struct fsl_pq_mdio_data) {
|
||||
.mii_offset = 0,
|
||||
.get_tbipa = get_gfar_tbipa,
|
||||
.get_tbipa = get_gfar_tbipa_from_mii,
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -315,7 +327,7 @@ static const struct of_device_id fsl_pq_mdio_match[] = {
|
||||
.compatible = "gianfar",
|
||||
.data = &(struct fsl_pq_mdio_data) {
|
||||
.mii_offset = offsetof(struct fsl_pq_mdio, mii),
|
||||
.get_tbipa = get_gfar_tbipa,
|
||||
.get_tbipa = get_gfar_tbipa_from_mdio,
|
||||
},
|
||||
},
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user