io.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * This program is free software; you can redistribute it and/or modify
  3. * it under the terms of the GNU General Public License as published by
  4. * the Free Software Foundation; either version 2 of the License, or
  5. * (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. *
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/module.h>
  20. #include <linux/types.h>
  21. #include <linux/device.h>
  22. #include <linux/string.h>
  23. #include <linux/slab.h>
  24. #include <linux/fs.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/of.h>
  27. #include <linux/of_address.h>
  28. #include <linux/firmware.h>
  29. #include <linux/io.h>
  30. #include "io.h"
  31. static inline void byte0_out(unsigned char data);
  32. static inline void byte1_out(unsigned char data);
  33. static inline void xl_cclk_b(int32_t i);
  34. /* Assert and Deassert CCLK */
  35. void xl_shift_cclk(int count)
  36. {
  37. int i;
  38. for (i = 0; i < count; i++) {
  39. xl_cclk_b(1);
  40. xl_cclk_b(0);
  41. }
  42. }
  43. int xl_supported_prog_bus_width(enum wbus bus_bytes)
  44. {
  45. switch (bus_bytes) {
  46. case bus_1byte:
  47. break;
  48. case bus_2byte:
  49. break;
  50. default:
  51. pr_err("unsupported program bus width %d\n",
  52. bus_bytes);
  53. return 0;
  54. }
  55. return 1;
  56. }
  57. /* Serialize byte and clock each bit on target's DIN and CCLK pins */
  58. void xl_shift_bytes_out(enum wbus bus_byte, unsigned char *pdata)
  59. {
  60. /*
  61. * supports 1 and 2 bytes programming mode
  62. */
  63. if (likely(bus_byte == bus_2byte))
  64. byte0_out(pdata[0]);
  65. byte1_out(pdata[1]);
  66. xl_shift_cclk(1);
  67. }
  68. /*
  69. * generic bit swap for xilinx SYSTEMMAP FPGA programming
  70. */
  71. void xl_program_b(int32_t i)
  72. {
  73. }
  74. void xl_rdwr_b(int32_t i)
  75. {
  76. }
  77. void xl_csi_b(int32_t i)
  78. {
  79. }
  80. int xl_get_init_b(void)
  81. {
  82. return -1;
  83. }
  84. int xl_get_done_b(void)
  85. {
  86. return -1;
  87. }
  88. static inline void byte0_out(unsigned char data)
  89. {
  90. }
  91. static inline void byte1_out(unsigned char data)
  92. {
  93. }
  94. static inline void xl_cclk_b(int32_t i)
  95. {
  96. }
  97. /*
  98. * configurable per device type for different I/O config
  99. */
  100. int xl_init_io(void)
  101. {
  102. return -1;
  103. }