summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dufour2013-04-11 10:48:06 +0200
committerOlivier Dufour2013-04-11 15:44:06 +0200
commit0f57407d245d93d25da94a6299ac2230724c9531 (patch)
tree6df5885d52ba52f9a08873f53fc3e470c08c46c4
parentbbb68e8f911504eb150f2a90261d8e9f1e5ba9ed (diff)
polux/linux: add support of eth2 in linux, closes #3887
-rw-r--r--polux/linux-2.6.10/arch/arm/mach-mse500/core.c1
-rw-r--r--polux/linux-2.6.10/drivers/net/synop3504/synop3504.c74
-rw-r--r--polux/package/initramfs/root/etc/init.d/bridge6
3 files changed, 57 insertions, 24 deletions
diff --git a/polux/linux-2.6.10/arch/arm/mach-mse500/core.c b/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
index e2508abd0f..77c9dee427 100644
--- a/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
+++ b/polux/linux-2.6.10/arch/arm/mach-mse500/core.c
@@ -330,6 +330,7 @@ void __init mse500_init_irq(void)
/* max priority=15 and min priority=0 */
set_irq_priority(INT_ETH, INT_PRIO_ETH);
+ set_irq_priority(INT_ETH2, INT_PRIO_ETH);
set_irq_priority(INT_TIMER_1, INT_PRIO_TIMER_1);
set_irq_priority(INT_TIMER_2, INT_PRIO_TIMER_2);
set_irq_priority(PLC_INT__RX_END, INT_PRIO_SPC200_PLC_RX_END);
diff --git a/polux/linux-2.6.10/drivers/net/synop3504/synop3504.c b/polux/linux-2.6.10/drivers/net/synop3504/synop3504.c
index 4ccbc5cc14..871a79ada2 100644
--- a/polux/linux-2.6.10/drivers/net/synop3504/synop3504.c
+++ b/polux/linux-2.6.10/drivers/net/synop3504/synop3504.c
@@ -2279,7 +2279,7 @@ synop3504_readproc_phy_model (char *buf, char **start, off_t offset,
#endif
-static struct net_device *_device;
+static struct net_device *_device[2];
/**
* Function : synop3504_priv_init
@@ -2315,20 +2315,18 @@ synop3504_priv_init (Private *pr, uint32_t macid)
}
/**
- * Function : synop3504_eth_init
- * Purpose : Initialize the module.
- * parameters : void
+ * Function : synop3504_single_port_init
+ * Purpose : Initialize a device on the given mac id
+ * parameters : MAC id
* return value : error code.
*/
static int
-synop3504_eth_init (void)
+synop3504_single_port_init (uint32_t macid)
{
- int result;
Private *pr;
+ int result;
struct net_device *dev;
- printk ("%s", version);
-
dev = alloc_etherdev (sizeof (Private));
if (NULL == dev)
{
@@ -2336,9 +2334,8 @@ synop3504_eth_init (void)
}
/* Initialize private data */
pr = (Private *) dev->priv;
- if (-1 == synop3504_priv_init (pr, 1))
+ if (-1 == synop3504_priv_init (pr, macid))
return -1;
-
dev->init = synop3504_init;
SET_MODULE_OWNER (dev);
@@ -2350,21 +2347,23 @@ synop3504_eth_init (void)
pr->minor);
kfree (dev->priv);
free_netdev (dev);
+ return result;
}
else
{
- _device = dev;
+ _device[macid - 1] = dev;
}
-
#ifdef CONFIG_PROC_FS
{
struct proc_dir_entry *eth_dir;
struct proc_dir_entry *regs_dir;
struct proc_dir_entry *entry;
struct proc_dir_entry *internals_dir;
+ char directory[8];
- eth_dir = proc_mkdir ("eth", proc_net);
+ sprintf (directory, "eth%d", macid - 1);
+ eth_dir = proc_mkdir (directory, proc_net);
create_proc_read_entry ("stats", 0, eth_dir, synop3504_readproc_stats,
dev);
create_proc_read_entry ("phy_model", 0, eth_dir,
@@ -2379,6 +2378,31 @@ synop3504_eth_init (void)
entry->data = (int *) dev;
}
#endif
+
+ return result;
+}
+
+/**
+ * Function : synop3504_eth_init
+ * Purpose : Initialize the module.
+ * parameters : void
+ * return value : error code.
+ */
+static int
+synop3504_eth_init (void)
+{
+ int result = -1;
+
+ printk ("%s", version);
+ result = synop3504_single_port_init (1);
+ if (result != 0)
+ return result;
+
+ if (NVRAM_BFEXT(ETH2_DISABLE, spidcom_nvram.pkg_cfg) == NVRAM_ETH2_ENABLED)
+ {
+ return synop3504_single_port_init (2);
+ }
+
return result;
}
@@ -2391,20 +2415,24 @@ synop3504_eth_init (void)
static void
synop3504_eth_exit (void)
{
- Private *pr = _device->priv;
- int minor = pr->minor;
+ Private *pr;
+ int i;
- if (_device)
+ for (i = 0; i < 2; i++)
{
- //Freeing private field of the net device struture
- if (pr)
- kfree (pr);
+ if (_device[i])
+ {
+ pr = _device[i]->priv;
+ //Freeing private field of the net device struture
+ if (pr)
+ kfree (pr);
- //Freeing network device
- free_netdev (_device);
+ //Freeing network device
+ free_netdev (_device[i]);
- //Unregister net device
- unregister_netdev (_device);
+ //Unregister net device
+ unregister_netdev (_device[i]);
+ }
}
}
diff --git a/polux/package/initramfs/root/etc/init.d/bridge b/polux/package/initramfs/root/etc/init.d/bridge
index 9cba9209b1..9886c18da4 100644
--- a/polux/package/initramfs/root/etc/init.d/bridge
+++ b/polux/package/initramfs/root/etc/init.d/bridge
@@ -9,7 +9,7 @@ case "$1" in
# Check that bridge service is up.
grep " *BRIDGING *= *no" /etc/config/network && exit 0
[ -d /proc/net/plc ] || exit 0
- [ -d /proc/net/eth ] || exit 0
+ [ -d /proc/net/eth0 ] || exit 0
if [ "$EXIST" = "0" ]
then
@@ -19,9 +19,11 @@ case "$1" in
echo "Mounting Bridge interface...."
ifconfig plc0 0.0.0.0
ifconfig eth0 0.0.0.0
+ [ -d /proc/net/eth1 ] && ifconfig eth1 0.0.0.0
brctl addbr br0
brctl addif br0 plc0
brctl addif br0 eth0
+ [ -d /proc/net/eth1 ] && brctl addif br0 eth1
brctl setfd br0 0
ifup br0
brctl setfd br0 0
@@ -37,9 +39,11 @@ case "$1" in
ifdown br0
brctl delif br0 plc0
brctl delif br0 eth0
+ [ -d /proc/net/eth1 ] && brctl delif br0 eth1
brctl delbr br0
echo > /var/run/ifstate
ifup eth0
+ [ -d /proc/net/eth1 ] && ifup eth1
ifup plc0
;;
restart)