generic: b53: remove empty spaces
[openwrt/openwrt.git] / target / linux / generic / files / drivers / net / phy / b53 / b53_phy_fixup.c
1 /*
2 * B53 PHY Fixup call
3 *
4 * Copyright (C) 2013 Jonas Gorski <jogo@openwrt.org>
5 *
6 * Permission to use, copy, modify, and/or distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <linux/phy.h>
22
23 #define B53_PSEUDO_PHY 0x1e /* Register Access Pseudo PHY */
24
25 #define B53_BRCM_OUI_1 0x0143bc00
26 #define B53_BRCM_OUI_2 0x03625c00
27
28 static int b53_phy_fixup(struct phy_device *dev)
29 {
30 u32 phy_id;
31 struct mii_bus *bus = dev->bus;
32
33 if (dev->addr != B53_PSEUDO_PHY)
34 return 0;
35
36 /* read the first port's id */
37 phy_id = mdiobus_read(bus, 0, 2) << 16;
38 phy_id |= mdiobus_read(bus, 0, 3);
39
40 if ((phy_id & 0xfffffc00) == B53_BRCM_OUI_1 ||
41 (phy_id & 0xfffffc00) == B53_BRCM_OUI_2) {
42 dev->phy_id = phy_id;
43 }
44
45 return 0;
46 }
47
48 int __init b53_phy_fixup_register(void)
49 {
50 return phy_register_fixup_for_id(PHY_ANY_ID, b53_phy_fixup);
51 }
52
53 subsys_initcall(b53_phy_fixup_register);