1*6ccb4101SSimon GlassHow to port a serial driver to driver model 2*6ccb4101SSimon Glass=========================================== 3*6ccb4101SSimon Glass 4*6ccb4101SSimon GlassOver half of the I2C drivers have been converted as at November 2016. These 5*6ccb4101SSimon Glassones remain: 6*6ccb4101SSimon Glass 7*6ccb4101SSimon Glass adi_i2c 8*6ccb4101SSimon Glass davinci_i2c 9*6ccb4101SSimon Glass fti2c010 10*6ccb4101SSimon Glass ihs_i2c 11*6ccb4101SSimon Glass kona_i2c 12*6ccb4101SSimon Glass lpc32xx_i2c 13*6ccb4101SSimon Glass pca9564_i2c 14*6ccb4101SSimon Glass ppc4xx_i2c 15*6ccb4101SSimon Glass rcar_i2c 16*6ccb4101SSimon Glass sh_i2c 17*6ccb4101SSimon Glass soft_i2c 18*6ccb4101SSimon Glass zynq_i2c 19*6ccb4101SSimon Glass 20*6ccb4101SSimon GlassThe deadline for this work is the end of June 2017. If no one steps 21*6ccb4101SSimon Glassforward to convert these, at some point there may come a patch to remove them! 22*6ccb4101SSimon Glass 23*6ccb4101SSimon GlassHere is a suggested approach for converting your I2C driver over to driver 24*6ccb4101SSimon Glassmodel. Please feel free to update this file with your ideas and suggestions. 25*6ccb4101SSimon Glass 26*6ccb4101SSimon Glass- #ifdef out all your own I2C driver code (#ifndef CONFIG_DM_I2C) 27*6ccb4101SSimon Glass- Define CONFIG_DM_I2C for your board, vendor or architecture 28*6ccb4101SSimon Glass- If the board does not already use driver model, you need CONFIG_DM also 29*6ccb4101SSimon Glass- Your board should then build, but will not work fully since there will be 30*6ccb4101SSimon Glass no I2C driver 31*6ccb4101SSimon Glass- Add the U_BOOT_DRIVER piece at the end (e.g. copy tegra_i2c.c for example) 32*6ccb4101SSimon Glass- Add a private struct for the driver data - avoid using static variables 33*6ccb4101SSimon Glass- Implement each of the driver methods, perhaps by calling your old methods 34*6ccb4101SSimon Glass- You may need to adjust the function parameters so that the old and new 35*6ccb4101SSimon Glass implementations can share most of the existing code 36*6ccb4101SSimon Glass- If you convert all existing users of the driver, remove the pre-driver-model 37*6ccb4101SSimon Glass code 38*6ccb4101SSimon Glass 39*6ccb4101SSimon GlassIn terms of patches a conversion series typically has these patches: 40*6ccb4101SSimon Glass- clean up / prepare the driver for conversion 41*6ccb4101SSimon Glass- add driver model code 42*6ccb4101SSimon Glass- convert at least one existing board to use driver model serial 43*6ccb4101SSimon Glass- (if no boards remain that don't use driver model) remove the old code 44*6ccb4101SSimon Glass 45*6ccb4101SSimon GlassThis may be a good time to move your board to use device tree also. Mostly 46*6ccb4101SSimon Glassthis involves these steps: 47*6ccb4101SSimon Glass 48*6ccb4101SSimon Glass- define CONFIG_OF_CONTROL and CONFIG_OF_SEPARATE 49*6ccb4101SSimon Glass- add your device tree files to arch/<arch>/dts 50*6ccb4101SSimon Glass- update the Makefile there 51*6ccb4101SSimon Glass- Add stdout-path to your /chosen device tree node if it is not already there 52*6ccb4101SSimon Glass- build and get u-boot-dtb.bin so you can test it 53*6ccb4101SSimon Glass- Your drivers can now use device tree 54*6ccb4101SSimon Glass- For device tree in SPL, define CONFIG_SPL_OF_CONTROL 55