diff --git a/bsp/.gitignore b/bsp/.gitignore new file mode 100644 index 0000000000..3907c6a98c --- /dev/null +++ b/bsp/.gitignore @@ -0,0 +1,17 @@ +*.swp +tags +*.cpio.gz +*.o.* +*.o +*.cmd.* +*.mod +*.mod.* +*.order +*.order.cmd +Module.symvers +.*Module.symvers.* +*.ko +*.ko.cmd +*.elf +.vscode* +sunxi-autogen.h diff --git a/bsp/configs/linux-5.15/arm64_min_defconfig b/bsp/configs/linux-5.15/arm64_min_defconfig index 7c667a86ce..76b802da73 100644 --- a/bsp/configs/linux-5.15/arm64_min_defconfig +++ b/bsp/configs/linux-5.15/arm64_min_defconfig @@ -17,7 +17,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/rootfs_arm64.cpio.gz" +CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/ramfs_aarch64.cpio.gz" # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set diff --git a/bsp/configs/linux-5.15/sun55iw3p1_min_defconfig b/bsp/configs/linux-5.15/sun55iw3p1_min_defconfig index 3cd6b27fd6..6fbc161cff 100644 --- a/bsp/configs/linux-5.15/sun55iw3p1_min_defconfig +++ b/bsp/configs/linux-5.15/sun55iw3p1_min_defconfig @@ -22,7 +22,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/rootfs_arm64.cpio.gz" +CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/ramfs_aarch64.cpio.gz" # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set diff --git a/bsp/configs/linux-5.15/sun55iw3p1_standby_min_defconfig b/bsp/configs/linux-5.15/sun55iw3p1_standby_min_defconfig index 19a3025555..7e3bbfa781 100644 --- a/bsp/configs/linux-5.15/sun55iw3p1_standby_min_defconfig +++ b/bsp/configs/linux-5.15/sun55iw3p1_standby_min_defconfig @@ -40,7 +40,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/rootfs_arm64.cpio.gz" +CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/ramfs_aarch64.cpio.gz" # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set diff --git a/bsp/configs/linux-6.1/sun55iw3p1_min_defconfig b/bsp/configs/linux-6.1/sun55iw3p1_min_defconfig index 53e3f3c863..39d943cdad 100644 --- a/bsp/configs/linux-6.1/sun55iw3p1_min_defconfig +++ b/bsp/configs/linux-6.1/sun55iw3p1_min_defconfig @@ -19,7 +19,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/rootfs_arm64.cpio.gz" +CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/ramfs_aarch64.cpio.gz" # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set diff --git a/bsp/configs/linux-6.6/sun55iw3p1_min_defconfig b/bsp/configs/linux-6.6/sun55iw3p1_min_defconfig index 9615dd842d..11691d4aa5 100644 --- a/bsp/configs/linux-6.6/sun55iw3p1_min_defconfig +++ b/bsp/configs/linux-6.6/sun55iw3p1_min_defconfig @@ -16,7 +16,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y -CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/rootfs_arm64.cpio.gz" +CONFIG_INITRAMFS_SOURCE="./bsp/ramfs/ramfs_aarch64.cpio.gz" # CONFIG_RD_BZIP2 is not set # CONFIG_RD_LZMA is not set # CONFIG_RD_XZ is not set diff --git a/bsp/drivers/dma/sunxi-dma.c b/bsp/drivers/dma/sunxi-dma.c index 1d2c8406be..f3e8c058cb 100644 --- a/bsp/drivers/dma/sunxi-dma.c +++ b/bsp/drivers/dma/sunxi-dma.c @@ -22,6 +22,8 @@ #include #include #include "sunxi-dma.h" + +#define SUNXI_DMA_MODULE_VERSION "1.0.12" /* * Common registers */ @@ -1937,7 +1939,8 @@ static int sun6i_dma_probe(struct platform_device *pdev) writel(DMA_IRQ_MCU_DISABLE_MASK, sdc->base + DMA_IRQ_MCU_EN_REG); } - dev_info(&pdev->dev, "sunxi dma probed\n"); + dev_info(&pdev->dev, "sunxi dma probed, driver version: %s\n", + SUNXI_DMA_MODULE_VERSION); return 0; @@ -2006,4 +2009,4 @@ MODULE_DESCRIPTION("Allwinner A31 DMA Controller Driver"); MODULE_AUTHOR("Sugar "); MODULE_AUTHOR("Maxime Ripard "); MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0.11"); +MODULE_VERSION(SUNXI_DMA_MODULE_VERSION); diff --git a/bsp/drivers/drm/Kconfig b/bsp/drivers/drm/Kconfig index fb7953de14..3ea1d9414d 100644 --- a/bsp/drivers/drm/Kconfig +++ b/bsp/drivers/drm/Kconfig @@ -7,6 +7,10 @@ config AW_DRM depends on DRM && AW_BSP select DRM_KMS_HELPER select DRM_KMS_CMA_HELPER + select DRM_KMS_DMA_HELPER + select DRM_GEM_DMA_HELPER + select DRM_DISPLAY_HELPER + select VIDEOMODE_HELPERS default n config AW_DRM_DE @@ -30,6 +34,13 @@ config AW_DRM_TCON_TOP help If you want use TCON TOP, select it. +config AW_DRM_FBDEV_BOOTLOGO + bool "Support Bootlogo Output from uboot" + depends on AW_DRM_LCD + default n + help + If you want bootlogo output for drm driver, select it. + menuconfig AW_DRM_LCD bool "Support LCD Output" depends on AW_DRM @@ -45,13 +56,6 @@ config AW_DRM_LCD_DSI help If you want lcd-dsi output for drm driver, select it. -config AW_DRM_FBDEV_BOOTLOGO - bool "Support Bootlogo Output from uboot" - depends on AW_DRM_LCD - default n - help - If you want bootlogo output for drm driver, select it. - config AW_DRM_LCD_DSI_COMBO_PHY bool "Support LCD-DSI COMBO PHY" depends on AW_DRM_LCD_DSI @@ -62,6 +66,8 @@ config AW_DRM_LCD_DSI_COMBO_PHY menuconfig AW_DRM_HDMI_TX tristate "Support Hdmi Output" depends on AW_DRM + select DRM_DISPLAY_HDCP_HELPER + select DRM_DISPLAY_HDMI_HELPER default y help If you want hdmi output for drm driver, select it. diff --git a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_avp.c b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_avp.c index 88d4c2a37f..a33e717bb6 100644 --- a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_avp.c +++ b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_avp.c @@ -9,7 +9,14 @@ * warranty of any kind, whether express or implied. ******************************************************************************/ #include +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) #include +#else +#include +#include +#endif #include "dw_mc.h" #include "dw_fc.h" @@ -119,31 +126,25 @@ static struct dw_video_s *dw_get_video(void) int dw_video_timing_print(void) { struct dw_video_s *video = dw_get_video(); - char buf[256]; - int n = 0; if (!video) { hdmi_err("check point video is null\n"); - goto ret_failed; + return -1; } - n += sprintf(buf + n, "[video timing]\n"); - n += sprintf(buf + n, " - pixel clock: %dKHz, repeat: %d, %s, ratio: %dx%d\n", + hdmi_inf("[timing info]\n"); + hdmi_inf(" - pixel clock: %dKHz, repeat: %d, %s, ratio: %dx%d\n", video->mDtd.mPixelClock, video->mDtd.mPixelRepetitionInput, - video->mDtd.mInterlaced ? "Interlaced" : "Progressive", + video->mDtd.mInterlaced ? "interlaced" : "progressive", video->mDtd.mHImageSize, video->mDtd.mVImageSize); - n += sprintf(buf + n, " - hactive: %d, hblank: %d, hfront: %d, hsync: %d, hpol: %d\n", + hdmi_inf(" - hactive: %d, hblank: %d, hfront: %d, hsync: %d, hpol: %d\n", video->mDtd.mHActive, video->mDtd.mHBlanking, video->mDtd.mHSyncOffset, video->mDtd.mHSyncPulseWidth, video->mDtd.mHSyncPolarity); - n += sprintf(buf + n, " - vactive: %d, vblank: %d, vfront: %d, vsync: %d, vpol: %d\n", + hdmi_inf(" - vactive: %d, vblank: %d, vfront: %d, vsync: %d, vpol: %d\n", video->mDtd.mVActive, video->mDtd.mVBlanking, video->mDtd.mVSyncOffset, video->mDtd.mVSyncPulseWidth, video->mDtd.mVSyncPolarity); - printk(KERN_CONT "%s\n", buf); - return 0; -ret_failed: - return -1; } int dw_video_dtd_filling(dw_dtd_t *dtd, u32 rate) @@ -1461,10 +1462,17 @@ int dw_avp_config(void) hdmi_err("sink unsupport config scramble and 1/40 ratio\n"); return -1; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) /* scdc set enable scramble */ drm_scdc_set_scrambling(hdmi->i2cm_dev.adapter, 0x1); /* scdc set tmds clock ratio 1/40 */ drm_scdc_set_high_tmds_clock_ratio(hdmi->i2cm_dev.adapter, 0x1); +#else + /* scdc set enable scramble */ + drm_scdc_set_scrambling(hdmi->connect, 0x1); + /* scdc set tmds clock ratio 1/40 */ + drm_scdc_set_high_tmds_clock_ratio(hdmi->connect, 0x1); +#endif /* tmds software reset */ dw_mc_reset_tmds_clock(0x1); /* enable scramble */ @@ -1475,10 +1483,17 @@ int dw_avp_config(void) dw_fc_video_set_scramble(0x0); /* tmds software reset */ dw_mc_reset_tmds_clock(0x1); - /* scdc set disable scramble */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) + /* scdc set enable scramble */ drm_scdc_set_scrambling(hdmi->i2cm_dev.adapter, 0x0); - /* scdc set tmds clock ratio 1/10 */ + /* scdc set tmds clock ratio 1/40 */ drm_scdc_set_high_tmds_clock_ratio(hdmi->i2cm_dev.adapter, 0x0); +#else + /* scdc set disable scramble */ + drm_scdc_set_scrambling(hdmi->connect, 0x0); + /* scdc set tmds clock ratio 1/10 */ + drm_scdc_set_high_tmds_clock_ratio(hdmi->connect, 0x0); +#endif dw_fc_video_set_hdcp_keepout(0x0); } diff --git a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_dev.h b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_dev.h index 56815f7931..587da543ea 100644 --- a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_dev.h +++ b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_dev.h @@ -609,6 +609,7 @@ struct dw_phy_ops_s { * @short Main structures to instantiate the driver */ struct dw_hdmi_dev_s { + struct drm_connector *connect; struct device *dev; uintptr_t addr; @@ -777,6 +778,15 @@ void dw_write_mask(u32 addr, u8 mask, u8 data); DRM_INFO("sunxi-hdmi: [cec]: "fmt, ##args); \ } while (0) +#ifdef phy_log +#undef phy_log +#endif +#define phy_log(fmt, args...) \ + do { \ + if (dw_dev_check_loglevel(DW_LOG_INDEX_PHY)) \ + DRM_INFO("sunxi-hdmi: [phy]: "fmt, ##args); \ + } while (0) + #ifdef hdcp_log #undef hdcp_log #endif diff --git a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_i2cm.c b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_i2cm.c index 4334e60080..08dd4f8d7f 100644 --- a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_i2cm.c +++ b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/dw_i2cm.c @@ -177,7 +177,6 @@ int _dw_i2cm_write(unsigned char *buf, unsigned int length) int dw_i2cm_xfer(struct i2c_msg *msgs, int num) { - u8 addr = msgs[0].addr; int i = 0, ret = 0; diff --git a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/phy_inno.c b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/phy_inno.c index c21c8e3306..d9d3b867c1 100644 --- a/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/phy_inno.c +++ b/bsp/drivers/drm/sunxi_device/hardware/lowlevel_hdmi20/phy_inno.c @@ -60,92 +60,51 @@ struct inno_phy_electric_s { struct inno_phy_dev_s { int version; + int elec_size; + struct inno_phy_electric_s *elec_data; }; static struct inno_phy_dev_s phy_dev; static volatile struct __inno_phy_reg_t *phy_base; -static struct inno_phy_electric_s inno_phy_electric_table0[] = { - { 25000, 165000, 0x02060708, 0x1c1c1c1c, 0x00000000, 0x05050500}, - {165000, 340000, 0x02060708, 0x1c1c1c1c, 0x00000000, 0x05050500}, +/** + * @desc: default inno phy table. applicable to A/T527 A or B Board + */ +static struct inno_phy_electric_s phy_elec_default[] = { + { 25000, 165000, 0x00020202, 0x1c1c1c1c, 0x00000000, 0x00000000}, + {165000, 340000, 0x02060708, 0x1c1c1c1c, 0x00000000, 0x03030300}, {340000, 600000, 0x020f0f0f, 0x1c1c1c1c, 0x00000000, 0x03030300}, - {0, 0, 0, 0, 0}, -}; - -static struct inno_phy_electric_s inno_phy_electric_table1[] = { - { 25000, 165000, 0x01000102, 0x1c1c1c1c, 0x00000000, 0x02020200}, - {165000, 340000, 0x01040506, 0x1c1c1c1c, 0x00000000, 0x03030300}, - {340000, 600000, 0x010f0f0f, 0x1c1c1c1c, 0x00000000, 0x00000000}, -}; - -static struct inno_phy_electric_s inno_phy_electric_table2[] = { - { 25000, 165000, 0x01010102, 0x1c1c1c1c, 0x00000000, 0x00000000}, - {165000, 340000, 0x01020304, 0x1c1c1c1c, 0x00000000, 0x05050500}, - {340000, 600000, 0x010e0f0f, 0x1c1c1c1c, 0x00000000, 0x00000000}, -}; - -/* inno_phy clock: unit:kHZ */ -static struct inno_phy_mpll_s inno_phy_mpll_table0[] = { - {25200, 0x00002a01, 0x00010103, 0x00000103, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {27000, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {33750, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {37125, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, - {46406, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, - {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {92813, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {119000, 0x00007701, 0x00010102, 0x00000603, 0x00000202, 0x03555515, 0x030a0000, 0x00}, - {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {185625, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {234000, 0x00004E01, 0x00000101, 0x00000400, 0x00000101, 0x030000C0, 0x030a0001, 0x00}, - {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, - {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, - {312250, 0x00006801, 0x00000001, 0x00000403, 0x00000101, 0x00555515, 0x030a0000, 0x00}, - {371250, 0x00007B01, 0x00000201, 0x00000103, 0x00000101, 0x000000C0, 0x000a0002, 0x00}, - {594000, 0x00006301, 0x00000200, 0x00000100, 0x00000101, 0x03000000, 0x00140004, 0x00}, - {594000, 0x00006301, 0x00000200, 0x00000100, 0x00000101, 0x03000000, 0x00140004, 0x00}, - {0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00} -}; - -static struct inno_phy_mpll_s inno_phy_mpll_table1[] = { - {25200, 0x00002a01, 0x00010103, 0x00000103, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {27000, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {33750, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, - {37125, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, - {46406, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, - {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {92813, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {119000, 0x00007701, 0x00010102, 0x00000603, 0x00000202, 0x03555515, 0x030a0000, 0x00}, - {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {185625, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {234000, 0x00004E01, 0x00000101, 0x00000400, 0x00000101, 0x030000C0, 0x030a0001, 0x00}, - {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, - {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, - {312250, 0x00006801, 0x00000001, 0x00000403, 0x00000101, 0x00555515, 0x030a0000, 0x00}, - {371250, 0x00007B01, 0x00000201, 0x00000103, 0x00000101, 0x000000C0, 0x000a0002, 0x00}, - {594000, 0x00006301, 0x00000200, 0x00000100, 0x00000101, 0x03000000, 0x00140004, 0x00}, - {594000, 0x00006301, 0x00000200, 0x00000100, 0x00000101, 0x03000000, 0x00140004, 0x00}, - {0, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00} }; -static struct inno_phy_mpll_s inno_phy_mpll_table2[] = { +static struct inno_phy_mpll_s phy_mpll[] = { +/* tmds clk */ {25200, 0x00002a01, 0x00010103, 0x00000103, 0x00000403, 0x03000000, 0x03280000, 0x03}, {27000, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, {33750, 0x00003601, 0x00020202, 0x00000603, 0x00000403, 0x03000000, 0x03280000, 0x03}, + {36000, 0x00002401, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x03280001, 0x03}, {37125, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, + {40000, 0x00002801, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x03140001, 0x01}, {46406, 0x00006301, 0x00030301, 0x00000102, 0x00000403, 0x03000000, 0x03500004, 0x01}, + {65000, 0x00004101, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x03140001, 0x01}, + {68250, 0x00005b01, 0x00030300, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, + {71000, 0x00004701, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x03140001, 0x01}, + {72000, 0x00002401, 0x00000002, 0x00000101, 0x00000202, 0x03000000, 0x03140001, 0x01}, {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, - {74250, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, + {75000, 0x00003201, 0x00020200, 0x00000100, 0x00000403, 0x03000000, 0x030a0001, 0x00}, + {79500, 0x00003501, 0x00020200, 0x00000100, 0x00000403, 0x03000000, 0x030a0001, 0x00}, + {85500, 0x00003901, 0x00020200, 0x00000100, 0x00000403, 0x03000000, 0x030a0001, 0x00}, + {88750, 0x00002c01, 0x00000002, 0x00000101, 0x00000202, 0x00000060, 0x03140001, 0x01}, {92813, 0x00006301, 0x00020201, 0x00000102, 0x00000403, 0x03000000, 0x03140001, 0x01}, + {101000, 0x00006501, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x030a0001, 0x00}, + {108000, 0x00002401, 0x00010100, 0x00000100, 0x00000202, 0x03000000, 0x030a0001, 0x00}, + {119000, 0x00007701, 0x00010102, 0x00000101, 0x00000403, 0x03000000, 0x030a0001, 0x00}, {119000, 0x00007701, 0x00010102, 0x00000603, 0x00000202, 0x03555515, 0x030a0000, 0x00}, {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, {148500, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, + {154000, 0x00004d01, 0x00000002, 0x00000101, 0x00000202, 0x03000000, 0x030a0001, 0x00}, {185625, 0x00006301, 0x00010101, 0x00000102, 0x00000202, 0x03000000, 0x030a0001, 0x00}, - {234000, 0x00004E01, 0x00000101, 0x00000400, 0x00000101, 0x030000C0, 0x030a0001, 0x00}, + {234000, 0x00007501, 0x00000002, 0x00000303, 0x00000202, 0x03000000, 0x030a0000, 0x00}, {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, {297000, 0x00006301, 0x00000001, 0x00000102, 0x00000101, 0x03000000, 0x03140002, 0x00}, {312250, 0x00006801, 0x00000001, 0x00000403, 0x00000101, 0x00555515, 0x030a0000, 0x00}, @@ -168,67 +127,25 @@ static void inno_phy_set_version(void) phy_dev.version = INNO_PHY_VERSION_0; /* t - ab */ } -static void -_inno_phy_get_electric_table(struct inno_phy_electric_s **table, int *size) -{ - switch (phy_dev.version) { - case INNO_PHY_VERSION_1: - *table = inno_phy_electric_table1; - *size = ARRAY_SIZE(inno_phy_electric_table1); - break; - case INNO_PHY_VERSION_2: - *table = inno_phy_electric_table2; - *size = ARRAY_SIZE(inno_phy_electric_table2); - break; - case INNO_PHY_VERSION_0: - default: - *table = inno_phy_electric_table0; - *size = ARRAY_SIZE(inno_phy_electric_table0); - break; - } -} - -static void -_inno_phy_get_mpll_table(struct inno_phy_mpll_s **inno_phy, int *size) -{ - switch (phy_dev.version) { - case INNO_PHY_VERSION_1: - *inno_phy = inno_phy_mpll_table1; - *size = (ARRAY_SIZE(inno_phy_mpll_table1) - 1); - break; - case INNO_PHY_VERSION_2: - *inno_phy = inno_phy_mpll_table2; - *size = (ARRAY_SIZE(inno_phy_mpll_table2) - 1); - break; - case INNO_PHY_VERSION_0: - default: - *inno_phy = inno_phy_mpll_table0; - *size = (ARRAY_SIZE(inno_phy_mpll_table0) - 1); - break; - } -} - static struct inno_phy_mpll_s *_inno_phy_get_mpll_params(void) { struct dw_hdmi_dev_s *hdmi = dw_get_hdmi(); - struct inno_phy_mpll_s *inno_phy = NULL; - int size = 0, index = 0; u32 ref_clk = 0x0, tmds_clk = hdmi->ctrl_dev.tmds_clk; - _inno_phy_get_mpll_table(&inno_phy, &size); + size = ARRAY_SIZE(phy_mpll) - 1; /* check min clock */ - if (tmds_clk < inno_phy[0].tmds_clk) { - ref_clk = inno_phy[0].tmds_clk; + if (tmds_clk < phy_mpll[0].tmds_clk) { + ref_clk = phy_mpll[0].tmds_clk; hdmi_wrn("raw clock is %ukHz, change use min ref clock %ukHz\n", tmds_clk, ref_clk); goto clk_cfg; } /* check max clock */ - if (tmds_clk > inno_phy[size - 1].tmds_clk) { - ref_clk = inno_phy[size - 1].tmds_clk; + if (tmds_clk > phy_mpll[size - 1].tmds_clk) { + ref_clk = phy_mpll[size - 1].tmds_clk; hdmi_wrn("raw clock is %ukHz, change use min ref clock %ukHz\n", tmds_clk, ref_clk); goto clk_cfg; @@ -236,24 +153,24 @@ static struct inno_phy_mpll_s *_inno_phy_get_mpll_params(void) for (index = 0; index < size; index++) { /* check clock is match in table */ - if (tmds_clk == inno_phy[index].tmds_clk) { - ref_clk = inno_phy[index].tmds_clk; + if (tmds_clk == phy_mpll[index].tmds_clk) { + ref_clk = phy_mpll[index].tmds_clk; goto clk_cfg; } /* check clock is match in table */ - if (tmds_clk == inno_phy[index + 1].tmds_clk) { - ref_clk = inno_phy[index + 1].tmds_clk; + if (tmds_clk == phy_mpll[index + 1].tmds_clk) { + ref_clk = phy_mpll[index + 1].tmds_clk; goto clk_cfg; } /* clock unmatch and use near clock */ - if ((tmds_clk > inno_phy[index].tmds_clk) && - (tmds_clk < inno_phy[index + 1].tmds_clk)) { + if ((tmds_clk > phy_mpll[index].tmds_clk) && + (tmds_clk < phy_mpll[index + 1].tmds_clk)) { /* clock unmatch and use near clock */ - if ((tmds_clk - inno_phy[index].tmds_clk) > - (inno_phy[index + 1].tmds_clk - tmds_clk)) - ref_clk = inno_phy[index + 1].tmds_clk; + if ((tmds_clk - phy_mpll[index].tmds_clk) > + (phy_mpll[index + 1].tmds_clk - tmds_clk)) + ref_clk = phy_mpll[index + 1].tmds_clk; else - ref_clk = inno_phy[index].tmds_clk; + ref_clk = phy_mpll[index].tmds_clk; hdmi_inf("raw clock is %ukHz, change use near ref clock %ukHz\n", tmds_clk, ref_clk); @@ -264,10 +181,10 @@ static struct inno_phy_mpll_s *_inno_phy_get_mpll_params(void) return NULL; clk_cfg: - for (index = 0; inno_phy[index].tmds_clk != 0; index++) { - if (ref_clk == inno_phy[index].tmds_clk) { + for (index = 0; phy_mpll[index].tmds_clk != 0; index++) { + if (ref_clk == phy_mpll[index].tmds_clk) { hdmi_inf("inno phy param use table[%d]\n", index); - return &(inno_phy[index]); + return &(phy_mpll[index]); } } hdmi_err("inno phy get mpll failed when tmds clock %dKHz, ref clock %dKHz\n", @@ -582,34 +499,50 @@ static void _inno_phy_enable_data_sync(void) phy_base->hdmi_phy_ctl0_2.bits.data_sy_ctl = 0x1; } -static int _inno_phy_electrical_config(void) +static int _inno_phy_config_electrical(void) { + struct inno_phy_electric_s *elec_table = NULL; struct dw_hdmi_dev_s *hdmi = dw_get_hdmi(); u32 tmds_clk = hdmi->ctrl_dev.tmds_clk; - int i, size; - - struct inno_phy_electric_s *table = NULL; + int i = 0; + int table_line = 0; + + if (phy_dev.elec_size) { + elec_table = phy_dev.elec_data; + table_line = phy_dev.elec_size / 6; + } else { + elec_table = phy_elec_default; + table_line = ARRAY_SIZE(phy_elec_default); + } - _inno_phy_get_electric_table(&table, &size); + for (i = 0; i < table_line; i++) { + if (elec_table[i].min_clk == elec_table[i].max_clk) { + if (tmds_clk != elec_table[i].min_clk) + continue; + } else { + if (tmds_clk < elec_table[i].min_clk) + continue; + if (tmds_clk >= elec_table[i].max_clk) + continue; + } - for (i = 0; i < size; i++) { - if (tmds_clk <= table[i].min_clk) - continue; - if (tmds_clk > table[i].max_clk) - continue; + hdmi_inf("%dHz match in [%dHz,%dHz]: 0x%x, 0x%x, 0x%x, 0x%x\n", + tmds_clk, elec_table[i].min_clk, elec_table[i].max_clk, + elec_table[i].cur_bias, elec_table[i].vlevel, + elec_table[i].pre_empl, elec_table[i].post_empl); - _inno_phy_cfg_cur_bias(table[i].cur_bias); + _inno_phy_cfg_cur_bias(elec_table[i].cur_bias); - _inno_phy_cfg_vlevel(table[i].vlevel); + _inno_phy_cfg_vlevel(elec_table[i].vlevel); - _inno_phy_cfg_pre_empl(table[i].pre_empl); + _inno_phy_cfg_pre_empl(elec_table[i].pre_empl); - _inno_phy_cfg_post_empl(table[i].post_empl); + _inno_phy_cfg_post_empl(elec_table[i].post_empl); return 0; } - hdmi_err("inno phy not set electric capabilities when tmds clock [%dKhz]\n", tmds_clk); + hdmi_err("inno phy not config electrical\n"); return -1; } @@ -664,7 +597,7 @@ static int _inno_phy_config_flow(void) _inno_turn_dirver_ctrl(0x1); /* config electrical capability */ - ret = _inno_phy_electrical_config(); + ret = _inno_phy_config_electrical(); if (ret != 0) { return -1; } @@ -713,12 +646,55 @@ int inno_phy_read(u8 addr, void *data) int inno_phy_init(void) { + int ret = 0, i = 0; struct dw_hdmi_dev_s *hdmi = dw_get_hdmi(); + u32 *tmp_buf; phy_base = (struct __inno_phy_reg_t *)(hdmi->addr + INNO_PHY_REG_OFFSET); inno_phy_set_version(); + if (phy_dev.version == INNO_PHY_VERSION_0) { + hdmi_inf("inno phy param use default table - version 0\n"); + goto reset; + } + + /* parse dts */ + ret = of_property_count_elems_of_size(hdmi->dev->of_node, "inno_phy", sizeof(u32)); + if (ret <= 0) { + hdmi_inf("inno phy not get table from dts, use default\n"); + goto reset; + } + + phy_dev.elec_size = ret; + hdmi_inf("inno phy get dts config table size: %d\n", phy_dev.elec_size); + + tmp_buf = kmalloc(phy_dev.elec_size, GFP_KERNEL | __GFP_ZERO); + if (!tmp_buf) { + hdmi_err("inno phy alloc buffer failed\n"); + goto reset; + } + + ret = of_property_read_u32_array(hdmi->dev->of_node, + "inno_phy", tmp_buf, phy_dev.elec_size); + if (ret < 0) { + hdmi_err("inno phy get dts table value failed\n"); + goto reset; + } + phy_dev.elec_data = (struct inno_phy_electric_s *)tmp_buf; + + for (i = 0; i < (phy_dev.elec_size / 6); i++) { + phy_log("line[%d], min_clk: %d, max_clk: %d, 0x%x, 0x%x, 0x%x, 0x%x\n", + i, phy_dev.elec_data[i].min_clk, phy_dev.elec_data[i].max_clk, + phy_dev.elec_data[i].cur_bias, phy_dev.elec_data[i].vlevel, + phy_dev.elec_data[i].pre_empl, phy_dev.elec_data[i].post_empl); + } + goto exit; + +reset: + phy_dev.elec_data = NULL; + phy_dev.elec_size = 0; +exit: return 0; } diff --git a/bsp/drivers/drm/sunxi_device/sunxi_de.h b/bsp/drivers/drm/sunxi_device/sunxi_de.h index 9727648ea7..08ca777b88 100644 --- a/bsp/drivers/drm/sunxi_device/sunxi_de.h +++ b/bsp/drivers/drm/sunxi_device/sunxi_de.h @@ -13,7 +13,7 @@ #define _SUNXI_DE_H_ #include "include.h" -#include "../sunxi_drm_crtc.h" +#include "sunxi_drm_crtc.h" //not visable for user struct sunxi_de_out; diff --git a/bsp/drivers/drm/sunxi_device/sunxi_de_v35x.c b/bsp/drivers/drm/sunxi_device/sunxi_de_v35x.c index cc75419c84..baa8c43fe0 100644 --- a/bsp/drivers/drm/sunxi_device/sunxi_de_v35x.c +++ b/bsp/drivers/drm/sunxi_device/sunxi_de_v35x.c @@ -21,7 +21,7 @@ #include #include "disp_al_de.h" -#include "../sunxi_drm_crtc.h" +#include "sunxi_drm_crtc.h" #define DISPLAY_NUM_MAX 4 #define MY_BYTE_ALIGN(x) (((x + (4 * 1024 - 1)) >> 12) << 12) diff --git a/bsp/drivers/drm/sunxi_device/sunxi_hdmi.c b/bsp/drivers/drm/sunxi_device/sunxi_hdmi.c index 96533024ad..e06f386590 100644 --- a/bsp/drivers/drm/sunxi_device/sunxi_hdmi.c +++ b/bsp/drivers/drm/sunxi_device/sunxi_hdmi.c @@ -10,8 +10,17 @@ ******************************************************************************/ #include +#include + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) #include #include +#else +#include +#include +#include +#endif #include "sunxi_hdmi.h" @@ -80,7 +89,7 @@ u8 sunxi_hdmi_scdc_read(u8 addr) u8 data = 0; int ret = 0; - ret = drm_scdc_readb(sunxi_hdmi->i2c, addr, &data); + ret = drm_scdc_readb(sunxi_hdmi->connect->ddc, addr, &data); if (ret != 0) { hdmi_wrn("hdmi drm scdc byte read 0x%x failed\n", addr); data = 0; @@ -93,7 +102,7 @@ void sunxi_hdmi_scdc_write(u8 addr, u8 data) { int ret = 0; - ret = drm_scdc_writeb(sunxi_hdmi->i2c, addr, data); + ret = drm_scdc_writeb(sunxi_hdmi->connect->ddc, addr, data); if (ret != 0) { hdmi_wrn("hdmi drm scdc byte write 0x%x = 0x%x failed\n", addr, data); } @@ -528,8 +537,13 @@ int sunxi_hdmi_disconfig(void) /* 2. clear sink scdc info */ if (dw_phy_hot_plug_state() && dw_fc_video_get_scramble()) { +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) drm_scdc_set_scrambling(sunxi_hdmi->i2c, 0x0); drm_scdc_set_high_tmds_clock_ratio(sunxi_hdmi->i2c, 0x0); +#else + drm_scdc_set_scrambling(sunxi_hdmi->connect, 0x0); + drm_scdc_set_high_tmds_clock_ratio(sunxi_hdmi->connect, 0x0); +#endif } return 0; @@ -629,6 +643,15 @@ int sunxi_hdmi_adap_bind(struct i2c_adapter *i2c_adap) return 0; } +int sunxi_hdmi_connect_creat(struct drm_connector *data) +{ + /* sunxi hdmi connect */ + sunxi_hdmi->connect = data; + /* dw hdmi connect */ + sunxi_hdmi->dw_hdmi.connect = data; + return 0; +} + int sunxi_hdmi_init(struct sunxi_hdmi_s *hdmi) { int ret = 0; diff --git a/bsp/drivers/drm/sunxi_device/sunxi_hdmi.h b/bsp/drivers/drm/sunxi_device/sunxi_hdmi.h index dcf7856fdc..17340f4c5e 100644 --- a/bsp/drivers/drm/sunxi_device/sunxi_hdmi.h +++ b/bsp/drivers/drm/sunxi_device/sunxi_hdmi.h @@ -209,6 +209,7 @@ struct sunxi_hdmi_s { struct platform_device *pdev; struct disp_device_config disp_info; + struct drm_connector *connect; int blacklist_index; @@ -388,6 +389,7 @@ struct disp_device_config *sunxi_hdmi_video_get_info(void); int sunxi_hdmi_video_set_info(struct disp_device_config *config); int sunxi_hdmi_adap_bind(struct i2c_adapter *i2c_adap); +int sunxi_hdmi_connect_creat(struct drm_connector *data); /** * @desc: sunxi hdmi core dump. point different hw * @buf: save dump info buffer diff --git a/bsp/drivers/drm/sunxi_device/sunxi_tcon_v35x.c b/bsp/drivers/drm/sunxi_device/sunxi_tcon_v35x.c index 4b6b945efe..0840bc00d5 100644 --- a/bsp/drivers/drm/sunxi_device/sunxi_tcon_v35x.c +++ b/bsp/drivers/drm/sunxi_device/sunxi_tcon_v35x.c @@ -21,9 +21,9 @@ #include "sunxi_tcon.h" #include "sunxi_tcon_top.h" #include "tcon_feat.h" -#include "../sunxi_drm_lcd.h" -#include "../sunxi_drm_hdmi.h" -#include "../sunxi_drm_edp.h" +#include "sunxi_drm_lcd.h" +#include "sunxi_drm_hdmi.h" +#include "sunxi_drm_edp.h" struct tcon_data { enum tcon_type type; diff --git a/bsp/drivers/drm/sunxi_drm_hdmi.c b/bsp/drivers/drm/sunxi_drm_hdmi.c index 85a14c8326..9d0d4c58bc 100644 --- a/bsp/drivers/drm/sunxi_drm_hdmi.c +++ b/bsp/drivers/drm/sunxi_drm_hdmi.c @@ -20,7 +20,12 @@ #include #include #include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) #include +#else +#include +#endif #include #include @@ -112,10 +117,12 @@ static const struct drm_prop_enum_list sunxi_hdmi_prop_scan_info[] = { { UNDERSCAN, "under_scan" }, }; +#if IS_ENABLED(CONFIG_EXTCON) static const unsigned int sunxi_hdmi_cable[] = { EXTCON_DISP_HDMI, EXTCON_NONE, }; +#endif enum sunxi_hdmi_ioctl_cmd_e { SUNXI_IOCTL_HDMI_NULL = 0, @@ -703,7 +710,7 @@ static int _sunxi_drv_hdmi_read_edid(struct sunxi_drm_hdmi *hdmi) return ret; } - //mutex_lock(&hdmi->hdmi_edid.edid_lock); + mutex_lock(&hdmi->hdmi_edid.edid_lock); if (hdmi->hdmi_edid.dbg_mode) { hdmi_inf("hdmi drv use debug edid\n"); @@ -724,7 +731,7 @@ static int _sunxi_drv_hdmi_read_edid(struct sunxi_drm_hdmi *hdmi) ret = 0; exit: - //mutex_unlock(&hdmi->hdmi_edid.edid_lock); + mutex_unlock(&hdmi->hdmi_edid.edid_lock); return ret; } @@ -997,7 +1004,7 @@ static int _sunxi_drv_hdmi_thread(void *parg) drm_helper_hpd_irq_event(hdmi->drm); next_loop: - msleep(200); + msleep(20); } return 0; @@ -1218,26 +1225,9 @@ _sunxi_drv_hdmi_init_resource(struct device *dev, struct sunxi_drm_hdmi *hdmi) } } - /* get pin control */ - pres->hdmi_pctl = pinctrl_get(dev); - if (IS_ERR(pres->hdmi_pctl)) - hdmi_inf("hdmi drv not get pinctrl\n"); - - /* get gpio */ - if (pcfg->ddc_gpio_en) { - pres->ddc_gpio.gpio = of_get_named_gpio_flags(dev->of_node, - "ddc_io_ctrl", 0x0, (enum of_gpio_flags *)(&(pres->ddc_gpio))); - - ret = gpio_request(pres->ddc_gpio.gpio, NULL); - if (ret != 0) { - hdmi_err("init resource to get ddc gpio is failed\n"); - return -1; - } - } - _sunxi_drv_hdmi_clk_enable(hdmi); - //mutex_init(&hdmi->hdmi_edid.edid_lock); + mutex_init(&hdmi->hdmi_edid.edid_lock); hdmi->hdmi_state.drv_hdcp_type = SUNXI_HDCP_TYPE_NULL; @@ -1267,7 +1257,7 @@ static int _sunxi_drv_hdmi_init_config_value(struct sunxi_drm_hdmi *hdmi) static int _sunxi_hdmi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { - return 0; + return sunxi_hdmi_i2c_xfer(msgs, num); } static u32 _sunxi_hdmi_i2c_func(struct i2c_adapter *adap) @@ -1904,7 +1894,7 @@ static ssize_t sunxi_hdmi_cmd_hdmi_source_show(struct device *dev, struct device_attribute *attr, char *buf) { int n = 0, loop = 0; - u8 data = 0; + u8 data = 0, status = 0; struct sunxi_drm_hdmi *hdmi = dev_get_drvdata(dev); struct sunxi_hdmi_dts_s *pdts = &hdmi->hdmi_dts; struct sunxi_hdmi_res_s *pres = &hdmi->hdmi_res; @@ -1935,9 +1925,10 @@ static ssize_t sunxi_hdmi_cmd_hdmi_source_show(struct device *dev, if (info->hdmi.scdc.supported) { n += sprintf(buf + n, "\n----------------- sink info -----------------\n"); data = sunxi_hdmi_scdc_read(SCDC_TMDS_CONFIG); + status = sunxi_hdmi_scdc_read(SCDC_SCRAMBLER_STATUS) & SCDC_SCRAMBLING_STATUS; n += sprintf(buf + n, " - clock ratio[%s], scramble enable[%d], scramble status[%d]\n", - (data & 0x2) ? "1/40" : "1/10", (data & 0x1), - drm_scdc_get_scrambling_status(&hdmi->i2c_adap)); + (data & SCDC_TMDS_BIT_CLOCK_RATIO_BY_40) ? "1/40" : "1/10", + (data & SCDC_SCRAMBLING_ENABLE), status); data = sunxi_hdmi_scdc_read(SCDC_STATUS_FLAGS_0); n += sprintf(buf + n, " - clk_lock[%d], ch0_lock[%d], ch1_lock[%d], ch2_lock[%d]\n", (data & SCDC_CLOCK_DETECT), (data & SCDC_CH0_LOCK) >> 1, @@ -2466,7 +2457,11 @@ static int _sunxi_dev_hdmi_init(struct sunxi_drm_hdmi *hdmi) } /* creat hdmi class */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 0) hdmi->hdmi_class = class_create(THIS_MODULE, "hdmi"); +#else + hdmi->hdmi_class = class_create("hdmi"); +#endif if (IS_ERR(hdmi->hdmi_class)) { hdmi_err("hdmi init dev failed when create hdmi class\n"); goto err_class; @@ -2715,7 +2710,6 @@ static enum drm_mode_status _sunxi_hdmi_drm_connector_mode_valid( /******************************************************************************* * drm sunxi hdmi connect functions ******************************************************************************/ -static u8 drm_connector_status_change_count = 0; static enum drm_connector_status _sunxi_hdmi_drm_connector_detect(struct drm_connector *connector, bool force) { @@ -2726,6 +2720,7 @@ _sunxi_hdmi_drm_connector_detect(struct drm_connector *connector, bool force) hdmi_err("%s param hdmi is null!!!\n", __func__); return connector_status_unknown; } + ret = _sunxi_drv_hdmi_hpd_get(hdmi); hdmi_inf("drm hdmi detect hpd: %s\n", ret ? "plugin" : "plugout"); return ret == 1 ? connector_status_connected : connector_status_disconnected; @@ -2987,6 +2982,8 @@ int sunxi_hdmi_drm_create(struct tcon_device *tcon) _sunxi_hdmi_drm_property_init(hdmi); + sunxi_hdmi_connect_creat(&hdmi->connector); + hdmi_inf("drm hdmi create finish\n"); return 0; } diff --git a/bsp/drivers/g2d/g2d_legacy/g2d_trace.h b/bsp/drivers/g2d/g2d_legacy/g2d_trace.h index bc7d578131..af2b9faac0 100644 --- a/bsp/drivers/g2d/g2d_legacy/g2d_trace.h +++ b/bsp/drivers/g2d/g2d_legacy/g2d_trace.h @@ -11,7 +11,7 @@ */ #undef TRACE_SYSTEM -#define TRACE_INCLUDE_PATH ../../../../bsp/drivers/g2d/g2d_legacy +#define TRACE_INCLUDE_PATH ./g2d_legacy/ #define TRACE_SYSTEM g2d_trace #if !defined(_TRACE_G2D_H) || defined(TRACE_HEADER_MULTI_READ) diff --git a/bsp/drivers/gmac/sunxi-gmac-trace.h b/bsp/drivers/gmac/sunxi-gmac-trace.h index fe3305caee..9c67027c47 100644 --- a/bsp/drivers/gmac/sunxi-gmac-trace.h +++ b/bsp/drivers/gmac/sunxi-gmac-trace.h @@ -91,7 +91,7 @@ TRACE_EVENT(sunxi_gmac_rx_desc, /* This must be outside ifdef _SUNXI_GMAC_TRACE_H */ #undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH ../../bsp/drivers/gmac +#define TRACE_INCLUDE_PATH . #undef TRACE_INCLUDE_FILE #define TRACE_INCLUDE_FILE sunxi-gmac-trace #include diff --git a/bsp/drivers/mmc/cqhci-core.c b/bsp/drivers/mmc/cqhci-core.c index b916ec1253..77c16ef4c3 100644 --- a/bsp/drivers/mmc/cqhci-core.c +++ b/bsp/drivers/mmc/cqhci-core.c @@ -954,7 +954,7 @@ irqreturn_t cqhci_irq(struct mmc_host *mmc, u32 intmask, int cmd_error, if ((status & (CQHCI_IS_RED | CQHCI_IS_GCE | CQHCI_IS_ICCE)) || cmd_error || data_error) { -#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 137)) && (LINUX_VERSION_CODE != KERNEL_VERSION(5, 15, 151))) +#if ((LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 137)) && (LINUX_VERSION_CODE != KERNEL_VERSION(5, 15, 147))) if (status & CQHCI_IS_RED) mmc_debugfs_err_stats_inc(mmc, MMC_ERR_CMDQ_RED); if (status & CQHCI_IS_GCE) diff --git a/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.c b/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.c index 0efc058d1d..430047669e 100644 --- a/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.c +++ b/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.c @@ -464,9 +464,9 @@ static loff_t gckvip_core_loading_get( ) { loff_t len = 0, offset = 0; - vip_uint32_t ratio = 0, i = 0; - vip_uint64_t total_time = 0, total_tmp = 0, total_time_ms = 0; - gckvip_profile_t profile_result = gckvip_debug_get_profile_data(); + vip_uint32_t i = 0; + vip_uint64_t total_time = 0, cur_time = 0, total_time_ms = 0; + #if vpmdUSE_DEBUG_FS struct seq_file *ptr = (struct seq_file*)m; #else @@ -478,29 +478,49 @@ static loff_t gckvip_core_loading_get( if (VIP_NULL == core_loading) return 0; + cur_time = gckvip_os_get_time(); if (0 == core_loading[0].destory_time) { - total_time = gckvip_os_get_time() - core_loading[0].init_time; + total_time = cur_time - core_loading[0].init_time; + } else { - total_time = core_loading[0].destory_time - core_loading[0].init_time; + core_loading[0].infer_time = 0; + core_loading[0].last_infer_time = 0; + core_loading[0].last_record_time = 0; } - total_time_ms = total_time; - do_div(total_time_ms, 1000); + total_time_ms = total_time; + do_div(total_time_ms, 1000); - FS_PRINTF(ptr, len, offset, "VIP Total Time=%" PRId64" ms\n", total_time_ms); for (i = 0; i < debugfs_core_cnt; i++) { + /* vip_uint64_t infer_ms = core_loading[i].infer_time; vip_uint64_t ratio = core_loading[i].infer_time * 100; do_div(infer_ms, 1000); do_div(ratio, total_time); if (0 == i) { - FS_PRINTF(ptr, len, offset, "History Loading -----> Core%d: Inference Time=%"PRId64" ms (%2d%%)\n", + FS_PRINTF(ptr, len, offset, "NPU Loading -----> Core%d: Inference Time=%"PRId64" ms (%2d%%)\n", i, infer_ms, ratio); } else { FS_PRINTF(ptr, len, offset, " Core%d: Inference Time=%"PRId64" ms (%2d%%)\n", i, infer_ms, ratio); + }*/ + vip_uint64_t step_infer = core_loading[i].infer_time - core_loading[0].last_infer_time; /*us*/ + vip_uint64_t step_total_us = cur_time - core_loading[0].last_record_time; + vip_uint64_t ratio = step_infer * 100; + do_div(step_infer, 1000); + do_div(ratio, step_total_us); + if (0 == i) { + FS_PRINTF(ptr, len, offset, "NPU Loading -----> Core%d: %2d%%\n", + i, ratio, step_infer); + } else { + FS_PRINTF(ptr, len, offset, " Core%d: %2d%%\n", + i, ratio); } } + core_loading[0].last_record_time = cur_time; + core_loading[0].last_infer_time = core_loading[0].infer_time; + + #if !vpmdUSE_DEBUG_FS flush_buffer: #endif @@ -519,13 +539,14 @@ static ssize_t gckvip_core_loading_set( ret = strncmp(buf, "reset", 5); - if (!ret) { for (i = 0; i < debugfs_core_cnt; i++) { core_loading[i].init_time = gckvip_os_get_time(); core_loading[i].submit_time = 0; core_loading[i].infer_time = 0; core_loading[i].destory_time = 0; + core_loading[i].last_record_time = core_loading[i].init_time; + core_loading[i].last_infer_time = 0; } } else { PRINTK_E("invalid param, please set reset string to reset core loading data.\n"); @@ -2750,22 +2771,6 @@ vip_status_e gckvip_debug_create_fs(void) #else status = gckvip_debug_create_sysfs(); #endif - return status; -} - -vip_status_e gckvip_debug_destroy_fs(void) -{ - vip_status_e status = VIP_SUCCESS; -#if vpmdUSE_DEBUG_FS - status = gckvip_debug_destroy_debugfs(); -#else - status = gckvip_debug_destroy_sysfs(); -#endif - - if (core_loading != VIP_NULL) { - gckvip_os_free_memory((void *)core_loading); - core_loading = VIP_NULL; - } return status; } @@ -2783,6 +2788,8 @@ vip_status_e gckvip_debug_profile_start(void) core_loading[i].destory_time = 0; core_loading[i].submit_time = 0; core_loading[i].infer_time = 0; + core_loading[i].last_record_time = time; + core_loading[i].last_infer_time = 0; } return status; @@ -2800,6 +2807,23 @@ vip_status_e gckvip_debug_profile_end(void) core_loading[i].destory_time = time; } + return status; + } + +vip_status_e gckvip_debug_destroy_fs(void) +{ + vip_status_e status = VIP_SUCCESS; +#if vpmdUSE_DEBUG_FS + status = gckvip_debug_destroy_debugfs(); +#else + status = gckvip_debug_destroy_sysfs(); +#endif + + if (core_loading != VIP_NULL) { + gckvip_os_free_memory((void *)core_loading); + core_loading = VIP_NULL; + } + return status; } diff --git a/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.h b/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.h index 235965400b..f65fa72eba 100644 --- a/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.h +++ b/bsp/drivers/npu/aw_nna_vip/linux/gc_vip_kernel_os_debug.h @@ -53,6 +53,7 @@ *****************************************************************************/ #ifndef _GC_VIP_DEBUG_FS_H #define _GC_VIP_DEBUG_FS_H + #include "gc_vip_common.h" #if vpmdENABLE_DEBUGFS @@ -70,11 +71,11 @@ typedef struct _gckvip_mem_mapping_profile_t { } gckvip_mem_mapping_profile_t; typedef struct _gckvip_profile_t { - vip_uint64_t init_time; /* the hardwarae init time */ + vip_uint64_t init_time; /* the hardware init time */ vip_uint64_t submit_time; /* the network submit time */ vip_uint64_t wait_time; /* the end time for network run */ - vip_uint64_t total_time; /* the total time for hardwarae work */ + vip_uint64_t total_time; /* the total time for hardware work */ vip_uint64_t infer_time; /* the total time for network inference */ vip_uint32_t video_memory; /* the current video memory */ @@ -84,11 +85,14 @@ typedef struct _gckvip_profile_t { } gckvip_profile_t; typedef struct _gckvip_core_loading_profile_t { - vip_uint64_t init_time; /* the hardwarae init time */ - vip_uint64_t destory_time; /* the hardwarae end time */ + vip_uint64_t init_time; /* the hardware init time */ + vip_uint64_t destory_time; /* the hardware end time */ vip_uint64_t submit_time; /* the network submit time */ vip_uint64_t infer_time; /* the total time for network inference */ + + vip_uint64_t last_record_time; /* the last record time */ + vip_uint64_t last_infer_time; /* the last record infer time */ } gckvip_core_loading_profile_t; typedef enum _gckvip_profile_data_type_t { diff --git a/bsp/drivers/pcie/pcie-sunxi-plat.c b/bsp/drivers/pcie/pcie-sunxi-plat.c index e9920c3dfb..eea451b88c 100644 --- a/bsp/drivers/pcie/pcie-sunxi-plat.c +++ b/bsp/drivers/pcie/pcie-sunxi-plat.c @@ -36,6 +36,8 @@ #include "pcie-sunxi-dma.h" #include "pcie-sunxi.h" +#define SUNXI_PCIE_MODULE_VERSION "1.0.8" + void sunxi_pcie_writel(u32 val, struct sunxi_pcie *pcie, u32 offset) { writel(val, pcie->app_base + offset); @@ -391,7 +393,7 @@ static int sunxi_pcie_plat_enable_power(struct sunxi_pcie *pci) int ret = 0; if (IS_ERR_OR_NULL(pci->pcie3v3)) - return ret; + return 1; ret = regulator_set_voltage(pci->pcie3v3, 3300000, 3300000); if (ret) @@ -401,6 +403,17 @@ static int sunxi_pcie_plat_enable_power(struct sunxi_pcie *pci) if (ret) dev_err(dev, "failed to enable pcie3v3 regulator\n"); + if (IS_ERR_OR_NULL(pci->pcie1v8)) + return 1; + + ret = regulator_set_voltage(pci->pcie1v8, 1800000, 1800000); + if (ret) + dev_warn(dev, "failed to set regulator voltage\n"); + + ret = regulator_enable(pci->pcie1v8); + if (ret) + dev_err(dev, "failed to enable pcie1v8 regulator\n"); + return ret; } @@ -415,6 +428,13 @@ static int sunxi_pcie_plat_disable_power(struct sunxi_pcie *pci) if (ret) dev_err(pci->dev, "fail to disable pcie3v3 regulator\n"); + if (IS_ERR_OR_NULL(pci->pcie1v8)) + return ret; + + ret = regulator_disable(pci->pcie1v8); + if (ret) + dev_err(pci->dev, "fail to disable pcie1v8 regulator\n"); + return ret; } @@ -829,6 +849,10 @@ static int sunxi_pcie_plat_parse_dts_res(struct platform_device *pdev, struct su if (IS_ERR(pci->pcie3v3)) dev_warn(&pdev->dev, "no pcie3v3 regulator found\n"); + pci->pcie1v8 = devm_regulator_get_optional(&pdev->dev, "pcie1v8"); + if (IS_ERR(pci->pcie1v8)) + dev_warn(&pdev->dev, "no pcie1v8 regulator found\n"); + ret = of_property_read_u32(np, "num-lanes", &pci->lanes); if (ret) { dev_err(&pdev->dev, "Failed to parse the number of lanes\n"); @@ -952,6 +976,8 @@ static int sunxi_pcie_plat_probe(struct platform_device *pdev) if (ret) goto err3; + dev_info(&pdev->dev, "driver version: %s\n", SUNXI_PCIE_MODULE_VERSION); + return 0; err3: @@ -1072,5 +1098,5 @@ module_platform_driver(sunxi_pcie_plat_driver); MODULE_AUTHOR("songjundong "); MODULE_DESCRIPTION("Allwinner PCIe controller platform driver"); -MODULE_VERSION("1.0.7"); +MODULE_VERSION(SUNXI_PCIE_MODULE_VERSION); MODULE_LICENSE("GPL v2"); diff --git a/bsp/drivers/pcie/pcie-sunxi.h b/bsp/drivers/pcie/pcie-sunxi.h index 076f70b33e..00b995e4cb 100644 --- a/bsp/drivers/pcie/pcie-sunxi.h +++ b/bsp/drivers/pcie/pcie-sunxi.h @@ -296,6 +296,7 @@ struct sunxi_pcie { const struct sunxi_pcie_of_data *drvdata; struct gpio_desc *rst_gpio; u32 lanes; + struct regulator *pcie1v8; struct regulator *pcie3v3; }; diff --git a/bsp/drivers/sound/adapter/snd_sunxi_adapter.c b/bsp/drivers/sound/adapter/snd_sunxi_adapter.c index 5464739ccf..63057ea88a 100644 --- a/bsp/drivers/sound/adapter/snd_sunxi_adapter.c +++ b/bsp/drivers/sound/adapter/snd_sunxi_adapter.c @@ -12,7 +12,7 @@ */ #include "snd_sunxi_adapter.h" -#include "../platform/snd_sunxi_log.h" +#include "snd_sunxi_log.h" #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) struct snd_soc_dai *sunxi_adpt_rtd_cpu_dai(struct snd_soc_pcm_runtime *rtd) diff --git a/bsp/drivers/sound/adapter/snd_sunxi_pcm_adapter.c b/bsp/drivers/sound/adapter/snd_sunxi_pcm_adapter.c index 3096122046..db119afbbd 100644 --- a/bsp/drivers/sound/adapter/snd_sunxi_pcm_adapter.c +++ b/bsp/drivers/sound/adapter/snd_sunxi_pcm_adapter.c @@ -16,8 +16,8 @@ #include #include -#include "../platform/snd_sunxi_log.h" -#include "../platform/snd_sunxi_pcm.h" +#include "snd_sunxi_log.h" +#include "snd_sunxi_pcm.h" #define SUNXI_DMAENGINE_PCM_DRV_NAME "sunxi_dmaengine_pcm" diff --git a/bsp/drivers/sound/platform/platforms/snd_sun55iw3_i2s.c b/bsp/drivers/sound/platform/platforms/snd_sun55iw3_i2s.c index f1cf03cbe1..2737d6dbf1 100644 --- a/bsp/drivers/sound/platform/platforms/snd_sun55iw3_i2s.c +++ b/bsp/drivers/sound/platform/platforms/snd_sun55iw3_i2s.c @@ -19,8 +19,8 @@ #include #include -#include "../snd_sunxi_log.h" -#include "../snd_sunxi_i2s.h" +#include "snd_sunxi_log.h" +#include "snd_sunxi_i2s.h" struct sunxi_i2s_clk { /* parent clk */ diff --git a/bsp/drivers/stmmac/dwmac-sunxi.c b/bsp/drivers/stmmac/dwmac-sunxi.c index 552bae62a3..94fa16e910 100644 --- a/bsp/drivers/stmmac/dwmac-sunxi.c +++ b/bsp/drivers/stmmac/dwmac-sunxi.c @@ -734,7 +734,7 @@ static int __init sunxi_dwmac_set_mac_addr(char *str) return 0; } -__setup("mac1_addr=", sunxi_dwmac_set_mac_addr); +__setup("mac_addr=", sunxi_dwmac_set_mac_addr); #endif /* MODULE */ MODULE_DESCRIPTION("Allwinner DWMAC driver"); diff --git a/bsp/drivers/twi/twi-sunxi.c b/bsp/drivers/twi/twi-sunxi.c index e7c0e22ac9..ed20f0e4c8 100644 --- a/bsp/drivers/twi/twi-sunxi.c +++ b/bsp/drivers/twi/twi-sunxi.c @@ -57,7 +57,7 @@ #include #endif /* CONFIG_AW_TWI_DELAYINIT */ -#define SUNXI_TWI_VERSION "2.6.8" +#define SUNXI_TWI_VERSION "2.6.9" /* TWI Register Offset */ /* 31:8bit reserved,7-1bit for slave addr,0 bit for GCE */ @@ -398,6 +398,19 @@ enum SUNXI_TWI_XFER_STATUS { #endif }; +static char const *twi_status[] = { + "idle", + "running", + "shutdown", + "complete" +#if IS_ENABLED(CONFIG_I2C_SLAVE) + , "slave_idle", + "slave_saddr", + "slave_wdata", + "slave_rdata" +#endif + }; + struct sunxi_twi_dma { struct dma_chan *chan; dma_addr_t dma_buf; @@ -2298,11 +2311,11 @@ sunxi_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) return -EINVAL; } - /* Set twi to RUNNING state when it is not in SHUTDOWN state */ + /* Set twi to RUNNING state when it is in IDLE state */ spin_lock_irqsave(&twi->lock, flags); - if (twi->status == SUNXI_TWI_XFER_STATUS_SHUTDOWN) { + if (twi->status == SUNXI_TWI_XFER_STATUS_SHUTDOWN || twi->status == SUNXI_TWI_XFER_STATUS_RUNNING) { spin_unlock_irqrestore(&twi->lock, flags); - sunxi_err(twi->dev, "twi bus is shutdown and shouldn't be working anymore\n"); + sunxi_err(twi->dev, "twi bus is %s and shouldn't be working anymore\n", twi_status[twi->status]); return -EBUSY; } else { twi->status = SUNXI_TWI_XFER_STATUS_RUNNING; @@ -2832,7 +2845,7 @@ static ssize_t sunxi_twi_status_show(struct device *dev, return scnprintf(buf, PAGE_SIZE, "twi->bus_num = %d\n" - "twi->status = [%d]\n" + "twi->status = [%d] %s\n" "twi->msg_num = %u, ->msg_idx = %u, ->buf_idx = %u\n" "twi->bus_freq = %u\n" "twi->irq = %d\n" @@ -2843,7 +2856,7 @@ static ssize_t sunxi_twi_status_show(struct device *dev, "[STAT] 0x%02x = 0x%08x, [CCR] 0x%02x = 0x%08x\n" "[SRST] 0x%02x = 0x%08x, [EFR] 0x%02x = 0x%08x\n" "[LCR] 0x%02x = 0x%08x\n", - twi->bus_num, twi->status, + twi->bus_num, twi->status, twi_status[twi->status], twi->msg_num, twi->msg_idx, twi->buf_idx, twi->bus_freq, twi->irq, twi->debug_state, twi->base_addr, @@ -3295,6 +3308,7 @@ static int sunxi_twi_resume_noirq(struct device *dev) { struct sunxi_twi *twi = dev_get_drvdata(dev); int ret = 0; + unsigned long flags; /* * cpus + normal standby : the twi used by pmu dont close it regulator @@ -3308,10 +3322,16 @@ static int sunxi_twi_resume_noirq(struct device *dev) * during wake-up. */ if (twi->no_suspend) { - sunxi_info(twi->dev, "resume noirq\n"); - sunxi_twi_adap_lock_bus(&twi->adap, I2C_LOCK_SEGMENT); + spin_lock_irqsave(&twi->lock, flags); + twi->status = SUNXI_TWI_XFER_STATUS_RUNNING; + spin_unlock_irqrestore(&twi->lock, flags); + + sunxi_info(twi->dev, "new resume noirq\n"); ret = sunxi_twi_hw_init(twi); - sunxi_twi_adap_unlock_bus(&twi->adap, I2C_LOCK_SEGMENT); + + spin_lock_irqsave(&twi->lock, flags); + twi->status = SUNXI_TWI_XFER_STATUS_IDLE; + spin_unlock_irqrestore(&twi->lock, flags); } return ret; diff --git a/bsp/drivers/usb/host/sunxi-hci.h b/bsp/drivers/usb/host/sunxi-hci.h index dcff2834be..ed5b51bfda 100644 --- a/bsp/drivers/usb/host/sunxi-hci.h +++ b/bsp/drivers/usb/host/sunxi-hci.h @@ -28,7 +28,7 @@ #include #include -#include "../sunxi_usb/include/sunxi_usb_debug.h" +#include <../sunxi_usb/include/sunxi_usb_debug.h> extern int usb_disabled(void); extern atomic_t hci_thread_suspend_flag; diff --git a/bsp/drivers/usb/sunxi_usb/udc/sunxi_udc.c b/bsp/drivers/usb/sunxi_usb/udc/sunxi_udc.c index 9462adb584..172c148754 100644 --- a/bsp/drivers/usb/sunxi_usb/udc/sunxi_udc.c +++ b/bsp/drivers/usb/sunxi_usb/udc/sunxi_udc.c @@ -431,8 +431,8 @@ static __u32 is_peripheral_active(void) #define big_req(req, ep) ((req->req.length != req->req.actual) \ ? ((req->req.length >= 512) \ && ((req->req.length - req->req.actual) \ - > ep->ep.maxpacket)) \ - : (req->req.length > ep->ep.maxpacket)) + >= ep->ep.maxpacket)) \ + : (req->req.length >= ep->ep.maxpacket)) #define is_sunxi_udc_dma_capable(req, ep) (is_udc_support_dma() \ && big_req(req, ep) \ && ep->num \ diff --git a/bsp/include/sunxi-autogen.h b/bsp/include/sunxi-autogen.h index 803fc25954..46e757757c 100644 --- a/bsp/include/sunxi-autogen.h +++ b/bsp/include/sunxi-autogen.h @@ -1 +1 @@ -#define AW_BSP_VERSION "b6b861664c, 2024-03-06 09:22:31 +0800" +#define AW_BSP_VERSION "f65e1496a1, 2024-04-10 13:56:44 +0800"