您尚未登录。

#1 Re: 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-05-03 09:39:26

酷酷酷 说:

请问如果移植完是黑屏的怎么办 u-boot使用的默认的配置 没有lcd的

cat /dev/urandom > /dev/fb0
cat /dev/zero > /dev/fb0

使用第一条命令可以让屏幕出现雪花

使用第二条命令可以让屏幕变黑

说明屏幕移植成功

#2 Re: 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-04-30 07:29:36

zzm24 说:

记得spi FIFO只有64字节,楼主可以在刷屏时cat /proc/interrupts看看spi的中断次数不?
看看刷屏中断会不会太频繁了

你看下

# cat /proc/interrupts
           CPU0
 19:       7542     GIC-0  27 Level     arch_timer
 21:          0     GIC-0  50 Level     timer@1c20c00
 22:          0     GIC-0  82 Level     1c02000.dma-controller
 23:      27439     GIC-0  92 Level     sunxi-mmc
 24:          0     GIC-0 103 Level     musb-hdrc.1.auto
 25:          0     GIC-0 104 Level     ehci_hcd:usb1
 26:          2     GIC-0 105 Level     ohci_hcd:usb2
 27:          0     GIC-0  72 Level     1c20400.rtc
 29:       1021     GIC-0 116 Level     sun6i-csi
 34:        392     GIC-0  32 Level     ttyS0
 35:       1724     GIC-0  39 Level     mv64xxx_i2c
 36:    4082175     GIC-0  97 Level     sun6i-spi
IPI0:          0  CPU wakeup interrupts
IPI1:          0  Timer broadcast interrupts
IPI2:          0  Rescheduling interrupts
IPI3:          0  Function call interrupts
IPI4:          0  CPU stop interrupts
IPI5:          0  IRQ work interrupts
IPI6:          0  completion interrupts
Err:          0

#3 Re: NXP i.MX6UL/6ULL » [正点原子i.MX6UL] v4l2+framebuffer预览USB摄像头(三):实时预览 » 2021-04-30 07:22:23

无痕 说:

大佬,根据你的代码(没有动过)在荔枝派上运行,运行报下面的错误
https://whycan.com/files/members/5938/Image.png

另外一个很奇怪的是,我用ffmpeg命令录制视频时并不会报VIDIOC_STREAMON错误。只要用ffmpeg的API和V4L2的API编写程序就会报这样的错误。
请问大佬知道啥原因吗?

摄像头不支持V4L2_PIX_FMT_YUYV格式,换成其它格式支持的格式就可以了

#4 Re: 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-04-29 17:21:44

zzm24 说:

记得spi FIFO只有64字节,楼主可以在刷屏时cat /proc/interrupts看看spi的中断次数不?
看看刷屏中断会不会太频繁了

可以呀,但是我现在只是把屏幕配置好。我是打算把摄像头获取到的图像显示在屏幕上的,但是使用的时候遇到了问题。问题发在下面的帖子上。
https://whycan.com/t_3909.html

或者你告诉怎么刷屏

#5 Re: NXP i.MX6UL/6ULL » [正点原子i.MX6UL] v4l2+framebuffer预览USB摄像头(三):实时预览 » 2021-04-29 14:15:51

大佬,根据你的代码(没有动过)在荔枝派上运行,运行报下面的错误
Image.png

另外一个很奇怪的是,我用ffmpeg命令录制视频时并不会报VIDIOC_STREAMON错误。只要用ffmpeg的API和V4L2的API编写程序就会报这样的错误。
请问大佬知道啥原因吗?

#6 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-28 23:35:49

心情复杂 说:
无痕 说:
心情复杂 说:

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

感谢大佬指点,按照你的指示,在fbtft_request_one_gpio加打印函数调试,发现问题,现在已经解决,屏幕已经点亮。

大佬不敢当 roll 我也是个小菜鸡
啥问题 ? 可以分享上来下,让大家学习下。


问题描述已经发在楼上了哈哈

#7 Re: 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-04-28 21:49:14

接线

SPI屏    zero
3v3    3v3
GND    GND
DC    PWM1
RST    3v3
CS    CS
CLK    CLK
MISO    MISO
MOSI    MOSI
LED   3.3V

#8 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-04-28 21:47:32

无痕
回复: 18

内核版本:linux5.2

参考文章:
      https://whycan.com/t_576.html#p1579
      https://blog.csdn.net/qulang000/article/details/114686525

我在配置此屏幕时遇到问题发的帖子
      https://whycan.com/t_6393.html

感谢大佬们的热心指导!

-----------------------------------------------------------------------------------------------------------------------------
1、配置内核驱动
Device Drivers  --->
    [ * ] Staging drivers  --->
        <*>   Support for small TFT LCD display modules  --->
                <*>   FB driver for the ILI9341 LCD Controller
                <*>   Generic FB driver for TFT LCD displays

2、在sun8i-v3s-licheepi-zero.dts添加设备树节点。注意,reset、dc引脚可以自由选择,只要不跟其它驱动冲突即可。

&i2c0 {
112     status = "disable";
113 
114     ns2009: ns2009@48 {
115         compatible = "nsiway,ns2009";
116         reg = <0x48>;
117     };
118 };


183 &spi0 {
184     status = "okay";
185     spi_lcd@0 {
186         #address-cells = <1>;
187         #size-cells = <1>;
188         rotate = <90>;
189         fps = <30>;
190         buswidth = <8>;
191         bgr;
192         dc-gpios = <&pio 1 5 GPIO_ACTIVE_HIGH>;
193         reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
194         debug = <0x0>;
195         compatible = "ilitek,ili9341";
196         reg = <0>;
197         spi-max-frequency = <48000000>;
198     };
199 };

3、修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_request_one_gpio函数

注意需要在该文件上引入下面头文件,否则编译报错。
#include <linux/of_gpio.h>

      static int fbtft_request_one_gpio(struct fbtft_par *par,
  76                   const char *name, int index,
  77                   struct gpio_desc **gpiop)
  78 {
  79 /*
  80     struct device *dev = par->info->device;
  81     struct device_node *node = dev->of_node;
  82     int ret = 0;
  83 
  84     if (of_find_property(node, name, NULL)) {
  85         *gpiop = devm_gpiod_get_index(dev, dev->driver->name, index,
  86                           GPIOD_OUT_HIGH);
  87         if (IS_ERR(*gpiop)) {
  88             ret = PTR_ERR(*gpiop);
  89             dev_err(dev,
  90                 "Failed to request %s GPIO:%d\n", name, ret);
  91             return ret;
  92         }
  93         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
  94                   __func__, name);
  95     }
  96 
  97     return ret;
  98 */
 100     struct device *dev = par->info->device;
 101     struct device_node *node = dev->of_node;
 102     int gpio, flags, ret = 0;
 103     enum of_gpio_flags of_flags;
 104     char gpio_names[32];
 105 
 106     //sprintf(gpio_names, "%s-gpios", name);
 107     sprintf(gpio_names, "%s", name);
 108     printk("@ gpio_names = %s\n", gpio_names);
 109     if (of_find_property(node, gpio_names, NULL)) {
 110         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
 111         printk ("@ gpio = %d | ENOENT = %d | EPROBE_DEFER = %d  \n", gpio, ENOENT, EPROBE_DEFER);
 112         if (gpio == -ENOENT)
 113             return 0;
 114         if (gpio == -EPROBE_DEFER)
 115             return gpio;
 116         if (gpio < 0) {
 117             dev_err(dev,
 118                 "failed to get '%s' from DT\n", gpio_names);
 119             return gpio;
 120         }
 121 
 122          //active low translates to initially low 
 123         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
 124                             GPIOF_OUT_INIT_HIGH;
 125         ret = devm_gpio_request_one(dev, gpio, flags,
 126                         dev->driver->name);
 127         if (ret) {
 128             dev_err(dev,
 129                 "gpio_request_one('%s'=%d) failed with %d\n",
 130                 gpio_names, gpio, ret);
 131             return ret;
 132         }
 133 
 134         *gpiop = gpio_to_desc(gpio);
 135         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
 136                             __func__, gpio_names, gpio);
 137     }
 138     return ret;
 139 }

4、修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_reset函数

 278 static void fbtft_reset(struct fbtft_par *par)
 279 {
 280     /*
 281     if (!par->gpio.reset)
 282         return;
 283     fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
 284     gpiod_set_value_cansleep(par->gpio.reset, 0);
 285     usleep_range(20, 40);
 286     gpiod_set_value_cansleep(par->gpio.reset, 1);
 287     msleep(120);
 288     */
 289 
 290 
 291     if (!par->gpio.reset)
 292         return;
 293     fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
 294     gpiod_set_value_cansleep(par->gpio.reset, 1);
 295     usleep_range(20, 40);
 296     gpiod_set_value_cansleep(par->gpio.reset, 0);
 297     msleep(120);
 298     gpiod_set_value_cansleep(par->gpio.reset, 1);
 299     msleep(10);
 300 
 301 }

5、修改修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_request_gpios_dt函数里面,reset和dc引脚名称,从reset-gpios 和 dc-gpios 改为reset 和dc。

141 static int fbtft_request_gpios_dt(struct fbtft_par *par)
 142 {
 143     int i;
 144     int ret;
 145 
 146     if (!par->info->device->of_node)
 147         return -EINVAL;
 148 
 149 
 150     ret = fbtft_request_one_gpio(par, "reset", 0, &par->gpio.reset);
 151     if (ret)
 152         return ret;
 153 
 154     ret = fbtft_request_one_gpio(par, "dc", 0, &par->gpio.dc);
 155     if (ret)
 156         return ret;
 157 
 158     ret = fbtft_request_one_gpio(par, "rd-gpios", 0, &par->gpio.rd);
 159     if (ret)
 160         return ret;
 161     ret = fbtft_request_one_gpio(par, "wr-gpios", 0, &par->gpio.wr);
 162     if (ret)
 163         return ret;
 164     ret = fbtft_request_one_gpio(par, "cs-gpios", 0, &par->gpio.cs);
 165     if (ret)
 166         return ret;
 167     ret = fbtft_request_one_gpio(par, "latch-gpios", 0, &par->gpio.latch);
 168     if (ret)
 169         return ret;
 170     for (i = 0; i < 16; i++) {
 171         ret = fbtft_request_one_gpio(par, "db-gpios", i,
 172                          &par->gpio.db[i]);
 173         if (ret)
 174             return ret;
 175         ret = fbtft_request_one_gpio(par, "led-gpios", i,
 176                          &par->gpio.led[i]);
 177         if (ret)
 178             return ret;
 179         ret = fbtft_request_one_gpio(par, "aux-gpios", i,
 180                          &par->gpio.aux[i]);
 181         if (ret)
 182             return ret;
 183     }

6、修改drivers/staging/fbtft/fbtft-bus.c 中的fbtft_write_vmem16_bus8函数,直接替换

 
int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
{
	u16 *vmem16;
	__be16 *txbuf16 = par->txbuf.buf;
	size_t remain;
	size_t to_copy;
	size_t tx_array_size;
	int i;
	int ret = 0;
	size_t startbyte_size = 0;
 
	fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n",
		      __func__, offset, len);
 
	remain = len / 2;
	vmem16 = (u16 *)(par->info->screen_buffer + offset);
 
	if (par->gpio.dc)
	{
		//printk("dc拉高!\n");
		gpiod_set_value(par->gpio.dc, 1);
	}
	/* non buffered write */
	if (!par->txbuf.buf)
		return par->fbtftops.write(par, vmem16, len);
 
	/* buffered write */
	tx_array_size = par->txbuf.len / 2;
 
	if (par->startbyte) {
		txbuf16 = par->txbuf.buf + 1;
		tx_array_size -= 2;
		*(u8 *)(par->txbuf.buf) = par->startbyte | 0x2;
		startbyte_size = 1;
	}
 
	while (remain) {
		to_copy = min(tx_array_size, remain);
		dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n",
			to_copy, remain - to_copy);
 
		for (i = 0; i < to_copy; i++)
			txbuf16[i] = cpu_to_be16(vmem16[i]);
 
		vmem16 = vmem16 + to_copy;
		ret = par->fbtftops.write(par, par->txbuf.buf,
						startbyte_size + to_copy * 2);
		if (ret < 0)
			return ret;
		remain -= to_copy;
	}
 
	return ret;
}

最后编译运行即可,启动log中会出现下面提示

[    1.165809] fbtft_of_value: buswidth = 8
[    1.169779] fbtft_of_value: debug = 0
[    1.173438] fbtft_of_value: rotate = 90
[    1.177267] fbtft_of_value: fps = 30
[    1.215817] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.225921] mmc0: new high speed SDHC card at address 1234
[    1.233279] mmcblk0: mmc0:1234 SA08G 7.21 GiB
[    1.239976]  mmcblk0: p1 p2
[    1.475892] random: fast init done
[    1.510864] Console: switching to colour frame buffer device 40x30
[    1.517762] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=33, spi0.0 at 48 MHz

#9 全志 SOC » linux5.2内核,配置SPI屏幕(ili9341)步骤 » 2021-04-28 21:47:30

无痕
回复: 0

内核版本:linux5.2

参考文章:
      https://whycan.com/t_576.html#p1579
      https://blog.csdn.net/qulang000/article/details/114686525

我在配置此屏幕时遇到问题发的帖子
      https://whycan.com/t_6393.html

感谢大佬们的热心指导!

-----------------------------------------------------------------------------------------------------------------------------
1、配置内核驱动
Device Drivers  --->
    [ * ] Staging drivers  --->
        <*>   Support for small TFT LCD display modules  --->
                <*>   FB driver for the ILI9341 LCD Controller
                <*>   Generic FB driver for TFT LCD displays

2、在sun8i-v3s-licheepi-zero.dts添加设备树节点。注意,reset、dc引脚可以自由选择,只要不跟其它驱动冲突即可。

&i2c0 {
112     status = "disable";
113 
114     ns2009: ns2009@48 {
115         compatible = "nsiway,ns2009";
116         reg = <0x48>;
117     };
118 };


183 &spi0 {
184     status = "okay";
185     spi_lcd@0 {
186         #address-cells = <1>;
187         #size-cells = <1>;
188         rotate = <90>;
189         fps = <30>;
190         buswidth = <8>;
191         bgr;
192         dc-gpios = <&pio 1 5 GPIO_ACTIVE_HIGH>;
193         reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
194         debug = <0x0>;
195         compatible = "ilitek,ili9341";
196         reg = <0>;
197         spi-max-frequency = <48000000>;
198     };
199 };

3、修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_request_one_gpio函数

注意需要在该文件上引入下面头文件,否则编译报错。
#include <linux/of_gpio.h>

      static int fbtft_request_one_gpio(struct fbtft_par *par,
  76                   const char *name, int index,
  77                   struct gpio_desc **gpiop)
  78 {
  79 /*
  80     struct device *dev = par->info->device;
  81     struct device_node *node = dev->of_node;
  82     int ret = 0;
  83 
  84     if (of_find_property(node, name, NULL)) {
  85         *gpiop = devm_gpiod_get_index(dev, dev->driver->name, index,
  86                           GPIOD_OUT_HIGH);
  87         if (IS_ERR(*gpiop)) {
  88             ret = PTR_ERR(*gpiop);
  89             dev_err(dev,
  90                 "Failed to request %s GPIO:%d\n", name, ret);
  91             return ret;
  92         }
  93         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
  94                   __func__, name);
  95     }
  96 
  97     return ret;
  98 */
 100     struct device *dev = par->info->device;
 101     struct device_node *node = dev->of_node;
 102     int gpio, flags, ret = 0;
 103     enum of_gpio_flags of_flags;
 104     char gpio_names[32];
 105 
 106     //sprintf(gpio_names, "%s-gpios", name);
 107     sprintf(gpio_names, "%s", name);
 108     printk("@ gpio_names = %s\n", gpio_names);
 109     if (of_find_property(node, gpio_names, NULL)) {
 110         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
 111         printk ("@ gpio = %d | ENOENT = %d | EPROBE_DEFER = %d  \n", gpio, ENOENT, EPROBE_DEFER);
 112         if (gpio == -ENOENT)
 113             return 0;
 114         if (gpio == -EPROBE_DEFER)
 115             return gpio;
 116         if (gpio < 0) {
 117             dev_err(dev,
 118                 "failed to get '%s' from DT\n", gpio_names);
 119             return gpio;
 120         }
 121 
 122          //active low translates to initially low 
 123         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
 124                             GPIOF_OUT_INIT_HIGH;
 125         ret = devm_gpio_request_one(dev, gpio, flags,
 126                         dev->driver->name);
 127         if (ret) {
 128             dev_err(dev,
 129                 "gpio_request_one('%s'=%d) failed with %d\n",
 130                 gpio_names, gpio, ret);
 131             return ret;
 132         }
 133 
 134         *gpiop = gpio_to_desc(gpio);
 135         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
 136                             __func__, gpio_names, gpio);
 137     }
 138     return ret;
 139 }

4、修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_reset函数

 278 static void fbtft_reset(struct fbtft_par *par)
 279 {
 280     /*
 281     if (!par->gpio.reset)
 282         return;
 283     fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
 284     gpiod_set_value_cansleep(par->gpio.reset, 0);
 285     usleep_range(20, 40);
 286     gpiod_set_value_cansleep(par->gpio.reset, 1);
 287     msleep(120);
 288     */
 289 
 290 
 291     if (!par->gpio.reset)
 292         return;
 293     fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
 294     gpiod_set_value_cansleep(par->gpio.reset, 1);
 295     usleep_range(20, 40);
 296     gpiod_set_value_cansleep(par->gpio.reset, 0);
 297     msleep(120);
 298     gpiod_set_value_cansleep(par->gpio.reset, 1);
 299     msleep(10);
 300 
 301 }

5、修改修改drivers/staging/fbtft/fbtft-core.c文件中的fbtft_request_gpios_dt函数里面,reset和dc引脚名称,从reset-gpios 和 dc-gpios 改为reset 和dc。

141 static int fbtft_request_gpios_dt(struct fbtft_par *par)
 142 {
 143     int i;
 144     int ret;
 145 
 146     if (!par->info->device->of_node)
 147         return -EINVAL;
 148 
 149 
 150     ret = fbtft_request_one_gpio(par, "reset", 0, &par->gpio.reset);
 151     if (ret)
 152         return ret;
 153 
 154     ret = fbtft_request_one_gpio(par, "dc", 0, &par->gpio.dc);
 155     if (ret)
 156         return ret;
 157 
 158     ret = fbtft_request_one_gpio(par, "rd-gpios", 0, &par->gpio.rd);
 159     if (ret)
 160         return ret;
 161     ret = fbtft_request_one_gpio(par, "wr-gpios", 0, &par->gpio.wr);
 162     if (ret)
 163         return ret;
 164     ret = fbtft_request_one_gpio(par, "cs-gpios", 0, &par->gpio.cs);
 165     if (ret)
 166         return ret;
 167     ret = fbtft_request_one_gpio(par, "latch-gpios", 0, &par->gpio.latch);
 168     if (ret)
 169         return ret;
 170     for (i = 0; i < 16; i++) {
 171         ret = fbtft_request_one_gpio(par, "db-gpios", i,
 172                          &par->gpio.db[i]);
 173         if (ret)
 174             return ret;
 175         ret = fbtft_request_one_gpio(par, "led-gpios", i,
 176                          &par->gpio.led[i]);
 177         if (ret)
 178             return ret;
 179         ret = fbtft_request_one_gpio(par, "aux-gpios", i,
 180                          &par->gpio.aux[i]);
 181         if (ret)
 182             return ret;
 183     }

6、修改drivers/staging/fbtft/fbtft-bus.c 中的fbtft_write_vmem16_bus8函数,直接替换

 
int fbtft_write_vmem16_bus8(struct fbtft_par *par, size_t offset, size_t len)
{
	u16 *vmem16;
	__be16 *txbuf16 = par->txbuf.buf;
	size_t remain;
	size_t to_copy;
	size_t tx_array_size;
	int i;
	int ret = 0;
	size_t startbyte_size = 0;
 
	fbtft_par_dbg(DEBUG_WRITE_VMEM, par, "%s(offset=%zu, len=%zu)\n",
		      __func__, offset, len);
 
	remain = len / 2;
	vmem16 = (u16 *)(par->info->screen_buffer + offset);
 
	if (par->gpio.dc)
	{
		//printk("dc拉高!\n");
		gpiod_set_value(par->gpio.dc, 1);
	}
	/* non buffered write */
	if (!par->txbuf.buf)
		return par->fbtftops.write(par, vmem16, len);
 
	/* buffered write */
	tx_array_size = par->txbuf.len / 2;
 
	if (par->startbyte) {
		txbuf16 = par->txbuf.buf + 1;
		tx_array_size -= 2;
		*(u8 *)(par->txbuf.buf) = par->startbyte | 0x2;
		startbyte_size = 1;
	}
 
	while (remain) {
		to_copy = min(tx_array_size, remain);
		dev_dbg(par->info->device, "to_copy=%zu, remain=%zu\n",
			to_copy, remain - to_copy);
 
		for (i = 0; i < to_copy; i++)
			txbuf16[i] = cpu_to_be16(vmem16[i]);
 
		vmem16 = vmem16 + to_copy;
		ret = par->fbtftops.write(par, par->txbuf.buf,
						startbyte_size + to_copy * 2);
		if (ret < 0)
			return ret;
		remain -= to_copy;
	}
 
	return ret;
}

最后编译运行即可,启动log中会出现下面提示

[    1.165809] fbtft_of_value: buswidth = 8
[    1.169779] fbtft_of_value: debug = 0
[    1.173438] fbtft_of_value: rotate = 90
[    1.177267] fbtft_of_value: fps = 30
[    1.215817] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.225921] mmc0: new high speed SDHC card at address 1234
[    1.233279] mmcblk0: mmc0:1234 SA08G 7.21 GiB
[    1.239976]  mmcblk0: p1 p2
[    1.475892] random: fast init done
[    1.510864] Console: switching to colour frame buffer device 40x30
[    1.517762] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=33, spi0.0 at 48 MHz

#10 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-28 21:10:45

昨天调试后报下面这个错误,根据楼上大佬说的是IO没有申请成功,让我在fbtft_request_one_gpio加打印函数看看,我照做了(一定要勤动手),结果真的发现问题。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

fbtft_request_one_gpio加入打印函数后的代码,关键的打印函数在108行。

5 static int fbtft_request_one_gpio(struct fbtft_par *par,
  76                   const char *name, int index,
  77                   struct gpio_desc **gpiop)
  78 {
  79 /*
  80     struct device *dev = par->info->device;
  81     struct device_node *node = dev->of_node;
  82     int ret = 0;
  83 
  84     if (of_find_property(node, name, NULL)) {
  85         *gpiop = devm_gpiod_get_index(dev, dev->driver->name, index,
  86                           GPIOD_OUT_HIGH);
  87         if (IS_ERR(*gpiop)) {
  88             ret = PTR_ERR(*gpiop);
  89             dev_err(dev,
  90                 "Failed to request %s GPIO:%d\n", name, ret);
  91             return ret;
  92         }
  93         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' GPIO\n",
  94                   __func__, name);
  95     }
  96 
  97     return ret;
  98 */
  99 
 100     struct device *dev = par->info->device;
 101     struct device_node *node = dev->of_node;
 102     int gpio, flags, ret = 0;
 103     enum of_gpio_flags of_flags;
 104     char gpio_names[32];

 106     sprintf(gpio_names, "%s-gpios", name);
 108     printk("@ gpio_names = %s\n", gpio_names);
 109     if (of_find_property(node, gpio_names, NULL)) {
 110         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
 111         printk ("@ gpio = %d | ENOENT = %d | EPROBE_DEFER = %d  \n", gpio, ENOENT, EPROBE_DEFER);
 112         if (gpio == -ENOENT)
 113             return 0;
 114         if (gpio == -EPROBE_DEFER)
 115             return gpio;
 116         if (gpio < 0) {
 117             dev_err(dev,
 118                 "failed to get '%s' from DT\n", gpio_names);
 119             return gpio;
 120         }
 121 
 122          //active low translates to initially low 
 123         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
 124                             GPIOF_OUT_INIT_HIGH;
 125         ret = devm_gpio_request_one(dev, gpio, flags,
 126                         dev->driver->name);
 127         if (ret) {
 128             dev_err(dev,
 129                 "gpio_request_one('%s'=%d) failed with %d\n",
 130                 gpio_names, gpio, ret);
 131             return ret;
 132         }
 133 
 134         *gpiop = gpio_to_desc(gpio);
 135         fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
 136                             __func__, gpio_names, gpio);
 137     }
 138     return ret;
 139 }

内核启动后输出的如下内容

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173480] fbtft_of_value: rotate = 90
[    1.177309] fbtft_of_value: fps = 30
[    1.181541] @ gpio_names = reset-gpios-gpios
[    1.185883] @ gpio_names = dc-gpios-gpios
[    1.189960] @ gpio_names = rd-gpios-gpios
[    1.193969] @ gpio_names = wr-gpios-gpios
[    1.197999] @ gpio_names = cs-gpios-gpios
[    1.202004] @ gpio_names = latch-gpios-gpios
[    1.206267] @ gpio_names = db-gpios-gpios
[    1.210286] @ gpio_names = led-gpios-gpios
[    1.214377] @ gpio_names = aux-gpios-gpios
[    1.218478] @ gpio_names = db-gpios-gpios
[    1.222481] @ gpio_names = led-gpios-gpios
[    1.226570] @ gpio_names = aux-gpios-gpios
[    1.230668] @ gpio_names = db-gpios-gpios
[    1.234671] @ gpio_names = led-gpios-gpios
[    1.238770] @ gpio_names = aux-gpios-gpios
[    1.242859] @ gpio_names = db-gpios-gpios
[    1.246861] @ gpio_names = led-gpios-gpios
[    1.250961] @ gpio_names = aux-gpios-gpios
[    1.255049] @ gpio_names = db-gpios-gpios
[    1.259062] @ gpio_names = led-gpios-gpios
[    1.263151] @ gpio_names = aux-gpios-gpios
[    1.267239] @ gpio_names = db-gpios-gpios
[    1.271251] @ gpio_names = led-gpios-gpios
[    1.275340] @ gpio_names = aux-gpios-gpios
[    1.279440] @ gpio_names = db-gpios-gpios
[    1.283443] @ gpio_names = led-gpios-gpios
[    1.287531] @ gpio_names = aux-gpios-gpios
[    1.291630] @ gpio_names = db-gpios-gpios
[    1.295632] @ gpio_names = led-gpios-gpios
[    1.299731] @ gpio_names = aux-gpios-gpios
[    1.303821] @ gpio_names = db-gpios-gpios
[    1.307823] @ gpio_names = led-gpios-gpios
[    1.311921] @ gpio_names = aux-gpios-gpios
[    1.316010] @ gpio_names = db-gpios-gpios
[    1.320022] @ gpio_names = led-gpios-gpios
[    1.324111] @ gpio_names = aux-gpios-gpios
[    1.328210] @ gpio_names = db-gpios-gpios
[    1.332213] @ gpio_names = led-gpios-gpios
[    1.336302] @ gpio_names = aux-gpios-gpios
[    1.340400] @ gpio_names = db-gpios-gpios
[    1.344403] @ gpio_names = led-gpios-gpios
[    1.348502] @ gpio_names = aux-gpios-gpios
[    1.352591] @ gpio_names = db-gpios-gpios
[    1.356593] @ gpio_names = led-gpios-gpios
[    1.360693] @ gpio_names = aux-gpios-gpios
[    1.364781] @ gpio_names = db-gpios-gpios
[    1.368794] @ gpio_names = led-gpios-gpios
[    1.372884] @ gpio_names = aux-gpios-gpios
[    1.376973] @ gpio_names = db-gpios-gpios
[    1.380985] @ gpio_names = led-gpios-gpios
[    1.385065] @ gpio_names = aux-gpios-gpios
[    1.389165] @ gpio_names = db-gpios-gpios
[    1.393167] @ gpio_names = led-gpios-gpios
[    1.397255] @ gpio_names = aux-gpios-gpios
[    1.401356] @ pdata->display.buswidth = 8
[    1.405358] @ par->gpio.dc = 0
[    1.408425] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting. @xkt
[    1.415483] fb_ili9341: probe of spi0.0 failed with error -22

我是输出设备树中IO口的名称,发现reset和dc引脚的名称为:reset-gpios-gpios dc-gpios-gpios。跟设备树上的节点名称不一样,所以真如楼上大佬说的,是引脚没有申请成功!所以只需要把驱动和设备树的引脚名称修改为一致就好了。有多种修改方法。

#11 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-28 21:01:49

心情复杂 说:
无痕 说:

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

感谢大佬指点,按照你的指示,在fbtft_request_one_gpio加打印函数调试,发现问题,现在已经解决,屏幕已经点亮。

#12 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-28 15:38:55

心情复杂 说:
无痕 说:

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

你这不明显是DC申请不到吗? 可以在 fbtft_request_one_gpio 添加点打印函数 看看?

如果dc申请不到的话,不应该是报类似下面的错误吗?

[    1.181547] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2

应该是报[    1.181547] fb_ili9341 spi0.0: Failed to request dc-gpios GPIO:-2

我感觉不是dc申请不到哈。不过晚点,我会按照你说,把那个地方打印出来看看。

#13 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-28 00:17:40

reset GPIO能申请到了,但是dc引脚又出问题了,报下面的错误。

[    1.165851] fbtft_of_value: buswidth = 8
[    1.169818] fbtft_of_value: debug = 0
[    1.173478] fbtft_of_value: rotate = 270
[    1.177395] fbtft_of_value: fps = 10
[    1.181682] @ pdata->display.buswidth = 8
[    1.185755] @ par->gpio.dc = 0
[    1.188882] fb_ili9341 spi0.0: Missing info about 'dc' gpio. Aborting.

追log追到这里,原因是par->gpio.dc = 0导致下面的if条件成立。这问题奇奇怪怪的。

1173     if (pdata->display.buswidth != 9 &&  par->startbyte == 0 &&
1174         !par->gpio.dc) {
1175         printk ("@ pdata->display.buswidth = %d\n", pdata->display.buswidth);
1176         printk ("@ par->gpio.dc = %d\n", par->gpio.dc);
1177         dev_err(par->info->device,
1178             "Missing info about 'dc' gpio. Aborting.\n");
1179         return -EINVAL;
1180     }

另外我今晚跟着教程走,在4.17的内核中能够成功驱动手上的屏幕,所以屏幕是正常的。
注意屏幕上的LED引脚要接3.3V

#14 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-27 22:38:55

无痕 说:
心情复杂 说:

我在5.7改了fbtft-core.c 的 fbtft_request_one_gpio  fbtft_reset 函数 能用 你可以试试

static int fbtft_request_one_gpio(struct fbtft_par *par,
				  const char *name, int index,
				  struct gpio_desc **gpiop)
{
    struct device *dev = par->info->device;
    struct device_node *node = dev->of_node;
    int gpio, flags, ret = 0;
    enum of_gpio_flags of_flags;
	char gpio_names[32];

	sprintf(gpio_names, "%s-gpios", name);
    if (of_find_property(node, gpio_names, NULL)) {
        gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
        if (gpio == -ENOENT)
            return 0;
        if (gpio == -EPROBE_DEFER)
            return gpio;
        if (gpio < 0) {
            dev_err(dev,
                "failed to get '%s' from DT\n", gpio_names);
            return gpio;
        }

         //active low translates to initially low 
        flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                            GPIOF_OUT_INIT_HIGH;
        ret = devm_gpio_request_one(dev, gpio, flags,
                        dev->driver->name);
        if (ret) {
            dev_err(dev,
                "gpio_request_one('%s'=%d) failed with %d\n",
                gpio_names, gpio, ret);
            return ret;
        }

        *gpiop = gpio_to_desc(gpio);
        fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
                            __func__, gpio_names, gpio);
    }
    return ret;
}

static void fbtft_reset(struct fbtft_par *par)
{
	if (!par->gpio.reset)
		return;
	fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	usleep_range(20, 40);
	gpiod_set_value_cansleep(par->gpio.reset, 0);
	msleep(120);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	msleep(10);
}

我按照你贴出来的代码修改后,编译内核的时候报下面的错误,我是不是需要在头文件那里添加什么呀?

  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/staging/fbtft/fbtft-core.o
drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_request_one_gpio’:
drivers/staging/fbtft/fbtft-core.c:102:24: error: storage size of ‘of_flags’ isn’t known
     enum of_gpio_flags of_flags;
                        ^
drivers/staging/fbtft/fbtft-core.c:107:9: error: implicit declaration of function ‘of_get_named_gpio_flags’ [-Werror=implicit-function-declaration]
         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
         ^
drivers/staging/fbtft/fbtft-core.c:119:29: error: ‘OF_GPIO_ACTIVE_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                             ^
drivers/staging/fbtft/fbtft-core.c:119:29: note: each undeclared identifier is reported only once for each function it appears in
drivers/staging/fbtft/fbtft-core.c:119:51: error: ‘GPIOF_OUT_INIT_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                                                   ^
drivers/staging/fbtft/fbtft-core.c:120:29: error: ‘GPIOF_OUT_INIT_HIGH’ undeclared (first use in this function)
                             GPIOF_OUT_INIT_HIGH;
                             ^
drivers/staging/fbtft/fbtft-core.c:121:9: error: implicit declaration of function ‘devm_gpio_request_one’ [-Werror=implicit-function-declaration]
         ret = devm_gpio_request_one(dev, gpio, flags,
         ^
drivers/staging/fbtft/fbtft-core.c:102:24: warning: unused variable ‘of_flags’ [-Wunused-variable]
     enum of_gpio_flags of_flags;
                        ^
cc1: some warnings being treated as errors
scripts/Makefile.build:278: recipe for target 'drivers/staging/fbtft/fbtft-core.o' failed
make[3]: *** [drivers/staging/fbtft/fbtft-core.o] Error 1
scripts/Makefile.build:498: recipe for target 'drivers/staging/fbtft' failed
make[2]: *** [drivers/staging/fbtft] Error 2
make[2]: *** Waiting for unfinished jobs....
scripts/Makefile.build:498: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:1077: recipe for target 'drivers' failed
make: *** [drivers] Error 2

在该文件添加下面这个头文件后,编译就不报错了
#include <linux/of_gpio.h>

#15 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-27 22:27:40

哇酷小二 说:
无痕 说:
哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525

都按这个改了?如果也改了,把of获取reset gpio那一段屏蔽起来,看看能不能获取dc gpio.

屏蔽掉reset引脚后,就报dc-gpio没找到哈哈哈

[    1.165822] fbtft_of_value: buswidth = 8
[    1.169792] fbtft_of_value: debug = 0
[    1.173452] fbtft_of_value: rotate = 270
[    1.177369] fbtft_of_value: fps = 10
[    1.181647] fb_ili9341 spi0.0: Failed to request dc-gpios GPIO:-2
[    1.187902] fb_ili9341: probe of spi0.0 failed with error -2

#16 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-27 22:17:10

心情复杂 说:

我在5.7改了fbtft-core.c 的 fbtft_request_one_gpio  fbtft_reset 函数 能用 你可以试试

static int fbtft_request_one_gpio(struct fbtft_par *par,
				  const char *name, int index,
				  struct gpio_desc **gpiop)
{
    struct device *dev = par->info->device;
    struct device_node *node = dev->of_node;
    int gpio, flags, ret = 0;
    enum of_gpio_flags of_flags;
	char gpio_names[32];

	sprintf(gpio_names, "%s-gpios", name);
    if (of_find_property(node, gpio_names, NULL)) {
        gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
        if (gpio == -ENOENT)
            return 0;
        if (gpio == -EPROBE_DEFER)
            return gpio;
        if (gpio < 0) {
            dev_err(dev,
                "failed to get '%s' from DT\n", gpio_names);
            return gpio;
        }

         //active low translates to initially low 
        flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                            GPIOF_OUT_INIT_HIGH;
        ret = devm_gpio_request_one(dev, gpio, flags,
                        dev->driver->name);
        if (ret) {
            dev_err(dev,
                "gpio_request_one('%s'=%d) failed with %d\n",
                gpio_names, gpio, ret);
            return ret;
        }

        *gpiop = gpio_to_desc(gpio);
        fbtft_par_dbg(DEBUG_REQUEST_GPIOS, par, "%s: '%s' = GPIO%d\n",
                            __func__, gpio_names, gpio);
    }
    return ret;
}

static void fbtft_reset(struct fbtft_par *par)
{
	if (!par->gpio.reset)
		return;
	fbtft_par_dbg(DEBUG_RESET, par, "%s()\n", __func__);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	usleep_range(20, 40);
	gpiod_set_value_cansleep(par->gpio.reset, 0);
	msleep(120);
	gpiod_set_value_cansleep(par->gpio.reset, 1);
	msleep(10);
}

我按照你贴出来的代码修改后,编译内核的时候报下面的错误,我是不是需要在头文件那里添加什么呀?

  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CC      drivers/staging/fbtft/fbtft-core.o
drivers/staging/fbtft/fbtft-core.c: In function ‘fbtft_request_one_gpio’:
drivers/staging/fbtft/fbtft-core.c:102:24: error: storage size of ‘of_flags’ isn’t known
     enum of_gpio_flags of_flags;
                        ^
drivers/staging/fbtft/fbtft-core.c:107:9: error: implicit declaration of function ‘of_get_named_gpio_flags’ [-Werror=implicit-function-declaration]
         gpio = of_get_named_gpio_flags(node, gpio_names, index, &of_flags);
         ^
drivers/staging/fbtft/fbtft-core.c:119:29: error: ‘OF_GPIO_ACTIVE_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                             ^
drivers/staging/fbtft/fbtft-core.c:119:29: note: each undeclared identifier is reported only once for each function it appears in
drivers/staging/fbtft/fbtft-core.c:119:51: error: ‘GPIOF_OUT_INIT_LOW’ undeclared (first use in this function)
         flags = (of_flags & OF_GPIO_ACTIVE_LOW) ? GPIOF_OUT_INIT_LOW :
                                                   ^
drivers/staging/fbtft/fbtft-core.c:120:29: error: ‘GPIOF_OUT_INIT_HIGH’ undeclared (first use in this function)
                             GPIOF_OUT_INIT_HIGH;
                             ^
drivers/staging/fbtft/fbtft-core.c:121:9: error: implicit declaration of function ‘devm_gpio_request_one’ [-Werror=implicit-function-declaration]
         ret = devm_gpio_request_one(dev, gpio, flags,
         ^
drivers/staging/fbtft/fbtft-core.c:102:24: warning: unused variable ‘of_flags’ [-Wunused-variable]
     enum of_gpio_flags of_flags;
                        ^
cc1: some warnings being treated as errors
scripts/Makefile.build:278: recipe for target 'drivers/staging/fbtft/fbtft-core.o' failed
make[3]: *** [drivers/staging/fbtft/fbtft-core.o] Error 1
scripts/Makefile.build:498: recipe for target 'drivers/staging/fbtft' failed
make[2]: *** [drivers/staging/fbtft] Error 2
make[2]: *** Waiting for unfinished jobs....
scripts/Makefile.build:498: recipe for target 'drivers/staging' failed
make[1]: *** [drivers/staging] Error 2
Makefile:1077: recipe for target 'drivers' failed
make: *** [drivers] Error 2

#17 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-26 23:23:20

阿黄 说:

&i2c0 {
    status = "disable";
   
    ns2009: ns2009@48 {
        compatible = "nsiway,ns2009";
        reg = <0x48>;
    };
};

改了之后还是报下面的错误

[    1.165724] fbtft_of_value: buswidth = 8
[    1.169696] fbtft_of_value: debug = 0
[    1.173355] fbtft_of_value: rotate = 270
[    1.177272] fbtft_of_value: fps = 10
[    1.181547] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.188150] fb_ili9341: probe of spi0.0 failed with error -2

#18 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-25 20:55:39

阿黄 说:

贴出你相关的几个完整设备树文件吧

完整的设备树文件如下

sun8i-v3s.dtsi

/*
 * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */

#include <dt-bindings/interrupt-controller/arm-gic.h>
#include <dt-bindings/clock/sun8i-v3s-ccu.h>
#include <dt-bindings/reset/sun8i-v3s-ccu.h>

/ {
	#address-cells = <1>;
	#size-cells = <1>;
	interrupt-parent = <&gic>;

	chosen {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;


		//simplefb_lcd: framebuffer@0 {
		//	compatible = "allwinner,simple-framebuffer",
		//		     "simple-framebuffer";
		//	allwinner,pipeline = "de0-lcd0";
		//	clocks = <&ccu CLK_BUS_TCON0>, <&display_clocks 0>,
		//		 <&display_clocks 6>, <&ccu CLK_TCON0>;
		//	status = "disabled";
		//};
	};

	cpus {
		#address-cells = <1>;
		#size-cells = <0>;

		cpu@0 {
			compatible = "arm,cortex-a7";
			device_type = "cpu";
			reg = <0>;
			clocks = <&ccu CLK_CPU>;
		};
	};

	de: display-engine {
		compatible = "allwinner,sun8i-v3s-display-engine";
		allwinner,pipelines = <&mixer0>;
		status = "disabled";
	};

	timer {
		compatible = "arm,armv7-timer";
		interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
			     <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
	};

	clocks {
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		osc24M: osc24M_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <24000000>;
			clock-output-names = "osc24M";
		};

		osc32k: osc32k_clk {
			#clock-cells = <0>;
			compatible = "fixed-clock";
			clock-frequency = <32768>;
			clock-output-names = "osc32k";
		};
	};

	soc {
		compatible = "simple-bus";
		#address-cells = <1>;
		#size-cells = <1>;
		ranges;

		display_clocks: clock@1000000 {
			compatible = "allwinner,sun8i-v3s-de2-clk";
			reg = <0x01000000 0x100000>;
			clocks = <&ccu CLK_DE>,
				 <&ccu CLK_BUS_DE>;
			clock-names = "mod",
				      "bus";
			resets = <&ccu RST_BUS_DE>;
			#clock-cells = <1>;
			#reset-cells = <1>;
		};

		mixer0: mixer@1100000 {
			compatible = "allwinner,sun8i-v3s-de2-mixer";
			reg = <0x01100000 0x100000>;
			clocks = <&display_clocks 0>,
				 <&display_clocks 6>;
			clock-names = "bus",
				      "mod";
			resets = <&display_clocks 0>;
			assigned-clocks = <&display_clocks 6>;
			assigned-clock-rates = <150000000>;

			ports {
				#address-cells = <1>;
				#size-cells = <0>;

				mixer0_out: port@1 {
					reg = <1>;

					mixer0_out_tcon0: endpoint {
						remote-endpoint = <&tcon0_in_mixer0>;
					};
				};
			};
		};

		syscon: syscon@1c00000 {
			compatible = "allwinner,sun8i-v3s-system-controller",
				"syscon";
			reg = <0x01c00000 0x1000>;
		};

		tcon0: lcd-controller@1c0c000 {
			compatible = "allwinner,sun8i-v3s-tcon";
			reg = <0x01c0c000 0x1000>;
			interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_TCON0>,
				 <&ccu CLK_TCON0>;
			clock-names = "ahb",
				      "tcon-ch0";
			clock-output-names = "tcon-pixel-clock";
			#clock-cells = <0>;
			resets = <&ccu RST_BUS_TCON0>;
			reset-names = "lcd";
			status = "disabled";

			ports {
				#address-cells = <1>;
				#size-cells = <0>;

				tcon0_in: port@0 {
					reg = <0>;

					tcon0_in_mixer0: endpoint {
						remote-endpoint = <&mixer0_out_tcon0>;
					};
				};

				tcon0_out: port@1 {
					#address-cells = <1>;
					#size-cells = <0>;
					reg = <1>;
				};
			};
		};

		dma: dma-controller@01c02000 {
			compatible = "allwinner,sun8i-v3s-dma";
			reg = <0x01c02000 0x1000>;
			interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_DMA>;
			resets = <&ccu RST_BUS_DMA>;
			#dma-cells = <1>;
		};

		mmc0: mmc@1c0f000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c0f000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC0>,
				 <&ccu CLK_MMC0>,
				 <&ccu CLK_MMC0_OUTPUT>,
				 <&ccu CLK_MMC0_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC0>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&mmc0_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mmc1: mmc@1c10000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c10000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC1>,
				 <&ccu CLK_MMC1>,
				 <&ccu CLK_MMC1_OUTPUT>,
				 <&ccu CLK_MMC1_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC1>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
			pinctrl-names = "default";
			pinctrl-0 = <&mmc1_pins>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		mmc2: mmc@1c11000 {
			compatible = "allwinner,sun7i-a20-mmc";
			reg = <0x01c11000 0x1000>;
			clocks = <&ccu CLK_BUS_MMC2>,
				 <&ccu CLK_MMC2>,
				 <&ccu CLK_MMC2_OUTPUT>,
				 <&ccu CLK_MMC2_SAMPLE>;
			clock-names = "ahb",
				      "mmc",
				      "output",
				      "sample";
			resets = <&ccu RST_BUS_MMC2>;
			reset-names = "ahb";
			interrupts = <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		usb_otg: usb@1c19000 {
			compatible = "allwinner,sun8i-h3-musb";
			reg = <0x01c19000 0x0400>;
			clocks = <&ccu CLK_BUS_OTG>;
			resets = <&ccu RST_BUS_OTG>;
			interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "mc";
			phys = <&usbphy 0>;
			phy-names = "usb";
			extcon = <&usbphy 0>;
			status = "disabled";
		};

		usbphy: phy@1c19400 {
			compatible = "allwinner,sun8i-v3s-usb-phy";
			reg = <0x01c19400 0x2c>,
			      <0x01c1a800 0x4>;
			reg-names = "phy_ctrl",
				    "pmu0";
			clocks = <&ccu CLK_USB_PHY0>;
			clock-names = "usb0_phy";
			resets = <&ccu RST_USB_PHY0>;
			reset-names = "usb0_reset";
			status = "disabled";
			#phy-cells = <1>;
		};

		ehci0: usb@01c1a000 {
			compatible = "allwinner,sun8i-v3s-ehci", "generic-ehci";
			reg = <0x01c1a000 0x100>;
			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};

		ohci0: usb@01c1a400 {
			compatible = "allwinner,sun8i-v3s-ohci", "generic-ohci";
			reg = <0x01c1a400 0x100>;
			interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_EHCI0>, <&ccu CLK_BUS_OHCI0>,
				 <&ccu CLK_USB_OHCI0>;
			resets = <&ccu RST_BUS_EHCI0>, <&ccu RST_BUS_OHCI0>;
			status = "disabled";
		};

		ccu: clock@1c20000 {
			compatible = "allwinner,sun8i-v3s-ccu";
			reg = <0x01c20000 0x400>;
			clocks = <&osc24M>, <&osc32k>;
			clock-names = "hosc", "losc";
			#clock-cells = <1>;
			#reset-cells = <1>;
		};

		rtc: rtc@1c20400 {
			compatible = "allwinner,sun6i-a31-rtc";
			reg = <0x01c20400 0x54>;
			interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
		};

		csi1: csi@1cb4000 {
			compatible = "allwinner,sun8i-v3s-csi";
			reg = <0x01cb4000 0x1000>;
			interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_CSI>,
					<&ccu CLK_CSI1_SCLK>,
					<&ccu CLK_DRAM_CSI>;
			clock-names = "bus", "mod", "ram";
			resets = <&ccu RST_BUS_CSI>;
			status = "disabled";
		};

		pio: pinctrl@1c20800 {
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;

			emac_rgmii_pins: emac-rgmii-pins {
				pins = "PD0", "PD1", "PD2", "PD3", "PD4",
				       "PD5", "PD7", "PD8", "PD9", "PD10",
				       "PD12", "PD13", "PD15", "PD16", "PD17";
				function = "emac";
				drive-strength = <40>;
			};

			i2c0_pins: i2c0-pins {
				pins = "PB6", "PB7";
				function = "i2c0";
			};

			pwm0_pins: pwm0 {
				pins = "PB4";
				function = "pwm0";
			};

			uart0_pb_pins: uart0-pb-pins {
				pins = "PB8", "PB9";
				function = "uart0";
			};

			lcd_rgb666_pins_a: lcd-rgb666-pe {
				pins = "PE0", "PE1", "PE2", "PE3", "PE4", "PE5",
				       "PE6", "PE7", "PE8", "PE9", "PE10", "PE11",
				       "PE12", "PE13", "PE14", "PE15", "PE16", "PE17",
				       "PE18", "PE19", "PE23", "PE24";
				function = "lcd";
			};

			mmc0_pins: mmc0-pins {
				pins = "PF0", "PF1", "PF2", "PF3",
				       "PF4", "PF5";
				function = "mmc0";
				drive-strength = <30>;
				bias-pull-up;
			};

			mmc1_pins: mmc1-pins {
				pins = "PG0", "PG1", "PG2", "PG3",
				       "PG4", "PG5";
				function = "mmc1";
				drive-strength = <30>;
				bias-pull-up;
			};

			spi0_pins: spi0-pins {
				pins = "PC0", "PC1", "PC2", "PC3";
				function = "spi0";
			};

			pwm1_pins: pwm1 {
				pins = "PB5";
				function = "pwm1";
			};

		csi1_8bit: csi1-8bit@0 {
       			pins 	 = "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15";
       			bias-disable;
       			function = "csi";
			};

		csi1_clk: csi1-clk@0 {
			pins = "PE0","PE2","PE3";
			bias-disable;
			function = "csi";
		};

		csi1_mclk: csi1-mclk@0 {
			pins = "PE1";
			bias-disable;
			function = "csi";
		};

		i2c1_pins: i2c1 {
			pins = "PE21", "PE22";
			function = "i2c1";
		};




		};


		timer@1c20c00 {
			compatible = "allwinner,sun4i-a10-timer";
			reg = <0x01c20c00 0xa0>;
			interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&osc24M>;
		};

		wdt0: watchdog@1c20ca0 {
			compatible = "allwinner,sun6i-a31-wdt";
			reg = <0x01c20ca0 0x20>;
			interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
		};

		pwm: pwm@1c21400 {
			compatible = "allwinner,sun8i-v3s-pwm",
				     "allwinner,sun7i-a20-pwm";
			reg = <0x01c21400 0x400>;
			clocks = <&osc24M>;
			#pwm-cells = <3>;
			status = "disabled";
		};

		lradc: lradc@1c22800 {
			compatible = "allwinner,sun4i-a10-lradc-keys";
			reg = <0x01c22800 0x400>;
			interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
			status = "disabled";
		};

		codec: codec@01c22c00 {
			#sound-dai-cells = <0>;
			compatible = "allwinner,sun8i-v3s-codec";
			reg = <0x01c22c00 0x400>;
			interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_CODEC>, <&ccu CLK_AC_DIG>;
			clock-names = "apb", "codec";
			resets = <&ccu RST_BUS_CODEC>;
			dmas = <&dma 15>, <&dma 15>;
			dma-names = "rx", "tx";
			allwinner,codec-analog-controls = <&codec_analog>;
			status = "disabled";
		};

		codec_analog: codec-analog@01c23000 {
			compatible = "allwinner,sun8i-v3s-codec-analog";
			reg = <0x01c23000 0x4>;
		};

		uart0: serial@1c28000 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28000 0x400>;
			interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART0>;
			resets = <&ccu RST_BUS_UART0>;
			status = "disabled";
		};

		uart1: serial@1c28400 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28400 0x400>;
			interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART1>;
			resets = <&ccu RST_BUS_UART1>;
			status = "disabled";
		};

		uart2: serial@1c28800 {
			compatible = "snps,dw-apb-uart";
			reg = <0x01c28800 0x400>;
			interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
			reg-shift = <2>;
			reg-io-width = <4>;
			clocks = <&ccu CLK_BUS_UART2>;
			resets = <&ccu RST_BUS_UART2>;
			status = "disabled";
		};

		i2c0: i2c@1c2ac00 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2ac00 0x400>;
			interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C0>;
			resets = <&ccu RST_BUS_I2C0>;
			pinctrl-names = "default";
			pinctrl-0 = <&i2c0_pins>;
			#address-cells = <1>;
			#size-cells = <0>;
		};

		i2c1: i2c@1c2b000 {
			compatible = "allwinner,sun6i-a31-i2c";
			reg = <0x01c2b000 0x400>;
			interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_I2C1>;
			resets = <&ccu RST_BUS_I2C1>;
			status = "disabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		emac: ethernet@1c30000 {
			compatible = "allwinner,sun8i-h3-emac";
			syscon = <&syscon>;
			reg = <0x01c30000 0x10000>;
			interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
			interrupt-names = "macirq";
			resets = <&ccu RST_BUS_EMAC>;
			reset-names = "stmmaceth";
			clocks = <&ccu CLK_BUS_EMAC>;
			clock-names = "stmmaceth";
			status = "disabled";

			mdio: mdio {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "snps,dwmac-mdio";
			};

			mdio-mux {
				compatible = "allwinner,sun8i-h3-mdio-mux";
				#address-cells = <1>;
				#size-cells = <0>;

				mdio-parent-bus = <&mdio>;
				/* Only one MDIO is usable at the time */
				internal_mdio: mdio@1 {
					compatible = "allwinner,sun8i-h3-mdio-internal";
					reg = <1>;
					#address-cells = <1>;
					#size-cells = <0>;

					int_mii_phy: ethernet-phy@1 {
						compatible = "ethernet-phy-ieee802.3-c22";
						reg = <1>;
						clocks = <&ccu CLK_BUS_EPHY>;
						resets = <&ccu RST_BUS_EPHY>;
					};
				};

				external_mdio: mdio@2 {
					reg = <2>;
					#address-cells = <1>;
					#size-cells = <0>;
				};
			};
		};

		spi0: spi@1c68000 {
			compatible = "allwinner,sun8i-h3-spi";
			reg = <0x01c68000 0x1000>;
			interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_SPI0>, <&ccu CLK_SPI0>;
			clock-names = "ahb", "mod";
			pinctrl-names = "default";
			pinctrl-0 = <&spi0_pins>;
			resets = <&ccu RST_BUS_SPI0>;
			status = "enabled";
			#address-cells = <1>;
			#size-cells = <0>;
		};

		gic: interrupt-controller@1c81000 {
			compatible = "arm,gic-400";
			reg = <0x01c81000 0x1000>,
			      <0x01c82000 0x1000>,
			      <0x01c84000 0x2000>,
			      <0x01c86000 0x2000>;
			interrupt-controller;
			#interrupt-cells = <3>;
			interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
		};
	};
};

sun8i-v3s-licheepi-zero.dts:

/*
 * Copyright (C) 2016 Icenowy Zheng <icenowy@aosc.xyz>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */

/dts-v1/;
#include "sun8i-v3s.dtsi"
#include "sunxi-common-regulators.dtsi"

/ {
	model = "Lichee Pi Zero";
	compatible = "licheepi,licheepi-zero", "allwinner,sun8i-v3s";

	aliases {
		serial0 = &uart0;
	};

	chosen {
		stdout-path = "serial0:115200n8";
	};
	
	pir{
		label = "licheepi:blue:usr";
		gpio-pir = <&pio 6 5 GPIO_ACTIVE_HIGH>; /* PG5 */
	};

	door_magnet{
		label = "licheepi:blue:usr";
		gpio-door_magnet = <&pio 6 4 GPIO_ACTIVE_HIGH>; /* PG4 */
	};

	leds {
		compatible = "gpio-leds";

		blue_led {
			label = "licheepi:blue:usr";
			gpios = <&pio 6 1 GPIO_ACTIVE_LOW>; /* PG1 */
		};

		green_led {
			label = "licheepi:green:usr";
			gpios = <&pio 6 0 GPIO_ACTIVE_LOW>; /* PG0 */
			default-state = "on";
		};

		red_led {
			label = "licheepi:red:usr";
			gpios = <&pio 6 2 GPIO_ACTIVE_LOW>; /* PG2 */
		};
	};

	door_key{
		compatible = "door_key";
		key-gpio = <&pio 6 3 GPIO_ACTIVE_LOW>;
	};

	lcd_key{
		compatible = "lcd_key";
		key-gpio = <&pio 6 2 GPIO_ACTIVE_LOW>;
	};
};
&ehci0 {
	status = "okay";
};

&mmc0 {
	broken-cd;
	bus-width = <4>;
	vmmc-supply = <&reg_vcc3v3>;
	status = "okay";
};


&i2c0 {
	status = "okay";
	
	ns2009: ns2009@48 {
		compatible = "nsiway,ns2009";
		reg = <0x48>;
	};
};

&ohci0 {
	status = "okay";
};

&uart0 {
	pinctrl-0 = <&uart0_pb_pins>;
	pinctrl-names = "default";
	status = "okay";
};

&usb_otg {
	dr_mode = "otg";
	status = "okay";
};

&usbphy {
	usb0_id_det-gpios = <&pio 5 6 GPIO_ACTIVE_HIGH>;
	status = "okay";
};

&csi1 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&csi1_clk &csi1_8bit>;

	port {
		csi1_ep: endpoint {
	
		remote-endpoint = <&ov2640_0>;
		hsync-active = <0>;
		vsync-active = <0>;
		bus-width = <10>;
	    	pclk-sample = <1>;
		
		};
	};
 };

&i2c1 {
	pinctrl-0 = <&i2c1_pins>;
	pinctrl-names = "default";
	status = "okay";

	
	ov2640: camera@30 {
		compatible = "ovti,ov2640";
		reg = <0x30>;
		pinctrl-names = "default";
		pinctrl-0 = <&csi1_mclk>;
		clocks = <&ccu CLK_CSI1_MCLK>;
		clock-names = "xvclk";
		assigned-clocks = <&ccu CLK_CSI1_MCLK>;
		assigned-clock-rates = <24000000>;
		
		port {
			ov2640_0: endpoint {
				remote-endpoint = <&csi1_ep>;
				bus-width = <10>;
			};
		};
	};
};

&spi0 {
      status = "okay";
      ili9341@0 {
             compatible = "ilitek,ili9341";
             reg = <0>;
             spi-max-frequency = <15000000>;
             rotate = <270>;
             bgr;
             fps = <10>;
             buswidth = <8>;
             reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
             dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
             debug = <0>;	 
      };
};

#19 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 21:04:08

无痕 说:
哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525


按照里面的操作,修改bug引脚相关代码后,还是报同样的错误。

#20 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 17:46:57

哇酷小二 说:

没理由,只能怀疑你改错了文件,或者dtb没有起作用。

我百度了下那错误,找到这个帖子,但是我看不懂。晕哥可以看下它写的内容
https://blog.csdn.net/qulang000/article/details/114686525

#21 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 17:45:19

哇酷小二 说:

当然要动啊,删除或者改


status = "disabled";


我刚刚在内核4.13.16版本上,按照教程一步步操作,发现没有遇到在5.2版本上的错误。
下面是运行成功的log,但是屏幕并没有亮起来。

[    1.244305] fbtft_of_value: buswidth = 8
[    1.248267] fbtft_of_value: debug = 0
[    1.251925] fbtft_of_value: rotate = 270
[    1.255841] fbtft_of_value: fps = 10
[    1.304740] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.314784] mmc0: new high speed SDHC card at address 1234
[    1.320956] mmcblk0: mmc0:1234 SA08G 7.21 GiB
[    1.327049]  mmcblk0: p1 p2
[    1.609569] Console: switching to colour frame buffer device 40x30
[    1.616454] graphics fb0: fb_ili9341 frame buffer, 320x240, 150 KiB video memory, 16 KiB buffer memory, fps=10, spi32766.0 at 15 MHz

使用下面的命令,并没有发现屏幕出现变化

cat /dev/urandom > /dev/fb0
cat /dev/zero > /dev/fb0

#22 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 17:31:40

哇酷小二 说:

当然要动啊,删除或者改


status = "disabled";

修改后还是报原来的错误。

[    1.176248] fbtft_of_value: buswidth = 8
[    1.180222] fbtft_of_value: debug = 0
[    1.183881] fbtft_of_value: rotate = 270
[    1.187798] fbtft_of_value: fps = 10
[    1.192082] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.198681] fb_ili9341: probe of spi0.0 failed with error -2

下面我重新贴下几个文件的相关代码。

sun8i-v3s-licheepi-zero.dts文件

183 &spi0 {
184       status = "okay";
185       ili9341@0 {
186              compatible = "ilitek,ili9341";
187              reg = <0>;
188              spi-max-frequency = <15000000>;
189              rotate = <270>;
190              bgr;
191              fps = <10>;
192              buswidth = <8>;
193              reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
194              dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
195              debug = <0>;
196       };
197 };

sun8i-v3s.dtsi文件

521         i2c0: i2c@1c2ac00 {
522             compatible = "allwinner,sun6i-a31-i2c";
523             reg = <0x01c2ac00 0x400>;
524             interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
525             clocks = <&ccu CLK_BUS_I2C0>;
526             resets = <&ccu RST_BUS_I2C0>;
527             pinctrl-names = "default";
528             pinctrl-0 = <&i2c0_pins>;
529             status = "eabled";
530             #address-cells = <1>;
531             #size-cells = <0>;
532         };

#23 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 15:58:35

哇酷小二 说:

你的i2c0使能了吗?也是用pb7?

没动过i2c0的设备树代码。

在sun8i-v3s-licheepi-zero.dts中有i2c0这个节点

111 &i2c0 {
112     status = "okay";
113     ns2009: ns2009@48 {
114         compatible = "nsiway,ns2009";
115         reg = <0x48>;
116     };
117 };

#24 Re: 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 15:42:22

哇酷小二 说:

获取dtb 里面 reset 引脚错误

linux错误代码: https://mariadb.com/kb/en/operating-system-error-codes/

sun8i-v3.dtsi下的pio节点

		pio: pinctrl@1c20800 {
			compatible = "allwinner,sun8i-v3s-pinctrl";
			reg = <0x01c20800 0x400>;
			interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
				     <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
			clocks = <&ccu CLK_BUS_PIO>, <&osc24M>, <&osc32k>;
			clock-names = "apb", "hosc", "losc";
			gpio-controller;
			#gpio-cells = <3>;
			interrupt-controller;
			#interrupt-cells = <3>;

			emac_rgmii_pins: emac-rgmii-pins {
				pins = "PD0", "PD1", "PD2", "PD3", "PD4",
				       "PD5", "PD7", "PD8", "PD9", "PD10",
				       "PD12", "PD13", "PD15", "PD16", "PD17";
				function = "emac";
				drive-strength = <40>;
			};

			i2c0_pins: i2c0-pins {
				pins = "PB6", "PB7";
				function = "i2c0";
			};

			pwm0_pins: pwm0 {
				pins = "PB4";
				function = "pwm0";
			};

			uart0_pb_pins: uart0-pb-pins {
				pins = "PB8", "PB9";
				function = "uart0";
			};

			lcd_rgb666_pins_a: lcd-rgb666-pe {
				pins = "PE0", "PE1", "PE2", "PE3", "PE4", "PE5",
				       "PE6", "PE7", "PE8", "PE9", "PE10", "PE11",
				       "PE12", "PE13", "PE14", "PE15", "PE16", "PE17",
				       "PE18", "PE19", "PE23", "PE24";
				function = "lcd";
			};

			mmc0_pins: mmc0-pins {
				pins = "PF0", "PF1", "PF2", "PF3",
				       "PF4", "PF5";
				function = "mmc0";
				drive-strength = <30>;
				bias-pull-up;
			};

			mmc1_pins: mmc1-pins {
				pins = "PG0", "PG1", "PG2", "PG3",
				       "PG4", "PG5";
				function = "mmc1";
				drive-strength = <30>;
				bias-pull-up;
			};

			spi0_pins: spi0-pins {
				pins = "PC0", "PC1", "PC2", "PC3";
				function = "spi0";
			};

			pwm1_pins: pwm1 {
				pins = "PB5";
				function = "pwm1";
			};

		csi1_8bit: csi1-8bit@0 {
       			pins 	 = "PE6","PE7","PE8","PE9","PE10","PE11","PE12","PE13","PE14","PE15";
       			bias-disable;
       			function = "csi";
			};

		csi1_clk: csi1-clk@0 {
			pins = "PE0","PE2","PE3";
			bias-disable;
			function = "csi";
		};

		csi1_mclk: csi1-mclk@0 {
			pins = "PE1";
			bias-disable;
			function = "csi";
		};

		i2c1_pins: i2c1 {
			pins = "PE21", "PE22";
			function = "i2c1";
		};

		};

sun8i-v3s-licheepi-zero.dts下的spi节点

163 &spi0 {
164      status = "okay";
165      ili9341@0 {
166             compatible = "ilitek,ili9341";
167             reg = <0>;
168             spi-max-frequency = <15000000>;
169             rotate = <270>;
170             bgr;
171             fps = <10>;
172             buswidth = <8>;
173             reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>;
174             dc-gpios = <&pio 1 5 GPIO_ACTIVE_LOW>;
175            debug = <0>;
176       };
177 };

173 reset-gpios = <&pio 1 7 GPIO_ACTIVE_LOW>; 指的是PB7,是i2c0的SDA引脚,讲道理是可以获取到这个引脚的。配置教程上面也说了,SPI屏幕的复位引脚可以直接接电源的,所以不接PB7也可以。所以我不清楚为什么会获取dtb里面 reset 引脚发生错误

#25 全志 SOC » 5.2内核,启动SPI屏幕(ili9341)失败 » 2021-04-24 15:18:20

无痕
回复: 51

内核版本:zero-5.2.y

按照晕哥写的教程,一步一步操作。
https://whycan.com/t_576.html#p1579

内核启动log中显示如下:

[    1.052704] fbtft_of_value: buswidth = 8
[    1.056628] fbtft_of_value: debug = 0
[    1.060326] fbtft_of_value: rotate = 270
[    1.064244] fbtft_of_value: fps = 10
[    1.068691] fb_ili9341 spi0.0: Failed to request reset-gpios GPIO:-2
[    1.075218] fb_ili9341: probe of spi0.0 failed with error -2

是不是zero-5.2.y的内核太新了,改了什么东西,导致按照上面的流程操作后,启动失败。

#26 全志 SOC » ov2640在荔枝派上使用ffmpeg录制视频报以下错误,在虚拟机上运行则不会。 » 2021-04-21 15:21:51

无痕
回复: 0

内核:zero.5.2-y

运行命令:ffmpeg -S 10 -f video4linux2 -s 800x600 -r 30 -i /dev/video0 test.avi

报错log:

[  570.389211] ffmpeg: page allocation failure: order:8, mode:0xcc0(GFP_KERNEL), nodemask=(null)
[  570.397874] CPU: 0 PID: 216 Comm: ffmpeg Not tainted 5.2.0-licheepi-zero #6
[  570.404829] Hardware name: Allwinner sun8i Family
[  570.409563] [<c010ec34>] (unwind_backtrace) from [<c010b6cc>] (show_stack+0x10/0x14)
[  570.417311] [<c010b6cc>] (show_stack) from [<c06cc540>] (dump_stack+0x94/0xa8)
[  570.424536] [<c06cc540>] (dump_stack) from [<c01fa62c>] (warn_alloc+0xc8/0x16c)
[  570.431844] [<c01fa62c>] (warn_alloc) from [<c01fb1bc>] (__alloc_pages_nodemask+0xa4c/0xd50)
[  570.440276] [<c01fb1bc>] (__alloc_pages_nodemask) from [<c0113eb4>] (__dma_alloc_buffer+0x38/0x184)
[  570.449314] [<c0113eb4>] (__dma_alloc_buffer) from [<c011468c>] (remap_allocator_alloc+0x34/0x8c)
[  570.458177] [<c011468c>] (remap_allocator_alloc) from [<c01141ac>] (__dma_alloc+0x180/0x260)
[  570.466605] [<c01141ac>] (__dma_alloc) from [<c0114308>] (arm_dma_alloc+0x40/0x48)
[  570.474169] [<c0114308>] (arm_dma_alloc) from [<c017bcc8>] (dma_alloc_attrs+0x100/0x110)
[  570.482259] [<c017bcc8>] (dma_alloc_attrs) from [<c053853c>] (vb2_dc_alloc+0x64/0x104)
[  570.490178] [<c053853c>] (vb2_dc_alloc) from [<c0531dec>] (__vb2_queue_alloc+0x184/0x404)
[  570.498353] [<c0531dec>] (__vb2_queue_alloc) from [<c05325a4>] (vb2_core_reqbufs+0x2ac/0x404)
[  570.506872] [<c05325a4>] (vb2_core_reqbufs) from [<c0535d9c>] (vb2_ioctl_reqbufs+0x74/0x9c)
[  570.515222] [<c0535d9c>] (vb2_ioctl_reqbufs) from [<c051038c>] (__video_do_ioctl+0x24c/0x448)
[  570.523743] [<c051038c>] (__video_do_ioctl) from [<c0512334>] (video_usercopy+0x24c/0x514)
[  570.532004] [<c0512334>] (video_usercopy) from [<c0226f6c>] (do_vfs_ioctl+0xac/0x8f4)
[  570.539830] [<c0226f6c>] (do_vfs_ioctl) from [<c02277e8>] (ksys_ioctl+0x34/0x5c)
[  570.547222] [<c02277e8>] (ksys_ioctl) from [<c0101000>] (ret_fast_syscall+0x0/0x54)
[  570.554867] Exception stack(0xc12f9fa8 to 0xc12f9ff0)
[  570.559916] 9fa0:                   00055250 00055a80 00000003 c0145608 bed4e210 b58961b1
[  570.568084] 9fc0: 00055250 00055a80 00000000 00000036 00055a90 bed4e2a8 32315559 00055a80
[  570.576249] 9fe0: 00000001 bed4dedc b6ef2540 b58961b8
[  570.581423] Mem-Info:
[  570.583717] active_anon:370 inactive_anon:3 isolated_anon:0
[  570.583717]  active_file:2138 inactive_file:846 isolated_file:32
[  570.583717]  unevictable:0 dirty:1 writeback:126 unstable:0
[  570.583717]  slab_reclaimable:245 slab_unreclaimable:1141
[  570.583717]  mapped:1356 shmem:20 pagetables:46 bounce:0
[  570.583717]  free:7096 free_pcp:0 free_cma:0
[  570.615763] Node 0 active_anon:1480kB inactive_anon:12kB active_file:8552kB inactive_file:3384kB unevictable:0kB isolated(anon):0kB isolated(file):128kB mapped:5424kB dirty:4kB writeback:504kB shmem:80kB writeback_tmp:0kB unstable:0kB all_unreclaimable? no
[  570.638434] Normal free:28384kB min:924kB low:1152kB high:1380kB active_anon:1480kB inactive_anon:12kB active_file:8552kB inactive_file:3384kB unevictable:0kB writepending:512kB present:64036kB managed:54572kB mlocked:0kB kernel_stack:312kB pagetables:184kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB
[  570.665593] lowmem_reserve[]: 0 0 0
[  570.669093] Normal: 168*4kB (M) 80*8kB (UM) 30*16kB (UM) 73*32kB (UM) 63*64kB (UM) 28*128kB (UM) 27*256kB (UM) 19*512kB (U) 0*1024kB 0*2048kB 0*4096kB = 28384kB
[  570.683451] 3038 total pagecache pages
[  570.687196] 0 pages in swap cache
[  570.690517] Swap cache stats: add 0, delete 0, find 0/0
[  570.695732] Free swap  = 0kB
[  570.698619] Total swap = 0kB
[  570.701495] 16009 pages RAM
[  570.704284] 0 pages HighMem/MovableOnly
[  570.708121] 2366 pages reserved
[  570.711278] sun6i-csi 1cb4000.csi: dma_alloc_coherent of size 720896 failed

请问为什么会出现这个错误:ffmpeg: page allocation failure: order:8, mode:0xcc0(GFP_KERNEL), nodemask=(null)
有什么办法可以解决呢?

#28 Re: 全志 SOC » 编解码引擎 CedarX for Mainline Linux v5.4 » 2021-02-28 00:52:43

你好!
根据github上的指导移植驱动,并且在/dev目录下找到cedar_dev和ion节点。

并且完成了下面的操作:

Allwinner CedarX userspace library
Based on lindenis-v536 SDK

Add package to buildroot system
Copy dir "buildroot-package/libcedarc" to "buildroot/package"

Modify "buildroot/package/Config.in", add package source to any menu you want

source "package/libcedarc/Config.in"
Demo

menu "Hardware handling"
source "package/libcedarc/Config.in" # <--Add
source "package/acsccid/Config.in"
source "package/bcm2835/Config.in"


Build
make menuconfig
Select "libcedarc" package
make
Work with ffmpeg (tested with buildroot 2020.02.1)
make menuconfig
goto "> Target packages > Audio and video applications > ffmpeg"
set "(--enable-omx) Additional parameters for ./configure"
recompile ffmpeg

以上操作完之后,要如何使用h264硬编码的功能呢?请大佬指点!

#30 Re: 全志 SOC » 围观蓝莓派(Blueberry-PI)之后, 一定要试一试 主线 Linux DVP CSI 摄像头 » 2021-02-07 01:06:37

晕哥!!设备树的配置方法连接失效了!!麻烦再发一下

#31 Re: 全志 SOC » 全志V3s采用UDP视频传输H264效果很好 » 2021-02-04 21:37:42

raspberryman 说:
无痕 说:

请问在linux下如何使用全志V3S的硬编码(x.264)功能?

V3s使用gstreamer的插件openmax调用cedar硬解码,荔枝派zero测试通过
http://whycan.com/t_5398.html
(出处:哇酷开发者社区)

这是主线linux的

谢谢!我看看

#32 Re: 全志 SOC » V3S挖坑EC20 » 2021-02-04 21:18:39

你好,你的EC20模块是用串口跟V3S连接还是用UDB OTG和V3S连接呢?

#33 Re: 全志 SOC » 全志V3s采用UDP视频传输H264效果很好 » 2021-02-04 16:25:09

请问在linux下如何使用全志V3S的硬编码(x.264)功能?

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn