Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * net/dsa/mv88e6xxx.h - 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 | |
| 11 | #ifndef __MV88E6XXX_H |
| 12 | #define __MV88E6XXX_H |
| 13 | |
| 14 | #define REG_PORT(p) (0x10 + (p)) |
| 15 | #define REG_GLOBAL 0x1b |
| 16 | #define REG_GLOBAL2 0x1c |
| 17 | |
| 18 | struct mv88e6xxx_priv_state { |
| 19 | /* |
| 20 | * When using multi-chip addressing, this mutex protects |
| 21 | * access to the indirect access registers. (In single-chip |
| 22 | * mode, this mutex is effectively useless.) |
| 23 | */ |
| 24 | struct mutex smi_mutex; |
| 25 | |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 26 | #ifdef CONFIG_NET_DSA_MV88E6XXX_NEED_PPU |
| 27 | /* |
| 28 | * Handles automatic disabling and re-enabling of the PHY |
| 29 | * polling unit. |
| 30 | */ |
| 31 | struct mutex ppu_mutex; |
| 32 | int ppu_disabled; |
| 33 | struct work_struct ppu_work; |
| 34 | struct timer_list ppu_timer; |
| 35 | #endif |
| 36 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 37 | /* |
| 38 | * This mutex serialises access to the statistics unit. |
| 39 | * Hold this mutex over snapshot + dump sequences. |
| 40 | */ |
| 41 | struct mutex stats_mutex; |
Peter Korsgaard | ec80bfc | 2011-04-05 03:03:56 +0000 | [diff] [blame] | 42 | |
| 43 | int id; /* switch product id */ |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct mv88e6xxx_hw_stat { |
| 47 | char string[ETH_GSTRING_LEN]; |
| 48 | int sizeof_stat; |
| 49 | int reg; |
| 50 | }; |
| 51 | |
| 52 | int __mv88e6xxx_reg_read(struct mii_bus *bus, int sw_addr, int addr, int reg); |
| 53 | int mv88e6xxx_reg_read(struct dsa_switch *ds, int addr, int reg); |
| 54 | int __mv88e6xxx_reg_write(struct mii_bus *bus, int sw_addr, int addr, |
| 55 | int reg, u16 val); |
| 56 | int mv88e6xxx_reg_write(struct dsa_switch *ds, int addr, int reg, u16 val); |
| 57 | int mv88e6xxx_config_prio(struct dsa_switch *ds); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 58 | int mv88e6xxx_set_addr_direct(struct dsa_switch *ds, u8 *addr); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 59 | int mv88e6xxx_set_addr_indirect(struct dsa_switch *ds, u8 *addr); |
| 60 | int mv88e6xxx_phy_read(struct dsa_switch *ds, int addr, int regnum); |
| 61 | int mv88e6xxx_phy_write(struct dsa_switch *ds, int addr, int regnum, u16 val); |
Lennert Buytenhek | 2e5f032 | 2008-10-07 13:45:18 +0000 | [diff] [blame] | 62 | void mv88e6xxx_ppu_state_init(struct dsa_switch *ds); |
| 63 | int mv88e6xxx_phy_read_ppu(struct dsa_switch *ds, int addr, int regnum); |
| 64 | int mv88e6xxx_phy_write_ppu(struct dsa_switch *ds, int addr, |
| 65 | int regnum, u16 val); |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 66 | void mv88e6xxx_poll_link(struct dsa_switch *ds); |
| 67 | void mv88e6xxx_get_strings(struct dsa_switch *ds, |
| 68 | int nr_stats, struct mv88e6xxx_hw_stat *stats, |
| 69 | int port, uint8_t *data); |
| 70 | void mv88e6xxx_get_ethtool_stats(struct dsa_switch *ds, |
| 71 | int nr_stats, struct mv88e6xxx_hw_stat *stats, |
| 72 | int port, uint64_t *data); |
| 73 | |
Ben Hutchings | 98e6730 | 2011-11-25 14:36:19 +0000 | [diff] [blame] | 74 | extern struct dsa_switch_driver mv88e6131_switch_driver; |
| 75 | extern struct dsa_switch_driver mv88e6123_61_65_switch_driver; |
| 76 | |
Lennert Buytenhek | 91da11f | 2008-10-07 13:44:02 +0000 | [diff] [blame] | 77 | #define REG_READ(addr, reg) \ |
| 78 | ({ \ |
| 79 | int __ret; \ |
| 80 | \ |
| 81 | __ret = mv88e6xxx_reg_read(ds, addr, reg); \ |
| 82 | if (__ret < 0) \ |
| 83 | return __ret; \ |
| 84 | __ret; \ |
| 85 | }) |
| 86 | |
| 87 | #define REG_WRITE(addr, reg, val) \ |
| 88 | ({ \ |
| 89 | int __ret; \ |
| 90 | \ |
| 91 | __ret = mv88e6xxx_reg_write(ds, addr, reg, val); \ |
| 92 | if (__ret < 0) \ |
| 93 | return __ret; \ |
| 94 | }) |
| 95 | |
| 96 | |
| 97 | |
| 98 | #endif |