blob: 4f9df940ed9e08509327c97eaf83ffc0b153a0f8 [file] [log] [blame]
Marek Vasut909bbcc2012-08-08 01:42:17 +00001The U-Boot Driver Model Project
2===============================
3I/O system analysis
4===================
5Marek Vasut <marek.vasut@gmail.com>
62012-02-21
7
8I) Overview
9-----------
10
11The current FPGA implementation is handled by command "fpga". This command in
12turn calls the following functions:
13
14fpga_info()
15fpga_load()
16fpga_dump()
17
18These functions are implemented by what appears to be FPGA multiplexer, located
19in drivers/fpga/fpga.c . This code determines which device to operate with
20depending on the device ID.
21
22The fpga_info() function is multiplexer of the functions providing information
23about the particular FPGA device. These functions are implemented in the drivers
24for the particular FPGA device:
25
26xilinx_info()
27altera_info()
28lattice_info()
29
30Similar approach is used for fpga_load(), which multiplexes "xilinx_load()",
31"altera_load()" and "lattice_load()" and is used to load firmware into the FPGA
32device.
33
34The fpga_dump() function, which prints the contents of the FPGA device, is no
35different either, by multiplexing "xilinx_dump()", "altera_dump()" and
36"lattice_dump()" functions.
37
38Finally, each new FPGA device is registered by calling "fpga_add()" function.
39This function takes two arguments, the second one being particularly important,
40because it's basically what will become platform_data. Currently, it's data that
41are passed to the driver from the board/platform code.
42
43II) Approach
44------------
45
46The path to conversion of the FPGA subsystem will be very straightforward, since
47the FPGA subsystem is already quite dynamic. Multiple things will need to be
48modified though.
49
50First is the registration of the new FPGA device towards the FPGA core. This
51will be achieved by calling:
52
53 fpga_device_register(struct instance *i, const struct fpga_ops *ops);
54
55The particularly interesting part is the struct fpga_ops, which contains
56operations supported by the FPGA device. These are basically the already used
57calls in the current implementation:
58
59struct fpga_ops {
60 int info(struct instance *i);
61 int load(struct instance *i, const char *buf, size_t size);
62 int dump(struct instance *i, const char *buf, size_t size);
63}
64
65The other piece that'll have to be modified is how the devices are tracked.
66It'll be necessary to introduce a linked list of devices within the FPGA core
67instead of tracking them by ID number.
68
69Next, the "Xilinx_desc", "Lattice_desc" and "Altera_desc" structures will have
70to be moved to driver's private_data. Finally, structures passed from the board
71and/or platform files, like "Xilinx_Virtex2_Slave_SelectMap_fns" would be passed
72via platform_data to the driver.
73
74III) Analysis of in-tree drivers
75--------------------------------
76
77 1) Altera driver
78 ----------------
79 The driver is realized using the following files:
80
81 drivers/fpga/altera.c
82 drivers/fpga/ACEX1K.c
83 drivers/fpga/cyclon2.c
84 drivers/fpga/stratixII.c
85
86 All of the sub-drivers implement basically the same info-load-dump interface
87 and there's no expected problem during the conversion. The driver itself will
88 be realised by altera.c and all the sub-drivers will be linked in. The
89 distinction will be done by passing different platform data.
90
91 2) Lattice driver
92 -----------------
93 The driver is realized using the following files:
94
95 drivers/fpga/lattice.c
96 drivers/fpga/ivm_core.c
97
98 This driver also implements the standard interface, but to realise the
99 operations with the FPGA device, uses functions from "ivm_core.c" file. This
100 file implements the main communications logic and has to be linked in together
101 with "lattice.c". No problem converting is expected here.
102
103 3) Xilinx driver
104 ----------------
105 The driver is realized using the following files:
106
107 drivers/fpga/xilinx.c
108 drivers/fpga/spartan2.c
109 drivers/fpga/spartan3.c
110 drivers/fpga/virtex2.c
111
112 This set of sub-drivers is special by defining a big set of macros in
113 "include/spartan3.h" and similar files. These macros would need to be either
114 rewritten or replaced. Otherwise, there are no problems expected during the
115 conversion process.