platform.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the
  6. * Free Software Foundation; either version 2 of the License, or (at your
  7. * option) any later version.
  8. */
  9. #include <linux/clk.h>
  10. #include <linux/dma-mapping.h>
  11. #include <linux/err.h>
  12. #include <linux/phy.h>
  13. #include <linux/serial_8250.h>
  14. #include <linux/stmmac.h>
  15. #include <asm-generic/sizes.h>
  16. #include <loongson1.h>
  17. #define LS1X_UART(_id) \
  18. { \
  19. .mapbase = LS1X_UART ## _id ## _BASE, \
  20. .irq = LS1X_UART ## _id ## _IRQ, \
  21. .iotype = UPIO_MEM, \
  22. .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \
  23. .type = PORT_16550A, \
  24. }
  25. static struct plat_serial8250_port ls1x_serial8250_port[] = {
  26. LS1X_UART(0),
  27. LS1X_UART(1),
  28. LS1X_UART(2),
  29. LS1X_UART(3),
  30. {},
  31. };
  32. struct platform_device ls1x_uart_device = {
  33. .name = "serial8250",
  34. .id = PLAT8250_DEV_PLATFORM,
  35. .dev = {
  36. .platform_data = ls1x_serial8250_port,
  37. },
  38. };
  39. void __init ls1x_serial_setup(void)
  40. {
  41. struct clk *clk;
  42. struct plat_serial8250_port *p;
  43. clk = clk_get(NULL, "dc");
  44. if (IS_ERR(clk))
  45. panic("unable to get dc clock, err=%ld", PTR_ERR(clk));
  46. for (p = ls1x_serial8250_port; p->flags != 0; ++p)
  47. p->uartclk = clk_get_rate(clk);
  48. }
  49. /* Synopsys Ethernet GMAC */
  50. static struct resource ls1x_eth0_resources[] = {
  51. [0] = {
  52. .start = LS1X_GMAC0_BASE,
  53. .end = LS1X_GMAC0_BASE + SZ_64K - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .name = "macirq",
  58. .start = LS1X_GMAC0_IRQ,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = {
  63. .bus_id = 0,
  64. .phy_mask = 0,
  65. };
  66. static struct plat_stmmacenet_data ls1x_eth_data = {
  67. .bus_id = 0,
  68. .phy_addr = -1,
  69. .mdio_bus_data = &ls1x_mdio_bus_data,
  70. .has_gmac = 1,
  71. .tx_coe = 1,
  72. };
  73. struct platform_device ls1x_eth0_device = {
  74. .name = "stmmaceth",
  75. .id = 0,
  76. .num_resources = ARRAY_SIZE(ls1x_eth0_resources),
  77. .resource = ls1x_eth0_resources,
  78. .dev = {
  79. .platform_data = &ls1x_eth_data,
  80. },
  81. };
  82. /* USB EHCI */
  83. static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
  84. static struct resource ls1x_ehci_resources[] = {
  85. [0] = {
  86. .start = LS1X_EHCI_BASE,
  87. .end = LS1X_EHCI_BASE + SZ_32K - 1,
  88. .flags = IORESOURCE_MEM,
  89. },
  90. [1] = {
  91. .start = LS1X_EHCI_IRQ,
  92. .flags = IORESOURCE_IRQ,
  93. },
  94. };
  95. struct platform_device ls1x_ehci_device = {
  96. .name = "ls1x-ehci",
  97. .id = -1,
  98. .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
  99. .resource = ls1x_ehci_resources,
  100. .dev = {
  101. .dma_mask = &ls1x_ehci_dmamask,
  102. },
  103. };
  104. /* Real Time Clock */
  105. struct platform_device ls1x_rtc_device = {
  106. .name = "ls1x-rtc",
  107. .id = -1,
  108. };