高通APQ8074 spi 接口配置
8074 平台含有两个BLSP(BAM Low-Speed Peripheral) , 每一个BLSP含有两个QUP, 每一个QUP可以被配置为I2C, SPI, UART, UIM接口, BLSP是高通对于低速接口的一种管理方式。
每个QUP是和特定的引脚相关的, 如下图所示,比如下面的引脚是属于BLSP8的, 也就是第二个BLSP的第二个QUP,
注意这些引脚只能被配置到第二个BLSP的第2个QUP上,可以通过继续查看高通相关资料
QUP的中断相关信息
得到这些信息后,如果只是要将SPI配置成FIFO模式,而不是BAM模式,需要修改如下文件
diff --git a/arch/arm/boot/dts/msm8974.dtsi b/arch/arm/boot/dts/msm8974.dtsi
index 4178acf..649aa87 100644
--- a/arch/arm/boot/dts/msm8974.dtsi
+++ b/arch/arm/boot/dts/msm8974.dtsi
@@ -20,6 +20,7 @@
aliases {
spi0 = &spi_0;
spi7 = &spi_7;
+ spi8 = &spi_8;
sdhc1 = &sdhc_1; /* SDC1 eMMC slot */
sdhc2 = &sdhc_2; /* SDC2 SD card slot */
sdhc3 = &sdhc_3; /* SDC3 SDIO slot */
@@ -888,6 +889,27 @@
qcom,master-id = <86>;
};
+ spi_8: spi@f9964000 {
+ compatible = "qcom,spi-qup-v2";
+ reg = <0xf9964000 0x1000>;
+ interrupts = <0 102 0>;
+ spi-max-frequency = <19200000>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ qcom,gpio-clk = <&msmgpio 48 0>; /* CLK */
+ qcom,gpio-miso = <&msmgpio 46 0>; /* MISO */
+ qcom,gpio-mosi = <&msmgpio 45 0>; /* MOSI */
+ qcom,gpio-cs0 = <&msmgpio 47 0>;
+
+ qcom,master-id = <84>;
+
+ spidev@0 { //Slave driver and CS ID
+ compatible = "qcom,spi_name"; //Manufacture, and Mode
+ reg = <0>; //Same as CS ID
+ spi-max-frequency = <3200000>; //Max Frequency for Device
+ };
+ };
+
qcom,clock-krait@f9016000 {
compatible = "qcom,clock-krait-8974";
reg = <0xf9016000 0x20>,
/*使能 spi驱动, 可以修改spidev.c的 compatible 把名字修改为device tree相同的名字,之后kernel会挂在这个设备到spi总线,dev目录下将会出现spidev8.0的设备节点*/
diff --git a/arch/arm/configs/msm8974_defconfig b/arch/arm/configs/msm8974_defconfig
index a12538a..74c51e6 100755
--- a/arch/arm/configs/msm8974_defconfig
+++ b/arch/arm/configs/msm8974_defconfig
@@ -315,7 +315,7 @@ CONFIG_I2C_CHARDEV=y
CONFIG_I2C_QUP=y
CONFIG_SPI=y
CONFIG_SPI_QUP=y
-CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_SPIDEV=y
CONFIG_SPMI=y
CONFIG_SPMI_MSM_PMIC_ARB=y
CONFIG_MSM_QPNP_INT=y
修改gpio SPI属性,注意GPIO的function不要和已经注册的function 冲突
diff --git a/arch/arm/mach-msm/board-8974-gpiomux.c b/arch/arm/mach-msm/board-8974-gpiomux.c
index cec1a8f..6d67f18 100755
--- a/arch/arm/mach-msm/board-8974-gpiomux.c
+++ b/arch/arm/mach-msm/board-8974-gpiomux.c
@@ -683,6 +683,35 @@ static struct msm_gpiomux_config msm_blsp_configs[] __initdata = {
[GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
},
},
+
+ {
+ .gpio = 45, /* BLSP2 QUP1 SPI_DATA_MOSI */
+ .settings = {
+ [GPIOMUX_ACTIVE] = &gpio_spi_config,
+ [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
+ },
+ },
+ {
+ .gpio = 46, /* BLSP2 QUP1 SPI_DATA_MISO */
+ .settings = {
+ [GPIOMUX_ACTIVE] = &gpio_spi_config,
+ [GPIOMUX_SUSPENDED] = &gpio_suspend_config[1],
+ },
+ },
+ {
+ .gpio = 48, /* BLSP2 QUP1 SPI_CLK */
+ .settings = {
+ [GPIOMUX_ACTIVE] = &gpio_spi_config,
+ [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
+ },
+ },
+ {
+ .gpio = 47, /* BLSP2 QUP1 SPI_CS0_N */
+ .settings = {
+ [GPIOMUX_ACTIVE] = &gpio_spi_config,
+ [GPIOMUX_SUSPENDED] = &gpio_suspend_config[0],
+ },
+ },
};
diff --git a/arch/arm/mach-msm/clock-8974.c b/arch/arm/mach-msm/clock-8974.c
index 128a363..adff33a 100755
--- a/arch/arm/mach-msm/clock-8974.c
+++ b/arch/arm/mach-msm/clock-8974.c
@@ -4967,7 +4967,8 @@ static struct clk_lookup msm_clocks_8974_common[] __initdata = {
CLK_LOOKUP("core_clk", gcc_blsp2_qup1_i2c_apps_clk.c, ""),
CLK_LOOKUP("core_clk", gcc_blsp2_qup1_spi_apps_clk.c, ""),
CLK_LOOKUP("core_clk", gcc_blsp2_qup2_i2c_apps_clk.c, ""),
- CLK_LOOKUP("core_clk", gcc_blsp2_qup2_spi_apps_clk.c, ""),
+ CLK_LOOKUP("iface_clk", gcc_blsp2_ahb_clk.c, "f9964000.spi"),
+ CLK_LOOKUP("core_clk", gcc_blsp2_qup2_spi_apps_clk.c, "f9964000.spi"),
CLK_LOOKUP("core_clk", gcc_blsp2_qup3_i2c_apps_clk.c, ""),
CLK_LOOKUP("core_clk", gcc_blsp2_qup3_spi_apps_clk.c, ""),
CLK_LOOKUP("core_clk", gcc_blsp2_qup4_i2c_apps_clk.c, ""),
最后注意下使能的spidev.c设备驱动,这个驱动也需要修改spi_qsd.c 保存实际传输数据长度的actual_lenght字段不会被赋值,需要对spidev.c文件进行少许的修改
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index aaf0265..efb7d07 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -198,14 +204,14 @@ spidev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos)
mutex_lock(&spidev->buf_lock);
status = spidev_sync_read(spidev, count);
- if (status > 0) {
+ if (status >= 0) {
unsigned long missing;
- missing = copy_to_user(buf, spidev->buffer, status);
- if (missing == status)
+ missing = copy_to_user(buf, spidev->buffer, count);
+ if (missing == count)
status = -EFAULT;
else
- status = status - missing;
+ status = count - missing;
}
mutex_unlock(&spidev->buf_lock);
之后可以通过打开dev/spidev8.0文件进行SPI设备的读写测试,需要注意的是,如果你用dragonboard, 需要注意一下电平转换芯片的电压,一定要在PMIC中时能对应的电压。
高通APQ8074 spi 接口配置,布布扣,bubuko.com
原文地址:http://blog.csdn.net/jumper511/article/details/25622833