~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/Documentation/arch/sh/new-machine.rst

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /Documentation/arch/sh/new-machine.rst (Version linux-6.12-rc7) and /Documentation/arch/ppc/new-machine.rst (Version linux-6.5.13)


  1 .. SPDX-License-Identifier: GPL-2.0               
  2                                                   
  3 =============================                     
  4 Adding a new board to LinuxSH                     
  5 =============================                     
  6                                                   
  7                Paul Mundt <lethal@linux-sh.org>    
  8                                                   
  9 This document attempts to outline what steps a    
 10 for new boards to the LinuxSH port under the n    
 11 also attempts to outline some of the noticeabl    
 12 and the 2.5/2.6 SH backend.                       
 13                                                   
 14 1. New Directory Structure                        
 15 ==========================                        
 16                                                   
 17 The first thing to note is the new directory s    
 18 of the board-specific code (with the exception    
 19 in arch/sh/kernel/ directly, with board-specif    
 20 include/asm-sh/. For the new kernel, things ar    
 21 companion chip type, and CPU type. Looking at     
 22 hierarchy looks like the following:               
 23                                                   
 24 Board-specific code::                             
 25                                                   
 26     .                                             
 27     |-- arch                                      
 28     |   `-- sh                                    
 29     |       `-- boards                            
 30     |           |-- adx                           
 31     |           |   `-- board-specific files      
 32     |           |-- bigsur                        
 33     |           |   `-- board-specific files      
 34     |           |                                 
 35     |           ... more boards here ...          
 36     |                                             
 37     `-- include                                   
 38         `-- asm-sh                                
 39             |-- adx                               
 40             |   `-- board-specific headers        
 41             |-- bigsur                            
 42             |   `-- board-specific headers        
 43             |                                     
 44             .. more boards here ...               
 45                                                   
 46 Next, for companion chips::                       
 47                                                   
 48     .                                             
 49     `-- arch                                      
 50         `-- sh                                    
 51             `-- cchips                            
 52                 `-- hd6446x                       
 53                     `-- hd64461                   
 54                         `-- cchip-specific fil    
 55                                                   
 56 ... and so on. Headers for the companion chips    
 57 board-specific headers. Thus, include/asm-sh/h    
 58 hd64461-specific headers.                         
 59                                                   
 60 Finally, CPU family support is also abstracted    
 61                                                   
 62     .                                             
 63     |-- arch                                      
 64     |   `-- sh                                    
 65     |       |-- kernel                            
 66     |       |   `-- cpu                           
 67     |       |       |-- sh2                       
 68     |       |       |   `-- SH-2 generic files    
 69     |       |       |-- sh3                       
 70     |       |       |   `-- SH-3 generic files    
 71     |       |       `-- sh4                       
 72     |       |           `-- SH-4 generic files    
 73     |       `-- mm                                
 74     |           `-- This is also broken out pe    
 75     |               have their own set of cach    
 76     |                                             
 77     `-- include                                   
 78         `-- asm-sh                                
 79             |-- cpu-sh2                           
 80             |   `-- SH-2 specific headers         
 81             |-- cpu-sh3                           
 82             |   `-- SH-3 specific headers         
 83             `-- cpu-sh4                           
 84                 `-- SH-4 specific headers         
 85                                                   
 86 It should be noted that CPU subtypes are _not_    
 87 need to be dealt with by the CPU family specif    
 88                                                   
 89 2. Adding a New Board                             
 90 =====================                             
 91                                                   
 92 The first thing to determine is whether the bo    
 93 isolated, or whether it will be part of a fami    
 94 share the same board-specific code with minor     
 95                                                   
 96 In the first case, this is just a matter of ma    
 97 board in arch/sh/boards/ and adding rules to h    
 98 build system (more on this in the next section    
 99 it makes more sense to have a common top-level    
100 and then populate that with sub-directories fo    
101 Both the Solution Engine and the hp6xx boards     
102                                                   
103 After you have setup your new arch/sh/boards/     
104 should also add a directory in include/asm-sh     
105 board (if there are going to be more than one)    
106 seamlessly with the build system, it's best to    
107 as the arch/sh/boards/ directory name, though     
108 a family, the build system has ways of dealing    
109 overloading), and you can feel free to name th    
110 member itself.                                    
111                                                   
112 There are a few things that each board is requ    
113 arch/sh/boards and the include/asm-sh/ hierarc    
114 explain this, we use some examples for adding     
115 setup code, we're required at the very least t    
116 get_system_type() and platform_setup(). For ou    
117 might look something like::                       
118                                                   
119     /*                                            
120     * arch/sh/boards/vapor/setup.c - Setup cod    
121     */                                            
122     #include <linux/init.h>                       
123                                                   
124     const char *get_system_type(void)             
125     {                                             
126             return "FooTech Vaporboard";          
127     }                                             
128                                                   
129     int __init platform_setup(void)               
130     {                                             
131             /*                                    
132             * If our hardware actually existed    
133             * setup here. Though it's also san    
134             * if there's no real init work tha    
135             * this board.                         
136             */                                    
137                                                   
138             /* Start-up imaginary PCI ... */      
139                                                   
140             /* And whatever else ... */           
141                                                   
142             return 0;                             
143     }                                             
144                                                   
145 Our new imaginary board will also have to tie     
146 to be of any use.                                 
147                                                   
148 machvec functions fall into a number of catego    
149                                                   
150  - I/O functions to IO memory (inb etc) and PC    
151  - I/O mapping functions (ioport_map, ioport_u    
152  - a 'heartbeat' function.                        
153  - PCI and IRQ initialization routines.           
154  - Consistent allocators (for boards that need    
155    particularly for allocating out of some boa    
156    handles).                                      
157                                                   
158 There are machvec functions added and removed     
159 consult include/asm-sh/machvec.h for the curre    
160                                                   
161 The kernel will automatically wrap in generic     
162 pointers in the machvec at boot time, as machv    
163 unconditionally throughout most of the tree. S    
164 sparse machvecs (such as the dreamcast and sh0    
165 virtually everything (rts7751r2d).                
166                                                   
167 Adding a new machine is relatively trivial (us    
168                                                   
169 If the board-specific definitions are quite mi    
170 the vast majority of boards, simply having a s    
171 sufficient.                                       
172                                                   
173  - add a new file include/asm-sh/vapor.h which    
174    any machine specific IO functions prefixed     
175    example vapor_inb. These will be needed whe    
176    vector.                                        
177                                                   
178    Note that these prototypes are generated au    
179    __IO_PREFIX to something sensible. A typica    
180                                                   
181         #define __IO_PREFIX vapor                 
182         #include <asm/io_generic.h>               
183                                                   
184    somewhere in the board-specific header. Any    
185    have a legacy io.h should remove it entirel    
186                                                   
187  - Add machine vector definitions to the board    
188    this must be defined as something like::       
189                                                   
190         struct sh_machine_vector mv_vapor __in    
191                 .mv_name = "vapor",               
192         };                                        
193         ALIAS_MV(vapor)                           
194                                                   
195  - finally add a file arch/sh/boards/vapor/io.    
196    the machine specific io functions (if there    
197                                                   
198 3. Hooking into the Build System                  
199 ================================                  
200                                                   
201 Now that we have the corresponding directories    
202 board-specific code is in place, it's time to     
203 whole mess to fit into the build system.          
204                                                   
205 Large portions of the build system are now ent    
206 require the proper entry here and there in ord    
207                                                   
208 The first thing to do is to add an entry to ar    
209 "System type" menu::                              
210                                                   
211     config SH_VAPOR                               
212             bool "Vapor"                          
213             help                                  
214             select Vapor if configuring for a     
215                                                   
216 next, this has to be added into arch/sh/Makefi    
217 machdir-y entry in order to be built. This ent    
218 the board directory as it appears in arch/sh/b    
219 sub-directory (in which case, all parent direc    
220 need to be listed). For our new board, this en    
221                                                   
222     machdir-$(CONFIG_SH_VAPOR)  += vapor          
223                                                   
224 provided that we've placed everything in the a    
225                                                   
226 Next, the build system assumes that your inclu    
227 be named the same. If this is not the case (as    
228 boards belonging to a common family), then the    
229 implicitly appended to incdir-y. The existing     
230 Solution Engine and hp6xx boards, so see these    
231                                                   
232 Once that is taken care of, it's time to add a    
233 This is done by adding an entry to the end of     
234 list. The method for doing this is self explan    
235 space restating it here. After this is done, y    
236 implicit checks for your board if you need thi    
237 common code, such as::                            
238                                                   
239         /* Make sure we're on the FooTech Vapo    
240         if (!mach_is_vapor())                     
241                 return -ENODEV;                   
242                                                   
243 also note that the mach_is_boardname() check w    
244 lowercase, regardless of the fact that the mac    
245 uppercase. You can read the script if you real    
246 so you probably don't want to do that.            
247                                                   
248 Now all that's left to do is providing a defco    
249 way, other people who end up with this board c    
250 for reference instead of trying to guess what     
251 used on it.                                       
252                                                   
253 Also, as soon as you have copied over a sample    
254 (assume arch/sh/configs/vapor_defconfig), you     
255 build target, and it will be implicitly listed    
256                                                   
257 Looking at the 'make help' output, you should     
258                                                   
259 Architecture specific targets (sh):               
260                                                   
261   =======================   ==================    
262   zImage                    Compressed kernel     
263   adx_defconfig             Build for adx         
264   cqreek_defconfig          Build for cqreek      
265   dreamcast_defconfig       Build for dreamcas    
266   ...                                             
267   vapor_defconfig           Build for vapor       
268   =======================   ==================    
269                                                   
270 which then allows you to do::                     
271                                                   
272     $ make ARCH=sh CROSS_COMPILE=sh4-linux- va    
273                                                   
274 which will in turn copy the defconfig for this    
275 oldconfig (prompting you for any new options s    
276 and start you on your way to having a function    
277 board.                                            
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php