History log of /drivers/net/ethernet/ti/cpsw.c
Revision Date Author Comments
35717d8d6fc6fc50692273d6667a0a575c26aa93 14-Nov-2014 John Ogness <john.ogness@linutronix.de> drivers: net: cpsw: Fix TX_IN_SEL offset

The TX_IN_SEL offset for the CPSW_PORT/TX_IN_CTL register was
incorrect. This caused the Dual MAC mode to never get set when
it should. It also caused possible unintentional setting of a
bit in the CPSW_PORT/TX_BLKS_REM register.

The purpose of setting the Dual MAC mode for this register is to:

"... allow packets from both ethernet ports to be written into
the FIFO without one port starving the other port."
- AM335x ARM TRM

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1e5c4bc497c0a96e1ad2974539d353870f2cb0b6 31-Oct-2014 Lennart Sorensen <lsorense@csclub.uwaterloo.ca> drivers: net: cpsw: Support ALLMULTI and fix IFF_PROMISC in switch mode

The cpsw driver did not support the IFF_ALLMULTI flag which makes dynamic
multicast routing not work. Related to this, when enabling IFF_PROMISC
in switch mode, all registered multicast addresses are flushed, resulting
in only broadcast and unicast traffic being received.

A new cpsw_ale_set_allmulti function now scans through the ALE entry
table and adds/removes the host port from the unregistered multicast
port mask of each vlan entry depending on the state of IFF_ALLMULTI.
In promiscious mode, cpsw_ale_set_allmulti is used to force reception
of all multicast traffic in addition to the unicast and broadcast traffic.

With this change dynamic multicast and promiscious mode both work in
switch mode.

Signed-off-by: Len Sorensen <lsorense@csclub.uwaterloo.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
6f979eb3fcfb4c3f42f230d174db4bbad0080710 31-Oct-2014 Lennart Sorensen <lsorense@csclub.uwaterloo.ca> drivers: net: cpsw: Fix broken loop condition in switch mode

0d961b3b52f566f823070ce2366511a7f64b928c (drivers: net: cpsw: fix buggy
loop condition) accidentally fixed a loop comparison in too many places
while fixing a real bug.

It was correct to fix the dual_emac mode section since there 'i' is used
as an index into priv->slaves which is a 0 based array.

However the other two changes (which are only used in switch mode)
are wrong since there 'i' is actually the ALE port number, and port 0
is the host port, while port 1 and up are the slave ports.

Putting the loop condition back in the switch mode section fixes it.

A comment has been added to point out the intent clearly to avoid future
confusion. Also a comment is fixed that said the opposite of what was
actually happening.

Signed-off-by: Len Sorensen <lsorense@csclub.uwaterloo.ca>
Acked-by: Heiko Schocher <hs@denx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
47276fcc2d542e7b15e384c08b1709c1921b06c1 24-Oct-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net:cpsw: fix probe_dt when only slave 1 is pinned out

when slave 0 has no phy and slave 1 connected to phy, driver probe will
fail as there is no phy id present for slave 0 device tree, so continuing
even though no phy-id found, also moving mac-id read later to ensure
mac-id is read from device tree even when phy-id entry in not found.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
030b16a0e37ff2a870dd57c5da89c1741c683684 13-Oct-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: remove child devices while driver detach

remove all the child devices from the system to make sure that re-insert of
cpsw module doesn't fail on child device populated by of_platform_populate().

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0ba517b18aac0ed747b0f0716ca87cedaa8e5491 29-Sep-2014 Markus Pargmann <mpa@pengutronix.de> net: cpsw: Add am33xx MACID readout

This patch adds a function to get the MACIDs from the am33xx SoC
control module registers which hold unique vendor MACIDs. This is only
used if of_get_mac_address() fails to get a valid mac address.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Tested-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
56fdb2e04697c06b0af421cece0f360087af9cd1 29-Sep-2014 Markus Pargmann <mpa@pengutronix.de> net: cpsw: Replace pr_err by dev_err

Use dev_err instead of pr_err.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
4d507dffe766b8e29f29d17ae8e0611b5638286e 29-Sep-2014 Markus Pargmann <mpa@pengutronix.de> net: cpsw: Add missing return value

ret is set 0 at this point, so jumping to that error label would result
in a return value of 0. Set ret to -ENOMEM to return a proper error
value.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
618073e30c225ddaef086c030a5f0a3c7ef2d323 11-Sep-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: dual_emac: in suspend/resume bring down/up all the netdev

During suspend and resume in Dual EMAC, second port is not working as in
suspend/resume only the first slave netdev is closed and opened. So bring
down and up all the interfaces that are up during suspend/resume.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Nishanth Menon <nm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a0e2c822bf0a1095dc250b5875e39ac0662a5df6 10-Sep-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: dual_emac: fix reducing of rx descriptor during ifdown

In Dual EMAC, when both interface are up and while doing ifdown with heavy
traffic then skbs already processed by DMA from that slave emac has to be
requeued as still the other interface is up and running.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c9104b04fe708ec4ac7452eef7ccdedfd22eff25 08-Sep-2014 Varka Bhadram <varkabhadram@gmail.com> ethernet: ti: remove unwanted THIS_MODULE macro

It removes the owner field updation of driver structure.
It will be automatically updated by module_platform_driver()

Signed-off-by: Varka Bhadram <varkab@cdac.in>
Signed-off-by: David S. Miller <davem@davemloft.net>
1923d6e4186c9470a83d0179e86e1aea8cfcbe67 08-Sep-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add support for pause frames

CPSW supports both rx and tx pause frames for flow control.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c2b32e580ccc574cf353661ee6d900947e9fdf28 04-Sep-2014 Daniel Mack <zonque@gmail.com> net: ethernet: cpsw: improve interrupt lookup logic in cpsw_probe()

Simplify the interrupt resource lookup code in cpsw_probe() by the
following:

* Only look at the first member of the resource. As the driver only
works for DT-enabled platforms anyway, a resource of type
IORESOURCE_IRQ will only contain one single entry
(res->start == res->end), so there is no need for the iteration.

* Add a bounds check to avoid overflows if we are passed more than
ARRAY_SIZE(priv->irqs_table) resources.

* Assign 'ret' with the return value of devm_request_irq() so that
cpsw_probe() returns the appropriate error code.

* If devm_request_irq() fails, report the error code in the log
message.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Mugunthan V N <mugunthanvnm@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ef492001214ba250b3bd18a7a346a047fe079449 24-Jul-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: cleanup: remove unused function

removing unused function as part of driver cleanup.`

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
52c4f0ec662bbf02f1b0bcb311a48af2c8e5ee89 22-Jul-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: add support to dump ALE table via ethtool register dump

Add support to view addresses added by the driver and learnt by the
hardware from ALE table via ethtool register dump interface.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a84bc2a9013fb123deeca7283480955d021503fb 15-Jul-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: disable coalesce when rx_coalesce_usecs is zero

instead of return error on zero rx_coalesce_usecs, disable coalesce

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e6afea0bbf129f88dc3fc39fd0d769f9ff064172 18-Jun-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix dual EMAC stall when connected to same switch

In commit 629c9a8fd0bbdfc6d702526b327470166ec39c6b (drivers: net: cpsw: Add
default vlan for dual emac case also), api cpsw_add_default_vlan() also
changes the port vlan which is required to seperate the ports which results
in the following behavior

In Dual EMAC mode, when both the Etnernet connected is connected to same
switch, it creates a loop in the switch and when a broadcast packet is
received it is forwarded to the other port which stalls the whole switch
and needs a reset/power cycle to the switch to recover. So intead of using
the api, add only the default VLAN entry in dual EMAC case.

Cc: Yegor Yefremov <yegorslists@googlemail.com>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Tested-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5f47dfb400d6a82d5ce9cdf537e33969af8278ff 14-May-2014 Joe Perches <joe@perches.com> ti: Remove trailing semicolon from do {...} while (0) macro

These should not have trailing semicolons so remove them.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
88c99ff639aee9a5c37b796340a8fc9973bf86cb 12-May-2014 George Cherian <george.cherian@ti.com> driver net: cpsw: Convert pr_*() to dev_*() calls

Convert all pr_*() calls to dev_*() calls.
No functional changes.

Signed-off-by: George Cherian <george.cherian@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7ad24ea4bf620a32631d7b3069c3e30c078b0c3e 11-May-2014 Wilfried Klaebe <w-lkml@lebenslange-mailadresse.de> net: get rid of SET_ETHTOOL_OPS

net: get rid of SET_ETHTOOL_OPS

Dave Miller mentioned he'd like to see SET_ETHTOOL_OPS gone.
This does that.

Mostly done via coccinelle script:
@@
struct ethtool_ops *ops;
struct net_device *dev;
@@
- SET_ETHTOOL_OPS(dev, ops);
+ dev->ethtool_ops = ops;

Compile tested only, but I'd seriously wonder if this broke anything.

Suggested-by: Dave Miller <davem@davemloft.net>
Signed-off-by: Wilfried Klaebe <w-lkml@lebenslange-mailadresse.de>
Acked-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
60e71ab56b5fbd839aaef4f4af7778d86e0206f0 08-May-2014 Johan Hovold <jhovold@gmail.com> net: cpsw: add missing of_node_put

Add missing of_node_put to avoid kref leak.

Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6954cc1f238199e971ec905c5cc87120806ac981 08-May-2014 Johan Hovold <jhovold@gmail.com> net: cpsw: fix null dereference at probe

Fix null-pointer dereference at probe when the mdio platform device is
missing (e.g. when it has been disabled in DT).

Cc: stable <stable@vger.kernel.org> # v3.8
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
59993f48b38fd46863b23bb1bb1dc3291e7278fb 08-May-2014 Johan Hovold <jhovold@gmail.com> Revert "net: eth: cpsw: Correctly attach to GPIO bitbang MDIO driver"

This reverts commit f8d56d8f892be43a2404356073e16401eb5a42e6 ("net:
eth: cpsw: Correctly attach to GPIO bitbang MDIO driver").

Fix potential null-pointer dereference at probe if the mdio-gpio device
has not been successfully probed yet.

The offending commit is plain wrong for a number of reasons. First of
all it accesses internal driver data of an unrelated device. Neither
does it check that the data is non-null (which it is in case the device
has not been probed yet).

Furthermore, the decision on whether to treat any driver data according
to the mdio-gpio driver's internals is made based on the node name. But
the name is not compared against "mdio" which is the normal name for the
node, but rather against "gpio" which the node does not have to be named
(and shouldn't be according to the binding documentation). [ If this
hack is to be kept out-of-tree it should at least be matching against
the compatible property. ]

Cc: Stefan Roese <sr@denx.de>
Cc: stable <stable@vger.kernel.org> # v3.14
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
09c5537246fd469625d116080ab1caa72d170d96 01-May-2014 George Cherian <george.cherian@ti.com> drivers: net: cpsw: Enable Annexe F Time sync

Enable the Annex F Time Sync explicitly for DRA7x and AM4372.
With this enabled the L2 PTP is working.

while at that rename TS_BIT8 to TS_TTL_NONZERO

Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f7d403cb38cde82778cbb0c2a5a474a014df1771 01-May-2014 George Cherian <george.cherian@ti.com> drivers: net: cpsw: Enable CPTS for DRA7xx and AM4372

Enable cpts hardware time stamping for Dra7xx and AM4372.
This enables PTPv2 for DRA7xx and AM4372.

Signed-off-by: George Cherian <george.cherian@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f63a975e8f07a75dbf0386402788330d0bebd8d8 10-Apr-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: enable interrupts after napi enable and clearing previous interrupts

When the Ethernet interface is put down and up with heavy Ethernet
traffic, then there is prossibility of an interrupt waiting in irq
controller to be processed, so when the interface is brought up again
just after enable interrupt, it goes to ISR due to the previous
unhandled interrutp and in ISR napi is not scheduled as the napi
is not enabled in ndo_open which results in disabled interrupt for
CPSW and no packets are received in cpsw. So this patch moves enabling
of interupts after napi_enable and clearing CPDMA interrupts.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
16e5c57da61cda26998bee91a327960ebd1562f6 10-Apr-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: discard all packets received when interface is down

When the Ethernet interface is brought down during high Ethernet traffic,
then cpsw creates the following warn dump. When cpdma has already processed
the packet then the status will be greater than 0, so the cpsw_rx_handler
considers that the interface is up and try to resubmit one more rx buffer
to cpdma which fails as the DMA is in teardown process. This can be avoided
by checking the interface state and then process the received packet, if the
interface is down just discard and free the skb and return.

[ 2823.104591] WARNING: CPU: 0 PID: 1823 at drivers/net/ethernet/ti/cpsw.c:711 cpsw_rx_handler+0x148/0x164()
[ 2823.114654] Modules linked in:
[ 2823.117872] CPU: 0 PID: 1823 Comm: ifconfig Tainted: G W 3.14.0-11992-gf34c4a3 #11
[ 2823.126860] [<c0014b5c>] (unwind_backtrace) from [<c00117e4>] (show_stack+0x10/0x14)
[ 2823.135030] [<c00117e4>] (show_stack) from [<c0533a9c>] (dump_stack+0x80/0x9c)
[ 2823.142619] [<c0533a9c>] (dump_stack) from [<c003f0e0>] (warn_slowpath_common+0x6c/0x90)
[ 2823.151141] [<c003f0e0>] (warn_slowpath_common) from [<c003f120>] (warn_slowpath_null+0x1c/0x24)
[ 2823.160336] [<c003f120>] (warn_slowpath_null) from [<c03caeb0>] (cpsw_rx_handler+0x148/0x164)
[ 2823.169314] [<c03caeb0>] (cpsw_rx_handler) from [<c03c730c>] (__cpdma_chan_free+0x90/0xa8)
[ 2823.178028] [<c03c730c>] (__cpdma_chan_free) from [<c03c7418>] (__cpdma_chan_process+0xf4/0x134)
[ 2823.187279] [<c03c7418>] (__cpdma_chan_process) from [<c03c7560>] (cpdma_chan_stop+0xb4/0x17c)
[ 2823.196349] [<c03c7560>] (cpdma_chan_stop) from [<c03c766c>] (cpdma_ctlr_stop+0x44/0x9c)
[ 2823.204872] [<c03c766c>] (cpdma_ctlr_stop) from [<c03cb708>] (cpsw_ndo_stop+0x154/0x188)
[ 2823.213321] [<c03cb708>] (cpsw_ndo_stop) from [<c046f0ec>] (__dev_close_many+0x84/0xc8)
[ 2823.221761] [<c046f0ec>] (__dev_close_many) from [<c046f158>] (__dev_close+0x28/0x3c)
[ 2823.230012] [<c046f158>] (__dev_close) from [<c0474ca8>] (__dev_change_flags+0x88/0x160)
[ 2823.238483] [<c0474ca8>] (__dev_change_flags) from [<c0474da0>] (dev_change_flags+0x18/0x48)
[ 2823.247316] [<c0474da0>] (dev_change_flags) from [<c04d12c4>] (devinet_ioctl+0x61c/0x6e0)
[ 2823.255884] [<c04d12c4>] (devinet_ioctl) from [<c045c660>] (sock_ioctl+0x68/0x2a4)
[ 2823.263789] [<c045c660>] (sock_ioctl) from [<c0125fe4>] (do_vfs_ioctl+0x78/0x61c)
[ 2823.271629] [<c0125fe4>] (do_vfs_ioctl) from [<c01265ec>] (SyS_ioctl+0x64/0x74)
[ 2823.279284] [<c01265ec>] (SyS_ioctl) from [<c000e580>] (ret_fast_syscall+0x0/0x48)

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
629c9a8fd0bbdfc6d702526b327470166ec39c6b 09-Apr-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add default vlan for dual emac case also

Dual EMAC works with VLAN segregation of the ports, so default vlan needs
to be added in dual EMAC case else default vlan will be tagged for all
egress packets and vlan unaware switches/servers will drop packets
from the EVM.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b085f311e85b1d6f75d610097c2f20583b776fda 16-Mar-2014 Benedikt Spranger <b.spranger@linutronix.de> net: cpsw: do not register cpts twice

commit f280e89a (drivers: net: cpsw: fix for cpsw crash when build as modules)
moved cpts_register()/cpts_unregister() to ndo_open()/ndo_stop(), but failed
to remove cpts_register in cpsw_probe() which leads to a double registration
and the following debug object splat.

[ 18.991902] ODEBUG: init active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x2c
[ 19.082249] [<c0059e80>] (init_timer_key) from [<c04965d4>] (cpts_register+0x1f0/0x2c4)
[ 19.090642] [<c04965d4>] (cpts_register) from [<c04931dc>] (cpsw_ndo_open+0x780/0x81c)
[ 19.098948] [<c04931dc>] (cpsw_ndo_open) from [<c0599c2c>] (__dev_open+0xb4/0x118)

Signed-off-by: Benedikt Spranger <b.spranger@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
8dc43ddc9fe0af3a555af235a69a398c3eba2639 10-Mar-2014 Tobias Klauser <tklauser@distanz.ch> net: eth: cpsw: Use net_device_stats from struct net_device

Instead of using an own copy of struct net_device_stats in struct
cpsw_priv, use stats from struct net_device. Also remove the thus
unnecessary .ndo_get_stats function, as it just returns dev->stats,
which is the default.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3995d265b3640fb7dc843a3c5f62ced4f121fb89 03-Mar-2014 Schuyler Patton <spatton@ti.com> net: cpsw: fix cpdma rx descriptor leak on down interface

This patch fixes a CPDMA RX Descriptor leak that occurs after taking
the interface down when the CPSW is in Dual MAC mode. Previously
the CPSW_ALE port was left open up which causes packets to be received
and processed by the RX interrupt handler and were passed to the
non active network interface where they were ignored.

The fix is for the slave_stop function of the selected interface
to disable the respective CPSW_ALE Port from forwarding packets. This
blocks traffic from being received on the inactive interface.

Signed-off-by: Schuyler Patton <spatton@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c1b5994770ad5ae03336b5cdd1e0ad622a870a00 16-Feb-2014 Stefan Sørensen <stefan.sorensen@spectralink.com> net:cpsw: Pass unhandled ioctl's on to generic phy ioctl

This patch allows the use of a generic timestamping phy connected
to the cpsw if CPTS support is not enabled. This also adds support
of the SIOCGMIIREG and SIOCSMIIREG, and moves handling of SIOCGMIIPHY
to the generic driver.

Signed-off-by: Stefan Sørensen <stefan.sorensen@spectralink.com>
Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
0d961b3b52f566f823070ce2366511a7f64b928c 13-Feb-2014 Heiko Schocher <hs@denx.de> drivers: net: cpsw: fix buggy loop condition

Commit 0cd8f9cc0654c06adde353c6532114c5f53a18e8 ("drivers: net: cpsw:
enable promiscuous mode support")

Enable promiscuous mode support for CPSW.

Introduced a crash on an am335x based board (similiar to am335x-evm).
Reason is buggy end condition in for loop in cpsw_set_promiscious()

for (i = 0; i <= priv->data.slaves; i++)

should be

for (i = 0; i < priv->data.slaves; i++)

Fix this ...

Signed-off-by: Heiko Schocher <hs@denx.de>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Sebastian Siewior <bigeasy@linutronix.de>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Markus Pargmann <mpa@pengutronix.de>
Cc: netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
89e101729be4cacd5847fef7e7c99680772c6e3c 12-Feb-2014 Uwe Kleine-König <u.kleine-koenig@pengutronix.de> net: cpsw: catch of_get_phy_mode failing and propagate error

It's wrong if the device tree doesn't provide a phy-mode property for
the cpsw slaves as it is documented to be required in
Documentation/devicetree/bindings/net/cpsw.txt.

Anyhow it's nice to catch that problem, still more as it used to work
without this property up to commit 388367a5a9fb (drivers: net: cpsw: use
cpsw-phy-sel driver to configure phy mode) which is in v3.13-rc1.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f8d56d8f892be43a2404356073e16401eb5a42e6 29-Jan-2014 Stefan Roese <sr@denx.de> net: eth: cpsw: Correctly attach to GPIO bitbang MDIO driver

When the GPIO bitbang MDIO driver is used instead of the Davinci MDIO driver
we need to configure the phy_id string differently. Otherwise this string
looks like this "gpio.6" instead of "gpio-0" and the PHY is not found when
phy_connect() is called.

Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Lukas Stockmann <lukas.stockmann@siemens.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0cd8f9cc0654c06adde353c6532114c5f53a18e8 22-Jan-2014 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: enable promiscuous mode support

Enable promiscuous mode support for CPSW.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
db850559a303dc9459d7dd7339bd19a66907a15a 18-Dec-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net : cpsw: pass proper device name while requesting irq

During checking the interrupts with "cat /proc/interrupts", it is showing
device name as (null), this change was done with commit id aa1a15e2d where
request_irq is changed to devm_request_irq also changing the irq name from
platform device name to net device name, but the net device is not
registered at this point with the network frame work, so devm_request_irq
is called with device name as NULL, by which it is showed as "(null)" in
"cat /proc/interrupts". So this patch changes back irq name to platform
device name itself in devm_request_irq so that the device name shows as
below.

Previous to this patch
root@am335x-evm:~# cat /proc/interrupts
CPU0
28: 2265 INTC 12 edma
30: 80 INTC 14 edma_error
56: 0 INTC 40 (null)
57: 1794 INTC 41 (null)
58: 7 INTC 42 (null)
59: 0 INTC 43 (null)

With this patch
root@am335x-evm:~# cat /proc/interrupts
CPU0
28: 213 INTC 12 edma
30: 9 INTC 14 edma_error
56: 0 INTC 40 4a100000.ethernet
57: 16097 INTC 41 4a100000.ethernet
58: 11964 INTC 42 4a100000.ethernet
59: 0 INTC 43 4a100000.ethernet

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a81d8762d71396f69d27187a909fcc69f1a7be75 13-Dec-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net cpsw: Enable In Band mode in cpsw for 10 mbps

This patch adds support for enabling In Band mode in 10 mbps speed.
RGMII supports 1 Gig and 100 mbps mode for Forced mode of operation.
For 10mbps mode it should be configured to in band mode so that link
status, duplexity and speed are determined from the RGMII input data
stream

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f280e89ad6a29d9969cb6b216123c798e1689bc4 12-Dec-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix for cpsw crash when build as modules

When CPSW and Davinci MDIO are build as modules, CPSW crashes when
accessing CPSW registers in CPSW probe. The same is working in built-in
as the CPSW clocks are enabled in Davindi MDIO probe, SO Enabling the
clocks before accessing the version register and moving out the other
register access to cpsw device open.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1a3b50566f259eb79039b720dbfdbb97a7a1b9c5 12-Dec-2013 Olof Johansson <olof@lixom.net> net: eth: cpsw: 64-bit phys_addr_t and sparse cleanup

Minor fix for printk format of a phys_addr_t, and the switch of two local
functions to static since they're not used outside of the file.

Signed-off-by: Olof Johansson <olof@lixom.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
3a27bfac17fe375539c4e0a53478679645eb5ae2 01-Dec-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix dt probe for one port ethernet

When only one port of the two port is pinned out, then dt probe is failing
because second port phy is not found. fixing this by checking the number of
slaves and breaking the loop.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a5b4145ba937b76dd698ad6fe5c5f37e0edbac43 19-Nov-2013 Ben Hutchings <bhutchings@solarflare.com> ti_cpsw: Implement the SIOCGHWTSTAMP ioctl

This is untested.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
1e7a2e219ab6bc57ed901485a0d0be85235ebe61 15-Nov-2013 Daniel Mack <zonque@gmail.com> net: ethernet: ti/cpsw: do not crash on single-MAC machines during resume

During resume, use for_each_slave to walk the slaves of the cpsw, and
soft-reset each of them. This prevents oopses if there is only one
slave configured.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Mugunthan V N <mugunthanvnm@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2ee91e54bd5367bf4123719a4f7203857b28e046 14-Nov-2013 Ben Hutchings <bhutchings@solarflare.com> ti_cpsw: Validate hwtstamp_config completely before applying it

cpsw_hwtstamp_ioctl() should validate all fields of hwtstamp_config,
and the hardware version, before making any changes. Currently it
sets the TX configuration before validating the rx_filter field
or that the hardware supports timestamping.

Also correct the error code for hardware versions that don't
support timestamping. ENOTSUPP is used by the NFS implementation
and is not part of userland API; we want EOPNOTSUPP (which glibc
also calls ENOTSUP, with one 'P').

Untested as I don't have a cross-compiler to hand.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Acked-by: Mugunthan V N <mugunthanvnm@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
49595b7b21ca60ebae7fb6d6fda7dc67d7bbbd66 19-Oct-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix kernel warn during iperf test with interrupt pacing

When interrupt pacing is enabled, receive/transmit statistics are not
updated properly by hardware which leads to ISR return with IRQ_NONE
and inturn kernel disables the interrupt. This patch removed the checking
of receive/transmit statistics from ISR.

This patch is verified with AM335x Beagle Bone Black and below is the
kernel warn when interrupt pacing is enabled.

[ 104.298254] irq 58: nobody cared (try booting with the "irqpoll" option)
[ 104.305356] CPU: 0 PID: 1073 Comm: iperf Not tainted 3.12.0-rc3-00342-g77d4015 #3
[ 104.313284] [<c001bb84>] (unwind_backtrace+0x0/0xf0) from [<c0017db0>] (show_stack+0x10/0x14)
[ 104.322282] [<c0017db0>] (show_stack+0x10/0x14) from [<c0507920>] (dump_stack+0x78/0x94)
[ 104.330816] [<c0507920>] (dump_stack+0x78/0x94) from [<c0088c1c>] (__report_bad_irq+0x20/0xc0)
[ 104.339889] [<c0088c1c>] (__report_bad_irq+0x20/0xc0) from [<c008912c>] (note_interrupt+0x1dc/0x23c)
[ 104.349505] [<c008912c>] (note_interrupt+0x1dc/0x23c) from [<c0086d74>] (handle_irq_event_percpu+0xc4/0x238)
[ 104.359851] [<c0086d74>] (handle_irq_event_percpu+0xc4/0x238) from [<c0086f24>] (handle_irq_event+0x3c/0x5c)
[ 104.370198] [<c0086f24>] (handle_irq_event+0x3c/0x5c) from [<c008991c>] (handle_level_irq+0xac/0x10c)
[ 104.379907] [<c008991c>] (handle_level_irq+0xac/0x10c) from [<c00866d8>] (generic_handle_irq+0x20/0x30)
[ 104.389812] [<c00866d8>] (generic_handle_irq+0x20/0x30) from [<c0014ce8>] (handle_IRQ+0x4c/0xb0)
[ 104.399066] [<c0014ce8>] (handle_IRQ+0x4c/0xb0) from [<c000856c>] (omap3_intc_handle_irq+0x60/0x74)
[ 104.408598] [<c000856c>] (omap3_intc_handle_irq+0x60/0x74) from [<c050d8e4>] (__irq_svc+0x44/0x5c)
[ 104.418021] Exception stack(0xde4f7c00 to 0xde4f7c48)
[ 104.423345] 7c00: 00000001 00000000 00000000 dd002140 60000013 de006e54 00000002 00000000
[ 104.431952] 7c20: de345748 00000040 c11c8588 00018ee0 00000000 de4f7c48 c009dfc8 c050d300
[ 104.440553] 7c40: 60000013 ffffffff
[ 104.444237] [<c050d8e4>] (__irq_svc+0x44/0x5c) from [<c050d300>] (_raw_spin_unlock_irqrestore+0x34/0x44)
[ 104.454220] [<c050d300>] (_raw_spin_unlock_irqrestore+0x34/0x44) from [<c00868c0>] (__irq_put_desc_unlock+0x14/0x38)
[ 104.465295] [<c00868c0>] (__irq_put_desc_unlock+0x14/0x38) from [<c0088068>] (enable_irq+0x4c/0x74)
[ 104.474829] [<c0088068>] (enable_irq+0x4c/0x74) from [<c03abd24>] (cpsw_poll+0xb8/0xdc)
[ 104.483276] [<c03abd24>] (cpsw_poll+0xb8/0xdc) from [<c044ef68>] (net_rx_action+0xc0/0x1e8)
[ 104.492085] [<c044ef68>] (net_rx_action+0xc0/0x1e8) from [<c0048a90>] (__do_softirq+0x100/0x27c)
[ 104.501338] [<c0048a90>] (__do_softirq+0x100/0x27c) from [<c0048cd0>] (do_softirq+0x68/0x70)
[ 104.510224] [<c0048cd0>] (do_softirq+0x68/0x70) from [<c0048e8c>] (local_bh_enable+0xd0/0xe4)
[ 104.519211] [<c0048e8c>] (local_bh_enable+0xd0/0xe4) from [<c048c774>] (tcp_rcv_established+0x450/0x648)
[ 104.529201] [<c048c774>] (tcp_rcv_established+0x450/0x648) from [<c0494904>] (tcp_v4_do_rcv+0x154/0x474)
[ 104.539195] [<c0494904>] (tcp_v4_do_rcv+0x154/0x474) from [<c043d750>] (release_sock+0xac/0x1ac)
[ 104.548448] [<c043d750>] (release_sock+0xac/0x1ac) from [<c04844e8>] (tcp_recvmsg+0x4d0/0xa8c)
[ 104.557528] [<c04844e8>] (tcp_recvmsg+0x4d0/0xa8c) from [<c04a8720>] (inet_recvmsg+0xcc/0xf0)
[ 104.566507] [<c04a8720>] (inet_recvmsg+0xcc/0xf0) from [<c0439744>] (sock_recvmsg+0x90/0xb0)
[ 104.575394] [<c0439744>] (sock_recvmsg+0x90/0xb0) from [<c043b778>] (SyS_recvfrom+0x88/0xd8)
[ 104.584280] [<c043b778>] (SyS_recvfrom+0x88/0xd8) from [<c043b7e0>] (sys_recv+0x18/0x20)
[ 104.592805] [<c043b7e0>] (sys_recv+0x18/0x20) from [<c0013da0>] (ret_fast_syscall+0x0/0x48)
[ 104.601587] handlers:
[ 104.603992] [<c03acd94>] cpsw_interrupt
[ 104.608040] Disabling IRQ #58

Cc: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dbbd2ad89bb1f86b94b23bb2e56d4935717f9b94 13-Oct-2013 Markus Pargmann <mpa@pengutronix.de> net/ethernet: cpsw: Bugfix interrupts before enabling napi

If interrupts happen before napi_enable was called, the driver will not
work as expected. Network transmissions are impossible in this state.
This bug can be reproduced easily by restarting the network interface in
a loop. After some time any network transmissions on the network
interface will fail.

This patch fixes the bug by enabling napi before enabling the network
interface interrupts.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
281abd965fedfe7c31927d84e01a5bfa554b5502 04-Oct-2013 Markus Pargmann <mpa@pengutronix.de> net/ethernet: cpsw: DT read bool dual_emac

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
f468b10e3de6c5f90a14b9c82f1403a2651cef35 04-Oct-2013 Markus Pargmann <mpa@pengutronix.de> net: ethernet: cpsw: Search childs for slave nodes

The current implementation searches the whole DT for nodes named
"slave".

This patch changes it to search only child nodes for slaves.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
1e5c76d40fd41194472b4c1b369d7d63df0bea03 30-Sep-2013 Sachin Kamat <sachin.kamat@linaro.org> net: ethernet: cpsw: Remove redundant of_match_ptr

The data structure of_match_ptr() protects is always compiled in.
Hence of_match_ptr() is not needed.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
388367a5a9fbbb86db815ab069c8d5e970d2b86e 20-Sep-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: use cpsw-phy-sel driver to configure phy mode

Phy mode can be configured via the cpsw-phy-sel driver, this patch enabled the
cpsw driver to utilise the api provided by the cpsw-phy-sel driver to configure
the phy mode.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
aa1a15e2d9199711cdcc9399fdb22544ab835a83 20-Sep-2013 Daniel Mack <zonque@gmail.com> net: ethernet: cpsw: switch to devres allocations

This patch cleans up the allocation and error unwind paths, which
allows us to carry less information in struct cpsw_priv and reduce the
amount of jump labels in the probe functions.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d8a64420eb267bec9f4c99627deee4fa3bf4133e 20-Aug-2013 Matus Ujhelyi <ujhelyi.m@gmail.com> net: cpsw: Add support for wake-on-lan for cpsw

Some phy's can be configured to enable wake on lan (e.g. at803x or marvell 88E1318S).
There is no way how to enable wol on CPSW with such connected phys. This patch
adds this support. It is provided by calling the phy's related code.

Tested on board with at8030x connected phy. Wol interrupt line is
connected to GPIO0 on am335x.

Signed-off-by: Matus Ujhelyi <ujhelyi.m@gmail.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dbe34724c08ea25d39d31735120077013fbbb6fb 19-Aug-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: remove platform data header file of cpsw

CPSW driver no longer supports platform register as all the SoCs which has CPSW
are supporting DT only booting, so moving cpsw.h header file from platform
include to drivers/net/ethernet/ti

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
926489be1d2b030c17d38fa10b5921bf3409d91d 12-Aug-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add support for new CPSW IP version present in AM43xx SoC

The new IP version which is present in AM43xx SoC has a minor changes and the
offsets are same as the previous version, so adding new IP version support in
the driver.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c193f3655d9b916a3b8cb685c6b4327397507b2f 05-Aug-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add support for new CPSW IP version

The new IP version has a minor changes and the offsets are same as the
previous version, so adding new IP version support in the driver.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7069f982b9099133b44e3cecbdd0192d81590bec 02-Aug-2013 Felipe Balbi <balbi@ti.com> net: ethernet: cpsw: drop IRQF_DISABLED

IRQF_DISABLED is a no-op by now and should be
removed.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dcfd8d5830f8cc9062eb7040f455c034e8d160e6 25-Jul-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add support for set MAC address

Adding support for setting MAC address to cpsw device via ndo_set_mac_address

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d97185466cc83902de49c7bea512651c7af12566 23-Jul-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: add support to show hw stats via ethtool

Add support to show CPSW hardware statistics to user via ethtool
so user can find if there were any error reported by hardware or
the system is over loaded duing high data rate transfer.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
cf6122be45de68bc773f64e4266db76129ea556f 27-Jun-2013 Daniel Mack <zonque@gmail.com> drivers: net: cpsw: add newline after MACID log

Cosmetic patch to add a newline after logging the device's MACID.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b90fc27a64a57b273351ceef7ae298558ff8a6ac 21-Jun-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix compilation error with cpsw driver

drivers/net/ethernet/ti/cpsw.c: In function 'cpsw_suspend':
drivers/net/ethernet/ti/cpsw.c:1979:26: error: 'priv' undeclared (first use in this function)
drivers/net/ethernet/ti/cpsw.c:1979:26: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [drivers/net/ethernet/ti/cpsw.o] Error 1

The compilation error was introduced by the following commit
6d3d76f (drivers: net: cpsw: fix cpsw clock gating issue across suspend/resume)

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6d3d76f877ca061911343d5d1650458906fdf0ea 18-Jun-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix cpsw clock gating issue across suspend/resume

Due to some hardware integration issue, CPSW sliver modules requires a
reset across suspend/resume cycle for a successful clock gating to
CPGMAC (CPSW and Davinci MDIO) in AM335x PG1.0.
This issue is fixed in PG2.x, though to support suspend/resume on PG1.0
this reset is required.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ab8e99d276d4b72d1532bda4423b14c9e2ce053c 17-Jun-2013 Sebastian Siewior <bigeasy@linutronix.de> net: cpsw: check for cpts pointer after its allocation

after priv->cpts got allocated then this pointer should check to determine
if the allocation succeeded or not.

Cc: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
739683b48d088bd7dcf91bcd255d7340bb76ccbd 06-Jun-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: use pinctrl PM helpers

This utilize the new pinctrl core PM helpers to transition
the driver to "default" and "sleep" states.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
c5ceea7a2813fecded01567383cca4d6855164ab 03-Jun-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: add phy-mode support to cpsw driver

Adding phy-mode support to cpsw driver and updating the cpsw binding
documentation.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dfd93c977d84fef77404b689ef95bc716b313533 27-May-2013 Jingoo Han <jg1.han@samsung.com> net: ethernet: remove unnecessary platform_set_drvdata()

The driver core clears the driver data to NULL after device_release
or on probe failure, since commit 0998d0631001288a5974afc0b2a5f568bcdecb4d
(device-core: Ensure drvdata = NULL when no driver is bound).
Thus, it is not needed to manually clear the device driver data to NULL.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Roland Stigge <stigge@antcom.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Tested-by: Roland Stigge <stigge@antcom.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
af5c6df704af46f2cfebea329887f3d70ccb7b3d 02-May-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: irq not disabled in cpsw isr in particular sequence

In CPSW NAPI, after processing all interrupts IRQ is enabled and then book
keeping irq_enabled is updated. In random cases when a packet is transmitted
or received between processing packets and IRQ enabled, then just after
enabled IRQ and before irq_enabled is updated, ISR is called so IRQs are
not disabled as irq_enabled is still false and CPU gets locked in CPSW ISR.

By changing the sequence as update the irq_enabled and then enable IRQ
fixes the issue. This issue is not captured always as it is a timing issue
whether Tx or Rx IRQ is invoked between packet processing and enable IRQ.

Cc: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
7dcf313a7a68adc9a060e4e41a55245c0f9a3d31 30-Apr-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: fix kernel warn on cpsw irq enable

With the commit a11fbba (net/cpsw: fix irq_disable() with threaded interrupts)
from Sebastian Siewior, a kernel warning is generated as below. This warning
is generated as the irq_enabled is not initialized for the primary interface
and in probe it is initialized for the second interface. This patch moves
irq_enabled initialization from second interface to primary interface.

[ 3.049173] net eth0: phy found : id is : 0x4dd074
[ 3.054552] net eth0: phy found : id is : 0x4dd074
[ 3.070421] ------------[ cut here ]------------
[ 3.075308] WARNING: at kernel/irq/manage.c:437 enable_irq+0x3c/0x74()
[ 3.082173] Unbalanced enable for IRQ 56
[ 3.086299] Modules linked in:
[ 3.089557] [<c001abcc>] (unwind_backtrace+0x0/0xf0) from [<c004294c>] (warn_slowpath_common+0x4c/0x68)
[ 3.099450] [<c004294c>] (warn_slowpath_common+0x4c/0x68) from [<c00429fc>] (warn_slowpath_fmt+0x30/0x40)
[ 3.109521] [<c00429fc>] (warn_slowpath_fmt+0x30/0x40) from [<c00a29fc>] (enable_irq+0x3c/0x74)
[ 3.118681] [<c00a29fc>] (enable_irq+0x3c/0x74) from [<c03a7818>] (cpsw_ndo_open+0x61c/0x684)
[ 3.127669] [<c03a7818>] (cpsw_ndo_open+0x61c/0x684) from [<c0445c08>] (__dev_open+0x9c/0xf8)
[ 3.136646] [<c0445c08>] (__dev_open+0x9c/0xf8) from [<c0445e34>] (__dev_change_flags+0x78/0x13c)
[ 3.145988] [<c0445e34>] (__dev_change_flags+0x78/0x13c) from [<c0445f64>] (dev_change_flags+0x10/0x48)
[ 3.155884] [<c0445f64>] (dev_change_flags+0x10/0x48) from [<c0736d88>] (ip_auto_config+0x198/0x111c)
[ 3.165592] [<c0736d88>] (ip_auto_config+0x198/0x111c) from [<c00086a4>] (do_one_initcall+0x34/0x180)
[ 3.175309] [<c00086a4>] (do_one_initcall+0x34/0x180) from [<c07078f8>] (kernel_init_freeable+0xfc/0x1c8)
[ 3.185393] [<c07078f8>] (kernel_init_freeable+0xfc/0x1c8) from [<c04f36ec>] (kernel_init+0x8/0xe4)
[ 3.194929] [<c04f36ec>] (kernel_init+0x8/0xe4) from [<c00133d0>] (ret_from_fork+0x14/0x24)
[ 3.203712] ---[ end trace d6f979da080bc391 ]---

Cc: Sebastian Siewior <bigeasy@linutronix.de>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a11fbba9a7d338c4a4e4be624af0334bbf2c9a5a 24-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: fix irq_disable() with threaded interrupts

During high throughput it is likely that we receive both: an RX and TX
interrupt. The normal behaviour is that once we enter the ISR the
interrupts are disabled in the IRQ chip and so the ISR is invoked only
once and the interrupt line is disabled once. It will be re-enabled
after napi completes.
With threaded interrupts on the other hand the interrupt the interrupt
is disabled immediately and the ISR is marked for "later". By having TX
and RX interrupt marked pending we invoke them both and disable the
interrupt line twice. The napi callback is still executed once and so
after it completes we remain with interrupts disabled.

The initial patch simply removed the cpsw_{enable|disable}_irq() calls
and it worked well on my AM335X ES1.0 (beagle bone). On ES2.0 (beagle
bone black) it caused an never ending interrupt (even after the mask via
cpsw_intr_disable()) according to Mugunthan V N. Since I don't have the
ES2.0 and no idea what is going on this patch tracks the state of the
irq_disable() call and execute it only when not yet done.
The book keeping is done on the first struct since with dual_emac we can
have two of those and only one interrupt line.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6e6ceaedb5901c7ebd23e5222726dab5362938bd 24-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: optimize the for_each_slave_macro()

text data bss dec hex filename
15530 92 4 15626 3d0a cpsw.o.before
15478 92 4 15574 3cd6 cpsw.o.after

52 bytes smaller, 13 for each invocation.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d1bd9acfa3419dc9d5c32589b34a370ca6ae100e 24-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: make sure modules remove does not leak any ressources

This driver does not clean up properly after leaving. Here is a list:
- Use unregister_netdev(). free_netdev() is good but not enough
- Use the above also on the other ndev in case of dual mac
- Free data.slave_data. The name of the strucre makes it look like
it is platform_data but it is not. It is just a trick!
- Free all irqs. Again: freeing one irq is good start, but freeing all
of them is better.

With this rmmod & modprobe of cpsw seems to work. The remaining issue
is:
|WARNING: at fs/sysfs/dir.c:536 sysfs_add_one+0x9c/0xd4()
|sysfs: cannot create duplicate filename '/devices/ocp.2/4a100000.ethernet/4a101000.mdio'
|WARNING: at lib/kobject.c:196 kobject_add_internal+0x1a4/0x1c8()

comming from of_platform_populate() and I am not sure that this belongs
here.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4bc21d4162366bb892dc1a4a92110c656e2622ca 24-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/ti: add MODULE_DEVICE_TABLE + MODULE_LICENSE

If compiled as modules each one of these modules is missing something.
With this patch the modules are loaded on demand and don't taint the
kernel due to license issues.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b4727e69b81b71c6e9696185091e8256d863f9be 23-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: redo rx skb allocation in rx path

In case that we run into OOM during the allocation of the new rx-skb we
don't get one and we have one skb less than we used to have. If this
continues to happen then we end up with no rx-skbs at all.
This patch changes the following:
- if we fail to allocate the new skb, then we treat the currently
completed skb as the new one and so drop the currently received data.
- instead of testing multiple times if the device is gone we rely one
the status field which is set to -ENOSYS in case the channel is going
down and incomplete requests are purged.
cpdma_chan_stop() removes most of the packages with -ENOSYS. The
currently active packet which is removed has the "tear down" bit set.
So if that bit is set, we send ENOSYS as well otherwise we pass the
status bits which are required to figure out which of the two possible
just finished.

Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
aef614e13dfbdd3b9ae44ad110159f75b9029bba 23-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/davinci_cpdma: remove unused argument in cpdma_chan_submit()

The gfp_mask argument is not used in cpdma_chan_submit() and always set
to GFP_KERNEL even in atomic sections. This patch drops it since it is
unused.

Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
fd51cf199421197d14099b4ba382301cc28e5544 23-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: don't rely only on netif_running() to check which device is active

netif_running() reports false before the ->ndo_stop() callback is
called. That means if one executes "ifconfig down" and the system
receives an interrupt before the interrupt source has been disabled we
hang for always for two reasons:
- we never disable the interrupt source because devices claim to be
already inactive and don't feel responsible.
- since the ISR always reports IRQ_HANDLED the line is never deactivated
because it looks like the ISR feels responsible.

This patch changes the logic in the ISR a little:
- If none of the status registers reports an active source (RX or TX,
misc is ignored because it is not actived) we leave with IRQ_NONE.
- the interrupt is deactivated
- The first active network device is taken and napi is scheduled. If
none are active (a small race window between ndo_down() and the
interrupt the) then we leave and should not come back because the
source is off.
There is no need to schedule the second NAPI because both share the
same dma queue.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
aacebbf8026ecdae1b55db3912e65c6b1308f5ed 23-Apr-2013 Sebastian Siewior <bigeasy@linutronix.de> net/cpsw: don't continue if we miss to allocate rx skbs

if during "ifconfig up" we run out of mem we continue regardless how
many skbs we got. In worst case we have zero RX skbs and can't ever
receive further packets since the RX skbs are never reallocated. If
cpdma_chan_submit() fails we even leak the skb.
This patch changes the behavior here:
If we fail to allocate an skb during bring up we don't continue and
report that error. Same goes for errors from cpdma_chan_submit().
While here I changed to __netdev_alloc_skb_ip_align() so GFP_KERNEL can
be used.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
80d5c3689b886308247da295a228a54df49a44f6 19-Apr-2013 Patrick McHardy <kaber@trash.net> net: vlan: prepare for 802.1ad VLAN filtering offload

Change the rx_{add,kill}_vid callbacks to take a protocol argument in
preparation of 802.1ad support. The protocol argument used so far is
always htons(ETH_P_8021Q).

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
f646968f8f7c624587de729115d802372b9063dd 19-Apr-2013 Patrick McHardy <kaber@trash.net> net: vlan: rename NETIF_F_HW_VLAN_* feature flags to NETIF_F_HW_VLAN_CTAG_*

Rename the hardware VLAN acceleration features to include "CTAG" to indicate
that they only support CTAGs. Follow up patches will introduce 802.1ad
server provider tagging (STAGs) and require the distinction for hardware not
supporting acclerating both.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
91c4166c1a01c00b8bed74f7a7defa620071de88 15-Apr-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: get slave VLAN id from slave node instead of cpsw node

Dual EMAC slave VLAN id must be got from slave node instead of cpsw node as
VLAN id for each slave will be different.

Reported-by: Mark Jackson <mpfj-list@mimc.co.uk>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b56d6b3fca6d1214dbc9c5655f26e5d4ec04afc8 27-Mar-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: use netif_wake_queue() while restarting tx queue

To restart tx queue use netif_wake_queue() intead of netif_start_queue()
so that net schedule will restart transmission immediately which will
increase network performance while doing huge data transfers.

Reported-by: Dan Franke <dan.franke@schneider-electric.com>
Suggested-by: Sriramakrishnan A G <srk@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ce16294fda230c787ce5c35f61b2f80d14d70a72 21-Mar-2013 Lothar Waßmann <LW@KARO-electronics.de> net: ethernet: cpsw: fix erroneous condition in error check

The error check in cpsw_probe_dt() has an '&&' where an '||' is
meant to be. This causes a NULL pointer dereference when incomplet DT
data is passed to the driver ('phy_id' property for cpsw_emac1
missing).

Signed-off-by: Lothar Waßmann <LW@KARO-electronics.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
d35162f89b8f00537d7b240b76d2d0e8b8d29aa0 12-Mar-2013 Daniel Mack <zonque@gmail.com> net: ethernet: cpsw: fix usage of cpdma_check_free_tx_desc()

Commit fae50823d0 ("net: ethernet: davinci_cpdma: Add boundary for rx
and tx descriptors") introduced a function to check the current
allocation state of tx packets. The return value is taken into account
to stop the netqork queue on the adapter in case there are no free
slots.

However, cpdma_check_free_tx_desc() returns 'true' if there is room in
the bitmap, not 'false', so the usage of the function is wrong.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Reported-by: Sven Neumann <s.neumann@raumfeld.com>
Reported-by: Andreas Fenkart <andreas.fenkart@streamunlimited.com>
Tested-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Tested-by: Andreas Fenkart <andreas.fenkart@streamunlimited.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
11f2c988382b880e602a005c26436043c5d2c274 12-Mar-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: implement get phy_id via ioctl

Implement get phy_id via ioctl SIOCGMIIPHY. In switch mode active phy_id
is returned and in dual EMAC mode slave's specific phy_id is returned.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ff5b8ef2ef3af0fd7e1cf6c8c1ed9ec5afbda422 12-Mar-2013 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: cpsw: implement interrupt pacing via ethtool

This patch implements support for interrupt pacing block of CPSW via ethtool
Inetrrupt pacing block is common of both the ethernet interface in
dual emac mode

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d3bb9c58b567d240eaaa2dc8bd778696eaed5fbd 12-Mar-2013 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: cpsw: implement ethtool get/set phy setting

This patch implements get/set of the phy settings via ethtool apis

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e86ac13b031cf71d8f40ff513e627aac80e6b765 12-Mar-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: change cpts_active_slave to active_slave

Change cpts_active_slave to active_slave so that the same DT property
can be used to ethtool and SIOCGMIIPHY.

CC: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0237c11044b3670adcbe80cd6dd721285347f497 26-Feb-2013 Daniel Mack <zonque@gmail.com> drivers: net: ethernet: cpsw: consider number of slaves in interation

Make cpsw_add_default_vlan() look at the actual number of slaves for its
iteration, so boards with less than 2 slaves don't ooops at boot.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: David S. Miller <davem@davemloft.net>
Acked-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
510a1e7249298f6bbd049e1ec98041ddf5ef6452 17-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: davinci_cpdma: acknowledge interrupt properly

CPDMA interrupts are not properly acknowledged which leads to interrupt
storm, only cpdma interrupt 0 is acknowledged in Davinci CPDMA driver.
Changed cpdma_ctlr_eoi api to acknowledge 1 and 2 interrupts which are
used for rx and tx respectively.

Reported-by: Pantelis Antoniou <panto@antoniou-consulting.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d9ba8f9e6298af71ec1c1fd3d88c3ef68abd0ec3 11-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: cpsw: dual emac interface implementation

The CPSW switch can act as Dual EMAC by segregating the switch ports
using VLAN and port VLAN as per the TRM description in
14.3.2.10.2 Dual Mac Mode

Following CPSW components will be common for both the interfaces.
* Interrupt source is common for both eth interfaces
* Interrupt pacing is common for both interfaces
* Hardware statistics is common for all the ports
* CPDMA is common for both eth interface
* CPTS is common for both the interface and it should not be enabled on
both the interface as timestamping information doesn't contain port
information.

Constrains
* Reserved VID of One port should not be used in other interface which will
enable switching functionality
* Same VID must not be used in both the interface which will enable switching
functionality

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9232b16df2167c8afcb89de39ee85f5091ebacff 11-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: cpsw: make cpts as pointer

As CPTS is common module for both EMAC in Dual EMAC mode so making cpts as
pointer.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f6e135c81eeb648c6addc6aeff2ee80f28ea413b 11-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: davinci_cpdma: add support for directed packet and source port detection

* Introduced parameter to add port number for directed packet in cpdma_chan_submit
* Source port detection macro with DMA descriptor status

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3b72c2fe0c6bbec42ed7f899931daef227b80322 05-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net:ethernet: cpsw: add support for VLAN

adding support for VLAN interface for cpsw.

CPSW VLAN Capability
* Can filter VLAN packets in Hardware

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e11b220f336c654db876027d40953acef90b0cae 05-Feb-2013 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: cpsw: Add helper functions for VLAN ALE implementation

Add helper functions for VLAN ALE implementations for Add, Delete
Dump VLAN related ALE entries

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b2adaca92c63b9bb8beb021d554f656e387a7648 03-Feb-2013 Joe Perches <joe@perches.com> ethernet: Remove unnecessary alloc/OOM messages, alloc cleanups

alloc failures already get standardized OOM
messages and a dump_stack.

Convert kzalloc's with multiplies to kcalloc.
Convert kmalloc's with multiplies to kmalloc_array.
Fix a few whitespace defects.
Convert a constant 6 to ETH_ALEN.
Use parentheses around sizeof.
Convert vmalloc/memset to vzalloc.
Remove now unused size variables.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fae50823d0ee579e006a7ba2b20880e354388b25 17-Jan-2013 Mugunthan V N <mugunthanvnm@ti.com> net: ethernet: davinci_cpdma: Add boundary for rx and tx descriptors

When there is heavy transmission traffic in the CPDMA, then Rx descriptors
memory is also utilized as tx desc memory looses all rx descriptors and the
driver stops working then.

This patch adds boundary for tx and rx descriptors in bd ram dividing the
descriptor memory to ensure that during heavy transmission tx doesn't use
rx descriptors.

This patch is already applied to davinci_emac driver, since CPSW and
davici_dmac shares the same CPDMA, moving the boundry seperation from
Davinci EMAC driver to CPDMA driver which was done in the following
commit

commit 86d8c07ff2448eb4e860e50f34ef6ee78e45c40c
Author: Sascha Hauer <s.hauer@pengutronix.de>
Date: Tue Jan 3 05:27:47 2012 +0000

net/davinci: do not use all descriptors for tx packets

The driver uses a shared pool for both rx and tx descriptors.
During open it queues fixed number of 128 descriptors for receive
packets. For each received packet it tries to queue another
descriptor. If this fails the descriptor is lost for rx.
The driver has no limitation on tx descriptors to use, so it
can happen during a nmap / ping -f attack that the driver
allocates all descriptors for tx and looses all rx descriptors.
The driver stops working then.
To fix this limit the number of tx descriptors used to half of
the descriptors available, the rx path uses the other half.

Tested on a custom board using nmap / ping -f to the board from
two different hosts.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f9a8f83b04e0c362a2fc660dbad980d24af209fc 14-Jan-2013 Florian Fainelli <florian@openwrt.org> net: phy: remove flags argument from phy_{attach, connect, connect_direct}

The flags argument of the phy_{attach,connect,connect_direct} functions
is then used to assign a struct phy_device dev_flags with its value.
All callers but the tg3 driver pass the flag 0, which results in the
underlying PHY drivers in drivers/net/phy/ not being able to actually
use any of the flags they would set in dev_flags. This patch gets rid of
the flags argument, and passes phydev->dev_flags to the internal PHY
library call phy_attach_direct() such that drivers which actually modify
a phy device dev_flags get the value preserved for use by the underlying
phy driver.

Acked-by: Kosta Zertsekel <konszert@marvell.com>
Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
7826d43f2db45c9305a6e0ba165650e1a203f517 06-Jan-2013 Jiri Pirko <jiri@resnulli.us> ethtool: fix drvinfo strings set in drivers

Use strlcpy where possible to ensure the string is \0 terminated.
Use always sizeof(string) instead of 32, ETHTOOL_BUSINFO_LEN
and custom defines.
Use snprintf instead of sprint.
Remove unnecessary inits of ->fw_version
Remove unnecessary inits of drvinfo struct.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
663e12e61d8764ce342588325d1050d9cb5460c0 03-Dec-2012 Bill Pemberton <wfp5p@virginia.edu> cpsw: remove __dev* attributes

CONFIG_HOTPLUG is going away as an option. As result the __dev*
markings will be going away.

Remove use of __devinit, __devexit_p, __devinitdata, __devinitconst,
and __devexit.

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
3177bf6f922f62743133abbcbbbb5545f4133b2d 27-Nov-2012 Mugunthan V N <mugunthanvnm@ti.com> net: ethernet: cpsw: fix build warnings for CPSW when CPTS not selected

CC drivers/net/ethernet/ti/cpsw.o
drivers/net/ethernet/ti/cpsw.c: In function 'cpsw_ndo_ioctl':
drivers/net/ethernet/ti/cpsw.c:881:20: warning: unused variable 'priv'

The build warning is generated when CPTS is not selected in Kernel Build.
Fixing by passing the net_device pointer to cpts IOCTL instead of passing priv

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
71380f9bb18200ec65ddd2ef117410d1229e2de2 14-Nov-2012 Mugunthan V N <mugunthanvnm@ti.com> net: cpsw: halt network stack before halting the device during suspend

Move network stack halt APIs before halting the hardware to ensure no
packets are queued to hardware during closing the device during
suspend sequence.

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
549985ee9c723fea8fd7759b5046fb8249896d50 14-Nov-2012 Richard Cochran <richardcochran@gmail.com> cpsw: simplify the setup of the register pointers

Instead of having a host of different register offsets in the device tree,
this patch simplifies the CPSW code by letting the driver set the proper
register offsets automatically, based on the CPSW version.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1fb19aa730e400e474b562c55227849060549733 14-Nov-2012 Vaibhav Hiremath <hvaibhav@ti.com> net: cpsw: Add parent<->child relation support between cpsw and mdio

CPGMAC SubSystem consist of various sub-modules, like, mdio, cpdma,
cpsw, etc... These sub-modules are also used in some of Davinci family
of devices. Now based on requirement, use-case and available technology
nodes the integration of these sub-modules varies across devices.

So coming back to Linux net driver, currently separate and independent
platform devices & drivers for CPSW and MDIO is implemented. In case of
Davinci they both has separate control, from resources perspective,
like clock.

In case of AM33XX, the resources are shared and only one register
bit-field is provided to control module/clock enable/disable, makes it
difficult to handle common resource.

So the solution here implemented in this patch is,

Create parent<->child relationship between both the drivers, making
CPSW as a parent and MDIO as its child and enumerate all the child nodes
under CPSW module.
Both the drivers will function exactly the way it was operating before,
including runtime-pm functionality. No change is required in MDIO driver
(for that matter to any child driver).

As this is only supported during DT boot, the parent<->child relationship
is created and populated in DT execution flow. The only required change
is inside DTS file, making MDIO as a child to CPSW node.

Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Peter Korsgaard <jacmet@sunsite.dk>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5250c9694fa879532470d87ebf6a485be1124221 02-Nov-2012 Richard Cochran <richardcochran@gmail.com> cpsw: fix leaking IO mappings

The CPSW driver remaps two different IO regions, but fails to unmap them
both. This patch fixes the issue by calling iounmap in the appropriate
places.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a65dd5b236053fbafb1926b7694fcdb2482b2f73 02-Nov-2012 Richard Cochran <richardcochran@gmail.com> cpsw: rename register banks to match the reference manual, part 2

The code mixes up the CPSW_SS and the CPSW_WR register naming. This patch
changes the names to conform to the published Technical Reference Manual
from TI, in order to make working on the code less confusing.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2e5b38abcfad3049608a051826a5aaec2122cdac 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: support the HWTSTAMP ioctl and the CPTS

This patch hooks into the CPTS code and adds support for the HWTSTAMP
ioctl. The patch includes code for the CPSW version found in the dm814x
even though the background device tree support for this board is still
missing.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
00ab94eeaf6c1ad38ad7368c5148fed31403c8a2 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpts: specify the input clock frequency via DT

This patch adds a way to configure the CPTS input clock scaling factors
via the device tree.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
78ca0b287314ad6b7b06161b3ff9b13e8a8bcce0 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: add a DT field for the active time stamping port

Because time stamping on both external ports of the switch simultaneously
is positively useless from the application's point of view, this patch
provides a DT configuration method to choose the active port.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6b60393e08f9263c7b129d54eeb261e8f970175c 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: add a DT field for the cpts offset

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9750a3ade7b635a18f04371b4fddad0de0b4e6d8 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: support both silicon versions

This patch fixes the cpsw driver to operate correctly with both the
dm814x and the am335x versions of the switch hardware.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e90cfac6c281da3c8b89dba0eb783c23872705b1 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: remember the silicon version

This patch lets the CPSW driver remember the version number in order to
support the two different variants already in the wild.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
bd357af2a52259778dfcc06482dc70463b7b1301 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: add missing fields to the CPSW_SS register bank.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
996a5c27880e40a7e5be2687ee9e486c09bbb29c 29-Oct-2012 Richard Cochran <richardcochran@gmail.com> cpsw: rename register banks to match the reference manual

The code mixes up the CPSW_SS and the CPSW_WR register naming. This patch
changes the names to conform to the published Technical Reference Manual
from TI, in order to make working on the code less confusing.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5c50a856d550b3bf6a731f6e33a794ed5c519817 29-Oct-2012 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: add multicast address to ALE table

Adding multicast address to ALE table via netdev ops to subscribe, transmit
or receive multicast frames to and from the network

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d4e62648274857a2b3a5bc62f910c062e71b2d9b 01-Oct-2012 David S. Miller <davem@davemloft.net> Revert "net: ti cpsw ethernet: allow reading phy interface mode from DT"

This reverts commit d7559982701ac500662b2e8e150ff34f7faf0281.

It wasn't meant to be applied, commit
342b7b741d76bc8aadeff844634348bb2a343d19 ("net: ti cpsw ethernet: set
IFCTL_A bit in MACCONTROL") was redone in such a way to make this
commit unnecessary.

Signed-off-by: David S. Miller <davem@davemloft.net>
d7559982701ac500662b2e8e150ff34f7faf0281 26-Sep-2012 Daniel Mack <zonque@gmail.com> net: ti cpsw ethernet: allow reading phy interface mode from DT

Allow users to specify the phy interface of the CPSW slaves. The new
node parameter is called "phy_if_mode" and is optional. The original
behaviour of the driver is preserved when not given.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
342b7b741d76bc8aadeff844634348bb2a343d19 27-Sep-2012 Daniel Mack <zonque@gmail.com> net: ti cpsw ethernet: set IFCTL_A bit in MACCONTROL

For RMII/RGMII mode operation in 100Mbps, the CPSW needs to set the
IFCTL_A bits in the MACCONTROL register. For all other PHY modes, this
bit is unused, so setting it unconditionally shouldn't cause any
trouble.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mugunthan V N <mugunthanvnm@ti.com>
Cc: Vaibhav Hiremath <hvaibhav@ti.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2eb32b0a6f9d73fafc6b2c00ac0b705de13ae143 30-Jul-2012 Mugunthan V N <mugunthanvnm@ti.com> drivers: net: ethernet: cpsw: Add device tree support to CPSW

This patch adds device tree support for cpsw driver

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f150bd7f8cf742c4cdd0c929aa494ef72f7f5b13 17-Jul-2012 Mugunthan V N <mugunthanvnm@ti.com> driver: net: ethernet: cpsw: runtime PM support

Enabling runtime PM support for cpsw driver

Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7efd26d0db5917b9e53d72e76e52338b2600ae20 12-Jul-2012 Joe Perches <joe@perches.com> ethernet: Use eth_random_addr

Convert the existing uses of random_ether_addr to
the new eth_random_addr.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5c473ed26dba609622c9a625f896f8f59d86066c 20-Mar-2012 David S. Miller <davem@davemloft.net> cpsw: Hook up default ndo_change_mtu.

Reported-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
df828598a755732e717b0adca82f884e44d37576 18-Mar-2012 Mugunthan V N <mugunthanvnm@ti.com> netdev: driver: ethernet: Add TI CPSW driver

This patch adds support for TI's CPSW driver.

The three port switch gigabit ethernet subsystem provides ethernet packet
communication and can be configured as an ethernet switch. Supports
10/100/1000 Mbps.

Signed-off-by: Cyril Chemparathy <cyril@ti.com>
Signed-off-by: Sriramakrishnan A G <srk@ti.com>
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: David S. Miller <davem@davemloft.net>