工作记录(星期一)
摆脱一份幻觉比发现一个真理更能使人明智
当你在凝视深渊的时候深渊也在凝视你
在周六、周日的时候,也算是测试完了这些系统,目前还有问题的是HDMIIN,这个功能确实需要测试看看,目前的现象是无法采集到正确的图像信息。

HDMIIN的问题就先这样了,没有什么要搞的东西,现在这样可以的,能用就行,然后我要做什么呢?
gnome的构建吗,其实目前对我来说并没什么用,客户对于这个系统也并不是必要的,不是吗,而其他的一些包,我感觉并没有什么实际的作用,等真正用到了再说吧,现在确是不知道做什么了。
pip install opencv-python==4.5.4 -i https://repo.huaweicloud.com/repository/pypi/simple/
sudo apt install pip
pip install opencv-python -i https://repo.huaweicloud.com/repository/pypi/simple/
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main() {
// 使用GStreamer管道获取视频,并确保使用BGR格式
VideoCapture cap("v4l2src device=/dev/video20 ! video/x-raw, format=(string)BGR ! videoconvert ! appsink", cv::CAP_GSTREAMER);
if (!cap.isOpened()) {
std::cerr << "Error: Could not open video device." << std::endl;
return -1;
}
double time0 = static_cast<double>(getTickCount()); // 获取开始时间
Mat frame;
while (true) {
cap >> frame;
if (frame.empty()) {
std::cerr << "Error: Could not read frame." << std::endl;
break;
}
double time1 = static_cast<double>(getTickCount()); // 获取当前时间
double fps = getTickFrequency() / (time1 - time0); // 计算帧率
time0 = time1; // 更新开始时间
putText(frame, "FPS: " + to_string(fps), Point(10, 30), FONT_HERSHEY_SIMPLEX, 1, Scalar(0, 0, 255), 2); // 在图像上显示帧率
imshow("Video", frame);
// 按下'q'键退出循环
if (waitKey(1) == 'q') {
break;
}
}
// 释放资源并关闭窗口
cap.release();
destroyAllWindows();
return 0;
}
[ 35.263239] start_addr=(0x20000), end_addr=(0x40000), buffer_size=(0x20000), smp_number_max=(16384)
[ 35.283231] [BT_RFKILL]: Enter rfkill_rk_pm_complete
[ 35.283234] []: ** disable irq
[ 35.283242] [BT_RFKILL]: Enable UART_RTS
[ 35.288046] Restarting tasks ...
[ 35.291903] healthd: battery l=100 v=0 t=42.4 h=2 st=2 chg=a
[ 35.298048] done.
[ 35.298175] PM: suspend exit 2024-07-24 02:00:01.967182114 UTC
[ 35.398375] PM: suspend entry 2024-07-24 02:00:02.067387124 UTC
[ 35.398395] PM: Syncing filesystems ... done.
[ 35.407545] Freezing user space processes ... (elapsed 0.004 seconds) done.
[ 35.411975] Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done.
[ 35.414587] Suspending console(s) (use no_console_suspend to debug)
[ 35.414855] [BT_RFKILL]: Enter rfkill_rk_pm_prepare
[ 35.414858] [BT_RFKILL]: Disable UART_RTS
[ 35.414933] [BT_RFKILL]: enable irq for bt wakeup host
[ 35.525388] led_ctl suspend:power off!
[ 35.525394] led_ctl suspend:power off!
[ 35.525406] [WLAN_RFKILL]: Enter rfkill_wlan_suspend
[ 35.578742] PM: suspend of devices complete after 163.237 msecs
[ 35.581533] PM: late suspend of devices complete after 2.311 msecs
[ 35.583572] PM: noirq suspend of devices complete after 2.028 msecs
[ 35.583577] Disabling non-boot CPUs ...
[ 35.602059] CPU1: shutdown
[ 35.614931] psci: Retrying again to check for CPU kill
[ 35.614935] psci: CPU1 killed.
[ 35.661990] CPU2: shutdown
[ 35.661995] psci: CPU2 killed.
[ 35.708593] CPU3: shutdown
[ 35.721591] psci: Retrying again to check for CPU kill
[ 35.721595] psci: CPU3 killed.
[ 35.761853] CPU4: shutdown
[ 35.774951] psci: Retrying again to check for CPU kill
[ 35.774955] psci: CPU4 killed.
[ 35.815139] CPU5: shutdown
[ 35.828258] psci: Retrying again to check for CPU kill
[ 35.828262] psci: CPU5 killed.
[ 35.840234] Enabling non-boot CPUs ...
[ 35.859198] Detected VIPT I-cache on CPU1
[ 35.859224] CPU1: found redistributor 1 region 0:0x00000000fef20000
[ 35.859267] CPU1: update cpu_capacity 401
[ 35.859271] CPU1: Booted secondary processor [410fd034]
[ 35.859749] CPU1 is up
[ 35.879169] Detected VIPT I-cache on CPU2
[ 35.879190] CPU2: found redistributor 2 region 0:0x00000000fef40000
[ 35.879221] CPU2: update cpu_capacity 401
[ 35.879225] CPU2: Booted secondary processor [410fd034]
[ 35.879778] CPU2 is up
[ 35.899357] Detected VIPT I-cache on CPU3
[ 35.899378] CPU3: found redistributor 3 region 0:0x00000000fef60000
[ 35.899410] CPU3: update cpu_capacity 401
[ 35.899413] CPU3: Booted secondary processor [410fd034]
[ 35.900147] CPU3 is up
[ 35.919599] Detected PIPT I-cache on CPU4
[ 35.919624] CPU4: found redistributor 100 region 0:0x00000000fef80000
[ 35.919671] CPU4: update cpu_capacity 1024
[ 35.919674] CPU4: Booted secondary processor [410fd082]
[ 35.922157] cpu cpu4: avs=0, target-scale=17
[ 35.922248] cpu cpu4: l=10000 h=2147483647 hyst=5000 l_limit=0 h_limit=0
[ 35.922406] CPU4 is up
[ 35.946469] Detected PIPT I-cache on CPU5
[ 35.946487] CPU5: found redistributor 101 region 0:0x00000000fefa0000
[ 35.946521] CPU5: update cpu_capacity 1024
[ 35.946524] CPU5: Booted secondary processor [410fd082]
[ 35.949428] CPU5 is up
[ 35.951567] PM: noirq resume of devices complete after 2.027 msecs
[ 35.953788] PM: early resume of devices complete after 1.899 msecs
[ 35.959114] rk_gmac-dwmac fe300000.ethernet: init for RGMII
[ 36.162727] [WLAN_RFKILL]: Enter rfkill_wlan_resume
[ 36.162734] led_ctl resume:power on!
[ 36.162737] led_ctl resume:power on!
[ 36.164058] Suspended for 816.167 seconds
[ 36.165770] cdn-dp fec00000.dp: [drm:cdn_dp_pd_event_work] Not connected. Disabling cdn
[ 36.191636] mmc_host mmc2: Bus speed (slot 0) = 50000000Hz (slot req 50000000Hz, actual 50000000HZ div = 0)
在Linux中,电源管理通常涉及不同的休眠和低功耗模式。你提供的宏定义代表了各种不同的电源管理模式和操作。这些模式用于控制系统在休眠时的不同状态和行为,特别是在嵌入式系统和片上系统(SoC)中。以下是对这些模式的解释:
- RKPM_SLP_WFI (Wait for Interrupt)
- 定义:
#define RKPM_SLP_WFI (1 << 0) - 解释:这种模式下,CPU进入低功耗状态并等待中断。CPU时钟停止,直到某个外部或内部事件发生并产生中断信号,使CPU从等待状态中唤醒。
- 定义:
- RKPM_SLP_ARMPD (ARM Power Down)
- 定义:
#define RKPM_SLP_ARMPD (1 << 1) - 解释:这种模式下,ARM处理器核心完全关闭电源。此模式通常用于深度睡眠或休眠状态,以节省更多的电能。
- 定义:
- RKPM_SLP_PERILPPD (Peripheral Power Down)
- 定义:
#define RKPM_SLP_PERILPPD (1 << 2) - 解释:这种模式下,系统外围设备(如I/O接口)关闭电源。这有助于减少不必要的能耗,尤其是在外围设备不需要工作的情况下。
- 定义:
- RKPM_SLP_DDR_RET (DDR Retention)
- 定义:
#define RKPM_SLP_DDR_RET (1 << 3) - 解释:这种模式下,DDR内存进入保留状态(Retention),即保持其内容但消耗极低的功率。这种模式确保在系统唤醒时数据不会丢失。
- 定义:
- RKPM_SLP_PLLPD (PLL Power Down)
- 定义:
#define RKPM_SLP_PLLPD (1 << 4) - 解释:这种模式下,关闭相位锁定环(PLL)。PLL用于生成高频时钟信号,关闭PLL可以显著降低功耗。
- 定义:
- RKPM_SLP_OSC_DIS (Oscillator Disable)
- 定义:
#define RKPM_SLP_OSC_DIS (1 << 5) - 解释:这种模式下,关闭系统时钟振荡器。关闭振荡器进一步减少功耗,但系统不能进行任何操作,直到振荡器重新启用。
- 定义:
- RKPM_SLP_CENTER_PD (Center Power Down)
- 定义:
#define RKPM_SLP_CENTER_PD (1 << 6) - 解释:这种模式可能涉及SoC的中心部分(如中央总线、桥接器等)的电源关闭。这有助于节省核心架构的功耗。
- 定义:
- RKPM_SLP_AP_PWROFF (Application Processor Power Off)
- 定义:
#define RKPM_SLP_AP_PWROFF (1 << 7) - 解释:这种模式下,应用处理器(AP)关闭电源。通常用于整个系统的深度休眠或关机状态。
- 定义:
这些模式在不同的硬件平台上可能有不同的实现,但总体目标都是在系统处于闲置或低活动状态时,通过不同程度的关闭或降低系统组件的功耗来节省能耗。这些模式通常由内核或电源管理固件管理,并根据系统状态动态启用或禁用。
原版
rockchip,sleep-mode-config = <
(0
| RKPM_SLP_ARMPD
| RKPM_SLP_PERILPPD
| RKPM_SLP_DDR_RET
| RKPM_SLP_PLLPD
| RKPM_SLP_CENTER_PD
| RKPM_SLP_OSC_DIS
| RKPM_SLP_AP_PWROFF
)
>;
0.0719A 873mw
修改之后
rockchip,sleep-mode-config = <
(0
| RKPM_SLP_PERILPPD
| RKPM_SLP_DDR_RET
| RKPM_SLP_PLLPD
| RKPM_SLP_CENTER_PD
| RKPM_SLP_WFI // 这里可以添加WFI(等待中断)模式
)
>;
rockchip,sleep-mode-config = <
(0 | RKPM_SLP_ARMPD | RKPM_SLP_DDR_RET | RKPM_SLP_PLLPD | RKPM_SLP_CENTER_PD | RKPM_SLP_WFI)
>;
rockchip,sleep-mode-config = <
(0 | RKPM_SLP_ARMPD | RKPM_SLP_PERILPPD | RKPM_SLP_DDR_RET | RKPM_SLP_PLLPD | RKPM_SLP_CENTER_PD | RKPM_SLP_WFI
)
>;

7.26(星期五)
正常打印:


然后来等着,看一下即可,目前的时间是99.86211,去简单的学习一下。



第一次休眠打印
��INFO: sleep mode config[0xfe]:
INFO: AP_PWROFF
INFO: SLP_ARMPD
INFO: SLP_PLLPD
INFO: DDR_RET
INFO: SLP_CENTER_PD
INFO: OSC_DIS
INFO: wakeup source config[0x4]:
INFO: GPIO interrupt can wakeup system
INFO: PWM CONFIG[0x4]:
INFO: PWM: PWM2D_REGULATOR_EN
INFO: APIOS info[0x0]:
INFO: not config
INFO: GPIO POWER INFO:
INFO: not config
INFO: PMU_MODE_CONG: 0x1477bf79
INFO: RK3399 the wake up information:
INFO: wake up status: 0x4
INFO: GPIO interrupt wakeup
INFO: GPIO0: 0x0
INFO: GPIO1: 0x200000
INFO: GPIO2: 0x0
INFO: GPIO3: 0x0
INFO: GPIO4: 0x0
第二次休眠打印
INFO: sleep mode config[0xfe]:
INFO: AP_PWROFF
INFO: SLP_ARMPD
INFO: SLP_PLLPD
INFO: DDR_RET
INFO: SLP_CENTER_PD
INFO: OSC_DIS
INFO: wakeup source config[0x4]:
INFO: GPIO interrupt can wakeup system
INFO: PWM CONFIG[0x4]:
INFO: PWM: PWM2D_REGULATOR_EN
INFO: APIOS info[0x0]:
INFO: not config
INFO: GPIO POWER INFO:
INFO: not config
INFO: PMU_MODE_CONG: 0x1477bf79
INFO: RK3399 the wake up information:
INFO: wake up status: 0x4
INFO: GPIO interrupt wakeup
INFO: GPIO0: 0x0
INFO: GPIO1: 0x200000
INFO: GPIO2: 0x0
INFO: GPIO3: 0x0
INFO: GPIO4: 0x0
第三次休眠打印:
INFO: sleep mode config[0xfe]:
INFO: AP_PWROFF
INFO: SLP_ARMPD
INFO: SLP_PLLPD
INFO: DDR_RET
INFO: SLP_CENTER_PD
INFO: OSC_DIS
INFO: wakeup source config[0x4]:
INFO: GPIO interrupt can wakeup system
INFO: PWM CONFIG[0x4]:
INFO: PWM: PWM2D_REGULATOR_EN
INFO: APIOS info[0x0]:
INFO: not config
INFO: GPIO POWER INFO:
INFO: not config
INFO: PMU_MODE_CONG: 0x1477bf79
7.29(工作记录)
在迷失的时候,不如去选择更艰辛的那条路,因为即使是再长的路也会有尽头

rk_gmac-dwmac fe010000.ethernet eth0

rk_gmac-dwmac fe2a0000.ethernet eth1
根据原理图可知,gmac0 实际上是网口1,而gmac1实际上是网口0,这一点要注意,然后
底板引脚
| 网卡0复位 | GMAC0_RSTn_GPIO3_B7 | 111 |
|---|---|---|
| 网卡0中断 | GMAC0_INT/PMEB_GPIO3_C0 | 112 |
| 网卡1复位 | GMAC1_RSTn_GPIO3_B0 | 104 |
| 网卡1中断 | GMAC1_INT/PMEB_GPIO3_A7 | 103 |

客户底板引脚
| 网卡0复位 | GMAC0_RSTn_GPIO3_A5 | 101 |
|---|---|---|
| 网卡0中断 | GMAC0_INT/PMEB_GPIO3_A6 | 102 |
| 网卡1复位 | GMAC1_RSTn_GPIO3_B0 | 103 |
| 网卡1中断 | GMAC1_INT/PMEB_GPIO3_A7 | 104 |

关于网卡的问题就先这样了,如果想让我来解决硬件问题,那可真的太难了,听会儿音乐吧。然后来看CAN的问题,首先说一下为什么不用板载的CAN,而是使用SPI转can,这是因为SOC的canIP是有问题的,所以无可避免的就会出现问题,现在客户是用了两对SPI,两个MCP2515来转换的,具体使用的是哪个SPI转CAN呢


这个图肯定是看不出来的,而且我也不需要看他这里的转换,重要的是这个图:


mcp2515的驱动默认是在5.10中有的,编译完成如下所示:

然后开始确定硬件SPI编号。
CAN2
| 引脚标号 | 网络名 | 复用关系 | |
|---|---|---|---|
| CON4 7 | PCIE20_PERSTn_M1 | SPI1_MOSI_M1 | GPIO3_C1 |
| CON4 11 | HP_DET_L_GPIO3_C2 | SPI1_MISO_M1 | GPIO3_C2_d |
| CON4 13 | 5G_RESET | SPI1_CLK_M1 | GPIO3_C3_d |
| CON4 35 | PCIE30X1_PERSTn_M1 | SPI1_CS0_M1 | GPIO3_A1_d |
| CON2 54 | I2C3_SCL_M0 | 感觉没啥用 |


CAN1
| 引脚标号 | 网络名 | 复用关系 | |
|---|---|---|---|
| CON4 17 | PCIE20_CLKREQn_M1 | SPI0_MISO_M1 | GPIO2_D0_d |
| CON4 19 | PCIE20_WAKEn_M1 | SPI0_MOSI_M1 | GPIO2_D1_d |
| CON4 21 | PCIE30X1_CLKREQn_M1 | SPI0_CS0_M1 | GPIO2_D2_d |
| CON4 23 | PCIE30X1_WAKEn_M1 | SPI0_CLK_M1 | GPIO2_D3_d |
| CON2 37 | I2S3_MCLK_M0 | 感觉没啥用 |

clk8m: clk8m {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <40000000>;
};
&spi0 {
status = "okay";
pinctrl-0 = <&spi0m1_cs0 &spi0m1_pins>;
pinctrl-1 = <&spi0m1_cs0 &spi0m1_pins_hs>;
mcp25180: mcp25180@0 {
compatible = "microchip,mcp2518fd";
reg = <0>;
spi-max-frequency = <10000000>;
interrupts-extended = <&gpio3 RK_PA2 IRQ_TYPE_LEVEL_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&mcp2518_int0>;
clocks = <&clk8m>;
status = "okay";
};
};
&spi1 {
status = "okay";
pinctrl-0 = <&spi1m1_cs0 &spi1m1_pins>;
pinctrl-1 = <&spi1m1_cs0 &spi1m1_pins_hs>;
mcp25181: mcp25181@0 {
compatible = "microchip,mcp2518fd";
reg = <0>;
spi-max-frequency = <10000000>;
interrupts-extended = <&gpio3 RK_PA3 IRQ_TYPE_LEVEL_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&mcp2518_int1>;
clocks = <&clk8m>;
status = "okay";
};
};
mcp2518-gpio{
mcp2518_int0:mcp2518-int0 {
rockchip,pins = <3 RK_PA2 RK_FUNC_GPIO &pcfg_pull_none>;
};
mcp2518_int1:mcp2518-int1 {
rockchip,pins = <3 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>;
};
};


ip link set can0 down
ip link set can0 type can bitrate 1000000 dbitrate 3000000 fd on
ip -details link show can0
ip link set can0 up
cansend can0 123#DEADBEEF
candump can0 &



标准帧

扩展帧

ip link set can1 down
ip link set can1 type can bitrate 1000000 dbitrate 3000000 fd on
ip -details link show can1
ip link set can1 up
cansend can1 123#DEADBEEF
candump can1 &





7.31 星期三

#include <linux/clk.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/irqdesc.h>
#include <linux/irqdomain.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/cdev.h>
#include <linux/fs.h>
#include <linux/errno.h>
#include <linux/cdev.h>
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/spinlock.h>
#include <linux/interrupt.h>
/* PWM0 registers */
#define PWM_REG_CNTR 0x00 /* Counter Register */
#define PWM_REG_HPR 0x04 /* Period Register */
#define PWM_REG_LPR 0x08 /* Duty Cycle Register */
#define PWM_REG_CTRL 0x0c /* Control Register */
#define PWM3_REG_INTSTS 0x10 /* Interrupt Status Refister For Pwm3*/
#define PWM2_REG_INTSTS 0x20 /* Interrupt Status Refister For Pwm2*/
#define PWM1_REG_INTSTS 0x30 /* Interrupt Status Refister For Pwm1*/
#define PWM0_REG_INTSTS 0x40 /* Interrupt Status Refister For Pwm0*/
#define PWM3_REG_INT_EN 0x14 /* Interrupt Enable Refister For Pwm3*/
#define PWM2_REG_INT_EN 0x24 /* Interrupt Enable Refister For Pwm2*/
#define PWM1_REG_INT_EN 0x34 /* Interrupt Enable Refister For Pwm1*/
#define PWM0_REG_INT_EN 0x44 /* Interrupt Enable Refister For Pwm0*/
/*REG_CTRL bits definitions*/
#define PWM_ENABLE (1 << 0)
#define PWM_DISABLE (0 << 0)
/*operation mode*/
#define PWM_MODE_ONESHOT (0x00 << 1)
#define PWM_MODE_CONTINUMOUS (0x01 << 1)
#define PWM_MODE_CAPTURE (0x02 << 1)
/*duty cycle output polarity*/
#define PWM_DUTY_POSTIVE (0x01 << 3)
#define PWM_DUTY_NEGATIVE (0x00 << 3)
/*incative state output polarity*/
#define PWM_INACTIVE_POSTIVE (0x01 << 4)
#define PWM_INACTIVE_NEGATIVE (0x00 << 4)
/*clock source select*/
#define PWM_CLK_SCALE (1 << 9)
#define PWM_CLK_NON_SCALE (0 << 9)
#define PWM_CH0_INT (1 << 0)
#define PWM_CH1_INT (1 << 1)
#define PWM_CH2_INT (1 << 2)
#define PWM_CH3_INT (1 << 3)
#define PWM_PWR_KEY_INT (1 << 7)
#define PWM_CH0_POL (1 << 8)
#define PWM_CH1_POL (1 << 9)
#define PWM_CH2_POL (1 << 10)
#define PWM_CH3_POL (1 << 11)
#define PWM_CH0_INT_ENABLE (1 << 0)
#define PWM_CH0_INT_DISABLE (0 << 0)
#define PWM_CH1_INT_ENABLE (1 << 1)
#define PWM_CH1_INT_DISABLE (0 << 1)
#define PWM_CH2_INT_ENABLE (1 << 2)
#define PWM_CH2_INT_DISABLE (0 << 2)
#define PWM_CH3_INT_ENABLE (1 << 3)
#define PWM_CH3_INT_DISABLE (0 << 3)
#define PWM_INT_ENABLE 1
#define PWM_INT_DISABLE 0
/*prescale factor*/
#define PWMCR_MIN_PRESCALE 0x00
#define PWMCR_MAX_PRESCALE 0x07
#define PWMDCR_MIN_DUTY 0x0001
#define PWMDCR_MAX_DUTY 0xFFFF
#define PWMPCR_MIN_PERIOD 0x0001
#define PWMPCR_MAX_PERIOD 0xFFFF
#define PWMPCR_MIN_PERIOD 0x0001
#define PWMPCR_MAX_PERIOD 0xFFFF
#define PWM_REG_INTSTS(n) ((3 - (n)) * 0x10 + 0x10)
#define PWM_REG_INT_EN(n) ((3 - (n)) * 0x10 + 0x14)
#define RK_PWM_VERSION_ID(n) ((3 - (n)) * 0x10 + 0x2c)
#define PWM_REG_PWRMATCH_CTRL(n) ((3 - (n)) * 0x10 + 0x50)
#define PWM_REG_PWRMATCH_LPRE(n) ((3 - (n)) * 0x10 + 0x54)
#define PWM_REG_PWRMATCH_HPRE(n) ((3 - (n)) * 0x10 + 0x58)
#define PWM_REG_PWRMATCH_LD(n) ((3 - (n)) * 0x10 + 0x5C)
#define PWM_REG_PWRMATCH_HD_ZERO(n) ((3 - (n)) * 0x10 + 0x60)
#define PWM_REG_PWRMATCH_HD_ONE(n) ((3 - (n)) * 0x10 + 0x64)
#define PWM_PWRMATCH_VALUE(n) ((3 - (n)) * 0x10 + 0x68)
#define PWM_PWRCAPTURE_VALUE(n) ((3 - (n)) * 0x10 + 0x9c)
#define PWM_CH_INT(n) BIT(n)
#define PWM_CH_POL(n) BIT(n+8)
#define PWM_CH_INT_ENABLE(n) BIT(n)
#define PWM_PWR_INT_ENABLE BIT(7)
#define CH3_PWRKEY_ENABLE BIT(3)
struct rk_pwm_capture_data_t {
u_int64_t period_ns;
u_int64_t duty_ns;
u_int8_t capture_ms;
};
enum pwm_div {
PWM_DIV1 = (0x0 << 12),
PWM_DIV2 = (0x1 << 12),
PWM_DIV4 = (0x2 << 12),
PWM_DIV8 = (0x3 << 12),
PWM_DIV16 = (0x4 << 12),
PWM_DIV32 = (0x5 << 12),
PWM_DIV64 = (0x6 << 12),
PWM_DIV128 = (0x7 << 12),
};
static DEFINE_MUTEX(device_mutex);
typedef enum _CAP_STATE {
CAP_IDLE,
CAP_JUNK_DATA_1, // lpr/hpr junk data
CAP_JUNK_DATA_2, // hpr/lpr junk data
CAP_DATA,
CAP_DONE,
} eCAP_STATE;
struct rk_pwm_capture_sysfs_data {
dev_t devno;
char dev_name[32];
struct cdev _cdev;
struct class *_class;
struct rk_pwm_capture_data_t user_data;
};
struct rk_pwm_capture_drvdata {
void __iomem *base;
int irq;
int irq_cpu_id;
struct device dev;
int pwm_freq_nstime; // Cycle of capture clock
int pwm_channel; // RK3568 4-built-in PWM channels
int hpr; // Number of capture clock cycles at high levels in a PWM cycle to be tested
int lpr; // Number of capture clock cycles at low levels in a PWM cycle to be tested
eCAP_STATE state;
struct clk *clk;
struct clk *p_clk;
struct rk_pwm_capture_sysfs_data sdata;
};