Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2009 |
| 3 | * Marvell Semiconductor <www.marvell.com> |
| 4 | * Written-by: Prafulla Wadaskar <prafulla@marvell.com> |
| 5 | * |
| 6 | * (C) Copyright 2003 |
| 7 | * Ingo Assmus <ingo.assmus@keymile.com> |
| 8 | * |
| 9 | * based on - Driver for MV64360X ethernet ports |
| 10 | * Copyright (C) 2002 rabeeh@galileo.co.il |
| 11 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 12 | * SPDX-License-Identifier: GPL-2.0+ |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #include <common.h> |
| 16 | #include <net.h> |
| 17 | #include <malloc.h> |
| 18 | #include <miiphy.h> |
Lei Wen | a7efd71 | 2011-10-18 20:11:42 +0530 | [diff] [blame] | 19 | #include <asm/io.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 20 | #include <linux/errno.h> |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 21 | #include <asm/types.h> |
Lei Wen | a7efd71 | 2011-10-18 20:11:42 +0530 | [diff] [blame] | 22 | #include <asm/system.h> |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 23 | #include <asm/byteorder.h> |
Anatolij Gustschin | 36aaa91 | 2011-10-29 10:09:22 +0000 | [diff] [blame] | 24 | #include <asm/arch/cpu.h> |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 25 | |
| 26 | #if defined(CONFIG_KIRKWOOD) |
Stefan Roese | 3dc23f7 | 2014-10-22 12:13:06 +0200 | [diff] [blame] | 27 | #include <asm/arch/soc.h> |
Albert Aribaud | d3c9ffd | 2010-07-12 22:24:29 +0200 | [diff] [blame] | 28 | #elif defined(CONFIG_ORION5X) |
| 29 | #include <asm/arch/orion5x.h> |
Sebastian Hesselbarth | fb4879b | 2012-12-04 09:32:01 +0100 | [diff] [blame] | 30 | #elif defined(CONFIG_DOVE) |
| 31 | #include <asm/arch/dove.h> |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 32 | #endif |
| 33 | |
Albert Aribaud | 9b6bcdc | 2010-07-12 22:24:27 +0200 | [diff] [blame] | 34 | #include "mvgbe.h" |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 35 | |
Albert Aribaud | 49fa6ed | 2010-07-05 20:15:25 +0200 | [diff] [blame] | 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Luka Perkov | 5aa2297 | 2013-11-11 07:27:53 +0100 | [diff] [blame] | 38 | #ifndef CONFIG_MVGBE_PORTS |
| 39 | # define CONFIG_MVGBE_PORTS {0, 0} |
| 40 | #endif |
| 41 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 42 | #define MV_PHY_ADR_REQUEST 0xee |
| 43 | #define MVGBE_SMI_REG (((struct mvgbe_registers *)MVGBE0_BASE)->smi) |
Simon Kagstrom | bb1ca3b | 2009-08-20 10:12:28 +0200 | [diff] [blame] | 44 | |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 45 | #if defined(CONFIG_PHYLIB) || defined(CONFIG_MII) || defined(CONFIG_CMD_MII) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 46 | /* |
| 47 | * smi_reg_read - miiphy_read callback function. |
| 48 | * |
| 49 | * Returns 16bit phy register value, or 0xffff on error |
| 50 | */ |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 51 | static int smi_reg_read(struct mii_dev *bus, int phy_adr, int devad, |
| 52 | int reg_ofs) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 53 | { |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 54 | u16 data = 0; |
| 55 | struct eth_device *dev = eth_get_dev_by_name(bus->name); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 56 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 57 | struct mvgbe_registers *regs = dmvgbe->regs; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 58 | u32 smi_reg; |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 59 | u32 timeout; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 60 | |
| 61 | /* Phyadr read request */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 62 | if (phy_adr == MV_PHY_ADR_REQUEST && |
| 63 | reg_ofs == MV_PHY_ADR_REQUEST) { |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 64 | /* */ |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 65 | data = (u16) (MVGBE_REG_RD(regs->phyadr) & PHYADR_MASK); |
| 66 | return data; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 67 | } |
| 68 | /* check parameters */ |
| 69 | if (phy_adr > PHYADR_MASK) { |
| 70 | printf("Err..(%s) Invalid PHY address %d\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 71 | __func__, phy_adr); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 72 | return -EFAULT; |
| 73 | } |
| 74 | if (reg_ofs > PHYREG_MASK) { |
| 75 | printf("Err..(%s) Invalid register offset %d\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 76 | __func__, reg_ofs); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 77 | return -EFAULT; |
| 78 | } |
| 79 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 80 | timeout = MVGBE_PHY_SMI_TIMEOUT; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 81 | /* wait till the SMI is not busy */ |
| 82 | do { |
| 83 | /* read smi register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 84 | smi_reg = MVGBE_REG_RD(MVGBE_SMI_REG); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 85 | if (timeout-- == 0) { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 86 | printf("Err..(%s) SMI busy timeout\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 87 | return -EFAULT; |
| 88 | } |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 89 | } while (smi_reg & MVGBE_PHY_SMI_BUSY_MASK); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 90 | |
| 91 | /* fill the phy address and regiser offset and read opcode */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 92 | smi_reg = (phy_adr << MVGBE_PHY_SMI_DEV_ADDR_OFFS) |
| 93 | | (reg_ofs << MVGBE_SMI_REG_ADDR_OFFS) |
| 94 | | MVGBE_PHY_SMI_OPCODE_READ; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 95 | |
| 96 | /* write the smi register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 97 | MVGBE_REG_WR(MVGBE_SMI_REG, smi_reg); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 98 | |
| 99 | /*wait till read value is ready */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 100 | timeout = MVGBE_PHY_SMI_TIMEOUT; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 101 | |
| 102 | do { |
| 103 | /* read smi register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 104 | smi_reg = MVGBE_REG_RD(MVGBE_SMI_REG); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 105 | if (timeout-- == 0) { |
| 106 | printf("Err..(%s) SMI read ready timeout\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 107 | __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 108 | return -EFAULT; |
| 109 | } |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 110 | } while (!(smi_reg & MVGBE_PHY_SMI_READ_VALID_MASK)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 111 | |
| 112 | /* Wait for the data to update in the SMI register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 113 | for (timeout = 0; timeout < MVGBE_PHY_SMI_TIMEOUT; timeout++) |
| 114 | ; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 115 | |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 116 | data = (u16) (MVGBE_REG_RD(MVGBE_SMI_REG) & MVGBE_PHY_SMI_DATA_MASK); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 117 | |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 118 | debug("%s:(adr %d, off %d) value= %04x\n", __func__, phy_adr, reg_ofs, |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 119 | data); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 120 | |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 121 | return data; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /* |
| 125 | * smi_reg_write - imiiphy_write callback function. |
| 126 | * |
| 127 | * Returns 0 if write succeed, -EINVAL on bad parameters |
| 128 | * -ETIME on timeout |
| 129 | */ |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 130 | static int smi_reg_write(struct mii_dev *bus, int phy_adr, int devad, |
| 131 | int reg_ofs, u16 data) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 132 | { |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 133 | struct eth_device *dev = eth_get_dev_by_name(bus->name); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 134 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 135 | struct mvgbe_registers *regs = dmvgbe->regs; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 136 | u32 smi_reg; |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 137 | u32 timeout; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 138 | |
| 139 | /* Phyadr write request*/ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 140 | if (phy_adr == MV_PHY_ADR_REQUEST && |
| 141 | reg_ofs == MV_PHY_ADR_REQUEST) { |
| 142 | MVGBE_REG_WR(regs->phyadr, data); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | /* check parameters */ |
| 147 | if (phy_adr > PHYADR_MASK) { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 148 | printf("Err..(%s) Invalid phy address\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 149 | return -EINVAL; |
| 150 | } |
| 151 | if (reg_ofs > PHYREG_MASK) { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 152 | printf("Err..(%s) Invalid register offset\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 153 | return -EINVAL; |
| 154 | } |
| 155 | |
| 156 | /* wait till the SMI is not busy */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 157 | timeout = MVGBE_PHY_SMI_TIMEOUT; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 158 | do { |
| 159 | /* read smi register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 160 | smi_reg = MVGBE_REG_RD(MVGBE_SMI_REG); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 161 | if (timeout-- == 0) { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 162 | printf("Err..(%s) SMI busy timeout\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 163 | return -ETIME; |
| 164 | } |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 165 | } while (smi_reg & MVGBE_PHY_SMI_BUSY_MASK); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 166 | |
| 167 | /* fill the phy addr and reg offset and write opcode and data */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 168 | smi_reg = (data << MVGBE_PHY_SMI_DATA_OFFS); |
| 169 | smi_reg |= (phy_adr << MVGBE_PHY_SMI_DEV_ADDR_OFFS) |
| 170 | | (reg_ofs << MVGBE_SMI_REG_ADDR_OFFS); |
| 171 | smi_reg &= ~MVGBE_PHY_SMI_OPCODE_READ; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 172 | |
| 173 | /* write the smi register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 174 | MVGBE_REG_WR(MVGBE_SMI_REG, smi_reg); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 175 | |
| 176 | return 0; |
| 177 | } |
Stefan Bigler | cc79697 | 2012-03-26 00:02:13 +0000 | [diff] [blame] | 178 | #endif |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 179 | |
| 180 | /* Stop and checks all queues */ |
| 181 | static void stop_queue(u32 * qreg) |
| 182 | { |
| 183 | u32 reg_data; |
| 184 | |
| 185 | reg_data = readl(qreg); |
| 186 | |
| 187 | if (reg_data & 0xFF) { |
| 188 | /* Issue stop command for active channels only */ |
| 189 | writel((reg_data << 8), qreg); |
| 190 | |
| 191 | /* Wait for all queue activity to terminate. */ |
| 192 | do { |
| 193 | /* |
| 194 | * Check port cause register that all queues |
| 195 | * are stopped |
| 196 | */ |
| 197 | reg_data = readl(qreg); |
| 198 | } |
| 199 | while (reg_data & 0xFF); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | /* |
| 204 | * set_access_control - Config address decode parameters for Ethernet unit |
| 205 | * |
| 206 | * This function configures the address decode parameters for the Gigabit |
| 207 | * Ethernet Controller according the given parameters struct. |
| 208 | * |
| 209 | * @regs Register struct pointer. |
| 210 | * @param Address decode parameter struct. |
| 211 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 212 | static void set_access_control(struct mvgbe_registers *regs, |
| 213 | struct mvgbe_winparam *param) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 214 | { |
| 215 | u32 access_prot_reg; |
| 216 | |
| 217 | /* Set access control register */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 218 | access_prot_reg = MVGBE_REG_RD(regs->epap); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 219 | /* clear window permission */ |
| 220 | access_prot_reg &= (~(3 << (param->win * 2))); |
| 221 | access_prot_reg |= (param->access_ctrl << (param->win * 2)); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 222 | MVGBE_REG_WR(regs->epap, access_prot_reg); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 223 | |
| 224 | /* Set window Size reg (SR) */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 225 | MVGBE_REG_WR(regs->barsz[param->win].size, |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 226 | (((param->size / 0x10000) - 1) << 16)); |
| 227 | |
| 228 | /* Set window Base address reg (BA) */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 229 | MVGBE_REG_WR(regs->barsz[param->win].bar, |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 230 | (param->target | param->attrib | param->base_addr)); |
| 231 | /* High address remap reg (HARR) */ |
| 232 | if (param->win < 4) |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 233 | MVGBE_REG_WR(regs->ha_remap[param->win], param->high_addr); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 234 | |
| 235 | /* Base address enable reg (BARER) */ |
| 236 | if (param->enable == 1) |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 237 | MVGBE_REG_BITS_RESET(regs->bare, (1 << param->win)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 238 | else |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 239 | MVGBE_REG_BITS_SET(regs->bare, (1 << param->win)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 240 | } |
| 241 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 242 | static void set_dram_access(struct mvgbe_registers *regs) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 243 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 244 | struct mvgbe_winparam win_param; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 245 | int i; |
| 246 | |
| 247 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 248 | /* Set access parameters for DRAM bank i */ |
| 249 | win_param.win = i; /* Use Ethernet window i */ |
| 250 | /* Window target - DDR */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 251 | win_param.target = MVGBE_TARGET_DRAM; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 252 | /* Enable full access */ |
| 253 | win_param.access_ctrl = EWIN_ACCESS_FULL; |
| 254 | win_param.high_addr = 0; |
Albert Aribaud | 49fa6ed | 2010-07-05 20:15:25 +0200 | [diff] [blame] | 255 | /* Get bank base and size */ |
| 256 | win_param.base_addr = gd->bd->bi_dram[i].start; |
| 257 | win_param.size = gd->bd->bi_dram[i].size; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 258 | if (win_param.size == 0) |
| 259 | win_param.enable = 0; |
| 260 | else |
| 261 | win_param.enable = 1; /* Enable the access */ |
| 262 | |
| 263 | /* Enable DRAM bank */ |
| 264 | switch (i) { |
| 265 | case 0: |
| 266 | win_param.attrib = EBAR_DRAM_CS0; |
| 267 | break; |
| 268 | case 1: |
| 269 | win_param.attrib = EBAR_DRAM_CS1; |
| 270 | break; |
| 271 | case 2: |
| 272 | win_param.attrib = EBAR_DRAM_CS2; |
| 273 | break; |
| 274 | case 3: |
| 275 | win_param.attrib = EBAR_DRAM_CS3; |
| 276 | break; |
| 277 | default: |
Albert Aribaud | 49fa6ed | 2010-07-05 20:15:25 +0200 | [diff] [blame] | 278 | /* invalid bank, disable access */ |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 279 | win_param.enable = 0; |
| 280 | win_param.attrib = 0; |
| 281 | break; |
| 282 | } |
| 283 | /* Set the access control for address window(EPAPR) RD/WR */ |
| 284 | set_access_control(regs, &win_param); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | /* |
| 289 | * port_init_mac_tables - Clear all entrance in the UC, SMC and OMC tables |
| 290 | * |
| 291 | * Go through all the DA filter tables (Unicast, Special Multicast & Other |
| 292 | * Multicast) and set each entry to 0. |
| 293 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 294 | static void port_init_mac_tables(struct mvgbe_registers *regs) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 295 | { |
| 296 | int table_index; |
| 297 | |
| 298 | /* Clear DA filter unicast table (Ex_dFUT) */ |
| 299 | for (table_index = 0; table_index < 4; ++table_index) |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 300 | MVGBE_REG_WR(regs->dfut[table_index], 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 301 | |
| 302 | for (table_index = 0; table_index < 64; ++table_index) { |
| 303 | /* Clear DA filter special multicast table (Ex_dFSMT) */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 304 | MVGBE_REG_WR(regs->dfsmt[table_index], 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 305 | /* Clear DA filter other multicast table (Ex_dFOMT) */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 306 | MVGBE_REG_WR(regs->dfomt[table_index], 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | |
| 310 | /* |
| 311 | * port_uc_addr - This function Set the port unicast address table |
| 312 | * |
| 313 | * This function locates the proper entry in the Unicast table for the |
| 314 | * specified MAC nibble and sets its properties according to function |
| 315 | * parameters. |
| 316 | * This function add/removes MAC addresses from the port unicast address |
| 317 | * table. |
| 318 | * |
| 319 | * @uc_nibble Unicast MAC Address last nibble. |
| 320 | * @option 0 = Add, 1 = remove address. |
| 321 | * |
| 322 | * RETURN: 1 if output succeeded. 0 if option parameter is invalid. |
| 323 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 324 | static int port_uc_addr(struct mvgbe_registers *regs, u8 uc_nibble, |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 325 | int option) |
| 326 | { |
| 327 | u32 unicast_reg; |
| 328 | u32 tbl_offset; |
| 329 | u32 reg_offset; |
| 330 | |
| 331 | /* Locate the Unicast table entry */ |
| 332 | uc_nibble = (0xf & uc_nibble); |
| 333 | /* Register offset from unicast table base */ |
| 334 | tbl_offset = (uc_nibble / 4); |
| 335 | /* Entry offset within the above register */ |
| 336 | reg_offset = uc_nibble % 4; |
| 337 | |
| 338 | switch (option) { |
| 339 | case REJECT_MAC_ADDR: |
| 340 | /* |
| 341 | * Clear accepts frame bit at specified unicast |
| 342 | * DA table entry |
| 343 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 344 | unicast_reg = MVGBE_REG_RD(regs->dfut[tbl_offset]); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 345 | unicast_reg &= (0xFF << (8 * reg_offset)); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 346 | MVGBE_REG_WR(regs->dfut[tbl_offset], unicast_reg); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 347 | break; |
| 348 | case ACCEPT_MAC_ADDR: |
| 349 | /* Set accepts frame bit at unicast DA filter table entry */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 350 | unicast_reg = MVGBE_REG_RD(regs->dfut[tbl_offset]); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 351 | unicast_reg &= (0xFF << (8 * reg_offset)); |
| 352 | unicast_reg |= ((0x01 | (RXUQ << 1)) << (8 * reg_offset)); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 353 | MVGBE_REG_WR(regs->dfut[tbl_offset], unicast_reg); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 354 | break; |
| 355 | default: |
| 356 | return 0; |
| 357 | } |
| 358 | return 1; |
| 359 | } |
| 360 | |
| 361 | /* |
| 362 | * port_uc_addr_set - This function Set the port Unicast address. |
| 363 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 364 | static void port_uc_addr_set(struct mvgbe_registers *regs, u8 * p_addr) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 365 | { |
| 366 | u32 mac_h; |
| 367 | u32 mac_l; |
| 368 | |
| 369 | mac_l = (p_addr[4] << 8) | (p_addr[5]); |
| 370 | mac_h = (p_addr[0] << 24) | (p_addr[1] << 16) | (p_addr[2] << 8) | |
| 371 | (p_addr[3] << 0); |
| 372 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 373 | MVGBE_REG_WR(regs->macal, mac_l); |
| 374 | MVGBE_REG_WR(regs->macah, mac_h); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 375 | |
| 376 | /* Accept frames of this address */ |
| 377 | port_uc_addr(regs, p_addr[5], ACCEPT_MAC_ADDR); |
| 378 | } |
| 379 | |
| 380 | /* |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 381 | * mvgbe_init_rx_desc_ring - Curve a Rx chain desc list and buffer in memory. |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 382 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 383 | static void mvgbe_init_rx_desc_ring(struct mvgbe_device *dmvgbe) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 384 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 385 | struct mvgbe_rxdesc *p_rx_desc; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 386 | int i; |
| 387 | |
| 388 | /* initialize the Rx descriptors ring */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 389 | p_rx_desc = dmvgbe->p_rxdesc; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 390 | for (i = 0; i < RINGSZ; i++) { |
| 391 | p_rx_desc->cmd_sts = |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 392 | MVGBE_BUFFER_OWNED_BY_DMA | MVGBE_RX_EN_INTERRUPT; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 393 | p_rx_desc->buf_size = PKTSIZE_ALIGN; |
| 394 | p_rx_desc->byte_cnt = 0; |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 395 | p_rx_desc->buf_ptr = dmvgbe->p_rxbuf + i * PKTSIZE_ALIGN; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 396 | if (i == (RINGSZ - 1)) |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 397 | p_rx_desc->nxtdesc_p = dmvgbe->p_rxdesc; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 398 | else { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 399 | p_rx_desc->nxtdesc_p = (struct mvgbe_rxdesc *) |
| 400 | ((u32) p_rx_desc + MV_RXQ_DESC_ALIGNED_SIZE); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 401 | p_rx_desc = p_rx_desc->nxtdesc_p; |
| 402 | } |
| 403 | } |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 404 | dmvgbe->p_rxdesc_curr = dmvgbe->p_rxdesc; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 405 | } |
| 406 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 407 | static int mvgbe_init(struct eth_device *dev) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 408 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 409 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 410 | struct mvgbe_registers *regs = dmvgbe->regs; |
Sascha Silbe | 0611c60 | 2013-08-11 17:08:23 +0200 | [diff] [blame] | 411 | #if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && \ |
| 412 | !defined(CONFIG_PHYLIB) && \ |
| 413 | defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) |
Simon Kagstrom | cad713b | 2009-08-20 10:13:06 +0200 | [diff] [blame] | 414 | int i; |
Prafulla Wadaskar | aba8237 | 2009-09-09 15:59:19 +0530 | [diff] [blame] | 415 | #endif |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 416 | /* setup RX rings */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 417 | mvgbe_init_rx_desc_ring(dmvgbe); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 418 | |
| 419 | /* Clear the ethernet port interrupts */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 420 | MVGBE_REG_WR(regs->ic, 0); |
| 421 | MVGBE_REG_WR(regs->ice, 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 422 | /* Unmask RX buffer and TX end interrupt */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 423 | MVGBE_REG_WR(regs->pim, INT_CAUSE_UNMASK_ALL); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 424 | /* Unmask phy and link status changes interrupts */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 425 | MVGBE_REG_WR(regs->peim, INT_CAUSE_UNMASK_ALL_EXT); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 426 | |
| 427 | set_dram_access(regs); |
| 428 | port_init_mac_tables(regs); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 429 | port_uc_addr_set(regs, dmvgbe->dev.enetaddr); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 430 | |
| 431 | /* Assign port configuration and command. */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 432 | MVGBE_REG_WR(regs->pxc, PRT_CFG_VAL); |
| 433 | MVGBE_REG_WR(regs->pxcx, PORT_CFG_EXTEND_VALUE); |
| 434 | MVGBE_REG_WR(regs->psc0, PORT_SERIAL_CONTROL_VALUE); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 435 | |
| 436 | /* Assign port SDMA configuration */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 437 | MVGBE_REG_WR(regs->sdc, PORT_SDMA_CFG_VALUE); |
| 438 | MVGBE_REG_WR(regs->tqx[0].qxttbc, QTKNBKT_DEF_VAL); |
| 439 | MVGBE_REG_WR(regs->tqx[0].tqxtbc, |
| 440 | (QMTBS_DEF_VAL << 16) | QTKNRT_DEF_VAL); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 441 | /* Turn off the port/RXUQ bandwidth limitation */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 442 | MVGBE_REG_WR(regs->pmtu, 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 443 | |
| 444 | /* Set maximum receive buffer to 9700 bytes */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 445 | MVGBE_REG_WR(regs->psc0, MVGBE_MAX_RX_PACKET_9700BYTE |
| 446 | | (MVGBE_REG_RD(regs->psc0) & MRU_MASK)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 447 | |
Prafulla Wadaskar | f0588fd | 2010-04-06 21:33:08 +0530 | [diff] [blame] | 448 | /* Enable port initially */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 449 | MVGBE_REG_BITS_SET(regs->psc0, MVGBE_SERIAL_PORT_EN); |
Prafulla Wadaskar | f0588fd | 2010-04-06 21:33:08 +0530 | [diff] [blame] | 450 | |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 451 | /* |
| 452 | * Set ethernet MTU for leaky bucket mechanism to 0 - this will |
| 453 | * disable the leaky bucket mechanism . |
| 454 | */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 455 | MVGBE_REG_WR(regs->pmtu, 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 456 | |
| 457 | /* Assignment of Rx CRDB of given RXUQ */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 458 | MVGBE_REG_WR(regs->rxcdp[RXUQ], (u32) dmvgbe->p_rxdesc_curr); |
Albert Aribaud | c19a20d | 2010-07-10 15:41:29 +0200 | [diff] [blame] | 459 | /* ensure previous write is done before enabling Rx DMA */ |
| 460 | isb(); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 461 | /* Enable port Rx. */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 462 | MVGBE_REG_WR(regs->rqc, (1 << RXUQ)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 463 | |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 464 | #if (defined(CONFIG_MII) || defined(CONFIG_CMD_MII)) && \ |
| 465 | !defined(CONFIG_PHYLIB) && \ |
| 466 | defined(CONFIG_SYS_FAULT_ECHO_LINK_DOWN) |
Simon Kagstrom | cad713b | 2009-08-20 10:13:06 +0200 | [diff] [blame] | 467 | /* Wait up to 5s for the link status */ |
| 468 | for (i = 0; i < 5; i++) { |
| 469 | u16 phyadr; |
| 470 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 471 | miiphy_read(dev->name, MV_PHY_ADR_REQUEST, |
| 472 | MV_PHY_ADR_REQUEST, &phyadr); |
Simon Kagstrom | cad713b | 2009-08-20 10:13:06 +0200 | [diff] [blame] | 473 | /* Return if we get link up */ |
| 474 | if (miiphy_link(dev->name, phyadr)) |
| 475 | return 0; |
| 476 | udelay(1000000); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 477 | } |
Simon Kagstrom | cad713b | 2009-08-20 10:13:06 +0200 | [diff] [blame] | 478 | |
| 479 | printf("No link on %s\n", dev->name); |
| 480 | return -1; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 481 | #endif |
| 482 | return 0; |
| 483 | } |
| 484 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 485 | static int mvgbe_halt(struct eth_device *dev) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 486 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 487 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 488 | struct mvgbe_registers *regs = dmvgbe->regs; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 489 | |
| 490 | /* Disable all gigE address decoder */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 491 | MVGBE_REG_WR(regs->bare, 0x3f); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 492 | |
| 493 | stop_queue(®s->tqc); |
| 494 | stop_queue(®s->rqc); |
| 495 | |
Prafulla Wadaskar | f0588fd | 2010-04-06 21:33:08 +0530 | [diff] [blame] | 496 | /* Disable port */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 497 | MVGBE_REG_BITS_RESET(regs->psc0, MVGBE_SERIAL_PORT_EN); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 498 | /* Set port is not reset */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 499 | MVGBE_REG_BITS_RESET(regs->psc1, 1 << 4); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 500 | #ifdef CONFIG_SYS_MII_MODE |
| 501 | /* Set MMI interface up */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 502 | MVGBE_REG_BITS_RESET(regs->psc1, 1 << 3); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 503 | #endif |
| 504 | /* Disable & mask ethernet port interrupts */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 505 | MVGBE_REG_WR(regs->ic, 0); |
| 506 | MVGBE_REG_WR(regs->ice, 0); |
| 507 | MVGBE_REG_WR(regs->pim, 0); |
| 508 | MVGBE_REG_WR(regs->peim, 0); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 513 | static int mvgbe_write_hwaddr(struct eth_device *dev) |
Prafulla Wadaskar | b5ce63e | 2010-04-06 22:21:33 +0530 | [diff] [blame] | 514 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 515 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 516 | struct mvgbe_registers *regs = dmvgbe->regs; |
Prafulla Wadaskar | b5ce63e | 2010-04-06 22:21:33 +0530 | [diff] [blame] | 517 | |
| 518 | /* Programs net device MAC address after initialization */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 519 | port_uc_addr_set(regs, dmvgbe->dev.enetaddr); |
Prafulla Wadaskar | b5ce63e | 2010-04-06 22:21:33 +0530 | [diff] [blame] | 520 | return 0; |
| 521 | } |
| 522 | |
Joe Hershberger | 10cbe3b | 2012-05-22 18:36:19 +0000 | [diff] [blame] | 523 | static int mvgbe_send(struct eth_device *dev, void *dataptr, int datasize) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 524 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 525 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 526 | struct mvgbe_registers *regs = dmvgbe->regs; |
| 527 | struct mvgbe_txdesc *p_txdesc = dmvgbe->p_txdesc; |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 528 | void *p = (void *)dataptr; |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 529 | u32 cmd_sts; |
Anatolij Gustschin | e6e556c | 2011-11-19 08:59:36 +0000 | [diff] [blame] | 530 | u32 txuq0_reg_addr; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 531 | |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 532 | /* Copy buffer if it's misaligned */ |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 533 | if ((u32) dataptr & 0x07) { |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 534 | if (datasize > PKTSIZE_ALIGN) { |
| 535 | printf("Non-aligned data too large (%d)\n", |
| 536 | datasize); |
| 537 | return -1; |
| 538 | } |
| 539 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 540 | memcpy(dmvgbe->p_aligned_txbuf, p, datasize); |
| 541 | p = dmvgbe->p_aligned_txbuf; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 542 | } |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 543 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 544 | p_txdesc->cmd_sts = MVGBE_ZERO_PADDING | MVGBE_GEN_CRC; |
| 545 | p_txdesc->cmd_sts |= MVGBE_TX_FIRST_DESC | MVGBE_TX_LAST_DESC; |
| 546 | p_txdesc->cmd_sts |= MVGBE_BUFFER_OWNED_BY_DMA; |
| 547 | p_txdesc->cmd_sts |= MVGBE_TX_EN_INTERRUPT; |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 548 | p_txdesc->buf_ptr = (u8 *) p; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 549 | p_txdesc->byte_cnt = datasize; |
| 550 | |
Albert Aribaud | c19a20d | 2010-07-10 15:41:29 +0200 | [diff] [blame] | 551 | /* Set this tc desc as zeroth TXUQ */ |
Anatolij Gustschin | e6e556c | 2011-11-19 08:59:36 +0000 | [diff] [blame] | 552 | txuq0_reg_addr = (u32)®s->tcqdp[TXUQ]; |
| 553 | writel((u32) p_txdesc, txuq0_reg_addr); |
Albert Aribaud | c19a20d | 2010-07-10 15:41:29 +0200 | [diff] [blame] | 554 | |
| 555 | /* ensure tx desc writes above are performed before we start Tx DMA */ |
| 556 | isb(); |
| 557 | |
| 558 | /* Apply send command using zeroth TXUQ */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 559 | MVGBE_REG_WR(regs->tqc, (1 << TXUQ)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 560 | |
| 561 | /* |
| 562 | * wait for packet xmit completion |
| 563 | */ |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 564 | cmd_sts = readl(&p_txdesc->cmd_sts); |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 565 | while (cmd_sts & MVGBE_BUFFER_OWNED_BY_DMA) { |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 566 | /* return fail if error is detected */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 567 | if ((cmd_sts & (MVGBE_ERROR_SUMMARY | MVGBE_TX_LAST_FRAME)) == |
| 568 | (MVGBE_ERROR_SUMMARY | MVGBE_TX_LAST_FRAME) && |
| 569 | cmd_sts & (MVGBE_UR_ERROR | MVGBE_RL_ERROR)) { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 570 | printf("Err..(%s) in xmit packet\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 571 | return -1; |
| 572 | } |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 573 | cmd_sts = readl(&p_txdesc->cmd_sts); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 574 | }; |
| 575 | return 0; |
| 576 | } |
| 577 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 578 | static int mvgbe_recv(struct eth_device *dev) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 579 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 580 | struct mvgbe_device *dmvgbe = to_mvgbe(dev); |
| 581 | struct mvgbe_rxdesc *p_rxdesc_curr = dmvgbe->p_rxdesc_curr; |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 582 | u32 cmd_sts; |
| 583 | u32 timeout = 0; |
Anatolij Gustschin | e6e556c | 2011-11-19 08:59:36 +0000 | [diff] [blame] | 584 | u32 rxdesc_curr_addr; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 585 | |
| 586 | /* wait untill rx packet available or timeout */ |
| 587 | do { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 588 | if (timeout < MVGBE_PHY_SMI_TIMEOUT) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 589 | timeout++; |
| 590 | else { |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 591 | debug("%s time out...\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 592 | return -1; |
| 593 | } |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 594 | } while (readl(&p_rxdesc_curr->cmd_sts) & MVGBE_BUFFER_OWNED_BY_DMA); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 595 | |
| 596 | if (p_rxdesc_curr->byte_cnt != 0) { |
| 597 | debug("%s: Received %d byte Packet @ 0x%x (cmd_sts= %08x)\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 598 | __func__, (u32) p_rxdesc_curr->byte_cnt, |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 599 | (u32) p_rxdesc_curr->buf_ptr, |
| 600 | (u32) p_rxdesc_curr->cmd_sts); |
| 601 | } |
| 602 | |
| 603 | /* |
| 604 | * In case received a packet without first/last bits on |
| 605 | * OR the error summary bit is on, |
| 606 | * the packets needs to be dropeed. |
| 607 | */ |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 608 | cmd_sts = readl(&p_rxdesc_curr->cmd_sts); |
| 609 | |
| 610 | if ((cmd_sts & |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 611 | (MVGBE_RX_FIRST_DESC | MVGBE_RX_LAST_DESC)) |
| 612 | != (MVGBE_RX_FIRST_DESC | MVGBE_RX_LAST_DESC)) { |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 613 | |
| 614 | printf("Err..(%s) Dropping packet spread on" |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 615 | " multiple descriptors\n", __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 616 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 617 | } else if (cmd_sts & MVGBE_ERROR_SUMMARY) { |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 618 | |
| 619 | printf("Err..(%s) Dropping packet with errors\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 620 | __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 621 | |
| 622 | } else { |
| 623 | /* !!! call higher layer processing */ |
| 624 | debug("%s: Sending Received packet to" |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 625 | " upper layer (net_process_received_packet)\n", |
| 626 | __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 627 | |
| 628 | /* let the upper layer handle the packet */ |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 629 | net_process_received_packet((p_rxdesc_curr->buf_ptr + |
| 630 | RX_BUF_OFFSET), |
| 631 | (int)(p_rxdesc_curr->byte_cnt - |
| 632 | RX_BUF_OFFSET)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 633 | } |
| 634 | /* |
| 635 | * free these descriptors and point next in the ring |
| 636 | */ |
| 637 | p_rxdesc_curr->cmd_sts = |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 638 | MVGBE_BUFFER_OWNED_BY_DMA | MVGBE_RX_EN_INTERRUPT; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 639 | p_rxdesc_curr->buf_size = PKTSIZE_ALIGN; |
| 640 | p_rxdesc_curr->byte_cnt = 0; |
| 641 | |
Anatolij Gustschin | e6e556c | 2011-11-19 08:59:36 +0000 | [diff] [blame] | 642 | rxdesc_curr_addr = (u32)&dmvgbe->p_rxdesc_curr; |
| 643 | writel((unsigned)p_rxdesc_curr->nxtdesc_p, rxdesc_curr_addr); |
Simon Kagstrom | 7b05f5e | 2009-07-08 13:03:18 +0200 | [diff] [blame] | 644 | |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 645 | return 0; |
| 646 | } |
| 647 | |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 648 | #if defined(CONFIG_PHYLIB) |
| 649 | int mvgbe_phylib_init(struct eth_device *dev, int phyid) |
| 650 | { |
| 651 | struct mii_dev *bus; |
| 652 | struct phy_device *phydev; |
| 653 | int ret; |
| 654 | |
| 655 | bus = mdio_alloc(); |
| 656 | if (!bus) { |
| 657 | printf("mdio_alloc failed\n"); |
| 658 | return -ENOMEM; |
| 659 | } |
Chris Packham | 6ecf9e2 | 2016-11-01 10:48:32 +1300 | [diff] [blame] | 660 | bus->read = smi_reg_read; |
| 661 | bus->write = smi_reg_write; |
Ben Whitten | 192bc69 | 2015-12-30 13:05:58 +0000 | [diff] [blame] | 662 | strcpy(bus->name, dev->name); |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 663 | |
| 664 | ret = mdio_register(bus); |
| 665 | if (ret) { |
| 666 | printf("mdio_register failed\n"); |
| 667 | free(bus); |
| 668 | return -ENOMEM; |
| 669 | } |
| 670 | |
| 671 | /* Set phy address of the port */ |
Chris Packham | 6ecf9e2 | 2016-11-01 10:48:32 +1300 | [diff] [blame] | 672 | smi_reg_write(bus, MV_PHY_ADR_REQUEST, 0, MV_PHY_ADR_REQUEST, phyid); |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 673 | |
| 674 | phydev = phy_connect(bus, phyid, dev, PHY_INTERFACE_MODE_RGMII); |
| 675 | if (!phydev) { |
| 676 | printf("phy_connect failed\n"); |
| 677 | return -ENODEV; |
| 678 | } |
| 679 | |
| 680 | phy_config(phydev); |
| 681 | phy_startup(phydev); |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | #endif |
| 686 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 687 | int mvgbe_initialize(bd_t *bis) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 688 | { |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 689 | struct mvgbe_device *dmvgbe; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 690 | struct eth_device *dev; |
| 691 | int devnum; |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 692 | u8 used_ports[MAX_MVGBE_DEVS] = CONFIG_MVGBE_PORTS; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 693 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 694 | for (devnum = 0; devnum < MAX_MVGBE_DEVS; devnum++) { |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 695 | /*skip if port is configured not to use */ |
| 696 | if (used_ports[devnum] == 0) |
| 697 | continue; |
| 698 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 699 | dmvgbe = malloc(sizeof(struct mvgbe_device)); |
| 700 | |
| 701 | if (!dmvgbe) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 702 | goto error1; |
| 703 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 704 | memset(dmvgbe, 0, sizeof(struct mvgbe_device)); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 705 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 706 | dmvgbe->p_rxdesc = |
| 707 | (struct mvgbe_rxdesc *)memalign(PKTALIGN, |
| 708 | MV_RXQ_DESC_ALIGNED_SIZE*RINGSZ + 1); |
| 709 | |
| 710 | if (!dmvgbe->p_rxdesc) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 711 | goto error2; |
| 712 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 713 | dmvgbe->p_rxbuf = (u8 *) memalign(PKTALIGN, |
| 714 | RINGSZ*PKTSIZE_ALIGN + 1); |
| 715 | |
| 716 | if (!dmvgbe->p_rxbuf) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 717 | goto error3; |
| 718 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 719 | dmvgbe->p_aligned_txbuf = memalign(8, PKTSIZE_ALIGN); |
| 720 | |
| 721 | if (!dmvgbe->p_aligned_txbuf) |
Simon Kagstrom | 477fa63 | 2009-08-20 10:14:11 +0200 | [diff] [blame] | 722 | goto error4; |
| 723 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 724 | dmvgbe->p_txdesc = (struct mvgbe_txdesc *) memalign( |
| 725 | PKTALIGN, sizeof(struct mvgbe_txdesc) + 1); |
| 726 | |
| 727 | if (!dmvgbe->p_txdesc) { |
| 728 | free(dmvgbe->p_aligned_txbuf); |
| 729 | error4: |
| 730 | free(dmvgbe->p_rxbuf); |
| 731 | error3: |
| 732 | free(dmvgbe->p_rxdesc); |
| 733 | error2: |
| 734 | free(dmvgbe); |
| 735 | error1: |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 736 | printf("Err.. %s Failed to allocate memory\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 737 | __func__); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 738 | return -1; |
| 739 | } |
| 740 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 741 | dev = &dmvgbe->dev; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 742 | |
Mike Frysinger | f6add13 | 2011-11-10 14:11:04 +0000 | [diff] [blame] | 743 | /* must be less than sizeof(dev->name) */ |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 744 | sprintf(dev->name, "egiga%d", devnum); |
| 745 | |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 746 | switch (devnum) { |
| 747 | case 0: |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 748 | dmvgbe->regs = (void *)MVGBE0_BASE; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 749 | break; |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 750 | #if defined(MVGBE1_BASE) |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 751 | case 1: |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 752 | dmvgbe->regs = (void *)MVGBE1_BASE; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 753 | break; |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 754 | #endif |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 755 | default: /* this should never happen */ |
| 756 | printf("Err..(%s) Invalid device number %d\n", |
Joe Hershberger | 1fd92db | 2015-04-08 01:41:06 -0500 | [diff] [blame] | 757 | __func__, devnum); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 758 | return -1; |
| 759 | } |
| 760 | |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 761 | dev->init = (void *)mvgbe_init; |
| 762 | dev->halt = (void *)mvgbe_halt; |
| 763 | dev->send = (void *)mvgbe_send; |
| 764 | dev->recv = (void *)mvgbe_recv; |
| 765 | dev->write_hwaddr = (void *)mvgbe_write_hwaddr; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 766 | |
| 767 | eth_register(dev); |
| 768 | |
Sebastian Hesselbarth | cd3ca3f | 2012-12-04 09:32:00 +0100 | [diff] [blame] | 769 | #if defined(CONFIG_PHYLIB) |
| 770 | mvgbe_phylib_init(dev, PHY_BASE_ADR + devnum); |
| 771 | #elif defined(CONFIG_MII) || defined(CONFIG_CMD_MII) |
Joe Hershberger | 5a49f17 | 2016-08-08 11:28:38 -0500 | [diff] [blame] | 772 | int retval; |
| 773 | struct mii_dev *mdiodev = mdio_alloc(); |
| 774 | if (!mdiodev) |
| 775 | return -ENOMEM; |
| 776 | strncpy(mdiodev->name, dev->name, MDIO_NAME_LEN); |
| 777 | mdiodev->read = smi_reg_read; |
| 778 | mdiodev->write = smi_reg_write; |
| 779 | |
| 780 | retval = mdio_register(mdiodev); |
| 781 | if (retval < 0) |
| 782 | return retval; |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 783 | /* Set phy address of the port */ |
Albert Aribaud | d44265a | 2010-07-12 22:24:28 +0200 | [diff] [blame] | 784 | miiphy_write(dev->name, MV_PHY_ADR_REQUEST, |
| 785 | MV_PHY_ADR_REQUEST, PHY_BASE_ADR + devnum); |
Prafulla Wadaskar | 9131589 | 2009-06-14 22:33:46 +0530 | [diff] [blame] | 786 | #endif |
| 787 | } |
| 788 | return 0; |
Prafulla Wadaskar | 0b785dd | 2009-07-01 20:34:51 +0200 | [diff] [blame] | 789 | } |