History log of /drivers/net/ethernet/renesas/sh_eth.c
Revision Date Author Comments
7fa2955ff70ce4532f144d26b8a087095f9c9ffc 28-Nov-2014 Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com> sh_eth: Fix sleeping function called from invalid context

This resolves the following bug which can be reproduced by building the
kernel with CONFIG_DEBUG_ATOMIC_SLEEP=y and reading network statistics
while the network interface is down.

e.g.:

ifconfig eth0 down
cat /sys/class/net/eth0/statistics/tx_errors

----
[ 1238.161349] BUG: sleeping function called from invalid context at drivers/base/power/runtime.c:952
[ 1238.188279] in_atomic(): 1, irqs_disabled(): 0, pid: 1388, name: cat
[ 1238.207425] CPU: 0 PID: 1388 Comm: cat Not tainted 3.10.31-ltsi-00046-gefa0b46 #1087
[ 1238.230737] Backtrace:
[ 1238.238123] [<c0012e64>] (dump_backtrace+0x0/0x10c) from [<c0013000>] (show_stack+0x18/0x1c)
[ 1238.263499] r6:000003b8 r5:c06160c0 r4:c0669e00 r3:00404000
[ 1238.280583] [<c0012fe8>] (show_stack+0x0/0x1c) from [<c04515a4>] (dump_stack+0x20/0x28)
[ 1238.304631] [<c0451584>] (dump_stack+0x0/0x28) from [<c004970c>] (__might_sleep+0xf8/0x118)
[ 1238.329734] [<c0049614>] (__might_sleep+0x0/0x118) from [<c02465ac>] (__pm_runtime_resume+0x38/0x90)
[ 1238.357170] r7:d616f000 r6:c049c458 r5:00000004 r4:d6a17210
[ 1238.374251] [<c0246574>] (__pm_runtime_resume+0x0/0x90) from [<c029b1c4>] (sh_eth_get_stats+0x44/0x280)
[ 1238.402468] r7:d616f000 r6:c049c458 r5:d5c21000 r4:d5c21000
[ 1238.419552] [<c029b180>] (sh_eth_get_stats+0x0/0x280) from [<c03ae39c>] (dev_get_stats+0x54/0x88)
[ 1238.446204] r5:d5c21000 r4:d5ed7e08
[ 1238.456980] [<c03ae348>] (dev_get_stats+0x0/0x88) from [<c03c677c>] (netstat_show.isra.15+0x54/0x9c)
[ 1238.484413] r6:d5c21000 r5:d5c21238 r4:00000028 r3:00000001
[ 1238.501495] [<c03c6728>] (netstat_show.isra.15+0x0/0x9c) from [<c03c69b8>] (show_tx_errors+0x18/0x1c)
[ 1238.529196] r7:d5f945d8 r6:d5f945c0 r5:c049716c r4:c0650e7c
[ 1238.546279] [<c03c69a0>] (show_tx_errors+0x0/0x1c) from [<c023963c>] (dev_attr_show+0x24/0x50)
[ 1238.572157] [<c0239618>] (dev_attr_show+0x0/0x50) from [<c010c148>] (sysfs_read_file+0xb0/0x140)
[ 1238.598554] r5:c049716c r4:d5c21240
[ 1238.609326] [<c010c098>] (sysfs_read_file+0x0/0x140) from [<c00b9ee4>] (vfs_read+0xb0/0x13c)
[ 1238.634679] [<c00b9e34>] (vfs_read+0x0/0x13c) from [<c00ba0ac>] (SyS_read+0x44/0x74)
[ 1238.657944] r8:bef45bf0 r7:00000000 r6:d6ac0600 r5:00000000 r4:00000000
[ 1238.678172] [<c00ba068>] (SyS_read+0x0/0x74) from [<c000eec0>] (ret_fast_syscall+0x0/0x30)
----

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
4d6a949c62f123569fb355b6ec7f314b76f93735 27-Nov-2014 Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com> sh_eth: Fix skb alloc size and alignment adjust rule.

In the current driver, allocation size of skb does not care the alignment
adjust after allocation.
And also, in the current implementation, buffer alignment method by
sh_eth_set_receive_align function has a bug that this function displace
buffer start address forcedly when the alignment is corrected.
In the result, tail of the skb will exceed allocated area and kernel panic
will be occurred.
This patch fix this issue.

Signed-off-by: Mitsuhiro Kimura <mitsuhiro.kimura.kc@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0f76b9d83b2b010b63a094024b3cfd82e20af28d 01-Aug-2014 Hisashi Nakamura <hisashi.nakamura.ak@renesas.com> net: sh_eth: Add r8a7794 support

Signed-off-by: Hisashi Nakamura <hisashi.nakamura.ak@renesas.com>
[uli: added bindings documentation]
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
179d80aff82bf8dff9db30589fe5a2297c454d35 28-Jun-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: remove checks around dev_kfree_skb() calls

Since consume_skb() (and hence dev_kfree_skb() macro) checks the passed pointer
for NULL, there's no need to check for NULL before invoking dev_kfree_skb().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1b72a0fc9c308d9f3255c177945cf383c3c82b0e 10-Jun-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: Fix timing of RACT setting in sh_eth_rx()

This patch fixes an issue that we cannot use nfs rootfs correctly
on r8a7790 when the command below runs on a host PC.

$ sudo ping -f -l 8 $BOARD_IP_ADDR

Since the driver sets the RACT to 1 in the first while loop of
sh_eth_rx(), the controller accepts a next frame into the next RX
descriptor during the while loop. But, in the first while loop
doesn't allocate a next skb. So, this patch removes the RACT setting
in the first while loop of sh_eth_rx().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4f809cea611f1f00a0b7a42751cb12d997a4c11c 10-Jun-2014 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: Fix receive packet "exceeded" condition in sh_eth_rx()

This patch fixes the packet "exceeded" condition in sh_eth_rx() when
RACT in an RX descriptor is not set and the "quota" is 0.
Otherwise, kernel panic happens because the "&n->poll_list" is deleted
twice in sh_eth_poll() which calls napi_complete() and net_rx_action().

Signed-off-by: Kouei Abe <kouei.abe.cp@renesas.com>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d8b0426af5b67973585712c9af36b86f6ea97815 03-Jun-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix SH7619/771x support

Commit 4a55530f38e4 (net: sh_eth: modify the definitions of register) managed
to leave out the E-DMAC register entries in sh_eth_offset_fast_sh3_sh2[], thus
totally breaking SH7619/771x support. Add the missing entries using the data
from before that commit.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
530aa2d0d9d55ab2775d47621ddf4b5b15bc1110 03-Jun-2014 Ben Dooks <ben.dooks@codethink.co.uk> sh_eth: use RNC mode for packet reception

The current behaviour of the sh_eth driver is not to use the RNC bit
for the receive ring. This means that every packet recieved is not only
generating an IRQ but it also stops the receive ring DMA as well until
the driver re-enables it after unloading the packet.

This means that a number of the following errors are generated due to
the receive packet FIFO overflowing due to nowhere to put packets:

net eth0: Receive FIFO Overflow

Since feedback from Yoshihiro Shimoda shows that every supported LSI
for this driver should have the bit enabled it seems the best way is
to remove the RMCR default value from the per-system data and just
write it when initialising the RMCR value. This is discussed in
the message (http://www.spinics.net/lists/netdev/msg284912.html).

I have tested the RMCR_RNC configuration with NFS root filesystem and
the driver has not failed yet. There are further test reports from
Sergei Shtylov and others for both the R8A7790 and R8A7791.

There is also feedback fron Cao Minh Hiep[1] which reports the
same issue in (http://comments.gmane.org/gmane.linux.network/316285)
showing this fixes issues with losing UDP datagrams under iperf.

Tested-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Acked-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
86b5d251d5ac4dda51a022b34cb29b4ce65a8cd5 13-May-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: replace devm_kzalloc() with devm_kmalloc_array()

When I was converting the driver to the managed device API, only devm_kzalloc()
was available for memory allocation, so I had to use it, despite zeroing out the
PHY IRQ array right before initializing all its entries to PHY_POLL was quite
stupid. Now that devm_kmalloc_array() has become available, we can avoid the
needless zeroing out...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.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>
b5893a08812602de164fa5ac6494f84df8d09a4f 21-Mar-2014 Ben Dooks <ben.dooks@codethink.co.uk> sh_eth: ensure pm_runtime cannot suspend the device during init

The pm_rumtime work queue is causing the device to be suspended during
initialisation, thus the initialisation may not be able to access registers
properly. As the code is called from a work queue, it is possible that this
is not seen from certain configurations/builds due to the asynchronos
nature of the code.

Another issue has also been found where the network device registration
calls back into the driver thus causing further pm_runtime calls that
also caused issues with the MDIO bus code. This has now been checked
and is the only place the MDIO can be called without the device open.

Use pm_runtime_get_sync() and pm_runtime_put() to ensure that the
pm system does not suspend it during the probe() call and remove the
now unnecessary pm_runtime_resume() call. Also add a call in the error
path to call pm_runtime_disable().

This fixes the external abort that can cause /sbin/init or other such
init processed to die.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Tested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f738a13d8365b0f824f3f20450b413f55374f175 20-Mar-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: Remove goto statements that jump straight to a return

"goto" is well accepted for error paths in the kernel but should not be
used unnecessarily. Return the correct value directly instead of using a
goto when possible.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
daacf03f0bbfefee3df107c3f7659d22e22538a7 20-Mar-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: Register MDIO bus before registering the network device

Network API functions that rely on the MDIO bus can be called as soon as
the driver calls register_netdev(). Register the MDIO bus before the
network device to avoid race conditions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
bd920ff553ba17f19372501a14e432d9d92b102b 20-Mar-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: Simplify MDIO bus initialization and release

The network device passed to the sh_mdio_init and sh_mdio_release
functions is only used to access the sh_eth_private instance. Pass it
directly to those functions.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
a5bd60608936fbb84471a80592401ce29a68de71 20-Mar-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: Use the platform device as the MDIO bus parent

The MDIO bus parent is set to the network device. Beside not reflecting
the hardware topology, this prevents registering the MDIO bus before
initializing the network device. Fix it by setting the MDIO bus parent
to the platform device.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
aa8d422510969b705656e49fc0166d862aca9246 20-Mar-2014 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: Use the platform device for memory allocation

Memory allocated for the MDIO bus with the devm_kzalloc() API is
associated with the network device. While this will cause memory to be
freed at the right time, it doesn't allow allocating memory before the
network device is initialized.

Replace the network device with the parent platform device for memory
allocation to remove that dependency. This also improves consistency
with the other devm_* calls in the driver that all use the platform
device.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
8d5009f6a9d9f4ef62a39bf68b53379b2b766c1c 15-Mar-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fold netif_msg_*() and netdev_*() calls into netif_*() invocations

Now that we call netdev_*() under netif_msg_*() checks, we can fold these into
netif_*() macro invocations.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
da2468555643efbde3fb026cd46e5245800cc872 15-Mar-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: convert dev_*() to netdev_*() calls

Convert dev_*(&ndev->dev, ...) to netdev_*(ndev, ...) calls since they are a bit
shorter and at the same time give more information on a device.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f75f14ec2f7b552dc87b4b57b2a19e487378f774 15-Mar-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: convert pr_*() to netdev_*() calls

Convert pr_*() to netdev_*() calls as the latter provide info on a device.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
264be2f5a973cc85be3e31d6bf6234b55a256627 15-Mar-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: exit probe with unknown register layout

Exit the driver's probe() method when the register layout is unknown as the
driver would cause kernel oops in this case anyway.

While at it, move the corresponding error message printout and convert it from
pr_err() to dev_err().

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
702eca02b7c8574b42359512ebccfa777a71f66e 12-Mar-2014 Ben Dooks <ben.dooks@codethink.co.uk> sh_eth: update OF PHY registeration

If the sh_eth device is registered using OF, then the driver
should call of_mdiobus_register() to register the PHYs described
in the devicetree and then use of_phy_connect() to connect the
PHYs to the device.

This ensures that any PHYs registered in the device tree are
appropriately connected to the parent devices nodes so that
the PHY drivers can access their OF properties.

Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
b356e978e92fccd17a3e4620a4821bdbfb706c1a 18-Feb-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add device tree support

Add support of the device tree probing for the Renesas SH-Mobile SoCs
documenting the device tree binding as necessary.

This work is loosely based on the original patch by Nobuhiro Iwamatsu
<nobuhiro.iwamatsu.yj@renesas.com>.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
730c8c69bc8d4640336885e20e719b0842d0fcb2 14-Feb-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: use ETH_ZLEN instead of home-grown #define

The driver #define's and uses ETHERSMALL macro for the minimum Ethernet frame
size for which we have a standard macro ETH_ZLEN. Use the latter instead of
the home-grown one.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
db893473d313a4ad9455e89d1bd5e136a57f411e 17-Jan-2014 Simon Horman <horms+renesas@verge.net.au> sh_eth: Add support for r7s72100

The r7s72100 SoC includes a fast ethernet controller.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
504c8ca55c70fb6cab0b97381e70ad0e143f539e 17-Jan-2014 Simon Horman <horms+renesas@verge.net.au> sh_eth: Use bool as return type of sh_eth_is_gether()

Return a boolean from sh_eth_is_gether() and refactor it as a one-liner.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a81ab36bf52d0ca3a32251a923be1dbced726141 08-Jan-2014 Paul Gortmaker <paul.gortmaker@windriver.com> drivers/net: delete non-required instances of include <linux/init.h>

None of these files are actually using any __init type directives
and hence don't need to include <linux/init.h>. Most are just a
left over from __devinit and __cpuinit removal, or simply due to
code getting copied from one driver to the next.

This covers everything under drivers/net except for wireless, which
has been submitted separately.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
090d560fc4723f61b561c8fceb810d4645b49b4c 11-Jan-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix garbled TX error message

sh_eth_error() in case of a TX error tries to print a message using 2 dev_err()
calls with the first string not finished by '\n', so that the resulting message
would inevitably come out garbled, with something like "3net eth0: " inserted
in the middle. Avoid that by merging 2 calls into one.

While at it, insert an empty line after the nearby declaration.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
128296fc3fa2f607050cc2c5d6dc90237f3cedb3 03-Jan-2014 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: coding style fixes

Running 'scripts/checkpatch.pl' on the driver files gives numerous warnings:

- block comments using empty /* line;

- unneeded \ at end of lines;

- message string split across lines;

- use of __attribute__((aligned(n))) instead of __aligned(n) macro;

- use of __attribute__((packed)) instead of __packed macro.

Additionally, running 'scripts/checkpatch.pl --strict' gives more complaints:

- including the paragraph about writing to FSF into the heading comment;

- alignment not matching open paren;

- multiple assignments on one line;

- use of CamelCase names;

- missing {} on one of the *if* arms where another has them;

- spinlock definition without a comment.

While fixing these, also do some more style cleanups:

- remove useless () around expressions;

- add {} around multi-line *if* operator's arm;

- remove space before comma;

- add spaces after /* and before */;

- properly align continuation lines of broken up expressions;

- realign comments to the structure fields.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c4bde29cb0f3a520e3dd666e523f9a576a47a47a 30-Dec-2013 dingtianhong <dingtianhong@huawei.com> net: renesas: slight optimization of addr compare

Use possibly more efficient ether_addr_equal
to instead of memcmp.

Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
4174ecd78f6591a3d1ec04738ef7bc900a11f5ce 19-Dec-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: do not reset PHY needlessly

There's no need anymore to call phy_init_hw() to reset/resume the PHY from the
driver, as the call chain in phylib already has reached it, and so reset/resumed
the PHY (even resuming it twice). This duplicate reset is not only needless, it
e.g. clears the PHY's interrupt enables just setup by phylib and so prevents the
expected IRQs from the PHY.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
18be099badcfc4a12f058addc55c4270d5a8bec8 19-Dec-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add PHY IRQ to platform data

Allow the platform code to pass PHY's IRQ to the driver. Print this IRQ along
with the other PHY datails in sh_eth_phy_init().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
94a12b15e4c575e0aa0ba5e24a4f213163a823d0 08-Dec-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add R8A7791 support

Add support for yet another ARM member of the R-Car family, R-Car M2, also known
as R8A7791 -- it will share the code and data with previously added R8A7790.
Despite the Ether devices in these SoCs are indistinguishable at least from the
driver's point of view, we do introduce a new platform device ID "r8a7791-ether"
unlike the wildcard ID used for R8A7778/9 SoCs, due to newly established policy
for the Renesas SoCs.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0c9eb5b931c3da3a79faa889b903dc7bd318203c 06-Dec-2013 Florian Fainelli <f.fainelli@gmail.com> net: sh_eth: do not issue a wild PHY reset through BMCR

The sh_eth driver issues an uncontrolled PHY reset through the MII
register BMCR but fails to wait for the reset to complete, and will also
implicitely wipe out all possible PHY fixups applied. Use phy_init_hw()
which remedies both problems.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3b4c5cbf42bda976ab70354e7786a0808265d9d5 30-Oct-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: check platform data pointer

Check the platform data pointer before dereferencing it and error out of the
probe() method if it's NULL.

This has additional effect of preventing kernel oops with outdated platform data
containing zero PHY address instead (such as on SolutionEngine7710).

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
305a3388b5b3121aff6b10054136b40ca91ab35b 16-Oct-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add/use RMCR.RNC bit

Declare 'enum RMCR_BIT' containing the single member for the RMCR.RNC bit and
replace bare numbers in the driver by this mnemonic.

Suggested-by: David Miller <davem@davemloft.net>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
cc23528db0300d5c8c0b98670a577bf1dc3e0e82 10-Oct-2013 Simon Horman <horms+renesas@verge.net.au> net: sh_eth: Correct fix for RX packet errors on R8A7740

Nguyen Hong Ky posted a patch to correct RX packet errors on R8A7740 which
was applied as 2c6221e4a5aab417 ("net: sh_eth: Fix RX packets errors on
R8A7740"). Unfortunately sh_eth.c contains many similar instances
of struct sh_eth_cpu_data and the patch was miss-applied, updating
sh7734_data instead of r8a7740_data.

This patch corrects this problem by.
1. Reverting the change to sh7734_data and;
2. Applying the change to r8a7740_data.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
2c6221e4a5aab417cb18bef6f1130d1374240258 07-Oct-2013 Nguyen Hong Ky <nh-ky@jinso.co.jp> net: sh_eth: Fix RX packets errors on R8A7740

This patch will fix RX packets errors when receiving big size
of data by set bit RNC = 1.

RNC - Receive Enable Control

0: Upon completion of reception of one frame, the E-DMAC writes
the receive status to the descriptor and clears the RR bit in
EDRRR to 0.

1: Upon completion of reception of one frame, the E-DMAC writes
(writes back) the receive status to the descriptor. In addition,
the E-DMAC reads the next descriptor and prepares for reception
of the next frame.

In addition, for get more stable when receiving packets, I set
maximum size for the transmit/receive FIFO and inserts padding
in receive data.

Signed-off-by: Nguyen Hong Ky <nh-ky@jinso.co.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
d458cdf712e0c671e8e819abb16ecd6e44f9daec 02-Oct-2013 Joe Perches <joe@perches.com> net:drivers/net: Miscellaneous conversions to ETH_ALEN

Convert the memset/memcpy uses of 6 to ETH_ALEN
where appropriate.

Also convert some struct definitions and u8 array
declarations of [6] to ETH_ALEN.

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d2779e99468fd83ef1493c34f3803fec9aad8345 04-Sep-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix napi_{en|dis}able() calls racing against interrupts

While implementing NAPI for the driver, I overlooked the race conditions where
interrupt handler might have called napi_schedule_prep() before napi_enable()
was called or after napi_disable() was called. If RX interrupt happens, this
would cause the endless interrupts and messages like:

sh-eth eth0: ignoring interrupt, status 0x00040000, mask 0x01ff009f.

The interrupt wouldn't even be masked by the kernel eventually since the handler
would return IRQ_HANDLED all the time.

As a fix, move napi_enable() call before request_irq() call and napi_disable()
call after free_irq() call.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a8e9fd0f7462f5cada5189513d12fe6c9cce2105 03-Sep-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: NAPI requires netif_receive_skb()

Driver supporting NAPI should use NAPI-specific function for receiving packets,
so netif_rx() should be changed to netif_receive_skb().

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fd9af07c3404ac9ecbd0d859563360f51ce1ffde 29-Aug-2013 Kouei Abe <kouei.abe.cp@renesas.com> sh_eth: Enable Rx descriptor word 0 shift for r8a7790

This corrects an oversight when r8a7790 support was added to sh_eth.

Signed-off-by: Kouei Abe <kouei.abe.cp@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
7db8e0c14c9cb4adb667b4c558d8ffec8d5b40f2 29-Aug-2013 Kouei Abe <kouei.abe.cp@renesas.com> sh_eth: Fix cache invalidation omission of receive buffer

Signed-off-by: Kouei Abe <kouei.abe.cp@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
0b76b86235296efeabe49f79a3e70336cff9664e 30-Aug-2013 Jingoo Han <jg1.han@samsung.com> net: sh_eth: use dev_get_platdata()

Use the wrapper function for retrieving the platform data instead of
accessing dev->platform_data directly. This is a cosmetic change
to make the code simpler and enhance the readability.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
488594883e25cc6e40df067a9a7b39737ebb18d8 29-Aug-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: no need to call ether_setup()

There's no need to call ether_setup() in the driver since prior alloc_etherdev()
call already arranges for it.

Suggested-by: Denis Kirjanov <kda@linux-powerpc.org>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a3153d8c41132d6fda080a4b3e53b7ee25d3c125 18-Aug-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get register layout from 'struct sh_eth_cpu_data'

The register layout is a SoC characteristic, so it's wrong that it's stored
in the otherwise board specific platform data. Add 'register_type' field to
'struct sh_eth_cpu_data', initialize it properly for each SoC, and read it
from this structure instead of the platfrom data from now on...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ba361cb3d4c977e2b94b5d97905f66b4d48964de 31-Jul-2013 Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> sh_eth: r8a7790: Handle the RFE (Receive FIFO overflow Error) interrupt

The RFE interrupt is enabled for the r8a7790 but isn't handled,
resulting in the interrupts core noticing unhandled interrupts, and
eventually disabling the ethernet IRQ.

Fix it by adding RFE to the bitmask of error interrupts to be handled
for r8a7790.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
e18dbf7efcb7a727e5db773597ddfd6981a530e6 23-Jul-2013 Simon Horman <horms+renesas@verge.net.au> sh_eth: Add support for r8a7790 SoC

This is a copy of support for r8a7778/9 with the .rmiimode mode bit
of struct sh_eth_cpu_data set.

Also update R8A7779 to R8A777x.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
55754f19d7ee4fa3633f55a4a084af8590c35efa 23-Jul-2013 Simon Horman <horms+renesas@verge.net.au> sh_eth: add support for RMIIMODE register

This register is prsent on the r8a7790 SoC.

Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
4eb313a7a939a983c525648227b5fe0a9d41679f 20-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix misreporting of transmit abort

Due to obviously missing braces, EESR.TABT (transmit abort) interrupt may be
reported even if it hasn't happened, just when EESR.TWB (transmit descriptor
write-back) interrupt happens. Luckily (?), EESR.TWB is disabled by the driver
via the TRIMD register and all the interrupt masks, so that transmit abort is
never actually logged...

Put the braces where they should be and fix the incoherent comment, while at it.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ca8c35852138ee0585eaffe6b9f10a5261ea7771 20-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix unhandled RFE interrupt

EESR.RFE (receive FIFO overflow) interrupt is enabled by the driver on all SoCs
and sh_eth_error() handles it but it's not present in any initializer/assignment
of the 'eesr_err_check' field of 'struct sh_eth_cpu_data'. This leads to that
interrupt not being handled and cleared, and finally to disabling IRQ and the
driver being non-functional.

Modify DEFAULT_EESR_ERR_CHECK macro and all explicit initializers of the above
mentioned field to contain the EESR.RFE bit. Remove useless backslashes from the
initializers, while at it.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ac8025a643a0e0beb81f3f37ca693364c6b77858 13-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get R8A7740 Rx descriptor word 0 shift out of #ifdef

The only R8A7740 specific #ifdef hindering ARM multiplatform build is left in
sh_eth_rx(): it covers the code shifting Rx buffer descriptor word 0 by 16. Get
rid of the #ifdef by adding 'shift_rd0' field to the 'struct sh_eth_cpu_data',
making the shift dependent on it, and setting it to 1 for the R8A7740 case...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a80c3de714bc4855747faf5f00e8203fb800e6bb 20-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: remove redundant bits from 'eesipr_value' field initializer

For SH7724 'eesipr_value' field initializer includes DMAC_M_RFRMER & DMAC_M_ECI
bits which are already contained in 0x01ff009f -- remove them.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8f80899665c4baca5fe18e919a18db818c3e11fa 20-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: remove 'tx_error_check' field of 'struct sh_eth_cpu_data'

The 'tx_error_check' field of 'struct sh_eth_cpu_data' is write-only, so remove
it along with the DEFAULT_TX_ERROR_CHECK macro.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3719109d61ca96746c733538ec776d02a6952640 19-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add NAPI support

The driver hasn't used NAPI so far; implement its support at last...

The patch was tested on Renesas R8A77781 BOCK-W board.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ea7d69e75ac06daa7bc2fca2a8317197e5e3c81c 19-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: define/use EESR_RX_CHECK macro

sh_eth_interrupt() uses the same Rx interrupt mask twice to check the interrupt
status register -- #define EESR_RX_CHECK and use it instead.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dd019897358b815f7828dab90b51d51df4d3658d 13-Jun-2013 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix incorrect RX length error if R8A7740

This patch fixes an issue that the driver increments the "RX length error"
on every buffer in sh_eth_rx() if the R8A7740.
This patch also adds a description about the Receive Frame Status bits.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8e994402ad5e6ae3d391c0935f9f1dc2eeb92a5e 12-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: remove '__maybe_unused' annotations

Now that the SoC specific support is no longer done with help of #ifdef'fery,
we no longer need '__maybe_unused' annotations to sh_eth_select_mii() and
sh_eth_set_duplex()...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
8f728d7934c77f63e89abcc96b46a7a98416d5c1 12-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: split 'sh_eth_netdev_ops'

Commit 9f86134155047720a3685cda21467f68695152d2 (sh_eth: remove SH_ETH_HAS_TSU)
removes 'const' from 'sh_eth_netdev_ops' and modifies it in case TSU registers
are present. I've originally suggested to Iwamatsu-san to split this structure
in two instead and afterwards Dave M. suggested doing the same.
Split 'sh_eth_netdev_ops_tsu' from 'sh_eth_netdev_ops', making both 'const', and
assigning 'ndev->detdev_ops' depending on the presence of TSU registers.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9f8c4265bda4a6e9aa97041d5cfd91386f460b65 05-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix result of sh_eth_check_reset() on timeout

When the first loop in sh_eth_check_reset() runs to its end, 'cnt' is 0, so the
following check for 'cnt < 0' fails to catch the timeout. Fix the condition in
this check, so that the timeout is actually reported.
While at it, fix the grammar in the failure message...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e403d295817cf9f8be3110eb7ee1a03981287495 08-Jun-2013 David S. Miller <davem@davemloft.net> sh_eth: Fix warnings on 64-bit.

Don't cast a plain integer to a pointer.

drivers/net/ethernet/renesas/sh_eth.c: In function ‘sh_eth_chip_reset_giga’:
drivers/net/ethernet/renesas/sh_eth.c:482:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/net/ethernet/renesas/sh_eth.c:483:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/net/ethernet/renesas/sh_eth.c:492:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
drivers/net/ethernet/renesas/sh_eth.c:493:22: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Signed-off-by: David S. Miller <davem@davemloft.net>
589ebdef7e3107401bf96a9c660753d397329ee9 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get R8A777x support out of #ifdef

Get the R-Car code/data in the driver out of #ifdef by adding "r8a777x-ether" to
the platfrom driver's ID table; since it's the last #ifdef, we remove CARDNAME
from the ID table and no longer check the driver data before assigning it to
'mdp->cd'...
Change the Ether platform device's name in the ARM platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9c3beaabb951d672b1534c7f56f84054b088f879 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get SH7724 support out of #ifdef

Get the SH7724 code/data in the driver out of #ifdef by adding "r8a7724-ether"
to the platform driver's ID table. Change the Ether platform device's name in
the SH platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
24549e2a0f33628b5160eac16c6aebf1cfaf22f1 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get SH7757 support out of #ifdef

Get the SH7757 code/data in the driver out of #ifdef by adding "sh7757-ether"
and "sh7757-gether" to the platform driver's ID table. Note that we can remove
SH_ETH_HAS_BOTH_MODULES and sh_eth_get_cpu_data().
Change the Ether/GEther platform devices' names in the SH platform code
accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f5d12767c8fd77e29d3d6771de59fd9ac3e540bb 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get SH77{34|63} support out of #ifdef

Get the SH77{34|63} specific code/data in the driver out of #ifdef by adding
"sh7734-gether" and "sh7763-gether" to the platform driver's ID table. Note
that we have to split the 'struct sh_eth_cpu_data' instance into two due to
#ifdef inside it; note that we can kill the duplicate sh_eth_set_rate_gether().
Change the GEther platform device's name in the SH platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
e5c9b4cd665106d9b5397114ea81a53059410b6a 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get R8A7740 support out of #ifdef

Get the R8A7740 code/data in the driver out of #ifdef by adding "r8a7740-gether"
to the platform driver's ID table. Change the GEther platform device's name in
the ARM platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c18a79abe31f555ec3b363b5b8c1d003230053b6 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get SH7619 support out of #ifdef

Get the SH7619 data in the driver out of #ifdef by adding "sh7619-ether" to the
platform driver's ID table. Change the Ether platform device's name in the SH
platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
7bbe150d8c57c59689c8c50fd7b9915f4a7e10da 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: get SH771x support out of #ifdef

Get the SH771[02] data in the driver out of #ifdef by adding "sh771x-ether" to
the platform driver's ID table. Change the Ether platform device's name in the
SH platform code accordingly.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
afe391ad4b05f8f00ca955e165f3b37b480506b7 07-Jun-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: create initial ID table

We are trying to get away from the current driver's scheme of identifying a SoC
based on #ifdef's and the platform device ID table matching seems to be a good
replacement -- we can use the 'driver_data' field of 'struct platform_device_id'
as a pointer to a 'struct sh_eth_cpu_data'. Start by creating the initial table
with driver's name as the only entry without the driver data. Check the driver
data in the probe() method and if it's not NULL override 'mdp->cd' from it.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
540ad1b888ad9564520c1c8c48ad675f76ffce62 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: enclose PM code into #ifdef CONFIG_PM

Put '#ifdef CONFIG_PM' around sh_eth_runtime_nop() and 'sh_eth_dev_pm_ops'.
Add '#define SH_ETH_PM_OPS' to facilitate initialization of driver's 'pm' field
depending on whether CONFIG_PM is enabled.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dabdde9ea77d4a77094726c82468a3bd767fb29b 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: consolidate sh_eth_reset()

This driver has sh_eth_reset() function for each SoC and this function is almost
always the same, except for the several a bit different variations for Gigabit
Ethernet. Consolidate every variation into a single function -- which allows
us to get rid of some more #ifdef'fery.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: moved the new sh_eth_reset() and sh_eth_is_gether() up to decrease the
patch size, fixed function call continuation lines' indentation, reworded the
changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
b7feacf1ee6944fc571802d58dcffaf13b4fb4cc 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: remove #ifdef around sh_eth_select_mii()

We can simply remove #ifdef'fery around sh_eth_select_mii(). We have to annotate
it with '__maybe_unused' then.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5b3dfd13ae8bdebea67c02612fe282baff850bb0 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: add IRQ flags to 'struct sh_eth_cpu_data'

The driver supports some SH and SH-Mobile SOCs. There are SOCs with two or more
Ethernet devices, for these we need to pass IRQF_SHARED to request_irq(). Add
the 'irq_flags' field to the 'struct sh_eth_cpu_data' instead of #ifdef'fery.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: properly aligned request_irq() call continuation line, reworded the
changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
9f86134155047720a3685cda21467f68695152d2 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: remove SH_ETH_HAS_TSU

Remove SH_ETH_HAS_TSU #define's and #ifdef's. Set three 'struct net_device_ops'
methods that depend on the presence of TSU basing on the 'tsu' field of 'struct
sh_eth_cpu_data'.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: made two method assignments one-liners, added the changelog, reworded
the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
04b0ed2ad49834fe47d3c4171ad189c688a222b9 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: remove duplicate sh_eth_set_duplex() definitions

Remove all the duplicate definitions of sh_eth_set_duplex() under different
#ifdef's, leaving only one outside the #ifdef's. We have to annotate it with
'__maybe_unused' since it's called not from all SoC #ifdef blocks.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: annotated sh_eth_set_duplex() as '__maybe_unused', added the changelog,
reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ddcd91c6b8ec60a6bd5d3691d2cfaf4447215da1 06-Jun-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> sh_eth: use EDSR_ENALL to set EDSR

Use now always available EDSR_ENALL instead of the bare number to set EDSR.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
[Sergei: added the changelog, reworded the subject, changing the prefix.]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.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>
042c730aa1a134c88c9afccef529694825891640 12-May-2013 Wolfram Sang <wsa@the-dreams.de> drivers/net/ethernet/renesas: don't check resource with devm_ioremap_resource

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
d6a98c9680a6f885715ce64daa5de73b33d3edd4 16-May-2013 Wolfram Sang <wsa@the-dreams.de> drivers/net/ethernet/renesas: don't check resource with devm_ioremap_resource

devm_ioremap_resource does sanity checks on the given resource. No need to
duplicate this in the driver.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
ff6e722870ddca2808b5d46159e58904f8ededf1 29-Apr-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: use random MAC address if no valid one supplied

On Renesas R-Car based development boards, although a MAC address is printed on
all the Ethernet port labels, U-Boot doesn't write a valid MAC address to the
Ether MAHR/MALR registers (there's no storage provided for the Ether MAC address
either), so we have to resort to using a random MAC address...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
674853b222168f2066db028cad89ab52cbcdeee5 27-Apr-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add R8A77781 support

Add support for another ARM member of the R-Car family, R-Car M1A, also known as
R8A77781 -- it will share the code with previously added R8A77790.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.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>
3340d2aae3433ad9147f6bf0adc452b324e31591 31-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: make 'link' field of 'struct sh_eth_private' *int*

The 'link' field of 'struct sh_eth_private' has type 'enum phy_state' while the
'link' field of 'struct phy_device' is merely *int* (having values 0 and 1) and
the former field gets assigned from the latter. Make the field match, getting
rid of incorrectly used PHY_DOWN value in assignments/comparisons.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3893b27345ac0ff13c1b9ec20ad50966b810997e 31-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: workaround for spurious ECI interrupt

At least on Renesas R8A7778, EESR.ECI interrupt seems to fire regardless of its
mask in EESIPR register. I can 100% reproduce it with the following scenario:
target is booted with 'ip=on' option, and so IP-Config opens SoC Ether device
but doesn't get a proper reply and then succeeds with on-board SMC chip; then
I login and try to bring up the SoC Ether device with 'ifconfig', and I get
an ECI interrupt once request_irq() is called by sh_eth_open() (while interrupt
mask in EESIPR register is all 0), if that interrupt is accompanied by a pending
EESR.FRC (frame receive completion) interrupt, I get kernel oops in sh_eth_rx()
because sh_eth_ring_init() hasn't been called yet!

The solution I worked out is the following: in sh_eth_interrupt(), mask the
interrupt status from EESR register with the interrupt mask from EESIPR register
in order not to handle the disabled interrupts -- but forcing EESIPR.M_ECI bit
in this mask set because we always need to fully handle EESR.ECI interrupt in
sh_eth_error() in order to quench it (as it doesn't get cleared by just writing
1 to the this bit as all the other interrupts).

While at it, remove unneeded initializer for 'intr_status' variable and give it
*unsigned long* type, matching the type of sh_eth_read()'s result; fix comment.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: Max Filippov <max.filippov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
1e1b812bbe1069fc8e2e372dca7d5f541c7a8ceb 31-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix handling of no LINK signal

The code handling the absent LINK signal (or the absent PSR register -- which
reflects the state of this signal) is quite naive and has probably never really
worked. It's probably enough to say that this code is executed only on the LINK
change interrupt (sic!) but even if we actually have the signal and choose to
ignore it (it might be connected to PHY's link/activity LED output as on the
Renesas BOCK-W board), sh_eth_adjust_link() on which this code relies to update
'mdp->link' gets executed later than the LINK change interrupt where it is
checked, and so RX/TX never get enabled via ECMR register.

So, ignore the LINK changed interrupt iff LINK signal is absent (or just chosen
not to be used) or PSR register is absent, and enable/disable RX/TX directly in
sh_eth_adjust_link() in this case.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a3f109bd793dfe5c611220ca5ab6c72f1aed479e 28-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: add R-Car support for real

Commit d0418bb7123f44b23d69ac349eec7daf9103472f (net: sh_eth: Add eth support
for R8A7779 device) was a failed attempt to add support for one of members of
the R-Car SoC family. That's for three reasons: it treated R8A7779 the same
as SH7724 except including quite dirty hack adding ECMR_ELB bit to the mask
in sh_eth_set_rate() while not removing ECMR_RTM bit (despite it's reserved in
R-Car Ether), and it didn't add a new register offset array despite the closest
SH_ETH_REG_FAST_SH4 mapping differs by 0x200 to the offsets all the R-Car Ether
registers have, and also some of the registers in this old mapping don't exist
on R-Car Ether (due to this, SH7724's 'sh_eth_my_cpu_data' structure is not
adequeate for R-Car too). Fix all these shortcomings, restoring the SH7724
related section to its pristine state...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c0013f6f8bbcb7605d591431444780d636dbe223 28-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: move data from header file to driver

The driver's header file contains initialized register offset tables which (as
any data definitions), of course, have no business being there. Move them to
the driver's body, somewhat beautifying the initializers, while at it...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fe0e76f7e7107ca6dcb869da6d28dd2ba9be36b3 21-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix unused variable warning

Commit d5e07e69218fd9aa21d6c8c5ccc629d92bdb9b0f (sh_eth: use managed device API)
has caused this warning (due to my overlook):

drivers/net/ethernet/renesas/sh_eth.c: In function `sh_eth_drv_remove':
drivers/net/ethernet/renesas/sh_eth.c:2482:25: warning: unused variable `mdp'
[-Wunused-variable]

Kill the darn variable now...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d5e07e69218fd9aa21d6c8c5ccc629d92bdb9b0f 21-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: use managed device API

Switch the driver to the managed device API by replacing ioremap() calls with
devm_ioremap_resource() (that will also result in calling request_mem_region()
which the driver forgot to do until now) and k[mz]alloc() with devm_kzalloc() --
this permits to simplify driver's probe()/remove() method cleanup. We can now
remove the ioremap() error messages since the error messages are printed by
devm_ioremap_resource() itself. We can also remove the 'bitbang' field from
'struct sh_eth_private' as we don't need it anymore in order to free the memory
behind it...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
564044b0928d46a87774c246ae80cb3cead9264d 21-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: kill unneeded typecast in sh_eth_drv_probe()

sh_eth_drv_probe() does cast from 'void *' when assigning to the 'pd' variable
which is automatic anyway. Turn the assignment into initializer, while removing
the cast...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
dfed5e7fb4ec946694cad7400d75c44f3bb7f645 21-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: use PIR_* bits

sh_mdio_init() uses the bare numbers instead of the PHY interface bits, despite
these are declared in sh_eth.h as 'enum PIR_BIT'...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14c3326a111b948cabc35d523a43a1e6663f6091 20-Mar-2013 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> net: sh-eth: Use pr_err instead of printk

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
fc0c0900408e05758a0df17c1924ca837fafca5e 19-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: check TSU registers ioremap() error

One must check the result of ioremap() -- in this case it prevents potential
kernel oops when initializing TSU registers further on...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0582b7d15f8a7ae53dd2128b8eb01567b3fd2277 19-Mar-2013 Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> sh_eth: fix bitbang memory leak

sh_mdio_init() allocates pointer to 'struct bb_info' but only stores it locally,
so that sh_mdio_release() can't free it on driver unload. Add the pointer to
'struct bb_info' to 'struct sh_eth_private', so that sh_mdio_init() can save
'bitbang' variable for sh_mdio_release() to be able to free it later...

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d0320f750093d012d3ed69fc1e8b385f654523d5 14-Mar-2013 Joe Perches <joe@perches.com> drivers:net: Remove dma_alloc_coherent OOM messages

I believe these error messages are already logged
on allocation failure by warn_alloc_failed and so
get a dump_stack on OOM.

Remove the unnecessary additional error logging.

Around these deletions:

o Alignment neatening.
o Remove unnecessary casts of dma_alloc_coherent.
o Hoist assigns from ifs.

Signed-off-by: Joe Perches <joe@perches.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>
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>
8f6352f2b5aecd4b0af5ef31361af1146f9528d6 02-Nov-2012 YOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org> net: sh_eth: Fix a typo - replace regist with register.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
043c4789726e6abb5be6115cb054af4926481952 05-Oct-2012 Peter Senna Tschudin <peter.senna@gmail.com> drivers/net/ethernet/renesas/sh_eth.c: fix error return code

The function sh_eth_drv_probe() return 0 for success and negative value
for most of its internal tests failures. There is one exception
that is error case going to out_release:. For this error case, the
function abort its success execution path, but returns non negative
value, making it difficult for a caller function to notice the error.

This patch fixes the error case that do not return negative value.

This was found by Coccinelle, but the code change was made by hand.
This patch is not robot generated.

A simplified version of the semantic match that finds this problem is
as follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
{ ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
when != &ret
*if(...)
{
... when != ret = e2
when forall
return ret;
}
// </smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d0418bb7123f44b23d69ac349eec7daf9103472f 14-Aug-2012 Phil Edworthy <PHIL.EDWORTHY@renesas.com> net: sh_eth: Add eth support for R8A7779 device

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
525b8075edda9c2ab4b81e210505bd7487ea6e56 26-Jun-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: add support for set_ringparam/get_ringparam

This patch supports the ethtool's set_ringparam() and get_ringparam().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
91c77550000a7d888aaf9f9ac13e3e3485d18560 26-Jun-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix up the buffer pointers

After freeing the buffer, the driver should change the value of
the pointer to NULL.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2ecbb783c3bf5a63f555c39deef308dcc1902b7f 26-Jun-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: remove unnecessary members/definitions

This patch removes unnecessary members in sh_th_private.
This patch also removes unnecessary definitions in sh_eth.h

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
c26502680e59af556211fc3fd3ae0f2aa5d98440 26-Jun-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: remove unnecessary function

The sh_eth_timer() called mod_timer() for itself. So, this patch
removes the function.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5cee1d37c9f565f1aa515408863dbb13db67dab9 25-Jun-2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> net/sh-eth: Check return value of sh_eth_reset when chip reset fail

The sh_eth_reset function resets chip, but this performs nothing when failed.
This changes sh_eth_reset return an error, when this failed in reset.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
5e7a76be0e48217aff6b6f34bdcce4725db999e2 25-Jun-2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> net/sh-eth: Add support selecting MII function for SH7734 and R8A7740

Ethernet IP of SH7734 and R8A7740 has selecting MII register.
The user needs to change a value according to MII to be used.
This adds the function to change the value of this register.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
a18e08bdcf845efb7344cea146e683df746bbfb4 20-Jun-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix the condition to fix the cur_tx/dirty_rx

The following commit couldn't work if the RMCR is not set to 1.

"net: sh_eth: fix the rxdesc pointer when rx descriptor empty happens"
commit id 79fba9f51755c704c0a7d7b7f0df10874dc0a744

If RMCR is not set, the controller will clear the EDRRR after it received
a frame. In this case, the driver doesn't need to fix the value of
cur_rx/dirty_rx. The driver only needs it when the controll detects
receive descriptors are empty.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
79fba9f51755c704c0a7d7b7f0df10874dc0a744 29-May-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix the rxdesc pointer when rx descriptor empty happens

When Receive Descriptor Empty happens, rxdesc pointer of the driver
and actual next descriptor of the controller may be mismatch.
This patch fixes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
73a0d907301ece200d32b4e8ba2da2ca296b507f 04-Apr-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: add support R8A7740

The R8A7740 has a Gigabit Ethernet MAC. This patch supports it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
10b9194f959608368ed89df1937f17cfe6bd6d84 29-Mar-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix endian check for architecture independent

SuperH has the "CONFIG_CPU_LITTLE_ENDIAN" and the "__LITTLE_ENDIAN__".
But, other architecture doesn't have them. So, this patch fixes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
f0e81fecd4f83de7854262c8a6b3af19dfa99bf9 25-Mar-2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> net: sh_eth: Add support SH7734

Add define of SH7734 register and sh_eth_reset_hw_crc function.

V3: Rebase net/HEAD.
V2: Do not split line of #if defined.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
71cc7c37af71b497698f7f8a68e46a458071fcef 15-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: add support for VLAN tag filtering

Some controllers have TSU. It can register one VLAN tag, and it can
filter other VLAN tag by hardware.
If vlan_rx_add_vid() is called twice or more, the driver will disable
the filtering.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6743fe6df43b4dc5950f605edfeee086d0a80f06 15-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: add support for multicast filtering

Some controllers have TSU. It can filter multicast by hardware.
This patch supports it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
6ba88021c36516c26c11eff8c6d7d9a045faecd3 15-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: modify a condition of ioremap for TSU

If the controller has TSU, the each channel needs TSU registers.
This patch also fixes the iounmap condition in the sh_eth_drv_remove().

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
150647fb2c313d7c5184fca3fa0829a4a7d6f7bc 15-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: change the condition of initialization

The SH7757 has 2 Fast Ethernet and 2 Gigabit Ethernet, and the first
Gigabit channel needs the initialization. So, this patch adds the
parameter of "needs_init", and if the sh_eth_plat_data is set it
to 1, the driver will initialize the channel.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
3acbc9715a5ac8a2534a69eb3488b63b7c9fb1e2 15-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: add the value of tsu to the SH7757's GETHER

The SH7757's GETHER has TSU registers. So, this patch adds the value
of ".tsu = 1" in the sh_eth_cpu_data.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
16387605a503a5462c79b740f9696ad4f5a960e5 15-Feb-2012 Danny Kukawka <danny.kukawka@bisect.de> renesas/sh_eth.c: fix linux/interrupt.h included twice

Remove double include of linux/interrupt.h.

Signed-off-by: Danny Kukawka <danny.kukawka@bisect.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
dae2e9f430c46c29e3f771110094bd3da3625aa4 06-Feb-2012 Pradeep A. Dalvi <netdev@pradeepdalvi.com> netdev: ethernet dev_alloc_skb to netdev_alloc_skb

Replaced deprecating dev_alloc_skb with netdev_alloc_skb in drivers/net/ethernet
- Removed extra skb->dev = dev after netdev_alloc_skb

Signed-off-by: Pradeep A Dalvi <netdev@pradeepdalvi.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
bb7d92e3e3049e22b5807ac559a72b38fad5f499 06-Feb-2012 Eric Dumazet <eric.dumazet@gmail.com> sh-eth: use netdev stats structure and fix dma_map_single

No need to maintain a parallel net_device_stats structure in
sh_eth_private, since we have a generic one in netdev

Fix two dma_map_single() incorrect parameters, passing skb->tail instead
of skb->data. Seems that there is no corresponding dmap_unmap_single()
calls for the moment in this driver.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
fdb37a7f84a58ccad24abffd54ad46d23b763e13 07-Feb-2012 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix skb_over_panic happen

When this GETHER controller received a large frame (about 1800 bytes
or more), skb_over_panic() happened. This is because the previous
driver set the RFLR to 0x1000 (4096 bytes) and the skb allocate size
is smaller than 4096 bytes. So, the controller accepted such a frame.

The controller can discard a large frame by the RFLR setting.
So, the patch modifies the value of RFLR to mtu + ETH_HLEN +
VLAN_HLEN + ETH_FCS_LEN.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
41de8d4cff21a2e81e3d9ff66f5f7c903f9c3ab1 29-Jan-2012 Joe Perches <joe@perches.com> drivers/net: Remove alloc_etherdev error messages

alloc_etherdev has a generic OOM/unable to alloc message.
Remove the duplicative messages after alloc_etherdev calls.

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
34aa6f1400810890636ba0b170effbfa71eacec7 16-Jan-2012 Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com> net: sh-eth: Fix build error by the value which is not defined

-----
drivers/net/ethernet/renesas/sh_eth.c:1706: error: 'pdid' undeclared (first use in this function)
drivers/net/ethernet/renesas/sh_eth.c:1706: error: (Each undeclared identifier is reported only once
drivers/net/ethernet/renesas/sh_eth.c:1706: error: for each function it appears in.)
make[5]: *** [drivers/net/ethernet/renesas/sh_eth.o] Error 1
-----

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
CC: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
5278fb547076ad6768d16c8b4df45c086470c163 10-Jan-2012 Florian Fainelli <florian@openwrt.org> sh-eth: use an unique MDIO bus name.

Signed-off-by: Florian Fainelli <florian@openwrt.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
9b07be4b2a78166bc54c8eedf18da8a8aafacfab 04-Jan-2012 stephen hemminger <shemminger@vyatta.com> net: make ethtool_ops const

Auditing all usage of ethtool_ops found several drivers that
are not declaring the struct const when it should be.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
db62f684deeb291ab2533b99843d5df9a36b1f19 27-Nov-2011 Axel Lin <axel.lin@gmail.com> net/ethernet: convert drivers/net/ethernet/* to use module_platform_driver()

This patch converts the drivers in drivers/net/ethernet/* to use the
module_platform_driver() macro which makes the code smaller and a bit
simpler.

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Pantelis Antoniou <pantelis.antoniou@gmail.com>
Cc: Vitaly Bordug <vbordug@ru.mvista.com>
Cc: Wan ZongShun <mcuos.com@gmail.com>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Cc: Jiri Pirko <jpirko@redhat.com>
Cc: Daniel Hellstrom <daniel@gaisler.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Tobias Klauser <tklauser@distanz.ch>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Richard Cochran <richard.cochran@omicron.at>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Sebastian Poehn <sebastian.poehn@belden.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Wan ZongShun <mcuos.com@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
0654011d900670884197d9a06ad17b378dfde831 29-Sep-2011 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: fix build failure

The following commit removed some including headers:
"net: sh_eth: move the asm/sh_eth.h to include/linux/"
(commit id: d4fa0e35fdbd54acf791fa3793d6d17f7795f7ae)

Then, the build failure happened on the linux-next:

drivers/net/ethernet/renesas/sh_eth.c:601: error: 'THIS_MODULE' undeclared here (not in a function)
drivers/net/ethernet/renesas/sh_eth.c:1970: error: expected declaration specifiers or '...' before string constant
drivers/net/ethernet/renesas/sh_eth.c:1970: warning: data definition has no type or storage class
drivers/net/ethernet/renesas/sh_eth.c:1970: warning: type defaults to 'int' in declaration of 'MODULE_AUTHOR'
drivers/net/ethernet/renesas/sh_eth.c:1970: warning: function declaration isn't a prototype
drivers/net/ethernet/renesas/sh_eth.c:1971: error: expected declaration specifiers or '...' before string constant
drivers/net/ethernet/renesas/sh_eth.c:1971: warning: data definition has no type or storage class
drivers/net/ethernet/renesas/sh_eth.c:1971: warning: type defaults to 'int' in declaration of 'MODULE_DESCRIPTION'
drivers/net/ethernet/renesas/sh_eth.c:1971: warning: function declaration isn't a prototype
drivers/net/ethernet/renesas/sh_eth.c:1972: error: expected declaration specifiers or '...' before string constant
drivers/net/ethernet/renesas/sh_eth.c:1972: warning: data definition has no type or storage class
drivers/net/ethernet/renesas/sh_eth.c:1972: warning: type defaults to 'int' in declaration of 'MODULE_LICENSE'
drivers/net/ethernet/renesas/sh_eth.c:1972: warning: function declaration isn't a prototype

This patch fixes the issue. This patch also get back include/kernel.h
and linux/spinlock.h.

Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
d4fa0e35fdbd54acf791fa3793d6d17f7795f7ae 27-Sep-2011 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: move the asm/sh_eth.h to include/linux/

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
ae70644df780c0e87f1705fda932e7cb1bdb2074 27-Sep-2011 Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> net: sh_eth: use ioremap()

This patch also changes writel/readl to iowrite32/ioread32.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
afc4b13df143122f99a0eb10bfefb216c2806de0 16-Aug-2011 Jiri Pirko <jpirko@redhat.com> net: remove use of ndo_set_multicast_list in drivers

replace it by ndo_set_rx_mode

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
37b937575b5a93a8fcbd4e1d553415f99381f650 25-Jun-2011 Jeff Kirsher <jeffrey.t.kirsher@intel.com> sh_eth: Move the Renesas SuperH driver

Move the Renesas driver into drivers/net/ethernet/renesas/ and make
the necessary Kconfig and Makefile changes.

CC: Yoshihiro Shimoda <yoshihiro.shirmoda.uh@renesas.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>