NanoPi H3 linux 4.14 修改FBTFT驱动

1. 修改DTS文件:

  sun8i-h3-nanopi.dtsi 中, 增加   matrix = &matrix; 

  

 1 / {
 2     aliases {
 3         serial0 = &uart0;
 4         serial1 = &uart1;
 5         serial2 = &uart2;
 6         serial3 = &uart3;
 7         i2c0 = &i2c0;
 8         i2c1 = &i2c1;
 9         i2c2 = &i2c2;
10         spi0 = &spi0;
11         spi1 = &spi1;
12         pwm0 = &pwm;
13         mmc0 = &mmc0;
14         mmc2 = &mmc2;
15         ethernet0 = &emac;
16         i2s0 = &i2s0;
17         pcm5102a = &pcm5102a;
18         spidev0 =&spidev0;
19         matrix = &matrix;
20         ir = &ir;
21     };
View Code

     增加 matrix: matrix@0在SPI0 节点下.

 1 &spi0 {
 2     /* needed to avoid dtc warning */
 3     #address-cells = <1>;
 4     #size-cells = <0>;
 5     status = "okay";
 6     pinctrl-names = "default";
 7     pinctrl-0 = <&spi0_pins &spi_cs0_pin>;//<&spi0_pins &spi0_cs_pins>,
 8     cs-gpios =  <&pio 6 9 GPIO_ACTIVE_HIGH>;//<&pio 2 3 GPIO_ACTIVE_HIGH>, <&pio 0 6 GPIO_ACTIVE_HIGH>;
 9     
10     spidev0: spi@0 {
11         compatible = "nanopi,spidev";
12         reg = <0>;
13         status = "disabled";
14         spi-max-frequency = <10000000>;
15     };
16 
17     matrix: matrix@0{
18         compatible =  "fa,st7735s";
19         reg = <0>; 
20         status = "okay";
21 
22         spi-max-frequency = <32000000>;
23         fps = <33>;
24         rotate = <90>;
25         buswidth = <8>;
26 
27         dc-gpios = <&pio  0 17 GPIO_ACTIVE_HIGH>;     /* PA17 */
28         reset-gpios = <&pio 0 3 GPIO_ACTIVE_HIGH>;    /* PA3 */
29         debug = <0x0>;
30     };
31 }

 

2. 在linux 内核目录/drivers/staging/fbtft/fbtft_device.c中    static struct fbtft_device_display displays[] 结构体中增加一个成员

   

{
        .name = "matrix-st7735s",
        .spi = &(struct spi_board_info) {
            .modalias = "fb_st7735s",
            .max_speed_hz = 32000000,
            .bus_num                = 0,
            .chip_select            = 0,        // third spi dev
            .mode = SPI_MODE_0,
//            .controller_data= &spi_config,
            .platform_data = &(struct fbtft_platform_data) {
                .display = {                
                    .buswidth = 8,
                    .backlight = 1,
                },
                .gpios = (const struct fbtft_gpio []) {
                    { "reset", 3 },
                    { "dc" ,  17  },
                    { "led",  1   },
                    { "cs" ,  201   },
                },
            }
 }

4. make menuconfig  中配置,将4.14内核中的staging 中的fbtft部分编译成模块

 

3. 重新make dts , make  uImage ,make modules. 然后分别更新SD卡的内核,dts,以及rootfs,

 

4. 在根据matrix部分内容,重新编译QT后,运行./run.sh /dev/fb-st7735s ,就可以看见和3.5内核一致效果.

 

posted @ 2019-01-02 11:09  jiangcheng88  阅读(1667)  评论(0编辑  收藏  举报