d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * CDDL HEADER START
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * The contents of this file are subject to the terms of the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Common Development and Distribution License (the "License").
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * You may not use this file except in compliance with the License.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * or http://www.opensolaris.org/os/licensing.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * See the License for the specific language governing permissions
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * and limitations under the License.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * When distributing Covered Code, include this CDDL HEADER in each
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * If applicable, add the following below this CDDL HEADER, with the
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * fields enclosed by brackets "[]" replaced with your own identifying
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * information: Portions Copyright [yyyy] [name of copyright owner]
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw *
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * CDDL HEADER END
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#pragma ident "%Z%%M% %I% %E% SMI" /* cphy.h */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#ifndef CHELSIO_CPHY_H
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#define CHELSIO_CPHY_H
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#include "common.h"
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstruct mdio_ops {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw void (*init)(adapter_t *adapter, const struct board_info *bi);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*read)(adapter_t *adapter, int phy_addr, int mmd_addr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int reg_addr, unsigned int *val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*write)(adapter_t *adapter, int phy_addr, int mmd_addr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int reg_addr, unsigned int val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* PHY interrupt types */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwenum {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cphy_cause_link_change = 0x1,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw cphy_cause_error = 0x2
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwenum {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PHY_LINK_UP = 0x1,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PHY_AUTONEG_RDY = 0x2,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw PHY_AUTONEG_EN = 0x4
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstruct cphy;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* PHY operations */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstruct cphy_ops {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw void (*destroy)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*reset)(struct cphy *, int wait);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*interrupt_enable)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*interrupt_disable)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*interrupt_clear)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*interrupt_handler)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*autoneg_enable)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*autoneg_disable)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*autoneg_restart)(struct cphy *);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*advertise)(struct cphy *phy, unsigned int advertise_map);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*set_loopback)(struct cphy *, int on);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*set_speed_duplex)(struct cphy *phy, int speed, int duplex);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*get_link_status)(struct cphy *phy, int *link_ok, int *speed,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int *duplex, int *fc);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* A PHY instance */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstruct cphy {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int addr; /* PHY address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int state; /* Link status state machine */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw adapter_t *adapter; /* associated adapter */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw ch_cyclic_t phy_update_cyclic;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw u16 bmsr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int count;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int act_count;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int act_on;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw u32 elmer_gpo;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct cphy_ops *ops; /* PHY operations */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*mdio_read)(adapter_t *adapter, int phy_addr, int mmd_addr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int reg_addr, unsigned int *val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*mdio_write)(adapter_t *adapter, int phy_addr, int mmd_addr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int reg_addr, unsigned int val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct cphy_instance *instance;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* Convenience MDIO read/write wrappers */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic inline int mdio_read(struct cphy *cphy, int mmd, int reg,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw unsigned int *valp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return cphy->mdio_read(cphy->adapter, cphy->addr, mmd, reg, valp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic inline int mdio_write(struct cphy *cphy, int mmd, int reg,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw unsigned int val)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return cphy->mdio_write(cphy->adapter, cphy->addr, mmd, reg, val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic inline int simple_mdio_read(struct cphy *cphy, int reg,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw unsigned int *valp)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return mdio_read(cphy, 0, reg, valp);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic inline int simple_mdio_write(struct cphy *cphy, int reg,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw unsigned int val)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw return mdio_write(cphy, 0, reg, val);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* Convenience initializer */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstatic inline void cphy_init(struct cphy *phy, adapter_t *adapter,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int phy_addr, struct cphy_ops *phy_ops,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct mdio_ops *mdio_ops)
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw{
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw phy->adapter = adapter;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw phy->addr = phy_addr;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw phy->ops = phy_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw if (mdio_ops) {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw phy->mdio_read = mdio_ops->read;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw phy->mdio_write = mdio_ops->write;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw }
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw}
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw/* Operations of the PHY-instance factory */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwstruct gphy {
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /* Construct a PHY instance with the given PHY address */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct cphy *(*create)(adapter_t *adapter, int phy_addr,
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw struct mdio_ops *mdio_ops);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw /*
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * Reset the PHY chip. This resets the whole PHY chip, not individual
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw * ports.
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw */
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw int (*reset)(adapter_t *adapter);
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw};
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwextern struct gphy t1_my3126_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwextern struct gphy t1_mv88e1xxx_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwextern struct gphy t1_xpak_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwextern struct gphy t1_mv88x201x_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xwextern struct gphy t1_dummy_phy_ops;
d39a76e7b087a3d0927cbe6898dc0a6770fa6c68xw#endif