Analysis of kirkwood support in U-boot

Ok, I got some time for playing, so I've picked one of the issues I had, and it is 'mainline U-boot support for Orion'. Things have improved since last time I'd lokked at Marvell-provided U-boot support, as mainline U-boot now has kirkwood support, in a form that can be fiendishly copied built upon in the spirit of reuse and Open Source for adding Orion support as well.

First thing I did was assess the size of kirkwood-related code in the mainline U-boot git repository. After pulling u-boot locally, I looked for files which implemented kirkwood-specifi functionality, as well as files which integrated kirkwood into u-boot.

19 files are used to implement kirkwood functionality in U-Boot. A quick analysis based on the 88F5182 and 88F6181/6192/6180 functional specifications leads to the following table, where comments are colored according to estimated difficulty of porting — easy, medium an difficult:
Ethernet driver
Orion egiga is same as kirkwood's.
drivers/usb/host/ehci-kirkwood.c USB driver
Same as Orion's first USB port. Use of second USB port at U-Boot level might need code mofifications.
drivers/spi/kirkwood_spi.c SPI driver
No SPI on Orion — no need for this code.
drivers/i2c/kirkwood_i2c.c I2C driver
Apparently identical to Orion (but kirkwood documentation has areas marked reserved in some tables even though they are discussed in the TWSI chapter).
drivers/mtd/nand/kirkwood_nand.c NAND controller
No NAND on Orion — no needfor this code.
cpu/arm926ejs/kirkwood/dram.c DRAM controller
Some registers different (pad strength control, 32-bit DRAM support).
cpu/arm926ejs/kirkwood/mpp.c Pin multplexing controller
Different number of GPIOs, slight changes in register addresses.
cpu/arm926ejs/kirkwood/cpu.c CPU related
Various changes needed.
cpu/arm926ejs/kirkwood/Makefile Defines objects to include for KW support
Requires only trivial modifications.
cpu/arm926ejs/kirkwood/timer.c Timer Orion timers are the same as kirkwood's.
include/asm-arm/arch-kirkwood/kw88f6192.h 6192-specific TCLK and REG base address TCLK=166MHz matches Orion's.
include/asm-arm/arch-kirkwood/kirkwood.h   Various Register address mappings need some checks.
include/asm-arm/arch-kirkwood/gpio.h   Remove high GPIO registers corresponding to additional GPIOs not existing in Orion.
include/asm-arm/arch-kirkwood/kw88f6281.h  6281-specific TCLK and REG base address
TCLK=200MHz does not match Orion's — not needed.
include/asm-arm/arch-kirkwood/spi.h   No SPI on Orion — no need for this code.
include/asm-arm/arch-kirkwood/cpu.h   Various changes needed.
include/asm-arm/arch-kirkwood/mpp.h    Various changes needed to support Orion GPIO/MPP variants
drivers/gpio/kw_gpio.c GPIO driver Could be (re-)used as such.

32 files have 'kirkwood' in their content:

Board definition for MV88F6281GTW_GE
Use as a model for Orion boards.
Board definition for Open-RD Base
Board definition for RD6281A
Board definition for SheevaPlug
common/image.c Adds a 'kirkwood boot image'
Kirkwood specific boot image format for booting from NAND, SPI NAND, SATA... Does not exist in Orion.
drivers/gpio/Makefile   Might even not need any change.
drivers/i2c/Makefile   Needs trivial changes only.
drivers/mtd/nand/Makefile   Needs trivial changes only.
drivers/net/Makefile   Needs trivial changes only.
drivers/serial/serial.c 16550 serial console driver Needs trivial changes only.
drivers/spi/Makefile   SPI not supported on Orion — No change needed
drivers/usb/host/Makefile   Might even not need any change.
Configuration for MV88F6281GTW_GE Use as a model for Orion-based configurations
include/configs/openrd_base.h Configuration for Open-RD Base
include/configs/rd6281a.h Configuration for RD6281A
include/configs/sheevaplug.h Configuration for SheevaPlug
include/image.h Adds a 'kirkwood boot image' Not needed in Orion.
include/netdev.h   Might even not need any change.
Makefile   Needs trivial changes only.
tools/kwbimage.c   Not needed in Orion.
tools/mkimage.c   Might even not need any change.