summaryrefslogtreecommitdiff
path: root/cleopatre/linux-2.6.25.10-spc300/drivers
diff options
context:
space:
mode:
authorsave2010-05-19 08:07:07 +0000
committersave2010-05-19 08:07:07 +0000
commit11317ee158182adf40a8c7ef2fad405c439e73ef (patch)
tree07a144d4698f7c07e9233192cb5b055c2cadf1f3 /cleopatre/linux-2.6.25.10-spc300/drivers
parent9972c8015628f221a492af370fa43b57aacf1f75 (diff)
cleo/linux/drivers/eth: add /proc for mii registers, refs #1394
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7113 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cleopatre/linux-2.6.25.10-spc300/drivers')
-rw-r--r--cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c107
1 files changed, 107 insertions, 0 deletions
diff --git a/cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c b/cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c
index a4117f7547..13e508803d 100644
--- a/cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c
+++ b/cleopatre/linux-2.6.25.10-spc300/drivers/net/arm/synop3504.c
@@ -993,6 +993,100 @@ static int synop3504_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
}// synop3504_ioctl
/**
+ * Read the PHY MII registers by /proc.
+ *
+ * \param file file structure.
+ * \param buffer string pointer given by user.
+ * \param start string pointer begin.
+ * \param offset offset value.
+ * \param count count parameter.
+ * \param eof end of file.
+ * \param data network device structure.
+ * \return new pointer position.
+ */
+static int synop3504_readproc_mii(char *buf, char **start, off_t offset, int count, int *eof, void *data)
+{
+ int phy_begin, phy_end, phy_addr;
+ struct net_device *dev = (struct net_device *)data;
+ struct net_priv *priv = dev->priv;
+ int reg;
+ uint16_t val;
+ char *p;
+
+ p = buf;
+
+ if((priv->phy_oui == OUI_ICPLUS) && (priv->phy_model == ICPLUS_MODEL_IP175))
+ {
+ phy_begin = 0;
+ phy_end = 5;
+ }
+ else
+ {
+ phy_begin = priv->phy_addr;
+ phy_end = priv->phy_addr;
+ }
+
+ for(phy_addr=phy_begin ; phy_addr<=phy_end ; phy_addr++)
+ {
+ for(reg=0 ; reg<=31 ; reg++)
+ {
+ val = mdio_read(dev, phy_addr, reg);
+ p += sprintf(p, "PHY%d REG%-2d 0x%04x\n", phy_addr, reg, val);
+ }
+ }
+
+ if((priv->phy_oui == OUI_ICPLUS) && (priv->phy_model == ICPLUS_MODEL_IP175))
+ {
+ for(phy_addr=20 ; phy_addr<=26 ; phy_addr++)
+ {
+ p += sprintf(p,"\n");
+ for(reg=0 ; reg<=31 ; reg++)
+ {
+ val = mdio_read(dev, phy_addr, reg);
+ p += sprintf(p, "PHY%d REG%-2d 0x%04x\n", phy_addr, reg, val);
+ }
+ }
+ for(phy_addr=29 ; phy_addr<=31 ; phy_addr++)
+ {
+ p += sprintf(p,"\n");
+ for(reg=0 ; reg<=31 ; reg++)
+ {
+ val = mdio_read(dev, phy_addr, reg);
+ p += sprintf(p, "PHY%d REG%-2d 0x%04x\n", phy_addr, reg, val);
+ }
+ }
+ }
+
+ *eof = 1;
+ return p-buf+1;
+}
+
+/**
+ * Write into PHY MII registers by /proc.
+ *
+ * \param file file structure.
+ * \param buffer string pointer given by user.
+ * \param count count parameter.
+ * \param data network device structure.
+ * \return counter value.
+ */
+static int synop3504_writeproc_mii(struct file *file, const char *buffer, unsigned long count, void *data)
+{
+ struct net_device *dev = (struct net_device *)data;
+ unsigned int reg;
+ int value;
+ int phy;
+
+ if(sscanf(buffer,"PHY%d REG%u %i",&phy, &reg, &value) == 3)
+ {
+ mdio_write(dev, phy, reg, value);
+ printk("Sent PHY%d REG%d 0x%04x\n", phy, reg, value);
+ }
+
+ return count;
+}
+
+/**
* transmit frame procedure.
* \param skb frame structure.
* \param dev device structure.
@@ -1643,6 +1737,8 @@ static int __init synop3504_module_probe(struct platform_device *pdev)
struct net_device *dev = NULL;
struct net_priv *priv;
struct synop3504_platform_data *pdata;
+ struct proc_dir_entry *eth_dir;
+ struct proc_dir_entry *entry;
printk("%s", version);
@@ -1727,6 +1823,13 @@ static int __init synop3504_module_probe(struct platform_device *pdev)
goto err_out_free_dev;
}
+ //Create a proc entry for MII
+ eth_dir = proc_mkdir("eth", init_net.proc_net);
+ entry = create_proc_entry("mii", 0, eth_dir);
+ entry->read_proc = synop3504_readproc_mii;
+ entry->write_proc = synop3504_writeproc_mii;
+ entry->data = (int*)dev;
+
platform_set_drvdata(pdev, dev);
return 0;
@@ -1765,6 +1868,10 @@ static void __exit synop3504_module_remove(struct platform_device *pdev)
//Freeing network device
free_netdev(dev);
+ //Remove proc
+ remove_proc_entry("eth/mii", init_net.proc_net);
+ remove_proc_entry("eth", init_net.proc_net);
+
//Erase driver data informations
platform_set_drvdata(pdev, NULL);
}