xref: /OK3568_Linux_fs/u-boot/doc/driver-model/serial-howto.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunHow to port a serial driver to driver model
2*4882a593Smuzhiyun===========================================
3*4882a593Smuzhiyun
4*4882a593SmuzhiyunAlmost all of the serial drivers have been converted as at January 2016. These
5*4882a593Smuzhiyunones remain:
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun   serial_bfin.c
8*4882a593Smuzhiyun   serial_pxa.c
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe deadline for this work was the end of January 2016. If no one steps
11*4882a593Smuzhiyunforward to convert these, at some point there may come a patch to remove them!
12*4882a593Smuzhiyun
13*4882a593SmuzhiyunHere is a suggested approach for converting your serial driver over to driver
14*4882a593Smuzhiyunmodel. Please feel free to update this file with your ideas and suggestions.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun- #ifdef out all your own serial driver code (#ifndef CONFIG_DM_SERIAL)
17*4882a593Smuzhiyun- Define CONFIG_DM_SERIAL for your board, vendor or architecture
18*4882a593Smuzhiyun- If the board does not already use driver model, you need CONFIG_DM also
19*4882a593Smuzhiyun- Your board should then build, but will not boot since there will be no serial
20*4882a593Smuzhiyun    driver
21*4882a593Smuzhiyun- Add the U_BOOT_DRIVER piece at the end (e.g. copy serial_s5p.c for example)
22*4882a593Smuzhiyun- Add a private struct for the driver data - avoid using static variables
23*4882a593Smuzhiyun- Implement each of the driver methods, perhaps by calling your old methods
24*4882a593Smuzhiyun- You may need to adjust the function parameters so that the old and new
25*4882a593Smuzhiyun    implementations can share most of the existing code
26*4882a593Smuzhiyun- If you convert all existing users of the driver, remove the pre-driver-model
27*4882a593Smuzhiyun    code
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunIn terms of patches a conversion series typically has these patches:
30*4882a593Smuzhiyun- clean up / prepare the driver for conversion
31*4882a593Smuzhiyun- add driver model code
32*4882a593Smuzhiyun- convert at least one existing board to use driver model serial
33*4882a593Smuzhiyun- (if no boards remain that don't use driver model) remove the old code
34*4882a593Smuzhiyun
35*4882a593SmuzhiyunThis may be a good time to move your board to use device tree also. Mostly
36*4882a593Smuzhiyunthis involves these steps:
37*4882a593Smuzhiyun
38*4882a593Smuzhiyun- define CONFIG_OF_CONTROL and CONFIG_OF_SEPARATE
39*4882a593Smuzhiyun- add your device tree files to arch/<arch>/dts
40*4882a593Smuzhiyun- update the Makefile there
41*4882a593Smuzhiyun- Add stdout-path to your /chosen device tree node if it is not already there
42*4882a593Smuzhiyun- build and get u-boot-dtb.bin so you can test it
43*4882a593Smuzhiyun- Your drivers can now use device tree
44*4882a593Smuzhiyun- For device tree in SPL, define CONFIG_SPL_OF_CONTROL
45