Skip to content

Commit

Permalink
net: lpc-enet: move phy setup into platform code
Browse files Browse the repository at this point in the history
Setting the phy mode requires touching a platform specific
register, which prevents us from building the driver without
its header files.

Move it into a separate function in arch/arm/mach/lpc32xx
to hide the core registers from the network driver.

Link: https://lore.kernel.org/r/[email protected]
Acked-by: Sylvain Lemieux <[email protected]>
Signed-off-by: Arnd Bergmann <[email protected]>
  • Loading branch information
arndb committed Aug 15, 2019
1 parent 9dc03ff commit ecca1a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
12 changes: 12 additions & 0 deletions arch/arm/mach-lpc32xx/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr)
}
EXPORT_SYMBOL_GPL(lpc32xx_return_iram);

void lpc32xx_set_phy_interface_mode(phy_interface_t mode)
{
u32 tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
if (mode == PHY_INTERFACE_MODE_MII)
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
else
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
__raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL);
}
EXPORT_SYMBOL_GPL(lpc32xx_set_phy_interface_mode);

static struct map_desc lpc32xx_io_desc[] __initdata = {
{
.virtual = (unsigned long)IO_ADDRESS(LPC32XX_AHB0_START),
Expand Down
12 changes: 1 addition & 11 deletions drivers/net/ethernet/nxp/lpc_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#include <linux/spinlock.h>
#include <linux/soc/nxp/lpc32xx-misc.h>

#include <mach/hardware.h>
#include <mach/platform.h>

#define MODNAME "lpc-eth"
#define DRV_VERSION "1.00"

Expand Down Expand Up @@ -1237,16 +1234,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev)
dma_addr_t dma_handle;
struct resource *res;
int irq, ret;
u32 tmp;

/* Setup network interface for RMII or MII mode */
tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL);
tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK;
if (lpc_phy_interface_mode(dev) == PHY_INTERFACE_MODE_MII)
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS;
else
tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS;
__raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL);
lpc32xx_set_phy_interface_mode(lpc_phy_interface_mode(dev));

/* Get platform resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
Expand Down
5 changes: 5 additions & 0 deletions include/linux/soc/nxp/lpc32xx-misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,21 @@
#define __SOC_LPC32XX_MISC_H

#include <linux/types.h>
#include <linux/phy.h>

#ifdef CONFIG_ARCH_LPC32XX
extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr);
extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode);
#else
static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr)
{
*mapbase = NULL;
*dmaaddr = 0;
return 0;
}
static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode)
{
}
#endif

#endif /* __SOC_LPC32XX_MISC_H */

0 comments on commit ecca1a6

Please sign in to comment.