1. 设备树
spi_1: spi@78b9000 {
compatible = "qcom,spi-qup-v2";
#address-cells = <1>;
#size-cells = <0>;
reg-names = "spi_physical", "spi_bam_physical";
reg = <0x78b9000 0x600>,
<0x7884000 0x23000>;
interrupt-names = "spi_irq", "spi_bam_irq";
interrupts = <0 99 0>, <0 238 0>;
spi-max-frequency = <19200000>;
pinctrl-names = "spi_default", "spi_sleep";
pinctrl-0 = <&spi1_default &spi1_cs0_active>;
pinctrl-1 = <&spi1_sleep &spi1_cs0_sleep>;
clocks = <&clock_gcc clk_gcc_blsp1_ahb_clk>,
<&clock_gcc clk_gcc_blsp1_qup5_spi_apps_clk>;
clock-names = "iface_clk", "core_clk";
qcom,infinite-mode = <0>;
qcom,use-bam;
qcom,use-pinctrl;
qcom,ver-reg-exists;
qcom,bam-consumer-pipe-index = <18>;
qcom,bam-producer-pipe-index = <19>;
qcom,master-id = <86>;
};
spi1_active {
qcom,pins = <&gp 16>, <&gp 17>, <&gp 19>;
qcom,num-grp-pins = <3>;
qcom,pin-func = <1>;
label = "spi1-active";
spi1_default: spi1_default {
drive-strength = <12>;
bias-disable = <0>;
};
};
spi1_suspend {
qcom,pins = <&gp 16>, <&gp 17>, <&gp 19>;
qcom,num-grp-pins = <3>;
qcom,pin-func = <0>;
label = "spi1-suspend";
spi1_sleep: spi1_sleep {
drive-strength = <2>;
bias-pull-down;
};
};
spi1_cs0_active {
qcom,pins = <&gp 18>;
qcom,num-grp-pins = <1>;
qcom,pin-func = <1>;
label = "spi1-cs0-active";
spi1_cs0_active: cs0_active {
drive-strength = <2>;
bias-disable = <0>;
};
};
spi1_cs0_suspend {
qcom,pins = <&gp 18>;
qcom,num-grp-pins = <1>;
qcom,pin-func = <0>;
label = "spi1-cs0-suspend";
spi1_cs0_sleep: cs0_sleep {
drive-strength = <2>;
bias-disable = <0>;
};
};
注意:
如有GPIO重复使用,请屏蔽相关gpio和相关驱动(如I2C_5,因为I2C和SPI均被注册),
tpiu_setb_4 中
//qcom,pins = <&gp 16>;
tpiu_setb_5 中
//qcom,pins = <&gp 17>;
tlmm_gpio_key 中
//ZHANGLEI
//qcom,pins = <&gp 16>, <&gp 17>, <&gp 92>; // 90 91
2. set up clocks
//此步骤不适用于msm8994之后的版本
Project_Root/drivers/clk/qcom/clock-gcc-8909.c:
添加时钟节点:
static struct clk_lookup msm_clocks_lookup[] = {
CLK_LIST(gcc_blsp1_ahb_clk),
CLK_LIST(blsp1_qup4_spi_apps_clk_src),
3. Set up the GPIO
//此步骤不适用于msm8994之后的版本
3.1 Project_Root/kernel/arch/arm/mach-msm/board--gpiomux.c
3.1.1 Create a configuration structure:
static struct gpiomux_setting gpio_blsp1_spi_config
3.1.2 Create a GPIO array:
static struct msm_gpiomux_config msm_blsp_configs[] __initdata
3.1.3 Register the GPIOs:
void __init msm_8974_init_gpiomux(void)
//此步骤不适用于msm8994之后的版本
4.1 Project_Root/kernel/arch/arm/mach-msm/board--gpiomux.c
4.1.1 Create a suspend/active configuration structure:
static struct gpiomux_setting gpio_blsp1_spi_config
static struct gpiomux_setting gpio_blsp1_spi_suspend_config
4.1.2 Create a GPIO array
static struct msm_gpiomux_config msm_blsp_configs[] __initdata
4.1.3 Register the GPIOs
void __init msm_8974_init_gpiomux(void)
4.1.4 Add GPIO numbers to the device tree.
/kernel/arch/arm/boot/dts/-cdp.dts