文档路径 :Documentation/devicetree/bindings/spi/spi-gpio.yaml
# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/spi/spi-gpio.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: SPI-GPIO devicetree bindings
maintainers:
- Rob Herring <robh@kernel.org>
description:
This represents a group of 3-n GPIO lines used for bit-banged SPI on
dedicated GPIO lines.
allOf:
- $ref: "/schemas/spi/spi-controller.yaml#"
properties:
compatible:
const: spi-gpio
sck-gpios:
description: GPIO spec for the SCK line to use
maxItems: 1
miso-gpios:
description: GPIO spec for the MISO line to use
maxItems: 1
mosi-gpios:
description: GPIO spec for the MOSI line to use
maxItems: 1
cs-gpios:
description: GPIOs to use for chipselect lines.
Not needed if num-chipselects = <0>.
minItems: 1
maxItems: 1024
num-chipselects:
description: Number of chipselect lines. Should be <0> if a single device
with no chip select is connected.
$ref: "/schemas/types.yaml#/definitions/uint32"
# Deprecated properties
gpio-sck: false
gpio-miso: false
gpio-mosi: false
required:
- compatible
- num-chipselects
- sck-gpios
examples:
- |
spi {
compatible = "spi-gpio";
#address-cells = <0x1>;
#size-cells = <0x0>;
sck-gpios = <&gpio 95 0>;
miso-gpios = <&gpio 98 0>;
mosi-gpios = <&gpio 97 0>;
cs-gpios = <&gpio 125 0>;
num-chipselects = <1>;
/* clients */
};
看起来还是挺简单的,只需要配置 compatible 和对应的 gpio。
但是要在内核勾选相应的模块。
1、在linux内核目录下,输入 make menuconfig 即可进入菜单页面
2、左斜杠 / 进入搜素 ,输入 spi_gpio ,然后回车


3、输入 1 选中它,然后勾选这两项

4、然后退出
此时工作已经完成一半了,下面直接修改设备树即可使用。
参照那个文档,进行设备树的配置
aspi{
compatible = "spi-gpio";
#address-cells = <0x1>;
#size-cells = <0x0>;
sck-gpios = <&pio PE 8 0>;
miso-gpios = <&pio PE 9 0>;
mosi-gpios = <&pio PE 10 0>;
cs-gpios = <&pio PE 11 0>;
num-chipselects = <1>;
status = "okay";
/* 下面添加具体的spi设备*/
};
如下所示:

aspi_pin: aspi_pin{
allwinner,pins = "PE8","PE9","PE10","PE11";
};
如下所示:

然后编译内核、buildroot、烧录balabala。。。
参照上一个文档的程序 fb-test-rect
感受:慢。
明显感觉到一帧帧地刷过去。

其实实现模拟spi不是为了刷屏,而是这个屏幕使用的是电阻屏,使用的是XPT2046芯片,需要使用spi通信,对于读取触摸屏位置来说,对速度的要求其实不高。但是这个板子没有多余的spi了,cs只有一个,只能暂时模拟spi使用了(如果把核心板的spi nand拆掉呢)