Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2005 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * Author: Shlomi Gridish |
| 5 | * |
| 6 | * Description: UCC GETH Driver -- PHY handling |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 7 | * Driver for UEC on QE |
| 8 | * Based on 8260_io/fcc_enet.c |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 9 | * |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 10 | * This program is free software; you can redistribute it and/or modify it |
| 11 | * under the terms of the GNU General Public License as published by the |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 12 | * Free Software Foundation; either version 2 of the License, or (at your |
| 13 | * option) any later version. |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | #include "common.h" |
| 18 | #include "net.h" |
| 19 | #include "malloc.h" |
| 20 | #include "asm/errno.h" |
| 21 | #include "asm/immap_qe.h" |
| 22 | #include "asm/io.h" |
| 23 | #include "qe.h" |
| 24 | #include "uccf.h" |
| 25 | #include "uec.h" |
| 26 | #include "uec_phy.h" |
| 27 | #include "miiphy.h" |
| 28 | |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 29 | #define ugphy_printk(format, arg...) \ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 30 | printf(format "\n", ## arg) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 31 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 32 | #define ugphy_dbg(format, arg...) \ |
| 33 | ugphy_printk(format , ## arg) |
| 34 | #define ugphy_err(format, arg...) \ |
| 35 | ugphy_printk(format , ## arg) |
| 36 | #define ugphy_info(format, arg...) \ |
| 37 | ugphy_printk(format , ## arg) |
| 38 | #define ugphy_warn(format, arg...) \ |
| 39 | ugphy_printk(format , ## arg) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 40 | |
| 41 | #ifdef UEC_VERBOSE_DEBUG |
| 42 | #define ugphy_vdbg ugphy_dbg |
| 43 | #else |
| 44 | #define ugphy_vdbg(ugeth, fmt, args...) do { } while (0) |
| 45 | #endif /* UEC_VERBOSE_DEBUG */ |
| 46 | |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 47 | /*--------------------------------------------------------------------+ |
| 48 | * Fixed PHY (PHY-less) support for Ethernet Ports. |
| 49 | * |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 50 | * Copied from arch/powerpc/cpu/ppc4xx/4xx_enet.c |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 51 | *--------------------------------------------------------------------*/ |
| 52 | |
| 53 | /* |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 54 | * Some boards do not have a PHY for each ethernet port. These ports are known |
| 55 | * as Fixed PHY (or PHY-less) ports. For such ports, set the appropriate |
| 56 | * CONFIG_SYS_UECx_PHY_ADDR equal to CONFIG_FIXED_PHY_ADDR (an unused address) |
| 57 | * When the drver tries to identify the PHYs, CONFIG_FIXED_PHY will be returned |
| 58 | * and the driver will search CONFIG_SYS_FIXED_PHY_PORTS to find what network |
| 59 | * speed and duplex should be for the port. |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 60 | * |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 61 | * Example board header configuration file: |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 62 | * #define CONFIG_FIXED_PHY 0xFFFFFFFF |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 63 | * #define CONFIG_SYS_FIXED_PHY_ADDR 0x1E (pick an unused phy address) |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 64 | * |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 65 | * #define CONFIG_SYS_UEC1_PHY_ADDR CONFIG_SYS_FIXED_PHY_ADDR |
| 66 | * #define CONFIG_SYS_UEC2_PHY_ADDR 0x02 |
| 67 | * #define CONFIG_SYS_UEC3_PHY_ADDR CONFIG_SYS_FIXED_PHY_ADDR |
| 68 | * #define CONFIG_SYS_UEC4_PHY_ADDR 0x04 |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 69 | * |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 70 | * #define CONFIG_SYS_FIXED_PHY_PORT(name,speed,duplex) \ |
| 71 | * {name, speed, duplex}, |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 72 | * |
| 73 | * #define CONFIG_SYS_FIXED_PHY_PORTS \ |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 74 | * CONFIG_SYS_FIXED_PHY_PORT("FSL UEC0",SPEED_100,DUPLEX_FULL) \ |
| 75 | * CONFIG_SYS_FIXED_PHY_PORT("FSL UEC2",SPEED_100,DUPLEX_HALF) |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 76 | */ |
| 77 | |
| 78 | #ifndef CONFIG_FIXED_PHY |
| 79 | #define CONFIG_FIXED_PHY 0xFFFFFFFF /* Fixed PHY (PHY-less) */ |
| 80 | #endif |
| 81 | |
| 82 | #ifndef CONFIG_SYS_FIXED_PHY_PORTS |
| 83 | #define CONFIG_SYS_FIXED_PHY_PORTS /* default is an empty array */ |
| 84 | #endif |
| 85 | |
| 86 | struct fixed_phy_port { |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 87 | char name[NAMESIZE]; /* ethernet port name */ |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 88 | unsigned int speed; /* specified speed 10,100 or 1000 */ |
| 89 | unsigned int duplex; /* specified duplex FULL or HALF */ |
| 90 | }; |
| 91 | |
| 92 | static const struct fixed_phy_port fixed_phy_port[] = { |
| 93 | CONFIG_SYS_FIXED_PHY_PORTS /* defined in board configuration file */ |
| 94 | }; |
| 95 | |
Richard Retanubun | 23c34af | 2009-06-17 16:00:41 -0400 | [diff] [blame] | 96 | /*--------------------------------------------------------------------+ |
| 97 | * BitBang MII support for ethernet ports |
| 98 | * |
| 99 | * Based from MPC8560ADS implementation |
| 100 | *--------------------------------------------------------------------*/ |
| 101 | /* |
| 102 | * Example board header file to define bitbang ethernet ports: |
| 103 | * |
| 104 | * #define CONFIG_SYS_BITBANG_PHY_PORT(name) name, |
| 105 | * #define CONFIG_SYS_BITBANG_PHY_PORTS CONFIG_SYS_BITBANG_PHY_PORT("FSL UEC0") |
| 106 | */ |
| 107 | #ifndef CONFIG_SYS_BITBANG_PHY_PORTS |
| 108 | #define CONFIG_SYS_BITBANG_PHY_PORTS /* default is an empty array */ |
| 109 | #endif |
| 110 | |
| 111 | #if defined(CONFIG_BITBANGMII) |
| 112 | static const char *bitbang_phy_port[] = { |
| 113 | CONFIG_SYS_BITBANG_PHY_PORTS /* defined in board configuration file */ |
| 114 | }; |
| 115 | #endif /* CONFIG_BITBANGMII */ |
| 116 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 117 | static void config_genmii_advert (struct uec_mii_info *mii_info); |
| 118 | static void genmii_setup_forced (struct uec_mii_info *mii_info); |
| 119 | static void genmii_restart_aneg (struct uec_mii_info *mii_info); |
| 120 | static int gbit_config_aneg (struct uec_mii_info *mii_info); |
| 121 | static int genmii_config_aneg (struct uec_mii_info *mii_info); |
| 122 | static int genmii_update_link (struct uec_mii_info *mii_info); |
| 123 | static int genmii_read_status (struct uec_mii_info *mii_info); |
| 124 | u16 phy_read (struct uec_mii_info *mii_info, u16 regnum); |
| 125 | void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 126 | |
| 127 | /* Write value to the PHY for this device to the register at regnum, */ |
| 128 | /* waiting until the write is done before it returns. All PHY */ |
| 129 | /* configuration has to be done through the TSEC1 MIIM regs */ |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 130 | void uec_write_phy_reg (struct eth_device *dev, int mii_id, int regnum, int value) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 131 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 132 | uec_private_t *ugeth = (uec_private_t *) dev->priv; |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 133 | uec_mii_t *ug_regs; |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 134 | enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; |
| 135 | u32 tmp_reg; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 136 | |
Richard Retanubun | 23c34af | 2009-06-17 16:00:41 -0400 | [diff] [blame] | 137 | |
| 138 | #if defined(CONFIG_BITBANGMII) |
| 139 | u32 i = 0; |
| 140 | |
| 141 | for (i = 0; i < ARRAY_SIZE(bitbang_phy_port); i++) { |
| 142 | if (strncmp(dev->name, bitbang_phy_port[i], |
| 143 | sizeof(dev->name)) == 0) { |
| 144 | (void)bb_miiphy_write(NULL, mii_id, regnum, value); |
| 145 | return; |
| 146 | } |
| 147 | } |
| 148 | #endif /* CONFIG_BITBANGMII */ |
| 149 | |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 150 | ug_regs = ugeth->uec_mii_regs; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 151 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 152 | /* Stop the MII management read cycle */ |
| 153 | out_be32 (&ug_regs->miimcom, 0); |
| 154 | /* Setting up the MII Mangement Address Register */ |
| 155 | tmp_reg = ((u32) mii_id << MIIMADD_PHY_ADDRESS_SHIFT) | mii_reg; |
| 156 | out_be32 (&ug_regs->miimadd, tmp_reg); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 157 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 158 | /* Setting up the MII Mangement Control Register with the value */ |
| 159 | out_be32 (&ug_regs->miimcon, (u32) value); |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 160 | sync(); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 161 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 162 | /* Wait till MII management write is complete */ |
| 163 | while ((in_be32 (&ug_regs->miimind)) & MIIMIND_BUSY); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | /* Reads from register regnum in the PHY for device dev, */ |
| 167 | /* returning the value. Clears miimcom first. All PHY */ |
| 168 | /* configuration has to be done through the TSEC1 MIIM regs */ |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 169 | int uec_read_phy_reg (struct eth_device *dev, int mii_id, int regnum) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 170 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 171 | uec_private_t *ugeth = (uec_private_t *) dev->priv; |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 172 | uec_mii_t *ug_regs; |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 173 | enet_tbi_mii_reg_e mii_reg = (enet_tbi_mii_reg_e) regnum; |
| 174 | u32 tmp_reg; |
| 175 | u16 value; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 176 | |
Richard Retanubun | 23c34af | 2009-06-17 16:00:41 -0400 | [diff] [blame] | 177 | |
| 178 | #if defined(CONFIG_BITBANGMII) |
| 179 | u32 i = 0; |
| 180 | |
| 181 | for (i = 0; i < ARRAY_SIZE(bitbang_phy_port); i++) { |
| 182 | if (strncmp(dev->name, bitbang_phy_port[i], |
| 183 | sizeof(dev->name)) == 0) { |
| 184 | (void)bb_miiphy_read(NULL, mii_id, regnum, &value); |
| 185 | return (value); |
| 186 | } |
| 187 | } |
| 188 | #endif /* CONFIG_BITBANGMII */ |
| 189 | |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 190 | ug_regs = ugeth->uec_mii_regs; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 191 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 192 | /* Setting up the MII Mangement Address Register */ |
| 193 | tmp_reg = ((u32) mii_id << MIIMADD_PHY_ADDRESS_SHIFT) | mii_reg; |
| 194 | out_be32 (&ug_regs->miimadd, tmp_reg); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 195 | |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 196 | /* clear MII management command cycle */ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 197 | out_be32 (&ug_regs->miimcom, 0); |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 198 | sync(); |
| 199 | |
| 200 | /* Perform an MII management read cycle */ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 201 | out_be32 (&ug_regs->miimcom, MIIMCOM_READ_CYCLE); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 202 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 203 | /* Wait till MII management write is complete */ |
| 204 | while ((in_be32 (&ug_regs->miimind)) & |
| 205 | (MIIMIND_NOT_VALID | MIIMIND_BUSY)); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 206 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 207 | /* Read MII management status */ |
| 208 | value = (u16) in_be32 (&ug_regs->miimstat); |
| 209 | if (value == 0xffff) |
Joakim Tjernlund | 84a3047 | 2008-01-16 09:40:41 +0100 | [diff] [blame] | 210 | ugphy_vdbg |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 211 | ("read wrong value : mii_id %d,mii_reg %d, base %08x", |
| 212 | mii_id, mii_reg, (u32) & (ug_regs->miimcfg)); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 213 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 214 | return (value); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 215 | } |
| 216 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 217 | void mii_clear_phy_interrupt (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 218 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 219 | if (mii_info->phyinfo->ack_interrupt) |
| 220 | mii_info->phyinfo->ack_interrupt (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 221 | } |
| 222 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 223 | void mii_configure_phy_interrupt (struct uec_mii_info *mii_info, |
| 224 | u32 interrupts) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 225 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 226 | mii_info->interrupts = interrupts; |
| 227 | if (mii_info->phyinfo->config_intr) |
| 228 | mii_info->phyinfo->config_intr (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 229 | } |
| 230 | |
| 231 | /* Writes MII_ADVERTISE with the appropriate values, after |
| 232 | * sanitizing advertise to make sure only supported features |
| 233 | * are advertised |
| 234 | */ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 235 | static void config_genmii_advert (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 236 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 237 | u32 advertise; |
| 238 | u16 adv; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 239 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 240 | /* Only allow advertising what this PHY supports */ |
| 241 | mii_info->advertising &= mii_info->phyinfo->features; |
| 242 | advertise = mii_info->advertising; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 243 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 244 | /* Setup standard advertisement */ |
| 245 | adv = phy_read (mii_info, PHY_ANAR); |
| 246 | adv &= ~(ADVERTISE_ALL | ADVERTISE_100BASE4); |
| 247 | if (advertise & ADVERTISED_10baseT_Half) |
| 248 | adv |= ADVERTISE_10HALF; |
| 249 | if (advertise & ADVERTISED_10baseT_Full) |
| 250 | adv |= ADVERTISE_10FULL; |
| 251 | if (advertise & ADVERTISED_100baseT_Half) |
| 252 | adv |= ADVERTISE_100HALF; |
| 253 | if (advertise & ADVERTISED_100baseT_Full) |
| 254 | adv |= ADVERTISE_100FULL; |
| 255 | phy_write (mii_info, PHY_ANAR, adv); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 256 | } |
| 257 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 258 | static void genmii_setup_forced (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 259 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 260 | u16 ctrl; |
| 261 | u32 features = mii_info->phyinfo->features; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 262 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 263 | ctrl = phy_read (mii_info, PHY_BMCR); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 264 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 265 | ctrl &= ~(PHY_BMCR_DPLX | PHY_BMCR_100_MBPS | |
| 266 | PHY_BMCR_1000_MBPS | PHY_BMCR_AUTON); |
| 267 | ctrl |= PHY_BMCR_RESET; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 268 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 269 | switch (mii_info->speed) { |
| 270 | case SPEED_1000: |
| 271 | if (features & (SUPPORTED_1000baseT_Half |
| 272 | | SUPPORTED_1000baseT_Full)) { |
| 273 | ctrl |= PHY_BMCR_1000_MBPS; |
| 274 | break; |
| 275 | } |
| 276 | mii_info->speed = SPEED_100; |
| 277 | case SPEED_100: |
| 278 | if (features & (SUPPORTED_100baseT_Half |
| 279 | | SUPPORTED_100baseT_Full)) { |
| 280 | ctrl |= PHY_BMCR_100_MBPS; |
| 281 | break; |
| 282 | } |
| 283 | mii_info->speed = SPEED_10; |
| 284 | case SPEED_10: |
| 285 | if (features & (SUPPORTED_10baseT_Half |
| 286 | | SUPPORTED_10baseT_Full)) |
| 287 | break; |
| 288 | default: /* Unsupported speed! */ |
| 289 | ugphy_err ("%s: Bad speed!", mii_info->dev->name); |
| 290 | break; |
| 291 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 292 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 293 | phy_write (mii_info, PHY_BMCR, ctrl); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | /* Enable and Restart Autonegotiation */ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 297 | static void genmii_restart_aneg (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 298 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 299 | u16 ctl; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 300 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 301 | ctl = phy_read (mii_info, PHY_BMCR); |
| 302 | ctl |= (PHY_BMCR_AUTON | PHY_BMCR_RST_NEG); |
| 303 | phy_write (mii_info, PHY_BMCR, ctl); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 304 | } |
| 305 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 306 | static int gbit_config_aneg (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 307 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 308 | u16 adv; |
| 309 | u32 advertise; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 310 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 311 | if (mii_info->autoneg) { |
| 312 | /* Configure the ADVERTISE register */ |
| 313 | config_genmii_advert (mii_info); |
| 314 | advertise = mii_info->advertising; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 315 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 316 | adv = phy_read (mii_info, MII_1000BASETCONTROL); |
| 317 | adv &= ~(MII_1000BASETCONTROL_FULLDUPLEXCAP | |
| 318 | MII_1000BASETCONTROL_HALFDUPLEXCAP); |
| 319 | if (advertise & SUPPORTED_1000baseT_Half) |
| 320 | adv |= MII_1000BASETCONTROL_HALFDUPLEXCAP; |
| 321 | if (advertise & SUPPORTED_1000baseT_Full) |
| 322 | adv |= MII_1000BASETCONTROL_FULLDUPLEXCAP; |
| 323 | phy_write (mii_info, MII_1000BASETCONTROL, adv); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 324 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 325 | /* Start/Restart aneg */ |
| 326 | genmii_restart_aneg (mii_info); |
| 327 | } else |
| 328 | genmii_setup_forced (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 329 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 330 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 331 | } |
| 332 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 333 | static int marvell_config_aneg (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 334 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 335 | /* The Marvell PHY has an errata which requires |
| 336 | * that certain registers get written in order |
| 337 | * to restart autonegotiation */ |
| 338 | phy_write (mii_info, PHY_BMCR, PHY_BMCR_RESET); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 339 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 340 | phy_write (mii_info, 0x1d, 0x1f); |
| 341 | phy_write (mii_info, 0x1e, 0x200c); |
| 342 | phy_write (mii_info, 0x1d, 0x5); |
| 343 | phy_write (mii_info, 0x1e, 0); |
| 344 | phy_write (mii_info, 0x1e, 0x100); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 345 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 346 | gbit_config_aneg (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 347 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 348 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 349 | } |
| 350 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 351 | static int genmii_config_aneg (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 352 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 353 | if (mii_info->autoneg) { |
| 354 | config_genmii_advert (mii_info); |
| 355 | genmii_restart_aneg (mii_info); |
| 356 | } else |
| 357 | genmii_setup_forced (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 358 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 359 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 360 | } |
| 361 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 362 | static int genmii_update_link (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 363 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 364 | u16 status; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 365 | |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 366 | /* Status is read once to clear old link state */ |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 367 | phy_read (mii_info, PHY_BMSR); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 368 | |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 369 | /* |
| 370 | * Wait if the link is up, and autonegotiation is in progress |
| 371 | * (ie - we're capable and it's not done) |
| 372 | */ |
| 373 | status = phy_read(mii_info, PHY_BMSR); |
| 374 | if ((status & PHY_BMSR_LS) && (status & PHY_BMSR_AUTN_ABLE) |
| 375 | && !(status & PHY_BMSR_AUTN_COMP)) { |
| 376 | int i = 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 377 | |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 378 | while (!(status & PHY_BMSR_AUTN_COMP)) { |
| 379 | /* |
| 380 | * Timeout reached ? |
| 381 | */ |
| 382 | if (i > UGETH_AN_TIMEOUT) { |
| 383 | mii_info->link = 0; |
| 384 | return 0; |
| 385 | } |
| 386 | |
Kim Phillips | f30b6154 | 2008-02-27 16:08:22 -0600 | [diff] [blame] | 387 | i++; |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 388 | udelay(1000); /* 1 ms */ |
| 389 | status = phy_read(mii_info, PHY_BMSR); |
| 390 | } |
| 391 | mii_info->link = 1; |
| 392 | udelay(500000); /* another 500 ms (results in faster booting) */ |
| 393 | } else { |
| 394 | if (status & PHY_BMSR_LS) |
| 395 | mii_info->link = 1; |
| 396 | else |
| 397 | mii_info->link = 0; |
| 398 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 399 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 400 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 401 | } |
| 402 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 403 | static int genmii_read_status (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 404 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 405 | u16 status; |
| 406 | int err; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 407 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 408 | /* Update the link, but return if there |
| 409 | * was an error */ |
| 410 | err = genmii_update_link (mii_info); |
| 411 | if (err) |
| 412 | return err; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 413 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 414 | if (mii_info->autoneg) { |
Anton Vorontsov | 91cdaa3 | 2008-03-24 20:46:24 +0300 | [diff] [blame] | 415 | status = phy_read(mii_info, MII_1000BASETSTATUS); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 416 | |
Anton Vorontsov | 91cdaa3 | 2008-03-24 20:46:24 +0300 | [diff] [blame] | 417 | if (status & (LPA_1000FULL | LPA_1000HALF)) { |
| 418 | mii_info->speed = SPEED_1000; |
| 419 | if (status & LPA_1000FULL) |
| 420 | mii_info->duplex = DUPLEX_FULL; |
| 421 | else |
| 422 | mii_info->duplex = DUPLEX_HALF; |
| 423 | } else { |
| 424 | status = phy_read(mii_info, PHY_ANLPAR); |
| 425 | |
| 426 | if (status & (PHY_ANLPAR_10FD | PHY_ANLPAR_TXFD)) |
| 427 | mii_info->duplex = DUPLEX_FULL; |
| 428 | else |
| 429 | mii_info->duplex = DUPLEX_HALF; |
| 430 | if (status & (PHY_ANLPAR_TXFD | PHY_ANLPAR_TX)) |
| 431 | mii_info->speed = SPEED_100; |
| 432 | else |
| 433 | mii_info->speed = SPEED_10; |
| 434 | } |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 435 | mii_info->pause = 0; |
| 436 | } |
| 437 | /* On non-aneg, we assume what we put in BMCR is the speed, |
| 438 | * though magic-aneg shouldn't prevent this case from occurring |
| 439 | */ |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 440 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 441 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 442 | } |
| 443 | |
Anton Vorontsov | 300615d | 2008-03-24 20:46:34 +0300 | [diff] [blame] | 444 | static int bcm_init(struct uec_mii_info *mii_info) |
| 445 | { |
| 446 | struct eth_device *edev = mii_info->dev; |
| 447 | uec_private_t *uec = edev->priv; |
| 448 | |
| 449 | gbit_config_aneg(mii_info); |
| 450 | |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 451 | if ((uec->uec_info->enet_interface_type == RGMII_RXID) && |
| 452 | (uec->uec_info->speed == 1000)) { |
Anton Vorontsov | 300615d | 2008-03-24 20:46:34 +0300 | [diff] [blame] | 453 | u16 val; |
| 454 | int cnt = 50; |
| 455 | |
| 456 | /* Wait for aneg to complete. */ |
| 457 | do |
| 458 | val = phy_read(mii_info, PHY_BMSR); |
| 459 | while (--cnt && !(val & PHY_BMSR_AUTN_COMP)); |
| 460 | |
| 461 | /* Set RDX clk delay. */ |
| 462 | phy_write(mii_info, 0x18, 0x7 | (7 << 12)); |
| 463 | |
| 464 | val = phy_read(mii_info, 0x18); |
| 465 | /* Set RDX-RXC skew. */ |
| 466 | val |= (1 << 8); |
| 467 | val |= (7 | (7 << 12)); |
| 468 | /* Write bits 14:0. */ |
| 469 | val |= (1 << 15); |
| 470 | phy_write(mii_info, 0x18, val); |
| 471 | } |
| 472 | |
| 473 | return 0; |
| 474 | } |
| 475 | |
Haiying Wang | 41410ee | 2008-09-24 11:42:12 -0500 | [diff] [blame] | 476 | static int marvell_init(struct uec_mii_info *mii_info) |
| 477 | { |
| 478 | struct eth_device *edev = mii_info->dev; |
| 479 | uec_private_t *uec = edev->priv; |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 480 | enum enet_interface_type iface = uec->uec_info->enet_interface_type; |
| 481 | int speed = uec->uec_info->speed; |
Haiying Wang | 41410ee | 2008-09-24 11:42:12 -0500 | [diff] [blame] | 482 | |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 483 | if ((speed == 1000) && |
| 484 | (iface == RGMII_ID || |
| 485 | iface == RGMII_RXID || |
| 486 | iface == RGMII_TXID)) { |
Haiying Wang | 41410ee | 2008-09-24 11:42:12 -0500 | [diff] [blame] | 487 | int temp; |
| 488 | |
| 489 | temp = phy_read(mii_info, MII_M1111_PHY_EXT_CR); |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 490 | if (iface == RGMII_ID) { |
Anton Vorontsov | 6185f80 | 2009-09-16 23:21:53 +0400 | [diff] [blame] | 491 | temp |= MII_M1111_RX_DELAY | MII_M1111_TX_DELAY; |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 492 | } else if (iface == RGMII_RXID) { |
Anton Vorontsov | 6185f80 | 2009-09-16 23:21:53 +0400 | [diff] [blame] | 493 | temp &= ~MII_M1111_TX_DELAY; |
| 494 | temp |= MII_M1111_RX_DELAY; |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 495 | } else if (iface == RGMII_TXID) { |
Anton Vorontsov | 6185f80 | 2009-09-16 23:21:53 +0400 | [diff] [blame] | 496 | temp &= ~MII_M1111_RX_DELAY; |
| 497 | temp |= MII_M1111_TX_DELAY; |
| 498 | } |
Haiying Wang | 41410ee | 2008-09-24 11:42:12 -0500 | [diff] [blame] | 499 | phy_write(mii_info, MII_M1111_PHY_EXT_CR, temp); |
| 500 | |
| 501 | temp = phy_read(mii_info, MII_M1111_PHY_EXT_SR); |
| 502 | temp &= ~MII_M1111_HWCFG_MODE_MASK; |
| 503 | temp |= MII_M1111_HWCFG_MODE_RGMII; |
| 504 | phy_write(mii_info, MII_M1111_PHY_EXT_SR, temp); |
| 505 | |
| 506 | phy_write(mii_info, PHY_BMCR, PHY_BMCR_RESET); |
| 507 | } |
| 508 | |
| 509 | return 0; |
| 510 | } |
| 511 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 512 | static int marvell_read_status (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 513 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 514 | u16 status; |
| 515 | int err; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 516 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 517 | /* Update the link, but return if there |
| 518 | * was an error */ |
| 519 | err = genmii_update_link (mii_info); |
| 520 | if (err) |
| 521 | return err; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 522 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 523 | /* If the link is up, read the speed and duplex */ |
| 524 | /* If we aren't autonegotiating, assume speeds |
| 525 | * are as set */ |
| 526 | if (mii_info->autoneg && mii_info->link) { |
| 527 | int speed; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 528 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 529 | status = phy_read (mii_info, MII_M1011_PHY_SPEC_STATUS); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 530 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 531 | /* Get the duplexity */ |
| 532 | if (status & MII_M1011_PHY_SPEC_STATUS_FULLDUPLEX) |
| 533 | mii_info->duplex = DUPLEX_FULL; |
| 534 | else |
| 535 | mii_info->duplex = DUPLEX_HALF; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 536 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 537 | /* Get the speed */ |
| 538 | speed = status & MII_M1011_PHY_SPEC_STATUS_SPD_MASK; |
| 539 | switch (speed) { |
| 540 | case MII_M1011_PHY_SPEC_STATUS_1000: |
| 541 | mii_info->speed = SPEED_1000; |
| 542 | break; |
| 543 | case MII_M1011_PHY_SPEC_STATUS_100: |
| 544 | mii_info->speed = SPEED_100; |
| 545 | break; |
| 546 | default: |
| 547 | mii_info->speed = SPEED_10; |
| 548 | break; |
| 549 | } |
| 550 | mii_info->pause = 0; |
| 551 | } |
| 552 | |
| 553 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 554 | } |
| 555 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 556 | static int marvell_ack_interrupt (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 557 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 558 | /* Clear the interrupts by reading the reg */ |
| 559 | phy_read (mii_info, MII_M1011_IEVENT); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 560 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 561 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 562 | } |
| 563 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 564 | static int marvell_config_intr (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 565 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 566 | if (mii_info->interrupts == MII_INTERRUPT_ENABLED) |
| 567 | phy_write (mii_info, MII_M1011_IMASK, MII_M1011_IMASK_INIT); |
| 568 | else |
| 569 | phy_write (mii_info, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 570 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 571 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 572 | } |
| 573 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 574 | static int dm9161_init (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 575 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 576 | /* Reset the PHY */ |
| 577 | phy_write (mii_info, PHY_BMCR, phy_read (mii_info, PHY_BMCR) | |
| 578 | PHY_BMCR_RESET); |
| 579 | /* PHY and MAC connect */ |
| 580 | phy_write (mii_info, PHY_BMCR, phy_read (mii_info, PHY_BMCR) & |
| 581 | ~PHY_BMCR_ISO); |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 582 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 583 | phy_write (mii_info, MII_DM9161_SCR, MII_DM9161_SCR_INIT); |
Kim Phillips | ee62ed3 | 2008-01-15 14:11:00 -0600 | [diff] [blame] | 584 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 585 | config_genmii_advert (mii_info); |
| 586 | /* Start/restart aneg */ |
| 587 | genmii_config_aneg (mii_info); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 588 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 589 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 590 | } |
| 591 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 592 | static int dm9161_config_aneg (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 593 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 594 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 595 | } |
| 596 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 597 | static int dm9161_read_status (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 598 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 599 | u16 status; |
| 600 | int err; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 601 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 602 | /* Update the link, but return if there was an error */ |
| 603 | err = genmii_update_link (mii_info); |
| 604 | if (err) |
| 605 | return err; |
| 606 | /* If the link is up, read the speed and duplex |
| 607 | If we aren't autonegotiating assume speeds are as set */ |
| 608 | if (mii_info->autoneg && mii_info->link) { |
| 609 | status = phy_read (mii_info, MII_DM9161_SCSR); |
| 610 | if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_100H)) |
| 611 | mii_info->speed = SPEED_100; |
| 612 | else |
| 613 | mii_info->speed = SPEED_10; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 614 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 615 | if (status & (MII_DM9161_SCSR_100F | MII_DM9161_SCSR_10F)) |
| 616 | mii_info->duplex = DUPLEX_FULL; |
| 617 | else |
| 618 | mii_info->duplex = DUPLEX_HALF; |
| 619 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 620 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 621 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 622 | } |
| 623 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 624 | static int dm9161_ack_interrupt (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 625 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 626 | /* Clear the interrupt by reading the reg */ |
| 627 | phy_read (mii_info, MII_DM9161_INTR); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 628 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 629 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 630 | } |
| 631 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 632 | static int dm9161_config_intr (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 633 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 634 | if (mii_info->interrupts == MII_INTERRUPT_ENABLED) |
| 635 | phy_write (mii_info, MII_DM9161_INTR, MII_DM9161_INTR_INIT); |
| 636 | else |
| 637 | phy_write (mii_info, MII_DM9161_INTR, MII_DM9161_INTR_STOP); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 638 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 639 | return 0; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 640 | } |
| 641 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 642 | static void dm9161_close (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 643 | { |
| 644 | } |
| 645 | |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 646 | static int fixed_phy_aneg (struct uec_mii_info *mii_info) |
| 647 | { |
| 648 | mii_info->autoneg = 0; /* Turn off auto negotiation for fixed phy */ |
| 649 | return 0; |
| 650 | } |
| 651 | |
| 652 | static int fixed_phy_read_status (struct uec_mii_info *mii_info) |
| 653 | { |
| 654 | int i = 0; |
| 655 | |
| 656 | for (i = 0; i < ARRAY_SIZE(fixed_phy_port); i++) { |
Richard Retanubun | 1443cd7 | 2009-07-01 14:04:05 -0400 | [diff] [blame] | 657 | if (strncmp(mii_info->dev->name, fixed_phy_port[i].name, |
| 658 | strlen(mii_info->dev->name)) == 0) { |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 659 | mii_info->speed = fixed_phy_port[i].speed; |
| 660 | mii_info->duplex = fixed_phy_port[i].duplex; |
| 661 | mii_info->link = 1; /* Link is always UP */ |
| 662 | mii_info->pause = 0; |
| 663 | break; |
| 664 | } |
| 665 | } |
| 666 | return 0; |
| 667 | } |
| 668 | |
Heiko Schocher | 8b69b56 | 2008-11-20 09:57:14 +0100 | [diff] [blame] | 669 | static int smsc_config_aneg (struct uec_mii_info *mii_info) |
| 670 | { |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | static int smsc_read_status (struct uec_mii_info *mii_info) |
| 675 | { |
| 676 | u16 status; |
| 677 | int err; |
| 678 | |
| 679 | /* Update the link, but return if there |
| 680 | * was an error */ |
| 681 | err = genmii_update_link (mii_info); |
| 682 | if (err) |
| 683 | return err; |
| 684 | |
| 685 | /* If the link is up, read the speed and duplex */ |
| 686 | /* If we aren't autonegotiating, assume speeds |
| 687 | * are as set */ |
| 688 | if (mii_info->autoneg && mii_info->link) { |
| 689 | int val; |
| 690 | |
| 691 | status = phy_read (mii_info, 0x1f); |
| 692 | val = (status & 0x1c) >> 2; |
| 693 | |
| 694 | switch (val) { |
| 695 | case 1: |
| 696 | mii_info->duplex = DUPLEX_HALF; |
| 697 | mii_info->speed = SPEED_10; |
| 698 | break; |
| 699 | case 5: |
| 700 | mii_info->duplex = DUPLEX_FULL; |
| 701 | mii_info->speed = SPEED_10; |
| 702 | break; |
| 703 | case 2: |
| 704 | mii_info->duplex = DUPLEX_HALF; |
| 705 | mii_info->speed = SPEED_100; |
| 706 | break; |
| 707 | case 6: |
| 708 | mii_info->duplex = DUPLEX_FULL; |
| 709 | mii_info->speed = SPEED_100; |
| 710 | break; |
| 711 | } |
| 712 | mii_info->pause = 0; |
| 713 | } |
| 714 | |
| 715 | return 0; |
| 716 | } |
| 717 | |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 718 | static struct phy_info phy_info_dm9161 = { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 719 | .phy_id = 0x0181b880, |
| 720 | .phy_id_mask = 0x0ffffff0, |
| 721 | .name = "Davicom DM9161E", |
| 722 | .init = dm9161_init, |
| 723 | .config_aneg = dm9161_config_aneg, |
| 724 | .read_status = dm9161_read_status, |
| 725 | .close = dm9161_close, |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 726 | }; |
| 727 | |
| 728 | static struct phy_info phy_info_dm9161a = { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 729 | .phy_id = 0x0181b8a0, |
| 730 | .phy_id_mask = 0x0ffffff0, |
| 731 | .name = "Davicom DM9161A", |
| 732 | .features = MII_BASIC_FEATURES, |
| 733 | .init = dm9161_init, |
| 734 | .config_aneg = dm9161_config_aneg, |
| 735 | .read_status = dm9161_read_status, |
| 736 | .ack_interrupt = dm9161_ack_interrupt, |
| 737 | .config_intr = dm9161_config_intr, |
| 738 | .close = dm9161_close, |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 739 | }; |
| 740 | |
| 741 | static struct phy_info phy_info_marvell = { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 742 | .phy_id = 0x01410c00, |
| 743 | .phy_id_mask = 0xffffff00, |
| 744 | .name = "Marvell 88E11x1", |
| 745 | .features = MII_GBIT_FEATURES, |
Haiying Wang | 41410ee | 2008-09-24 11:42:12 -0500 | [diff] [blame] | 746 | .init = &marvell_init, |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 747 | .config_aneg = &marvell_config_aneg, |
| 748 | .read_status = &marvell_read_status, |
| 749 | .ack_interrupt = &marvell_ack_interrupt, |
| 750 | .config_intr = &marvell_config_intr, |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 751 | }; |
| 752 | |
Anton Vorontsov | 300615d | 2008-03-24 20:46:34 +0300 | [diff] [blame] | 753 | static struct phy_info phy_info_bcm5481 = { |
| 754 | .phy_id = 0x0143bca0, |
| 755 | .phy_id_mask = 0xffffff0, |
| 756 | .name = "Broadcom 5481", |
| 757 | .features = MII_GBIT_FEATURES, |
| 758 | .read_status = genmii_read_status, |
| 759 | .init = bcm_init, |
| 760 | }; |
| 761 | |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 762 | static struct phy_info phy_info_fixedphy = { |
| 763 | .phy_id = CONFIG_FIXED_PHY, |
| 764 | .phy_id_mask = CONFIG_FIXED_PHY, |
| 765 | .name = "Fixed PHY", |
| 766 | .config_aneg = fixed_phy_aneg, |
| 767 | .read_status = fixed_phy_read_status, |
| 768 | }; |
| 769 | |
Heiko Schocher | 8b69b56 | 2008-11-20 09:57:14 +0100 | [diff] [blame] | 770 | static struct phy_info phy_info_smsclan8700 = { |
| 771 | .phy_id = 0x0007c0c0, |
| 772 | .phy_id_mask = 0xfffffff0, |
| 773 | .name = "SMSC LAN8700", |
| 774 | .features = MII_BASIC_FEATURES, |
| 775 | .config_aneg = smsc_config_aneg, |
| 776 | .read_status = smsc_read_status, |
| 777 | }; |
| 778 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 779 | static struct phy_info phy_info_genmii = { |
| 780 | .phy_id = 0x00000000, |
| 781 | .phy_id_mask = 0x00000000, |
| 782 | .name = "Generic MII", |
| 783 | .features = MII_BASIC_FEATURES, |
| 784 | .config_aneg = genmii_config_aneg, |
| 785 | .read_status = genmii_read_status, |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 786 | }; |
| 787 | |
| 788 | static struct phy_info *phy_info[] = { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 789 | &phy_info_dm9161, |
| 790 | &phy_info_dm9161a, |
| 791 | &phy_info_marvell, |
Anton Vorontsov | 300615d | 2008-03-24 20:46:34 +0300 | [diff] [blame] | 792 | &phy_info_bcm5481, |
Heiko Schocher | 8b69b56 | 2008-11-20 09:57:14 +0100 | [diff] [blame] | 793 | &phy_info_smsclan8700, |
Richard Retanubun | edf3fe7 | 2008-10-23 09:08:18 -0400 | [diff] [blame] | 794 | &phy_info_fixedphy, |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 795 | &phy_info_genmii, |
| 796 | NULL |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 797 | }; |
| 798 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 799 | u16 phy_read (struct uec_mii_info *mii_info, u16 regnum) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 800 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 801 | return mii_info->mdio_read (mii_info->dev, mii_info->mii_id, regnum); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 802 | } |
| 803 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 804 | void phy_write (struct uec_mii_info *mii_info, u16 regnum, u16 val) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 805 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 806 | mii_info->mdio_write (mii_info->dev, mii_info->mii_id, regnum, val); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 807 | } |
| 808 | |
| 809 | /* Use the PHY ID registers to determine what type of PHY is attached |
| 810 | * to device dev. return a struct phy_info structure describing that PHY |
| 811 | */ |
Andy Fleming | da9d461 | 2007-08-14 00:14:25 -0500 | [diff] [blame] | 812 | struct phy_info *uec_get_phy_info (struct uec_mii_info *mii_info) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 813 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 814 | u16 phy_reg; |
| 815 | u32 phy_ID; |
| 816 | int i; |
| 817 | struct phy_info *theInfo = NULL; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 818 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 819 | /* Grab the bits from PHYIR1, and put them in the upper half */ |
| 820 | phy_reg = phy_read (mii_info, PHY_PHYIDR1); |
| 821 | phy_ID = (phy_reg & 0xffff) << 16; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 822 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 823 | /* Grab the bits from PHYIR2, and put them in the lower half */ |
| 824 | phy_reg = phy_read (mii_info, PHY_PHYIDR2); |
| 825 | phy_ID |= (phy_reg & 0xffff); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 826 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 827 | /* loop through all the known PHY types, and find one that */ |
| 828 | /* matches the ID we read from the PHY. */ |
| 829 | for (i = 0; phy_info[i]; i++) |
| 830 | if (phy_info[i]->phy_id == |
| 831 | (phy_ID & phy_info[i]->phy_id_mask)) { |
| 832 | theInfo = phy_info[i]; |
| 833 | break; |
| 834 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 835 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 836 | /* This shouldn't happen, as we have generic PHY support */ |
| 837 | if (theInfo == NULL) { |
| 838 | ugphy_info ("UEC: PHY id %x is not supported!", phy_ID); |
| 839 | return NULL; |
| 840 | } else { |
| 841 | ugphy_info ("UEC: PHY is %s (%x)", theInfo->name, phy_ID); |
| 842 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 843 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 844 | return theInfo; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 845 | } |
| 846 | |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 847 | void marvell_phy_interface_mode (struct eth_device *dev, |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 848 | enet_interface_type_e type, |
| 849 | int speed |
| 850 | ) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 851 | { |
Wolfgang Denk | dd520bf | 2006-11-30 18:02:20 +0100 | [diff] [blame] | 852 | uec_private_t *uec = (uec_private_t *) dev->priv; |
| 853 | struct uec_mii_info *mii_info; |
Kim Phillips | f655ade | 2008-02-27 15:06:39 -0600 | [diff] [blame] | 854 | u16 status; |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 855 | |
| 856 | if (!uec->mii_info) { |
Kim Phillips | f30b6154 | 2008-02-27 16:08:22 -0600 | [diff] [blame] | 857 | printf ("%s: the PHY not initialized\n", __FUNCTION__); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 858 | return; |
| 859 | } |
| 860 | mii_info = uec->mii_info; |
| 861 | |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 862 | if (type == RGMII) { |
| 863 | if (speed == 100) { |
| 864 | phy_write (mii_info, 0x00, 0x9140); |
| 865 | phy_write (mii_info, 0x1d, 0x001f); |
| 866 | phy_write (mii_info, 0x1e, 0x200c); |
| 867 | phy_write (mii_info, 0x1d, 0x0005); |
| 868 | phy_write (mii_info, 0x1e, 0x0000); |
| 869 | phy_write (mii_info, 0x1e, 0x0100); |
| 870 | phy_write (mii_info, 0x09, 0x0e00); |
| 871 | phy_write (mii_info, 0x04, 0x01e1); |
| 872 | phy_write (mii_info, 0x00, 0x9140); |
| 873 | phy_write (mii_info, 0x00, 0x1000); |
| 874 | udelay (100000); |
| 875 | phy_write (mii_info, 0x00, 0x2900); |
| 876 | phy_write (mii_info, 0x14, 0x0cd2); |
| 877 | phy_write (mii_info, 0x00, 0xa100); |
| 878 | phy_write (mii_info, 0x09, 0x0000); |
| 879 | phy_write (mii_info, 0x1b, 0x800b); |
| 880 | phy_write (mii_info, 0x04, 0x05e1); |
| 881 | phy_write (mii_info, 0x00, 0xa100); |
| 882 | phy_write (mii_info, 0x00, 0x2100); |
| 883 | udelay (1000000); |
| 884 | } else if (speed == 10) { |
| 885 | phy_write (mii_info, 0x14, 0x8e40); |
| 886 | phy_write (mii_info, 0x1b, 0x800b); |
| 887 | phy_write (mii_info, 0x14, 0x0c82); |
| 888 | phy_write (mii_info, 0x00, 0x8100); |
| 889 | udelay (1000000); |
| 890 | } |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 891 | } |
Kim Phillips | f655ade | 2008-02-27 15:06:39 -0600 | [diff] [blame] | 892 | |
| 893 | /* handle 88e1111 rev.B2 erratum 5.6 */ |
| 894 | if (mii_info->autoneg) { |
| 895 | status = phy_read (mii_info, PHY_BMCR); |
| 896 | phy_write (mii_info, PHY_BMCR, status | PHY_BMCR_AUTON); |
| 897 | } |
| 898 | /* now the B2 will correctly report autoneg completion status */ |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 899 | } |
| 900 | |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 901 | void change_phy_interface_mode (struct eth_device *dev, |
| 902 | enet_interface_type_e type, int speed) |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 903 | { |
| 904 | #ifdef CONFIG_PHY_MODE_NEED_CHANGE |
Heiko Schocher | 582c55a | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 905 | marvell_phy_interface_mode (dev, type, speed); |
Dave Liu | 7737d5c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 906 | #endif |
| 907 | } |