6 #include <linux/module.h>
8 #include <linux/errno.h>
9 #include <linux/atmdev.h>
10 #include <linux/sonet.h>
12 #include <linux/slab.h>
13 #include <asm/uaccess.h>
20 #define DPRINTK(format,args...) printk(KERN_DEBUG format,##args)
22 #define DPRINTK(format,args...)
34 #define PRIV(dev) ((struct uPD98402_priv *) dev->phy_data)
36 #define PUT(val,reg) dev->ops->phy_put(dev,val,uPD98402_##reg)
37 #define GET(reg) dev->ops->phy_get(dev,uPD98402_##reg)
51 tmp.corr_hcs = tmp.tx_cells = tmp.rx_cells = 0;
54 return error ? -
EFAULT : 0;
58 static int set_framing(
struct atm_dev *
dev,
unsigned char framing)
60 static const unsigned char sonet[] = { 1,2,3,0 };
61 static const unsigned char sdh[] = { 1,0,0,2 };
81 spin_unlock_irqrestore(&
PRIV(dev)->lock, flags);
95 spin_unlock_irqrestore(&
PRIV(dev)->lock, flags);
102 static int set_loopback(
struct atm_dev *dev,
int mode)
104 unsigned char mode_reg;
135 static int uPD98402_ioctl(
struct atm_dev *dev,
unsigned int cmd,
void __user *arg)
143 return set_framing(dev, (
int)(
unsigned long)arg);
148 return get_sense(dev,arg);
150 return set_loopback(dev, (
int)(
unsigned long)arg);
152 return put_user(
PRIV(dev)->loop_mode,(
int __user *)arg) ?
163 #define ADD_LIMITED(s,v) \
164 { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
165 if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
166 atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
169 static void stat_event(
struct atm_dev *dev)
185 static void uPD98402_int(
struct atm_dev *dev)
187 static unsigned long silence = 0;
201 (
time_after(jiffies, silence) || silence == 0)) {
210 static int uPD98402_start(
struct atm_dev *dev)
223 uPD98402_INT_LOS),PIMR);
232 static int uPD98402_stop(
struct atm_dev *dev)
240 static const struct atmphy_ops uPD98402_ops = {
241 .start = uPD98402_start,
242 .ioctl = uPD98402_ioctl,
243 .interrupt = uPD98402_int,
244 .stop = uPD98402_stop,
251 dev->
phy = &uPD98402_ops;
260 static __init int uPD98402_module_init(
void)