diff options
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/sh/new-machine.txt | 128 |
1 files changed, 51 insertions, 77 deletions
diff --git a/Documentation/sh/new-machine.txt b/Documentation/sh/new-machine.txt index eb2dd2e6993b..73988e0d112b 100644 --- a/Documentation/sh/new-machine.txt +++ b/Documentation/sh/new-machine.txt | |||
@@ -41,11 +41,6 @@ Board-specific code: | |||
41 | | | 41 | | |
42 | .. more boards here ... | 42 | .. more boards here ... |
43 | 43 | ||
44 | It should also be noted that each board is required to have some certain | ||
45 | headers. At the time of this writing, io.h is the only thing that needs | ||
46 | to be provided for each board, and can generally just reference generic | ||
47 | functions (with the exception of isa_port2addr). | ||
48 | |||
49 | Next, for companion chips: | 44 | Next, for companion chips: |
50 | . | 45 | . |
51 | `-- arch | 46 | `-- arch |
@@ -104,12 +99,13 @@ and then populate that with sub-directories for each member of the family. | |||
104 | Both the Solution Engine and the hp6xx boards are an example of this. | 99 | Both the Solution Engine and the hp6xx boards are an example of this. |
105 | 100 | ||
106 | After you have setup your new arch/sh/boards/ directory, remember that you | 101 | After you have setup your new arch/sh/boards/ directory, remember that you |
107 | also must add a directory in include/asm-sh for headers localized to this | 102 | should also add a directory in include/asm-sh for headers localized to this |
108 | board. In order to interoperate seamlessly with the build system, it's best | 103 | board (if there are going to be more than one). In order to interoperate |
109 | to have this directory the same as the arch/sh/boards/ directory name, | 104 | seamlessly with the build system, it's best to have this directory the same |
110 | though if your board is again part of a family, the build system has ways | 105 | as the arch/sh/boards/ directory name, though if your board is again part of |
111 | of dealing with this, and you can feel free to name the directory after | 106 | a family, the build system has ways of dealing with this (via incdir-y |
112 | the family member itself. | 107 | overloading), and you can feel free to name the directory after the family |
108 | member itself. | ||
113 | 109 | ||
114 | There are a few things that each board is required to have, both in the | 110 | There are a few things that each board is required to have, both in the |
115 | arch/sh/boards and the include/asm-sh/ heirarchy. In order to better | 111 | arch/sh/boards and the include/asm-sh/ heirarchy. In order to better |
@@ -122,6 +118,7 @@ might look something like: | |||
122 | * arch/sh/boards/vapor/setup.c - Setup code for imaginary board | 118 | * arch/sh/boards/vapor/setup.c - Setup code for imaginary board |
123 | */ | 119 | */ |
124 | #include <linux/init.h> | 120 | #include <linux/init.h> |
121 | #include <asm/rtc.h> /* for board_time_init() */ | ||
125 | 122 | ||
126 | const char *get_system_type(void) | 123 | const char *get_system_type(void) |
127 | { | 124 | { |
@@ -152,79 +149,57 @@ int __init platform_setup(void) | |||
152 | } | 149 | } |
153 | 150 | ||
154 | Our new imaginary board will also have to tie into the machvec in order for it | 151 | Our new imaginary board will also have to tie into the machvec in order for it |
155 | to be of any use. Currently the machvec is slowly on its way out, but is still | 152 | to be of any use. |
156 | required for the time being. As such, let us take a look at what needs to be | ||
157 | done for the machvec assignment. | ||
158 | 153 | ||
159 | machvec functions fall into a number of categories: | 154 | machvec functions fall into a number of categories: |
160 | 155 | ||
161 | - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc). | 156 | - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc). |
162 | - I/O remapping functions (ioremap etc) | 157 | - I/O mapping functions (ioport_map, ioport_unmap, etc). |
163 | - some initialisation functions | 158 | - a 'heartbeat' function. |
164 | - a 'heartbeat' function | 159 | - PCI and IRQ initialization routines. |
165 | - some miscellaneous flags | 160 | - Consistent allocators (for boards that need special allocators, |
166 | 161 | particularly for allocating out of some board-specific SRAM for DMA | |
167 | The tree can be built in two ways: | 162 | handles). |
168 | - as a fully generic build. All drivers are linked in, and all functions | 163 | |
169 | go through the machvec | 164 | There are machvec functions added and removed over time, so always be sure to |
170 | - as a machine specific build. In this case only the required drivers | 165 | consult include/asm-sh/machvec.h for the current state of the machvec. |
171 | will be linked in, and some macros may be redefined to not go through | 166 | |
172 | the machvec where performance is important (in particular IO functions). | 167 | The kernel will automatically wrap in generic routines for undefined function |
173 | 168 | pointers in the machvec at boot time, as machvec functions are referenced | |
174 | There are three ways in which IO can be performed: | 169 | unconditionally throughout most of the tree. Some boards have incredibly |
175 | - none at all. This is really only useful for the 'unknown' machine type, | 170 | sparse machvecs (such as the dreamcast and sh03), whereas others must define |
176 | which us designed to run on a machine about which we know nothing, and | 171 | virtually everything (rts7751r2d). |
177 | so all all IO instructions do nothing. | 172 | |
178 | - fully custom. In this case all IO functions go to a machine specific | 173 | Adding a new machine is relatively trivial (using vapor as an example): |
179 | set of functions which can do what they like | 174 | |
180 | - a generic set of functions. These will cope with most situations, | 175 | If the board-specific definitions are quite minimalistic, as is the case for |
181 | and rely on a single function, mv_port2addr, which is called through the | 176 | the vast majority of boards, simply having a single board-specific header is |
182 | machine vector, and converts an IO address into a memory address, which | 177 | sufficient. |
183 | can be read from/written to directly. | 178 | |
184 | 179 | - add a new file include/asm-sh/vapor.h which contains prototypes for | |
185 | Thus adding a new machine involves the following steps (I will assume I am | ||
186 | adding a machine called vapor): | ||
187 | |||
188 | - add a new file include/asm-sh/vapor/io.h which contains prototypes for | ||
189 | any machine specific IO functions prefixed with the machine name, for | 180 | any machine specific IO functions prefixed with the machine name, for |
190 | example vapor_inb. These will be needed when filling out the machine | 181 | example vapor_inb. These will be needed when filling out the machine |
191 | vector. | 182 | vector. |
192 | 183 | ||
193 | This is the minimum that is required, however there are ample | 184 | Note that these prototypes are generated automatically by setting |
194 | opportunities to optimise this. In particular, by making the prototypes | 185 | __IO_PREFIX to something sensible. A typical example would be: |
195 | inline function definitions, it is possible to inline the function when | 186 | |
196 | building machine specific versions. Note that the machine vector | 187 | #define __IO_PREFIX vapor |
197 | functions will still be needed, so that a module built for a generic | 188 | #include <asm/io_generic.h> |
198 | setup can be loaded. | 189 | |
199 | 190 | somewhere in the board-specific header. Any boards being ported that still | |
200 | - add a new file arch/sh/boards/vapor/mach.c. This contains the definition | 191 | have a legacy io.h should remove it entirely and switch to the new model. |
201 | of the machine vector. When building the machine specific version, this | 192 | |
202 | will be the real machine vector (via an alias), while in the generic | 193 | - Add machine vector definitions to the board's setup.c. At a bare minimum, |
203 | version is used to initialise the machine vector, and then freed, by | 194 | this must be defined as something like: |
204 | making it initdata. This should be defined as: | 195 | |
205 | 196 | struct sh_machine_vector mv_vapor __initmv = { | |
206 | struct sh_machine_vector mv_vapor __initmv = { | 197 | .mv_name = "vapor", |
207 | .mv_name = "vapor", | 198 | }; |
208 | } | 199 | ALIAS_MV(vapor) |
209 | ALIAS_MV(vapor) | 200 | |
210 | 201 | - finally add a file arch/sh/boards/vapor/io.c, which contains definitions of | |
211 | - finally add a file arch/sh/boards/vapor/io.c, which contains | 202 | the machine specific io functions (if there are enough to warrant it). |
212 | definitions of the machine specific io functions. | ||
213 | |||
214 | A note about initialisation functions. Three initialisation functions are | ||
215 | provided in the machine vector: | ||
216 | - mv_arch_init - called very early on from setup_arch | ||
217 | - mv_init_irq - called from init_IRQ, after the generic SH interrupt | ||
218 | initialisation | ||
219 | - mv_init_pci - currently not used | ||
220 | |||
221 | Any other remaining functions which need to be called at start up can be | ||
222 | added to the list using the __initcalls macro (or module_init if the code | ||
223 | can be built as a module). Many generic drivers probe to see if the device | ||
224 | they are targeting is present, however this may not always be appropriate, | ||
225 | so a flag can be added to the machine vector which will be set on those | ||
226 | machines which have the hardware in question, reducing the probe to a | ||
227 | single conditional. | ||
228 | 203 | ||
229 | 3. Hooking into the Build System | 204 | 3. Hooking into the Build System |
230 | ================================ | 205 | ================================ |
@@ -303,4 +278,3 @@ which will in turn copy the defconfig for this board, run it through | |||
303 | oldconfig (prompting you for any new options since the time of creation), | 278 | oldconfig (prompting you for any new options since the time of creation), |
304 | and start you on your way to having a functional kernel for your new | 279 | and start you on your way to having a functional kernel for your new |
305 | board. | 280 | board. |
306 | |||