stmark2.c 2.8 KB

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