Allows building and compile-testing the i.MX TPM driver for ARM64.
Signed-off-by: Anson Huang <[email protected]>
---
drivers/clocksource/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index f2142e6..e9e7fe1 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -617,7 +617,7 @@ config CLKSRC_IMX_GPT
config CLKSRC_IMX_TPM
bool "Clocksource using i.MX TPM" if COMPILE_TEST
- depends on ARM && CLKDEV_LOOKUP
+ depends on (ARM || ARM64) && CLKDEV_LOOKUP
select CLKSRC_MMIO
help
Enable this option to use IMX Timer/PWM Module (TPM) timer as
--
2.7.4
Select CLKSRC_IMX_TPM for ARCH_MXC by default.
Signed-off-by: Anson Huang <[email protected]>
---
arch/arm64/Kconfig.platforms | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm64/Kconfig.platforms b/arch/arm64/Kconfig.platforms
index 55d70cf..3e9011c 100644
--- a/arch/arm64/Kconfig.platforms
+++ b/arch/arm64/Kconfig.platforms
@@ -169,6 +169,7 @@ config ARCH_MXC
bool "ARMv8 based NXP i.MX SoC family"
select ARM64_ERRATUM_843419
select ARM64_ERRATUM_845719 if COMPAT
+ select CLKSRC_IMX_TPM
select IMX_GPCV2
select IMX_GPCV2_PM_DOMAINS
select PM
--
2.7.4
Hi Anson,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on arm64/for-next/core]
[also build test ERROR on tip/timers/core daniel.lezcano/clockevents/next v5.6 next-20200409]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Anson-Huang/clocksource-Add-support-for-i-MX-TPM-driver-with-ARM64/20200410-144627
base: https://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-next/core
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=9.3.0 make.cross ARCH=arm64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>
All errors (new ones prefixed by >>):
drivers/clocksource/timer-imx-tpm.c: In function 'tpm_clocksource_init':
>> drivers/clocksource/timer-imx-tpm.c:149:17: error: invalid use of undefined type 'struct delay_timer'
149 | tpm_delay_timer.read_current_timer = &tpm_read_current_timer;
| ^
drivers/clocksource/timer-imx-tpm.c:150:17: error: invalid use of undefined type 'struct delay_timer'
150 | tpm_delay_timer.freq = timer_of_rate(&to_tpm) >> 3;
| ^
>> drivers/clocksource/timer-imx-tpm.c:151:2: error: implicit declaration of function 'register_current_timer_delay' [-Werror=implicit-function-declaration]
151 | register_current_timer_delay(&tpm_delay_timer);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/clocksource/timer-imx-tpm.c: At top level:
>> drivers/clocksource/timer-imx-tpm.c:66:27: error: storage size of 'tpm_delay_timer' isn't known
66 | static struct delay_timer tpm_delay_timer;
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +149 drivers/clocksource/timer-imx-tpm.c
059ab7b82eecfc Dong Aisheng 2017-08-01 65
059ab7b82eecfc Dong Aisheng 2017-08-01 @66 static struct delay_timer tpm_delay_timer;
059ab7b82eecfc Dong Aisheng 2017-08-01 67
059ab7b82eecfc Dong Aisheng 2017-08-01 68 static inline unsigned long tpm_read_counter(void)
059ab7b82eecfc Dong Aisheng 2017-08-01 69 {
059ab7b82eecfc Dong Aisheng 2017-08-01 70 return readl(timer_base + TPM_CNT);
059ab7b82eecfc Dong Aisheng 2017-08-01 71 }
059ab7b82eecfc Dong Aisheng 2017-08-01 72
059ab7b82eecfc Dong Aisheng 2017-08-01 73 static unsigned long tpm_read_current_timer(void)
059ab7b82eecfc Dong Aisheng 2017-08-01 74 {
059ab7b82eecfc Dong Aisheng 2017-08-01 75 return tpm_read_counter();
059ab7b82eecfc Dong Aisheng 2017-08-01 76 }
059ab7b82eecfc Dong Aisheng 2017-08-01 77
059ab7b82eecfc Dong Aisheng 2017-08-01 78 static u64 notrace tpm_read_sched_clock(void)
059ab7b82eecfc Dong Aisheng 2017-08-01 79 {
059ab7b82eecfc Dong Aisheng 2017-08-01 80 return tpm_read_counter();
059ab7b82eecfc Dong Aisheng 2017-08-01 81 }
059ab7b82eecfc Dong Aisheng 2017-08-01 82
059ab7b82eecfc Dong Aisheng 2017-08-01 83 static int tpm_set_next_event(unsigned long delta,
059ab7b82eecfc Dong Aisheng 2017-08-01 84 struct clock_event_device *evt)
059ab7b82eecfc Dong Aisheng 2017-08-01 85 {
059ab7b82eecfc Dong Aisheng 2017-08-01 86 unsigned long next, now;
059ab7b82eecfc Dong Aisheng 2017-08-01 87
059ab7b82eecfc Dong Aisheng 2017-08-01 88 next = tpm_read_counter();
059ab7b82eecfc Dong Aisheng 2017-08-01 89 next += delta;
059ab7b82eecfc Dong Aisheng 2017-08-01 90 writel(next, timer_base + TPM_C0V);
059ab7b82eecfc Dong Aisheng 2017-08-01 91 now = tpm_read_counter();
059ab7b82eecfc Dong Aisheng 2017-08-01 92
059ab7b82eecfc Dong Aisheng 2017-08-01 93 /*
059ab7b82eecfc Dong Aisheng 2017-08-01 94 * NOTE: We observed in a very small probability, the bus fabric
059ab7b82eecfc Dong Aisheng 2017-08-01 95 * contention between GPU and A7 may results a few cycles delay
059ab7b82eecfc Dong Aisheng 2017-08-01 96 * of writing CNT registers which may cause the min_delta event got
059ab7b82eecfc Dong Aisheng 2017-08-01 97 * missed, so we need add a ETIME check here in case it happened.
059ab7b82eecfc Dong Aisheng 2017-08-01 98 */
7407188489c62a Anson Huang 2018-04-19 99 return (int)(next - now) <= 0 ? -ETIME : 0;
059ab7b82eecfc Dong Aisheng 2017-08-01 100 }
059ab7b82eecfc Dong Aisheng 2017-08-01 101
059ab7b82eecfc Dong Aisheng 2017-08-01 102 static int tpm_set_state_oneshot(struct clock_event_device *evt)
059ab7b82eecfc Dong Aisheng 2017-08-01 103 {
059ab7b82eecfc Dong Aisheng 2017-08-01 104 tpm_timer_enable();
059ab7b82eecfc Dong Aisheng 2017-08-01 105
059ab7b82eecfc Dong Aisheng 2017-08-01 106 return 0;
059ab7b82eecfc Dong Aisheng 2017-08-01 107 }
059ab7b82eecfc Dong Aisheng 2017-08-01 108
059ab7b82eecfc Dong Aisheng 2017-08-01 109 static int tpm_set_state_shutdown(struct clock_event_device *evt)
059ab7b82eecfc Dong Aisheng 2017-08-01 110 {
059ab7b82eecfc Dong Aisheng 2017-08-01 111 tpm_timer_disable();
059ab7b82eecfc Dong Aisheng 2017-08-01 112
059ab7b82eecfc Dong Aisheng 2017-08-01 113 return 0;
059ab7b82eecfc Dong Aisheng 2017-08-01 114 }
059ab7b82eecfc Dong Aisheng 2017-08-01 115
059ab7b82eecfc Dong Aisheng 2017-08-01 116 static irqreturn_t tpm_timer_interrupt(int irq, void *dev_id)
059ab7b82eecfc Dong Aisheng 2017-08-01 117 {
059ab7b82eecfc Dong Aisheng 2017-08-01 118 struct clock_event_device *evt = dev_id;
059ab7b82eecfc Dong Aisheng 2017-08-01 119
059ab7b82eecfc Dong Aisheng 2017-08-01 120 tpm_irq_acknowledge();
059ab7b82eecfc Dong Aisheng 2017-08-01 121
059ab7b82eecfc Dong Aisheng 2017-08-01 122 evt->event_handler(evt);
059ab7b82eecfc Dong Aisheng 2017-08-01 123
059ab7b82eecfc Dong Aisheng 2017-08-01 124 return IRQ_HANDLED;
059ab7b82eecfc Dong Aisheng 2017-08-01 125 }
059ab7b82eecfc Dong Aisheng 2017-08-01 126
3825603a807673 Anson Huang 2018-11-06 127 static struct timer_of to_tpm = {
3825603a807673 Anson Huang 2018-11-06 128 .flags = TIMER_OF_IRQ | TIMER_OF_BASE | TIMER_OF_CLOCK,
3825603a807673 Anson Huang 2018-11-06 129 .clkevt = {
059ab7b82eecfc Dong Aisheng 2017-08-01 130 .name = "i.MX7ULP TPM Timer",
3825603a807673 Anson Huang 2018-11-06 131 .rating = 200,
059ab7b82eecfc Dong Aisheng 2017-08-01 132 .features = CLOCK_EVT_FEAT_ONESHOT,
3825603a807673 Anson Huang 2018-11-06 133 .set_state_shutdown = tpm_set_state_shutdown,
059ab7b82eecfc Dong Aisheng 2017-08-01 134 .set_state_oneshot = tpm_set_state_oneshot,
059ab7b82eecfc Dong Aisheng 2017-08-01 135 .set_next_event = tpm_set_next_event,
3825603a807673 Anson Huang 2018-11-06 136 .cpumask = cpu_possible_mask,
3825603a807673 Anson Huang 2018-11-06 137 },
3825603a807673 Anson Huang 2018-11-06 138 .of_irq = {
3825603a807673 Anson Huang 2018-11-06 139 .handler = tpm_timer_interrupt,
3825603a807673 Anson Huang 2018-11-06 140 .flags = IRQF_TIMER | IRQF_IRQPOLL,
3825603a807673 Anson Huang 2018-11-06 141 },
4f352d1fc5a8d3 Anson Huang 2018-12-07 142 .of_clk = {
4f352d1fc5a8d3 Anson Huang 2018-12-07 143 .name = "per",
4f352d1fc5a8d3 Anson Huang 2018-12-07 144 },
059ab7b82eecfc Dong Aisheng 2017-08-01 145 };
059ab7b82eecfc Dong Aisheng 2017-08-01 146
3825603a807673 Anson Huang 2018-11-06 147 static int __init tpm_clocksource_init(void)
059ab7b82eecfc Dong Aisheng 2017-08-01 148 {
3825603a807673 Anson Huang 2018-11-06 @149 tpm_delay_timer.read_current_timer = &tpm_read_current_timer;
3825603a807673 Anson Huang 2018-11-06 @150 tpm_delay_timer.freq = timer_of_rate(&to_tpm) >> 3;
3825603a807673 Anson Huang 2018-11-06 @151 register_current_timer_delay(&tpm_delay_timer);
059ab7b82eecfc Dong Aisheng 2017-08-01 152
3825603a807673 Anson Huang 2018-11-06 153 sched_clock_register(tpm_read_sched_clock, counter_width,
3825603a807673 Anson Huang 2018-11-06 154 timer_of_rate(&to_tpm) >> 3);
059ab7b82eecfc Dong Aisheng 2017-08-01 155
3825603a807673 Anson Huang 2018-11-06 156 return clocksource_mmio_init(timer_base + TPM_CNT,
3825603a807673 Anson Huang 2018-11-06 157 "imx-tpm",
3825603a807673 Anson Huang 2018-11-06 158 timer_of_rate(&to_tpm) >> 3,
3825603a807673 Anson Huang 2018-11-06 159 to_tpm.clkevt.rating,
3825603a807673 Anson Huang 2018-11-06 160 counter_width,
3825603a807673 Anson Huang 2018-11-06 161 clocksource_mmio_readl_up);
059ab7b82eecfc Dong Aisheng 2017-08-01 162 }
059ab7b82eecfc Dong Aisheng 2017-08-01 163
:::::: The code at line 149 was first introduced by commit
:::::: 3825603a8076738d95b430d36896a760d7fc4909 clocksource/drivers/timer-imx-tpm: Convert the driver to timer-of
:::::: TO: Anson Huang <[email protected]>
:::::: CC: Daniel Lezcano <[email protected]>
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]
Gentle ping...
> -----Original Message-----
> From: Anson Huang <[email protected]>
> Sent: 2020??4??10?? 14:27
> To: [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]
> Cc: dl-linux-imx <[email protected]>
> Subject: [PATCH 1/2] clocksource: Add support for i.MX TPM driver with
> ARM64
>
> Allows building and compile-testing the i.MX TPM driver for ARM64.
>
> Signed-off-by: Anson Huang <[email protected]>
> ---
> drivers/clocksource/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index
> f2142e6..e9e7fe1 100644
> --- a/drivers/clocksource/Kconfig
> +++ b/drivers/clocksource/Kconfig
> @@ -617,7 +617,7 @@ config CLKSRC_IMX_GPT
>
> config CLKSRC_IMX_TPM
> bool "Clocksource using i.MX TPM" if COMPILE_TEST
> - depends on ARM && CLKDEV_LOOKUP
> + depends on (ARM || ARM64) && CLKDEV_LOOKUP
> select CLKSRC_MMIO
> help
> Enable this option to use IMX Timer/PWM Module (TPM) timer as
> --
> 2.7.4