Skip to content

Commit fec53f4

Browse files
colin-foster-in-advantagedavem330
authored andcommitted
net: mscc: ocelot: expose ocelot_pll5_init routine
Ocelot chips have an internal PLL that must be used when communicating through external phys. Expose the init routine, so it can be used by other drivers. Signed-off-by: Colin Foster <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c21ff09 commit fec53f4

File tree

3 files changed

+33
-30
lines changed

3 files changed

+33
-30
lines changed

drivers/net/ethernet/mscc/ocelot.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/dsa/ocelot.h>
88
#include <linux/if_bridge.h>
99
#include <linux/iopoll.h>
10+
#include <soc/mscc/ocelot_hsio.h>
1011
#include <soc/mscc/ocelot_vcap.h>
1112
#include "ocelot.h"
1213
#include "ocelot_vcap.h"
@@ -211,6 +212,36 @@ static void ocelot_mact_init(struct ocelot *ocelot)
211212
ocelot_write(ocelot, MACACCESS_CMD_INIT, ANA_TABLES_MACACCESS);
212213
}
213214

215+
void ocelot_pll5_init(struct ocelot *ocelot)
216+
{
217+
/* Configure PLL5. This will need a proper CCF driver
218+
* The values are coming from the VTSS API for Ocelot
219+
*/
220+
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG4,
221+
HSIO_PLL5G_CFG4_IB_CTRL(0x7600) |
222+
HSIO_PLL5G_CFG4_IB_BIAS_CTRL(0x8));
223+
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG0,
224+
HSIO_PLL5G_CFG0_CORE_CLK_DIV(0x11) |
225+
HSIO_PLL5G_CFG0_CPU_CLK_DIV(2) |
226+
HSIO_PLL5G_CFG0_ENA_BIAS |
227+
HSIO_PLL5G_CFG0_ENA_VCO_BUF |
228+
HSIO_PLL5G_CFG0_ENA_CP1 |
229+
HSIO_PLL5G_CFG0_SELCPI(2) |
230+
HSIO_PLL5G_CFG0_LOOP_BW_RES(0xe) |
231+
HSIO_PLL5G_CFG0_SELBGV820(4) |
232+
HSIO_PLL5G_CFG0_DIV4 |
233+
HSIO_PLL5G_CFG0_ENA_CLKTREE |
234+
HSIO_PLL5G_CFG0_ENA_LANE);
235+
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG2,
236+
HSIO_PLL5G_CFG2_EN_RESET_FRQ_DET |
237+
HSIO_PLL5G_CFG2_EN_RESET_OVERRUN |
238+
HSIO_PLL5G_CFG2_GAIN_TEST(0x8) |
239+
HSIO_PLL5G_CFG2_ENA_AMPCTRL |
240+
HSIO_PLL5G_CFG2_PWD_AMPCTRL_N |
241+
HSIO_PLL5G_CFG2_AMPC_SEL(0x10));
242+
}
243+
EXPORT_SYMBOL(ocelot_pll5_init);
244+
214245
static void ocelot_vcap_enable(struct ocelot *ocelot, int port)
215246
{
216247
ocelot_write_gix(ocelot, ANA_PORT_VCAP_S2_CFG_S2_ENA |

drivers/net/ethernet/mscc/ocelot_vsc7514.c

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,43 +18,13 @@
1818

1919
#include <soc/mscc/ocelot.h>
2020
#include <soc/mscc/ocelot_vcap.h>
21-
#include <soc/mscc/ocelot_hsio.h>
2221
#include <soc/mscc/vsc7514_regs.h>
2322
#include "ocelot_fdma.h"
2423
#include "ocelot.h"
2524

2625
#define VSC7514_VCAP_POLICER_BASE 128
2726
#define VSC7514_VCAP_POLICER_MAX 191
2827

29-
static void ocelot_pll5_init(struct ocelot *ocelot)
30-
{
31-
/* Configure PLL5. This will need a proper CCF driver
32-
* The values are coming from the VTSS API for Ocelot
33-
*/
34-
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG4,
35-
HSIO_PLL5G_CFG4_IB_CTRL(0x7600) |
36-
HSIO_PLL5G_CFG4_IB_BIAS_CTRL(0x8));
37-
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG0,
38-
HSIO_PLL5G_CFG0_CORE_CLK_DIV(0x11) |
39-
HSIO_PLL5G_CFG0_CPU_CLK_DIV(2) |
40-
HSIO_PLL5G_CFG0_ENA_BIAS |
41-
HSIO_PLL5G_CFG0_ENA_VCO_BUF |
42-
HSIO_PLL5G_CFG0_ENA_CP1 |
43-
HSIO_PLL5G_CFG0_SELCPI(2) |
44-
HSIO_PLL5G_CFG0_LOOP_BW_RES(0xe) |
45-
HSIO_PLL5G_CFG0_SELBGV820(4) |
46-
HSIO_PLL5G_CFG0_DIV4 |
47-
HSIO_PLL5G_CFG0_ENA_CLKTREE |
48-
HSIO_PLL5G_CFG0_ENA_LANE);
49-
regmap_write(ocelot->targets[HSIO], HSIO_PLL5G_CFG2,
50-
HSIO_PLL5G_CFG2_EN_RESET_FRQ_DET |
51-
HSIO_PLL5G_CFG2_EN_RESET_OVERRUN |
52-
HSIO_PLL5G_CFG2_GAIN_TEST(0x8) |
53-
HSIO_PLL5G_CFG2_ENA_AMPCTRL |
54-
HSIO_PLL5G_CFG2_PWD_AMPCTRL_N |
55-
HSIO_PLL5G_CFG2_AMPC_SEL(0x10));
56-
}
57-
5828
static int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops)
5929
{
6030
int ret;

include/soc/mscc/ocelot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,4 +1183,6 @@ ocelot_mrp_del_ring_role(struct ocelot *ocelot, int port,
11831183
}
11841184
#endif
11851185

1186+
void ocelot_pll5_init(struct ocelot *ocelot);
1187+
11861188
#endif

0 commit comments

Comments
 (0)