|
21 | 21 |
|
22 | 22 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
23 | 23 |
|
| 24 | +#include <linux/clk.h> |
24 | 25 | #include <linux/dma-mapping.h>
|
25 | 26 | #include <linux/etherdevice.h>
|
26 | 27 | #include <linux/ethtool.h>
|
|
59 | 60 | /* Min number of tx ring entries before stopping queue */
|
60 | 61 | #define TX_THRESHOLD (MAX_SKB_FRAGS + 1)
|
61 | 62 |
|
| 63 | +#define FTGMAC_100MHZ 100000000 |
| 64 | +#define FTGMAC_25MHZ 25000000 |
| 65 | + |
62 | 66 | struct ftgmac100 {
|
63 | 67 | /* Registers */
|
64 | 68 | struct resource *res;
|
@@ -96,6 +100,7 @@ struct ftgmac100 {
|
96 | 100 | struct napi_struct napi;
|
97 | 101 | struct work_struct reset_task;
|
98 | 102 | struct mii_bus *mii_bus;
|
| 103 | + struct clk *clk; |
99 | 104 |
|
100 | 105 | /* Link management */
|
101 | 106 | int cur_speed;
|
@@ -1734,6 +1739,22 @@ static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
|
1734 | 1739 | nd->link_up ? "up" : "down");
|
1735 | 1740 | }
|
1736 | 1741 |
|
| 1742 | +static void ftgmac100_setup_clk(struct ftgmac100 *priv) |
| 1743 | +{ |
| 1744 | + priv->clk = devm_clk_get(priv->dev, NULL); |
| 1745 | + if (IS_ERR(priv->clk)) |
| 1746 | + return; |
| 1747 | + |
| 1748 | + clk_prepare_enable(priv->clk); |
| 1749 | + |
| 1750 | + /* Aspeed specifies a 100MHz clock is required for up to |
| 1751 | + * 1000Mbit link speeds. As NCSI is limited to 100Mbit, 25MHz |
| 1752 | + * is sufficient |
| 1753 | + */ |
| 1754 | + clk_set_rate(priv->clk, priv->use_ncsi ? FTGMAC_25MHZ : |
| 1755 | + FTGMAC_100MHZ); |
| 1756 | +} |
| 1757 | + |
1737 | 1758 | static int ftgmac100_probe(struct platform_device *pdev)
|
1738 | 1759 | {
|
1739 | 1760 | struct resource *res;
|
@@ -1830,6 +1851,9 @@ static int ftgmac100_probe(struct platform_device *pdev)
|
1830 | 1851 | goto err_setup_mdio;
|
1831 | 1852 | }
|
1832 | 1853 |
|
| 1854 | + if (priv->is_aspeed) |
| 1855 | + ftgmac100_setup_clk(priv); |
| 1856 | + |
1833 | 1857 | /* Default ring sizes */
|
1834 | 1858 | priv->rx_q_entries = priv->new_rx_q_entries = DEF_RX_QUEUE_ENTRIES;
|
1835 | 1859 | priv->tx_q_entries = priv->new_tx_q_entries = DEF_TX_QUEUE_ENTRIES;
|
@@ -1883,6 +1907,8 @@ static int ftgmac100_remove(struct platform_device *pdev)
|
1883 | 1907 |
|
1884 | 1908 | unregister_netdev(netdev);
|
1885 | 1909 |
|
| 1910 | + clk_disable_unprepare(priv->clk); |
| 1911 | + |
1886 | 1912 | /* There's a small chance the reset task will have been re-queued,
|
1887 | 1913 | * during stop, make sure it's gone before we free the structure.
|
1888 | 1914 | */
|
|
0 commit comments