Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * net/dsa/mv88e6xxx.c - Marvell 88e6xxx switch chip support |
| 3 | * Copyright (c) 2008 Marvell Semiconductor |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | */ |
| 10 | |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 11 | #include <linux/delay.h> |
| 12 | #include <linux/jiffies.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 13 | #include <linux/list.h> |
Paul Gortmaker | 2bbba27 | 2012-01-24 10:41:40 +0000 | [diff] [blame] | 14 | #include <linux/module.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 15 | #include <linux/netdevice.h> |
| 16 | #include <linux/phy.h> |
Ben Hutchings | c8f0b86 | 2011-11-27 17:06:08 +0000 | [diff] [blame] | 17 | #include <net/dsa.h> |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 18 | #include "mv88e6xxx.h" |
| 19 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 20 | /* If the switch's ADDR[4:0] strap pins are strapped to zero, it will |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 21 | * use all 32 SMI bus addresses on its SMI bus, and all switch registers |
| 22 | * will be directly accessible on some {device address,register address} |
| 23 | * pair. If the ADDR[4:0] pins are not strapped to zero, the switch |
| 24 | * will only respond to SMI transactions to that specific address, and |
| 25 | * an indirect addressing mechanism needs to be used to access its |
| 26 | * registers. |
| 27 | */ |
| 28 | static int mv88e6xxx_reg_wait_ready(struct mii_bus *bus, int sw_addr) |
| 29 | { |
| 30 | int ret; |
| 31 | int i; |
| 32 | |
| 33 | for (i = 0; i < 16; i++) { |
| 34 | ret = mdiobus_read(bus, sw_addr, 0); |
| 35 | if (ret < 0) |
| 36 | return ret; |
| 37 | |
| 38 | if ((ret & 0x8000) == 0) |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | return -ETIMEDOUT; |
| 43 | } |
| 44 | |
| 45 | int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg) |
| 46 | { |
| 47 | int ret; |
| 48 | |
| 49 | if (sw_addr == 0) |
| 50 | return mdiobus_read(bus, addr, reg); |
| 51 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 52 | /* Wait for the bus to become free. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 53 | ret = mv88e6xxx_reg_wait_ready(bus, sw_addr); |
| 54 | if (ret < 0) |
| 55 | return ret; |
| 56 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 57 | /* Transmit the read command. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 58 | ret = mdiobus_write(bus, sw_addr, 0, 0x9800 | (addr << 5) | reg); |
| 59 | if (ret < 0) |
| 60 | return ret; |
| 61 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 62 | /* Wait for the read command to complete. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 63 | ret = mv88e6xxx_reg_wait_ready(bus, sw_addr); |
| 64 | if (ret < 0) |
| 65 | return ret; |
| 66 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 67 | /* Read the data. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 68 | ret = mdiobus_read(bus, sw_addr, 1); |
| 69 | if (ret < 0) |
| 70 | return ret; |
| 71 | |
| 72 | return ret & 0xffff; |
| 73 | } |
| 74 | |
Guenter Roeck | 8d6d09e | 2015-03-26 18:36:31 -0700 | [diff] [blame^] | 75 | /* Must be called with SMI mutex held */ |
| 76 | static int _mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 77 | { |
Guenter Roeck | b184e49 | 2014-10-17 12:30:58 -0700 | [diff] [blame] | 78 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 79 | int ret; |
| 80 | |
Guenter Roeck | b184e49 | 2014-10-17 12:30:58 -0700 | [diff] [blame] | 81 | if (bus == NULL) |
| 82 | return -EINVAL; |
| 83 | |
Guenter Roeck | b184e49 | 2014-10-17 12:30:58 -0700 | [diff] [blame] | 84 | ret = __mv88e6xxx_reg_read(bus, ds->pd->sw_addr, addr, reg); |
Vivien Didelot | bb92ea5 | 2015-01-23 16:10:36 -0500 | [diff] [blame] | 85 | if (ret < 0) |
| 86 | return ret; |
| 87 | |
| 88 | dev_dbg(ds->master_dev, "<- addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
| 89 | addr, reg, ret); |
| 90 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 91 | return ret; |
| 92 | } |
| 93 | |
Guenter Roeck | 8d6d09e | 2015-03-26 18:36:31 -0700 | [diff] [blame^] | 94 | int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg) |
| 95 | { |
| 96 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
| 97 | int ret; |
| 98 | |
| 99 | mutex_lock(&ps->smi_mutex); |
| 100 | ret = _mv88e6xxx_reg_read(ds, addr, reg); |
| 101 | mutex_unlock(&ps->smi_mutex); |
| 102 | |
| 103 | return ret; |
| 104 | } |
| 105 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 106 | int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, |
| 107 | int reg, u16 val) |
| 108 | { |
| 109 | int ret; |
| 110 | |
| 111 | if (sw_addr == 0) |
| 112 | return mdiobus_write(bus, addr, reg, val); |
| 113 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 114 | /* Wait for the bus to become free. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 115 | ret = mv88e6xxx_reg_wait_ready(bus, sw_addr); |
| 116 | if (ret < 0) |
| 117 | return ret; |
| 118 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 119 | /* Transmit the data to write. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 120 | ret = mdiobus_write(bus, sw_addr, 1, val); |
| 121 | if (ret < 0) |
| 122 | return ret; |
| 123 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 124 | /* Transmit the write command. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 125 | ret = mdiobus_write(bus, sw_addr, 0, 0x9400 | (addr << 5) | reg); |
| 126 | if (ret < 0) |
| 127 | return ret; |
| 128 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 129 | /* Wait for the write command to complete. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 130 | ret = mv88e6xxx_reg_wait_ready(bus, sw_addr); |
| 131 | if (ret < 0) |
| 132 | return ret; |
| 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | |
Guenter Roeck | 8d6d09e | 2015-03-26 18:36:31 -0700 | [diff] [blame^] | 137 | /* Must be called with SMI mutex held */ |
| 138 | static int _mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, |
| 139 | u16 val) |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 140 | { |
Guenter Roeck | b184e49 | 2014-10-17 12:30:58 -0700 | [diff] [blame] | 141 | struct mii_bus *bus = dsa_host_dev_to_mii_bus(ds->master_dev); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 142 | |
Guenter Roeck | b184e49 | 2014-10-17 12:30:58 -0700 | [diff] [blame] | 143 | if (bus == NULL) |
| 144 | return -EINVAL; |
| 145 | |
Vivien Didelot | bb92ea5 | 2015-01-23 16:10:36 -0500 | [diff] [blame] | 146 | dev_dbg(ds->master_dev, "-> addr: 0x%.2x reg: 0x%.2x val: 0x%.4x\n", |
| 147 | addr, reg, val); |
| 148 | |
Guenter Roeck | 8d6d09e | 2015-03-26 18:36:31 -0700 | [diff] [blame^] | 149 | return __mv88e6xxx_reg_write(bus, ds->pd->sw_addr, addr, reg, val); |
| 150 | } |
| 151 | |
| 152 | int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val) |
| 153 | { |
| 154 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
| 155 | int ret; |
| 156 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 157 | mutex_lock(&ps->smi_mutex); |
Guenter Roeck | 8d6d09e | 2015-03-26 18:36:31 -0700 | [diff] [blame^] | 158 | ret = _mv88e6xxx_reg_write(ds, addr, reg, val); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 159 | mutex_unlock(&ps->smi_mutex); |
| 160 | |
| 161 | return ret; |
| 162 | } |
| 163 | |
| 164 | int mv88e6xxx_config_prio(struct dsa_switch *ds) |
| 165 | { |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 166 | /* Configure the IP ToS mapping registers. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 167 | REG_WRITE(REG_GLOBAL, 0x10, 0x0000); |
| 168 | REG_WRITE(REG_GLOBAL, 0x11, 0x0000); |
| 169 | REG_WRITE(REG_GLOBAL, 0x12, 0x5555); |
| 170 | REG_WRITE(REG_GLOBAL, 0x13, 0x5555); |
| 171 | REG_WRITE(REG_GLOBAL, 0x14, 0xaaaa); |
| 172 | REG_WRITE(REG_GLOBAL, 0x15, 0xaaaa); |
| 173 | REG_WRITE(REG_GLOBAL, 0x16, 0xffff); |
| 174 | REG_WRITE(REG_GLOBAL, 0x17, 0xffff); |
| 175 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 176 | /* Configure the IEEE 802.1p priority mapping register. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 177 | REG_WRITE(REG_GLOBAL, 0x18, 0xfa41); |
| 178 | |
| 179 | return 0; |
| 180 | } |
| 181 | |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 182 | int mv88e6xxx_set_addr_direct(struct dsa_switch *ds, u8 *addr) |
| 183 | { |
| 184 | REG_WRITE(REG_GLOBAL, 0x01, (addr[0] << 8) | addr[1]); |
| 185 | REG_WRITE(REG_GLOBAL, 0x02, (addr[2] << 8) | addr[3]); |
| 186 | REG_WRITE(REG_GLOBAL, 0x03, (addr[4] << 8) | addr[5]); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 191 | int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr) |
| 192 | { |
| 193 | int i; |
| 194 | int ret; |
| 195 | |
| 196 | for (i = 0; i < 6; i++) { |
| 197 | int j; |
| 198 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 199 | /* Write the MAC address byte. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 200 | REG_WRITE(REG_GLOBAL2, 0x0d, 0x8000 | (i << 8) | addr[i]); |
| 201 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 202 | /* Wait for the write to complete. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 203 | for (j = 0; j < 16; j++) { |
| 204 | ret = REG_READ(REG_GLOBAL2, 0x0d); |
| 205 | if ((ret & 0x8000) == 0) |
| 206 | break; |
| 207 | } |
| 208 | if (j == 16) |
| 209 | return -ETIMEDOUT; |
| 210 | } |
| 211 | |
| 212 | return 0; |
| 213 | } |
| 214 | |
| 215 | int mv88e6xxx_phy_read(struct dsa_switch *ds, int addr, int regnum) |
| 216 | { |
| 217 | if (addr >= 0) |
| 218 | return mv88e6xxx_reg_read(ds, addr, regnum); |
| 219 | return 0xffff; |
| 220 | } |
| 221 | |
| 222 | int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val) |
| 223 | { |
| 224 | if (addr >= 0) |
| 225 | return mv88e6xxx_reg_write(ds, addr, regnum, val); |
| 226 | return 0; |
| 227 | } |
| 228 | |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 229 | #ifdef CONFIG_NET_DSA_MV88E6XXX_NEED_PPU |
| 230 | static int mv88e6xxx_ppu_disable(struct dsa_switch *ds) |
| 231 | { |
| 232 | int ret; |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 233 | unsigned long timeout; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 234 | |
| 235 | ret = REG_READ(REG_GLOBAL, 0x04); |
| 236 | REG_WRITE(REG_GLOBAL, 0x04, ret & ~0x4000); |
| 237 | |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 238 | timeout = jiffies + 1 * HZ; |
| 239 | while (time_before(jiffies, timeout)) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 240 | ret = REG_READ(REG_GLOBAL, 0x00); |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 241 | usleep_range(1000, 2000); |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 242 | if ((ret & 0xc000) != 0xc000) |
| 243 | return 0; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | return -ETIMEDOUT; |
| 247 | } |
| 248 | |
| 249 | static int mv88e6xxx_ppu_enable(struct dsa_switch *ds) |
| 250 | { |
| 251 | int ret; |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 252 | unsigned long timeout; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 253 | |
| 254 | ret = REG_READ(REG_GLOBAL, 0x04); |
| 255 | REG_WRITE(REG_GLOBAL, 0x04, ret | 0x4000); |
| 256 | |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 257 | timeout = jiffies + 1 * HZ; |
| 258 | while (time_before(jiffies, timeout)) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 259 | ret = REG_READ(REG_GLOBAL, 0x00); |
Barry Grussling | 19b2f97 | 2013-01-08 16:05:54 +0000 | [diff] [blame] | 260 | usleep_range(1000, 2000); |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 261 | if ((ret & 0xc000) == 0xc000) |
| 262 | return 0; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | return -ETIMEDOUT; |
| 266 | } |
| 267 | |
| 268 | static void mv88e6xxx_ppu_reenable_work(struct work_struct *ugly) |
| 269 | { |
| 270 | struct mv88e6xxx_priv_state *ps; |
| 271 | |
| 272 | ps = container_of(ugly, struct mv88e6xxx_priv_state, ppu_work); |
| 273 | if (mutex_trylock(&ps->ppu_mutex)) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 274 | struct dsa_switch *ds = ((struct dsa_switch *)ps) - 1; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 275 | |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 276 | if (mv88e6xxx_ppu_enable(ds) == 0) |
| 277 | ps->ppu_disabled = 0; |
| 278 | mutex_unlock(&ps->ppu_mutex); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 279 | } |
| 280 | } |
| 281 | |
| 282 | static void mv88e6xxx_ppu_reenable_timer(unsigned long _ps) |
| 283 | { |
| 284 | struct mv88e6xxx_priv_state *ps = (void *)_ps; |
| 285 | |
| 286 | schedule_work(&ps->ppu_work); |
| 287 | } |
| 288 | |
| 289 | static int mv88e6xxx_ppu_access_get(struct dsa_switch *ds) |
| 290 | { |
Florian Fainelli | a22adce | 2014-04-28 11:14:28 -0700 | [diff] [blame] | 291 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 292 | int ret; |
| 293 | |
| 294 | mutex_lock(&ps->ppu_mutex); |
| 295 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 296 | /* If the PHY polling unit is enabled, disable it so that |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 297 | * we can access the PHY registers. If it was already |
| 298 | * disabled, cancel the timer that is going to re-enable |
| 299 | * it. |
| 300 | */ |
| 301 | if (!ps->ppu_disabled) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 302 | ret = mv88e6xxx_ppu_disable(ds); |
| 303 | if (ret < 0) { |
| 304 | mutex_unlock(&ps->ppu_mutex); |
| 305 | return ret; |
| 306 | } |
| 307 | ps->ppu_disabled = 1; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 308 | } else { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 309 | del_timer(&ps->ppu_timer); |
| 310 | ret = 0; |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | return ret; |
| 314 | } |
| 315 | |
| 316 | static void mv88e6xxx_ppu_access_put(struct dsa_switch *ds) |
| 317 | { |
Florian Fainelli | a22adce | 2014-04-28 11:14:28 -0700 | [diff] [blame] | 318 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 319 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 320 | /* Schedule a timer to re-enable the PHY polling unit. */ |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 321 | mod_timer(&ps->ppu_timer, jiffies + msecs_to_jiffies(10)); |
| 322 | mutex_unlock(&ps->ppu_mutex); |
| 323 | } |
| 324 | |
| 325 | void mv88e6xxx_ppu_state_init(struct dsa_switch *ds) |
| 326 | { |
Florian Fainelli | a22adce | 2014-04-28 11:14:28 -0700 | [diff] [blame] | 327 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 328 | |
| 329 | mutex_init(&ps->ppu_mutex); |
| 330 | INIT_WORK(&ps->ppu_work, mv88e6xxx_ppu_reenable_work); |
| 331 | init_timer(&ps->ppu_timer); |
| 332 | ps->ppu_timer.data = (unsigned long)ps; |
| 333 | ps->ppu_timer.function = mv88e6xxx_ppu_reenable_timer; |
| 334 | } |
| 335 | |
| 336 | int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum) |
| 337 | { |
| 338 | int ret; |
| 339 | |
| 340 | ret = mv88e6xxx_ppu_access_get(ds); |
| 341 | if (ret >= 0) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 342 | ret = mv88e6xxx_reg_read(ds, addr, regnum); |
| 343 | mv88e6xxx_ppu_access_put(ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | return ret; |
| 347 | } |
| 348 | |
| 349 | int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr, |
| 350 | int regnum, u16 val) |
| 351 | { |
| 352 | int ret; |
| 353 | |
| 354 | ret = mv88e6xxx_ppu_access_get(ds); |
| 355 | if (ret >= 0) { |
Barry Grussling | 8568658 | 2013-01-08 16:05:56 +0000 | [diff] [blame] | 356 | ret = mv88e6xxx_reg_write(ds, addr, regnum, val); |
| 357 | mv88e6xxx_ppu_access_put(ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | return ret; |
| 361 | } |
| 362 | #endif |
| 363 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 364 | void mv88e6xxx_poll_link(struct dsa_switch *ds) |
| 365 | { |
| 366 | int i; |
| 367 | |
| 368 | for (i = 0; i < DSA_MAX_PORTS; i++) { |
| 369 | struct net_device *dev; |
Ingo Molnar | 2a9e797 | 2008-11-25 16:50:49 -0800 | [diff] [blame] | 370 | int uninitialized_var(port_status); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 371 | int link; |
| 372 | int speed; |
| 373 | int duplex; |
| 374 | int fc; |
| 375 | |
| 376 | dev = ds->ports[i]; |
| 377 | if (dev == NULL) |
| 378 | continue; |
| 379 | |
| 380 | link = 0; |
| 381 | if (dev->flags & IFF_UP) { |
| 382 | port_status = mv88e6xxx_reg_read(ds, REG_PORT(i), 0x00); |
| 383 | if (port_status < 0) |
| 384 | continue; |
| 385 | |
| 386 | link = !!(port_status & 0x0800); |
| 387 | } |
| 388 | |
| 389 | if (!link) { |
| 390 | if (netif_carrier_ok(dev)) { |
Barry Grussling | ab381a9 | 2013-01-08 16:05:55 +0000 | [diff] [blame] | 391 | netdev_info(dev, "link down\n"); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 392 | netif_carrier_off(dev); |
| 393 | } |
| 394 | continue; |
| 395 | } |
| 396 | |
| 397 | switch (port_status & 0x0300) { |
| 398 | case 0x0000: |
| 399 | speed = 10; |
| 400 | break; |
| 401 | case 0x0100: |
| 402 | speed = 100; |
| 403 | break; |
| 404 | case 0x0200: |
| 405 | speed = 1000; |
| 406 | break; |
| 407 | default: |
| 408 | speed = -1; |
| 409 | break; |
| 410 | } |
| 411 | duplex = (port_status & 0x0400) ? 1 : 0; |
| 412 | fc = (port_status & 0x8000) ? 1 : 0; |
| 413 | |
| 414 | if (!netif_carrier_ok(dev)) { |
Barry Grussling | ab381a9 | 2013-01-08 16:05:55 +0000 | [diff] [blame] | 415 | netdev_info(dev, |
| 416 | "link up, %d Mb/s, %s duplex, flow control %sabled\n", |
| 417 | speed, |
| 418 | duplex ? "full" : "half", |
| 419 | fc ? "en" : "dis"); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 420 | netif_carrier_on(dev); |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | static int mv88e6xxx_stats_wait(struct dsa_switch *ds) |
| 426 | { |
| 427 | int ret; |
| 428 | int i; |
| 429 | |
| 430 | for (i = 0; i < 10; i++) { |
Stephane Contri | 1ded3f5 | 2009-07-02 23:26:48 +0000 | [diff] [blame] | 431 | ret = REG_READ(REG_GLOBAL, 0x1d); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 432 | if ((ret & 0x8000) == 0) |
| 433 | return 0; |
| 434 | } |
| 435 | |
| 436 | return -ETIMEDOUT; |
| 437 | } |
| 438 | |
| 439 | static int mv88e6xxx_stats_snapshot(struct dsa_switch *ds, int port) |
| 440 | { |
| 441 | int ret; |
| 442 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 443 | /* Snapshot the hardware statistics counters for this port. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 444 | REG_WRITE(REG_GLOBAL, 0x1d, 0xdc00 | port); |
| 445 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 446 | /* Wait for the snapshotting to complete. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 447 | ret = mv88e6xxx_stats_wait(ds); |
| 448 | if (ret < 0) |
| 449 | return ret; |
| 450 | |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static void mv88e6xxx_stats_read(struct dsa_switch *ds, int stat, u32 *val) |
| 455 | { |
| 456 | u32 _val; |
| 457 | int ret; |
| 458 | |
| 459 | *val = 0; |
| 460 | |
| 461 | ret = mv88e6xxx_reg_write(ds, REG_GLOBAL, 0x1d, 0xcc00 | stat); |
| 462 | if (ret < 0) |
| 463 | return; |
| 464 | |
| 465 | ret = mv88e6xxx_stats_wait(ds); |
| 466 | if (ret < 0) |
| 467 | return; |
| 468 | |
| 469 | ret = mv88e6xxx_reg_read(ds, REG_GLOBAL, 0x1e); |
| 470 | if (ret < 0) |
| 471 | return; |
| 472 | |
| 473 | _val = ret << 16; |
| 474 | |
| 475 | ret = mv88e6xxx_reg_read(ds, REG_GLOBAL, 0x1f); |
| 476 | if (ret < 0) |
| 477 | return; |
| 478 | |
| 479 | *val = _val | ret; |
| 480 | } |
| 481 | |
| 482 | void mv88e6xxx_get_strings(struct dsa_switch *ds, |
| 483 | int nr_stats, struct mv88e6xxx_hw_stat *stats, |
| 484 | int port, uint8_t *data) |
| 485 | { |
| 486 | int i; |
| 487 | |
| 488 | for (i = 0; i < nr_stats; i++) { |
| 489 | memcpy(data + i * ETH_GSTRING_LEN, |
| 490 | stats[i].string, ETH_GSTRING_LEN); |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, |
| 495 | int nr_stats, struct mv88e6xxx_hw_stat *stats, |
| 496 | int port, uint64_t *data) |
| 497 | { |
Florian Fainelli | a22adce | 2014-04-28 11:14:28 -0700 | [diff] [blame] | 498 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 499 | int ret; |
| 500 | int i; |
| 501 | |
| 502 | mutex_lock(&ps->stats_mutex); |
| 503 | |
| 504 | ret = mv88e6xxx_stats_snapshot(ds, port); |
| 505 | if (ret < 0) { |
| 506 | mutex_unlock(&ps->stats_mutex); |
| 507 | return; |
| 508 | } |
| 509 | |
Barry Grussling | 3675c8d | 2013-01-08 16:05:53 +0000 | [diff] [blame] | 510 | /* Read each of the counters. */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 511 | for (i = 0; i < nr_stats; i++) { |
| 512 | struct mv88e6xxx_hw_stat *s = stats + i; |
| 513 | u32 low; |
Guenter Roeck | 17ee3e0 | 2014-10-29 10:45:07 -0700 | [diff] [blame] | 514 | u32 high = 0; |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 515 | |
Guenter Roeck | 17ee3e0 | 2014-10-29 10:45:07 -0700 | [diff] [blame] | 516 | if (s->reg >= 0x100) { |
| 517 | int ret; |
| 518 | |
| 519 | ret = mv88e6xxx_reg_read(ds, REG_PORT(port), |
| 520 | s->reg - 0x100); |
| 521 | if (ret < 0) |
| 522 | goto error; |
| 523 | low = ret; |
| 524 | if (s->sizeof_stat == 4) { |
| 525 | ret = mv88e6xxx_reg_read(ds, REG_PORT(port), |
| 526 | s->reg - 0x100 + 1); |
| 527 | if (ret < 0) |
| 528 | goto error; |
| 529 | high = ret; |
| 530 | } |
| 531 | data[i] = (((u64)high) << 16) | low; |
| 532 | continue; |
| 533 | } |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 534 | mv88e6xxx_stats_read(ds, s->reg, &low); |
| 535 | if (s->sizeof_stat == 8) |
| 536 | mv88e6xxx_stats_read(ds, s->reg + 1, &high); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 537 | |
| 538 | data[i] = (((u64)high) << 32) | low; |
| 539 | } |
Guenter Roeck | 17ee3e0 | 2014-10-29 10:45:07 -0700 | [diff] [blame] | 540 | error: |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 541 | mutex_unlock(&ps->stats_mutex); |
| 542 | } |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 543 | |
Guenter Roeck | a1ab91f3 | 2014-10-29 10:45:05 -0700 | [diff] [blame] | 544 | int mv88e6xxx_get_regs_len(struct dsa_switch *ds, int port) |
| 545 | { |
| 546 | return 32 * sizeof(u16); |
| 547 | } |
| 548 | |
| 549 | void mv88e6xxx_get_regs(struct dsa_switch *ds, int port, |
| 550 | struct ethtool_regs *regs, void *_p) |
| 551 | { |
| 552 | u16 *p = _p; |
| 553 | int i; |
| 554 | |
| 555 | regs->version = 0; |
| 556 | |
| 557 | memset(p, 0xff, 32 * sizeof(u16)); |
| 558 | |
| 559 | for (i = 0; i < 32; i++) { |
| 560 | int ret; |
| 561 | |
| 562 | ret = mv88e6xxx_reg_read(ds, REG_PORT(port), i); |
| 563 | if (ret >= 0) |
| 564 | p[i] = ret; |
| 565 | } |
| 566 | } |
| 567 | |
Andrew Lunn | eaa2376 | 2014-11-15 22:24:51 +0100 | [diff] [blame] | 568 | #ifdef CONFIG_NET_DSA_HWMON |
| 569 | |
| 570 | int mv88e6xxx_get_temp(struct dsa_switch *ds, int *temp) |
| 571 | { |
| 572 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
| 573 | int ret; |
| 574 | int val; |
| 575 | |
| 576 | *temp = 0; |
| 577 | |
| 578 | mutex_lock(&ps->phy_mutex); |
| 579 | |
| 580 | ret = mv88e6xxx_phy_write(ds, 0x0, 0x16, 0x6); |
| 581 | if (ret < 0) |
| 582 | goto error; |
| 583 | |
| 584 | /* Enable temperature sensor */ |
| 585 | ret = mv88e6xxx_phy_read(ds, 0x0, 0x1a); |
| 586 | if (ret < 0) |
| 587 | goto error; |
| 588 | |
| 589 | ret = mv88e6xxx_phy_write(ds, 0x0, 0x1a, ret | (1 << 5)); |
| 590 | if (ret < 0) |
| 591 | goto error; |
| 592 | |
| 593 | /* Wait for temperature to stabilize */ |
| 594 | usleep_range(10000, 12000); |
| 595 | |
| 596 | val = mv88e6xxx_phy_read(ds, 0x0, 0x1a); |
| 597 | if (val < 0) { |
| 598 | ret = val; |
| 599 | goto error; |
| 600 | } |
| 601 | |
| 602 | /* Disable temperature sensor */ |
| 603 | ret = mv88e6xxx_phy_write(ds, 0x0, 0x1a, ret & ~(1 << 5)); |
| 604 | if (ret < 0) |
| 605 | goto error; |
| 606 | |
| 607 | *temp = ((val & 0x1f) - 5) * 5; |
| 608 | |
| 609 | error: |
| 610 | mv88e6xxx_phy_write(ds, 0x0, 0x16, 0x0); |
| 611 | mutex_unlock(&ps->phy_mutex); |
| 612 | return ret; |
| 613 | } |
| 614 | #endif /* CONFIG_NET_DSA_HWMON */ |
| 615 | |
Andrew Lunn | f304468 | 2015-02-14 19:17:50 +0100 | [diff] [blame] | 616 | static int mv88e6xxx_wait(struct dsa_switch *ds, int reg, int offset, u16 mask) |
| 617 | { |
| 618 | unsigned long timeout = jiffies + HZ / 10; |
| 619 | |
| 620 | while (time_before(jiffies, timeout)) { |
| 621 | int ret; |
| 622 | |
| 623 | ret = REG_READ(reg, offset); |
| 624 | if (!(ret & mask)) |
| 625 | return 0; |
| 626 | |
| 627 | usleep_range(1000, 2000); |
| 628 | } |
| 629 | return -ETIMEDOUT; |
| 630 | } |
| 631 | |
| 632 | int mv88e6xxx_phy_wait(struct dsa_switch *ds) |
| 633 | { |
| 634 | return mv88e6xxx_wait(ds, REG_GLOBAL2, 0x18, 0x8000); |
| 635 | } |
| 636 | |
| 637 | int mv88e6xxx_eeprom_load_wait(struct dsa_switch *ds) |
| 638 | { |
| 639 | return mv88e6xxx_wait(ds, REG_GLOBAL2, 0x14, 0x0800); |
| 640 | } |
| 641 | |
| 642 | int mv88e6xxx_eeprom_busy_wait(struct dsa_switch *ds) |
| 643 | { |
| 644 | return mv88e6xxx_wait(ds, REG_GLOBAL2, 0x14, 0x8000); |
| 645 | } |
| 646 | |
| 647 | int mv88e6xxx_phy_read_indirect(struct dsa_switch *ds, int addr, int regnum) |
| 648 | { |
| 649 | int ret; |
| 650 | |
| 651 | REG_WRITE(REG_GLOBAL2, 0x18, 0x9800 | (addr << 5) | regnum); |
| 652 | |
| 653 | ret = mv88e6xxx_phy_wait(ds); |
| 654 | if (ret < 0) |
| 655 | return ret; |
| 656 | |
| 657 | return REG_READ(REG_GLOBAL2, 0x19); |
| 658 | } |
| 659 | |
| 660 | int mv88e6xxx_phy_write_indirect(struct dsa_switch *ds, int addr, int regnum, |
| 661 | u16 val) |
| 662 | { |
| 663 | REG_WRITE(REG_GLOBAL2, 0x19, val); |
| 664 | REG_WRITE(REG_GLOBAL2, 0x18, 0x9400 | (addr << 5) | regnum); |
| 665 | |
| 666 | return mv88e6xxx_phy_wait(ds); |
| 667 | } |
| 668 | |
Guenter Roeck | 11b3b45 | 2015-03-06 22:23:51 -0800 | [diff] [blame] | 669 | int mv88e6xxx_get_eee(struct dsa_switch *ds, int port, struct ethtool_eee *e) |
| 670 | { |
| 671 | int reg; |
| 672 | |
| 673 | reg = mv88e6xxx_phy_read_indirect(ds, port, 16); |
| 674 | if (reg < 0) |
| 675 | return -EOPNOTSUPP; |
| 676 | |
| 677 | e->eee_enabled = !!(reg & 0x0200); |
| 678 | e->tx_lpi_enabled = !!(reg & 0x0100); |
| 679 | |
| 680 | reg = REG_READ(REG_PORT(port), 0); |
| 681 | e->eee_active = !!(reg & 0x0040); |
| 682 | |
| 683 | return 0; |
| 684 | } |
| 685 | |
| 686 | static int mv88e6xxx_eee_enable_set(struct dsa_switch *ds, int port, |
| 687 | bool eee_enabled, bool tx_lpi_enabled) |
| 688 | { |
| 689 | int reg, nreg; |
| 690 | |
| 691 | reg = mv88e6xxx_phy_read_indirect(ds, port, 16); |
| 692 | if (reg < 0) |
| 693 | return reg; |
| 694 | |
| 695 | nreg = reg & ~0x0300; |
| 696 | if (eee_enabled) |
| 697 | nreg |= 0x0200; |
| 698 | if (tx_lpi_enabled) |
| 699 | nreg |= 0x0100; |
| 700 | |
| 701 | if (nreg != reg) |
| 702 | return mv88e6xxx_phy_write_indirect(ds, port, 16, nreg); |
| 703 | |
| 704 | return 0; |
| 705 | } |
| 706 | |
| 707 | int mv88e6xxx_set_eee(struct dsa_switch *ds, int port, |
| 708 | struct phy_device *phydev, struct ethtool_eee *e) |
| 709 | { |
| 710 | int ret; |
| 711 | |
| 712 | ret = mv88e6xxx_eee_enable_set(ds, port, e->eee_enabled, |
| 713 | e->tx_lpi_enabled); |
| 714 | if (ret) |
| 715 | return -EOPNOTSUPP; |
| 716 | |
| 717 | return 0; |
| 718 | } |
| 719 | |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 720 | int mv88e6xxx_setup_port_common(struct dsa_switch *ds, int port) |
| 721 | { |
| 722 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
| 723 | int ret, reg; |
| 724 | |
| 725 | mutex_lock(&ps->smi_mutex); |
| 726 | |
Guenter Roeck | 366f0a0 | 2015-03-26 18:36:30 -0700 | [diff] [blame] | 727 | /* Port Control 1: disable trunking, disable sending |
| 728 | * learning messages to this port. |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 729 | */ |
Guenter Roeck | 366f0a0 | 2015-03-26 18:36:30 -0700 | [diff] [blame] | 730 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x05, 0x0000); |
Guenter Roeck | d827e88 | 2015-03-26 18:36:29 -0700 | [diff] [blame] | 731 | if (ret) |
| 732 | goto abort; |
| 733 | |
| 734 | /* Port based VLAN map: give each port its own address |
| 735 | * database, allow the CPU port to talk to each of the 'real' |
| 736 | * ports, and allow each of the 'real' ports to only talk to |
| 737 | * the upstream port. |
| 738 | */ |
| 739 | reg = (port & 0xf) << 12; |
| 740 | if (dsa_is_cpu_port(ds, port)) |
| 741 | reg |= ds->phys_port_mask; |
| 742 | else |
| 743 | reg |= 1 << dsa_upstream_port(ds); |
| 744 | |
| 745 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x06, reg); |
| 746 | if (ret) |
| 747 | goto abort; |
| 748 | |
| 749 | /* Default VLAN ID and priority: don't set a default VLAN |
| 750 | * ID, and set the default packet priority to zero. |
| 751 | */ |
| 752 | ret = _mv88e6xxx_reg_write(ds, REG_PORT(port), 0x07, 0x0000); |
| 753 | abort: |
| 754 | mutex_unlock(&ps->smi_mutex); |
| 755 | return ret; |
| 756 | } |
| 757 | |
Guenter Roeck | acdaffc | 2015-03-26 18:36:28 -0700 | [diff] [blame] | 758 | int mv88e6xxx_setup_common(struct dsa_switch *ds) |
| 759 | { |
| 760 | struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); |
| 761 | |
| 762 | mutex_init(&ps->smi_mutex); |
| 763 | mutex_init(&ps->stats_mutex); |
| 764 | mutex_init(&ps->phy_mutex); |
| 765 | |
| 766 | return 0; |
| 767 | } |
| 768 | |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 769 | static int __init mv88e6xxx_init(void) |
| 770 | { |
| 771 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131) |
| 772 | register_switch_driver(&mv88e6131_switch_driver); |
| 773 | #endif |
| 774 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65) |
| 775 | register_switch_driver(&mv88e6123_61_65_switch_driver); |
| 776 | #endif |
Guenter Roeck | 3ad50cc | 2014-10-29 10:44:56 -0700 | [diff] [blame] | 777 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6352) |
| 778 | register_switch_driver(&mv88e6352_switch_driver); |
| 779 | #endif |
Andrew Lunn | 42f2725 | 2014-09-12 23:58:44 +0200 | [diff] [blame] | 780 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6171) |
| 781 | register_switch_driver(&mv88e6171_switch_driver); |
| 782 | #endif |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 783 | return 0; |
| 784 | } |
| 785 | module_init(mv88e6xxx_init); |
| 786 | |
| 787 | static void __exit mv88e6xxx_cleanup(void) |
| 788 | { |
Andrew Lunn | 42f2725 | 2014-09-12 23:58:44 +0200 | [diff] [blame] | 789 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6171) |
| 790 | unregister_switch_driver(&mv88e6171_switch_driver); |
| 791 | #endif |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 792 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6123_61_65) |
| 793 | unregister_switch_driver(&mv88e6123_61_65_switch_driver); |
| 794 | #endif |
| 795 | #if IS_ENABLED(CONFIG_NET_DSA_MV88E6131) |
| 796 | unregister_switch_driver(&mv88e6131_switch_driver); |
| 797 | #endif |
| 798 | } |
| 799 | module_exit(mv88e6xxx_cleanup); |
Ben Hutchings | 3d825ed | 2011-11-25 14:37:16 +0000 | [diff] [blame] | 800 | |
| 801 | MODULE_AUTHOR("Lennert Buytenhek <buytenh@wantstofly.org>"); |
| 802 | MODULE_DESCRIPTION("Driver for Marvell 88E6XXX ethernet switch chips"); |
| 803 | MODULE_LICENSE("GPL"); |