aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/timer-imx-tpm.c
Commit message (Collapse)AuthorAgeFilesLines
* clocksource/drivers/imx-tpm: Fix next event not taking effect sometimeJacky Bai2024-09-021-0/+8
| | | | | | | | | | | | | | | | | | The value written into the TPM CnV can only be updated into the hardware when the counter increases. Additional writes to the CnV write buffer are ignored until the register has been updated. Therefore, we need to check if the CnV has been updated before continuing. This may require waiting for 1 counter cycle in the worst case. Cc: [email protected] Fixes: 059ab7b82eec ("clocksource/drivers/imx-tpm: Add imx tpm timer support") Signed-off-by: Jacky Bai <[email protected]> Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Ye Li <[email protected]> Reviewed-by: Jason Liu <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Fix return -ETIME when delta exceeds INT_MAXJacky Bai2024-09-021-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In tpm_set_next_event(delta), return -ETIME by wrong cast to int when delta is larger than INT_MAX. For example: tpm_set_next_event(delta = 0xffff_fffe) { ... next = tpm_read_counter(); // assume next is 0x10 next += delta; // next will 0xffff_fffe + 0x10 = 0x1_0000_000e now = tpm_read_counter(); // now is 0x10 ... return (int)(next - now) <= 0 ? -ETIME : 0; ^^^^^^^^^^ 0x1_0000_000e - 0x10 = 0xffff_fffe, which is -2 when cast to int. So return -ETIME. } To fix this, introduce a 'prev' variable and check if 'now - prev' is larger than delta. Cc: [email protected] Fixes: 059ab7b82eec ("clocksource/drivers/imx-tpm: Add imx tpm timer support") Signed-off-by: Jacky Bai <[email protected]> Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Ye Li <[email protected]> Reviewed-by: Jason Liu <[email protected]> Signed-off-by: Frank Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Move tpm_read_sched_clock() under CONFIG_ARMNathan Chancellor2022-03-071-1/+1
| | | | | | | | | | | | | | | | | | When building this driver for an architecture other than ARCH=arm: drivers/clocksource/timer-imx-tpm.c:78:20: error: unused function 'tpm_read_sched_clock' [-Werror,-Wunused-function] static u64 notrace tpm_read_sched_clock(void) ^ 1 error generated. Move the function definition under the existing CONFIG_ARM section so there is no more warning. Fixes: 10720e120e2b ("clocksource/drivers/imx-tpm: Exclude sched clock for ARM64") Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Exclude sched clock for ARM64Peng Fan2022-02-161-1/+1
| | | | | | | | | | | | For ARM64 platform such as i.MX8ULP which has ARMv8 generic timer as sched clock, which is much faster compared with tpm sched clock. Reading the tpm count register in i.MX8ULP requires about 290ns, this is slow and introduce scheduler latency. So exclude tpm sched clock for ARM64 platform. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Update name of clkevtPeng Fan2022-01-261-1/+1
| | | | | | | | | The tpm driver is not only for i.MX7ULP now, i.MX8ULP also use it. It maybe also used by other i.MX variants, so update name to reflect it. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Add CLOCK_EVT_FEAT_DYNIRQPeng Fan2022-01-261-1/+1
| | | | | | | | | | | | Add CLOCK_EVT_FEAT_DYNIRQ to allow the IRQ could be runtime set affinity to the cores that needs wake up, otherwise saying core0 has to send IPI to wakeup core1. With CLOCK_EVT_FEAT_DYNIRQ set, when broadcast timer could wake up the cores, IPI is not needed. Acked-by: Jacky Bai <[email protected]> Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Mark two variable with __ro_after_initPeng Fan2022-01-261-2/+2
| | | | | | | | | counter_width and timer_base will not be updated after init, so mark as __ro_after_init. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Drop IRQF_IRQPOLLPeng Fan2022-01-261-1/+1
| | | | | | | | | | | | Per the Documentation, IRQF_IRQPOLL is used for polling (only the interrupt that is registered first in a shared interrupt is considered for performance reasons) The TPM timer is not sharing interrupt with others, and pass irqpoll not make sense for i.MX platform. Signed-off-by: Peng Fan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Add support for ARM64Anson Huang2020-04-091-2/+6
| | | | | | | | | Allows building and compile-testing the i.MX TPM driver also for ARM64. The delay_timer is only supported on ARMv7. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
* clocksource/drivers/imx-tpm: Remove unused includesAnson Huang2020-03-171-2/+0
| | | | | | | | There is nothing in use from of_address.h/of_irq.h, remove them. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]> Link: https://lore.kernel.org/r/[email protected]
* clocksource/drivers/timer-imx-tpm: Specify clock name for timer-ofAnson Huang2018-12-181-0/+3
| | | | | | | | | | | | | | i.MX TPM needs "ipg" clock for register access and "per" clock for timer function, the driver gets "ipg" clock by searching the clock name, but timer-of initialization will get first clock in device tree TPM node since no clock name specified in of_clk, that means the "per" clock MUST be the first clock entry in device tree TPM node, this patch specifies clock name for of_clk to avoid this restriction, it makes TPM driver work properly with different sequence of clock entries in device tree TPM node. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/timer-imx-tpm: Convert the driver to timer-ofAnson Huang2018-12-181-81/+55
| | | | | | | | | Convert the driver to use the timer_of helpers. This allows to handle timer base, clock and irq using common timer_of driver and it simplifies the code. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/timer-imx-tpm: Switch to SPDX identifierFabio Estevam2018-05-231-9/+4
| | | | | | | | Adopt the SPDX license identifier headers to ease license compliance management. Signed-off-by: Fabio Estevam <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/imx-tpm: Correct -ETIME return condition checkAnson Huang2018-04-191-1/+1
| | | | | | | | | | | | | | | | | | | The additional brakects added to tpm_set_next_event's return value computation causes (int) forced type conversion NOT taking effect, and the incorrect value return will cause various system timer issue, like RCU stall etc.. Remove the additional brackets to make sure tpm_set_next_event always returns correct value. Fixes: 059ab7b82eec ("clocksource/drivers/imx-tpm: Add imx tpm timer support") Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Dong Aisheng <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
* clocksource/drivers/imx-tpm: Add different counter width supportAnson Huang2018-03-301-8/+25
| | | | | | | | | | Different TPM modules have different width counters which is 16-bit or 32-bit, the counter width can be read from TPM_PARAM register bit[23:16], this patch adds dynamic check for counter width to support both 16-bit and 32-bit TPM modules. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Correct some registers operation flowAnson Huang2018-03-301-1/+7
| | | | | | | | | According to i.MX7ULP reference manual, TPM_SC_CPWMS can ONLY be written when counter is disabled, TPM_SC_TOF is write-1-clear, TPM_C0SC_CHF is also write-1-clear, correct these registers initialization flow; Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Fix typo of clock nameAnson Huang2018-03-301-1/+1
| | | | | | | The clock name should be ipg instead of igp. Signed-off-by: Anson Huang <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>
* clocksource/drivers/imx-tpm: Add imx tpm timer supportDong Aisheng2017-08-291-0/+239
IMX Timer/PWM Module (TPM) supports both timer and pwm function while this patch only adds the timer support. PWM would be added later. The TPM counter, compare and capture registers are clocked by an asynchronous clock that can remain enabled in low power modes. NOTE: We observed in a very small probability, the bus fabric contention between GPU and A7 may results a few cycles delay of writing CNT registers which may cause the min_delta event got missed, so we need add a ETIME check here in case it happened. Cc: Daniel Lezcano <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Anson Huang <[email protected]> Cc: Bai Ping <[email protected]> Signed-off-by: Dong Aisheng <[email protected]> Signed-off-by: Daniel Lezcano <[email protected]>