board.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2011-2016 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/leds.h>
  10. #include <linux/mtd/partitions.h>
  11. #include <linux/sizes.h>
  12. #include <loongson1.h>
  13. #include <dma.h>
  14. #include <nand.h>
  15. #include <platform.h>
  16. struct plat_ls1x_dma ls1x_dma_pdata = {
  17. .nr_channels = 3,
  18. };
  19. static struct mtd_partition ls1x_nand_parts[] = {
  20. {
  21. .name = "kernel",
  22. .offset = 0,
  23. .size = SZ_16M,
  24. },
  25. {
  26. .name = "rootfs",
  27. .offset = MTDPART_OFS_APPEND,
  28. .size = MTDPART_SIZ_FULL,
  29. },
  30. };
  31. struct plat_ls1x_nand ls1x_nand_pdata = {
  32. .parts = ls1x_nand_parts,
  33. .nr_parts = ARRAY_SIZE(ls1x_nand_parts),
  34. .hold_cycle = 0x2,
  35. .wait_cycle = 0xc,
  36. };
  37. static const struct gpio_led ls1x_gpio_leds[] __initconst = {
  38. {
  39. .name = "LED9",
  40. .default_trigger = "heartbeat",
  41. .gpio = 38,
  42. .active_low = 1,
  43. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  44. }, {
  45. .name = "LED6",
  46. .default_trigger = "nand-disk",
  47. .gpio = 39,
  48. .active_low = 1,
  49. .default_state = LEDS_GPIO_DEFSTATE_OFF,
  50. },
  51. };
  52. static const struct gpio_led_platform_data ls1x_led_pdata __initconst = {
  53. .num_leds = ARRAY_SIZE(ls1x_gpio_leds),
  54. .leds = ls1x_gpio_leds,
  55. };
  56. static struct platform_device *ls1b_platform_devices[] __initdata = {
  57. &ls1x_uart_pdev,
  58. &ls1x_cpufreq_pdev,
  59. &ls1x_dma_pdev,
  60. &ls1x_eth0_pdev,
  61. &ls1x_eth1_pdev,
  62. &ls1x_ehci_pdev,
  63. &ls1x_gpio0_pdev,
  64. &ls1x_gpio1_pdev,
  65. &ls1x_nand_pdev,
  66. &ls1x_rtc_pdev,
  67. };
  68. static int __init ls1b_platform_init(void)
  69. {
  70. ls1x_serial_set_uartclk(&ls1x_uart_pdev);
  71. ls1x_dma_set_platdata(&ls1x_dma_pdata);
  72. ls1x_nand_set_platdata(&ls1x_nand_pdata);
  73. gpio_led_register_device(-1, &ls1x_led_pdata);
  74. return platform_add_devices(ls1b_platform_devices,
  75. ARRAY_SIZE(ls1b_platform_devices));
  76. }
  77. arch_initcall(ls1b_platform_init);