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.
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
11 * GNU General Public License for more details.
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.
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20 #include <linux/module.h>
21 #include <linux/types.h>
22 #include <linux/device.h>
23 #include <linux/string.h>
24 #include <linux/slab.h>
26 #include <linux/platform_device.h>
28 #include <linux/of_address.h>
29 #include <linux/firmware.h>
34 static inline void byte0_out(unsigned char data);
35 static inline void byte1_out(unsigned char data);
36 static inline void xl_cclk_b(int32_t i);
39 /* Assert and Deassert CCLK */
40 void xl_shift_cclk(int count)
44 for (i = 0; i < count; i++) {
50 int xl_supported_prog_bus_width(enum wbus bus_bytes)
58 pr_err("unsupported program bus width %d\n",
66 /* Serialize byte and clock each bit on target's DIN and CCLK pins */
67 void xl_shift_bytes_out(enum wbus bus_byte, unsigned char *pdata)
70 * supports 1 and 2 bytes programming mode
72 if (likely(bus_byte == bus_2byte))
80 * generic bit swap for xilinx SYSTEMMAP FPGA programming
82 static inline unsigned char bitswap(unsigned char s)
86 d = (((s&0x80)>>7) | ((s&0x40)>>5) | ((s&0x20)>>3) | ((s&0x10)>>1) |
87 ((s&0x08)<<1) | ((s&0x04)<<3) | ((s&0x02)<<5) | ((s&0x01)<<7));
91 void xl_program_b(int32_t i)
95 void xl_rdwr_b(int32_t i)
99 void xl_csi_b(int32_t i)
103 int xl_get_init_b(void)
108 int xl_get_done_b(void)
113 static inline void byte0_out(unsigned char data)
117 static inline void byte1_out(unsigned char data)
121 static inline void xl_cclk_b(int32_t i)
126 * configurable per device type for different I/O config