forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/clocksource/sh_cmt.c
....@@ -1,16 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * SuperH Timer Support - CMT
34 *
45 * Copyright (C) 2008 Magnus Damm
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
146 */
157
168 #include <linux/clk.h>
....@@ -32,6 +24,10 @@
3224 #include <linux/sh_timer.h>
3325 #include <linux/slab.h>
3426 #include <linux/spinlock.h>
27
+
28
+#ifdef CONFIG_SUPERH
29
+#include <asm/platform_early.h>
30
+#endif
3531
3632 struct sh_cmt_device;
3733
....@@ -353,7 +349,7 @@
353349
354350 /*
355351 * According to the sh73a0 user's manual, as CMCNT can be operated
356
- * only by the RCLK (Pseudo 32 KHz), there's one restriction on
352
+ * only by the RCLK (Pseudo 32 kHz), there's one restriction on
357353 * modifying CMCNT register; two RCLK cycles are necessary before
358354 * this register is either read or any modification of the value
359355 * it holds is reflected in the LSI's actual operation.
....@@ -668,7 +664,7 @@
668664 return;
669665
670666 sh_cmt_stop(ch, FLAG_CLOCKSOURCE);
671
- pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
667
+ dev_pm_genpd_suspend(&ch->cmt->pdev->dev);
672668 }
673669
674670 static void sh_cmt_clocksource_resume(struct clocksource *cs)
....@@ -678,7 +674,7 @@
678674 if (!ch->cs_enabled)
679675 return;
680676
681
- pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
677
+ dev_pm_genpd_resume(&ch->cmt->pdev->dev);
682678 sh_cmt_start(ch, FLAG_CLOCKSOURCE);
683679 }
684680
....@@ -770,7 +766,7 @@
770766 {
771767 struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
772768
773
- pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev);
769
+ dev_pm_genpd_suspend(&ch->cmt->pdev->dev);
774770 clk_unprepare(ch->cmt->clk);
775771 }
776772
....@@ -779,7 +775,7 @@
779775 struct sh_cmt_channel *ch = ced_to_sh_cmt(ced);
780776
781777 clk_prepare(ch->cmt->clk);
782
- pm_genpd_syscore_poweron(&ch->cmt->pdev->dev);
778
+ dev_pm_genpd_resume(&ch->cmt->pdev->dev);
783779 }
784780
785781 static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch,
....@@ -790,11 +786,8 @@
790786 int ret;
791787
792788 irq = platform_get_irq(ch->cmt->pdev, ch->index);
793
- if (irq < 0) {
794
- dev_err(&ch->cmt->pdev->dev, "ch%u: failed to get irq\n",
795
- ch->index);
789
+ if (irq < 0)
796790 return irq;
797
- }
798791
799792 ret = request_irq(irq, sh_cmt_interrupt,
800793 IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING,
....@@ -918,7 +911,7 @@
918911 return -ENXIO;
919912 }
920913
921
- cmt->mapbase = ioremap_nocache(mem->start, resource_size(mem));
914
+ cmt->mapbase = ioremap(mem->start, resource_size(mem));
922915 if (cmt->mapbase == NULL) {
923916 dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n");
924917 return -ENXIO;
....@@ -935,14 +928,40 @@
935928 MODULE_DEVICE_TABLE(platform, sh_cmt_id_table);
936929
937930 static const struct of_device_id sh_cmt_of_table[] __maybe_unused = {
938
- { .compatible = "renesas,cmt-48", .data = &sh_cmt_info[SH_CMT_48BIT] },
931
+ {
932
+ /* deprecated, preserved for backward compatibility */
933
+ .compatible = "renesas,cmt-48",
934
+ .data = &sh_cmt_info[SH_CMT_48BIT]
935
+ },
939936 {
940937 /* deprecated, preserved for backward compatibility */
941938 .compatible = "renesas,cmt-48-gen2",
942939 .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
943940 },
944
- { .compatible = "renesas,rcar-gen2-cmt0", .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] },
945
- { .compatible = "renesas,rcar-gen2-cmt1", .data = &sh_cmt_info[SH_CMT1_RCAR_GEN2] },
941
+ {
942
+ .compatible = "renesas,r8a7740-cmt1",
943
+ .data = &sh_cmt_info[SH_CMT_48BIT]
944
+ },
945
+ {
946
+ .compatible = "renesas,sh73a0-cmt1",
947
+ .data = &sh_cmt_info[SH_CMT_48BIT]
948
+ },
949
+ {
950
+ .compatible = "renesas,rcar-gen2-cmt0",
951
+ .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
952
+ },
953
+ {
954
+ .compatible = "renesas,rcar-gen2-cmt1",
955
+ .data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
956
+ },
957
+ {
958
+ .compatible = "renesas,rcar-gen3-cmt0",
959
+ .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2]
960
+ },
961
+ {
962
+ .compatible = "renesas,rcar-gen3-cmt1",
963
+ .data = &sh_cmt_info[SH_CMT1_RCAR_GEN2]
964
+ },
946965 { }
947966 };
948967 MODULE_DEVICE_TABLE(of, sh_cmt_of_table);
....@@ -1043,7 +1062,7 @@
10431062 struct sh_cmt_device *cmt = platform_get_drvdata(pdev);
10441063 int ret;
10451064
1046
- if (!is_early_platform_device(pdev)) {
1065
+ if (!is_sh_early_platform_device(pdev)) {
10471066 pm_runtime_set_active(&pdev->dev);
10481067 pm_runtime_enable(&pdev->dev);
10491068 }
....@@ -1063,7 +1082,7 @@
10631082 pm_runtime_idle(&pdev->dev);
10641083 return ret;
10651084 }
1066
- if (is_early_platform_device(pdev))
1085
+ if (is_sh_early_platform_device(pdev))
10671086 return 0;
10681087
10691088 out:
....@@ -1100,7 +1119,10 @@
11001119 platform_driver_unregister(&sh_cmt_device_driver);
11011120 }
11021121
1103
-early_platform_init("earlytimer", &sh_cmt_device_driver);
1122
+#ifdef CONFIG_SUPERH
1123
+sh_early_platform_init("earlytimer", &sh_cmt_device_driver);
1124
+#endif
1125
+
11041126 subsys_initcall(sh_cmt_init);
11051127 module_exit(sh_cmt_exit);
11061128