Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v2.6.20-rc2 177 lines 3.9 kB view raw
1/* 2 * drivers/net/phy/lxt.c 3 * 4 * Driver for Intel LXT PHYs 5 * 6 * Author: Andy Fleming 7 * 8 * Copyright (c) 2004 Freescale Semiconductor, Inc. 9 * 10 * This program is free software; you can redistribute it and/or modify it 11 * under the terms of the GNU General Public License as published by the 12 * Free Software Foundation; either version 2 of the License, or (at your 13 * option) any later version. 14 * 15 */ 16#include <linux/kernel.h> 17#include <linux/sched.h> 18#include <linux/string.h> 19#include <linux/errno.h> 20#include <linux/unistd.h> 21#include <linux/slab.h> 22#include <linux/interrupt.h> 23#include <linux/init.h> 24#include <linux/delay.h> 25#include <linux/netdevice.h> 26#include <linux/etherdevice.h> 27#include <linux/skbuff.h> 28#include <linux/spinlock.h> 29#include <linux/mm.h> 30#include <linux/module.h> 31#include <linux/mii.h> 32#include <linux/ethtool.h> 33#include <linux/phy.h> 34 35#include <asm/io.h> 36#include <asm/irq.h> 37#include <asm/uaccess.h> 38 39/* The Level one LXT970 is used by many boards */ 40 41#define MII_LXT970_IER 17 /* Interrupt Enable Register */ 42 43#define MII_LXT970_IER_IEN 0x0002 44 45#define MII_LXT970_ISR 18 /* Interrupt Status Register */ 46 47#define MII_LXT970_CONFIG 19 /* Configuration Register */ 48 49/* ------------------------------------------------------------------------- */ 50/* The Level one LXT971 is used on some of my custom boards */ 51 52/* register definitions for the 971 */ 53#define MII_LXT971_IER 18 /* Interrupt Enable Register */ 54#define MII_LXT971_IER_IEN 0x00f2 55 56#define MII_LXT971_ISR 19 /* Interrupt Status Register */ 57 58 59MODULE_DESCRIPTION("Intel LXT PHY driver"); 60MODULE_AUTHOR("Andy Fleming"); 61MODULE_LICENSE("GPL"); 62 63static int lxt970_ack_interrupt(struct phy_device *phydev) 64{ 65 int err; 66 67 err = phy_read(phydev, MII_BMSR); 68 69 if (err < 0) 70 return err; 71 72 err = phy_read(phydev, MII_LXT970_ISR); 73 74 if (err < 0) 75 return err; 76 77 return 0; 78} 79 80static int lxt970_config_intr(struct phy_device *phydev) 81{ 82 int err; 83 84 if(phydev->interrupts == PHY_INTERRUPT_ENABLED) 85 err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN); 86 else 87 err = phy_write(phydev, MII_LXT970_IER, 0); 88 89 return err; 90} 91 92static int lxt970_config_init(struct phy_device *phydev) 93{ 94 int err; 95 96 err = phy_write(phydev, MII_LXT970_CONFIG, 0); 97 98 return err; 99} 100 101 102static int lxt971_ack_interrupt(struct phy_device *phydev) 103{ 104 int err = phy_read(phydev, MII_LXT971_ISR); 105 106 if (err < 0) 107 return err; 108 109 return 0; 110} 111 112static int lxt971_config_intr(struct phy_device *phydev) 113{ 114 int err; 115 116 if(phydev->interrupts == PHY_INTERRUPT_ENABLED) 117 err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN); 118 else 119 err = phy_write(phydev, MII_LXT971_IER, 0); 120 121 return err; 122} 123 124static struct phy_driver lxt970_driver = { 125 .phy_id = 0x78100000, 126 .name = "LXT970", 127 .phy_id_mask = 0xfffffff0, 128 .features = PHY_BASIC_FEATURES, 129 .flags = PHY_HAS_INTERRUPT, 130 .config_init = lxt970_config_init, 131 .config_aneg = genphy_config_aneg, 132 .read_status = genphy_read_status, 133 .ack_interrupt = lxt970_ack_interrupt, 134 .config_intr = lxt970_config_intr, 135 .driver = { .owner = THIS_MODULE,}, 136}; 137 138static struct phy_driver lxt971_driver = { 139 .phy_id = 0x001378e0, 140 .name = "LXT971", 141 .phy_id_mask = 0xfffffff0, 142 .features = PHY_BASIC_FEATURES, 143 .flags = PHY_HAS_INTERRUPT, 144 .config_aneg = genphy_config_aneg, 145 .read_status = genphy_read_status, 146 .ack_interrupt = lxt971_ack_interrupt, 147 .config_intr = lxt971_config_intr, 148 .driver = { .owner = THIS_MODULE,}, 149}; 150 151static int __init lxt_init(void) 152{ 153 int ret; 154 155 ret = phy_driver_register(&lxt970_driver); 156 if (ret) 157 goto err1; 158 159 ret = phy_driver_register(&lxt971_driver); 160 if (ret) 161 goto err2; 162 return 0; 163 164 err2: 165 phy_driver_unregister(&lxt970_driver); 166 err1: 167 return ret; 168} 169 170static void __exit lxt_exit(void) 171{ 172 phy_driver_unregister(&lxt970_driver); 173 phy_driver_unregister(&lxt971_driver); 174} 175 176module_init(lxt_init); 177module_exit(lxt_exit);