dspi.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2019
  4. * Angelo Dureghello <angleo@sysam.it>
  5. *
  6. * CPU specific dspi routines
  7. */
  8. #include <common.h>
  9. #include <asm/immap.h>
  10. #include <asm/io.h>
  11. #ifdef CONFIG_CF_DSPI
  12. void dspi_chip_select(int cs)
  13. {
  14. struct gpio *gpio = (struct gpio *)MMAP_GPIO;
  15. #ifdef CONFIG_MCF5445x
  16. switch (cs) {
  17. case 0:
  18. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  19. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  20. break;
  21. case 1:
  22. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  23. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  24. break;
  25. case 2:
  26. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  27. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  28. break;
  29. case 3:
  30. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  31. setbits_8(&gpio->par_dma, GPIO_PAR_DMA_DACK0_PCS3);
  32. break;
  33. case 5:
  34. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  35. setbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  36. break;
  37. }
  38. #endif
  39. #ifdef CONFIG_MCF5441x
  40. switch (cs) {
  41. case 0:
  42. clrbits_8(&gpio->par_dspi0,
  43. ~GPIO_PAR_DSPI0_PCS0_MASK);
  44. setbits_8(&gpio->par_dspi0,
  45. GPIO_PAR_DSPI0_PCS0_DSPI0PCS0);
  46. break;
  47. case 1:
  48. clrbits_8(&gpio->par_dspiow,
  49. GPIO_PAR_DSPIOW_DSPI0PSC1);
  50. setbits_8(&gpio->par_dspiow,
  51. GPIO_PAR_DSPIOW_DSPI0PSC1);
  52. break;
  53. }
  54. #endif
  55. }
  56. void dspi_chip_unselect(int cs)
  57. {
  58. struct gpio *gpio = (struct gpio *)MMAP_GPIO;
  59. #ifdef CONFIG_MCF5445x
  60. switch (cs) {
  61. case 0:
  62. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS0_PCS0);
  63. break;
  64. case 1:
  65. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS1_PCS1);
  66. break;
  67. case 2:
  68. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS2_PCS2);
  69. break;
  70. case 3:
  71. clrbits_8(&gpio->par_dma, ~GPIO_PAR_DMA_DACK0_UNMASK);
  72. break;
  73. case 5:
  74. clrbits_8(&gpio->par_dspi, GPIO_PAR_DSPI_PCS5_PCS5);
  75. break;
  76. }
  77. #endif
  78. #ifdef CONFIG_MCF5441x
  79. if (cs == 1)
  80. clrbits_8(&gpio->par_dspiow, GPIO_PAR_DSPIOW_DSPI0PSC1);
  81. #endif
  82. }
  83. #endif /* CONFIG_CF_DSPI */