stmark2.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * stmark2.c -- Support for Sysam AMCORE open board
  3. *
  4. * (C) Copyright 2017, Angelo Dureghello <angelo@sysam.it>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/platform_device.h>
  11. #include <linux/mtd/partitions.h>
  12. #include <linux/spi/spi.h>
  13. #include <linux/spi/spi-fsl-dspi.h>
  14. #include <linux/spi/flash.h>
  15. #include <asm/mcfsim.h>
  16. /*
  17. * Partitioning of parallel NOR flash (39VF3201B)
  18. */
  19. static struct mtd_partition stmark2_partitions[] = {
  20. {
  21. .name = "U-Boot (1024K)",
  22. .size = 0x100000,
  23. .offset = 0x0
  24. }, {
  25. .name = "Kernel+initramfs (7168K)",
  26. .size = 0x700000,
  27. .offset = MTDPART_OFS_APPEND
  28. }, {
  29. .name = "Flash Free Space (8192K)",
  30. .size = MTDPART_SIZ_FULL,
  31. .offset = MTDPART_OFS_APPEND
  32. }
  33. };
  34. static struct flash_platform_data stmark2_spi_flash_data = {
  35. .name = "is25lp128",
  36. .parts = stmark2_partitions,
  37. .nr_parts = ARRAY_SIZE(stmark2_partitions),
  38. .type = "is25lp128",
  39. };
  40. static struct spi_board_info stmark2_board_info[] __initdata = {
  41. {
  42. .modalias = "m25p80",
  43. .max_speed_hz = 5000000,
  44. .bus_num = 0,
  45. .chip_select = 1,
  46. .platform_data = &stmark2_spi_flash_data,
  47. .mode = SPI_MODE_3,
  48. }
  49. };
  50. /* SPI controller data, SPI (0) */
  51. static struct fsl_dspi_platform_data dspi_spi0_info = {
  52. .cs_num = 4,
  53. .bus_num = 0,
  54. .sck_cs_delay = 100,
  55. .cs_sck_delay = 100,
  56. };
  57. static struct resource dspi_spi0_resource[] = {
  58. [0] = {
  59. .start = MCFDSPI_BASE0,
  60. .end = MCFDSPI_BASE0 + 0xFF,
  61. .flags = IORESOURCE_MEM,
  62. },
  63. [1] = {
  64. .start = 12,
  65. .end = 13,
  66. .flags = IORESOURCE_DMA,
  67. },
  68. [2] = {
  69. .start = MCF_IRQ_DSPI0,
  70. .end = MCF_IRQ_DSPI0,
  71. .flags = IORESOURCE_IRQ,
  72. },
  73. };
  74. /* SPI controller, id = bus number */
  75. static struct platform_device dspi_spi0_device = {
  76. .name = "fsl-dspi",
  77. .id = 0,
  78. .num_resources = ARRAY_SIZE(dspi_spi0_resource),
  79. .resource = dspi_spi0_resource,
  80. .dev = {
  81. .platform_data = &dspi_spi0_info,
  82. },
  83. };
  84. static struct platform_device *stmark2_devices[] __initdata = {
  85. &dspi_spi0_device,
  86. };
  87. /*
  88. * Note: proper pin-mux setup is mandatory for proper SPI functionality.
  89. */
  90. static int __init init_stmark2(void)
  91. {
  92. /* DSPI0, all pins as DSPI, and using CS1 */
  93. __raw_writeb(0x80, MCFGPIO_PAR_DSPIOWL);
  94. __raw_writeb(0xfc, MCFGPIO_PAR_DSPIOWH);
  95. /* Board gpio setup */
  96. __raw_writeb(0x00, MCFGPIO_PAR_BE);
  97. __raw_writeb(0x00, MCFGPIO_PAR_FBCTL);
  98. __raw_writeb(0x00, MCFGPIO_PAR_CS);
  99. __raw_writeb(0x00, MCFGPIO_PAR_CANI2C);
  100. platform_add_devices(stmark2_devices, ARRAY_SIZE(stmark2_devices));
  101. spi_register_board_info(stmark2_board_info,
  102. ARRAY_SIZE(stmark2_board_info));
  103. return 0;
  104. }
  105. late_initcall(init_stmark2);