Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <tsbogend@alpha.franken.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Thomas Bogendoerfer and committed by
David S. Miller
e4cd854e 10b26f07

+15 -6
+15 -6
drivers/net/ethernet/korina.c
··· 57 57 #include <linux/ethtool.h> 58 58 #include <linux/crc32.h> 59 59 #include <linux/pgtable.h> 60 + #include <linux/clk.h> 60 61 61 62 #include <asm/bootinfo.h> 62 63 #include <asm/bitops.h> 63 64 #include <asm/io.h> 64 65 #include <asm/dma.h> 65 66 66 - #include <asm/mach-rc32434/rb.h> 67 - #include <asm/mach-rc32434/rc32434.h> 68 67 #include <asm/mach-rc32434/eth.h> 69 68 #include <asm/mach-rc32434/dma_v.h> 70 69 ··· 145 146 struct work_struct restart_task; 146 147 struct net_device *dev; 147 148 struct device *dmadev; 149 + int mii_clock_freq; 148 150 }; 149 - 150 - extern unsigned int idt_cpu_freq; 151 151 152 152 static dma_addr_t korina_tx_dma(struct korina_private *lp, int idx) 153 153 { ··· 897 899 898 900 /* Management Clock Prescaler Divisor 899 901 * Clock independent setting */ 900 - writel(((idt_cpu_freq) / MII_CLOCK + 1) & ~1, 901 - &lp->eth_regs->ethmcp); 902 + writel(((lp->mii_clock_freq) / MII_CLOCK + 1) & ~1, 903 + &lp->eth_regs->ethmcp); 902 904 writel(0, &lp->eth_regs->miimcfg); 903 905 904 906 /* don't transmit until fifo contains 48b */ ··· 1058 1060 u8 *mac_addr = dev_get_platdata(&pdev->dev); 1059 1061 struct korina_private *lp; 1060 1062 struct net_device *dev; 1063 + struct clk *clk; 1061 1064 void __iomem *p; 1062 1065 int rc; 1063 1066 ··· 1073 1074 ether_addr_copy(dev->dev_addr, mac_addr); 1074 1075 else if (of_get_mac_address(pdev->dev.of_node, dev->dev_addr) < 0) 1075 1076 eth_hw_addr_random(dev); 1077 + 1078 + clk = devm_clk_get_optional(&pdev->dev, "mdioclk"); 1079 + if (IS_ERR(clk)) 1080 + return PTR_ERR(clk); 1081 + if (clk) { 1082 + clk_prepare_enable(clk); 1083 + lp->mii_clock_freq = clk_get_rate(clk); 1084 + } else { 1085 + lp->mii_clock_freq = 200000000; /* max possible input clk */ 1086 + } 1076 1087 1077 1088 lp->rx_irq = platform_get_irq_byname(pdev, "rx"); 1078 1089 lp->tx_irq = platform_get_irq_byname(pdev, "tx");