三 源碼配置配置IOMUX的過程,實際上就是向指定的設備地址寫入配置值的過程。
內核代碼提供專門的宏 IOMUX_PAD,用來把IOMUX的配置進行拼裝,然后寫入到指定的設備地址中。
IOMUX_PAD 定義文件 ~/android/kernel_imx/arch/arm/plat-mxc/include/mach/iomux-v3.h
/* * build IOMUX_PAD structure * * This iomux scheme is based around pads, which are the physical balls * on the processor. * * - Each pad has a pad control register (IOMUXC_SW_PAD_CTRL_x) which controls * things like driving strength and pullup/pulldown. * - Each pad can have but not necessarily does have an output routing register * (IOMUXC_SW_MUX_CTL_PAD_x). * - Each pad can have but not necessarily does have an input routing register * (IOMUXC_x_SELECT_INPUT) * * The three register sets do not have a fixed offset to each other, * hence we order this table by pad control registers (which all pads * have) and put the optional i/o routing registers into additional * fields. * * The naming convention for the pad modes is MX35_PAD___ * If or refers to a GPIO, it is named * GPIO__ * * IOMUX/PAD Bit field definitions * * MUX_CTRL_OFS: 0..11 (12) * PAD_CTRL_OFS: 12..23 (12) * SEL_INPUT_OFS: 24..35 (12) * MUX_MODE + SION: 36..40 (5) * PAD_CTRL + NO_PAD_CTRL: 41..58 (18) * SEL_INP: 59..62 (4) * reserved: 63 (1)*/#define IOMUX_PAD(_pad_ctrl_ofs, _mux_ctrl_ofs, _mux_mode, _sel_input_ofs, _sel_input, _pad_ctrl) (((iomux_v3_cfg_t)(_mux_ctrl_ofs) << MUX_CTRL_OFS_SHIFT) | ((iomux_v3_cfg_t)(_mux_mode) << MUX_MODE_SHIFT) | ((iomux_v3_cfg_t)(_pad_ctrl_ofs) << MUX_PAD_CTRL_OFS_SHIFT) | ((iomux_v3_cfg_t)(_pad_ctrl) << MUX_PAD_CTRL_SHIFT) | ((iomux_v3_cfg_t)(_sel_input_ofs) << MUX_SEL_INPUT_OFS_SHIFT) | ((iomux_v3_cfg_t)(_sel_input) << MUX_SEL_INPUT_SHIFT))參數