From: Magnus Damm <magnus.damm@gmail.com>
To: linux-sh@vger.kernel.org
Subject: Re: Current ms7724se LAN doesn't work
Date: Wed, 07 Oct 2009 09:00:03 +0000 [thread overview]
Message-ID: <aec7e5c30910070200h64dab849tc0b40ec49ce376bf@mail.gmail.com> (raw)
In-Reply-To: <uzl9pr5cs.wl%morimoto.kuninori@renesas.com>
[-- Attachment #1: Type: text/plain, Size: 588 bytes --]
Hi Morimoto-san,
[CC Iwamatsu-san]
On Wed, Aug 26, 2009 at 7:09 PM, Kuninori Morimoto
<morimoto.kuninori@renesas.com> wrote:
> I tried Paul's patch + pm_runtime_resume
> But it still doesn't work for me...
Can you give the attached patches a try?
Apply in this order:
linux-2.6.32-rc-net-sh_eth-platform-data-mac-20091007b.patch
linux-2.6.32-rc-net-sh_eth-runtime-pm-20091007.patch
linux-2.6.32-rc-sh-ecovec-sh_eth-pdata-mac-20091007.patch
linux-2.6.32-rc-sh-ecovec-sh_eth-hwblk_id-20091007.patch
They seem to work fine on ecovec for me. Do they solve your issue?
Cheers,
/ magnus
[-- Attachment #2: linux-2.6.32-rc-net-sh_eth-platform-data-mac-20091007b.patch --]
[-- Type: application/octet-stream, Size: 2167 bytes --]
From: Magnus Damm <damm@opensource.se>
Extend the sh_eth driver to allow passing the mac address
using the platform data structure. This to simplify board
setup code.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
arch/sh/include/asm/sh_eth.h | 1 +
drivers/net/sh_eth.c | 20 ++++++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
--- 0001/arch/sh/include/asm/sh_eth.h
+++ work/arch/sh/include/asm/sh_eth.h 2009-10-07 15:04:57.000000000 +0900
@@ -7,6 +7,7 @@ struct sh_eth_plat_data {
int phy;
int edmac_endian;
+ unsigned char mac_addr[6];
unsigned no_ether_link:1;
unsigned ether_link_active_low:1;
};
--- 0001/drivers/net/sh_eth.c
+++ work/drivers/net/sh_eth.c 2009-10-07 16:54:29.000000000 +0900
@@ -298,16 +298,20 @@ static void update_mac_address(struct ne
* When you want use this device, you must set MAC address in bootloader.
*
*/
-static void read_mac_address(struct net_device *ndev)
+static void read_mac_address(struct net_device *ndev, unsigned char *mac)
{
u32 ioaddr = ndev->base_addr;
- ndev->dev_addr[0] = (ctrl_inl(ioaddr + MAHR) >> 24);
- ndev->dev_addr[1] = (ctrl_inl(ioaddr + MAHR) >> 16) & 0xFF;
- ndev->dev_addr[2] = (ctrl_inl(ioaddr + MAHR) >> 8) & 0xFF;
- ndev->dev_addr[3] = (ctrl_inl(ioaddr + MAHR) & 0xFF);
- ndev->dev_addr[4] = (ctrl_inl(ioaddr + MALR) >> 8) & 0xFF;
- ndev->dev_addr[5] = (ctrl_inl(ioaddr + MALR) & 0xFF);
+ if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) {
+ memcpy(ndev->dev_addr, mac, 6);
+ } else {
+ ndev->dev_addr[0] = (ctrl_inl(ioaddr + MAHR) >> 24);
+ ndev->dev_addr[1] = (ctrl_inl(ioaddr + MAHR) >> 16) & 0xFF;
+ ndev->dev_addr[2] = (ctrl_inl(ioaddr + MAHR) >> 8) & 0xFF;
+ ndev->dev_addr[3] = (ctrl_inl(ioaddr + MAHR) & 0xFF);
+ ndev->dev_addr[4] = (ctrl_inl(ioaddr + MALR) >> 8) & 0xFF;
+ ndev->dev_addr[5] = (ctrl_inl(ioaddr + MALR) & 0xFF);
+ }
}
struct bb_info {
@@ -1427,7 +1431,7 @@ static int sh_eth_drv_probe(struct platf
mdp->post_fw = POST_FW >> (devno << 1);
/* read and set MAC address */
- read_mac_address(ndev);
+ read_mac_address(ndev, pd->mac_addr);
/* First device only init */
if (!devno) {
[-- Attachment #3: linux-2.6.32-rc-net-sh_eth-runtime-pm-20091007.patch --]
[-- Type: application/octet-stream, Size: 3498 bytes --]
From: Magnus Damm <damm@opensource.se>
Add Runtime PM support to the sh_eth driver.
The clock to the ethernet hardware block will be
enabled as long as the network device is up.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
drivers/net/sh_eth.c | 35 +++++++++++++++++++++++++++++++++--
drivers/net/sh_eth.h | 1 +
2 files changed, 34 insertions(+), 2 deletions(-)
--- 0003/drivers/net/sh_eth.c
+++ work/drivers/net/sh_eth.c 2009-10-07 17:25:34.000000000 +0900
@@ -30,7 +30,7 @@
#include <linux/phy.h>
#include <linux/cache.h>
#include <linux/io.h>
-
+#include <linux/pm_runtime.h>
#include "sh_eth.h"
/* There is CPU dependent code */
@@ -1012,6 +1012,8 @@ static int sh_eth_open(struct net_device
int ret = 0;
struct sh_eth_private *mdp = netdev_priv(ndev);
+ pm_runtime_get_sync(&mdp->pdev->dev);
+
ret = request_irq(ndev->irq, &sh_eth_interrupt,
#if defined(CONFIG_CPU_SUBTYPE_SH7763) || defined(CONFIG_CPU_SUBTYPE_SH7764)
IRQF_SHARED,
@@ -1048,6 +1050,7 @@ static int sh_eth_open(struct net_device
out_free_irq:
free_irq(ndev->irq, ndev);
+ pm_runtime_put_sync(&mdp->pdev->dev);
return ret;
}
@@ -1179,6 +1182,8 @@ static int sh_eth_close(struct net_devic
ringsize = sizeof(struct sh_eth_txdesc) * TX_RING_SIZE;
dma_free_coherent(NULL, ringsize, mdp->tx_ring, mdp->tx_desc_dma);
+ pm_runtime_put_sync(&mdp->pdev->dev);
+
return 0;
}
@@ -1187,6 +1192,8 @@ static struct net_device_stats *sh_eth_g
struct sh_eth_private *mdp = netdev_priv(ndev);
u32 ioaddr = ndev->base_addr;
+ pm_runtime_get_sync(&mdp->pdev->dev);
+
mdp->stats.tx_dropped += ctrl_inl(ioaddr + TROCR);
ctrl_outl(0, ioaddr + TROCR); /* (write clear) */
mdp->stats.collisions += ctrl_inl(ioaddr + CDCR);
@@ -1202,6 +1209,8 @@ static struct net_device_stats *sh_eth_g
mdp->stats.tx_carrier_errors += ctrl_inl(ioaddr + CNDCR);
ctrl_outl(0, ioaddr + CNDCR); /* (write clear) */
#endif
+ pm_runtime_put_sync(&mdp->pdev->dev);
+
return &mdp->stats;
}
@@ -1410,6 +1419,9 @@ static int sh_eth_drv_probe(struct platf
mdp = netdev_priv(ndev);
spin_lock_init(&mdp->lock);
+ mdp->pdev = pdev;
+ pm_runtime_enable(&pdev->dev);
+ pm_runtime_resume(&pdev->dev);
pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
/* get PHY ID */
@@ -1485,18 +1497,37 @@ static int sh_eth_drv_remove(struct plat
sh_mdio_release(ndev);
unregister_netdev(ndev);
flush_scheduled_work();
-
+ pm_runtime_disable(&pdev->dev);
free_netdev(ndev);
platform_set_drvdata(pdev, NULL);
return 0;
}
+static int sh_eth_runtime_nop(struct device *dev)
+{
+ /*
+ * Runtime PM callback shared between ->runtime_suspend()
+ * and ->runtime_resume(). Simply returns success.
+ *
+ * This driver re-initializes all registers after
+ * pm_runtime_get_sync() anyway so there is no need
+ * to save and restore registers here.
+ */
+ return 0;
+}
+
+static struct dev_pm_ops sh_eth_dev_pm_ops = {
+ .runtime_suspend = sh_eth_runtime_nop,
+ .runtime_resume = sh_eth_runtime_nop,
+};
+
static struct platform_driver sh_eth_driver = {
.probe = sh_eth_drv_probe,
.remove = sh_eth_drv_remove,
.driver = {
.name = CARDNAME,
+ .pm = &sh_eth_dev_pm_ops,
},
};
--- 0001/drivers/net/sh_eth.h
+++ work/drivers/net/sh_eth.h 2009-10-07 17:22:24.000000000 +0900
@@ -703,6 +703,7 @@ struct sh_eth_cpu_data {
};
struct sh_eth_private {
+ struct platform_device *pdev;
struct sh_eth_cpu_data *cd;
dma_addr_t rx_desc_dma;
dma_addr_t tx_desc_dma;
[-- Attachment #4: linux-2.6.32-rc-sh-ecovec-sh_eth-pdata-mac-20091007.patch --]
[-- Type: application/octet-stream, Size: 1757 bytes --]
From: Magnus Damm <damm@opensource.se>
Convert the ecovec24 board code to pass the mac
address to the sh_eth driver using platform data.
Also, remove the static clock to allow Runtime PM.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
arch/sh/boards/mach-ecovec24/setup.c | 33 ++++-----------------------------
1 file changed, 4 insertions(+), 29 deletions(-)
--- 0003/arch/sh/boards/mach-ecovec24/setup.c
+++ work/arch/sh/boards/mach-ecovec24/setup.c 2009-10-07 15:11:51.000000000 +0900
@@ -414,12 +414,9 @@ static u8 mac_read(struct i2c_adapter *a
return buf;
}
-#define MAC_LEN 6
-static void __init sh_eth_init(void)
+static void __init sh_eth_init(struct sh_eth_plat_data *pd)
{
struct i2c_adapter *a = i2c_get_adapter(1);
- struct clk *eth_clk;
- u8 mac[MAC_LEN];
int i;
if (!a) {
@@ -427,33 +424,11 @@ static void __init sh_eth_init(void)
return;
}
- eth_clk = clk_get(NULL, "eth0");
- if (!eth_clk) {
- pr_err("can not get eth0 clk\n");
- return;
- }
-
/* read MAC address frome EEPROM */
- for (i = 0; i < MAC_LEN; i++) {
- mac[i] = mac_read(a, 0x10 + i);
+ for (i = 0; i < sizeof(pd->mac_addr); i++) {
+ pd->mac_addr[i] = mac_read(a, 0x10 + i);
msleep(10);
}
-
- /* clock enable */
- clk_enable(eth_clk);
-
- /* reset sh-eth */
- ctrl_outl(0x1, SH_ETH_ADDR + 0x0);
-
- /* set MAC addr */
- ctrl_outl((mac[0] << 24) |
- (mac[1] << 16) |
- (mac[2] << 8) |
- (mac[3] << 0), SH_ETH_MAHR);
- ctrl_outl((mac[4] << 8) |
- (mac[5] << 0), SH_ETH_MALR);
-
- clk_put(eth_clk);
}
#define PORT_HIZA 0xA4050158
@@ -665,7 +640,7 @@ arch_initcall(arch_setup);
static int __init devices_setup(void)
{
- sh_eth_init();
+ sh_eth_init(&sh_eth_plat);
return 0;
}
device_initcall(devices_setup);
[-- Attachment #5: linux-2.6.32-rc-sh-ecovec-sh_eth-hwblk_id-20091007.patch --]
[-- Type: application/octet-stream, Size: 616 bytes --]
From: Magnus Damm <damm@opensource.se>
Add HWBLK_ETHER to the sh_eth platform device
to allow Runtime PM of the ethernet hardware.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
arch/sh/boards/mach-ecovec24/setup.c | 3 +++
1 file changed, 3 insertions(+)
--- 0004/arch/sh/boards/mach-ecovec24/setup.c
+++ work/arch/sh/boards/mach-ecovec24/setup.c 2009-10-07 16:58:33.000000000 +0900
@@ -132,6 +132,9 @@ static struct platform_device sh_eth_dev
},
.num_resources = ARRAY_SIZE(sh_eth_resources),
.resource = sh_eth_resources,
+ .archdata = {
+ .hwblk_id = HWBLK_ETHER,
+ },
};
/* USB0 host */
next prev parent reply other threads:[~2009-10-07 9:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-24 8:19 Current ms7724se LAN doesn't work Kuninori Morimoto
2009-08-24 9:14 ` Paul Mundt
2009-08-24 9:45 ` Kuninori Morimoto
2009-08-24 9:55 ` Paul Mundt
2009-08-24 10:15 ` Kuninori Morimoto
2009-08-26 8:02 ` Magnus Damm
2009-08-26 10:09 ` Kuninori Morimoto
2009-10-07 9:00 ` Magnus Damm [this message]
2009-10-08 4:45 ` Kuninori Morimoto
2009-10-08 6:51 ` Magnus Damm
2009-10-08 7:21 ` Paul Mundt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aec7e5c30910070200h64dab849tc0b40ec49ce376bf@mail.gmail.com \
--to=magnus.damm@gmail.com \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox