75 #define AEL2005_MODDET_IRQ 4
84 static int set_phy_regs(
struct cphy *
phy,
const struct reg_val *rv)
100 static void ael100x_txon(
struct cphy *
phy)
113 static int ael_i2c_rd(
struct cphy *
phy,
int dev_addr,
int word_addr)
119 (dev_addr << 8) | (1 << 8) | word_addr);
123 for (i = 0; i < 200; i++) {
128 if ((stat & 3) == 1) {
136 CH_WARN(phy->
adapter,
"PHY %u i2c read of dev.addr %#x.%#x timed out\n",
137 phy->
mdio.prtad, dev_addr, word_addr);
141 static int ael1002_power_down(
struct cphy *phy,
int enable)
153 static int ael1002_reset(
struct cphy *phy,
int wait)
157 if ((err = ael1002_power_down(phy, 0)) ||
168 static int ael1002_intr_noop(
struct cphy *phy)
176 static int get_link_status_r(
struct cphy *phy,
int *link_ok,
int *speed,
180 unsigned int stat0, stat1, stat2;
192 *link_ok = (stat0 & stat1 & (stat2 >> 12)) & 1;
201 static struct cphy_ops ael1002_ops = {
202 .reset = ael1002_reset,
203 .intr_enable = ael1002_intr_noop,
204 .intr_disable = ael1002_intr_noop,
205 .intr_clear = ael1002_intr_noop,
206 .intr_handler = ael1002_intr_noop,
207 .get_link_status = get_link_status_r,
208 .power_down = ael1002_power_down,
215 cphy_init(phy, adapter, phy_addr, &ael1002_ops, mdio_ops,
222 static int ael1006_reset(
struct cphy *phy,
int wait)
227 static struct cphy_ops ael1006_ops = {
228 .reset = ael1006_reset,
233 .get_link_status = get_link_status_r,
234 .power_down = ael1002_power_down,
241 cphy_init(phy, adapter, phy_addr, &ael1006_ops, mdio_ops,
251 static int ael2xxx_get_module_type(
struct cphy *phy,
int delay_ms)
293 static int ael2005_setup_sr_edc(
struct cphy *phy)
304 err = set_phy_regs(phy, regs);
325 static int ael2005_setup_twinax_edc(
struct cphy *phy,
int modtype)
327 static const struct reg_val regs[] = {
338 err = set_phy_regs(phy, regs);
340 err = set_phy_regs(phy, preemphasis);
361 static int ael2005_get_module_type(
struct cphy *phy,
int delay_ms)
373 return ael2xxx_get_module_type(phy, delay_ms);
376 static int ael2005_intr_enable(
struct cphy *phy)
382 static int ael2005_intr_disable(
struct cphy *phy)
388 static int ael2005_intr_clear(
struct cphy *phy)
394 static int ael2005_reset(
struct cphy *phy,
int wait)
396 static const struct reg_val regs0[] = {
406 static const struct reg_val regs1[] = {
413 unsigned int lasi_ctrl;
426 err = set_phy_regs(phy, regs0);
432 err = ael2005_get_module_type(phy, 0);
438 err = ael2005_setup_twinax_edc(phy, err);
440 err = ael2005_setup_sr_edc(phy);
444 err = set_phy_regs(phy, regs1);
450 err = ael2005_intr_enable(phy);
454 static int ael2005_intr_handler(
struct cphy *phy)
470 ret = ael2005_get_module_type(phy, 300);
476 edc_needed = phy->
priv;
483 if (edc_needed != phy->
priv) {
484 ret = ael2005_reset(phy, 0);
498 static struct cphy_ops ael2005_ops = {
499 .reset = ael2005_reset,
500 .intr_enable = ael2005_intr_enable,
501 .intr_disable = ael2005_intr_disable,
502 .intr_clear = ael2005_intr_clear,
503 .intr_handler = ael2005_intr_handler,
504 .get_link_status = get_link_status_r,
505 .power_down = ael1002_power_down,
512 cphy_init(phy, adapter, phy_addr, &ael2005_ops, mdio_ops,
523 static int ael2020_setup_sr_edc(
struct cphy *phy)
525 static const struct reg_val regs[] = {
539 err = set_phy_regs(phy, regs);
551 static int ael2020_setup_twinax_edc(
struct cphy *phy,
int modtype)
554 static const struct reg_val uCclock40MHz[] = {
561 static const struct reg_val uCclockActivate[] = {
567 static const struct reg_val uCactivate[] = {
575 err = set_phy_regs(phy, uCclock40MHz);
579 err = set_phy_regs(phy, uCclockActivate);
595 err = set_phy_regs(phy, uCactivate);
604 static int ael2020_get_module_type(
struct cphy *phy,
int delay_ms)
618 return ael2xxx_get_module_type(phy, delay_ms);
625 static int ael2020_intr_enable(
struct cphy *phy)
627 static const struct reg_val regs[] = {
641 int err, link_ok = 0;
644 err = set_phy_regs(phy, regs);
648 err = get_link_status_r(phy, &link_ok,
NULL,
NULL,
NULL);
665 static int ael2020_intr_disable(
struct cphy *phy)
667 static const struct reg_val regs[] = {
682 err = set_phy_regs(phy, regs);
692 static int ael2020_intr_clear(
struct cphy *phy)
704 static const struct reg_val ael2020_reset_regs[] = {
722 static int ael2020_reset(
struct cphy *phy,
int wait)
725 unsigned int lasi_ctrl;
740 err = set_phy_regs(phy, ael2020_reset_regs);
745 err = ael2020_get_module_type(phy, 0);
750 err = ael2020_setup_twinax_edc(phy, err);
752 err = ael2020_setup_sr_edc(phy);
758 err = ael2005_intr_enable(phy);
765 static int ael2020_intr_handler(
struct cphy *phy)
768 int ret, edc_needed, cause = 0;
776 ret = ael2020_get_module_type(phy, 300);
782 edc_needed = phy->
priv;
789 if (edc_needed != phy->
priv) {
790 ret = ael2020_reset(phy, 0);
804 static struct cphy_ops ael2020_ops = {
805 .reset = ael2020_reset,
806 .intr_enable = ael2020_intr_enable,
807 .intr_disable = ael2020_intr_disable,
808 .intr_clear = ael2020_intr_clear,
809 .intr_handler = ael2020_intr_handler,
810 .get_link_status = get_link_status_r,
811 .power_down = ael1002_power_down,
820 cphy_init(phy, adapter, phy_addr, &ael2020_ops, mdio_ops,
825 err = set_phy_regs(phy, ael2020_reset_regs);
834 static int get_link_status_x(
struct cphy *phy,
int *link_ok,
int *speed,
835 int *duplex,
int *fc)
838 unsigned int stat0, stat1, stat2;
850 *link_ok = (stat0 & (stat1 >> 12) & (stat2 >> 12)) & 1;
859 static struct cphy_ops qt2045_ops = {
860 .reset = ael1006_reset,
865 .get_link_status = get_link_status_x,
866 .power_down = ael1002_power_down,
875 cphy_init(phy, adapter, phy_addr, &qt2045_ops, mdio_ops,
890 static int xaui_direct_reset(
struct cphy *phy,
int wait)
895 static int xaui_direct_get_link_status(
struct cphy *phy,
int *link_ok,
896 int *speed,
int *duplex,
int *fc)
900 int prtad = phy->
mdio.prtad;
902 status = t3_read_reg(phy->
adapter,
919 static int xaui_direct_power_down(
struct cphy *phy,
int enable)
924 static struct cphy_ops xaui_direct_ops = {
925 .reset = xaui_direct_reset,
926 .intr_enable = ael1002_intr_noop,
927 .intr_disable = ael1002_intr_noop,
928 .intr_clear = ael1002_intr_noop,
929 .intr_handler = ael1002_intr_noop,
930 .get_link_status = xaui_direct_get_link_status,
931 .power_down = xaui_direct_power_down,
937 cphy_init(phy, adapter, phy_addr, &xaui_direct_ops, mdio_ops,