| .. | .. |
|---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Marvell 88E6xxx Ethernet switch single-chip definition |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2008 Marvell Semiconductor |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 8 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 9 | | - * (at your option) any later version. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #ifndef _MV88E6XXX_CHIP_H |
|---|
| 13 | 9 | #define _MV88E6XXX_CHIP_H |
|---|
| 14 | 10 | |
|---|
| 11 | +#include <linux/idr.h> |
|---|
| 15 | 12 | #include <linux/if_vlan.h> |
|---|
| 16 | 13 | #include <linux/irq.h> |
|---|
| 17 | 14 | #include <linux/gpio/consumer.h> |
|---|
| .. | .. |
|---|
| 21 | 18 | #include <linux/timecounter.h> |
|---|
| 22 | 19 | #include <net/dsa.h> |
|---|
| 23 | 20 | |
|---|
| 24 | | -#define SMI_CMD 0x00 |
|---|
| 25 | | -#define SMI_CMD_BUSY BIT(15) |
|---|
| 26 | | -#define SMI_CMD_CLAUSE_22 BIT(12) |
|---|
| 27 | | -#define SMI_CMD_OP_22_WRITE ((1 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22) |
|---|
| 28 | | -#define SMI_CMD_OP_22_READ ((2 << 10) | SMI_CMD_BUSY | SMI_CMD_CLAUSE_22) |
|---|
| 29 | | -#define SMI_CMD_OP_45_WRITE_ADDR ((0 << 10) | SMI_CMD_BUSY) |
|---|
| 30 | | -#define SMI_CMD_OP_45_WRITE_DATA ((1 << 10) | SMI_CMD_BUSY) |
|---|
| 31 | | -#define SMI_CMD_OP_45_READ_DATA ((2 << 10) | SMI_CMD_BUSY) |
|---|
| 32 | | -#define SMI_CMD_OP_45_READ_DATA_INC ((3 << 10) | SMI_CMD_BUSY) |
|---|
| 33 | | -#define SMI_DATA 0x01 |
|---|
| 34 | | - |
|---|
| 21 | +#define EDSA_HLEN 8 |
|---|
| 35 | 22 | #define MV88E6XXX_N_FID 4096 |
|---|
| 36 | 23 | |
|---|
| 37 | 24 | /* PVT limits for 4-bit port and 5-bit switch */ |
|---|
| .. | .. |
|---|
| 45 | 32 | MV88E6XXX_EGRESS_MODE_UNTAGGED, |
|---|
| 46 | 33 | MV88E6XXX_EGRESS_MODE_TAGGED, |
|---|
| 47 | 34 | MV88E6XXX_EGRESS_MODE_ETHERTYPE, |
|---|
| 35 | +}; |
|---|
| 36 | + |
|---|
| 37 | +enum mv88e6xxx_egress_direction { |
|---|
| 38 | + MV88E6XXX_EGRESS_DIR_INGRESS, |
|---|
| 39 | + MV88E6XXX_EGRESS_DIR_EGRESS, |
|---|
| 48 | 40 | }; |
|---|
| 49 | 41 | |
|---|
| 50 | 42 | enum mv88e6xxx_frame_mode { |
|---|
| .. | .. |
|---|
| 72 | 64 | MV88E6190, |
|---|
| 73 | 65 | MV88E6190X, |
|---|
| 74 | 66 | MV88E6191, |
|---|
| 67 | + MV88E6220, |
|---|
| 75 | 68 | MV88E6240, |
|---|
| 69 | + MV88E6250, |
|---|
| 76 | 70 | MV88E6290, |
|---|
| 77 | 71 | MV88E6320, |
|---|
| 78 | 72 | MV88E6321, |
|---|
| .. | .. |
|---|
| 91 | 85 | MV88E6XXX_FAMILY_6097, /* 6046 6085 6096 6097 */ |
|---|
| 92 | 86 | MV88E6XXX_FAMILY_6165, /* 6123 6161 6165 */ |
|---|
| 93 | 87 | MV88E6XXX_FAMILY_6185, /* 6108 6121 6122 6131 6152 6155 6182 6185 */ |
|---|
| 88 | + MV88E6XXX_FAMILY_6250, /* 6220 6250 */ |
|---|
| 94 | 89 | MV88E6XXX_FAMILY_6320, /* 6320 6321 */ |
|---|
| 95 | 90 | MV88E6XXX_FAMILY_6341, /* 6141 6341 */ |
|---|
| 96 | 91 | MV88E6XXX_FAMILY_6351, /* 6171 6175 6350 6351 */ |
|---|
| .. | .. |
|---|
| 105 | 100 | u16 prod_num; |
|---|
| 106 | 101 | const char *name; |
|---|
| 107 | 102 | unsigned int num_databases; |
|---|
| 103 | + unsigned int num_macs; |
|---|
| 108 | 104 | unsigned int num_ports; |
|---|
| 109 | 105 | unsigned int num_internal_phys; |
|---|
| 110 | 106 | unsigned int num_gpio; |
|---|
| .. | .. |
|---|
| 118 | 114 | unsigned int g2_irqs; |
|---|
| 119 | 115 | bool pvt; |
|---|
| 120 | 116 | |
|---|
| 117 | + /* Mark certain ports as invalid. This is required for example for the |
|---|
| 118 | + * MV88E6220 (which is in general a MV88E6250 with 7 ports) but the |
|---|
| 119 | + * ports 2-4 are not routet to pins. |
|---|
| 120 | + */ |
|---|
| 121 | + unsigned int invalid_port_mask; |
|---|
| 121 | 122 | /* Multi-chip Addressing Mode. |
|---|
| 122 | 123 | * Some chips respond to only 2 registers of its own SMI device address |
|---|
| 123 | 124 | * when it is non-zero, and use indirect access to internal registers. |
|---|
| 124 | 125 | */ |
|---|
| 125 | 126 | bool multi_chip; |
|---|
| 127 | + /* Dual-chip Addressing Mode |
|---|
| 128 | + * Some chips respond to only half of the 32 SMI addresses, |
|---|
| 129 | + * allowing two to coexist on the same SMI interface. |
|---|
| 130 | + */ |
|---|
| 131 | + bool dual_chip; |
|---|
| 132 | + |
|---|
| 126 | 133 | enum dsa_tag_protocol tag_protocol; |
|---|
| 127 | 134 | |
|---|
| 128 | 135 | /* Mask for FromPort and ToPort value of PortVec used in ATU Move |
|---|
| .. | .. |
|---|
| 161 | 168 | u16 masked; |
|---|
| 162 | 169 | struct irq_chip chip; |
|---|
| 163 | 170 | struct irq_domain *domain; |
|---|
| 164 | | - unsigned int nirqs; |
|---|
| 171 | + int nirqs; |
|---|
| 165 | 172 | }; |
|---|
| 166 | 173 | |
|---|
| 167 | 174 | /* state flags for mv88e6xxx_port_hwtstamp::state */ |
|---|
| .. | .. |
|---|
| 190 | 197 | struct hwtstamp_config tstamp_config; |
|---|
| 191 | 198 | }; |
|---|
| 192 | 199 | |
|---|
| 200 | +enum mv88e6xxx_policy_mapping { |
|---|
| 201 | + MV88E6XXX_POLICY_MAPPING_DA, |
|---|
| 202 | + MV88E6XXX_POLICY_MAPPING_SA, |
|---|
| 203 | + MV88E6XXX_POLICY_MAPPING_VTU, |
|---|
| 204 | + MV88E6XXX_POLICY_MAPPING_ETYPE, |
|---|
| 205 | + MV88E6XXX_POLICY_MAPPING_PPPOE, |
|---|
| 206 | + MV88E6XXX_POLICY_MAPPING_VBAS, |
|---|
| 207 | + MV88E6XXX_POLICY_MAPPING_OPT82, |
|---|
| 208 | + MV88E6XXX_POLICY_MAPPING_UDP, |
|---|
| 209 | +}; |
|---|
| 210 | + |
|---|
| 211 | +enum mv88e6xxx_policy_action { |
|---|
| 212 | + MV88E6XXX_POLICY_ACTION_NORMAL, |
|---|
| 213 | + MV88E6XXX_POLICY_ACTION_MIRROR, |
|---|
| 214 | + MV88E6XXX_POLICY_ACTION_TRAP, |
|---|
| 215 | + MV88E6XXX_POLICY_ACTION_DISCARD, |
|---|
| 216 | +}; |
|---|
| 217 | + |
|---|
| 218 | +struct mv88e6xxx_policy { |
|---|
| 219 | + enum mv88e6xxx_policy_mapping mapping; |
|---|
| 220 | + enum mv88e6xxx_policy_action action; |
|---|
| 221 | + struct ethtool_rx_flow_spec fs; |
|---|
| 222 | + u8 addr[ETH_ALEN]; |
|---|
| 223 | + int port; |
|---|
| 224 | + u16 vid; |
|---|
| 225 | +}; |
|---|
| 226 | + |
|---|
| 193 | 227 | struct mv88e6xxx_port { |
|---|
| 194 | 228 | struct mv88e6xxx_chip *chip; |
|---|
| 195 | 229 | int port; |
|---|
| .. | .. |
|---|
| 199 | 233 | u64 atu_full_violation; |
|---|
| 200 | 234 | u64 vtu_member_violation; |
|---|
| 201 | 235 | u64 vtu_miss_violation; |
|---|
| 236 | + phy_interface_t interface; |
|---|
| 202 | 237 | u8 cmode; |
|---|
| 203 | | - int serdes_irq; |
|---|
| 238 | + bool mirror_ingress; |
|---|
| 239 | + bool mirror_egress; |
|---|
| 240 | + unsigned int serdes_irq; |
|---|
| 241 | + char serdes_irq_name[64]; |
|---|
| 242 | + struct devlink_region *region; |
|---|
| 243 | +}; |
|---|
| 244 | + |
|---|
| 245 | +enum mv88e6xxx_region_id { |
|---|
| 246 | + MV88E6XXX_REGION_GLOBAL1 = 0, |
|---|
| 247 | + MV88E6XXX_REGION_GLOBAL2, |
|---|
| 248 | + MV88E6XXX_REGION_ATU, |
|---|
| 249 | + |
|---|
| 250 | + _MV88E6XXX_REGION_MAX, |
|---|
| 251 | +}; |
|---|
| 252 | + |
|---|
| 253 | +struct mv88e6xxx_region_priv { |
|---|
| 254 | + enum mv88e6xxx_region_id id; |
|---|
| 204 | 255 | }; |
|---|
| 205 | 256 | |
|---|
| 206 | 257 | struct mv88e6xxx_chip { |
|---|
| .. | .. |
|---|
| 248 | 299 | /* List of mdio busses */ |
|---|
| 249 | 300 | struct list_head mdios; |
|---|
| 250 | 301 | |
|---|
| 302 | + /* Policy Control List IDs and rules */ |
|---|
| 303 | + struct idr policies; |
|---|
| 304 | + |
|---|
| 251 | 305 | /* There can be two interrupt controllers, which are chained |
|---|
| 252 | 306 | * off a GPIO as interrupt source |
|---|
| 253 | 307 | */ |
|---|
| 254 | 308 | struct mv88e6xxx_irq g1_irq; |
|---|
| 255 | 309 | struct mv88e6xxx_irq g2_irq; |
|---|
| 256 | 310 | int irq; |
|---|
| 311 | + char irq_name[64]; |
|---|
| 257 | 312 | int device_irq; |
|---|
| 313 | + char device_irq_name[64]; |
|---|
| 258 | 314 | int watchdog_irq; |
|---|
| 315 | + char watchdog_irq_name[64]; |
|---|
| 259 | 316 | |
|---|
| 260 | 317 | int atu_prob_irq; |
|---|
| 318 | + char atu_prob_irq_name[64]; |
|---|
| 261 | 319 | int vtu_prob_irq; |
|---|
| 320 | + char vtu_prob_irq_name[64]; |
|---|
| 262 | 321 | struct kthread_worker *kworker; |
|---|
| 263 | 322 | struct kthread_delayed_work irq_poll_work; |
|---|
| 264 | 323 | |
|---|
| .. | .. |
|---|
| 280 | 339 | u16 evcap_config; |
|---|
| 281 | 340 | u16 enable_count; |
|---|
| 282 | 341 | |
|---|
| 342 | + /* Current ingress and egress monitor ports */ |
|---|
| 343 | + int egress_dest_port; |
|---|
| 344 | + int ingress_dest_port; |
|---|
| 345 | + |
|---|
| 283 | 346 | /* Per-port timestamping resources. */ |
|---|
| 284 | 347 | struct mv88e6xxx_port_hwtstamp port_hwtstamp[DSA_MAX_PORTS]; |
|---|
| 285 | 348 | |
|---|
| 286 | 349 | /* Array of port structures. */ |
|---|
| 287 | 350 | struct mv88e6xxx_port ports[DSA_MAX_PORTS]; |
|---|
| 351 | + |
|---|
| 352 | + /* devlink regions */ |
|---|
| 353 | + struct devlink_region *regions[_MV88E6XXX_REGION_MAX]; |
|---|
| 288 | 354 | }; |
|---|
| 289 | 355 | |
|---|
| 290 | 356 | struct mv88e6xxx_bus_ops { |
|---|
| .. | .. |
|---|
| 351 | 417 | */ |
|---|
| 352 | 418 | int (*port_set_link)(struct mv88e6xxx_chip *chip, int port, int link); |
|---|
| 353 | 419 | |
|---|
| 354 | | -#define DUPLEX_UNFORCED -2 |
|---|
| 355 | | - |
|---|
| 356 | | - /* Port's MAC duplex mode |
|---|
| 357 | | - * |
|---|
| 358 | | - * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex, |
|---|
| 359 | | - * or DUPLEX_UNFORCED for normal duplex detection. |
|---|
| 360 | | - */ |
|---|
| 361 | | - int (*port_set_duplex)(struct mv88e6xxx_chip *chip, int port, int dup); |
|---|
| 362 | | - |
|---|
| 363 | 420 | #define PAUSE_ON 1 |
|---|
| 364 | 421 | #define PAUSE_OFF 0 |
|---|
| 365 | 422 | |
|---|
| .. | .. |
|---|
| 369 | 426 | |
|---|
| 370 | 427 | #define SPEED_MAX INT_MAX |
|---|
| 371 | 428 | #define SPEED_UNFORCED -2 |
|---|
| 429 | +#define DUPLEX_UNFORCED -2 |
|---|
| 372 | 430 | |
|---|
| 373 | | - /* Port's MAC speed (in Mbps) |
|---|
| 431 | + /* Port's MAC speed (in Mbps) and MAC duplex mode |
|---|
| 374 | 432 | * |
|---|
| 375 | 433 | * Depending on the chip, 10, 100, 200, 1000, 2500, 10000 are valid. |
|---|
| 376 | 434 | * Use SPEED_UNFORCED for normal detection, SPEED_MAX for max value. |
|---|
| 435 | + * |
|---|
| 436 | + * Use DUPLEX_HALF or DUPLEX_FULL to force half or full duplex, |
|---|
| 437 | + * or DUPLEX_UNFORCED for normal duplex detection. |
|---|
| 377 | 438 | */ |
|---|
| 378 | | - int (*port_set_speed)(struct mv88e6xxx_chip *chip, int port, int speed); |
|---|
| 439 | + int (*port_set_speed_duplex)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 440 | + int speed, int duplex); |
|---|
| 441 | + |
|---|
| 442 | + /* What interface mode should be used for maximum speed? */ |
|---|
| 443 | + phy_interface_t (*port_max_speed_mode)(int port); |
|---|
| 379 | 444 | |
|---|
| 380 | 445 | int (*port_tag_remap)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 446 | + |
|---|
| 447 | + int (*port_set_policy)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 448 | + enum mv88e6xxx_policy_mapping mapping, |
|---|
| 449 | + enum mv88e6xxx_policy_action action); |
|---|
| 381 | 450 | |
|---|
| 382 | 451 | int (*port_set_frame_mode)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 383 | 452 | enum mv88e6xxx_frame_mode mode); |
|---|
| .. | .. |
|---|
| 393 | 462 | u8 out); |
|---|
| 394 | 463 | int (*port_disable_learn_limit)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 395 | 464 | int (*port_disable_pri_override)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 465 | + int (*port_setup_message_port)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 396 | 466 | |
|---|
| 397 | 467 | /* CMODE control what PHY mode the MAC will use, eg. SGMII, RGMII, etc. |
|---|
| 398 | 468 | * Some chips allow this to be configured on specific ports. |
|---|
| .. | .. |
|---|
| 406 | 476 | */ |
|---|
| 407 | 477 | int (*port_set_upstream_port)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 408 | 478 | int upstream_port); |
|---|
| 409 | | - /* Return the port link state, as required by phylink */ |
|---|
| 410 | | - int (*port_link_state)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 411 | | - struct phylink_link_state *state); |
|---|
| 412 | 479 | |
|---|
| 413 | 480 | /* Snapshot the statistics for a port. The statistics can then |
|---|
| 414 | 481 | * be read back a leisure but still with a consistent view. |
|---|
| .. | .. |
|---|
| 426 | 493 | int (*stats_get_stats)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 427 | 494 | uint64_t *data); |
|---|
| 428 | 495 | int (*set_cpu_port)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 429 | | - int (*set_egress_port)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 496 | + int (*set_egress_port)(struct mv88e6xxx_chip *chip, |
|---|
| 497 | + enum mv88e6xxx_egress_direction direction, |
|---|
| 498 | + int port); |
|---|
| 430 | 499 | |
|---|
| 431 | 500 | #define MV88E6XXX_CASCADE_PORT_NONE 0xe |
|---|
| 432 | 501 | #define MV88E6XXX_CASCADE_PORT_MULTIPLE 0xf |
|---|
| .. | .. |
|---|
| 438 | 507 | int (*mgmt_rsvd2cpu)(struct mv88e6xxx_chip *chip); |
|---|
| 439 | 508 | |
|---|
| 440 | 509 | /* Power on/off a SERDES interface */ |
|---|
| 441 | | - int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, bool on); |
|---|
| 510 | + int (*serdes_power)(struct mv88e6xxx_chip *chip, int port, u8 lane, |
|---|
| 511 | + bool up); |
|---|
| 512 | + |
|---|
| 513 | + /* SERDES lane mapping */ |
|---|
| 514 | + u8 (*serdes_get_lane)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 515 | + |
|---|
| 516 | + int (*serdes_pcs_get_state)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 517 | + u8 lane, struct phylink_link_state *state); |
|---|
| 518 | + int (*serdes_pcs_config)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 519 | + u8 lane, unsigned int mode, |
|---|
| 520 | + phy_interface_t interface, |
|---|
| 521 | + const unsigned long *advertise); |
|---|
| 522 | + int (*serdes_pcs_an_restart)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 523 | + u8 lane); |
|---|
| 524 | + int (*serdes_pcs_link_up)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 525 | + u8 lane, int speed, int duplex); |
|---|
| 442 | 526 | |
|---|
| 443 | 527 | /* SERDES interrupt handling */ |
|---|
| 444 | | - int (*serdes_irq_setup)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 445 | | - void (*serdes_irq_free)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 528 | + unsigned int (*serdes_irq_mapping)(struct mv88e6xxx_chip *chip, |
|---|
| 529 | + int port); |
|---|
| 530 | + int (*serdes_irq_enable)(struct mv88e6xxx_chip *chip, int port, u8 lane, |
|---|
| 531 | + bool enable); |
|---|
| 532 | + irqreturn_t (*serdes_irq_status)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 533 | + u8 lane); |
|---|
| 446 | 534 | |
|---|
| 447 | 535 | /* Statistics from the SERDES interface */ |
|---|
| 448 | 536 | int (*serdes_get_sset_count)(struct mv88e6xxx_chip *chip, int port); |
|---|
| .. | .. |
|---|
| 450 | 538 | uint8_t *data); |
|---|
| 451 | 539 | int (*serdes_get_stats)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 452 | 540 | uint64_t *data); |
|---|
| 541 | + |
|---|
| 542 | + /* SERDES registers for ethtool */ |
|---|
| 543 | + int (*serdes_get_regs_len)(struct mv88e6xxx_chip *chip, int port); |
|---|
| 544 | + void (*serdes_get_regs)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 545 | + void *_p); |
|---|
| 546 | + |
|---|
| 547 | + /* Address Translation Unit operations */ |
|---|
| 548 | + int (*atu_get_hash)(struct mv88e6xxx_chip *chip, u8 *hash); |
|---|
| 549 | + int (*atu_set_hash)(struct mv88e6xxx_chip *chip, u8 hash); |
|---|
| 453 | 550 | |
|---|
| 454 | 551 | /* VLAN Translation Unit operations */ |
|---|
| 455 | 552 | int (*vtu_getnext)(struct mv88e6xxx_chip *chip, |
|---|
| .. | .. |
|---|
| 473 | 570 | void (*phylink_validate)(struct mv88e6xxx_chip *chip, int port, |
|---|
| 474 | 571 | unsigned long *mask, |
|---|
| 475 | 572 | struct phylink_link_state *state); |
|---|
| 573 | + |
|---|
| 574 | + /* Max Frame Size */ |
|---|
| 575 | + int (*set_max_frame_size)(struct mv88e6xxx_chip *chip, int mtu); |
|---|
| 476 | 576 | }; |
|---|
| 477 | 577 | |
|---|
| 478 | 578 | struct mv88e6xxx_irq_ops { |
|---|
| .. | .. |
|---|
| 536 | 636 | int arr1_sts_reg; |
|---|
| 537 | 637 | int dep_sts_reg; |
|---|
| 538 | 638 | u32 rx_filters; |
|---|
| 639 | + u32 cc_shift; |
|---|
| 640 | + u32 cc_mult; |
|---|
| 641 | + u32 cc_mult_num; |
|---|
| 642 | + u32 cc_mult_dem; |
|---|
| 539 | 643 | }; |
|---|
| 540 | 644 | |
|---|
| 541 | 645 | #define STATS_TYPE_PORT BIT(0) |
|---|
| .. | .. |
|---|
| 559 | 663 | return chip->info->num_databases; |
|---|
| 560 | 664 | } |
|---|
| 561 | 665 | |
|---|
| 666 | +static inline unsigned int mv88e6xxx_num_macs(struct mv88e6xxx_chip *chip) |
|---|
| 667 | +{ |
|---|
| 668 | + return chip->info->num_macs; |
|---|
| 669 | +} |
|---|
| 670 | + |
|---|
| 562 | 671 | static inline unsigned int mv88e6xxx_num_ports(struct mv88e6xxx_chip *chip) |
|---|
| 563 | 672 | { |
|---|
| 564 | 673 | return chip->info->num_ports; |
|---|
| .. | .. |
|---|
| 566 | 675 | |
|---|
| 567 | 676 | static inline u16 mv88e6xxx_port_mask(struct mv88e6xxx_chip *chip) |
|---|
| 568 | 677 | { |
|---|
| 569 | | - return GENMASK(mv88e6xxx_num_ports(chip) - 1, 0); |
|---|
| 678 | + return GENMASK((s32)mv88e6xxx_num_ports(chip) - 1, 0); |
|---|
| 570 | 679 | } |
|---|
| 571 | 680 | |
|---|
| 572 | 681 | static inline unsigned int mv88e6xxx_num_gpio(struct mv88e6xxx_chip *chip) |
|---|
| .. | .. |
|---|
| 574 | 683 | return chip->info->num_gpio; |
|---|
| 575 | 684 | } |
|---|
| 576 | 685 | |
|---|
| 686 | +static inline bool mv88e6xxx_is_invalid_port(struct mv88e6xxx_chip *chip, int port) |
|---|
| 687 | +{ |
|---|
| 688 | + return (chip->info->invalid_port_mask & BIT(port)) != 0; |
|---|
| 689 | +} |
|---|
| 690 | + |
|---|
| 577 | 691 | int mv88e6xxx_read(struct mv88e6xxx_chip *chip, int addr, int reg, u16 *val); |
|---|
| 578 | 692 | int mv88e6xxx_write(struct mv88e6xxx_chip *chip, int addr, int reg, u16 val); |
|---|
| 579 | | -int mv88e6xxx_update(struct mv88e6xxx_chip *chip, int addr, int reg, |
|---|
| 580 | | - u16 update); |
|---|
| 581 | | -int mv88e6xxx_wait(struct mv88e6xxx_chip *chip, int addr, int reg, u16 mask); |
|---|
| 693 | +int mv88e6xxx_wait_mask(struct mv88e6xxx_chip *chip, int addr, int reg, |
|---|
| 694 | + u16 mask, u16 val); |
|---|
| 695 | +int mv88e6xxx_wait_bit(struct mv88e6xxx_chip *chip, int addr, int reg, |
|---|
| 696 | + int bit, int val); |
|---|
| 582 | 697 | struct mii_bus *mv88e6xxx_default_mdio_bus(struct mv88e6xxx_chip *chip); |
|---|
| 583 | 698 | |
|---|
| 699 | +static inline void mv88e6xxx_reg_lock(struct mv88e6xxx_chip *chip) |
|---|
| 700 | +{ |
|---|
| 701 | + mutex_lock(&chip->reg_lock); |
|---|
| 702 | +} |
|---|
| 703 | + |
|---|
| 704 | +static inline void mv88e6xxx_reg_unlock(struct mv88e6xxx_chip *chip) |
|---|
| 705 | +{ |
|---|
| 706 | + mutex_unlock(&chip->reg_lock); |
|---|
| 707 | +} |
|---|
| 708 | + |
|---|
| 709 | +int mv88e6xxx_fid_map(struct mv88e6xxx_chip *chip, unsigned long *bitmap); |
|---|
| 710 | + |
|---|
| 584 | 711 | #endif /* _MV88E6XXX_CHIP_H */ |
|---|