1d39a76e7Sxw /*
2d39a76e7Sxw * CDDL HEADER START
3d39a76e7Sxw *
4d39a76e7Sxw * The contents of this file are subject to the terms of the
5d39a76e7Sxw * Common Development and Distribution License (the "License").
6d39a76e7Sxw * You may not use this file except in compliance with the License.
7d39a76e7Sxw *
8d39a76e7Sxw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9d39a76e7Sxw * or http://www.opensolaris.org/os/licensing.
10d39a76e7Sxw * See the License for the specific language governing permissions
11d39a76e7Sxw * and limitations under the License.
12d39a76e7Sxw *
13d39a76e7Sxw * When distributing Covered Code, include this CDDL HEADER in each
14d39a76e7Sxw * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15d39a76e7Sxw * If applicable, add the following below this CDDL HEADER, with the
16d39a76e7Sxw * fields enclosed by brackets "[]" replaced with your own identifying
17d39a76e7Sxw * information: Portions Copyright [yyyy] [name of copyright owner]
18d39a76e7Sxw *
19d39a76e7Sxw * CDDL HEADER END
20d39a76e7Sxw */
21d39a76e7Sxw
22d39a76e7Sxw /*
23d39a76e7Sxw * Copyright (C) 2003-2005 Chelsio Communications. All rights reserved.
24d39a76e7Sxw */
25d39a76e7Sxw
26d39a76e7Sxw #include "cphy.h"
27d39a76e7Sxw #include "elmer0.h"
28d39a76e7Sxw
29d39a76e7Sxw /* ARGSUSED */
xpak_reset(struct cphy * cphy,int wait)30d39a76e7Sxw static int xpak_reset(struct cphy *cphy, int wait)
31d39a76e7Sxw {
32d39a76e7Sxw return 0;
33d39a76e7Sxw }
34d39a76e7Sxw
35d39a76e7Sxw /* ARGSUSED */
xpak_interrupt_enable(struct cphy * cphy)36d39a76e7Sxw static int xpak_interrupt_enable(struct cphy *cphy)
37d39a76e7Sxw {
38d39a76e7Sxw return 0;
39d39a76e7Sxw }
40d39a76e7Sxw
41d39a76e7Sxw /* ARGSUSED */
xpak_interrupt_disable(struct cphy * cphy)42d39a76e7Sxw static int xpak_interrupt_disable(struct cphy *cphy)
43d39a76e7Sxw {
44d39a76e7Sxw return 0;
45d39a76e7Sxw }
46d39a76e7Sxw
47d39a76e7Sxw /* ARGSUSED */
xpak_interrupt_clear(struct cphy * cphy)48d39a76e7Sxw static int xpak_interrupt_clear(struct cphy *cphy)
49d39a76e7Sxw {
50d39a76e7Sxw return 0;
51d39a76e7Sxw }
52d39a76e7Sxw
53d39a76e7Sxw /* ARGSUSED */
xpak_set_loopback(struct cphy * cphy,int on)54d39a76e7Sxw static int xpak_set_loopback(struct cphy *cphy, int on)
55d39a76e7Sxw {
56d39a76e7Sxw return 0;
57d39a76e7Sxw }
58d39a76e7Sxw
59d39a76e7Sxw /* ARGSUSED */
xpak_get_link_status(struct cphy * cphy,int * link_ok,int * speed,int * duplex,int * fc)60d39a76e7Sxw static int xpak_get_link_status(struct cphy *cphy, int *link_ok, int *speed,
61d39a76e7Sxw int *duplex, int *fc)
62d39a76e7Sxw {
63d39a76e7Sxw if (link_ok)
64d39a76e7Sxw *link_ok = 1;
65d39a76e7Sxw if (speed)
66d39a76e7Sxw *speed = SPEED_10000;
67d39a76e7Sxw if (duplex)
68d39a76e7Sxw *duplex = DUPLEX_FULL;
69d39a76e7Sxw if (fc)
70d39a76e7Sxw *fc = PAUSE_RX | PAUSE_TX;
71d39a76e7Sxw return 0;
72d39a76e7Sxw }
73d39a76e7Sxw
xpak_destroy(struct cphy * cphy)74d39a76e7Sxw static void xpak_destroy(struct cphy *cphy)
75d39a76e7Sxw {
76d39a76e7Sxw t1_os_free((void *)cphy, sizeof(*cphy));
77d39a76e7Sxw }
78d39a76e7Sxw
79d39a76e7Sxw #ifdef C99_NOT_SUPPORTED
80d39a76e7Sxw static struct cphy_ops xpak_ops = {
81d39a76e7Sxw xpak_destroy,
82d39a76e7Sxw xpak_reset,
83d39a76e7Sxw xpak_interrupt_enable,
84d39a76e7Sxw xpak_interrupt_disable,
85d39a76e7Sxw xpak_interrupt_clear,
86d39a76e7Sxw NULL,
87d39a76e7Sxw NULL,
88d39a76e7Sxw NULL,
89d39a76e7Sxw NULL,
90d39a76e7Sxw NULL,
91d39a76e7Sxw xpak_set_loopback,
92d39a76e7Sxw NULL,
93d39a76e7Sxw xpak_get_link_status,
94d39a76e7Sxw };
95d39a76e7Sxw #else
96d39a76e7Sxw static struct cphy_ops xpak_ops = {
97d39a76e7Sxw .destroy = xpak_destroy,
98d39a76e7Sxw .reset = xpak_reset,
99d39a76e7Sxw .interrupt_enable = xpak_interrupt_enable,
100d39a76e7Sxw .interrupt_disable = xpak_interrupt_disable,
101d39a76e7Sxw .interrupt_clear = xpak_interrupt_clear,
102d39a76e7Sxw .get_link_status = xpak_get_link_status,
103d39a76e7Sxw .set_loopback = xpak_set_loopback,
104d39a76e7Sxw };
105d39a76e7Sxw #endif
106d39a76e7Sxw
107d39a76e7Sxw /* ARGSUSED */
xpak_phy_create(adapter_t * adapter,int phy_addr,struct mdio_ops * mdio_ops)108d39a76e7Sxw static struct cphy *xpak_phy_create(adapter_t * adapter, int phy_addr,
109d39a76e7Sxw struct mdio_ops *mdio_ops)
110d39a76e7Sxw {
111d39a76e7Sxw struct cphy *cphy = t1_os_malloc_wait_zero(sizeof(*cphy));
112d39a76e7Sxw
113d39a76e7Sxw if (!cphy)
114d39a76e7Sxw return NULL;
115d39a76e7Sxw
116d39a76e7Sxw cphy->ops = &xpak_ops;
117d39a76e7Sxw cphy->adapter = adapter;
118d39a76e7Sxw cphy->mdio_read = mdio_ops->read;
119d39a76e7Sxw cphy->mdio_write = mdio_ops->write;
120d39a76e7Sxw return cphy;
121d39a76e7Sxw }
122d39a76e7Sxw
xpak_phy_reset(adapter_t * adapter)123d39a76e7Sxw static int xpak_phy_reset(adapter_t *adapter)
124d39a76e7Sxw {
125d39a76e7Sxw u32 val;
126d39a76e7Sxw
127d39a76e7Sxw (void) t1_tpi_read(adapter, A_ELMER0_GPO, &val);
128d39a76e7Sxw val &= ~4;
129d39a76e7Sxw (void) t1_tpi_write(adapter, A_ELMER0_GPO, val);
130d39a76e7Sxw DELAY_MS(100);
131d39a76e7Sxw
132d39a76e7Sxw /*
133d39a76e7Sxw * Errata #26 states to wait 5 seconds after reset before transceiver
134d39a76e7Sxw * becomes operational.
135d39a76e7Sxw */
136d39a76e7Sxw (void) t1_tpi_write(adapter, A_ELMER0_GPO, val | 4);
137d39a76e7Sxw DELAY_MS(5000);
138d39a76e7Sxw
139d39a76e7Sxw /* Now lets enable the Laser. Delay 100us
140d39a76e7Sxw * as defined in XPAK errata.
141d39a76e7Sxw */
142d39a76e7Sxw (void) t1_tpi_read(adapter, A_ELMER0_GPO, &val);
143d39a76e7Sxw val |= 0x8000;
144d39a76e7Sxw (void) t1_tpi_write(adapter, A_ELMER0_GPO, val);
145d39a76e7Sxw DELAY_US(100);
146d39a76e7Sxw return 0;
147d39a76e7Sxw }
148d39a76e7Sxw
149d39a76e7Sxw struct gphy t1_xpak_ops = {
150d39a76e7Sxw xpak_phy_create,
151d39a76e7Sxw xpak_phy_reset
152d39a76e7Sxw };
153*2d6eb4a5SToomas Soome
154