121-arm-gemini-add-gmac-device.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. --- a/arch/arm/mach-gemini/common.h
  2. +++ b/arch/arm/mach-gemini/common.h
  3. @@ -15,6 +15,7 @@
  4. #include <linux/reboot.h>
  5. struct mtd_partition;
  6. +struct gemini_gmac_platform_data;
  7. extern void gemini_map_io(void);
  8. extern void gemini_init_irq(void);
  9. @@ -28,6 +29,7 @@ extern int platform_register_pflash(unsi
  10. struct mtd_partition *parts,
  11. unsigned int nr_parts);
  12. extern int platform_register_watchdog(void);
  13. +extern int platform_register_ethernet(struct gemini_gmac_platform_data *pdata);
  14. extern void gemini_restart(enum reboot_mode mode, const char *cmd);
  15. --- a/arch/arm/mach-gemini/devices.c
  16. +++ b/arch/arm/mach-gemini/devices.c
  17. @@ -17,6 +17,7 @@
  18. #include <mach/irqs.h>
  19. #include <mach/hardware.h>
  20. #include <mach/global_reg.h>
  21. +#include <mach/gmac.h>
  22. static struct plat_serial8250_port serial_platform_data[] = {
  23. {
  24. @@ -133,3 +134,56 @@ int __init platform_register_watchdog(vo
  25. {
  26. return platform_device_register(&wdt_device);
  27. }
  28. +
  29. +static struct resource gmac_resources[] = {
  30. + {
  31. + .start = GEMINI_TOE_BASE,
  32. + .end = GEMINI_TOE_BASE + 0xffff,
  33. + .flags = IORESOURCE_MEM,
  34. + },
  35. + {
  36. + .start = IRQ_GMAC0,
  37. + .end = IRQ_GMAC0,
  38. + .flags = IORESOURCE_IRQ,
  39. + },
  40. + {
  41. + .start = IRQ_GMAC1,
  42. + .end = IRQ_GMAC1,
  43. + .flags = IORESOURCE_IRQ,
  44. + },
  45. +};
  46. +
  47. +static u64 gmac_dmamask = 0xffffffffUL;
  48. +
  49. +static struct platform_device ethernet_device = {
  50. + .name = "gmac-gemini",
  51. + .id = 0,
  52. + .dev = {
  53. + .dma_mask = &gmac_dmamask,
  54. + .coherent_dma_mask = 0xffffffff,
  55. + },
  56. + .num_resources = ARRAY_SIZE(gmac_resources),
  57. + .resource = gmac_resources,
  58. +};
  59. +
  60. +int platform_register_ethernet(struct gemini_gmac_platform_data *pdata)
  61. +{
  62. + unsigned int reg;
  63. +
  64. + reg = readl((void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  65. + GLOBAL_MISC_CTRL));
  66. +
  67. + reg &= ~(GMAC_GMII | GMAC_1_ENABLE);
  68. +
  69. + if (pdata->bus_id[1])
  70. + reg |= GMAC_1_ENABLE;
  71. + else if (pdata->interface[0] == PHY_INTERFACE_MODE_GMII)
  72. + reg |= GMAC_GMII;
  73. +
  74. + writel(reg, (void __iomem*)(IO_ADDRESS(GEMINI_GLOBAL_BASE) +
  75. + GLOBAL_MISC_CTRL));
  76. +
  77. + ethernet_device.dev.platform_data = pdata;
  78. +
  79. + return platform_device_register(&ethernet_device);
  80. +}