高通 SPI驱动笔记


1. 设备树

//msm8909.dtsi:
spi_1: spi@78b9000 { /* BLSP1 QUP5 */
compatible = "qcom,spi-qup-v2";//厂商设备名
#address-cells = <1>;//子元素地址值的个数
#size-cells = <0>;//子元素长度值的个数
reg-names = "spi_physical", "spi_bam_physical";
reg = <0x78b9000 0x600>,//SPI地址
<0x7884000 0x23000>;//BAM地址
interrupt-names = "spi_irq", "spi_bam_irq";
/*中断号(BLSP4\SWDocument\BSP\Peripherals\BAM,\SWDocument\BSP\Peripherals\BAM)
BLSP[1~12]->IRQ[95~106]
BLSP[1~6]->BAM IRQ =238,BLSP[7~12]->BAM IRQ =239
*/

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>;//qup初始模式
qcom,use-bam;
qcom,use-pinctrl;
qcom,ver-reg-exists;
/*
bam-consumer-pipe-index:BLSP BAM pipes 见\SWDocument\BSP\Peripherals\BAM Table4-5
bam-producer-pipe-index:BLSP BAM pipes 见\SWDocument\BSP\Peripherals\BAM Table4-5
*/

qcom,bam-consumer-pipe-index = <18>;
qcom,bam-producer-pipe-index = <19>;
//BLSP bus master ID 见\SWDocument\BSP\Peripherals\BAM Table4-3
qcom,master-id = <86>;
};

//msm8909-pinctrl.dtsi:
spi1_active {
/* MOSI, MISO, CLK */
qcom,pins = <&gp 16>, <&gp 17>, <&gp 19>;
qcom,num-grp-pins = <3>;//how many pins contains in all
qcom,pin-func = <1>;//function pin
label = "spi1-active";
/* active state */
spi1_default: spi1_default {
drive-strength = <12>; /* 12 MA */
bias-disable = <0>; /* No PULL */
};
};

spi1_suspend {
/* MOSI, MISO, CLK */
qcom,pins = <&gp 16>, <&gp 17>, <&gp 19>;
qcom,num-grp-pins = <3>;
qcom,pin-func = <0>;
label = "spi1-suspend";
/* suspended state */
spi1_sleep: spi1_sleep {
drive-strength = <2>; /* 2 MA */
bias-pull-down; /* pull down */
};
};

spi1_cs0_active {
/* CS */
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 {
/* CS */
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:
//一部分cpu版本在kernel/arch/arm/mach-msm/下
添加时钟节点:
/* Clock lookup */
static struct clk_lookup msm_clocks_lookup[] = {
//Add node to BLSP1 AHB Clock

CLK_LIST(gcc_blsp1_ahb_clk),

/*
Add a node to QUP Core clock.
*/

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)

4. Configure the runtime GPIO:

//此步骤不适用于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/<chipset>-cdp.dts
智能推荐

注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告