platform.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 <linux/usb/ehci_pdriver.h>
  16. #include <asm-generic/sizes.h>
  17. #include <loongson1.h>
  18. #define LS1X_UART(_id) \
  19. { \
  20. .mapbase = LS1X_UART ## _id ## _BASE, \
  21. .irq = LS1X_UART ## _id ## _IRQ, \
  22. .iotype = UPIO_MEM, \
  23. .flags = UPF_IOREMAP | UPF_FIXED_TYPE, \
  24. .type = PORT_16550A, \
  25. }
  26. static struct plat_serial8250_port ls1x_serial8250_port[] = {
  27. LS1X_UART(0),
  28. LS1X_UART(1),
  29. LS1X_UART(2),
  30. LS1X_UART(3),
  31. {},
  32. };
  33. struct platform_device ls1x_uart_device = {
  34. .name = "serial8250",
  35. .id = PLAT8250_DEV_PLATFORM,
  36. .dev = {
  37. .platform_data = ls1x_serial8250_port,
  38. },
  39. };
  40. void __init ls1x_serial_setup(struct platform_device *pdev)
  41. {
  42. struct clk *clk;
  43. struct plat_serial8250_port *p;
  44. clk = clk_get(NULL, pdev->name);
  45. if (IS_ERR(clk))
  46. panic("unable to get %s clock, err=%ld",
  47. pdev->name, PTR_ERR(clk));
  48. for (p = pdev->dev.platform_data; p->flags != 0; ++p)
  49. p->uartclk = clk_get_rate(clk);
  50. }
  51. /* Synopsys Ethernet GMAC */
  52. static struct resource ls1x_eth0_resources[] = {
  53. [0] = {
  54. .start = LS1X_GMAC0_BASE,
  55. .end = LS1X_GMAC0_BASE + SZ_64K - 1,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. [1] = {
  59. .name = "macirq",
  60. .start = LS1X_GMAC0_IRQ,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static struct stmmac_mdio_bus_data ls1x_mdio_bus_data = {
  65. .phy_mask = 0,
  66. };
  67. static struct plat_stmmacenet_data ls1x_eth_data = {
  68. .bus_id = 0,
  69. .phy_addr = -1,
  70. .mdio_bus_data = &ls1x_mdio_bus_data,
  71. .has_gmac = 1,
  72. .tx_coe = 1,
  73. };
  74. struct platform_device ls1x_eth0_device = {
  75. .name = "stmmaceth",
  76. .id = 0,
  77. .num_resources = ARRAY_SIZE(ls1x_eth0_resources),
  78. .resource = ls1x_eth0_resources,
  79. .dev = {
  80. .platform_data = &ls1x_eth_data,
  81. },
  82. };
  83. /* USB EHCI */
  84. static u64 ls1x_ehci_dmamask = DMA_BIT_MASK(32);
  85. static struct resource ls1x_ehci_resources[] = {
  86. [0] = {
  87. .start = LS1X_EHCI_BASE,
  88. .end = LS1X_EHCI_BASE + SZ_32K - 1,
  89. .flags = IORESOURCE_MEM,
  90. },
  91. [1] = {
  92. .start = LS1X_EHCI_IRQ,
  93. .flags = IORESOURCE_IRQ,
  94. },
  95. };
  96. static struct usb_ehci_pdata ls1x_ehci_pdata = {
  97. };
  98. struct platform_device ls1x_ehci_device = {
  99. .name = "ehci-platform",
  100. .id = -1,
  101. .num_resources = ARRAY_SIZE(ls1x_ehci_resources),
  102. .resource = ls1x_ehci_resources,
  103. .dev = {
  104. .dma_mask = &ls1x_ehci_dmamask,
  105. .platform_data = &ls1x_ehci_pdata,
  106. },
  107. };
  108. /* Real Time Clock */
  109. struct platform_device ls1x_rtc_device = {
  110. .name = "ls1x-rtc",
  111. .id = -1,
  112. };