msp_eth.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * The setup file for ethernet related hardware on PMC-Sierra MSP processors.
  3. *
  4. * Copyright 2010 PMC-Sierra, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  12. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  14. * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  15. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  16. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  18. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  19. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  20. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  21. *
  22. * You should have received a copy of the GNU General Public License along
  23. * with this program; if not, write to the Free Software Foundation, Inc.,
  24. * 675 Mass Ave, Cambridge, MA 02139, USA.
  25. */
  26. #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>
  34. #define MSP_ETHERNET_GPIO0 14
  35. #define MSP_ETHERNET_GPIO1 15
  36. #define MSP_ETHERNET_GPIO2 16
  37. #define MSP_ETH_ID "pmc_mspeth"
  38. #define MSP_ETH_SIZE 0xE0
  39. static struct resource msp_eth0_resources[] = {
  40. [0] = {
  41. .start = MSP_MAC0_BASE,
  42. .end = MSP_MAC0_BASE + MSP_ETH_SIZE - 1,
  43. .flags = IORESOURCE_MEM,
  44. },
  45. [1] = {
  46. .start = MSP_INT_MAC0,
  47. .end = MSP_INT_MAC0,
  48. .flags = IORESOURCE_IRQ,
  49. },
  50. };
  51. static struct resource msp_eth1_resources[] = {
  52. [0] = {
  53. .start = MSP_MAC1_BASE,
  54. .end = MSP_MAC1_BASE + MSP_ETH_SIZE - 1,
  55. .flags = IORESOURCE_MEM,
  56. },
  57. [1] = {
  58. .start = MSP_INT_MAC1,
  59. .end = MSP_INT_MAC1,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. };
  63. static struct platform_device mspeth_device[] = {
  64. [0] = {
  65. .name = MSP_ETH_ID,
  66. .id = 0,
  67. .num_resources = ARRAY_SIZE(msp_eth0_resources),
  68. .resource = msp_eth0_resources,
  69. },
  70. [1] = {
  71. .name = MSP_ETH_ID,
  72. .id = 1,
  73. .num_resources = ARRAY_SIZE(msp_eth1_resources),
  74. .resource = msp_eth1_resources,
  75. },
  76. };
  77. #define msp_eth_devs mspeth_device
  78. int __init msp_eth_setup(void)
  79. {
  80. int i, ret = 0;
  81. /* Configure the GPIO and take the ethernet PHY out of reset */
  82. msp_gpio_pin_mode(MSP_GPIO_OUTPUT, MSP_ETHERNET_GPIO0);
  83. msp_gpio_pin_hi(MSP_ETHERNET_GPIO0);
  84. for (i = 0; i < ARRAY_SIZE(msp_eth_devs); i++) {
  85. ret = platform_device_register(&msp_eth_devs[i]);
  86. printk(KERN_INFO "device: %d, return value = %d\n", i, ret);
  87. if (ret) {
  88. platform_device_unregister(&msp_eth_devs[i]);
  89. break;
  90. }
  91. }
  92. if (ret)
  93. printk(KERN_WARNING "Could not initialize "
  94. "MSPETH device structures.\n");
  95. return ret;
  96. }
  97. subsys_initcall(msp_eth_setup);