From 3cee1388927015fc96edcd6e3ed707cb3a5fa26b Mon Sep 17 00:00:00 2001 From: Codrin Ciubotariu Date: Fri, 13 Feb 2015 14:47:58 +0200 Subject: net: phy: realtek: Disable interrupt on Realtek Ethernet PHY drivers Some Realtek Ethernet PHYs, like RTL8211D(G/N) and RTL8211E(G), have interrupts enabled by default. If the interrupt is not treated later by the OS and the PHY's interrupt line is enabled and shared with other interrupts, the system will get an interrupt storm. This patch disables the interrupt for PHY devices that use one of the current Realtek Ethernet PHY drivers. Some of Realtek Ethernet PHYs, such as RTL8211B(L) have the interrupt masked. In this case, the functionality of the PHY should not be afected since this patch brings INER and INSR registers to their default values. Signed-off-by: Codrin Ciubotariu Acked-by: Joe Hershberger diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index a3ace68..ee97079 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: GPL-2.0+ * - * Copyright 2010-2011 Freescale Semiconductor, Inc. + * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc. * author Andy Fleming */ #include @@ -21,12 +21,28 @@ #define MIIM_RTL8211x_PHYSTAT_SPDDONE 0x0800 #define MIIM_RTL8211x_PHYSTAT_LINK 0x0400 +/* RTL8211x PHY Interrupt Enable Register */ +#define MIIM_RTL8211x_PHY_INER 0x12 +#define MIIM_RTL8211x_PHY_INTR_ENA 0x9f01 +#define MIIM_RTL8211x_PHY_INTR_DIS 0x0000 + +/* RTL8211x PHY Interrupt Status Register */ +#define MIIM_RTL8211x_PHY_INSR 0x13 /* RealTek RTL8211x */ static int rtl8211x_config(struct phy_device *phydev) { phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET); + /* mask interrupt at init; if the interrupt is + * needed indeed, it should be explicitly enabled + */ + phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER, + MIIM_RTL8211x_PHY_INTR_DIS); + + /* read interrupt status just to clear it */ + phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER); + genphy_config_aneg(phydev); return 0; -- cgit v0.10.2 From 744152f8cf426ee939fc469925ebafca89fe14d5 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Fri, 20 Mar 2015 12:41:21 +0100 Subject: net: rtl8169: Build warning fixes for 64-bit Turn ioaddr into an unsigned long rather than a sized 32-bit variable. While at it, fix a couple of pointer to integer cast size mismatch warnings by casting through unsigned long going from pointers to integers and vice versa. Cc: Joe Hershberger Signed-off-by: Thierry Reding Acked-by: Joe Hershberger diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c index 4a53710..958488c 100644 --- a/drivers/net/rtl8169.c +++ b/drivers/net/rtl8169.c @@ -55,7 +55,7 @@ #define drv_version "v1.5" #define drv_date "01-17-2004" -static u32 ioaddr; +static unsigned long ioaddr; /* Condensed operations for readability. */ #define currticks() get_timer(0) @@ -92,19 +92,21 @@ static int media[MAX_UNITS] = { -1, -1, -1, -1, -1, -1, -1, -1 }; #define TX_TIMEOUT (6*HZ) /* write/read MMIO register. Notice: {read,write}[wl] do the necessary swapping */ -#define RTL_W8(reg, val8) writeb ((val8), ioaddr + (reg)) -#define RTL_W16(reg, val16) writew ((val16), ioaddr + (reg)) -#define RTL_W32(reg, val32) writel ((val32), ioaddr + (reg)) -#define RTL_R8(reg) readb (ioaddr + (reg)) -#define RTL_R16(reg) readw (ioaddr + (reg)) -#define RTL_R32(reg) ((unsigned long) readl (ioaddr + (reg))) +#define RTL_W8(reg, val8) writeb((val8), ioaddr + (reg)) +#define RTL_W16(reg, val16) writew((val16), ioaddr + (reg)) +#define RTL_W32(reg, val32) writel((val32), ioaddr + (reg)) +#define RTL_R8(reg) readb(ioaddr + (reg)) +#define RTL_R16(reg) readw(ioaddr + (reg)) +#define RTL_R32(reg) readl(ioaddr + (reg)) #define ETH_FRAME_LEN MAX_ETH_FRAME_SIZE #define ETH_ALEN MAC_ADDR_LEN #define ETH_ZLEN 60 -#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)dev->priv, (pci_addr_t)a) -#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)dev->priv, (phys_addr_t)a) +#define bus_to_phys(a) pci_mem_to_phys((pci_dev_t)(unsigned long)dev->priv, \ + (pci_addr_t)(unsigned long)a) +#define phys_to_bus(a) pci_phys_to_mem((pci_dev_t)(unsigned long)dev->priv, \ + (phys_addr_t)a) enum RTL8169_registers { MAC0 = 0, /* Ethernet hardware address. */ @@ -852,7 +854,7 @@ static int rtl_init(struct eth_device *dev, bd_t *bis) #ifdef DEBUG_RTL8169 /* Print out some hardware info */ - printf("%s: at ioaddr 0x%x\n", dev->name, ioaddr); + printf("%s: at ioaddr 0x%lx\n", dev->name, ioaddr); #endif /* if TBI is not endbled */ @@ -1004,7 +1006,7 @@ int rtl8169_initialize(bd_t *bis) memset(dev, 0, sizeof(*dev)); sprintf (dev->name, "RTL8169#%d", card_number); - dev->priv = (void *) devno; + dev->priv = (void *)(unsigned long)devno; dev->iobase = (int)pci_mem_to_phys(devno, iobase); dev->init = rtl_reset; -- cgit v0.10.2 From a60de1ee7fc49480b90996eef7bbeb66e67a7808 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Fri, 20 Mar 2015 13:25:57 -0500 Subject: Update MAINTAINERS and git-mailrc for net Update to my corporate email and make the supported filter and aliases more accurate. Signed-off-by: Joe Hershberger diff --git a/MAINTAINERS b/MAINTAINERS index 26d0d27..067fb22 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -328,10 +328,11 @@ T: git git://git.denx.de/u-boot-ppc4xx.git F: arch/powerpc/cpu/ppc4xx/ NETWORK -M: Joe Hershberger +M: Joe Hershberger S: Maintained T: git git://git.denx.de/u-boot-net.git F: drivers/net/ +F: net/ NAND FLASH M: Scott Wood diff --git a/doc/git-mailrc b/doc/git-mailrc index 5f8438e..174109f 100644 --- a/doc/git-mailrc +++ b/doc/git-mailrc @@ -24,7 +24,7 @@ alias ijc Ian Campbell alias iwamatsu Nobuhiro Iwamatsu alias jagan Jagannadha Sutradharudu Teki alias jasonjin Jason Jin -alias jhersh Joe Hershberger +alias jhersh Joe Hershberger alias jwrdegoede Hans de Goede alias kimphill Kim Phillips alias luka Luka Perkov @@ -113,6 +113,7 @@ alias x86 uboot, sjg, gruss alias dm uboot, sjg alias cfi uboot, stroese alias dfu uboot, lukma +alias eth uboot, jhersh alias kerneldoc uboot, marex alias fdt uboot, sjg alias i2c uboot, hs @@ -120,6 +121,7 @@ alias kconfig uboot, masahiro alias mmc uboot, panto alias nand uboot, scottwood alias net uboot, jhersh +alias phy uboot, jhersh alias spi uboot, jagan alias ubi uboot, hs alias usb uboot, marex -- cgit v0.10.2 From a095f047ebf3ee098e7b84197d765029e0797dd3 Mon Sep 17 00:00:00 2001 From: Tim James Date: Wed, 25 Mar 2015 11:55:15 +0000 Subject: mii: add read-modify-write option to mii command When accessing PHY registers it is often desirable to only update selected bits, so it is necessary to first read the current value before writing back an modified value with the relevant bits updated. To simplify this and to allow such operations to be incorporated into simple shell scripts propose adding a 'modify' option to the existing mii command, which takes a mask indicating the bits to be updated in addition to a data value containing the new bits, ie, = ( & ) | ( & ~). Signed-off-by: Tim Cc: Nobuhiro Iwamatsu Cc: Joe Hershberger Cc: Jeroen Hofstee Cc: Tom Rini Cc: Tim diff --git a/common/cmd_mii.c b/common/cmd_mii.c index 7c4a57a..5e9079d 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -249,6 +249,7 @@ static uint last_addr_lo; static uint last_addr_hi; static uint last_reg_lo; static uint last_reg_hi; +static uint last_mask; static void extract_range( char * input, @@ -272,7 +273,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) char op[2]; unsigned char addrlo, addrhi, reglo, reghi; unsigned char addr, reg; - unsigned short data; + unsigned short data, mask; int rcode = 0; const char *devname; @@ -294,6 +295,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) reglo = last_reg_lo; reghi = last_reg_hi; data = last_data; + mask = last_mask; if ((flag & CMD_FLAG_REPEAT) == 0) { op[0] = argv[1][0]; @@ -307,7 +309,9 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if (argc >= 4) extract_range(argv[3], ®lo, ®hi); if (argc >= 5) - data = simple_strtoul (argv[4], NULL, 16); + data = simple_strtoul(argv[4], NULL, 16); + if (argc >= 6) + mask = simple_strtoul(argv[5], NULL, 16); } /* use current device */ @@ -375,6 +379,28 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } } } + } else if (op[0] == 'm') { + for (addr = addrlo; addr <= addrhi; addr++) { + for (reg = reglo; reg <= reghi; reg++) { + unsigned short val = 0; + if (miiphy_read(devname, addr, + reg, &val)) { + printf("Error reading from the PHY"); + printf(" addr=%02x", addr); + printf(" reg=%02x\n", reg); + rcode = 1; + } else { + val = (val & ~mask) | (data & mask); + if (miiphy_write(devname, addr, + reg, val)) { + printf("Error writing to the PHY"); + printf(" addr=%02x", addr); + printf(" reg=%02x\n", reg); + rcode = 1; + } + } + } + } } else if (strncmp(op, "du", 2) == 0) { ushort regs[6]; int ok = 1; @@ -417,6 +443,7 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) last_reg_lo = reglo; last_reg_hi = reghi; last_data = data; + last_mask = mask; return rcode; } @@ -424,13 +451,15 @@ static int do_mii(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) /***************************************************/ U_BOOT_CMD( - mii, 5, 1, do_mii, + mii, 6, 1, do_mii, "MII utility commands", - "device - list available devices\n" - "mii device - set current device\n" - "mii info - display MII PHY info\n" - "mii read - read MII PHY register \n" - "mii write - write MII PHY register \n" - "mii dump - pretty-print (0-5 only)\n" + "device - list available devices\n" + "mii device - set current device\n" + "mii info - display MII PHY info\n" + "mii read - read MII PHY register \n" + "mii write - write MII PHY register \n" + "mii modify - modify MII PHY register \n" + " updating bits identified in \n" + "mii dump - pretty-print (0-5 only)\n" "Addr and/or reg may be ranges, e.g. 2-7." ); -- cgit v0.10.2 From c6a40f6e518c4fb900ec6a46a7fc1d1d354beb3a Mon Sep 17 00:00:00 2001 From: Luca Ellero Date: Tue, 24 Mar 2015 11:32:24 +0100 Subject: net: phy: micrel: add support for KSZ8081MNX This patch adds a support for KSZ8081MNX in MII mode. Signed-off-by: Luca Ellero Acked-by: Pavel Machek diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 1815b29..49f444a 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -22,6 +22,16 @@ static struct phy_driver KSZ804_driver = { .shutdown = &genphy_shutdown, }; +static struct phy_driver KSZ8081_driver = { + .name = "Micrel KSZ8081", + .uid = 0x221560, + .mask = 0xfffff0, + .features = PHY_BASIC_FEATURES, + .config = &genphy_config, + .startup = &genphy_startup, + .shutdown = &genphy_shutdown, +}; + /** * KSZ8895 */ @@ -272,6 +282,7 @@ static struct phy_driver ksz9031_driver = { int phy_micrel_init(void) { phy_register(&KSZ804_driver); + phy_register(&KSZ8081_driver); #ifdef CONFIG_PHY_MICREL_KSZ9021 phy_register(&ksz9021_driver); #else -- cgit v0.10.2 From 5707d5ffd42a45088f433a2514d1320a6491697b Mon Sep 17 00:00:00 2001 From: Shengzhou Liu Date: Tue, 7 Apr 2015 18:46:32 +0800 Subject: net/phy: fixup for get_phy_id commit 3c6928fd7b0f84 "net: phy: fix warnings with W=1" caused some PHYs(e.g. CS4315/CS4340) not working. This patch fixes the warning and make those special PHYs working as well. Signed-off-by: Shengzhou Liu diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 9d88afe..f5221a3 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -582,7 +582,7 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr, * Description: Reads the ID registers of the PHY at @addr on the * @bus, stores it in @phy_id and returns zero on success. */ -static int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id) +int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id) { int phy_reg; diff --git a/include/phy.h b/include/phy.h index 384dc23..3f826b6 100644 --- a/include/phy.h +++ b/include/phy.h @@ -254,6 +254,7 @@ int phy_teranetics_init(void); int phy_vitesse_init(void); int board_phy_config(struct phy_device *phydev); +int get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id); /** * phy_get_interface_by_name() - Look up a PHY interface name -- cgit v0.10.2 From 9ce1edc8d0d8d994b09ed01d1ec5815967ad9ac8 Mon Sep 17 00:00:00 2001 From: Michal Simek Date: Wed, 15 Apr 2015 13:31:28 +0200 Subject: net: gem: Use correct type for casting Use phys_addr_t which is used in function prototype in system.h. Signed-off-by: Michal Simek diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 74fda70..c723dbb 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -513,7 +513,8 @@ int zynq_gem_initialize(bd_t *bis, phys_addr_t base_addr, /* Align bd_space to 1MB */ bd_space = memalign(1 << MMU_SECTION_SHIFT, BD_SPACE); - mmu_set_region_dcache_behaviour((u32)bd_space, BD_SPACE, DCACHE_OFF); + mmu_set_region_dcache_behaviour((phys_addr_t)bd_space, + BD_SPACE, DCACHE_OFF); /* Initialize the bd spaces for tx and rx bd's */ priv->tx_bd = (struct emac_bd *)bd_space; -- cgit v0.10.2 From 523bb66f5a8e2cee22535e509c4e762bbc774406 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 15 Apr 2015 11:18:20 +0800 Subject: net: pch_gbe: Fix pch_gbe device name The name "pch_gbe.%x" exceeds the limit of the name in the 'struct eth_device'. Rename it as just "pch_gbe". Signed-off-by: Bin Meng diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index 15c9cdc..a03bdc0 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -446,7 +446,7 @@ int pch_gbe_register(bd_t *bis) dev->iobase = iobase; priv->mac_regs = (struct pch_gbe_regs *)iobase; - sprintf(dev->name, "pch_gbe.%x", iobase); + sprintf(dev->name, "pch_gbe"); /* Read MAC address from SROM and initialize dev->enetaddr with it */ pch_gbe_mac_read(priv->mac_regs, dev->enetaddr); -- cgit v0.10.2