wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 2 | * Freescale Three Speed Ethernet Controller driver |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 3 | * |
| 4 | * This software may be used and distributed according to the |
| 5 | * terms of the GNU Public License, Version 2, incorporated |
| 6 | * herein by reference. |
| 7 | * |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 8 | * Copyright 2004-2011 Freescale Semiconductor, Inc. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 9 | * (C) Copyright 2003, Motorola, Inc. |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 10 | * author Andy Fleming |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <config.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 15 | #include <common.h> |
| 16 | #include <malloc.h> |
| 17 | #include <net.h> |
| 18 | #include <command.h> |
Andy Fleming | c067fc1 | 2008-08-31 16:33:25 -0500 | [diff] [blame] | 19 | #include <tsec.h> |
Kim Phillips | ae4dd97 | 2009-08-24 14:32:26 -0500 | [diff] [blame] | 20 | #include <asm/errno.h> |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 21 | |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 22 | #include "miiphy.h" |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 23 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 24 | DECLARE_GLOBAL_DATA_PTR; |
| 25 | |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 26 | #define TX_BUF_CNT 2 |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 27 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 28 | static uint rxIdx; /* index of the current RX buffer */ |
| 29 | static uint txIdx; /* index of the current TX buffer */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 30 | |
| 31 | typedef volatile struct rtxbd { |
| 32 | txbd8_t txbd[TX_BUF_CNT]; |
| 33 | rxbd8_t rxbd[PKTBUFSRX]; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 34 | } RTXBD; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 35 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 36 | #define MAXCONTROLLERS (8) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 37 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 38 | static struct tsec_private *privlist[MAXCONTROLLERS]; |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 39 | static int num_tsecs = 0; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 40 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 41 | #ifdef __GNUC__ |
| 42 | static RTXBD rtx __attribute__ ((aligned(8))); |
| 43 | #else |
| 44 | #error "rtx must be 64-bit aligned" |
| 45 | #endif |
| 46 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 47 | static int tsec_send(struct eth_device *dev, |
| 48 | volatile void *packet, int length); |
| 49 | static int tsec_recv(struct eth_device *dev); |
| 50 | static int tsec_init(struct eth_device *dev, bd_t * bd); |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 51 | static int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info); |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 52 | static void tsec_halt(struct eth_device *dev); |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 53 | static void init_registers(tsec_t *regs); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 54 | static void startup_tsec(struct eth_device *dev); |
| 55 | static int init_phy(struct eth_device *dev); |
| 56 | void write_phy_reg(struct tsec_private *priv, uint regnum, uint value); |
| 57 | uint read_phy_reg(struct tsec_private *priv, uint regnum); |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 58 | static struct phy_info *get_phy_info(struct eth_device *dev); |
| 59 | static void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 60 | static void adjust_link(struct eth_device *dev); |
Wolfgang Denk | 9225411 | 2007-11-18 16:36:27 +0100 | [diff] [blame] | 61 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ |
| 62 | && !defined(BITBANGMII) |
Mike Frysinger | 5ff5fdb | 2010-07-27 18:35:08 -0400 | [diff] [blame] | 63 | static int tsec_miiphy_write(const char *devname, unsigned char addr, |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 64 | unsigned char reg, unsigned short value); |
Mike Frysinger | 5ff5fdb | 2010-07-27 18:35:08 -0400 | [diff] [blame] | 65 | static int tsec_miiphy_read(const char *devname, unsigned char addr, |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 66 | unsigned char reg, unsigned short *value); |
Wolfgang Denk | 9225411 | 2007-11-18 16:36:27 +0100 | [diff] [blame] | 67 | #endif |
David Updegraff | 7280da7 | 2007-06-11 10:41:07 -0500 | [diff] [blame] | 68 | #ifdef CONFIG_MCAST_TFTP |
| 69 | static int tsec_mcast_addr (struct eth_device *dev, u8 mcast_mac, u8 set); |
| 70 | #endif |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 71 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 72 | /* Default initializations for TSEC controllers. */ |
| 73 | |
| 74 | static struct tsec_info_struct tsec_info[] = { |
| 75 | #ifdef CONFIG_TSEC1 |
| 76 | STD_TSEC_INFO(1), /* TSEC1 */ |
| 77 | #endif |
| 78 | #ifdef CONFIG_TSEC2 |
| 79 | STD_TSEC_INFO(2), /* TSEC2 */ |
| 80 | #endif |
| 81 | #ifdef CONFIG_MPC85XX_FEC |
| 82 | { |
| 83 | .regs = (tsec_t *)(TSEC_BASE_ADDR + 0x2000), |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 84 | .miiregs = (tsec_mdio_t *)(MDIO_BASE_ADDR), |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 85 | .devname = CONFIG_MPC85XX_FEC_NAME, |
| 86 | .phyaddr = FEC_PHY_ADDR, |
| 87 | .flags = FEC_FLAGS |
| 88 | }, /* FEC */ |
| 89 | #endif |
| 90 | #ifdef CONFIG_TSEC3 |
| 91 | STD_TSEC_INFO(3), /* TSEC3 */ |
| 92 | #endif |
| 93 | #ifdef CONFIG_TSEC4 |
| 94 | STD_TSEC_INFO(4), /* TSEC4 */ |
| 95 | #endif |
| 96 | }; |
| 97 | |
Timur Tabi | 7762268 | 2010-06-08 08:21:21 -0500 | [diff] [blame] | 98 | /* |
| 99 | * Initialize all the TSEC devices |
| 100 | * |
| 101 | * Returns the number of TSEC devices that were initialized |
| 102 | */ |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 103 | int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num) |
| 104 | { |
| 105 | int i; |
Timur Tabi | 7762268 | 2010-06-08 08:21:21 -0500 | [diff] [blame] | 106 | int ret, count = 0; |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 107 | |
Timur Tabi | 7762268 | 2010-06-08 08:21:21 -0500 | [diff] [blame] | 108 | for (i = 0; i < num; i++) { |
| 109 | ret = tsec_initialize(bis, &tsecs[i]); |
| 110 | if (ret > 0) |
| 111 | count += ret; |
| 112 | } |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 113 | |
Timur Tabi | 7762268 | 2010-06-08 08:21:21 -0500 | [diff] [blame] | 114 | return count; |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | int tsec_standard_init(bd_t *bis) |
| 118 | { |
| 119 | return tsec_eth_init(bis, tsec_info, ARRAY_SIZE(tsec_info)); |
| 120 | } |
| 121 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 122 | /* Initialize device structure. Returns success if PHY |
| 123 | * initialization succeeded (i.e. if it recognizes the PHY) |
| 124 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 125 | static int tsec_initialize(bd_t * bis, struct tsec_info_struct *tsec_info) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 126 | { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 127 | struct eth_device *dev; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 128 | int i; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 129 | struct tsec_private *priv; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 130 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 131 | dev = (struct eth_device *)malloc(sizeof *dev); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 132 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 133 | if (NULL == dev) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 134 | return 0; |
| 135 | |
| 136 | memset(dev, 0, sizeof *dev); |
| 137 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 138 | priv = (struct tsec_private *)malloc(sizeof(*priv)); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 139 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 140 | if (NULL == priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 141 | return 0; |
| 142 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 143 | privlist[num_tsecs++] = priv; |
| 144 | priv->regs = tsec_info->regs; |
| 145 | priv->phyregs = tsec_info->miiregs; |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 146 | priv->phyregs_sgmii = tsec_info->miiregs_sgmii; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 147 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 148 | priv->phyaddr = tsec_info->phyaddr; |
| 149 | priv->flags = tsec_info->flags; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 150 | |
Andy Fleming | fecff2b | 2008-08-31 16:33:26 -0500 | [diff] [blame] | 151 | sprintf(dev->name, tsec_info->devname); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 152 | dev->iobase = 0; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 153 | dev->priv = priv; |
| 154 | dev->init = tsec_init; |
| 155 | dev->halt = tsec_halt; |
| 156 | dev->send = tsec_send; |
| 157 | dev->recv = tsec_recv; |
David Updegraff | 7280da7 | 2007-06-11 10:41:07 -0500 | [diff] [blame] | 158 | #ifdef CONFIG_MCAST_TFTP |
| 159 | dev->mcast = tsec_mcast_addr; |
| 160 | #endif |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 161 | |
| 162 | /* Tell u-boot to get the addr from the env */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 163 | for (i = 0; i < 6; i++) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 164 | dev->enetaddr[i] = 0; |
| 165 | |
| 166 | eth_register(dev); |
| 167 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 168 | /* Reset the MAC */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 169 | setbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); |
Andy Fleming | 2d1db14 | 2009-02-03 18:26:41 -0600 | [diff] [blame] | 170 | udelay(2); /* Soft Reset must be asserted for 3 TX clocks */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 171 | clrbits_be32(&priv->regs->maccfg1, MACCFG1_SOFT_RESET); |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 172 | |
Jon Loeliger | 82ecaad | 2007-07-09 17:39:42 -0500 | [diff] [blame] | 173 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 174 | && !defined(BITBANGMII) |
| 175 | miiphy_register(dev->name, tsec_miiphy_read, tsec_miiphy_write); |
| 176 | #endif |
| 177 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 178 | /* Try to initialize PHY here, and return */ |
| 179 | return init_phy(dev); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 180 | } |
| 181 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 182 | /* Initializes data structures and registers for the controller, |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 183 | * and brings the interface up. Returns the link status, meaning |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 184 | * that it returns success if the link is up, failure otherwise. |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 185 | * This allows u-boot to find the first active controller. |
| 186 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 187 | static int tsec_init(struct eth_device *dev, bd_t * bd) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 188 | { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 189 | uint tempval; |
| 190 | char tmpbuf[MAC_ADDR_LEN]; |
| 191 | int i; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 192 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 193 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 194 | |
| 195 | /* Make sure the controller is stopped */ |
| 196 | tsec_halt(dev); |
| 197 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 198 | /* Init MACCFG2. Defaults to GMII */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 199 | out_be32(®s->maccfg2, MACCFG2_INIT_SETTINGS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 200 | |
| 201 | /* Init ECNTRL */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 202 | out_be32(®s->ecntrl, ECNTRL_INIT_SETTINGS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 203 | |
| 204 | /* Copy the station address into the address registers. |
| 205 | * Backwards, because little endian MACS are dumb */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 206 | for (i = 0; i < MAC_ADDR_LEN; i++) { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 207 | tmpbuf[MAC_ADDR_LEN - 1 - i] = dev->enetaddr[i]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 208 | } |
Kim Phillips | 4f8b633 | 2009-07-17 12:17:00 -0500 | [diff] [blame] | 209 | tempval = (tmpbuf[0] << 24) | (tmpbuf[1] << 16) | (tmpbuf[2] << 8) | |
| 210 | tmpbuf[3]; |
| 211 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 212 | out_be32(®s->macstnaddr1, tempval); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 213 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 214 | tempval = *((uint *) (tmpbuf + 4)); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 215 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 216 | out_be32(®s->macstnaddr2, tempval); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 217 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 218 | /* reset the indices to zero */ |
| 219 | rxIdx = 0; |
| 220 | txIdx = 0; |
| 221 | |
| 222 | /* Clear out (for the most part) the other registers */ |
| 223 | init_registers(regs); |
| 224 | |
| 225 | /* Ready the device for tx/rx */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 226 | startup_tsec(dev); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 227 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 228 | /* If there's no link, fail */ |
Ben Warren | de9fcb5 | 2008-01-09 18:15:53 -0500 | [diff] [blame] | 229 | return (priv->link ? 0 : -1); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 230 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 231 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 232 | /* Writes the given phy's reg with value, using the specified MDIO regs */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 233 | static void tsec_local_mdio_write(tsec_mdio_t *phyregs, uint addr, |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 234 | uint reg, uint value) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 235 | { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 236 | int timeout = 1000000; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 237 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 238 | out_be32(&phyregs->miimadd, (addr << 8) | reg); |
| 239 | out_be32(&phyregs->miimcon, value); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 240 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 241 | timeout = 1000000; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 242 | while ((in_be32(&phyregs->miimind) & MIIMIND_BUSY) && timeout--) |
| 243 | ; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 244 | } |
| 245 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 246 | |
| 247 | /* Provide the default behavior of writing the PHY of this ethernet device */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 248 | #define write_phy_reg(priv, regnum, value) \ |
| 249 | tsec_local_mdio_write(priv->phyregs,priv->phyaddr,regnum,value) |
michael.firth@bt.com | 0838484 | 2008-01-16 11:40:51 +0000 | [diff] [blame] | 250 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 251 | /* Reads register regnum on the device's PHY through the |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 252 | * specified registers. It lowers and raises the read |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 253 | * command, and waits for the data to become valid (miimind |
| 254 | * notvalid bit cleared), and the bus to cease activity (miimind |
| 255 | * busy bit cleared), and then returns the value |
| 256 | */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 257 | static uint tsec_local_mdio_read(tsec_mdio_t *phyregs, uint phyid, uint regnum) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 258 | { |
| 259 | uint value; |
| 260 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 261 | /* Put the address of the phy, and the register |
| 262 | * number into MIIMADD */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 263 | out_be32(&phyregs->miimadd, (phyid << 8) | regnum); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 264 | |
| 265 | /* Clear the command register, and wait */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 266 | out_be32(&phyregs->miimcom, 0); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 267 | |
| 268 | /* Initiate a read command, and wait */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 269 | out_be32(&phyregs->miimcom, MIIM_READ_COMMAND); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 270 | |
| 271 | /* Wait for the the indication that the read is done */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 272 | while ((in_be32(&phyregs->miimind) & (MIIMIND_NOTVALID | MIIMIND_BUSY))) |
| 273 | ; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 274 | |
| 275 | /* Grab the value read from the PHY */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 276 | value = in_be32(&phyregs->miimstat); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 277 | |
| 278 | return value; |
| 279 | } |
| 280 | |
michael.firth@bt.com | 0838484 | 2008-01-16 11:40:51 +0000 | [diff] [blame] | 281 | /* #define to provide old read_phy_reg functionality without duplicating code */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 282 | #define read_phy_reg(priv,regnum) \ |
| 283 | tsec_local_mdio_read(priv->phyregs,priv->phyaddr,regnum) |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 284 | |
| 285 | #define TBIANA_SETTINGS ( \ |
| 286 | TBIANA_ASYMMETRIC_PAUSE \ |
| 287 | | TBIANA_SYMMETRIC_PAUSE \ |
| 288 | | TBIANA_FULL_DUPLEX \ |
| 289 | ) |
| 290 | |
Felix Radensky | 27f98e0 | 2010-06-28 01:57:39 +0300 | [diff] [blame] | 291 | /* By default force the TBI PHY into 1000Mbps full duplex when in SGMII mode */ |
| 292 | #ifndef CONFIG_TSEC_TBICR_SETTINGS |
Kumar Gala | c1457f9 | 2010-12-01 22:55:54 -0600 | [diff] [blame] | 293 | #define CONFIG_TSEC_TBICR_SETTINGS ( \ |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 294 | TBICR_PHY_RESET \ |
Kumar Gala | c1457f9 | 2010-12-01 22:55:54 -0600 | [diff] [blame] | 295 | | TBICR_ANEG_ENABLE \ |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 296 | | TBICR_FULL_DUPLEX \ |
| 297 | | TBICR_SPEED1_SET \ |
| 298 | ) |
Felix Radensky | 27f98e0 | 2010-06-28 01:57:39 +0300 | [diff] [blame] | 299 | #endif /* CONFIG_TSEC_TBICR_SETTINGS */ |
Peter Tyser | 583c1f4 | 2009-11-03 17:52:07 -0600 | [diff] [blame] | 300 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 301 | /* Configure the TBI for SGMII operation */ |
| 302 | static void tsec_configure_serdes(struct tsec_private *priv) |
| 303 | { |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 304 | /* Access TBI PHY registers at given TSEC register offset as opposed |
| 305 | * to the register offset used for external PHY accesses */ |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 306 | tsec_local_mdio_write(priv->phyregs_sgmii, priv->regs->tbipa, TBI_ANA, |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 307 | TBIANA_SETTINGS); |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 308 | tsec_local_mdio_write(priv->phyregs_sgmii, priv->regs->tbipa, TBI_TBICON, |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 309 | TBICON_CLK_SELECT); |
Sandeep Gopalpet | b5541ef | 2009-10-31 00:35:04 +0530 | [diff] [blame] | 310 | tsec_local_mdio_write(priv->phyregs_sgmii, priv->regs->tbipa, TBI_CR, |
Kumar Gala | c1457f9 | 2010-12-01 22:55:54 -0600 | [diff] [blame] | 311 | CONFIG_TSEC_TBICR_SETTINGS); |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 312 | } |
michael.firth@bt.com | 0838484 | 2008-01-16 11:40:51 +0000 | [diff] [blame] | 313 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 314 | /* Discover which PHY is attached to the device, and configure it |
| 315 | * properly. If the PHY is not recognized, then return 0 |
| 316 | * (failure). Otherwise, return 1 |
| 317 | */ |
| 318 | static int init_phy(struct eth_device *dev) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 319 | { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 320 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
| 321 | struct phy_info *curphy; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 322 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 323 | |
| 324 | /* Assign a Physical address to the TBI */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 325 | out_be32(®s->tbipa, CONFIG_SYS_TBIPA_VALUE); |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 326 | |
| 327 | /* Reset MII (due to new addresses) */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 328 | out_be32(&priv->phyregs->miimcfg, MIIMCFG_RESET); |
| 329 | out_be32(&priv->phyregs->miimcfg, MIIMCFG_INIT_VALUE); |
| 330 | while (in_be32(&priv->phyregs->miimind) & MIIMIND_BUSY) |
| 331 | ; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 332 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 333 | /* Get the cmd structure corresponding to the attached |
| 334 | * PHY */ |
| 335 | curphy = get_phy_info(dev); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 336 | |
Ben Warren | f11eefb | 2006-10-26 14:38:25 -0400 | [diff] [blame] | 337 | if (curphy == NULL) { |
| 338 | priv->phyinfo = NULL; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 339 | printf("%s: No PHY found\n", dev->name); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 340 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 341 | return 0; |
| 342 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 343 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 344 | if (in_be32(®s->ecntrl) & ECNTRL_SGMII_MODE) |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 345 | tsec_configure_serdes(priv); |
| 346 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 347 | priv->phyinfo = curphy; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 348 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 349 | phy_run_commands(priv, priv->phyinfo->config); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 350 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 351 | return 1; |
| 352 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 353 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 354 | /* |
| 355 | * Returns which value to write to the control register. |
| 356 | * For 10/100, the value is slightly different |
| 357 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 358 | static uint mii_cr_init(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 359 | { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 360 | if (priv->flags & TSEC_GIGABIT) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 361 | return MIIM_CONTROL_INIT; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 362 | else |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 363 | return MIIM_CR_INIT; |
| 364 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 365 | |
Peter Tyser | 4c84fd5 | 2009-02-04 15:14:05 -0600 | [diff] [blame] | 366 | /* |
| 367 | * Wait for auto-negotiation to complete, then determine link |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 368 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 369 | static uint mii_parse_sr(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 370 | { |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 371 | /* |
Andy Fleming | 4eb3dcf | 2007-08-15 20:03:44 -0500 | [diff] [blame] | 372 | * Wait if the link is up, and autonegotiation is in progress |
| 373 | * (ie - we're capable and it's not done) |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 374 | */ |
| 375 | mii_reg = read_phy_reg(priv, MIIM_STATUS); |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 376 | if ((mii_reg & BMSR_ANEGCAPABLE) && !(mii_reg & BMSR_ANEGCOMPLETE)) { |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 377 | int i = 0; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 378 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 379 | puts("Waiting for PHY auto negotiation to complete"); |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 380 | while (!(mii_reg & BMSR_ANEGCOMPLETE)) { |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 381 | /* |
| 382 | * Timeout reached ? |
| 383 | */ |
| 384 | if (i > PHY_AUTONEGOTIATE_TIMEOUT) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 385 | puts(" TIMEOUT !\n"); |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 386 | priv->link = 0; |
Jin Zhengxiong-R64188 | 487d223 | 2006-06-27 18:12:23 +0800 | [diff] [blame] | 387 | return 0; |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 388 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 389 | |
Kim Phillips | ae4dd97 | 2009-08-24 14:32:26 -0500 | [diff] [blame] | 390 | if (ctrlc()) { |
| 391 | puts("user interrupt!\n"); |
| 392 | priv->link = 0; |
| 393 | return -EINTR; |
| 394 | } |
| 395 | |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 396 | if ((i++ % 1000) == 0) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 397 | putc('.'); |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 398 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 399 | udelay(1000); /* 1 ms */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 400 | mii_reg = read_phy_reg(priv, MIIM_STATUS); |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 401 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 402 | puts(" done\n"); |
Peter Tyser | 4c84fd5 | 2009-02-04 15:14:05 -0600 | [diff] [blame] | 403 | |
| 404 | /* Link status bit is latched low, read it again */ |
| 405 | mii_reg = read_phy_reg(priv, MIIM_STATUS); |
| 406 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 407 | udelay(500000); /* another 500 ms (results in faster booting) */ |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Peter Tyser | 4c84fd5 | 2009-02-04 15:14:05 -0600 | [diff] [blame] | 410 | priv->link = mii_reg & MIIM_STATUS_LINK ? 1 : 0; |
| 411 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 412 | return 0; |
| 413 | } |
| 414 | |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 415 | /* Generic function which updates the speed and duplex. If |
| 416 | * autonegotiation is enabled, it uses the AND of the link |
| 417 | * partner's advertised capabilities and our advertised |
| 418 | * capabilities. If autonegotiation is disabled, we use the |
| 419 | * appropriate bits in the control register. |
| 420 | * |
| 421 | * Stolen from Linux's mii.c and phy_device.c |
| 422 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 423 | static uint mii_parse_link(uint mii_reg, struct tsec_private *priv) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 424 | { |
| 425 | /* We're using autonegotiation */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 426 | if (mii_reg & BMSR_ANEGCAPABLE) { |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 427 | uint lpa = 0; |
| 428 | uint gblpa = 0; |
| 429 | |
| 430 | /* Check for gigabit capability */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 431 | if (mii_reg & BMSR_ERCAP) { |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 432 | /* We want a list of states supported by |
| 433 | * both PHYs in the link |
| 434 | */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 435 | gblpa = read_phy_reg(priv, MII_STAT1000); |
| 436 | gblpa &= read_phy_reg(priv, MII_CTRL1000) << 2; |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | /* Set the baseline so we only have to set them |
| 440 | * if they're different |
| 441 | */ |
| 442 | priv->speed = 10; |
| 443 | priv->duplexity = 0; |
| 444 | |
| 445 | /* Check the gigabit fields */ |
| 446 | if (gblpa & (PHY_1000BTSR_1000FD | PHY_1000BTSR_1000HD)) { |
| 447 | priv->speed = 1000; |
| 448 | |
| 449 | if (gblpa & PHY_1000BTSR_1000FD) |
| 450 | priv->duplexity = 1; |
| 451 | |
| 452 | /* We're done! */ |
| 453 | return 0; |
| 454 | } |
| 455 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 456 | lpa = read_phy_reg(priv, MII_ADVERTISE); |
| 457 | lpa &= read_phy_reg(priv, MII_LPA); |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 458 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 459 | if (lpa & (LPA_100FULL | LPA_100HALF)) { |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 460 | priv->speed = 100; |
| 461 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 462 | if (lpa & LPA_100FULL) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 463 | priv->duplexity = 1; |
| 464 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 465 | } else if (lpa & LPA_10FULL) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 466 | priv->duplexity = 1; |
| 467 | } else { |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 468 | uint bmcr = read_phy_reg(priv, MII_BMCR); |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 469 | |
| 470 | priv->speed = 10; |
| 471 | priv->duplexity = 0; |
| 472 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 473 | if (bmcr & BMCR_FULLDPLX) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 474 | priv->duplexity = 1; |
| 475 | |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 476 | if (bmcr & BMCR_SPEED1000) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 477 | priv->speed = 1000; |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 478 | else if (bmcr & BMCR_SPEED100) |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 479 | priv->speed = 100; |
| 480 | } |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 485 | /* |
Zach LeRoy | ddb7fc7 | 2009-05-22 10:26:33 -0500 | [diff] [blame] | 486 | * "Ethernet@Wirespeed" needs to be enabled to achieve link in certain |
| 487 | * circumstances. eg a gigabit TSEC connected to a gigabit switch with |
| 488 | * a 4-wire ethernet cable. Both ends advertise gigabit, but can't |
| 489 | * link. "Ethernet@Wirespeed" reduces advertised speed until link |
| 490 | * can be achieved. |
| 491 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 492 | static uint mii_BCM54xx_wirespeed(uint mii_reg, struct tsec_private *priv) |
Zach LeRoy | ddb7fc7 | 2009-05-22 10:26:33 -0500 | [diff] [blame] | 493 | { |
| 494 | return (read_phy_reg(priv, mii_reg) & 0x8FFF) | 0x8010; |
| 495 | } |
| 496 | |
| 497 | /* |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 498 | * Parse the BCM54xx status register for speed and duplex information. |
| 499 | * The linux sungem_phy has this information, but in a table format. |
| 500 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 501 | static uint mii_parse_BCM54xx_sr(uint mii_reg, struct tsec_private *priv) |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 502 | { |
Peter Tyser | f672290 | 2009-11-09 13:09:44 -0600 | [diff] [blame] | 503 | /* If there is no link, speed and duplex don't matter */ |
| 504 | if (!priv->link) |
| 505 | return 0; |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 506 | |
Peter Tyser | f672290 | 2009-11-09 13:09:44 -0600 | [diff] [blame] | 507 | switch ((mii_reg & MIIM_BCM54xx_AUXSTATUS_LINKMODE_MASK) >> |
| 508 | MIIM_BCM54xx_AUXSTATUS_LINKMODE_SHIFT) { |
| 509 | case 1: |
| 510 | priv->duplexity = 0; |
| 511 | priv->speed = 10; |
| 512 | break; |
| 513 | case 2: |
| 514 | priv->duplexity = 1; |
| 515 | priv->speed = 10; |
| 516 | break; |
| 517 | case 3: |
| 518 | priv->duplexity = 0; |
| 519 | priv->speed = 100; |
| 520 | break; |
| 521 | case 5: |
| 522 | priv->duplexity = 1; |
| 523 | priv->speed = 100; |
| 524 | break; |
| 525 | case 6: |
| 526 | priv->duplexity = 0; |
| 527 | priv->speed = 1000; |
| 528 | break; |
| 529 | case 7: |
| 530 | priv->duplexity = 1; |
| 531 | priv->speed = 1000; |
| 532 | break; |
| 533 | default: |
| 534 | printf("Auto-neg error, defaulting to 10BT/HD\n"); |
| 535 | priv->duplexity = 0; |
| 536 | priv->speed = 10; |
| 537 | break; |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | return 0; |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 541 | } |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 542 | |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 543 | /* |
| 544 | * Find out if PHY is in copper or serdes mode by looking at Expansion Reg |
| 545 | * 0x42 - "Operating Mode Status Register" |
| 546 | */ |
| 547 | static int BCM8482_is_serdes(struct tsec_private *priv) |
| 548 | { |
| 549 | u16 val; |
| 550 | int serdes = 0; |
| 551 | |
| 552 | write_phy_reg(priv, MIIM_BCM54XX_EXP_SEL, MIIM_BCM54XX_EXP_SEL_ER | 0x42); |
| 553 | val = read_phy_reg(priv, MIIM_BCM54XX_EXP_DATA); |
| 554 | |
| 555 | switch (val & 0x1f) { |
| 556 | case 0x0d: /* RGMII-to-100Base-FX */ |
| 557 | case 0x0e: /* RGMII-to-SGMII */ |
| 558 | case 0x0f: /* RGMII-to-SerDes */ |
| 559 | case 0x12: /* SGMII-to-SerDes */ |
| 560 | case 0x13: /* SGMII-to-100Base-FX */ |
| 561 | case 0x16: /* SerDes-to-Serdes */ |
| 562 | serdes = 1; |
| 563 | break; |
| 564 | case 0x6: /* RGMII-to-Copper */ |
| 565 | case 0x14: /* SGMII-to-Copper */ |
| 566 | case 0x17: /* SerDes-to-Copper */ |
| 567 | break; |
| 568 | default: |
| 569 | printf("ERROR, invalid PHY mode (0x%x\n)", val); |
| 570 | break; |
| 571 | } |
| 572 | |
| 573 | return serdes; |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 574 | } |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 575 | |
| 576 | /* |
| 577 | * Determine SerDes link speed and duplex from Expansion reg 0x42 "Operating |
| 578 | * Mode Status Register" |
| 579 | */ |
| 580 | uint mii_parse_BCM5482_serdes_sr(struct tsec_private *priv) |
| 581 | { |
| 582 | u16 val; |
| 583 | int i = 0; |
| 584 | |
| 585 | /* Wait 1s for link - Clause 37 autonegotiation happens very fast */ |
| 586 | while (1) { |
| 587 | write_phy_reg(priv, MIIM_BCM54XX_EXP_SEL, |
| 588 | MIIM_BCM54XX_EXP_SEL_ER | 0x42); |
| 589 | val = read_phy_reg(priv, MIIM_BCM54XX_EXP_DATA); |
| 590 | |
| 591 | if (val & 0x8000) |
| 592 | break; |
| 593 | |
| 594 | if (i++ > 1000) { |
| 595 | priv->link = 0; |
| 596 | return 1; |
| 597 | } |
| 598 | |
| 599 | udelay(1000); /* 1 ms */ |
| 600 | } |
| 601 | |
| 602 | priv->link = 1; |
| 603 | switch ((val >> 13) & 0x3) { |
| 604 | case (0x00): |
| 605 | priv->speed = 10; |
| 606 | break; |
| 607 | case (0x01): |
| 608 | priv->speed = 100; |
| 609 | break; |
| 610 | case (0x02): |
| 611 | priv->speed = 1000; |
| 612 | break; |
| 613 | } |
| 614 | |
| 615 | priv->duplexity = (val & 0x1000) == 0x1000; |
| 616 | |
| 617 | return 0; |
| 618 | } |
| 619 | |
| 620 | /* |
| 621 | * Figure out if BCM5482 is in serdes or copper mode and determine link |
| 622 | * configuration accordingly |
| 623 | */ |
| 624 | static uint mii_parse_BCM5482_sr(uint mii_reg, struct tsec_private *priv) |
| 625 | { |
| 626 | if (BCM8482_is_serdes(priv)) { |
| 627 | mii_parse_BCM5482_serdes_sr(priv); |
Peter Tyser | 94f63a7 | 2009-11-09 13:09:48 -0600 | [diff] [blame] | 628 | priv->flags |= TSEC_FIBER; |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 629 | } else { |
| 630 | /* Wait for auto-negotiation to complete or fail */ |
| 631 | mii_parse_sr(mii_reg, priv); |
| 632 | |
| 633 | /* Parse BCM54xx copper aux status register */ |
| 634 | mii_reg = read_phy_reg(priv, MIIM_BCM54xx_AUXSTATUS); |
| 635 | mii_parse_BCM54xx_sr(mii_reg, priv); |
| 636 | } |
| 637 | |
| 638 | return 0; |
| 639 | } |
| 640 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 641 | /* Parse the 88E1011's status register for speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 642 | * information |
| 643 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 644 | static uint mii_parse_88E1011_psr(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 645 | { |
| 646 | uint speed; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 647 | |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 648 | mii_reg = read_phy_reg(priv, MIIM_88E1011_PHY_STATUS); |
| 649 | |
Andy Fleming | 4eb3dcf | 2007-08-15 20:03:44 -0500 | [diff] [blame] | 650 | if ((mii_reg & MIIM_88E1011_PHYSTAT_LINK) && |
| 651 | !(mii_reg & MIIM_88E1011_PHYSTAT_SPDDONE)) { |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 652 | int i = 0; |
| 653 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 654 | puts("Waiting for PHY realtime link"); |
Andy Fleming | 4eb3dcf | 2007-08-15 20:03:44 -0500 | [diff] [blame] | 655 | while (!(mii_reg & MIIM_88E1011_PHYSTAT_SPDDONE)) { |
| 656 | /* Timeout reached ? */ |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 657 | if (i > PHY_AUTONEGOTIATE_TIMEOUT) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 658 | puts(" TIMEOUT !\n"); |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 659 | priv->link = 0; |
| 660 | break; |
| 661 | } |
| 662 | |
| 663 | if ((i++ % 1000) == 0) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 664 | putc('.'); |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 665 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 666 | udelay(1000); /* 1 ms */ |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 667 | mii_reg = read_phy_reg(priv, MIIM_88E1011_PHY_STATUS); |
| 668 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 669 | puts(" done\n"); |
| 670 | udelay(500000); /* another 500 ms (results in faster booting) */ |
Andy Fleming | 4eb3dcf | 2007-08-15 20:03:44 -0500 | [diff] [blame] | 671 | } else { |
| 672 | if (mii_reg & MIIM_88E1011_PHYSTAT_LINK) |
| 673 | priv->link = 1; |
| 674 | else |
| 675 | priv->link = 0; |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 676 | } |
| 677 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 678 | if (mii_reg & MIIM_88E1011_PHYSTAT_DUPLEX) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 679 | priv->duplexity = 1; |
| 680 | else |
| 681 | priv->duplexity = 0; |
| 682 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 683 | speed = (mii_reg & MIIM_88E1011_PHYSTAT_SPEED); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 684 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 685 | switch (speed) { |
| 686 | case MIIM_88E1011_PHYSTAT_GBIT: |
| 687 | priv->speed = 1000; |
| 688 | break; |
| 689 | case MIIM_88E1011_PHYSTAT_100: |
| 690 | priv->speed = 100; |
| 691 | break; |
| 692 | default: |
| 693 | priv->speed = 10; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 694 | } |
| 695 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 696 | return 0; |
| 697 | } |
| 698 | |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 699 | /* Parse the RTL8211B's status register for speed and duplex |
| 700 | * information |
| 701 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 702 | static uint mii_parse_RTL8211B_sr(uint mii_reg, struct tsec_private * priv) |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 703 | { |
| 704 | uint speed; |
| 705 | |
| 706 | mii_reg = read_phy_reg(priv, MIIM_RTL8211B_PHY_STATUS); |
Anton Vorontsov | 91112ec | 2008-03-14 23:20:30 +0300 | [diff] [blame] | 707 | if (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) { |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 708 | int i = 0; |
| 709 | |
Anton Vorontsov | 91112ec | 2008-03-14 23:20:30 +0300 | [diff] [blame] | 710 | /* in case of timeout ->link is cleared */ |
| 711 | priv->link = 1; |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 712 | puts("Waiting for PHY realtime link"); |
| 713 | while (!(mii_reg & MIIM_RTL8211B_PHYSTAT_SPDDONE)) { |
| 714 | /* Timeout reached ? */ |
| 715 | if (i > PHY_AUTONEGOTIATE_TIMEOUT) { |
| 716 | puts(" TIMEOUT !\n"); |
| 717 | priv->link = 0; |
| 718 | break; |
| 719 | } |
| 720 | |
| 721 | if ((i++ % 1000) == 0) { |
| 722 | putc('.'); |
| 723 | } |
| 724 | udelay(1000); /* 1 ms */ |
| 725 | mii_reg = read_phy_reg(priv, MIIM_RTL8211B_PHY_STATUS); |
| 726 | } |
| 727 | puts(" done\n"); |
| 728 | udelay(500000); /* another 500 ms (results in faster booting) */ |
| 729 | } else { |
| 730 | if (mii_reg & MIIM_RTL8211B_PHYSTAT_LINK) |
| 731 | priv->link = 1; |
| 732 | else |
| 733 | priv->link = 0; |
| 734 | } |
| 735 | |
| 736 | if (mii_reg & MIIM_RTL8211B_PHYSTAT_DUPLEX) |
| 737 | priv->duplexity = 1; |
| 738 | else |
| 739 | priv->duplexity = 0; |
| 740 | |
| 741 | speed = (mii_reg & MIIM_RTL8211B_PHYSTAT_SPEED); |
| 742 | |
| 743 | switch (speed) { |
| 744 | case MIIM_RTL8211B_PHYSTAT_GBIT: |
| 745 | priv->speed = 1000; |
| 746 | break; |
| 747 | case MIIM_RTL8211B_PHYSTAT_100: |
| 748 | priv->speed = 100; |
| 749 | break; |
| 750 | default: |
| 751 | priv->speed = 10; |
| 752 | } |
| 753 | |
| 754 | return 0; |
| 755 | } |
| 756 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 757 | /* Parse the cis8201's status register for speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 758 | * information |
| 759 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 760 | static uint mii_parse_cis8201(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 761 | { |
| 762 | uint speed; |
| 763 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 764 | if (mii_reg & MIIM_CIS8201_AUXCONSTAT_DUPLEX) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 765 | priv->duplexity = 1; |
| 766 | else |
| 767 | priv->duplexity = 0; |
| 768 | |
| 769 | speed = mii_reg & MIIM_CIS8201_AUXCONSTAT_SPEED; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 770 | switch (speed) { |
| 771 | case MIIM_CIS8201_AUXCONSTAT_GBIT: |
| 772 | priv->speed = 1000; |
| 773 | break; |
| 774 | case MIIM_CIS8201_AUXCONSTAT_100: |
| 775 | priv->speed = 100; |
| 776 | break; |
| 777 | default: |
| 778 | priv->speed = 10; |
| 779 | break; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 780 | } |
| 781 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 782 | return 0; |
| 783 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 784 | |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 785 | /* Parse the vsc8244's status register for speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 786 | * information |
| 787 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 788 | static uint mii_parse_vsc8244(uint mii_reg, struct tsec_private * priv) |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 789 | { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 790 | uint speed; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 791 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 792 | if (mii_reg & MIIM_VSC8244_AUXCONSTAT_DUPLEX) |
| 793 | priv->duplexity = 1; |
| 794 | else |
| 795 | priv->duplexity = 0; |
| 796 | |
| 797 | speed = mii_reg & MIIM_VSC8244_AUXCONSTAT_SPEED; |
| 798 | switch (speed) { |
| 799 | case MIIM_VSC8244_AUXCONSTAT_GBIT: |
| 800 | priv->speed = 1000; |
| 801 | break; |
| 802 | case MIIM_VSC8244_AUXCONSTAT_100: |
| 803 | priv->speed = 100; |
| 804 | break; |
| 805 | default: |
| 806 | priv->speed = 10; |
| 807 | break; |
| 808 | } |
| 809 | |
| 810 | return 0; |
| 811 | } |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 812 | |
| 813 | /* Parse the DM9161's status register for speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 814 | * information |
| 815 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 816 | static uint mii_parse_dm9161_scsr(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 817 | { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 818 | if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_100H)) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 819 | priv->speed = 100; |
| 820 | else |
| 821 | priv->speed = 10; |
| 822 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 823 | if (mii_reg & (MIIM_DM9161_SCSR_100F | MIIM_DM9161_SCSR_10F)) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 824 | priv->duplexity = 1; |
| 825 | else |
| 826 | priv->duplexity = 0; |
| 827 | |
| 828 | return 0; |
| 829 | } |
| 830 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 831 | /* |
| 832 | * Hack to write all 4 PHYs with the LED values |
| 833 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 834 | static uint mii_cis8204_fixled(uint mii_reg, struct tsec_private * priv) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 835 | { |
| 836 | uint phyid; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 837 | tsec_mdio_t *regbase = priv->phyregs; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 838 | int timeout = 1000000; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 839 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 840 | for (phyid = 0; phyid < 4; phyid++) { |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 841 | out_be32(®base->miimadd, (phyid << 8) | mii_reg); |
| 842 | out_be32(®base->miimcon, MIIM_CIS8204_SLEDCON_INIT); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 843 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 844 | timeout = 1000000; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 845 | while ((in_be32(®base->miimind) & MIIMIND_BUSY) && timeout--) |
| 846 | ; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 847 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 848 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 849 | return MIIM_CIS8204_SLEDCON_INIT; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 850 | } |
| 851 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 852 | static uint mii_cis8204_setmode(uint mii_reg, struct tsec_private * priv) |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 853 | { |
| 854 | if (priv->flags & TSEC_REDUCED) |
| 855 | return MIIM_CIS8204_EPHYCON_INIT | MIIM_CIS8204_EPHYCON_RGMII; |
| 856 | else |
| 857 | return MIIM_CIS8204_EPHYCON_INIT; |
| 858 | } |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 859 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 860 | static uint mii_m88e1111s_setmode(uint mii_reg, struct tsec_private *priv) |
Dave Liu | b19ecd3 | 2007-09-18 12:37:57 +0800 | [diff] [blame] | 861 | { |
| 862 | uint mii_data = read_phy_reg(priv, mii_reg); |
| 863 | |
| 864 | if (priv->flags & TSEC_REDUCED) |
| 865 | mii_data = (mii_data & 0xfff0) | 0x000b; |
| 866 | return mii_data; |
| 867 | } |
| 868 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 869 | /* Initialized required registers to appropriate values, zeroing |
| 870 | * those we don't care about (unless zero is bad, in which case, |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 871 | * choose a more appropriate value) |
| 872 | */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 873 | static void init_registers(tsec_t *regs) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 874 | { |
| 875 | /* Clear IEVENT */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 876 | out_be32(®s->ievent, IEVENT_INIT_CLEAR); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 877 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 878 | out_be32(®s->imask, IMASK_INIT_CLEAR); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 879 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 880 | out_be32(®s->hash.iaddr0, 0); |
| 881 | out_be32(®s->hash.iaddr1, 0); |
| 882 | out_be32(®s->hash.iaddr2, 0); |
| 883 | out_be32(®s->hash.iaddr3, 0); |
| 884 | out_be32(®s->hash.iaddr4, 0); |
| 885 | out_be32(®s->hash.iaddr5, 0); |
| 886 | out_be32(®s->hash.iaddr6, 0); |
| 887 | out_be32(®s->hash.iaddr7, 0); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 888 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 889 | out_be32(®s->hash.gaddr0, 0); |
| 890 | out_be32(®s->hash.gaddr1, 0); |
| 891 | out_be32(®s->hash.gaddr2, 0); |
| 892 | out_be32(®s->hash.gaddr3, 0); |
| 893 | out_be32(®s->hash.gaddr4, 0); |
| 894 | out_be32(®s->hash.gaddr5, 0); |
| 895 | out_be32(®s->hash.gaddr6, 0); |
| 896 | out_be32(®s->hash.gaddr7, 0); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 897 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 898 | out_be32(®s->rctrl, 0x00000000); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 899 | |
| 900 | /* Init RMON mib registers */ |
| 901 | memset((void *)&(regs->rmon), 0, sizeof(rmon_mib_t)); |
| 902 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 903 | out_be32(®s->rmon.cam1, 0xffffffff); |
| 904 | out_be32(®s->rmon.cam2, 0xffffffff); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 905 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 906 | out_be32(®s->mrblr, MRBLR_INIT_SETTINGS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 907 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 908 | out_be32(®s->minflr, MINFLR_INIT_SETTINGS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 909 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 910 | out_be32(®s->attr, ATTR_INIT_SETTINGS); |
| 911 | out_be32(®s->attreli, ATTRELI_INIT_SETTINGS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 912 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 913 | } |
| 914 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 915 | /* Configure maccfg2 based on negotiated speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 916 | * reported by PHY handling code |
| 917 | */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 918 | static void adjust_link(struct eth_device *dev) |
| 919 | { |
| 920 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 921 | tsec_t *regs = priv->regs; |
| 922 | u32 ecntrl, maccfg2; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 923 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 924 | if (!priv->link) { |
| 925 | printf("%s: No link.\n", dev->name); |
| 926 | return; |
| 927 | } |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 928 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 929 | /* clear all bits relative with interface mode */ |
| 930 | ecntrl = in_be32(®s->ecntrl); |
| 931 | ecntrl &= ~ECNTRL_R100; |
Jon Loeliger | 77a4f6e | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 932 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 933 | maccfg2 = in_be32(®s->maccfg2); |
| 934 | maccfg2 &= ~(MACCFG2_IF | MACCFG2_FULL_DUPLEX); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 935 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 936 | if (priv->duplexity) |
| 937 | maccfg2 |= MACCFG2_FULL_DUPLEX; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 938 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 939 | switch (priv->speed) { |
| 940 | case 1000: |
| 941 | maccfg2 |= MACCFG2_GMII; |
| 942 | break; |
| 943 | case 100: |
| 944 | case 10: |
| 945 | maccfg2 |= MACCFG2_MII; |
| 946 | |
| 947 | /* Set R100 bit in all modes although |
| 948 | * it is only used in RGMII mode |
| 949 | */ |
| 950 | if (priv->speed == 100) |
| 951 | ecntrl |= ECNTRL_R100; |
| 952 | break; |
| 953 | default: |
| 954 | printf("%s: Speed was bad\n", dev->name); |
| 955 | break; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 956 | } |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 957 | |
| 958 | out_be32(®s->ecntrl, ecntrl); |
| 959 | out_be32(®s->maccfg2, maccfg2); |
| 960 | |
| 961 | printf("Speed: %d, %s duplex%s\n", priv->speed, |
| 962 | (priv->duplexity) ? "full" : "half", |
| 963 | (priv->flags & TSEC_FIBER) ? ", fiber mode" : ""); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 964 | } |
| 965 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 966 | /* Set up the buffers and their descriptors, and bring up the |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 967 | * interface |
| 968 | */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 969 | static void startup_tsec(struct eth_device *dev) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 970 | { |
| 971 | int i; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 972 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 973 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 974 | |
| 975 | /* Point to the buffer descriptors */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 976 | out_be32(®s->tbase, (unsigned int)(&rtx.txbd[txIdx])); |
| 977 | out_be32(®s->rbase, (unsigned int)(&rtx.rxbd[rxIdx])); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 978 | |
| 979 | /* Initialize the Rx Buffer descriptors */ |
| 980 | for (i = 0; i < PKTBUFSRX; i++) { |
| 981 | rtx.rxbd[i].status = RXBD_EMPTY; |
| 982 | rtx.rxbd[i].length = 0; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 983 | rtx.rxbd[i].bufPtr = (uint) NetRxPackets[i]; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 984 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 985 | rtx.rxbd[PKTBUFSRX - 1].status |= RXBD_WRAP; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 986 | |
| 987 | /* Initialize the TX Buffer Descriptors */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 988 | for (i = 0; i < TX_BUF_CNT; i++) { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 989 | rtx.txbd[i].status = 0; |
| 990 | rtx.txbd[i].length = 0; |
| 991 | rtx.txbd[i].bufPtr = 0; |
| 992 | } |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 993 | rtx.txbd[TX_BUF_CNT - 1].status |= TXBD_WRAP; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 994 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 995 | /* Start up the PHY */ |
Ben Warren | f11eefb | 2006-10-26 14:38:25 -0400 | [diff] [blame] | 996 | if(priv->phyinfo) |
| 997 | phy_run_commands(priv, priv->phyinfo->startup); |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 998 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 999 | adjust_link(dev); |
| 1000 | |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1001 | /* Enable Transmit and Receive */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1002 | setbits_be32(®s->maccfg1, MACCFG1_RX_EN | MACCFG1_TX_EN); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1003 | |
| 1004 | /* Tell the DMA it is clear to go */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1005 | setbits_be32(®s->dmactrl, DMACTRL_INIT_SETTINGS); |
| 1006 | out_be32(®s->tstat, TSTAT_CLEAR_THALT); |
| 1007 | out_be32(®s->rstat, RSTAT_CLEAR_RHALT); |
| 1008 | clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1009 | } |
| 1010 | |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1011 | /* This returns the status bits of the device. The return value |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1012 | * is never checked, and this is what the 8260 driver did, so we |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1013 | * do the same. Presumably, this would be zero if there were no |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1014 | * errors |
| 1015 | */ |
| 1016 | static int tsec_send(struct eth_device *dev, volatile void *packet, int length) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1017 | { |
| 1018 | int i; |
| 1019 | int result = 0; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1020 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1021 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1022 | |
| 1023 | /* Find an empty buffer descriptor */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1024 | for (i = 0; rtx.txbd[txIdx].status & TXBD_READY; i++) { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1025 | if (i >= TOUT_LOOP) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1026 | debug("%s: tsec: tx buffers full\n", dev->name); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1027 | return result; |
| 1028 | } |
| 1029 | } |
| 1030 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1031 | rtx.txbd[txIdx].bufPtr = (uint) packet; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1032 | rtx.txbd[txIdx].length = length; |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1033 | rtx.txbd[txIdx].status |= |
| 1034 | (TXBD_READY | TXBD_LAST | TXBD_CRC | TXBD_INTERRUPT); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1035 | |
| 1036 | /* Tell the DMA to go */ |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1037 | out_be32(®s->tstat, TSTAT_CLEAR_THALT); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1038 | |
| 1039 | /* Wait for buffer to be transmitted */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1040 | for (i = 0; rtx.txbd[txIdx].status & TXBD_READY; i++) { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1041 | if (i >= TOUT_LOOP) { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1042 | debug("%s: tsec: tx error\n", dev->name); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1043 | return result; |
| 1044 | } |
| 1045 | } |
| 1046 | |
| 1047 | txIdx = (txIdx + 1) % TX_BUF_CNT; |
| 1048 | result = rtx.txbd[txIdx].status & TXBD_STATS; |
| 1049 | |
| 1050 | return result; |
| 1051 | } |
| 1052 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1053 | static int tsec_recv(struct eth_device *dev) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1054 | { |
| 1055 | int length; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1056 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1057 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1058 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1059 | while (!(rtx.rxbd[rxIdx].status & RXBD_EMPTY)) { |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1060 | |
| 1061 | length = rtx.rxbd[rxIdx].length; |
| 1062 | |
| 1063 | /* Send the packet up if there were no errors */ |
| 1064 | if (!(rtx.rxbd[rxIdx].status & RXBD_STATS)) { |
| 1065 | NetReceive(NetRxPackets[rxIdx], length - 4); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1066 | } else { |
| 1067 | printf("Got error %x\n", |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1068 | (rtx.rxbd[rxIdx].status & RXBD_STATS)); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1069 | } |
| 1070 | |
| 1071 | rtx.rxbd[rxIdx].length = 0; |
| 1072 | |
| 1073 | /* Set the wrap bit if this is the last element in the list */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1074 | rtx.rxbd[rxIdx].status = |
| 1075 | RXBD_EMPTY | (((rxIdx + 1) == PKTBUFSRX) ? RXBD_WRAP : 0); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1076 | |
| 1077 | rxIdx = (rxIdx + 1) % PKTBUFSRX; |
| 1078 | } |
| 1079 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1080 | if (in_be32(®s->ievent) & IEVENT_BSY) { |
| 1081 | out_be32(®s->ievent, IEVENT_BSY); |
| 1082 | out_be32(®s->rstat, RSTAT_CLEAR_RHALT); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | return -1; |
| 1086 | |
| 1087 | } |
| 1088 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1089 | /* Stop the interface */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1090 | static void tsec_halt(struct eth_device *dev) |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1091 | { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1092 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1093 | tsec_t *regs = priv->regs; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1094 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1095 | clrbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); |
| 1096 | setbits_be32(®s->dmactrl, DMACTRL_GRS | DMACTRL_GTS); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1097 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1098 | while ((in_be32(®s->ievent) & (IEVENT_GRSC | IEVENT_GTSC)) |
| 1099 | != (IEVENT_GRSC | IEVENT_GTSC)) |
| 1100 | ; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1101 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1102 | clrbits_be32(®s->maccfg1, MACCFG1_TX_EN | MACCFG1_RX_EN); |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1103 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1104 | /* Shut down the PHY, as needed */ |
Ben Warren | f11eefb | 2006-10-26 14:38:25 -0400 | [diff] [blame] | 1105 | if(priv->phyinfo) |
| 1106 | phy_run_commands(priv, priv->phyinfo->shutdown); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1107 | } |
| 1108 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1109 | static struct phy_info phy_info_M88E1149S = { |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1110 | 0x1410ca, |
| 1111 | "Marvell 88E1149S", |
| 1112 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1113 | (struct phy_cmd[]) { /* config */ |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1114 | /* Reset and configure the PHY */ |
| 1115 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1116 | {0x1d, 0x1f, NULL}, |
| 1117 | {0x1e, 0x200c, NULL}, |
| 1118 | {0x1d, 0x5, NULL}, |
| 1119 | {0x1e, 0x0, NULL}, |
| 1120 | {0x1e, 0x100, NULL}, |
| 1121 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1122 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1123 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1124 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1125 | {miim_end,} |
| 1126 | }, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1127 | (struct phy_cmd[]) { /* startup */ |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1128 | /* Status is read once to clear old link state */ |
| 1129 | {MIIM_STATUS, miim_read, NULL}, |
| 1130 | /* Auto-negotiate */ |
| 1131 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1132 | /* Read the status */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1133 | {MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr}, |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1134 | {miim_end,} |
| 1135 | }, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1136 | (struct phy_cmd[]) { /* shutdown */ |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1137 | {miim_end,} |
| 1138 | }, |
Andy Fleming | bee6700 | 2007-08-03 04:05:25 -0500 | [diff] [blame] | 1139 | }; |
| 1140 | |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 1141 | /* The 5411 id is 0x206070, the 5421 is 0x2060e0 */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1142 | static struct phy_info phy_info_BCM5461S = { |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 1143 | 0x02060c1, /* 5461 ID */ |
| 1144 | "Broadcom BCM5461S", |
| 1145 | 0, /* not clear to me what minor revisions we can shift away */ |
| 1146 | (struct phy_cmd[]) { /* config */ |
| 1147 | /* Reset and configure the PHY */ |
| 1148 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1149 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1150 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1151 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1152 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1153 | {miim_end,} |
| 1154 | }, |
| 1155 | (struct phy_cmd[]) { /* startup */ |
| 1156 | /* Status is read once to clear old link state */ |
| 1157 | {MIIM_STATUS, miim_read, NULL}, |
| 1158 | /* Auto-negotiate */ |
| 1159 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1160 | /* Read the status */ |
| 1161 | {MIIM_BCM54xx_AUXSTATUS, miim_read, &mii_parse_BCM54xx_sr}, |
| 1162 | {miim_end,} |
| 1163 | }, |
| 1164 | (struct phy_cmd[]) { /* shutdown */ |
| 1165 | {miim_end,} |
| 1166 | }, |
| 1167 | }; |
| 1168 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1169 | static struct phy_info phy_info_BCM5464S = { |
Joe Hamman | ed7ad4e | 2007-04-30 16:47:28 -0500 | [diff] [blame] | 1170 | 0x02060b1, /* 5464 ID */ |
| 1171 | "Broadcom BCM5464S", |
| 1172 | 0, /* not clear to me what minor revisions we can shift away */ |
| 1173 | (struct phy_cmd[]) { /* config */ |
| 1174 | /* Reset and configure the PHY */ |
| 1175 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1176 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1177 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1178 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
Zach LeRoy | ddb7fc7 | 2009-05-22 10:26:33 -0500 | [diff] [blame] | 1179 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1180 | {miim_end,} |
| 1181 | }, |
| 1182 | (struct phy_cmd[]) { /* startup */ |
| 1183 | /* Status is read once to clear old link state */ |
| 1184 | {MIIM_STATUS, miim_read, NULL}, |
| 1185 | /* Auto-negotiate */ |
| 1186 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1187 | /* Read the status */ |
| 1188 | {MIIM_BCM54xx_AUXSTATUS, miim_read, &mii_parse_BCM54xx_sr}, |
| 1189 | {miim_end,} |
| 1190 | }, |
| 1191 | (struct phy_cmd[]) { /* shutdown */ |
| 1192 | {miim_end,} |
| 1193 | }, |
| 1194 | }; |
| 1195 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1196 | static struct phy_info phy_info_BCM5482S = { |
Zach LeRoy | ddb7fc7 | 2009-05-22 10:26:33 -0500 | [diff] [blame] | 1197 | 0x0143bcb, |
| 1198 | "Broadcom BCM5482S", |
| 1199 | 4, |
| 1200 | (struct phy_cmd[]) { /* config */ |
| 1201 | /* Reset and configure the PHY */ |
| 1202 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1203 | /* Setup read from auxilary control shadow register 7 */ |
| 1204 | {MIIM_BCM54xx_AUXCNTL, MIIM_BCM54xx_AUXCNTL_ENCODE(7), NULL}, |
| 1205 | /* Read Misc Control register and or in Ethernet@Wirespeed */ |
| 1206 | {MIIM_BCM54xx_AUXCNTL, 0, &mii_BCM54xx_wirespeed}, |
Joe Hamman | ed7ad4e | 2007-04-30 16:47:28 -0500 | [diff] [blame] | 1207 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 1208 | /* Initial config/enable of secondary SerDes interface */ |
| 1209 | {MIIM_BCM54XX_SHD, MIIM_BCM54XX_SHD_WR_ENCODE(0x14, 0xf), NULL}, |
| 1210 | /* Write intial value to secondary SerDes Contol */ |
| 1211 | {MIIM_BCM54XX_EXP_SEL, MIIM_BCM54XX_EXP_SEL_SSD | 0, NULL}, |
| 1212 | {MIIM_BCM54XX_EXP_DATA, MIIM_CONTROL_RESTART, NULL}, |
| 1213 | /* Enable copper/fiber auto-detect */ |
| 1214 | {MIIM_BCM54XX_SHD, MIIM_BCM54XX_SHD_WR_ENCODE(0x1e, 0x201)}, |
Joe Hamman | ed7ad4e | 2007-04-30 16:47:28 -0500 | [diff] [blame] | 1215 | {miim_end,} |
| 1216 | }, |
| 1217 | (struct phy_cmd[]) { /* startup */ |
| 1218 | /* Status is read once to clear old link state */ |
| 1219 | {MIIM_STATUS, miim_read, NULL}, |
Peter Tyser | 3c93d8b | 2009-11-09 13:09:47 -0600 | [diff] [blame] | 1220 | /* Determine copper/fiber, auto-negotiate, and read the result */ |
| 1221 | {MIIM_STATUS, miim_read, &mii_parse_BCM5482_sr}, |
Joe Hamman | ed7ad4e | 2007-04-30 16:47:28 -0500 | [diff] [blame] | 1222 | {miim_end,} |
| 1223 | }, |
| 1224 | (struct phy_cmd[]) { /* shutdown */ |
| 1225 | {miim_end,} |
| 1226 | }, |
| 1227 | }; |
| 1228 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1229 | static struct phy_info phy_info_M88E1011S = { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1230 | 0x01410c6, |
| 1231 | "Marvell 88E1011S", |
| 1232 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1233 | (struct phy_cmd[]) { /* config */ |
| 1234 | /* Reset and configure the PHY */ |
| 1235 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1236 | {0x1d, 0x1f, NULL}, |
| 1237 | {0x1e, 0x200c, NULL}, |
| 1238 | {0x1d, 0x5, NULL}, |
| 1239 | {0x1e, 0x0, NULL}, |
| 1240 | {0x1e, 0x100, NULL}, |
| 1241 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1242 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1243 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1244 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1245 | {miim_end,} |
| 1246 | }, |
| 1247 | (struct phy_cmd[]) { /* startup */ |
| 1248 | /* Status is read once to clear old link state */ |
| 1249 | {MIIM_STATUS, miim_read, NULL}, |
| 1250 | /* Auto-negotiate */ |
| 1251 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1252 | /* Read the status */ |
| 1253 | {MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr}, |
| 1254 | {miim_end,} |
| 1255 | }, |
| 1256 | (struct phy_cmd[]) { /* shutdown */ |
| 1257 | {miim_end,} |
| 1258 | }, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1259 | }; |
| 1260 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1261 | static struct phy_info phy_info_M88E1111S = { |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1262 | 0x01410cc, |
| 1263 | "Marvell 88E1111S", |
| 1264 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1265 | (struct phy_cmd[]) { /* config */ |
| 1266 | /* Reset and configure the PHY */ |
| 1267 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1268 | {0x1b, 0x848f, &mii_m88e1111s_setmode}, |
| 1269 | {0x14, 0x0cd2, NULL}, /* Delay RGMII TX and RX */ |
| 1270 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1271 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1272 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1273 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1274 | {miim_end,} |
| 1275 | }, |
| 1276 | (struct phy_cmd[]) { /* startup */ |
| 1277 | /* Status is read once to clear old link state */ |
| 1278 | {MIIM_STATUS, miim_read, NULL}, |
| 1279 | /* Auto-negotiate */ |
| 1280 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1281 | /* Read the status */ |
| 1282 | {MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr}, |
| 1283 | {miim_end,} |
| 1284 | }, |
| 1285 | (struct phy_cmd[]) { /* shutdown */ |
| 1286 | {miim_end,} |
| 1287 | }, |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1288 | }; |
| 1289 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1290 | static struct phy_info phy_info_M88E1118 = { |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1291 | 0x01410e1, |
| 1292 | "Marvell 88E1118", |
| 1293 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1294 | (struct phy_cmd[]) { /* config */ |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1295 | /* Reset and configure the PHY */ |
| 1296 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1297 | {0x16, 0x0002, NULL}, /* Change Page Number */ |
| 1298 | {0x15, 0x1070, NULL}, /* Delay RGMII TX and RX */ |
Ron Madrid | aa4aac4 | 2009-01-28 16:17:21 -0800 | [diff] [blame] | 1299 | {0x16, 0x0003, NULL}, /* Change Page Number */ |
| 1300 | {0x10, 0x021e, NULL}, /* Adjust LED control */ |
| 1301 | {0x16, 0x0000, NULL}, /* Change Page Number */ |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1302 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1303 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1304 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1305 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1306 | {miim_end,} |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1307 | }, |
| 1308 | (struct phy_cmd[]) { /* startup */ |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1309 | {0x16, 0x0000, NULL}, /* Change Page Number */ |
| 1310 | /* Status is read once to clear old link state */ |
| 1311 | {MIIM_STATUS, miim_read, NULL}, |
| 1312 | /* Auto-negotiate */ |
Ron Madrid | aa4aac4 | 2009-01-28 16:17:21 -0800 | [diff] [blame] | 1313 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1314 | /* Read the status */ |
| 1315 | {MIIM_88E1011_PHY_STATUS, miim_read, |
| 1316 | &mii_parse_88E1011_psr}, |
| 1317 | {miim_end,} |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1318 | }, |
| 1319 | (struct phy_cmd[]) { /* shutdown */ |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1320 | {miim_end,} |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1321 | }, |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1322 | }; |
| 1323 | |
Sergei Poselenov | 7d4a2c3 | 2008-06-06 15:52:44 +0200 | [diff] [blame] | 1324 | /* |
| 1325 | * Since to access LED register we need do switch the page, we |
| 1326 | * do LED configuring in the miim_read-like function as follows |
| 1327 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1328 | static uint mii_88E1121_set_led (uint mii_reg, struct tsec_private *priv) |
Sergei Poselenov | 7d4a2c3 | 2008-06-06 15:52:44 +0200 | [diff] [blame] | 1329 | { |
| 1330 | uint pg; |
| 1331 | |
| 1332 | /* Switch the page to access the led register */ |
| 1333 | pg = read_phy_reg(priv, MIIM_88E1121_PHY_PAGE); |
| 1334 | write_phy_reg(priv, MIIM_88E1121_PHY_PAGE, MIIM_88E1121_PHY_LED_PAGE); |
| 1335 | |
| 1336 | /* Configure leds */ |
| 1337 | write_phy_reg(priv, MIIM_88E1121_PHY_LED_CTRL, |
| 1338 | MIIM_88E1121_PHY_LED_DEF); |
| 1339 | |
| 1340 | /* Restore the page pointer */ |
| 1341 | write_phy_reg(priv, MIIM_88E1121_PHY_PAGE, pg); |
| 1342 | return 0; |
| 1343 | } |
| 1344 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1345 | static struct phy_info phy_info_M88E1121R = { |
Sergei Poselenov | 7d4a2c3 | 2008-06-06 15:52:44 +0200 | [diff] [blame] | 1346 | 0x01410cb, |
| 1347 | "Marvell 88E1121R", |
| 1348 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1349 | (struct phy_cmd[]) { /* config */ |
| 1350 | /* Reset and configure the PHY */ |
| 1351 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1352 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1353 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1354 | /* Configure leds */ |
| 1355 | {MIIM_88E1121_PHY_LED_CTRL, miim_read, &mii_88E1121_set_led}, |
| 1356 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1357 | /* Disable IRQs and de-assert interrupt */ |
| 1358 | {MIIM_88E1121_PHY_IRQ_EN, 0, NULL}, |
| 1359 | {MIIM_88E1121_PHY_IRQ_STATUS, miim_read, NULL}, |
| 1360 | {miim_end,} |
| 1361 | }, |
| 1362 | (struct phy_cmd[]) { /* startup */ |
| 1363 | /* Status is read once to clear old link state */ |
| 1364 | {MIIM_STATUS, miim_read, NULL}, |
| 1365 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1366 | {MIIM_STATUS, miim_read, &mii_parse_link}, |
| 1367 | {miim_end,} |
| 1368 | }, |
| 1369 | (struct phy_cmd[]) { /* shutdown */ |
| 1370 | {miim_end,} |
| 1371 | }, |
Sergei Poselenov | 7d4a2c3 | 2008-06-06 15:52:44 +0200 | [diff] [blame] | 1372 | }; |
| 1373 | |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1374 | static unsigned int m88e1145_setmode(uint mii_reg, struct tsec_private *priv) |
| 1375 | { |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1376 | uint mii_data = read_phy_reg(priv, mii_reg); |
| 1377 | |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1378 | /* Setting MIIM_88E1145_PHY_EXT_CR */ |
| 1379 | if (priv->flags & TSEC_REDUCED) |
| 1380 | return mii_data | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1381 | MIIM_M88E1145_RGMII_RX_DELAY | MIIM_M88E1145_RGMII_TX_DELAY; |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1382 | else |
| 1383 | return mii_data; |
| 1384 | } |
| 1385 | |
| 1386 | static struct phy_info phy_info_M88E1145 = { |
| 1387 | 0x01410cd, |
| 1388 | "Marvell 88E1145", |
| 1389 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1390 | (struct phy_cmd[]) { /* config */ |
| 1391 | /* Reset the PHY */ |
| 1392 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
Andy Fleming | 180d03a | 2007-05-08 17:23:02 -0500 | [diff] [blame] | 1393 | |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1394 | /* Errata E0, E1 */ |
| 1395 | {29, 0x001b, NULL}, |
| 1396 | {30, 0x418f, NULL}, |
| 1397 | {29, 0x0016, NULL}, |
| 1398 | {30, 0xa2da, NULL}, |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1399 | |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1400 | /* Configure the PHY */ |
| 1401 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1402 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1403 | {MIIM_88E1011_PHY_SCR, MIIM_88E1011_PHY_MDI_X_AUTO, NULL}, |
| 1404 | {MIIM_88E1145_PHY_EXT_CR, 0, &m88e1145_setmode}, |
| 1405 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1406 | {MIIM_CONTROL, MIIM_CONTROL_INIT, NULL}, |
| 1407 | {miim_end,} |
| 1408 | }, |
| 1409 | (struct phy_cmd[]) { /* startup */ |
| 1410 | /* Status is read once to clear old link state */ |
| 1411 | {MIIM_STATUS, miim_read, NULL}, |
| 1412 | /* Auto-negotiate */ |
| 1413 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1414 | {MIIM_88E1111_PHY_LED_CONTROL, MIIM_88E1111_PHY_LED_DIRECT, NULL}, |
| 1415 | /* Read the Status */ |
| 1416 | {MIIM_88E1011_PHY_STATUS, miim_read, &mii_parse_88E1011_psr}, |
| 1417 | {miim_end,} |
| 1418 | }, |
| 1419 | (struct phy_cmd[]) { /* shutdown */ |
| 1420 | {miim_end,} |
| 1421 | }, |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1422 | }; |
| 1423 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1424 | static struct phy_info phy_info_cis8204 = { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1425 | 0x3f11, |
| 1426 | "Cicada Cis8204", |
| 1427 | 6, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1428 | (struct phy_cmd[]) { /* config */ |
| 1429 | /* Override PHY config settings */ |
| 1430 | {MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL}, |
| 1431 | /* Configure some basic stuff */ |
| 1432 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1433 | {MIIM_CIS8204_SLED_CON, MIIM_CIS8204_SLEDCON_INIT, |
| 1434 | &mii_cis8204_fixled}, |
| 1435 | {MIIM_CIS8204_EPHY_CON, MIIM_CIS8204_EPHYCON_INIT, |
| 1436 | &mii_cis8204_setmode}, |
| 1437 | {miim_end,} |
| 1438 | }, |
| 1439 | (struct phy_cmd[]) { /* startup */ |
| 1440 | /* Read the Status (2x to make sure link is right) */ |
| 1441 | {MIIM_STATUS, miim_read, NULL}, |
| 1442 | /* Auto-negotiate */ |
| 1443 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1444 | /* Read the status */ |
| 1445 | {MIIM_CIS8201_AUX_CONSTAT, miim_read, &mii_parse_cis8201}, |
| 1446 | {miim_end,} |
| 1447 | }, |
| 1448 | (struct phy_cmd[]) { /* shutdown */ |
| 1449 | {miim_end,} |
| 1450 | }, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1451 | }; |
| 1452 | |
| 1453 | /* Cicada 8201 */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1454 | static struct phy_info phy_info_cis8201 = { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1455 | 0xfc41, |
| 1456 | "CIS8201", |
| 1457 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1458 | (struct phy_cmd[]) { /* config */ |
| 1459 | /* Override PHY config settings */ |
| 1460 | {MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL}, |
| 1461 | /* Set up the interface mode */ |
| 1462 | {MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT, NULL}, |
| 1463 | /* Configure some basic stuff */ |
| 1464 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1465 | {miim_end,} |
| 1466 | }, |
| 1467 | (struct phy_cmd[]) { /* startup */ |
| 1468 | /* Read the Status (2x to make sure link is right) */ |
| 1469 | {MIIM_STATUS, miim_read, NULL}, |
| 1470 | /* Auto-negotiate */ |
| 1471 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1472 | /* Read the status */ |
| 1473 | {MIIM_CIS8201_AUX_CONSTAT, miim_read, &mii_parse_cis8201}, |
| 1474 | {miim_end,} |
| 1475 | }, |
| 1476 | (struct phy_cmd[]) { /* shutdown */ |
| 1477 | {miim_end,} |
| 1478 | }, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1479 | }; |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1480 | |
| 1481 | static struct phy_info phy_info_VSC8211 = { |
Pieter Henning | 9370c8b | 2009-02-22 23:17:15 -0800 | [diff] [blame] | 1482 | 0xfc4b, |
| 1483 | "Vitesse VSC8211", |
| 1484 | 4, |
| 1485 | (struct phy_cmd[]) { /* config */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1486 | /* Override PHY config settings */ |
| 1487 | {MIIM_CIS8201_AUX_CONSTAT, MIIM_CIS8201_AUXCONSTAT_INIT, NULL}, |
| 1488 | /* Set up the interface mode */ |
| 1489 | {MIIM_CIS8201_EXT_CON1, MIIM_CIS8201_EXTCON1_INIT, NULL}, |
| 1490 | /* Configure some basic stuff */ |
| 1491 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1492 | {miim_end,} |
| 1493 | }, |
Pieter Henning | 9370c8b | 2009-02-22 23:17:15 -0800 | [diff] [blame] | 1494 | (struct phy_cmd[]) { /* startup */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1495 | /* Read the Status (2x to make sure link is right) */ |
| 1496 | {MIIM_STATUS, miim_read, NULL}, |
| 1497 | /* Auto-negotiate */ |
| 1498 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1499 | /* Read the status */ |
| 1500 | {MIIM_CIS8201_AUX_CONSTAT, miim_read, &mii_parse_cis8201}, |
| 1501 | {miim_end,} |
| 1502 | }, |
Pieter Henning | 9370c8b | 2009-02-22 23:17:15 -0800 | [diff] [blame] | 1503 | (struct phy_cmd[]) { /* shutdown */ |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1504 | {miim_end,} |
Pieter Henning | 9370c8b | 2009-02-22 23:17:15 -0800 | [diff] [blame] | 1505 | }, |
| 1506 | }; |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1507 | |
| 1508 | static struct phy_info phy_info_VSC8244 = { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1509 | 0x3f1b, |
| 1510 | "Vitesse VSC8244", |
| 1511 | 6, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1512 | (struct phy_cmd[]) { /* config */ |
| 1513 | /* Override PHY config settings */ |
| 1514 | /* Configure some basic stuff */ |
| 1515 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1516 | {miim_end,} |
| 1517 | }, |
| 1518 | (struct phy_cmd[]) { /* startup */ |
| 1519 | /* Read the Status (2x to make sure link is right) */ |
| 1520 | {MIIM_STATUS, miim_read, NULL}, |
| 1521 | /* Auto-negotiate */ |
| 1522 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1523 | /* Read the status */ |
| 1524 | {MIIM_VSC8244_AUX_CONSTAT, miim_read, &mii_parse_vsc8244}, |
| 1525 | {miim_end,} |
| 1526 | }, |
| 1527 | (struct phy_cmd[]) { /* shutdown */ |
| 1528 | {miim_end,} |
| 1529 | }, |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1530 | }; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1531 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1532 | static struct phy_info phy_info_VSC8641 = { |
Poonam Aggrwal | c91b5de | 2009-07-02 16:15:13 +0530 | [diff] [blame] | 1533 | 0x7043, |
| 1534 | "Vitesse VSC8641", |
| 1535 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1536 | (struct phy_cmd[]) { /* config */ |
| 1537 | /* Configure some basic stuff */ |
| 1538 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1539 | {miim_end,} |
| 1540 | }, |
| 1541 | (struct phy_cmd[]) { /* startup */ |
| 1542 | /* Read the Status (2x to make sure link is right) */ |
| 1543 | {MIIM_STATUS, miim_read, NULL}, |
| 1544 | /* Auto-negotiate */ |
| 1545 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1546 | /* Read the status */ |
| 1547 | {MIIM_VSC8244_AUX_CONSTAT, miim_read, &mii_parse_vsc8244}, |
| 1548 | {miim_end,} |
| 1549 | }, |
| 1550 | (struct phy_cmd[]) { /* shutdown */ |
| 1551 | {miim_end,} |
| 1552 | }, |
Poonam Aggrwal | c91b5de | 2009-07-02 16:15:13 +0530 | [diff] [blame] | 1553 | }; |
| 1554 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1555 | static struct phy_info phy_info_VSC8221 = { |
Poonam Aggrwal | c91b5de | 2009-07-02 16:15:13 +0530 | [diff] [blame] | 1556 | 0xfc55, |
| 1557 | "Vitesse VSC8221", |
| 1558 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1559 | (struct phy_cmd[]) { /* config */ |
| 1560 | /* Configure some basic stuff */ |
| 1561 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1562 | {miim_end,} |
| 1563 | }, |
| 1564 | (struct phy_cmd[]) { /* startup */ |
| 1565 | /* Read the Status (2x to make sure link is right) */ |
| 1566 | {MIIM_STATUS, miim_read, NULL}, |
| 1567 | /* Auto-negotiate */ |
| 1568 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1569 | /* Read the status */ |
| 1570 | {MIIM_VSC8244_AUX_CONSTAT, miim_read, &mii_parse_vsc8244}, |
| 1571 | {miim_end,} |
| 1572 | }, |
| 1573 | (struct phy_cmd[]) { /* shutdown */ |
| 1574 | {miim_end,} |
| 1575 | }, |
Poonam Aggrwal | c91b5de | 2009-07-02 16:15:13 +0530 | [diff] [blame] | 1576 | }; |
| 1577 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1578 | static struct phy_info phy_info_VSC8601 = { |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1579 | 0x00007042, |
| 1580 | "Vitesse VSC8601", |
| 1581 | 4, |
| 1582 | (struct phy_cmd[]) { /* config */ |
| 1583 | /* Override PHY config settings */ |
| 1584 | /* Configure some basic stuff */ |
| 1585 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1586 | #ifdef CONFIG_SYS_VSC8601_SKEWFIX |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1587 | {MIIM_VSC8601_EPHY_CON,MIIM_VSC8601_EPHY_CON_INIT_SKEW,NULL}, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 1588 | #if defined(CONFIG_SYS_VSC8601_SKEW_TX) && defined(CONFIG_SYS_VSC8601_SKEW_RX) |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1589 | {MIIM_EXT_PAGE_ACCESS,1,NULL}, |
| 1590 | #define VSC8101_SKEW \ |
| 1591 | (CONFIG_SYS_VSC8601_SKEW_TX << 14) | (CONFIG_SYS_VSC8601_SKEW_RX << 12) |
| 1592 | {MIIM_VSC8601_SKEW_CTRL,VSC8101_SKEW,NULL}, |
| 1593 | {MIIM_EXT_PAGE_ACCESS,0,NULL}, |
Andre Schwarz | 1e18be1 | 2008-04-29 19:18:32 +0200 | [diff] [blame] | 1594 | #endif |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 1595 | #endif |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1596 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1597 | {MIIM_CONTROL, MIIM_CONTROL_RESTART, &mii_cr_init}, |
| 1598 | {miim_end,} |
| 1599 | }, |
| 1600 | (struct phy_cmd[]) { /* startup */ |
| 1601 | /* Read the Status (2x to make sure link is right) */ |
| 1602 | {MIIM_STATUS, miim_read, NULL}, |
| 1603 | /* Auto-negotiate */ |
| 1604 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1605 | /* Read the status */ |
| 1606 | {MIIM_VSC8244_AUX_CONSTAT, miim_read, &mii_parse_vsc8244}, |
| 1607 | {miim_end,} |
| 1608 | }, |
| 1609 | (struct phy_cmd[]) { /* shutdown */ |
| 1610 | {miim_end,} |
| 1611 | }, |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 1612 | }; |
| 1613 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1614 | static struct phy_info phy_info_dm9161 = { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1615 | 0x0181b88, |
| 1616 | "Davicom DM9161E", |
| 1617 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1618 | (struct phy_cmd[]) { /* config */ |
| 1619 | {MIIM_CONTROL, MIIM_DM9161_CR_STOP, NULL}, |
| 1620 | /* Do not bypass the scrambler/descrambler */ |
| 1621 | {MIIM_DM9161_SCR, MIIM_DM9161_SCR_INIT, NULL}, |
| 1622 | /* Clear 10BTCSR to default */ |
| 1623 | {MIIM_DM9161_10BTCSR, MIIM_DM9161_10BTCSR_INIT, NULL}, |
| 1624 | /* Configure some basic stuff */ |
| 1625 | {MIIM_CONTROL, MIIM_CR_INIT, NULL}, |
| 1626 | /* Restart Auto Negotiation */ |
| 1627 | {MIIM_CONTROL, MIIM_DM9161_CR_RSTAN, NULL}, |
| 1628 | {miim_end,} |
| 1629 | }, |
| 1630 | (struct phy_cmd[]) { /* startup */ |
| 1631 | /* Status is read once to clear old link state */ |
| 1632 | {MIIM_STATUS, miim_read, NULL}, |
| 1633 | /* Auto-negotiate */ |
| 1634 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1635 | /* Read the status */ |
| 1636 | {MIIM_DM9161_SCSR, miim_read, &mii_parse_dm9161_scsr}, |
| 1637 | {miim_end,} |
| 1638 | }, |
| 1639 | (struct phy_cmd[]) { /* shutdown */ |
| 1640 | {miim_end,} |
| 1641 | }, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1642 | }; |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1643 | |
Heiko Schocher | 6d9933f | 2010-07-05 12:23:04 +0200 | [diff] [blame] | 1644 | /* micrel KSZ804 */ |
| 1645 | static struct phy_info phy_info_ksz804 = { |
| 1646 | 0x0022151, |
| 1647 | "Micrel KSZ804 PHY", |
| 1648 | 4, |
| 1649 | (struct phy_cmd[]) { /* config */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 1650 | {MII_BMCR, BMCR_RESET, NULL}, |
| 1651 | {MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART, NULL}, |
Heiko Schocher | 6d9933f | 2010-07-05 12:23:04 +0200 | [diff] [blame] | 1652 | {miim_end,} |
| 1653 | }, |
| 1654 | (struct phy_cmd[]) { /* startup */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 1655 | {MII_BMSR, miim_read, NULL}, |
| 1656 | {MII_BMSR, miim_read, &mii_parse_sr}, |
| 1657 | {MII_BMSR, miim_read, &mii_parse_link}, |
Heiko Schocher | 6d9933f | 2010-07-05 12:23:04 +0200 | [diff] [blame] | 1658 | {miim_end,} |
| 1659 | }, |
| 1660 | (struct phy_cmd[]) { /* shutdown */ |
| 1661 | {miim_end,} |
| 1662 | } |
| 1663 | }; |
| 1664 | |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 1665 | /* a generic flavor. */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1666 | static struct phy_info phy_info_generic = { |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 1667 | 0, |
| 1668 | "Unknown/Generic PHY", |
| 1669 | 32, |
| 1670 | (struct phy_cmd[]) { /* config */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 1671 | {MII_BMCR, BMCR_RESET, NULL}, |
| 1672 | {MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART, NULL}, |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 1673 | {miim_end,} |
| 1674 | }, |
| 1675 | (struct phy_cmd[]) { /* startup */ |
Mike Frysinger | d63ee71 | 2010-12-23 15:40:12 -0500 | [diff] [blame] | 1676 | {MII_BMSR, miim_read, NULL}, |
| 1677 | {MII_BMSR, miim_read, &mii_parse_sr}, |
| 1678 | {MII_BMSR, miim_read, &mii_parse_link}, |
David Updegraff | 0451b01 | 2007-04-20 14:34:48 -0500 | [diff] [blame] | 1679 | {miim_end,} |
| 1680 | }, |
| 1681 | (struct phy_cmd[]) { /* shutdown */ |
| 1682 | {miim_end,} |
| 1683 | } |
| 1684 | }; |
| 1685 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1686 | static uint mii_parse_lxt971_sr2(uint mii_reg, struct tsec_private *priv) |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 1687 | { |
wdenk | e085e5b | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 1688 | unsigned int speed; |
| 1689 | if (priv->link) { |
| 1690 | speed = mii_reg & MIIM_LXT971_SR2_SPEED_MASK; |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 1691 | |
wdenk | e085e5b | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 1692 | switch (speed) { |
| 1693 | case MIIM_LXT971_SR2_10HDX: |
| 1694 | priv->speed = 10; |
| 1695 | priv->duplexity = 0; |
| 1696 | break; |
| 1697 | case MIIM_LXT971_SR2_10FDX: |
| 1698 | priv->speed = 10; |
| 1699 | priv->duplexity = 1; |
| 1700 | break; |
| 1701 | case MIIM_LXT971_SR2_100HDX: |
| 1702 | priv->speed = 100; |
| 1703 | priv->duplexity = 0; |
urwithsughosh@gmail.com | 34b3f2e | 2007-09-10 14:54:56 -0400 | [diff] [blame] | 1704 | break; |
wdenk | e085e5b | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 1705 | default: |
| 1706 | priv->speed = 100; |
| 1707 | priv->duplexity = 1; |
wdenk | e085e5b | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 1708 | } |
| 1709 | } else { |
| 1710 | priv->speed = 0; |
| 1711 | priv->duplexity = 0; |
| 1712 | } |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 1713 | |
wdenk | e085e5b | 2005-04-05 23:32:21 +0000 | [diff] [blame] | 1714 | return 0; |
wdenk | f41ff3b | 2005-04-04 23:43:44 +0000 | [diff] [blame] | 1715 | } |
| 1716 | |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1717 | static struct phy_info phy_info_lxt971 = { |
| 1718 | 0x0001378e, |
| 1719 | "LXT971", |
| 1720 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1721 | (struct phy_cmd[]) { /* config */ |
| 1722 | {MIIM_CR, MIIM_CR_INIT, mii_cr_init}, /* autonegotiate */ |
| 1723 | {miim_end,} |
| 1724 | }, |
| 1725 | (struct phy_cmd[]) { /* startup - enable interrupts */ |
| 1726 | /* { 0x12, 0x00f2, NULL }, */ |
| 1727 | {MIIM_STATUS, miim_read, NULL}, |
| 1728 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1729 | {MIIM_LXT971_SR2, miim_read, &mii_parse_lxt971_sr2}, |
| 1730 | {miim_end,} |
| 1731 | }, |
| 1732 | (struct phy_cmd[]) { /* shutdown - disable interrupts */ |
| 1733 | {miim_end,} |
| 1734 | }, |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1735 | }; |
| 1736 | |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 1737 | /* Parse the DP83865's link and auto-neg status register for speed and duplex |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1738 | * information |
| 1739 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1740 | static uint mii_parse_dp83865_lanr(uint mii_reg, struct tsec_private *priv) |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 1741 | { |
| 1742 | switch (mii_reg & MIIM_DP83865_SPD_MASK) { |
| 1743 | |
| 1744 | case MIIM_DP83865_SPD_1000: |
| 1745 | priv->speed = 1000; |
| 1746 | break; |
| 1747 | |
| 1748 | case MIIM_DP83865_SPD_100: |
| 1749 | priv->speed = 100; |
| 1750 | break; |
| 1751 | |
| 1752 | default: |
| 1753 | priv->speed = 10; |
| 1754 | break; |
| 1755 | |
| 1756 | } |
| 1757 | |
| 1758 | if (mii_reg & MIIM_DP83865_DPX_FULL) |
| 1759 | priv->duplexity = 1; |
| 1760 | else |
| 1761 | priv->duplexity = 0; |
| 1762 | |
| 1763 | return 0; |
| 1764 | } |
| 1765 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1766 | static struct phy_info phy_info_dp83865 = { |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 1767 | 0x20005c7, |
| 1768 | "NatSemi DP83865", |
| 1769 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1770 | (struct phy_cmd[]) { /* config */ |
| 1771 | {MIIM_CONTROL, MIIM_DP83865_CR_INIT, NULL}, |
| 1772 | {miim_end,} |
| 1773 | }, |
| 1774 | (struct phy_cmd[]) { /* startup */ |
| 1775 | /* Status is read once to clear old link state */ |
| 1776 | {MIIM_STATUS, miim_read, NULL}, |
| 1777 | /* Auto-negotiate */ |
| 1778 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1779 | /* Read the link and auto-neg status */ |
| 1780 | {MIIM_DP83865_LANR, miim_read, &mii_parse_dp83865_lanr}, |
| 1781 | {miim_end,} |
| 1782 | }, |
| 1783 | (struct phy_cmd[]) { /* shutdown */ |
| 1784 | {miim_end,} |
| 1785 | }, |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 1786 | }; |
| 1787 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1788 | static struct phy_info phy_info_rtl8211b = { |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 1789 | 0x001cc91, |
| 1790 | "RealTek RTL8211B", |
| 1791 | 4, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1792 | (struct phy_cmd[]) { /* config */ |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 1793 | /* Reset and configure the PHY */ |
| 1794 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1795 | {MIIM_GBIT_CONTROL, MIIM_GBIT_CONTROL_INIT, NULL}, |
| 1796 | {MIIM_ANAR, MIIM_ANAR_INIT, NULL}, |
| 1797 | {MIIM_CONTROL, MIIM_CONTROL_RESET, NULL}, |
| 1798 | {MIIM_CONTROL, MIIM_CONTROL_INIT, &mii_cr_init}, |
| 1799 | {miim_end,} |
| 1800 | }, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1801 | (struct phy_cmd[]) { /* startup */ |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 1802 | /* Status is read once to clear old link state */ |
| 1803 | {MIIM_STATUS, miim_read, NULL}, |
| 1804 | /* Auto-negotiate */ |
| 1805 | {MIIM_STATUS, miim_read, &mii_parse_sr}, |
| 1806 | /* Read the status */ |
| 1807 | {MIIM_RTL8211B_PHY_STATUS, miim_read, &mii_parse_RTL8211B_sr}, |
| 1808 | {miim_end,} |
| 1809 | }, |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1810 | (struct phy_cmd[]) { /* shutdown */ |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 1811 | {miim_end,} |
| 1812 | }, |
| 1813 | }; |
| 1814 | |
Li Yang | 25e38bd | 2011-01-27 19:02:50 +0800 | [diff] [blame] | 1815 | struct phy_info phy_info_AR8021 = { |
| 1816 | 0x4dd04, |
| 1817 | "AR8021", |
| 1818 | 4, |
| 1819 | (struct phy_cmd[]) { /* config */ |
| 1820 | {MII_BMCR, BMCR_RESET, NULL}, |
| 1821 | {MII_BMCR, BMCR_ANENABLE|BMCR_ANRESTART, NULL}, |
| 1822 | {0x1d, 0x05, NULL}, |
| 1823 | {0x1e, 0x3D47, NULL}, |
| 1824 | {miim_end,} |
| 1825 | }, |
| 1826 | (struct phy_cmd[]) { /* startup */ |
| 1827 | {MII_BMSR, miim_read, NULL}, |
| 1828 | {MII_BMSR, miim_read, &mii_parse_sr}, |
| 1829 | {MII_BMSR, miim_read, &mii_parse_link}, |
| 1830 | {miim_end,} |
| 1831 | }, |
| 1832 | (struct phy_cmd[]) { /* shutdown */ |
| 1833 | {miim_end,} |
| 1834 | } |
| 1835 | }; |
| 1836 | |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1837 | static struct phy_info *phy_info[] = { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1838 | &phy_info_cis8204, |
Timur Tabi | 054838e | 2006-10-31 18:44:42 -0600 | [diff] [blame] | 1839 | &phy_info_cis8201, |
Paul Gortmaker | 2bd9f1b | 2007-01-16 11:38:14 -0500 | [diff] [blame] | 1840 | &phy_info_BCM5461S, |
Joe Hamman | ed7ad4e | 2007-04-30 16:47:28 -0500 | [diff] [blame] | 1841 | &phy_info_BCM5464S, |
Zach LeRoy | ddb7fc7 | 2009-05-22 10:26:33 -0500 | [diff] [blame] | 1842 | &phy_info_BCM5482S, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1843 | &phy_info_M88E1011S, |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1844 | &phy_info_M88E1111S, |
Ron Madrid | c1e2b58 | 2008-05-23 15:37:05 -0700 | [diff] [blame] | 1845 | &phy_info_M88E1118, |
Sergei Poselenov | 7d4a2c3 | 2008-06-06 15:52:44 +0200 | [diff] [blame] | 1846 | &phy_info_M88E1121R, |
Andy Fleming | 239e75f | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 1847 | &phy_info_M88E1145, |
Wolfgang Denk | 15e8757 | 2007-08-06 01:01:49 +0200 | [diff] [blame] | 1848 | &phy_info_M88E1149S, |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1849 | &phy_info_dm9161, |
Heiko Schocher | 6d9933f | 2010-07-05 12:23:04 +0200 | [diff] [blame] | 1850 | &phy_info_ksz804, |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1851 | &phy_info_lxt971, |
Pieter Henning | 9370c8b | 2009-02-22 23:17:15 -0800 | [diff] [blame] | 1852 | &phy_info_VSC8211, |
Jon Loeliger | 5c8aa97 | 2006-04-26 17:58:56 -0500 | [diff] [blame] | 1853 | &phy_info_VSC8244, |
Tor Krill | 8b3a82f | 2008-03-28 15:29:45 +0100 | [diff] [blame] | 1854 | &phy_info_VSC8601, |
Poonam Aggrwal | c91b5de | 2009-07-02 16:15:13 +0530 | [diff] [blame] | 1855 | &phy_info_VSC8641, |
| 1856 | &phy_info_VSC8221, |
Wolfgang Denk | f0c4e46 | 2006-03-12 22:50:55 +0100 | [diff] [blame] | 1857 | &phy_info_dp83865, |
Dave Liu | a304a28 | 2008-01-11 18:45:28 +0800 | [diff] [blame] | 1858 | &phy_info_rtl8211b, |
Li Yang | 25e38bd | 2011-01-27 19:02:50 +0800 | [diff] [blame] | 1859 | &phy_info_AR8021, |
Paul Gortmaker | f81b823 | 2009-03-09 18:07:53 -0500 | [diff] [blame] | 1860 | &phy_info_generic, /* must be last; has ID 0 and 32 bit mask */ |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1861 | NULL |
| 1862 | }; |
| 1863 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1864 | /* Grab the identifier of the device's PHY, and search through |
wdenk | bfad55d | 2005-03-14 23:56:42 +0000 | [diff] [blame] | 1865 | * all of the known PHYs to see if one matches. If so, return |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1866 | * it, if not, return NULL |
| 1867 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1868 | static struct phy_info *get_phy_info(struct eth_device *dev) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1869 | { |
| 1870 | struct tsec_private *priv = (struct tsec_private *)dev->priv; |
| 1871 | uint phy_reg, phy_ID; |
| 1872 | int i; |
| 1873 | struct phy_info *theInfo = NULL; |
| 1874 | |
| 1875 | /* Grab the bits from PHYIR1, and put them in the upper half */ |
| 1876 | phy_reg = read_phy_reg(priv, MIIM_PHYIR1); |
| 1877 | phy_ID = (phy_reg & 0xffff) << 16; |
| 1878 | |
| 1879 | /* Grab the bits from PHYIR2, and put them in the lower half */ |
| 1880 | phy_reg = read_phy_reg(priv, MIIM_PHYIR2); |
| 1881 | phy_ID |= (phy_reg & 0xffff); |
| 1882 | |
| 1883 | /* loop through all the known PHY types, and find one that */ |
| 1884 | /* matches the ID we read from the PHY. */ |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1885 | for (i = 0; phy_info[i]; i++) { |
Andy Fleming | b2d14f4 | 2007-05-09 00:54:20 -0500 | [diff] [blame] | 1886 | if (phy_info[i]->id == (phy_ID >> phy_info[i]->shift)) { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1887 | theInfo = phy_info[i]; |
Andy Fleming | b2d14f4 | 2007-05-09 00:54:20 -0500 | [diff] [blame] | 1888 | break; |
| 1889 | } |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1890 | } |
| 1891 | |
Paul Gortmaker | f81b823 | 2009-03-09 18:07:53 -0500 | [diff] [blame] | 1892 | if (theInfo == &phy_info_generic) { |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 1893 | printf("%s: No support for PHY id %x; assuming generic\n", |
| 1894 | dev->name, phy_ID); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1895 | } else { |
Stefan Roese | c0dc34f | 2005-09-21 18:20:22 +0200 | [diff] [blame] | 1896 | debug("%s: PHY is %s (%x)\n", dev->name, theInfo->name, phy_ID); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1897 | } |
| 1898 | |
| 1899 | return theInfo; |
| 1900 | } |
| 1901 | |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1902 | /* Execute the given series of commands on the given device's |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1903 | * PHY, running functions as necessary |
| 1904 | */ |
Peter Tyser | 08b2d78 | 2009-11-09 13:09:45 -0600 | [diff] [blame] | 1905 | static void phy_run_commands(struct tsec_private *priv, struct phy_cmd *cmd) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1906 | { |
| 1907 | int i; |
| 1908 | uint result; |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1909 | tsec_mdio_t *phyregs = priv->phyregs; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1910 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1911 | out_be32(&phyregs->miimcfg, MIIMCFG_RESET); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1912 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1913 | out_be32(&phyregs->miimcfg, MIIMCFG_INIT_VALUE); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1914 | |
Mingkai Hu | a65e610 | 2011-01-27 12:52:45 +0800 | [diff] [blame^] | 1915 | while (in_be32(&phyregs->miimind) & MIIMIND_BUSY) |
| 1916 | ; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1917 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1918 | for (i = 0; cmd->mii_reg != miim_end; i++) { |
| 1919 | if (cmd->mii_data == miim_read) { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1920 | result = read_phy_reg(priv, cmd->mii_reg); |
| 1921 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1922 | if (cmd->funct != NULL) |
| 1923 | (*(cmd->funct)) (result, priv); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1924 | |
| 1925 | } else { |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1926 | if (cmd->funct != NULL) |
| 1927 | result = (*(cmd->funct)) (cmd->mii_reg, priv); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1928 | else |
| 1929 | result = cmd->mii_data; |
| 1930 | |
| 1931 | write_phy_reg(priv, cmd->mii_reg, result); |
| 1932 | |
| 1933 | } |
| 1934 | cmd++; |
| 1935 | } |
| 1936 | } |
| 1937 | |
Jon Loeliger | 82ecaad | 2007-07-09 17:39:42 -0500 | [diff] [blame] | 1938 | #if defined(CONFIG_MII) || defined(CONFIG_CMD_MII) \ |
Marian Balakowicz | aab8c49 | 2005-10-28 22:30:33 +0200 | [diff] [blame] | 1939 | && !defined(BITBANGMII) |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1940 | |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1941 | /* |
| 1942 | * Read a MII PHY register. |
| 1943 | * |
| 1944 | * Returns: |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1945 | * 0 on success |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1946 | */ |
Mike Frysinger | 5ff5fdb | 2010-07-27 18:35:08 -0400 | [diff] [blame] | 1947 | static int tsec_miiphy_read(const char *devname, unsigned char addr, |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1948 | unsigned char reg, unsigned short *value) |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1949 | { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1950 | unsigned short ret; |
michael.firth@bt.com | 0838484 | 2008-01-16 11:40:51 +0000 | [diff] [blame] | 1951 | struct tsec_private *priv = privlist[0]; |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1952 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1953 | if (NULL == priv) { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1954 | printf("Can't read PHY at address %d\n", addr); |
| 1955 | return -1; |
| 1956 | } |
| 1957 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 1958 | ret = (unsigned short)tsec_local_mdio_read(priv->phyregs, addr, reg); |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1959 | *value = ret; |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1960 | |
| 1961 | return 0; |
| 1962 | } |
| 1963 | |
| 1964 | /* |
| 1965 | * Write a MII PHY register. |
| 1966 | * |
| 1967 | * Returns: |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1968 | * 0 on success |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1969 | */ |
Mike Frysinger | 5ff5fdb | 2010-07-27 18:35:08 -0400 | [diff] [blame] | 1970 | static int tsec_miiphy_write(const char *devname, unsigned char addr, |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1971 | unsigned char reg, unsigned short value) |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1972 | { |
michael.firth@bt.com | 0838484 | 2008-01-16 11:40:51 +0000 | [diff] [blame] | 1973 | struct tsec_private *priv = privlist[0]; |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1974 | |
Jon Loeliger | b7ced08 | 2006-10-10 17:03:43 -0500 | [diff] [blame] | 1975 | if (NULL == priv) { |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1976 | printf("Can't write PHY at address %d\n", addr); |
| 1977 | return -1; |
| 1978 | } |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1979 | |
Andy Fleming | ac65e07 | 2008-08-31 16:33:27 -0500 | [diff] [blame] | 1980 | tsec_local_mdio_write(priv->phyregs, addr, reg, value); |
wdenk | 78924a7 | 2004-04-18 21:45:42 +0000 | [diff] [blame] | 1981 | |
| 1982 | return 0; |
wdenk | 9c53f40 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1983 | } |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1984 | |
Jon Loeliger | 82ecaad | 2007-07-09 17:39:42 -0500 | [diff] [blame] | 1985 | #endif |
wdenk | a445ddf | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 1986 | |
David Updegraff | 7280da7 | 2007-06-11 10:41:07 -0500 | [diff] [blame] | 1987 | #ifdef CONFIG_MCAST_TFTP |
| 1988 | |
| 1989 | /* CREDITS: linux gianfar driver, slightly adjusted... thanx. */ |
| 1990 | |
| 1991 | /* Set the appropriate hash bit for the given addr */ |
| 1992 | |
| 1993 | /* The algorithm works like so: |
| 1994 | * 1) Take the Destination Address (ie the multicast address), and |
| 1995 | * do a CRC on it (little endian), and reverse the bits of the |
| 1996 | * result. |
| 1997 | * 2) Use the 8 most significant bits as a hash into a 256-entry |
| 1998 | * table. The table is controlled through 8 32-bit registers: |
| 1999 | * gaddr0-7. gaddr0's MSB is entry 0, and gaddr7's LSB is |
| 2000 | * gaddr7. This means that the 3 most significant bits in the |
| 2001 | * hash index which gaddr register to use, and the 5 other bits |
| 2002 | * indicate which bit (assuming an IBM numbering scheme, which |
| 2003 | * for PowerPC (tm) is usually the case) in the tregister holds |
| 2004 | * the entry. */ |
| 2005 | static int |
| 2006 | tsec_mcast_addr (struct eth_device *dev, u8 mcast_mac, u8 set) |
| 2007 | { |
Peter Tyser | 4ef03c0 | 2009-11-09 13:09:46 -0600 | [diff] [blame] | 2008 | struct tsec_private *priv = privlist[1]; |
| 2009 | volatile tsec_t *regs = priv->regs; |
| 2010 | volatile u32 *reg_array, value; |
| 2011 | u8 result, whichbit, whichreg; |
David Updegraff | 7280da7 | 2007-06-11 10:41:07 -0500 | [diff] [blame] | 2012 | |
| 2013 | result = (u8)((ether_crc(MAC_ADDR_LEN,mcast_mac) >> 24) & 0xff); |
| 2014 | whichbit = result & 0x1f; /* the 5 LSB = which bit to set */ |
| 2015 | whichreg = result >> 5; /* the 3 MSB = which reg to set it in */ |
| 2016 | value = (1 << (31-whichbit)); |
| 2017 | |
| 2018 | reg_array = &(regs->hash.gaddr0); |
| 2019 | |
| 2020 | if (set) { |
| 2021 | reg_array[whichreg] |= value; |
| 2022 | } else { |
| 2023 | reg_array[whichreg] &= ~value; |
| 2024 | } |
| 2025 | return 0; |
| 2026 | } |
| 2027 | #endif /* Multicast TFTP ? */ |