Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'spacemit-reset-for-6.17-1' of https://github.com/spacemit-com/linux

RISC-V SpacemiT Reset for 6.17

- Add reset driver support for K1 SoC

* tag 'spacemit-reset-for-6.17-1':
reset: spacemit: add support for SpacemiT CCU resets
clk: spacemit: define three reset-only CCUs
clk: spacemit: set up reset auxiliary devices
soc: spacemit: create a header for clock/reset registers
dt-bindings: soc: spacemit: define spacemit,k1-ccu resets

Signed-off-by: Yixun Lan <dlan@gentoo.org>

Yixun Lan c79550f6 7554729d

+757 -127
+22 -7
Documentation/devicetree/bindings/soc/spacemit/spacemit,k1-syscon.yaml
··· 19 19 - spacemit,k1-syscon-apbc 20 20 - spacemit,k1-syscon-apmu 21 21 - spacemit,k1-syscon-mpmu 22 + - spacemit,k1-syscon-rcpu 23 + - spacemit,k1-syscon-rcpu2 24 + - spacemit,k1-syscon-apbc2 22 25 23 26 reg: 24 27 maxItems: 1 ··· 50 47 required: 51 48 - compatible 52 49 - reg 53 - - clocks 54 - - clock-names 55 - - "#clock-cells" 56 50 - "#reset-cells" 57 51 58 52 allOf: ··· 57 57 properties: 58 58 compatible: 59 59 contains: 60 - const: spacemit,k1-syscon-apbc 60 + enum: 61 + - spacemit,k1-syscon-apmu 62 + - spacemit,k1-syscon-mpmu 61 63 then: 62 - properties: 63 - "#power-domain-cells": false 64 - else: 65 64 required: 66 65 - "#power-domain-cells" 66 + else: 67 + properties: 68 + "#power-domain-cells": false 69 + - if: 70 + properties: 71 + compatible: 72 + contains: 73 + enum: 74 + - spacemit,k1-syscon-apbc 75 + - spacemit,k1-syscon-apmu 76 + - spacemit,k1-syscon-mpmu 77 + then: 78 + required: 79 + - clocks 80 + - clock-names 81 + - "#clock-cells" 67 82 68 83 additionalProperties: false 69 84
+1
drivers/clk/spacemit/Kconfig
··· 3 3 config SPACEMIT_CCU 4 4 tristate "Clock support for SpacemiT SoCs" 5 5 depends on ARCH_SPACEMIT || COMPILE_TEST 6 + select AUXILIARY_BUS 6 7 select MFD_SYSCON 7 8 help 8 9 Say Y to enable clock controller unit support for SpacemiT SoCs.
+119 -120
drivers/clk/spacemit/ccu-k1.c
··· 5 5 */ 6 6 7 7 #include <linux/array_size.h> 8 + #include <linux/auxiliary_bus.h> 8 9 #include <linux/clk-provider.h> 9 10 #include <linux/delay.h> 11 + #include <linux/idr.h> 10 12 #include <linux/mfd/syscon.h> 11 13 #include <linux/minmax.h> 12 14 #include <linux/module.h> 13 15 #include <linux/platform_device.h> 16 + #include <linux/slab.h> 17 + #include <soc/spacemit/k1-syscon.h> 14 18 15 19 #include "ccu_common.h" 16 20 #include "ccu_pll.h" ··· 23 19 24 20 #include <dt-bindings/clock/spacemit,k1-syscon.h> 25 21 26 - /* APBS register offset */ 27 - #define APBS_PLL1_SWCR1 0x100 28 - #define APBS_PLL1_SWCR2 0x104 29 - #define APBS_PLL1_SWCR3 0x108 30 - #define APBS_PLL2_SWCR1 0x118 31 - #define APBS_PLL2_SWCR2 0x11c 32 - #define APBS_PLL2_SWCR3 0x120 33 - #define APBS_PLL3_SWCR1 0x124 34 - #define APBS_PLL3_SWCR2 0x128 35 - #define APBS_PLL3_SWCR3 0x12c 36 - 37 - /* MPMU register offset */ 38 - #define MPMU_POSR 0x0010 39 - #define POSR_PLL1_LOCK BIT(27) 40 - #define POSR_PLL2_LOCK BIT(28) 41 - #define POSR_PLL3_LOCK BIT(29) 42 - #define MPMU_SUCCR 0x0014 43 - #define MPMU_ISCCR 0x0044 44 - #define MPMU_WDTPCR 0x0200 45 - #define MPMU_RIPCCR 0x0210 46 - #define MPMU_ACGR 0x1024 47 - #define MPMU_APBCSCR 0x1050 48 - #define MPMU_SUCCR_1 0x10b0 49 - 50 - /* APBC register offset */ 51 - #define APBC_UART1_CLK_RST 0x00 52 - #define APBC_UART2_CLK_RST 0x04 53 - #define APBC_GPIO_CLK_RST 0x08 54 - #define APBC_PWM0_CLK_RST 0x0c 55 - #define APBC_PWM1_CLK_RST 0x10 56 - #define APBC_PWM2_CLK_RST 0x14 57 - #define APBC_PWM3_CLK_RST 0x18 58 - #define APBC_TWSI8_CLK_RST 0x20 59 - #define APBC_UART3_CLK_RST 0x24 60 - #define APBC_RTC_CLK_RST 0x28 61 - #define APBC_TWSI0_CLK_RST 0x2c 62 - #define APBC_TWSI1_CLK_RST 0x30 63 - #define APBC_TIMERS1_CLK_RST 0x34 64 - #define APBC_TWSI2_CLK_RST 0x38 65 - #define APBC_AIB_CLK_RST 0x3c 66 - #define APBC_TWSI4_CLK_RST 0x40 67 - #define APBC_TIMERS2_CLK_RST 0x44 68 - #define APBC_ONEWIRE_CLK_RST 0x48 69 - #define APBC_TWSI5_CLK_RST 0x4c 70 - #define APBC_DRO_CLK_RST 0x58 71 - #define APBC_IR_CLK_RST 0x5c 72 - #define APBC_TWSI6_CLK_RST 0x60 73 - #define APBC_COUNTER_CLK_SEL 0x64 74 - #define APBC_TWSI7_CLK_RST 0x68 75 - #define APBC_TSEN_CLK_RST 0x6c 76 - #define APBC_UART4_CLK_RST 0x70 77 - #define APBC_UART5_CLK_RST 0x74 78 - #define APBC_UART6_CLK_RST 0x78 79 - #define APBC_SSP3_CLK_RST 0x7c 80 - #define APBC_SSPA0_CLK_RST 0x80 81 - #define APBC_SSPA1_CLK_RST 0x84 82 - #define APBC_IPC_AP2AUD_CLK_RST 0x90 83 - #define APBC_UART7_CLK_RST 0x94 84 - #define APBC_UART8_CLK_RST 0x98 85 - #define APBC_UART9_CLK_RST 0x9c 86 - #define APBC_CAN0_CLK_RST 0xa0 87 - #define APBC_PWM4_CLK_RST 0xa8 88 - #define APBC_PWM5_CLK_RST 0xac 89 - #define APBC_PWM6_CLK_RST 0xb0 90 - #define APBC_PWM7_CLK_RST 0xb4 91 - #define APBC_PWM8_CLK_RST 0xb8 92 - #define APBC_PWM9_CLK_RST 0xbc 93 - #define APBC_PWM10_CLK_RST 0xc0 94 - #define APBC_PWM11_CLK_RST 0xc4 95 - #define APBC_PWM12_CLK_RST 0xc8 96 - #define APBC_PWM13_CLK_RST 0xcc 97 - #define APBC_PWM14_CLK_RST 0xd0 98 - #define APBC_PWM15_CLK_RST 0xd4 99 - #define APBC_PWM16_CLK_RST 0xd8 100 - #define APBC_PWM17_CLK_RST 0xdc 101 - #define APBC_PWM18_CLK_RST 0xe0 102 - #define APBC_PWM19_CLK_RST 0xe4 103 - 104 - /* APMU register offset */ 105 - #define APMU_JPG_CLK_RES_CTRL 0x020 106 - #define APMU_CSI_CCIC2_CLK_RES_CTRL 0x024 107 - #define APMU_ISP_CLK_RES_CTRL 0x038 108 - #define APMU_LCD_CLK_RES_CTRL1 0x044 109 - #define APMU_LCD_SPI_CLK_RES_CTRL 0x048 110 - #define APMU_LCD_CLK_RES_CTRL2 0x04c 111 - #define APMU_CCIC_CLK_RES_CTRL 0x050 112 - #define APMU_SDH0_CLK_RES_CTRL 0x054 113 - #define APMU_SDH1_CLK_RES_CTRL 0x058 114 - #define APMU_USB_CLK_RES_CTRL 0x05c 115 - #define APMU_QSPI_CLK_RES_CTRL 0x060 116 - #define APMU_DMA_CLK_RES_CTRL 0x064 117 - #define APMU_AES_CLK_RES_CTRL 0x068 118 - #define APMU_VPU_CLK_RES_CTRL 0x0a4 119 - #define APMU_GPU_CLK_RES_CTRL 0x0cc 120 - #define APMU_SDH2_CLK_RES_CTRL 0x0e0 121 - #define APMU_PMUA_MC_CTRL 0x0e8 122 - #define APMU_PMU_CC2_AP 0x100 123 - #define APMU_PMUA_EM_CLK_RES_CTRL 0x104 124 - #define APMU_AUDIO_CLK_RES_CTRL 0x14c 125 - #define APMU_HDMI_CLK_RES_CTRL 0x1b8 126 - #define APMU_CCI550_CLK_CTRL 0x300 127 - #define APMU_ACLK_CLK_CTRL 0x388 128 - #define APMU_CPU_C0_CLK_CTRL 0x38C 129 - #define APMU_CPU_C1_CLK_CTRL 0x390 130 - #define APMU_PCIE_CLK_RES_CTRL_0 0x3cc 131 - #define APMU_PCIE_CLK_RES_CTRL_1 0x3d4 132 - #define APMU_PCIE_CLK_RES_CTRL_2 0x3dc 133 - #define APMU_EMAC0_CLK_RES_CTRL 0x3e4 134 - #define APMU_EMAC1_CLK_RES_CTRL 0x3ec 135 - 136 22 struct spacemit_ccu_data { 23 + const char *reset_name; 137 24 struct clk_hw **hws; 138 25 size_t num; 139 26 }; 27 + 28 + static DEFINE_IDA(auxiliary_ids); 140 29 141 30 /* APBS clocks start, APBS region contains and only contains all PLL clocks */ 142 31 ··· 717 820 }; 718 821 719 822 static const struct spacemit_ccu_data k1_ccu_pll_data = { 720 - .hws = k1_ccu_pll_hws, 721 - .num = ARRAY_SIZE(k1_ccu_pll_hws), 823 + /* The PLL CCU implements no resets */ 824 + .hws = k1_ccu_pll_hws, 825 + .num = ARRAY_SIZE(k1_ccu_pll_hws), 722 826 }; 723 827 724 828 static struct clk_hw *k1_ccu_mpmu_hws[] = { ··· 759 861 }; 760 862 761 863 static const struct spacemit_ccu_data k1_ccu_mpmu_data = { 762 - .hws = k1_ccu_mpmu_hws, 763 - .num = ARRAY_SIZE(k1_ccu_mpmu_hws), 864 + .reset_name = "mpmu-reset", 865 + .hws = k1_ccu_mpmu_hws, 866 + .num = ARRAY_SIZE(k1_ccu_mpmu_hws), 764 867 }; 765 868 766 869 static struct clk_hw *k1_ccu_apbc_hws[] = { ··· 868 969 }; 869 970 870 971 static const struct spacemit_ccu_data k1_ccu_apbc_data = { 871 - .hws = k1_ccu_apbc_hws, 872 - .num = ARRAY_SIZE(k1_ccu_apbc_hws), 972 + .reset_name = "apbc-reset", 973 + .hws = k1_ccu_apbc_hws, 974 + .num = ARRAY_SIZE(k1_ccu_apbc_hws), 873 975 }; 874 976 875 977 static struct clk_hw *k1_ccu_apmu_hws[] = { ··· 939 1039 }; 940 1040 941 1041 static const struct spacemit_ccu_data k1_ccu_apmu_data = { 942 - .hws = k1_ccu_apmu_hws, 943 - .num = ARRAY_SIZE(k1_ccu_apmu_hws), 1042 + .reset_name = "apmu-reset", 1043 + .hws = k1_ccu_apmu_hws, 1044 + .num = ARRAY_SIZE(k1_ccu_apmu_hws), 1045 + }; 1046 + 1047 + static const struct spacemit_ccu_data k1_ccu_rcpu_data = { 1048 + .reset_name = "rcpu-reset", 1049 + }; 1050 + 1051 + static const struct spacemit_ccu_data k1_ccu_rcpu2_data = { 1052 + .reset_name = "rcpu2-reset", 1053 + }; 1054 + 1055 + static const struct spacemit_ccu_data k1_ccu_apbc2_data = { 1056 + .reset_name = "apbc2-reset", 944 1057 }; 945 1058 946 1059 static int spacemit_ccu_register(struct device *dev, ··· 963 1050 { 964 1051 struct clk_hw_onecell_data *clk_data; 965 1052 int i, ret; 1053 + 1054 + /* Nothing to do if the CCU does not implement any clocks */ 1055 + if (!data->hws) 1056 + return 0; 966 1057 967 1058 clk_data = devm_kzalloc(dev, struct_size(clk_data, hws, data->num), 968 1059 GFP_KERNEL); ··· 1008 1091 return ret; 1009 1092 } 1010 1093 1094 + static void spacemit_cadev_release(struct device *dev) 1095 + { 1096 + struct auxiliary_device *adev = to_auxiliary_dev(dev); 1097 + 1098 + ida_free(&auxiliary_ids, adev->id); 1099 + kfree(to_spacemit_ccu_adev(adev)); 1100 + } 1101 + 1102 + static void spacemit_adev_unregister(void *data) 1103 + { 1104 + struct auxiliary_device *adev = data; 1105 + 1106 + auxiliary_device_delete(adev); 1107 + auxiliary_device_uninit(adev); 1108 + } 1109 + 1110 + static int spacemit_ccu_reset_register(struct device *dev, 1111 + struct regmap *regmap, 1112 + const char *reset_name) 1113 + { 1114 + struct spacemit_ccu_adev *cadev; 1115 + struct auxiliary_device *adev; 1116 + int ret; 1117 + 1118 + /* Nothing to do if the CCU does not implement a reset controller */ 1119 + if (!reset_name) 1120 + return 0; 1121 + 1122 + cadev = kzalloc(sizeof(*cadev), GFP_KERNEL); 1123 + if (!cadev) 1124 + return -ENOMEM; 1125 + 1126 + cadev->regmap = regmap; 1127 + 1128 + adev = &cadev->adev; 1129 + adev->name = reset_name; 1130 + adev->dev.parent = dev; 1131 + adev->dev.release = spacemit_cadev_release; 1132 + adev->dev.of_node = dev->of_node; 1133 + ret = ida_alloc(&auxiliary_ids, GFP_KERNEL); 1134 + if (ret < 0) 1135 + goto err_free_cadev; 1136 + adev->id = ret; 1137 + 1138 + ret = auxiliary_device_init(adev); 1139 + if (ret) 1140 + goto err_free_aux_id; 1141 + 1142 + ret = auxiliary_device_add(adev); 1143 + if (ret) { 1144 + auxiliary_device_uninit(adev); 1145 + return ret; 1146 + } 1147 + 1148 + return devm_add_action_or_reset(dev, spacemit_adev_unregister, adev); 1149 + 1150 + err_free_aux_id: 1151 + ida_free(&auxiliary_ids, adev->id); 1152 + err_free_cadev: 1153 + kfree(cadev); 1154 + 1155 + return ret; 1156 + } 1157 + 1011 1158 static int k1_ccu_probe(struct platform_device *pdev) 1012 1159 { 1013 1160 struct regmap *base_regmap, *lock_regmap = NULL; 1161 + const struct spacemit_ccu_data *data; 1014 1162 struct device *dev = &pdev->dev; 1015 1163 int ret; 1016 1164 ··· 1104 1122 "failed to get lock regmap\n"); 1105 1123 } 1106 1124 1107 - ret = spacemit_ccu_register(dev, base_regmap, lock_regmap, 1108 - of_device_get_match_data(dev)); 1125 + data = of_device_get_match_data(dev); 1126 + 1127 + ret = spacemit_ccu_register(dev, base_regmap, lock_regmap, data); 1109 1128 if (ret) 1110 1129 return dev_err_probe(dev, ret, "failed to register clocks\n"); 1130 + 1131 + ret = spacemit_ccu_reset_register(dev, base_regmap, data->reset_name); 1132 + if (ret) 1133 + return dev_err_probe(dev, ret, "failed to register resets\n"); 1111 1134 1112 1135 return 0; 1113 1136 } ··· 1133 1146 { 1134 1147 .compatible = "spacemit,k1-syscon-apmu", 1135 1148 .data = &k1_ccu_apmu_data, 1149 + }, 1150 + { 1151 + .compatible = "spacemit,k1-syscon-rcpu", 1152 + .data = &k1_ccu_rcpu_data, 1153 + }, 1154 + { 1155 + .compatible = "spacemit,k1-syscon-rcpu2", 1156 + .data = &k1_ccu_rcpu2_data, 1157 + }, 1158 + { 1159 + .compatible = "spacemit,k1-syscon-apbc2", 1160 + .data = &k1_ccu_apbc2_data, 1136 1161 }, 1137 1162 { } 1138 1163 };
+9
drivers/reset/Kconfig
··· 270 270 This enables the reset driver for the SoCFPGA ARMv7 platforms. This 271 271 driver gets initialized early during platform init calls. 272 272 273 + config RESET_SPACEMIT 274 + tristate "SpacemiT reset driver" 275 + depends on ARCH_SPACEMIT || COMPILE_TEST 276 + select AUXILIARY_BUS 277 + default ARCH_SPACEMIT 278 + help 279 + This enables the reset controller driver for SpacemiT SoCs, 280 + including the K1. 281 + 273 282 config RESET_SUNPLUS 274 283 bool "Sunplus SoCs Reset Driver" if COMPILE_TEST 275 284 default ARCH_SUNPLUS
+1
drivers/reset/Makefile
··· 35 35 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o 36 36 obj-$(CONFIG_RESET_SIMPLE) += reset-simple.o 37 37 obj-$(CONFIG_RESET_SOCFPGA) += reset-socfpga.o 38 + obj-$(CONFIG_RESET_SPACEMIT) += reset-spacemit.o 38 39 obj-$(CONFIG_RESET_SUNPLUS) += reset-sunplus.o 39 40 obj-$(CONFIG_RESET_SUNXI) += reset-sunxi.o 40 41 obj-$(CONFIG_RESET_TH1520) += reset-th1520.o
+304
drivers/reset/reset-spacemit.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + 3 + /* SpacemiT reset controller driver */ 4 + 5 + #include <linux/auxiliary_bus.h> 6 + #include <linux/container_of.h> 7 + #include <linux/device.h> 8 + #include <linux/module.h> 9 + #include <linux/regmap.h> 10 + #include <linux/reset-controller.h> 11 + #include <linux/types.h> 12 + 13 + #include <soc/spacemit/k1-syscon.h> 14 + #include <dt-bindings/clock/spacemit,k1-syscon.h> 15 + 16 + struct ccu_reset_data { 17 + u32 offset; 18 + u32 assert_mask; 19 + u32 deassert_mask; 20 + }; 21 + 22 + struct ccu_reset_controller_data { 23 + const struct ccu_reset_data *reset_data; /* array */ 24 + size_t count; 25 + }; 26 + 27 + struct ccu_reset_controller { 28 + struct reset_controller_dev rcdev; 29 + const struct ccu_reset_controller_data *data; 30 + struct regmap *regmap; 31 + }; 32 + 33 + #define RESET_DATA(_offset, _assert_mask, _deassert_mask) \ 34 + { \ 35 + .offset = (_offset), \ 36 + .assert_mask = (_assert_mask), \ 37 + .deassert_mask = (_deassert_mask), \ 38 + } 39 + 40 + static const struct ccu_reset_data k1_mpmu_resets[] = { 41 + [RESET_WDT] = RESET_DATA(MPMU_WDTPCR, BIT(2), 0), 42 + }; 43 + 44 + static const struct ccu_reset_controller_data k1_mpmu_reset_data = { 45 + .reset_data = k1_mpmu_resets, 46 + .count = ARRAY_SIZE(k1_mpmu_resets), 47 + }; 48 + 49 + static const struct ccu_reset_data k1_apbc_resets[] = { 50 + [RESET_UART0] = RESET_DATA(APBC_UART1_CLK_RST, BIT(2), 0), 51 + [RESET_UART2] = RESET_DATA(APBC_UART2_CLK_RST, BIT(2), 0), 52 + [RESET_GPIO] = RESET_DATA(APBC_GPIO_CLK_RST, BIT(2), 0), 53 + [RESET_PWM0] = RESET_DATA(APBC_PWM0_CLK_RST, BIT(2), BIT(0)), 54 + [RESET_PWM1] = RESET_DATA(APBC_PWM1_CLK_RST, BIT(2), BIT(0)), 55 + [RESET_PWM2] = RESET_DATA(APBC_PWM2_CLK_RST, BIT(2), BIT(0)), 56 + [RESET_PWM3] = RESET_DATA(APBC_PWM3_CLK_RST, BIT(2), BIT(0)), 57 + [RESET_PWM4] = RESET_DATA(APBC_PWM4_CLK_RST, BIT(2), BIT(0)), 58 + [RESET_PWM5] = RESET_DATA(APBC_PWM5_CLK_RST, BIT(2), BIT(0)), 59 + [RESET_PWM6] = RESET_DATA(APBC_PWM6_CLK_RST, BIT(2), BIT(0)), 60 + [RESET_PWM7] = RESET_DATA(APBC_PWM7_CLK_RST, BIT(2), BIT(0)), 61 + [RESET_PWM8] = RESET_DATA(APBC_PWM8_CLK_RST, BIT(2), BIT(0)), 62 + [RESET_PWM9] = RESET_DATA(APBC_PWM9_CLK_RST, BIT(2), BIT(0)), 63 + [RESET_PWM10] = RESET_DATA(APBC_PWM10_CLK_RST, BIT(2), BIT(0)), 64 + [RESET_PWM11] = RESET_DATA(APBC_PWM11_CLK_RST, BIT(2), BIT(0)), 65 + [RESET_PWM12] = RESET_DATA(APBC_PWM12_CLK_RST, BIT(2), BIT(0)), 66 + [RESET_PWM13] = RESET_DATA(APBC_PWM13_CLK_RST, BIT(2), BIT(0)), 67 + [RESET_PWM14] = RESET_DATA(APBC_PWM14_CLK_RST, BIT(2), BIT(0)), 68 + [RESET_PWM15] = RESET_DATA(APBC_PWM15_CLK_RST, BIT(2), BIT(0)), 69 + [RESET_PWM16] = RESET_DATA(APBC_PWM16_CLK_RST, BIT(2), BIT(0)), 70 + [RESET_PWM17] = RESET_DATA(APBC_PWM17_CLK_RST, BIT(2), BIT(0)), 71 + [RESET_PWM18] = RESET_DATA(APBC_PWM18_CLK_RST, BIT(2), BIT(0)), 72 + [RESET_PWM19] = RESET_DATA(APBC_PWM19_CLK_RST, BIT(2), BIT(0)), 73 + [RESET_SSP3] = RESET_DATA(APBC_SSP3_CLK_RST, BIT(2), 0), 74 + [RESET_UART3] = RESET_DATA(APBC_UART3_CLK_RST, BIT(2), 0), 75 + [RESET_RTC] = RESET_DATA(APBC_RTC_CLK_RST, BIT(2), 0), 76 + [RESET_TWSI0] = RESET_DATA(APBC_TWSI0_CLK_RST, BIT(2), 0), 77 + [RESET_TIMERS1] = RESET_DATA(APBC_TIMERS1_CLK_RST, BIT(2), 0), 78 + [RESET_AIB] = RESET_DATA(APBC_AIB_CLK_RST, BIT(2), 0), 79 + [RESET_TIMERS2] = RESET_DATA(APBC_TIMERS2_CLK_RST, BIT(2), 0), 80 + [RESET_ONEWIRE] = RESET_DATA(APBC_ONEWIRE_CLK_RST, BIT(2), 0), 81 + [RESET_SSPA0] = RESET_DATA(APBC_SSPA0_CLK_RST, BIT(2), 0), 82 + [RESET_SSPA1] = RESET_DATA(APBC_SSPA1_CLK_RST, BIT(2), 0), 83 + [RESET_DRO] = RESET_DATA(APBC_DRO_CLK_RST, BIT(2), 0), 84 + [RESET_IR] = RESET_DATA(APBC_IR_CLK_RST, BIT(2), 0), 85 + [RESET_TWSI1] = RESET_DATA(APBC_TWSI1_CLK_RST, BIT(2), 0), 86 + [RESET_TSEN] = RESET_DATA(APBC_TSEN_CLK_RST, BIT(2), 0), 87 + [RESET_TWSI2] = RESET_DATA(APBC_TWSI2_CLK_RST, BIT(2), 0), 88 + [RESET_TWSI4] = RESET_DATA(APBC_TWSI4_CLK_RST, BIT(2), 0), 89 + [RESET_TWSI5] = RESET_DATA(APBC_TWSI5_CLK_RST, BIT(2), 0), 90 + [RESET_TWSI6] = RESET_DATA(APBC_TWSI6_CLK_RST, BIT(2), 0), 91 + [RESET_TWSI7] = RESET_DATA(APBC_TWSI7_CLK_RST, BIT(2), 0), 92 + [RESET_TWSI8] = RESET_DATA(APBC_TWSI8_CLK_RST, BIT(2), 0), 93 + [RESET_IPC_AP2AUD] = RESET_DATA(APBC_IPC_AP2AUD_CLK_RST, BIT(2), 0), 94 + [RESET_UART4] = RESET_DATA(APBC_UART4_CLK_RST, BIT(2), 0), 95 + [RESET_UART5] = RESET_DATA(APBC_UART5_CLK_RST, BIT(2), 0), 96 + [RESET_UART6] = RESET_DATA(APBC_UART6_CLK_RST, BIT(2), 0), 97 + [RESET_UART7] = RESET_DATA(APBC_UART7_CLK_RST, BIT(2), 0), 98 + [RESET_UART8] = RESET_DATA(APBC_UART8_CLK_RST, BIT(2), 0), 99 + [RESET_UART9] = RESET_DATA(APBC_UART9_CLK_RST, BIT(2), 0), 100 + [RESET_CAN0] = RESET_DATA(APBC_CAN0_CLK_RST, BIT(2), 0), 101 + }; 102 + 103 + static const struct ccu_reset_controller_data k1_apbc_reset_data = { 104 + .reset_data = k1_apbc_resets, 105 + .count = ARRAY_SIZE(k1_apbc_resets), 106 + }; 107 + 108 + static const struct ccu_reset_data k1_apmu_resets[] = { 109 + [RESET_CCIC_4X] = RESET_DATA(APMU_CCIC_CLK_RES_CTRL, 0, BIT(1)), 110 + [RESET_CCIC1_PHY] = RESET_DATA(APMU_CCIC_CLK_RES_CTRL, 0, BIT(2)), 111 + [RESET_SDH_AXI] = RESET_DATA(APMU_SDH0_CLK_RES_CTRL, 0, BIT(0)), 112 + [RESET_SDH0] = RESET_DATA(APMU_SDH0_CLK_RES_CTRL, 0, BIT(1)), 113 + [RESET_SDH1] = RESET_DATA(APMU_SDH1_CLK_RES_CTRL, 0, BIT(1)), 114 + [RESET_SDH2] = RESET_DATA(APMU_SDH2_CLK_RES_CTRL, 0, BIT(1)), 115 + [RESET_USBP1_AXI] = RESET_DATA(APMU_USB_CLK_RES_CTRL, 0, BIT(4)), 116 + [RESET_USB_AXI] = RESET_DATA(APMU_USB_CLK_RES_CTRL, 0, BIT(0)), 117 + [RESET_USB30_AHB] = RESET_DATA(APMU_USB_CLK_RES_CTRL, 0, BIT(9)), 118 + [RESET_USB30_VCC] = RESET_DATA(APMU_USB_CLK_RES_CTRL, 0, BIT(10)), 119 + [RESET_USB30_PHY] = RESET_DATA(APMU_USB_CLK_RES_CTRL, 0, BIT(11)), 120 + [RESET_QSPI] = RESET_DATA(APMU_QSPI_CLK_RES_CTRL, 0, BIT(1)), 121 + [RESET_QSPI_BUS] = RESET_DATA(APMU_QSPI_CLK_RES_CTRL, 0, BIT(0)), 122 + [RESET_DMA] = RESET_DATA(APMU_DMA_CLK_RES_CTRL, 0, BIT(0)), 123 + [RESET_AES] = RESET_DATA(APMU_AES_CLK_RES_CTRL, 0, BIT(4)), 124 + [RESET_VPU] = RESET_DATA(APMU_VPU_CLK_RES_CTRL, 0, BIT(0)), 125 + [RESET_GPU] = RESET_DATA(APMU_GPU_CLK_RES_CTRL, 0, BIT(1)), 126 + [RESET_EMMC] = RESET_DATA(APMU_PMUA_EM_CLK_RES_CTRL, 0, BIT(1)), 127 + [RESET_EMMC_X] = RESET_DATA(APMU_PMUA_EM_CLK_RES_CTRL, 0, BIT(0)), 128 + [RESET_AUDIO_SYS] = RESET_DATA(APMU_AUDIO_CLK_RES_CTRL, 0, BIT(0)), 129 + [RESET_AUDIO_MCU] = RESET_DATA(APMU_AUDIO_CLK_RES_CTRL, 0, BIT(2)), 130 + [RESET_AUDIO_APMU] = RESET_DATA(APMU_AUDIO_CLK_RES_CTRL, 0, BIT(3)), 131 + [RESET_HDMI] = RESET_DATA(APMU_HDMI_CLK_RES_CTRL, 0, BIT(9)), 132 + [RESET_PCIE0_DBI] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_0, 0, BIT(3)), 133 + [RESET_PCIE0_SLAVE] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_0, 0, BIT(4)), 134 + [RESET_PCIE0_MASTER] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_0, 0, BIT(5)), 135 + [RESET_PCIE0_GLOBAL] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_0, BIT(8), 0), 136 + [RESET_PCIE1_DBI] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_1, 0, BIT(3)), 137 + [RESET_PCIE1_SLAVE] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_1, 0, BIT(4)), 138 + [RESET_PCIE1_MASTER] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_1, 0, BIT(5)), 139 + [RESET_PCIE1_GLOBAL] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_1, BIT(8), 0), 140 + [RESET_PCIE2_DBI] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_2, 0, BIT(3)), 141 + [RESET_PCIE2_SLAVE] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_2, 0, BIT(4)), 142 + [RESET_PCIE2_MASTER] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_2, 0, BIT(5)), 143 + [RESET_PCIE2_GLOBAL] = RESET_DATA(APMU_PCIE_CLK_RES_CTRL_2, BIT(8), 0), 144 + [RESET_EMAC0] = RESET_DATA(APMU_EMAC0_CLK_RES_CTRL, 0, BIT(1)), 145 + [RESET_EMAC1] = RESET_DATA(APMU_EMAC1_CLK_RES_CTRL, 0, BIT(1)), 146 + [RESET_JPG] = RESET_DATA(APMU_JPG_CLK_RES_CTRL, 0, BIT(0)), 147 + [RESET_CCIC2PHY] = RESET_DATA(APMU_CSI_CCIC2_CLK_RES_CTRL, 0, BIT(2)), 148 + [RESET_CCIC3PHY] = RESET_DATA(APMU_CSI_CCIC2_CLK_RES_CTRL, 0, BIT(29)), 149 + [RESET_CSI] = RESET_DATA(APMU_CSI_CCIC2_CLK_RES_CTRL, 0, BIT(1)), 150 + [RESET_ISP] = RESET_DATA(APMU_ISP_CLK_RES_CTRL, 0, BIT(0)), 151 + [RESET_ISP_CPP] = RESET_DATA(APMU_ISP_CLK_RES_CTRL, 0, BIT(27)), 152 + [RESET_ISP_BUS] = RESET_DATA(APMU_ISP_CLK_RES_CTRL, 0, BIT(3)), 153 + [RESET_ISP_CI] = RESET_DATA(APMU_ISP_CLK_RES_CTRL, 0, BIT(16)), 154 + [RESET_DPU_MCLK] = RESET_DATA(APMU_LCD_CLK_RES_CTRL2, 0, BIT(9)), 155 + [RESET_DPU_ESC] = RESET_DATA(APMU_LCD_CLK_RES_CTRL1, 0, BIT(3)), 156 + [RESET_DPU_HCLK] = RESET_DATA(APMU_LCD_CLK_RES_CTRL1, 0, BIT(4)), 157 + [RESET_DPU_SPIBUS] = RESET_DATA(APMU_LCD_SPI_CLK_RES_CTRL, 0, BIT(4)), 158 + [RESET_DPU_SPI_HBUS] = RESET_DATA(APMU_LCD_SPI_CLK_RES_CTRL, 0, BIT(2)), 159 + [RESET_V2D] = RESET_DATA(APMU_LCD_CLK_RES_CTRL1, 0, BIT(27)), 160 + [RESET_MIPI] = RESET_DATA(APMU_LCD_CLK_RES_CTRL1, 0, BIT(15)), 161 + [RESET_MC] = RESET_DATA(APMU_PMUA_MC_CTRL, 0, BIT(0)), 162 + }; 163 + 164 + static const struct ccu_reset_controller_data k1_apmu_reset_data = { 165 + .reset_data = k1_apmu_resets, 166 + .count = ARRAY_SIZE(k1_apmu_resets), 167 + }; 168 + 169 + static const struct ccu_reset_data k1_rcpu_resets[] = { 170 + [RESET_RCPU_SSP0] = RESET_DATA(RCPU_SSP0_CLK_RST, 0, BIT(0)), 171 + [RESET_RCPU_I2C0] = RESET_DATA(RCPU_I2C0_CLK_RST, 0, BIT(0)), 172 + [RESET_RCPU_UART1] = RESET_DATA(RCPU_UART1_CLK_RST, 0, BIT(0)), 173 + [RESET_RCPU_IR] = RESET_DATA(RCPU_CAN_CLK_RST, 0, BIT(0)), 174 + [RESET_RCPU_CAN] = RESET_DATA(RCPU_IR_CLK_RST, 0, BIT(0)), 175 + [RESET_RCPU_UART0] = RESET_DATA(RCPU_UART0_CLK_RST, 0, BIT(0)), 176 + [RESET_RCPU_HDMI_AUDIO] = RESET_DATA(AUDIO_HDMI_CLK_CTRL, 0, BIT(0)), 177 + }; 178 + 179 + static const struct ccu_reset_controller_data k1_rcpu_reset_data = { 180 + .reset_data = k1_rcpu_resets, 181 + .count = ARRAY_SIZE(k1_rcpu_resets), 182 + }; 183 + 184 + static const struct ccu_reset_data k1_rcpu2_resets[] = { 185 + [RESET_RCPU2_PWM0] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 186 + [RESET_RCPU2_PWM1] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 187 + [RESET_RCPU2_PWM2] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 188 + [RESET_RCPU2_PWM3] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 189 + [RESET_RCPU2_PWM4] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 190 + [RESET_RCPU2_PWM5] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 191 + [RESET_RCPU2_PWM6] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 192 + [RESET_RCPU2_PWM7] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 193 + [RESET_RCPU2_PWM8] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 194 + [RESET_RCPU2_PWM9] = RESET_DATA(RCPU2_PWM9_CLK_RST, BIT(2), BIT(0)), 195 + }; 196 + 197 + static const struct ccu_reset_controller_data k1_rcpu2_reset_data = { 198 + .reset_data = k1_rcpu2_resets, 199 + .count = ARRAY_SIZE(k1_rcpu2_resets), 200 + }; 201 + 202 + static const struct ccu_reset_data k1_apbc2_resets[] = { 203 + [RESET_APBC2_UART1] = RESET_DATA(APBC2_UART1_CLK_RST, BIT(2), 0), 204 + [RESET_APBC2_SSP2] = RESET_DATA(APBC2_SSP2_CLK_RST, BIT(2), 0), 205 + [RESET_APBC2_TWSI3] = RESET_DATA(APBC2_TWSI3_CLK_RST, BIT(2), 0), 206 + [RESET_APBC2_RTC] = RESET_DATA(APBC2_RTC_CLK_RST, BIT(2), 0), 207 + [RESET_APBC2_TIMERS0] = RESET_DATA(APBC2_TIMERS0_CLK_RST, BIT(2), 0), 208 + [RESET_APBC2_KPC] = RESET_DATA(APBC2_KPC_CLK_RST, BIT(2), 0), 209 + [RESET_APBC2_GPIO] = RESET_DATA(APBC2_GPIO_CLK_RST, BIT(2), 0), 210 + }; 211 + 212 + static const struct ccu_reset_controller_data k1_apbc2_reset_data = { 213 + .reset_data = k1_apbc2_resets, 214 + .count = ARRAY_SIZE(k1_apbc2_resets), 215 + }; 216 + 217 + static int spacemit_reset_update(struct reset_controller_dev *rcdev, 218 + unsigned long id, bool assert) 219 + { 220 + struct ccu_reset_controller *controller; 221 + const struct ccu_reset_data *data; 222 + u32 mask; 223 + u32 val; 224 + 225 + controller = container_of(rcdev, struct ccu_reset_controller, rcdev); 226 + data = &controller->data->reset_data[id]; 227 + mask = data->assert_mask | data->deassert_mask; 228 + val = assert ? data->assert_mask : data->deassert_mask; 229 + 230 + return regmap_update_bits(controller->regmap, data->offset, mask, val); 231 + } 232 + 233 + static int spacemit_reset_assert(struct reset_controller_dev *rcdev, 234 + unsigned long id) 235 + { 236 + return spacemit_reset_update(rcdev, id, true); 237 + } 238 + 239 + static int spacemit_reset_deassert(struct reset_controller_dev *rcdev, 240 + unsigned long id) 241 + { 242 + return spacemit_reset_update(rcdev, id, false); 243 + } 244 + 245 + static const struct reset_control_ops spacemit_reset_control_ops = { 246 + .assert = spacemit_reset_assert, 247 + .deassert = spacemit_reset_deassert, 248 + }; 249 + 250 + static int spacemit_reset_controller_register(struct device *dev, 251 + struct ccu_reset_controller *controller) 252 + { 253 + struct reset_controller_dev *rcdev = &controller->rcdev; 254 + 255 + rcdev->ops = &spacemit_reset_control_ops; 256 + rcdev->owner = THIS_MODULE; 257 + rcdev->of_node = dev->of_node; 258 + rcdev->nr_resets = controller->data->count; 259 + 260 + return devm_reset_controller_register(dev, &controller->rcdev); 261 + } 262 + 263 + static int spacemit_reset_probe(struct auxiliary_device *adev, 264 + const struct auxiliary_device_id *id) 265 + { 266 + struct spacemit_ccu_adev *rdev = to_spacemit_ccu_adev(adev); 267 + struct ccu_reset_controller *controller; 268 + struct device *dev = &adev->dev; 269 + 270 + controller = devm_kzalloc(dev, sizeof(*controller), GFP_KERNEL); 271 + if (!controller) 272 + return -ENOMEM; 273 + controller->data = (const struct ccu_reset_controller_data *)id->driver_data; 274 + controller->regmap = rdev->regmap; 275 + 276 + return spacemit_reset_controller_register(dev, controller); 277 + } 278 + 279 + #define K1_AUX_DEV_ID(_unit) \ 280 + { \ 281 + .name = "spacemit_ccu_k1." #_unit "-reset", \ 282 + .driver_data = (kernel_ulong_t)&k1_ ## _unit ## _reset_data, \ 283 + } 284 + 285 + static const struct auxiliary_device_id spacemit_reset_ids[] = { 286 + K1_AUX_DEV_ID(mpmu), 287 + K1_AUX_DEV_ID(apbc), 288 + K1_AUX_DEV_ID(apmu), 289 + K1_AUX_DEV_ID(rcpu), 290 + K1_AUX_DEV_ID(rcpu2), 291 + K1_AUX_DEV_ID(apbc2), 292 + { }, 293 + }; 294 + MODULE_DEVICE_TABLE(auxiliary, spacemit_reset_ids); 295 + 296 + static struct auxiliary_driver spacemit_k1_reset_driver = { 297 + .probe = spacemit_reset_probe, 298 + .id_table = spacemit_reset_ids, 299 + }; 300 + module_auxiliary_driver(spacemit_k1_reset_driver); 301 + 302 + MODULE_AUTHOR("Alex Elder <elder@kernel.org>"); 303 + MODULE_DESCRIPTION("SpacemiT reset controller driver"); 304 + MODULE_LICENSE("GPL");
+141
include/dt-bindings/clock/spacemit,k1-syscon.h
··· 78 78 #define CLK_APB 31 79 79 #define CLK_WDT_BUS 32 80 80 81 + /* MPMU resets */ 82 + #define RESET_WDT 0 83 + 81 84 /* APBC clocks */ 82 85 #define CLK_UART0 0 83 86 #define CLK_UART2 1 ··· 183 180 #define CLK_TSEN_BUS 98 184 181 #define CLK_IPC_AP2AUD_BUS 99 185 182 183 + /* APBC resets */ 184 + #define RESET_UART0 0 185 + #define RESET_UART2 1 186 + #define RESET_UART3 2 187 + #define RESET_UART4 3 188 + #define RESET_UART5 4 189 + #define RESET_UART6 5 190 + #define RESET_UART7 6 191 + #define RESET_UART8 7 192 + #define RESET_UART9 8 193 + #define RESET_GPIO 9 194 + #define RESET_PWM0 10 195 + #define RESET_PWM1 11 196 + #define RESET_PWM2 12 197 + #define RESET_PWM3 13 198 + #define RESET_PWM4 14 199 + #define RESET_PWM5 15 200 + #define RESET_PWM6 16 201 + #define RESET_PWM7 17 202 + #define RESET_PWM8 18 203 + #define RESET_PWM9 19 204 + #define RESET_PWM10 20 205 + #define RESET_PWM11 21 206 + #define RESET_PWM12 22 207 + #define RESET_PWM13 23 208 + #define RESET_PWM14 24 209 + #define RESET_PWM15 25 210 + #define RESET_PWM16 26 211 + #define RESET_PWM17 27 212 + #define RESET_PWM18 28 213 + #define RESET_PWM19 29 214 + #define RESET_SSP3 30 215 + #define RESET_RTC 31 216 + #define RESET_TWSI0 32 217 + #define RESET_TWSI1 33 218 + #define RESET_TWSI2 34 219 + #define RESET_TWSI4 35 220 + #define RESET_TWSI5 36 221 + #define RESET_TWSI6 37 222 + #define RESET_TWSI7 38 223 + #define RESET_TWSI8 39 224 + #define RESET_TIMERS1 40 225 + #define RESET_TIMERS2 41 226 + #define RESET_AIB 42 227 + #define RESET_ONEWIRE 43 228 + #define RESET_SSPA0 44 229 + #define RESET_SSPA1 45 230 + #define RESET_DRO 46 231 + #define RESET_IR 47 232 + #define RESET_TSEN 48 233 + #define RESET_IPC_AP2AUD 49 234 + #define RESET_CAN0 50 235 + 186 236 /* APMU clocks */ 187 237 #define CLK_CCI550 0 188 238 #define CLK_CPU_C0_HI 1 ··· 299 243 #define CLK_DPU_SPI_ACLK 59 300 244 #define CLK_V2D 60 301 245 #define CLK_EMMC_BUS 61 246 + 247 + /* APMU resets */ 248 + #define RESET_CCIC_4X 0 249 + #define RESET_CCIC1_PHY 1 250 + #define RESET_SDH_AXI 2 251 + #define RESET_SDH0 3 252 + #define RESET_SDH1 4 253 + #define RESET_SDH2 5 254 + #define RESET_USBP1_AXI 6 255 + #define RESET_USB_AXI 7 256 + #define RESET_USB30_AHB 8 257 + #define RESET_USB30_VCC 9 258 + #define RESET_USB30_PHY 10 259 + #define RESET_QSPI 11 260 + #define RESET_QSPI_BUS 12 261 + #define RESET_DMA 13 262 + #define RESET_AES 14 263 + #define RESET_VPU 15 264 + #define RESET_GPU 16 265 + #define RESET_EMMC 17 266 + #define RESET_EMMC_X 18 267 + #define RESET_AUDIO_SYS 19 268 + #define RESET_AUDIO_MCU 20 269 + #define RESET_AUDIO_APMU 21 270 + #define RESET_HDMI 22 271 + #define RESET_PCIE0_MASTER 23 272 + #define RESET_PCIE0_SLAVE 24 273 + #define RESET_PCIE0_DBI 25 274 + #define RESET_PCIE0_GLOBAL 26 275 + #define RESET_PCIE1_MASTER 27 276 + #define RESET_PCIE1_SLAVE 28 277 + #define RESET_PCIE1_DBI 29 278 + #define RESET_PCIE1_GLOBAL 30 279 + #define RESET_PCIE2_MASTER 31 280 + #define RESET_PCIE2_SLAVE 32 281 + #define RESET_PCIE2_DBI 33 282 + #define RESET_PCIE2_GLOBAL 34 283 + #define RESET_EMAC0 35 284 + #define RESET_EMAC1 36 285 + #define RESET_JPG 37 286 + #define RESET_CCIC2PHY 38 287 + #define RESET_CCIC3PHY 39 288 + #define RESET_CSI 40 289 + #define RESET_ISP_CPP 41 290 + #define RESET_ISP_BUS 42 291 + #define RESET_ISP 43 292 + #define RESET_ISP_CI 44 293 + #define RESET_DPU_MCLK 45 294 + #define RESET_DPU_ESC 46 295 + #define RESET_DPU_HCLK 47 296 + #define RESET_DPU_SPIBUS 48 297 + #define RESET_DPU_SPI_HBUS 49 298 + #define RESET_V2D 50 299 + #define RESET_MIPI 51 300 + #define RESET_MC 52 301 + 302 + /* RCPU resets */ 303 + #define RESET_RCPU_SSP0 0 304 + #define RESET_RCPU_I2C0 1 305 + #define RESET_RCPU_UART1 2 306 + #define RESET_RCPU_IR 3 307 + #define RESET_RCPU_CAN 4 308 + #define RESET_RCPU_UART0 5 309 + #define RESET_RCPU_HDMI_AUDIO 6 310 + 311 + /* RCPU2 resets */ 312 + #define RESET_RCPU2_PWM0 0 313 + #define RESET_RCPU2_PWM1 1 314 + #define RESET_RCPU2_PWM2 2 315 + #define RESET_RCPU2_PWM3 3 316 + #define RESET_RCPU2_PWM4 4 317 + #define RESET_RCPU2_PWM5 5 318 + #define RESET_RCPU2_PWM6 6 319 + #define RESET_RCPU2_PWM7 7 320 + #define RESET_RCPU2_PWM8 8 321 + #define RESET_RCPU2_PWM9 9 322 + 323 + /* APBC2 resets */ 324 + #define RESET_APBC2_UART1 0 325 + #define RESET_APBC2_SSP2 1 326 + #define RESET_APBC2_TWSI3 2 327 + #define RESET_APBC2_RTC 3 328 + #define RESET_APBC2_TIMERS0 4 329 + #define RESET_APBC2_KPC 5 330 + #define RESET_APBC2_GPIO 6 302 331 303 332 #endif /* _DT_BINDINGS_SPACEMIT_CCU_H_ */
+160
include/soc/spacemit/k1-syscon.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + 3 + /* SpacemiT clock and reset driver definitions for the K1 SoC */ 4 + 5 + #ifndef __SOC_K1_SYSCON_H__ 6 + #define __SOC_K1_SYSCON_H__ 7 + 8 + /* Auxiliary device used to represent a CCU reset controller */ 9 + struct spacemit_ccu_adev { 10 + struct auxiliary_device adev; 11 + struct regmap *regmap; 12 + }; 13 + 14 + static inline struct spacemit_ccu_adev * 15 + to_spacemit_ccu_adev(struct auxiliary_device *adev) 16 + { 17 + return container_of(adev, struct spacemit_ccu_adev, adev); 18 + } 19 + 20 + /* APBS register offset */ 21 + #define APBS_PLL1_SWCR1 0x100 22 + #define APBS_PLL1_SWCR2 0x104 23 + #define APBS_PLL1_SWCR3 0x108 24 + #define APBS_PLL2_SWCR1 0x118 25 + #define APBS_PLL2_SWCR2 0x11c 26 + #define APBS_PLL2_SWCR3 0x120 27 + #define APBS_PLL3_SWCR1 0x124 28 + #define APBS_PLL3_SWCR2 0x128 29 + #define APBS_PLL3_SWCR3 0x12c 30 + 31 + /* MPMU register offset */ 32 + #define MPMU_POSR 0x0010 33 + #define POSR_PLL1_LOCK BIT(27) 34 + #define POSR_PLL2_LOCK BIT(28) 35 + #define POSR_PLL3_LOCK BIT(29) 36 + #define MPMU_SUCCR 0x0014 37 + #define MPMU_ISCCR 0x0044 38 + #define MPMU_WDTPCR 0x0200 39 + #define MPMU_RIPCCR 0x0210 40 + #define MPMU_ACGR 0x1024 41 + #define MPMU_APBCSCR 0x1050 42 + #define MPMU_SUCCR_1 0x10b0 43 + 44 + /* APBC register offset */ 45 + #define APBC_UART1_CLK_RST 0x00 46 + #define APBC_UART2_CLK_RST 0x04 47 + #define APBC_GPIO_CLK_RST 0x08 48 + #define APBC_PWM0_CLK_RST 0x0c 49 + #define APBC_PWM1_CLK_RST 0x10 50 + #define APBC_PWM2_CLK_RST 0x14 51 + #define APBC_PWM3_CLK_RST 0x18 52 + #define APBC_TWSI8_CLK_RST 0x20 53 + #define APBC_UART3_CLK_RST 0x24 54 + #define APBC_RTC_CLK_RST 0x28 55 + #define APBC_TWSI0_CLK_RST 0x2c 56 + #define APBC_TWSI1_CLK_RST 0x30 57 + #define APBC_TIMERS1_CLK_RST 0x34 58 + #define APBC_TWSI2_CLK_RST 0x38 59 + #define APBC_AIB_CLK_RST 0x3c 60 + #define APBC_TWSI4_CLK_RST 0x40 61 + #define APBC_TIMERS2_CLK_RST 0x44 62 + #define APBC_ONEWIRE_CLK_RST 0x48 63 + #define APBC_TWSI5_CLK_RST 0x4c 64 + #define APBC_DRO_CLK_RST 0x58 65 + #define APBC_IR_CLK_RST 0x5c 66 + #define APBC_TWSI6_CLK_RST 0x60 67 + #define APBC_COUNTER_CLK_SEL 0x64 68 + #define APBC_TWSI7_CLK_RST 0x68 69 + #define APBC_TSEN_CLK_RST 0x6c 70 + #define APBC_UART4_CLK_RST 0x70 71 + #define APBC_UART5_CLK_RST 0x74 72 + #define APBC_UART6_CLK_RST 0x78 73 + #define APBC_SSP3_CLK_RST 0x7c 74 + #define APBC_SSPA0_CLK_RST 0x80 75 + #define APBC_SSPA1_CLK_RST 0x84 76 + #define APBC_IPC_AP2AUD_CLK_RST 0x90 77 + #define APBC_UART7_CLK_RST 0x94 78 + #define APBC_UART8_CLK_RST 0x98 79 + #define APBC_UART9_CLK_RST 0x9c 80 + #define APBC_CAN0_CLK_RST 0xa0 81 + #define APBC_PWM4_CLK_RST 0xa8 82 + #define APBC_PWM5_CLK_RST 0xac 83 + #define APBC_PWM6_CLK_RST 0xb0 84 + #define APBC_PWM7_CLK_RST 0xb4 85 + #define APBC_PWM8_CLK_RST 0xb8 86 + #define APBC_PWM9_CLK_RST 0xbc 87 + #define APBC_PWM10_CLK_RST 0xc0 88 + #define APBC_PWM11_CLK_RST 0xc4 89 + #define APBC_PWM12_CLK_RST 0xc8 90 + #define APBC_PWM13_CLK_RST 0xcc 91 + #define APBC_PWM14_CLK_RST 0xd0 92 + #define APBC_PWM15_CLK_RST 0xd4 93 + #define APBC_PWM16_CLK_RST 0xd8 94 + #define APBC_PWM17_CLK_RST 0xdc 95 + #define APBC_PWM18_CLK_RST 0xe0 96 + #define APBC_PWM19_CLK_RST 0xe4 97 + 98 + /* APMU register offset */ 99 + #define APMU_JPG_CLK_RES_CTRL 0x020 100 + #define APMU_CSI_CCIC2_CLK_RES_CTRL 0x024 101 + #define APMU_ISP_CLK_RES_CTRL 0x038 102 + #define APMU_LCD_CLK_RES_CTRL1 0x044 103 + #define APMU_LCD_SPI_CLK_RES_CTRL 0x048 104 + #define APMU_LCD_CLK_RES_CTRL2 0x04c 105 + #define APMU_CCIC_CLK_RES_CTRL 0x050 106 + #define APMU_SDH0_CLK_RES_CTRL 0x054 107 + #define APMU_SDH1_CLK_RES_CTRL 0x058 108 + #define APMU_USB_CLK_RES_CTRL 0x05c 109 + #define APMU_QSPI_CLK_RES_CTRL 0x060 110 + #define APMU_DMA_CLK_RES_CTRL 0x064 111 + #define APMU_AES_CLK_RES_CTRL 0x068 112 + #define APMU_VPU_CLK_RES_CTRL 0x0a4 113 + #define APMU_GPU_CLK_RES_CTRL 0x0cc 114 + #define APMU_SDH2_CLK_RES_CTRL 0x0e0 115 + #define APMU_PMUA_MC_CTRL 0x0e8 116 + #define APMU_PMU_CC2_AP 0x100 117 + #define APMU_PMUA_EM_CLK_RES_CTRL 0x104 118 + #define APMU_AUDIO_CLK_RES_CTRL 0x14c 119 + #define APMU_HDMI_CLK_RES_CTRL 0x1b8 120 + #define APMU_CCI550_CLK_CTRL 0x300 121 + #define APMU_ACLK_CLK_CTRL 0x388 122 + #define APMU_CPU_C0_CLK_CTRL 0x38C 123 + #define APMU_CPU_C1_CLK_CTRL 0x390 124 + #define APMU_PCIE_CLK_RES_CTRL_0 0x3cc 125 + #define APMU_PCIE_CLK_RES_CTRL_1 0x3d4 126 + #define APMU_PCIE_CLK_RES_CTRL_2 0x3dc 127 + #define APMU_EMAC0_CLK_RES_CTRL 0x3e4 128 + #define APMU_EMAC1_CLK_RES_CTRL 0x3ec 129 + 130 + /* RCPU register offsets */ 131 + #define RCPU_SSP0_CLK_RST 0x0028 132 + #define RCPU_I2C0_CLK_RST 0x0030 133 + #define RCPU_UART1_CLK_RST 0x003c 134 + #define RCPU_CAN_CLK_RST 0x0048 135 + #define RCPU_IR_CLK_RST 0x004c 136 + #define RCPU_UART0_CLK_RST 0x00d8 137 + #define AUDIO_HDMI_CLK_CTRL 0x2044 138 + 139 + /* RCPU2 register offsets */ 140 + #define RCPU2_PWM0_CLK_RST 0x0000 141 + #define RCPU2_PWM1_CLK_RST 0x0004 142 + #define RCPU2_PWM2_CLK_RST 0x0008 143 + #define RCPU2_PWM3_CLK_RST 0x000c 144 + #define RCPU2_PWM4_CLK_RST 0x0010 145 + #define RCPU2_PWM5_CLK_RST 0x0014 146 + #define RCPU2_PWM6_CLK_RST 0x0018 147 + #define RCPU2_PWM7_CLK_RST 0x001c 148 + #define RCPU2_PWM8_CLK_RST 0x0020 149 + #define RCPU2_PWM9_CLK_RST 0x0024 150 + 151 + /* APBC2 register offsets */ 152 + #define APBC2_UART1_CLK_RST 0x0000 153 + #define APBC2_SSP2_CLK_RST 0x0004 154 + #define APBC2_TWSI3_CLK_RST 0x0008 155 + #define APBC2_RTC_CLK_RST 0x000c 156 + #define APBC2_TIMERS0_CLK_RST 0x0010 157 + #define APBC2_KPC_CLK_RST 0x0014 158 + #define APBC2_GPIO_CLK_RST 0x001c 159 + 160 + #endif /* __SOC_K1_SYSCON_H__ */