xref: /openbmc/u-boot/doc/driver-model/serial-howto.txt (revision ebb2c535852e7591c288aef7530fa24be32e3ec3)
11d149eddSSimon GlassHow to port a serial driver to driver model
21d149eddSSimon Glass===========================================
31d149eddSSimon Glass
4*92d05e50SSimon GlassAlmost all of the serial drivers have been converted as at January 2016. These
5*92d05e50SSimon Glassones remain:
61d149eddSSimon Glass
71d149eddSSimon Glass   serial_bfin.c
81d149eddSSimon Glass   serial_pxa.c
91d149eddSSimon Glass
10*92d05e50SSimon GlassThe deadline for this work was the end of January 2016. If no one steps
11*92d05e50SSimon Glassforward to convert these, at some point there may come a patch to remove them!
121d149eddSSimon Glass
131d149eddSSimon GlassHere is a suggested approach for converting your serial driver over to driver
141d149eddSSimon Glassmodel. Please feel free to update this file with your ideas and suggestions.
151d149eddSSimon Glass
161d149eddSSimon Glass- #ifdef out all your own serial driver code (#ifndef CONFIG_DM_SERIAL)
171d149eddSSimon Glass- Define CONFIG_DM_SERIAL for your board, vendor or architecture
181d149eddSSimon Glass- If the board does not already use driver model, you need CONFIG_DM also
191d149eddSSimon Glass- Your board should then build, but will not boot since there will be no serial
201d149eddSSimon Glass    driver
211d149eddSSimon Glass- Add the U_BOOT_DRIVER piece at the end (e.g. copy serial_s5p.c for example)
221d149eddSSimon Glass- Add a private struct for the driver data - avoid using static variables
231d149eddSSimon Glass- Implement each of the driver methods, perhaps by calling your old methods
241d149eddSSimon Glass- You may need to adjust the function parameters so that the old and new
251d149eddSSimon Glass    implementations can share most of the existing code
261d149eddSSimon Glass- If you convert all existing users of the driver, remove the pre-driver-model
271d149eddSSimon Glass    code
281d149eddSSimon Glass
291d149eddSSimon GlassIn terms of patches a conversion series typically has these patches:
301d149eddSSimon Glass- clean up / prepare the driver for conversion
311d149eddSSimon Glass- add driver model code
321d149eddSSimon Glass- convert at least one existing board to use driver model serial
331d149eddSSimon Glass- (if no boards remain that don't use driver model) remove the old code
341d149eddSSimon Glass
351d149eddSSimon GlassThis may be a good time to move your board to use device tree also. Mostly
361d149eddSSimon Glassthis involves these steps:
371d149eddSSimon Glass
381d149eddSSimon Glass- define CONFIG_OF_CONTROL and CONFIG_OF_SEPARATE
391d149eddSSimon Glass- add your device tree files to arch/<arch>/dts
401d149eddSSimon Glass- update the Makefile there
411d149eddSSimon Glass- Add stdout-path to your /chosen device tree node if it is not already there
421d149eddSSimon Glass- build and get u-boot-dtb.bin so you can test it
431d149eddSSimon Glass- Your drivers can now use device tree
441d149eddSSimon Glass- For device tree in SPL, define CONFIG_SPL_OF_CONTROL
45