Skip to content

Commit e4cd854

Browse files
tsbogenddavem330
authored andcommitted
net: korina: Get mdio input clock via common clock framework
With device tree clock is provided via CCF. For non device tree use a maximum clock value to not overclock the PHY. The non device tree usage will go away after platform is converted to DT. Signed-off-by: Thomas Bogendoerfer <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 10b26f0 commit e4cd854

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

drivers/net/ethernet/korina.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,13 @@
5757
#include <linux/ethtool.h>
5858
#include <linux/crc32.h>
5959
#include <linux/pgtable.h>
60+
#include <linux/clk.h>
6061

6162
#include <asm/bootinfo.h>
6263
#include <asm/bitops.h>
6364
#include <asm/io.h>
6465
#include <asm/dma.h>
6566

66-
#include <asm/mach-rc32434/rb.h>
67-
#include <asm/mach-rc32434/rc32434.h>
6867
#include <asm/mach-rc32434/eth.h>
6968
#include <asm/mach-rc32434/dma_v.h>
7069

@@ -146,10 +145,9 @@ struct korina_private {
146145
struct work_struct restart_task;
147146
struct net_device *dev;
148147
struct device *dmadev;
148+
int mii_clock_freq;
149149
};
150150

151-
extern unsigned int idt_cpu_freq;
152-
153151
static dma_addr_t korina_tx_dma(struct korina_private *lp, int idx)
154152
{
155153
return lp->td_dma + (idx * sizeof(struct dma_desc));
@@ -899,8 +897,8 @@ static int korina_init(struct net_device *dev)
899897

900898
/* Management Clock Prescaler Divisor
901899
* Clock independent setting */
902-
writel(((idt_cpu_freq) / MII_CLOCK + 1) & ~1,
903-
&lp->eth_regs->ethmcp);
900+
writel(((lp->mii_clock_freq) / MII_CLOCK + 1) & ~1,
901+
&lp->eth_regs->ethmcp);
904902
writel(0, &lp->eth_regs->miimcfg);
905903

906904
/* don't transmit until fifo contains 48b */
@@ -1060,6 +1058,7 @@ static int korina_probe(struct platform_device *pdev)
10601058
u8 *mac_addr = dev_get_platdata(&pdev->dev);
10611059
struct korina_private *lp;
10621060
struct net_device *dev;
1061+
struct clk *clk;
10631062
void __iomem *p;
10641063
int rc;
10651064

@@ -1075,6 +1074,16 @@ static int korina_probe(struct platform_device *pdev)
10751074
else if (of_get_mac_address(pdev->dev.of_node, dev->dev_addr) < 0)
10761075
eth_hw_addr_random(dev);
10771076

1077+
clk = devm_clk_get_optional(&pdev->dev, "mdioclk");
1078+
if (IS_ERR(clk))
1079+
return PTR_ERR(clk);
1080+
if (clk) {
1081+
clk_prepare_enable(clk);
1082+
lp->mii_clock_freq = clk_get_rate(clk);
1083+
} else {
1084+
lp->mii_clock_freq = 200000000; /* max possible input clk */
1085+
}
1086+
10781087
lp->rx_irq = platform_get_irq_byname(pdev, "rx");
10791088
lp->tx_irq = platform_get_irq_byname(pdev, "tx");
10801089

0 commit comments

Comments
 (0)