Move some I2C code into shared.
Move some more stuff around so it's more portable.