Path: blob/master/arch/mips/pmc-sierra/msp71xx/msp_eth.c
15118 views
/*1* The setup file for ethernet related hardware on PMC-Sierra MSP processors.2*3* Copyright 2010 PMC-Sierra, Inc.4*5* This program is free software; you can redistribute it and/or modify it6* under the terms of the GNU General Public License as published by the7* Free Software Foundation; either version 2 of the License, or (at your8* option) any later version.9*10* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED11* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN13* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,14* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT15* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF16* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON17* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT18* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF19* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.20*21* You should have received a copy of the GNU General Public License along22* with this program; if not, write to the Free Software Foundation, Inc.,23* 675 Mass Ave, Cambridge, MA 02139, USA.24*/2526#include <linux/init.h>27#include <linux/kernel.h>28#include <linux/ioport.h>29#include <linux/platform_device.h>30#include <linux/delay.h>31#include <msp_regs.h>32#include <msp_int.h>33#include <msp_gpio_macros.h>343536#define MSP_ETHERNET_GPIO0 1437#define MSP_ETHERNET_GPIO1 1538#define MSP_ETHERNET_GPIO2 163940#ifdef CONFIG_MSP_HAS_TSMAC41#define MSP_TSMAC_SIZE 0x1002042#define MSP_TSMAC_ID "pmc_tsmac"4344static struct resource msp_tsmac0_resources[] = {45[0] = {46.start = MSP_MAC0_BASE,47.end = MSP_MAC0_BASE + MSP_TSMAC_SIZE - 1,48.flags = IORESOURCE_MEM,49},50[1] = {51.start = MSP_INT_MAC0,52.end = MSP_INT_MAC0,53.flags = IORESOURCE_IRQ,54},55};5657static struct resource msp_tsmac1_resources[] = {58[0] = {59.start = MSP_MAC1_BASE,60.end = MSP_MAC1_BASE + MSP_TSMAC_SIZE - 1,61.flags = IORESOURCE_MEM,62},63[1] = {64.start = MSP_INT_MAC1,65.end = MSP_INT_MAC1,66.flags = IORESOURCE_IRQ,67},68};69static struct resource msp_tsmac2_resources[] = {70[0] = {71.start = MSP_MAC2_BASE,72.end = MSP_MAC2_BASE + MSP_TSMAC_SIZE - 1,73.flags = IORESOURCE_MEM,74},75[1] = {76.start = MSP_INT_SAR,77.end = MSP_INT_SAR,78.flags = IORESOURCE_IRQ,79},80};818283static struct platform_device tsmac_device[] = {84[0] = {85.name = MSP_TSMAC_ID,86.id = 0,87.num_resources = ARRAY_SIZE(msp_tsmac0_resources),88.resource = msp_tsmac0_resources,89},90[1] = {91.name = MSP_TSMAC_ID,92.id = 1,93.num_resources = ARRAY_SIZE(msp_tsmac1_resources),94.resource = msp_tsmac1_resources,95},96[2] = {97.name = MSP_TSMAC_ID,98.id = 2,99.num_resources = ARRAY_SIZE(msp_tsmac2_resources),100.resource = msp_tsmac2_resources,101},102};103#define msp_eth_devs tsmac_device104105#else106/* If it is not TSMAC assume MSP_ETH (100Mbps) */107#define MSP_ETH_ID "pmc_mspeth"108#define MSP_ETH_SIZE 0xE0109static struct resource msp_eth0_resources[] = {110[0] = {111.start = MSP_MAC0_BASE,112.end = MSP_MAC0_BASE + MSP_ETH_SIZE - 1,113.flags = IORESOURCE_MEM,114},115[1] = {116.start = MSP_INT_MAC0,117.end = MSP_INT_MAC0,118.flags = IORESOURCE_IRQ,119},120};121122static struct resource msp_eth1_resources[] = {123[0] = {124.start = MSP_MAC1_BASE,125.end = MSP_MAC1_BASE + MSP_ETH_SIZE - 1,126.flags = IORESOURCE_MEM,127},128[1] = {129.start = MSP_INT_MAC1,130.end = MSP_INT_MAC1,131.flags = IORESOURCE_IRQ,132},133};134135136137static struct platform_device mspeth_device[] = {138[0] = {139.name = MSP_ETH_ID,140.id = 0,141.num_resources = ARRAY_SIZE(msp_eth0_resources),142.resource = msp_eth0_resources,143},144[1] = {145.name = MSP_ETH_ID,146.id = 1,147.num_resources = ARRAY_SIZE(msp_eth1_resources),148.resource = msp_eth1_resources,149},150151};152#define msp_eth_devs mspeth_device153154#endif155int __init msp_eth_setup(void)156{157int i, ret = 0;158159/* Configure the GPIO and take the ethernet PHY out of reset */160msp_gpio_pin_mode(MSP_GPIO_OUTPUT, MSP_ETHERNET_GPIO0);161msp_gpio_pin_hi(MSP_ETHERNET_GPIO0);162163#ifdef CONFIG_MSP_HAS_TSMAC164/* 3 phys on boards with TSMAC */165msp_gpio_pin_mode(MSP_GPIO_OUTPUT, MSP_ETHERNET_GPIO1);166msp_gpio_pin_hi(MSP_ETHERNET_GPIO1);167168msp_gpio_pin_mode(MSP_GPIO_OUTPUT, MSP_ETHERNET_GPIO2);169msp_gpio_pin_hi(MSP_ETHERNET_GPIO2);170#endif171for (i = 0; i < ARRAY_SIZE(msp_eth_devs); i++) {172ret = platform_device_register(&msp_eth_devs[i]);173printk(KERN_INFO "device: %d, return value = %d\n", i, ret);174if (ret) {175platform_device_unregister(&msp_eth_devs[i]);176break;177}178}179180if (ret)181printk(KERN_WARNING "Could not initialize "182"MSPETH device structures.\n");183184return ret;185}186subsys_initcall(msp_eth_setup);187188189