diff options
author | Jason Jin <Jason.jin@freescale.com> | 2012-10-12 14:31:57 +0800 |
---|---|---|
committer | Andy Voltz <andy.voltz@timesys.com> | 2012-10-17 14:37:26 -0400 |
commit | e6610495a8c388f60c129dffd264141ef304508d (patch) | |
tree | d23a9f8236b4ce88fd9b9095295c0ca5be2fd553 /arch/arm/mach-mvf | |
parent | 303f7cf53e94893d816f7e77d4d03b4311b6aece (diff) |
ENGR00216078-1: switch: add platform support for L2 switch
Add platform support for Vybrid L2 switch driver.
Signed-off-by: Jason Jin <Jason.jin@freescale.com>
Diffstat (limited to 'arch/arm/mach-mvf')
-rw-r--r-- | arch/arm/mach-mvf/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-mvf/board-twr-vf700.c | 36 | ||||
-rw-r--r-- | arch/arm/mach-mvf/clock.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-mvf/l2switch.c | 93 |
4 files changed, 107 insertions, 24 deletions
diff --git a/arch/arm/mach-mvf/Makefile b/arch/arm/mach-mvf/Makefile index b6c048ba364b..c103e4dc3078 100644 --- a/arch/arm/mach-mvf/Makefile +++ b/arch/arm/mach-mvf/Makefile @@ -4,6 +4,7 @@ # Object file lists. obj-y := cpu.o mm.o system.o devices.o dummy_gpio.o irq.o bus_freq.o mvf_fec.o usb_dr.o usb_dr2.o +obj-y += l2switch.o obj-$(CONFIG_ARCH_MVFA5) += clock.o obj-$(CONFIG_MACH_MVFA5_TWR_VF700) += board-twr-vf700.o diff --git a/arch/arm/mach-mvf/board-twr-vf700.c b/arch/arm/mach-mvf/board-twr-vf700.c index 063ba4b50d2b..03cc6ad51788 100644 --- a/arch/arm/mach-mvf/board-twr-vf700.c +++ b/arch/arm/mach-mvf/board-twr-vf700.c @@ -71,7 +71,7 @@ #include <mach/mxc_asrc.h> #include <mach/mipi_dsi.h> #include <mach/mipi_csi2.h> - +#include <mach/fsl_l2_switch.h> #include <asm/irq.h> #include <asm/setup.h> #include <asm/mach-types.h> @@ -124,7 +124,7 @@ static iomux_v3_cfg_t mvf600_pads[] = { MVF600_PAD52_PTC7__RMII0_TXD0, MVF600_PAD53_PTC8__RMII0_TXEN, -#ifdef CONFIG_FEC1 +#if defined(CONFIG_FEC1) || defined(CONFIG_FSL_L2_SWITCH) /*FEC1*/ MVF600_PAD54_PTC9__RMII1_MDC, MVF600_PAD55_PTC10__RMII1_MDIO, @@ -252,32 +252,14 @@ static inline void mvf_vf700_init_uart(void) mvf_add_imx_uart(1, &mvf_uart1_pdata); } -static int mvf_vf700_fec_phy_init(struct phy_device *phydev) -{ -/* prefer master mode, 1000 Base-T capable */ - phy_write(phydev, 0x9, 0x0f00); - - /* min rx data delay */ - phy_write(phydev, 0x0b, 0x8105); - phy_write(phydev, 0x0c, 0x0000); - - /* max rx/tx clock delay, min rx/tx control delay */ - phy_write(phydev, 0x0b, 0x8104); - phy_write(phydev, 0x0c, 0xf0f0); - phy_write(phydev, 0x0b, 0x104); - - return 0; -} - -static int mvf_vf700_fec_power_hibernate(struct phy_device *phydev) -{ - return 0; -} - static struct fec_platform_data fec_data __initdata = { .phy = PHY_INTERFACE_MODE_RMII, }; +static struct switch_platform_data switch_data __initdata = { + .phy = PHY_INTERFACE_MODE_RMII, +}; + static int mvf_vf600_spi_cs[] = { 134, }; @@ -466,7 +448,13 @@ static void __init mvf_board_init(void) ARRAY_SIZE(mvf600_pads)); mvf_vf700_init_uart(); +#ifdef CONFIG_FEC mvf_init_fec(fec_data); +#endif + +#ifdef CONFIG_FSL_L2_SWITCH + mvf_init_switch(switch_data); +#endif mvf_add_snvs_rtc(); diff --git a/arch/arm/mach-mvf/clock.c b/arch/arm/mach-mvf/clock.c index e48711a4f835..cfcea6eccff2 100644 --- a/arch/arm/mach-mvf/clock.c +++ b/arch/arm/mach-mvf/clock.c @@ -1863,6 +1863,7 @@ static struct clk_lookup lookups[] = { _REGISTER_CLOCK("pit", NULL, pit_clk), _REGISTER_CLOCK("fec.0", NULL, enet_clk[0]), _REGISTER_CLOCK("fec.1", NULL, enet_clk[1]), + _REGISTER_CLOCK("switch.0", NULL, enet_clk[0]), _REGISTER_CLOCK("imx2-wdt.0", NULL, dummy_clk), _REGISTER_CLOCK("sdhci-esdhc-imx.1", NULL, esdhc1_clk), _REGISTER_CLOCK("mvf-dcu.0", NULL, dcu0_clk), diff --git a/arch/arm/mach-mvf/l2switch.c b/arch/arm/mach-mvf/l2switch.c new file mode 100644 index 000000000000..2911fc413e9b --- /dev/null +++ b/arch/arm/mach-mvf/l2switch.c @@ -0,0 +1,93 @@ +/* + * l2switch.c + * + * Sub-architcture dependant initialization code for the Freescale + * 5441X and Vybrid L2 Switch module. + * + * Copyright 2010-2012 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + +#include <linux/kernel.h> +#include <linux/sched.h> +#include <linux/param.h> +#include <linux/init.h> +#include <linux/interrupt.h> +#include <linux/device.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/platform_device.h> +#include <linux/fsl_devices.h> +#include <linux/dma-mapping.h> + +#include <asm/traps.h> +#include <asm/sizes.h> + +#include <mach/clock.h> +#include <mach/fsl_l2_switch.h> +#include <mach/hardware.h> +#include <mach/devices-common.h> + + +#define ENET_PALR 0x0e4 +#define ENET_PAUR 0x0e8 + +static unsigned char default_mac[ETH_ALEN] = { + 0x00, 0x04, 0x9F, 0x00, 0xB3, 0x49}; + +/* FEC mac registers set by bootloader */ +static int switch_get_mac_addr(unsigned char *mac) +{ + unsigned int value; + + value = readl(MVF_IO_ADDRESS(MVF_FEC_BASE_ADDR) + ENET_PALR); + mac[2] = value & 0xff; + mac[3] = (value >> 8) & 0xff; + mac[4] = (value >> 16) & 0xff; + mac[5] = (value >> 24) & 0xff; + value = readl(MVF_IO_ADDRESS(MVF_FEC_BASE_ADDR) + ENET_PAUR); + mac[0] = (value >> 16) & 0xff; + mac[1] = (value >> 24) & 0xff; + + return 0; +} + +struct platform_device *__init mvf_init_switch( + struct switch_platform_data pdata) + +{ + struct resource res[] = { + { + .start = MVF_L2SWITCH_BASE_ADDR, + .end = MVF_L2SWITCH_BASE_ADDR + SZ_4K - 1 , + .flags = IORESOURCE_MEM, + }, + { + .start = MVF_L2SWITCH_MACBASE_ADDR, + .end = MVF_L2SWITCH_MACBASE_ADDR + SZ_16K - 1, + .flags = IORESOURCE_MEM, + }, + { + .start = MVF_MAC0_BASE_ADDR, + .end = MVF_MAC0_BASE_ADDR + SZ_8K - 1, + .flags = IORESOURCE_MEM, + }, + { + .start = MVF_INT_ENET_SWITCH, + .end = MVF_INT_ENET_SWITCH, + .flags = IORESOURCE_IRQ, + }, + }; + + switch_get_mac_addr(pdata.mac); + if (!is_valid_ether_addr(pdata.mac)) + memcpy(pdata.mac, default_mac, ETH_ALEN); + + return imx_add_platform_device_dmamask("switch", 0, + res, ARRAY_SIZE(res), + &pdata, sizeof(pdata), DMA_BIT_MASK(32)); +} |