| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * SuperH Timer Support - CMT |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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. |
|---|
| 14 | 6 | */ |
|---|
| 15 | 7 | |
|---|
| 16 | 8 | #include <linux/clk.h> |
|---|
| .. | .. |
|---|
| 32 | 24 | #include <linux/sh_timer.h> |
|---|
| 33 | 25 | #include <linux/slab.h> |
|---|
| 34 | 26 | #include <linux/spinlock.h> |
|---|
| 27 | + |
|---|
| 28 | +#ifdef CONFIG_SUPERH |
|---|
| 29 | +#include <asm/platform_early.h> |
|---|
| 30 | +#endif |
|---|
| 35 | 31 | |
|---|
| 36 | 32 | struct sh_cmt_device; |
|---|
| 37 | 33 | |
|---|
| .. | .. |
|---|
| 353 | 349 | |
|---|
| 354 | 350 | /* |
|---|
| 355 | 351 | * 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 |
|---|
| 357 | 353 | * modifying CMCNT register; two RCLK cycles are necessary before |
|---|
| 358 | 354 | * this register is either read or any modification of the value |
|---|
| 359 | 355 | * it holds is reflected in the LSI's actual operation. |
|---|
| .. | .. |
|---|
| 668 | 664 | return; |
|---|
| 669 | 665 | |
|---|
| 670 | 666 | sh_cmt_stop(ch, FLAG_CLOCKSOURCE); |
|---|
| 671 | | - pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); |
|---|
| 667 | + dev_pm_genpd_suspend(&ch->cmt->pdev->dev); |
|---|
| 672 | 668 | } |
|---|
| 673 | 669 | |
|---|
| 674 | 670 | static void sh_cmt_clocksource_resume(struct clocksource *cs) |
|---|
| .. | .. |
|---|
| 678 | 674 | if (!ch->cs_enabled) |
|---|
| 679 | 675 | return; |
|---|
| 680 | 676 | |
|---|
| 681 | | - pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); |
|---|
| 677 | + dev_pm_genpd_resume(&ch->cmt->pdev->dev); |
|---|
| 682 | 678 | sh_cmt_start(ch, FLAG_CLOCKSOURCE); |
|---|
| 683 | 679 | } |
|---|
| 684 | 680 | |
|---|
| .. | .. |
|---|
| 770 | 766 | { |
|---|
| 771 | 767 | struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); |
|---|
| 772 | 768 | |
|---|
| 773 | | - pm_genpd_syscore_poweroff(&ch->cmt->pdev->dev); |
|---|
| 769 | + dev_pm_genpd_suspend(&ch->cmt->pdev->dev); |
|---|
| 774 | 770 | clk_unprepare(ch->cmt->clk); |
|---|
| 775 | 771 | } |
|---|
| 776 | 772 | |
|---|
| .. | .. |
|---|
| 779 | 775 | struct sh_cmt_channel *ch = ced_to_sh_cmt(ced); |
|---|
| 780 | 776 | |
|---|
| 781 | 777 | clk_prepare(ch->cmt->clk); |
|---|
| 782 | | - pm_genpd_syscore_poweron(&ch->cmt->pdev->dev); |
|---|
| 778 | + dev_pm_genpd_resume(&ch->cmt->pdev->dev); |
|---|
| 783 | 779 | } |
|---|
| 784 | 780 | |
|---|
| 785 | 781 | static int sh_cmt_register_clockevent(struct sh_cmt_channel *ch, |
|---|
| .. | .. |
|---|
| 790 | 786 | int ret; |
|---|
| 791 | 787 | |
|---|
| 792 | 788 | 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) |
|---|
| 796 | 790 | return irq; |
|---|
| 797 | | - } |
|---|
| 798 | 791 | |
|---|
| 799 | 792 | ret = request_irq(irq, sh_cmt_interrupt, |
|---|
| 800 | 793 | IRQF_TIMER | IRQF_IRQPOLL | IRQF_NOBALANCING, |
|---|
| .. | .. |
|---|
| 918 | 911 | return -ENXIO; |
|---|
| 919 | 912 | } |
|---|
| 920 | 913 | |
|---|
| 921 | | - cmt->mapbase = ioremap_nocache(mem->start, resource_size(mem)); |
|---|
| 914 | + cmt->mapbase = ioremap(mem->start, resource_size(mem)); |
|---|
| 922 | 915 | if (cmt->mapbase == NULL) { |
|---|
| 923 | 916 | dev_err(&cmt->pdev->dev, "failed to remap I/O memory\n"); |
|---|
| 924 | 917 | return -ENXIO; |
|---|
| .. | .. |
|---|
| 935 | 928 | MODULE_DEVICE_TABLE(platform, sh_cmt_id_table); |
|---|
| 936 | 929 | |
|---|
| 937 | 930 | 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 | + }, |
|---|
| 939 | 936 | { |
|---|
| 940 | 937 | /* deprecated, preserved for backward compatibility */ |
|---|
| 941 | 938 | .compatible = "renesas,cmt-48-gen2", |
|---|
| 942 | 939 | .data = &sh_cmt_info[SH_CMT0_RCAR_GEN2] |
|---|
| 943 | 940 | }, |
|---|
| 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 | + }, |
|---|
| 946 | 965 | { } |
|---|
| 947 | 966 | }; |
|---|
| 948 | 967 | MODULE_DEVICE_TABLE(of, sh_cmt_of_table); |
|---|
| .. | .. |
|---|
| 1043 | 1062 | struct sh_cmt_device *cmt = platform_get_drvdata(pdev); |
|---|
| 1044 | 1063 | int ret; |
|---|
| 1045 | 1064 | |
|---|
| 1046 | | - if (!is_early_platform_device(pdev)) { |
|---|
| 1065 | + if (!is_sh_early_platform_device(pdev)) { |
|---|
| 1047 | 1066 | pm_runtime_set_active(&pdev->dev); |
|---|
| 1048 | 1067 | pm_runtime_enable(&pdev->dev); |
|---|
| 1049 | 1068 | } |
|---|
| .. | .. |
|---|
| 1063 | 1082 | pm_runtime_idle(&pdev->dev); |
|---|
| 1064 | 1083 | return ret; |
|---|
| 1065 | 1084 | } |
|---|
| 1066 | | - if (is_early_platform_device(pdev)) |
|---|
| 1085 | + if (is_sh_early_platform_device(pdev)) |
|---|
| 1067 | 1086 | return 0; |
|---|
| 1068 | 1087 | |
|---|
| 1069 | 1088 | out: |
|---|
| .. | .. |
|---|
| 1100 | 1119 | platform_driver_unregister(&sh_cmt_device_driver); |
|---|
| 1101 | 1120 | } |
|---|
| 1102 | 1121 | |
|---|
| 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 | + |
|---|
| 1104 | 1126 | subsys_initcall(sh_cmt_init); |
|---|
| 1105 | 1127 | module_exit(sh_cmt_exit); |
|---|
| 1106 | 1128 | |
|---|