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

Merge tag 'mips_6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux

Pull MIPS updates from Thomas Bogendoerfer:

- add support for TP-Link HC220 G5 v1

- add support for Wifi/Bluetooth on CI20

- rework Ralink clock and reset handling

- cleanups and fixes

* tag 'mips_6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux: (58 commits)
MIPS: Loongson64: DTS: Add RTC support to Loongson-2K1000
MIPS: Loongson64: DTS: Add RTC support to LS7A PCH
MIPS: OCTEON: octeon-usb: cleanup divider calculation
MIPS: OCTEON: octeon-usb: introduce dwc3_octeon_{read,write}q
MIPS: OCTEON: octeon-usb: move gpio config to separate function
MIPS: OCTEON: octeon-usb: use bitfields for shim register
MIPS: OCTEON: octeon-usb: use bitfields for host config register
MIPS: OCTEON: octeon-usb: use bitfields for control register
MIPS: OCTEON: octeon-usb: add all register offsets
mips: ralink: match all supported system controller compatible strings
MIPS: dec: prom: Address -Warray-bounds warning
MIPS: DTS: CI20: Raise VDDCORE voltage to 1.125 volts
clk: ralink: mtmips: Fix uninitialized use of ret in mtmips_register_{fixed,factor}_clocks()
mips: ralink: introduce commonly used remap node function
mips: pci-mt7620: use dev_info() to log PCIe device detection result
mips: pci-mt7620: do not print NFTS register value as error log
MAINTAINERS: add Mediatek MTMIPS Clock maintainer
mips: ralink: get cpu rate from new driver code
mips: ralink: remove reset related code
mips: ralink: mt7620: remove clock related code
...

+2092 -1136
+4 -4
Documentation/admin-guide/kernel-parameters.txt
··· 3716 3716 3717 3717 nohibernate [HIBERNATION] Disable hibernation and resume. 3718 3718 3719 - nohlt [ARM,ARM64,MICROBLAZE,SH] Forces the kernel to busy wait 3720 - in do_idle() and not use the arch_cpu_idle() 3719 + nohlt [ARM,ARM64,MICROBLAZE,MIPS,SH] Forces the kernel to 3720 + busy wait in do_idle() and not use the arch_cpu_idle() 3721 3721 implementation; requires CONFIG_GENERIC_IDLE_POLL_SETUP 3722 3722 to be effective. This is useful on platforms where the 3723 3723 sleep(SH) or wfi(ARM,ARM64) instructions do not work ··· 3852 3852 nosmp [SMP] Tells an SMP kernel to act as a UP kernel, 3853 3853 and disable the IO APIC. legacy for "maxcpus=0". 3854 3854 3855 - nosmt [KNL,S390] Disable symmetric multithreading (SMT). 3855 + nosmt [KNL,MIPS,S390] Disable symmetric multithreading (SMT). 3856 3856 Equivalent to smt=1. 3857 3857 3858 3858 [KNL,X86] Disable symmetric multithreading (SMT). ··· 5770 5770 1: Fast pin select (default) 5771 5771 2: ATC IRMode 5772 5772 5773 - smt= [KNL,S390] Set the maximum number of threads (logical 5773 + smt= [KNL,MIPS,S390] Set the maximum number of threads (logical 5774 5774 CPUs) to use per physical CPU on systems capable of 5775 5775 symmetric multithreading (SMT). Will be capped to the 5776 5776 actual hardware limit.
+64
Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/clock/mediatek,mtmips-sysc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MTMIPS SoCs System Controller 8 + 9 + maintainers: 10 + - Sergio Paracuellos <sergio.paracuellos@gmail.com> 11 + 12 + description: | 13 + MediaTek MIPS and Ralink SoCs provides a system controller to allow 14 + to access to system control registers. These registers include clock 15 + and reset related ones so this node is both clock and reset provider 16 + for the rest of the world. 17 + 18 + These SoCs have an XTAL from where the cpu clock is 19 + provided as well as derived clocks for the bus and the peripherals. 20 + 21 + properties: 22 + compatible: 23 + items: 24 + - enum: 25 + - ralink,mt7620-sysc 26 + - ralink,mt7628-sysc 27 + - ralink,mt7688-sysc 28 + - ralink,rt2880-sysc 29 + - ralink,rt3050-sysc 30 + - ralink,rt3052-sysc 31 + - ralink,rt3352-sysc 32 + - ralink,rt3883-sysc 33 + - ralink,rt5350-sysc 34 + - const: syscon 35 + 36 + reg: 37 + maxItems: 1 38 + 39 + '#clock-cells': 40 + description: 41 + The first cell indicates the clock number. 42 + const: 1 43 + 44 + '#reset-cells': 45 + description: 46 + The first cell indicates the reset bit within the register. 47 + const: 1 48 + 49 + required: 50 + - compatible 51 + - reg 52 + - '#clock-cells' 53 + - '#reset-cells' 54 + 55 + additionalProperties: false 56 + 57 + examples: 58 + - | 59 + syscon@0 { 60 + compatible = "ralink,rt5350-sysc", "syscon"; 61 + reg = <0x0 0x100>; 62 + #clock-cells = <1>; 63 + #reset-cells = <1>; 64 + };
+1
Documentation/devicetree/bindings/mips/ralink.yaml
··· 80 80 - enum: 81 81 - gnubee,gb-pc1 82 82 - gnubee,gb-pc2 83 + - tplink,hc220-g5-v1 83 84 - const: mediatek,mt7621-soc 84 85 85 86 additionalProperties: true
+6 -1
MAINTAINERS
··· 11442 11442 11443 11443 KERNEL VIRTUAL MACHINE FOR MIPS (KVM/mips) 11444 11444 M: Huacai Chen <chenhuacai@kernel.org> 11445 - M: Aleksandar Markovic <aleksandar.qemu.devel@gmail.com> 11446 11445 L: linux-mips@vger.kernel.org 11447 11446 L: kvm@vger.kernel.org 11448 11447 S: Maintained ··· 13329 13330 S: Maintained 13330 13331 F: Documentation/devicetree/bindings/i2c/mediatek,mt7621-i2c.yaml 13331 13332 F: drivers/i2c/busses/i2c-mt7621.c 13333 + 13334 + MEDIATEK MTMIPS CLOCK DRIVER 13335 + M: Sergio Paracuellos <sergio.paracuellos@gmail.com> 13336 + S: Maintained 13337 + F: Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml 13338 + F: drivers/clk/ralink/clk-mtmips.c 13332 13339 13333 13340 MEDIATEK NAND CONTROLLER DRIVER 13334 13341 L: linux-mtd@lists.infradead.org
+3 -1
arch/mips/Kconfig
··· 45 45 select GENERIC_LIB_UCMPDI2 46 46 select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC 47 47 select GENERIC_SMP_IDLE_THREAD 48 + select GENERIC_IDLE_POLL_SETUP 48 49 select GENERIC_TIME_VSYSCALL 49 50 select GUP_GET_PXX_LOW_HIGH if CPU_MIPS32 && PHYS_ADDR_T_64BIT 50 51 select HAS_IOPORT if !NO_IOPORT_MAP || ISA ··· 81 80 select HAVE_LD_DEAD_CODE_DATA_ELIMINATION 82 81 select HAVE_MOD_ARCH_SPECIFIC 83 82 select HAVE_NMI 84 - select HAVE_PATA_PLATFORM 85 83 select HAVE_PERF_EVENTS 86 84 select HAVE_PERF_REGS 87 85 select HAVE_PERF_USER_STACK_DUMP ··· 155 155 select SWAP_IO_SPACE 156 156 select SYS_HAS_CPU_MIPS32_R1 157 157 select SYS_HAS_CPU_MIPS32_R2 158 + select SYS_HAS_CPU_MIPS32_R5 158 159 select SYS_HAS_CPU_MIPS32_R6 159 160 select SYS_HAS_CPU_MIPS64_R1 160 161 select SYS_HAS_CPU_MIPS64_R2 162 + select SYS_HAS_CPU_MIPS64_R5 161 163 select SYS_HAS_CPU_MIPS64_R6 162 164 select SYS_SUPPORTS_32BIT_KERNEL 163 165 select SYS_SUPPORTS_64BIT_KERNEL
+1
arch/mips/alchemy/Kconfig
··· 14 14 bool "Alchemy DB1XXX / PB1XXX boards" 15 15 select GPIOLIB 16 16 select HAVE_PCI 17 + select HAVE_PATA_PLATFORM 17 18 select SYS_SUPPORTS_LITTLE_ENDIAN 18 19 select SYS_HAS_EARLY_PRINTK 19 20 help
+102 -50
arch/mips/boot/dts/ingenic/ci20.dts
··· 67 67 }; 68 68 }; 69 69 70 - eth0_power: fixedregulator@0 { 70 + eth0_power: fixedregulator-0 { 71 71 compatible = "regulator-fixed"; 72 72 73 73 regulator-name = "eth0_power"; 74 74 regulator-min-microvolt = <3300000>; 75 75 regulator-max-microvolt = <3300000>; 76 76 77 - gpio = <&gpb 25 GPIO_ACTIVE_LOW>; 77 + gpio = <&gpb 25 0>; 78 78 enable-active-high; 79 79 }; 80 80 ··· 97 97 gpios = <&gpe 3 GPIO_ACTIVE_LOW>; 98 98 }; 99 99 100 - wlan0_power: fixedregulator@1 { 100 + bt_power: fixedregulator-1 { 101 101 compatible = "regulator-fixed"; 102 102 103 - regulator-name = "wlan0_power"; 103 + regulator-name = "bt_power"; 104 + regulator-min-microvolt = <3300000>; 105 + regulator-max-microvolt = <3300000>; 106 + regulator-settling-time-us = <1400>; 104 107 105 - gpio = <&gpb 19 GPIO_ACTIVE_LOW>; 108 + vin-supply = <&vcc_50>; 109 + 110 + gpio = <&gpb 19 0>; 106 111 enable-active-high; 107 112 }; 108 113 109 - otg_power: fixedregulator@2 { 114 + otg_power: fixedregulator-2 { 110 115 compatible = "regulator-fixed"; 111 116 112 117 regulator-name = "otg_power"; 113 118 regulator-min-microvolt = <5000000>; 114 119 regulator-max-microvolt = <5000000>; 115 120 116 - gpio = <&gpf 15 GPIO_ACTIVE_LOW>; 121 + gpio = <&gpf 15 0>; 117 122 enable-active-high; 123 + }; 124 + 125 + wifi_power: fixedregulator-4 { 126 + compatible = "regulator-fixed"; 127 + 128 + regulator-name = "wifi_power"; 129 + 130 + /* 131 + * Technically it's 5V, the WiFi chip has its own internal 132 + * regulators; but the MMC/SD subsystem won't accept such a 133 + * value. 134 + */ 135 + regulator-min-microvolt = <3300000>; 136 + regulator-max-microvolt = <3300000>; 137 + regulator-settling-time-us = <150000>; 138 + 139 + vin-supply = <&bt_power>; 140 + }; 141 + 142 + vcc_33v: fixedregulator-5 { 143 + compatible = "regulator-fixed"; 144 + 145 + regulator-name = "vcc_33v"; 146 + regulator-min-microvolt = <3300000>; 147 + regulator-max-microvolt = <3300000>; 148 + regulator-always-on; 149 + }; 150 + 151 + wifi_pwrseq: pwrseq { 152 + compatible = "mmc-pwrseq-simple"; 153 + reset-gpios = <&gpf 7 GPIO_ACTIVE_LOW>; 154 + 155 + clocks = <&rtc_dev>; 156 + clock-names = "ext_clock"; 118 157 }; 119 158 }; 120 159 ··· 168 129 */ 169 130 assigned-clocks = <&cgu JZ4780_CLK_OTGPHY>, <&cgu JZ4780_CLK_RTC>, 170 131 <&cgu JZ4780_CLK_SSIPLL>, <&cgu JZ4780_CLK_SSI>, 171 - <&cgu JZ4780_CLK_HDMI>; 132 + <&cgu JZ4780_CLK_HDMI>, <&cgu JZ4780_CLK_MSCMUX>; 172 133 assigned-clock-parents = <0>, <&cgu JZ4780_CLK_RTCLK>, 173 134 <&cgu JZ4780_CLK_MPLL>, 174 - <&cgu JZ4780_CLK_SSIPLL>; 135 + <&cgu JZ4780_CLK_SSIPLL>, 136 + <0>, <&cgu JZ4780_CLK_MPLL>; 175 137 assigned-clock-rates = <48000000>, <0>, <54000000>, <0>, <27000000>; 176 138 }; 177 139 ··· 200 160 pinctrl-0 = <&pins_mmc0>; 201 161 202 162 cd-gpios = <&gpf 20 GPIO_ACTIVE_LOW>; 163 + vmmc-supply = <&vcc_33v>; 164 + vqmmc-supply = <&vcc_33v>; 203 165 }; 204 166 205 167 &mmc1 { 206 168 status = "okay"; 207 169 208 170 bus-width = <4>; 209 - max-frequency = <50000000>; 171 + max-frequency = <25000000>; 172 + mmc-pwrseq = <&wifi_pwrseq>; 173 + vmmc-supply = <&wifi_power>; 174 + vqmmc-supply = <&wifi_io>; 210 175 non-removable; 211 176 212 177 pinctrl-names = "default"; 213 178 pinctrl-0 = <&pins_mmc1>; 214 179 215 - brcmf: wifi@1 { 216 - /* reg = <4>;*/ 217 - compatible = "brcm,bcm4330-fmac"; 218 - vcc-supply = <&wlan0_power>; 219 - device-wakeup-gpios = <&gpd 9 GPIO_ACTIVE_HIGH>; 220 - shutdown-gpios = <&gpf 7 GPIO_ACTIVE_LOW>; 180 + #address-cells = <1>; 181 + #size-cells = <0>; 182 + 183 + wifi@1 { 184 + compatible = "brcm,bcm4329-fmac"; 185 + reg = <1>; 186 + 187 + interrupt-parent = <&gpd>; 188 + interrupts = <9 IRQ_TYPE_EDGE_FALLING>; 189 + interrupt-names = "host-wake"; 221 190 }; 222 191 }; 223 192 ··· 253 204 254 205 bluetooth { 255 206 compatible = "brcm,bcm4330-bt"; 256 - reset-gpios = <&gpf 8 GPIO_ACTIVE_HIGH>; 257 - vcc-supply = <&wlan0_power>; 207 + 208 + vbat-supply = <&bt_power>; 209 + vddio-supply = <&wifi_io>; 210 + 211 + interrupt-parent = <&gpf>; 212 + interrupts = <6 IRQ_TYPE_EDGE_RISING>; 213 + interrupt-names = "host-wakeup"; 214 + 215 + clocks = <&rtc_dev>; 216 + clock-names = "lpo"; 217 + 218 + reset-gpios = <&gpf 8 GPIO_ACTIVE_LOW>; 258 219 device-wakeup-gpios = <&gpf 5 GPIO_ACTIVE_HIGH>; 259 - host-wakeup-gpios = <&gpf 6 GPIO_ACTIVE_HIGH>; 260 - shutdown-gpios = <&gpf 4 GPIO_ACTIVE_LOW>; 220 + shutdown-gpios = <&gpf 4 GPIO_ACTIVE_HIGH>; 261 221 }; 262 222 }; 263 223 ··· 295 237 act8600: act8600@5a { 296 238 compatible = "active-semi,act8600"; 297 239 reg = <0x5a>; 298 - status = "okay"; 299 240 300 241 regulators { 301 - vddcore: SUDCDC1 { 302 - regulator-name = "DCDC_REG1"; 303 - regulator-min-microvolt = <1100000>; 304 - regulator-max-microvolt = <1100000>; 242 + vddcore: DCDC1 { 243 + regulator-min-microvolt = <1125000>; 244 + regulator-max-microvolt = <1125000>; 245 + vp1-supply = <&vcc_33v>; 305 246 regulator-always-on; 306 247 }; 307 - vddmem: SUDCDC2 { 308 - regulator-name = "DCDC_REG2"; 248 + vddmem: DCDC2 { 309 249 regulator-min-microvolt = <1500000>; 310 250 regulator-max-microvolt = <1500000>; 251 + vp2-supply = <&vcc_33v>; 311 252 regulator-always-on; 312 253 }; 313 - vcc_33: SUDCDC3 { 314 - regulator-name = "DCDC_REG3"; 254 + vcc_33: DCDC3 { 315 255 regulator-min-microvolt = <3300000>; 316 256 regulator-max-microvolt = <3300000>; 257 + vp3-supply = <&vcc_33v>; 317 258 regulator-always-on; 318 259 }; 319 - vcc_50: SUDCDC4 { 320 - regulator-name = "SUDCDC_REG4"; 260 + vcc_50: SUDCDC_REG4 { 321 261 regulator-min-microvolt = <5000000>; 322 262 regulator-max-microvolt = <5000000>; 323 263 regulator-always-on; 324 264 }; 325 - vcc_25: LDO_REG5 { 326 - regulator-name = "LDO_REG5"; 265 + vcc_25: LDO5 { 327 266 regulator-min-microvolt = <2500000>; 328 267 regulator-max-microvolt = <2500000>; 268 + inl-supply = <&vcc_33v>; 329 269 regulator-always-on; 330 270 }; 331 - wifi_io: LDO_REG6 { 332 - regulator-name = "LDO_REG6"; 333 - regulator-min-microvolt = <2500000>; 334 - regulator-max-microvolt = <2500000>; 335 - regulator-always-on; 271 + wifi_io: LDO6 { 272 + regulator-min-microvolt = <1800000>; 273 + regulator-max-microvolt = <1800000>; 274 + regulator-settling-time-us = <150000>; 275 + inl-supply = <&vcc_33v>; 336 276 }; 337 - vcc_28: LDO_REG7 { 338 - regulator-name = "LDO_REG7"; 277 + cim_io_28: LDO7 { 339 278 regulator-min-microvolt = <2800000>; 340 279 regulator-max-microvolt = <2800000>; 341 - regulator-always-on; 280 + inl-supply = <&vcc_33v>; 342 281 }; 343 - vcc_15: LDO_REG8 { 344 - regulator-name = "LDO_REG8"; 282 + cim_io_15: LDO8 { 345 283 regulator-min-microvolt = <1500000>; 346 284 regulator-max-microvolt = <1500000>; 347 - regulator-always-on; 285 + inl-supply = <&vcc_33v>; 348 286 }; 349 287 vrtc_18: LDO_REG9 { 350 - regulator-name = "LDO_REG9"; 351 288 /* Despite the datasheet stating 3.3V 352 289 * for REG9 and the driver expecting that, 353 290 * REG9 outputs 1.8V. ··· 356 303 regulator-always-on; 357 304 }; 358 305 vcc_11: LDO_REG10 { 359 - regulator-name = "LDO_REG10"; 360 306 regulator-min-microvolt = <1200000>; 361 307 regulator-max-microvolt = <1200000>; 362 308 regulator-always-on; ··· 415 363 #address-cells = <1>; 416 364 #size-cells = <0>; 417 365 418 - ingenic,bch-controller = <&bch>; 366 + ecc-engine = <&bch>; 419 367 420 368 ingenic,nemc-tAS = <10>; 421 369 ingenic,nemc-tAH = <5>; ··· 481 429 pinctrl-names = "default"; 482 430 pinctrl-0 = <&pins_nemc_cs6>; 483 431 484 - reg = <6 0 1 /* addr */ 485 - 6 2 1>; /* data */ 432 + reg = <6 0 1>, /* addr */ 433 + <6 2 1>; /* data */ 486 434 487 435 ingenic,nemc-tAS = <15>; 488 436 ingenic,nemc-tAH = <10>; ··· 494 442 vcc-supply = <&eth0_power>; 495 443 496 444 interrupt-parent = <&gpe>; 497 - interrupts = <19 4>; 445 + interrupts = <19 IRQ_TYPE_EDGE_RISING>; 498 446 499 447 nvmem-cells = <&eth0_addr>; 500 448 nvmem-cell-names = "mac-address";
+2 -5
arch/mips/boot/dts/ingenic/jz4725b.dtsi
··· 198 198 199 199 #sound-dai-cells = <0>; 200 200 201 - clocks = <&cgu JZ4725B_CLK_AIC>, 202 - <&cgu JZ4725B_CLK_I2S>, 203 - <&cgu JZ4725B_CLK_EXT>, 204 - <&cgu JZ4725B_CLK_PLL_HALF>; 205 - clock-names = "aic", "i2s", "ext", "pll half"; 201 + clocks = <&cgu JZ4725B_CLK_AIC>, <&cgu JZ4725B_CLK_I2S>; 202 + clock-names = "aic", "i2s"; 206 203 207 204 interrupt-parent = <&intc>; 208 205 interrupts = <10>;
+2 -5
arch/mips/boot/dts/ingenic/jz4740.dtsi
··· 192 192 interrupt-parent = <&intc>; 193 193 interrupts = <18>; 194 194 195 - clocks = <&cgu JZ4740_CLK_AIC>, 196 - <&cgu JZ4740_CLK_I2S>, 197 - <&cgu JZ4740_CLK_EXT>, 198 - <&cgu JZ4740_CLK_PLL_HALF>; 199 - clock-names = "aic", "i2s", "ext", "pll half"; 195 + clocks = <&cgu JZ4740_CLK_AIC>, <&cgu JZ4740_CLK_I2S>; 196 + clock-names = "aic", "i2s"; 200 197 201 198 dmas = <&dmac 25 0xffffffff>, <&dmac 24 0xffffffff>; 202 199 dma-names = "rx", "tx";
+2 -3
arch/mips/boot/dts/ingenic/jz4770.dtsi
··· 238 238 239 239 #sound-dai-cells = <0>; 240 240 241 - clocks = <&cgu JZ4770_CLK_AIC>, <&cgu JZ4770_CLK_I2S>, 242 - <&cgu JZ4770_CLK_EXT>, <&cgu JZ4770_CLK_PLL0>; 243 - clock-names = "aic", "i2s", "ext", "pll half"; 241 + clocks = <&cgu JZ4770_CLK_AIC>, <&cgu JZ4770_CLK_I2S>; 242 + clock-names = "aic", "i2s"; 244 243 245 244 interrupt-parent = <&intc>; 246 245 interrupts = <34>;
+3 -3
arch/mips/boot/dts/ingenic/qi_lb60.dts
··· 27 27 stdout-path = &uart0; 28 28 }; 29 29 30 - vcc: regulator@0 { 30 + vcc: regulator-0 { 31 31 compatible = "regulator-fixed"; 32 32 regulator-name = "vcc"; 33 33 ··· 36 36 regulator-always-on; 37 37 }; 38 38 39 - mmc_power: regulator@1 { 39 + mmc_power: regulator-1 { 40 40 compatible = "regulator-fixed"; 41 41 regulator-name = "mmc_vcc"; 42 42 gpio = <&gpd 2 0>; ··· 45 45 regulator-max-microvolt = <3300000>; 46 46 }; 47 47 48 - amp_supply: regulator@2 { 48 + amp_supply: regulator-2 { 49 49 compatible = "regulator-fixed"; 50 50 regulator-name = "amp_supply"; 51 51 gpio = <&gpd 4 0>;
+18
arch/mips/boot/dts/ingenic/x1000.dtsi
··· 417 417 418 418 status = "disabled"; 419 419 }; 420 + 421 + aic: audio-controller@10020000 { 422 + compatible = "ingenic,x1000-i2s"; 423 + reg = <0x10020000 0x38>; 424 + 425 + #sound-dai-cells = <0>; 426 + 427 + interrupt-parent = <&intc>; 428 + interrupts = <1>; 429 + 430 + clocks = <&cgu X1000_CLK_AIC>, 431 + <&cgu X1000_CLK_I2S>; 432 + clock-names = "aic", "i2s"; 433 + 434 + dmas = <&pdma X1000_DMA_I2S0_RX 0xffffffff>, 435 + <&pdma X1000_DMA_I2S0_TX 0xffffffff>; 436 + dma-names = "rx", "tx"; 437 + }; 420 438 };
+7
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
··· 97 97 <0x00000000>; /* int3 */ 98 98 }; 99 99 100 + rtc0: rtc@1fe07800 { 101 + compatible = "loongson,ls2k1000-rtc"; 102 + reg = <0 0x1fe07800 0 0x78>; 103 + interrupt-parent = <&liointc0>; 104 + interrupts = <60 IRQ_TYPE_LEVEL_LOW>; 105 + }; 106 + 100 107 uart0: serial@1fe00000 { 101 108 compatible = "ns16550a"; 102 109 reg = <0 0x1fe00000 0 0x8>;
+7
arch/mips/boot/dts/loongson/ls7a-pch.dtsi
··· 19 19 #interrupt-cells = <2>; 20 20 }; 21 21 22 + rtc0: rtc@100d0100 { 23 + compatible = "loongson,ls7a-rtc"; 24 + reg = <0 0x100d0100 0 0x78>; 25 + interrupt-parent = <&pic>; 26 + interrupts = <52 IRQ_TYPE_LEVEL_HIGH>; 27 + }; 28 + 22 29 ls7a_uart0: serial@10080000 { 23 30 compatible = "ns16550a"; 24 31 reg = <0 0x10080000 0 0x100>;
+2 -1
arch/mips/boot/dts/ralink/Makefile
··· 8 8 9 9 dtb-$(CONFIG_SOC_MT7621) += \ 10 10 mt7621-gnubee-gb-pc1.dtb \ 11 - mt7621-gnubee-gb-pc2.dtb 11 + mt7621-gnubee-gb-pc2.dtb \ 12 + mt7621-tplink-hc220-g5-v1.dtb 12 13 13 14 obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y))
+20 -20
arch/mips/boot/dts/ralink/mt7628a.dtsi
··· 51 51 pinctrl-single,register-width = <32>; 52 52 pinctrl-single,function-mask = <0x1>; 53 53 54 - pinmux_gpio_gpio: pinmux_gpio_gpio { 54 + pinmux_gpio_gpio: gpio-gpio-pins { 55 55 pinctrl-single,bits = <0x0 0x0 0x3>; 56 56 }; 57 57 58 - pinmux_spi_cs1_cs: pinmux_spi_cs1_cs { 58 + pinmux_spi_cs1_cs: spi-cs1-cs-pins { 59 59 pinctrl-single,bits = <0x0 0x0 0x30>; 60 60 }; 61 61 62 - pinmux_i2s_gpio: pinmux_i2s_gpio { 62 + pinmux_i2s_gpio: i2s-gpio-pins { 63 63 pinctrl-single,bits = <0x0 0x40 0xc0>; 64 64 }; 65 65 66 - pinmux_uart0_uart: pinmux_uart0_uart0 { 66 + pinmux_uart0_uart: uart0-uart0-pins { 67 67 pinctrl-single,bits = <0x0 0x0 0x300>; 68 68 }; 69 69 70 - pinmux_sdmode_sdxc: pinmux_sdmode_sdxc { 70 + pinmux_sdmode_sdxc: sdmode-sdxc-pins { 71 71 pinctrl-single,bits = <0x0 0x0 0xc00>; 72 72 }; 73 73 74 - pinmux_sdmode_gpio: pinmux_sdmode_gpio { 74 + pinmux_sdmode_gpio: sdmode-gpio-pins { 75 75 pinctrl-single,bits = <0x0 0x400 0xc00>; 76 76 }; 77 77 78 - pinmux_spi_spi: pinmux_spi_spi { 78 + pinmux_spi_spi: spi-spi-pins { 79 79 pinctrl-single,bits = <0x0 0x0 0x1000>; 80 80 }; 81 81 82 - pinmux_refclk_gpio: pinmux_refclk_gpio { 82 + pinmux_refclk_gpio: refclk-gpio-pins { 83 83 pinctrl-single,bits = <0x0 0x40000 0x40000>; 84 84 }; 85 85 86 - pinmux_i2c_i2c: pinmux_i2c_i2c { 86 + pinmux_i2c_i2c: i2c-i2c-pins { 87 87 pinctrl-single,bits = <0x0 0x0 0x300000>; 88 88 }; 89 89 90 - pinmux_uart1_uart: pinmux_uart1_uart1 { 90 + pinmux_uart1_uart: uart1-uart1-pins { 91 91 pinctrl-single,bits = <0x0 0x0 0x3000000>; 92 92 }; 93 93 94 - pinmux_uart2_uart: pinmux_uart2_uart { 94 + pinmux_uart2_uart: uart2-uart-pins { 95 95 pinctrl-single,bits = <0x0 0x0 0xc000000>; 96 96 }; 97 97 98 - pinmux_pwm0_pwm: pinmux_pwm0_pwm { 98 + pinmux_pwm0_pwm: pwm0-pwm-pins { 99 99 pinctrl-single,bits = <0x0 0x0 0x30000000>; 100 100 }; 101 101 102 - pinmux_pwm0_gpio: pinmux_pwm0_gpio { 102 + pinmux_pwm0_gpio: pwm0-gpio-pins { 103 103 pinctrl-single,bits = <0x0 0x10000000 104 104 0x30000000>; 105 105 }; 106 106 107 - pinmux_pwm1_pwm: pinmux_pwm1_pwm { 107 + pinmux_pwm1_pwm: pwm1-pwm-pins { 108 108 pinctrl-single,bits = <0x0 0x0 0xc0000000>; 109 109 }; 110 110 111 - pinmux_pwm1_gpio: pinmux_pwm1_gpio { 111 + pinmux_pwm1_gpio: pwm1-gpio-pins { 112 112 pinctrl-single,bits = <0x0 0x40000000 113 113 0xc0000000>; 114 114 }; 115 115 116 - pinmux_p0led_an_gpio: pinmux_p0led_an_gpio { 116 + pinmux_p0led_an_gpio: p0led-an-gpio-pins { 117 117 pinctrl-single,bits = <0x4 0x4 0xc>; 118 118 }; 119 119 120 - pinmux_p1led_an_gpio: pinmux_p1led_an_gpio { 120 + pinmux_p1led_an_gpio: p1led-an-gpio-pins { 121 121 pinctrl-single,bits = <0x4 0x10 0x30>; 122 122 }; 123 123 124 - pinmux_p2led_an_gpio: pinmux_p2led_an_gpio { 124 + pinmux_p2led_an_gpio: p2led-an-gpio-pins { 125 125 pinctrl-single,bits = <0x4 0x40 0xc0>; 126 126 }; 127 127 128 - pinmux_p3led_an_gpio: pinmux_p3led_an_gpio { 128 + pinmux_p3led_an_gpio: p3led-an-gpio-pins { 129 129 pinctrl-single,bits = <0x4 0x100 0x300>; 130 130 }; 131 131 132 - pinmux_p4led_an_gpio: pinmux_p4led_an_gpio { 132 + pinmux_p4led_an_gpio: p4led-an-gpio-pins { 133 133 pinctrl-single,bits = <0x4 0x400 0xc00>; 134 134 }; 135 135 };
+315 -312
arch/mips/cavium-octeon/octeon-usb.c
··· 8 8 * for more details. 9 9 */ 10 10 11 - #include <linux/module.h> 11 + #include <linux/bitfield.h> 12 + #include <linux/bits.h> 12 13 #include <linux/device.h> 13 - #include <linux/mutex.h> 14 14 #include <linux/delay.h> 15 - #include <linux/of_platform.h> 16 15 #include <linux/io.h> 16 + #include <linux/module.h> 17 + #include <linux/mutex.h> 18 + #include <linux/of_platform.h> 17 19 18 - #include <asm/octeon/octeon.h> 20 + /* 21 + * USB Control Register 22 + */ 23 + #define USBDRD_UCTL_CTL 0x00 24 + /* BIST fast-clear mode select. A BIST run with this bit set 25 + * clears all entries in USBH RAMs to 0x0. 26 + */ 27 + # define USBDRD_UCTL_CTL_CLEAR_BIST BIT(63) 28 + /* 1 = Start BIST and cleared by hardware */ 29 + # define USBDRD_UCTL_CTL_START_BIST BIT(62) 30 + /* Reference clock select for SuperSpeed and HighSpeed PLLs: 31 + * 0x0 = Both PLLs use DLMC_REF_CLK0 for reference clock 32 + * 0x1 = Both PLLs use DLMC_REF_CLK1 for reference clock 33 + * 0x2 = SuperSpeed PLL uses DLMC_REF_CLK0 for reference clock & 34 + * HighSpeed PLL uses PLL_REF_CLK for reference clck 35 + * 0x3 = SuperSpeed PLL uses DLMC_REF_CLK1 for reference clock & 36 + * HighSpeed PLL uses PLL_REF_CLK for reference clck 37 + */ 38 + # define USBDRD_UCTL_CTL_REF_CLK_SEL GENMASK(61, 60) 39 + /* 1 = Spread-spectrum clock enable, 0 = SS clock disable */ 40 + # define USBDRD_UCTL_CTL_SSC_EN BIT(59) 41 + /* Spread-spectrum clock modulation range: 42 + * 0x0 = -4980 ppm downspread 43 + * 0x1 = -4492 ppm downspread 44 + * 0x2 = -4003 ppm downspread 45 + * 0x3 - 0x7 = Reserved 46 + */ 47 + # define USBDRD_UCTL_CTL_SSC_RANGE GENMASK(58, 56) 48 + /* Enable non-standard oscillator frequencies: 49 + * [55:53] = modules -1 50 + * [52:47] = 2's complement push amount, 0 = Feature disabled 51 + */ 52 + # define USBDRD_UCTL_CTL_SSC_REF_CLK_SEL GENMASK(55, 47) 53 + /* Reference clock multiplier for non-standard frequencies: 54 + * 0x19 = 100MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 55 + * 0x28 = 125MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 56 + * 0x32 = 50MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 57 + * Other Values = Reserved 58 + */ 59 + # define USBDRD_UCTL_CTL_MPLL_MULTIPLIER GENMASK(46, 40) 60 + /* Enable reference clock to prescaler for SuperSpeed functionality. 61 + * Should always be set to "1" 62 + */ 63 + # define USBDRD_UCTL_CTL_REF_SSP_EN BIT(39) 64 + /* Divide the reference clock by 2 before entering the 65 + * REF_CLK_FSEL divider: 66 + * If REF_CLK_SEL = 0x0 or 0x1, then only 0x0 is legal 67 + * If REF_CLK_SEL = 0x2 or 0x3, then: 68 + * 0x1 = DLMC_REF_CLK* is 125MHz 69 + * 0x0 = DLMC_REF_CLK* is another supported frequency 70 + */ 71 + # define USBDRD_UCTL_CTL_REF_CLK_DIV2 BIT(38) 72 + /* Select reference clock freqnuency for both PLL blocks: 73 + * 0x27 = REF_CLK_SEL is 0x0 or 0x1 74 + * 0x07 = REF_CLK_SEL is 0x2 or 0x3 75 + */ 76 + # define USBDRD_UCTL_CTL_REF_CLK_FSEL GENMASK(37, 32) 77 + /* Controller clock enable. */ 78 + # define USBDRD_UCTL_CTL_H_CLK_EN BIT(30) 79 + /* Select bypass input to controller clock divider: 80 + * 0x0 = Use divided coprocessor clock from H_CLKDIV 81 + * 0x1 = Use clock from GPIO pins 82 + */ 83 + # define USBDRD_UCTL_CTL_H_CLK_BYP_SEL BIT(29) 84 + /* Reset controller clock divider. */ 85 + # define USBDRD_UCTL_CTL_H_CLKDIV_RST BIT(28) 86 + /* Clock divider select: 87 + * 0x0 = divide by 1 88 + * 0x1 = divide by 2 89 + * 0x2 = divide by 4 90 + * 0x3 = divide by 6 91 + * 0x4 = divide by 8 92 + * 0x5 = divide by 16 93 + * 0x6 = divide by 24 94 + * 0x7 = divide by 32 95 + */ 96 + # define USBDRD_UCTL_CTL_H_CLKDIV_SEL GENMASK(26, 24) 97 + /* USB3 port permanently attached: 0x0 = No, 0x1 = Yes */ 98 + # define USBDRD_UCTL_CTL_USB3_PORT_PERM_ATTACH BIT(21) 99 + /* USB2 port permanently attached: 0x0 = No, 0x1 = Yes */ 100 + # define USBDRD_UCTL_CTL_USB2_PORT_PERM_ATTACH BIT(20) 101 + /* Disable SuperSpeed PHY: 0x0 = No, 0x1 = Yes */ 102 + # define USBDRD_UCTL_CTL_USB3_PORT_DISABLE BIT(18) 103 + /* Disable HighSpeed PHY: 0x0 = No, 0x1 = Yes */ 104 + # define USBDRD_UCTL_CTL_USB2_PORT_DISABLE BIT(16) 105 + /* Enable PHY SuperSpeed block power: 0x0 = No, 0x1 = Yes */ 106 + # define USBDRD_UCTL_CTL_SS_POWER_EN BIT(14) 107 + /* Enable PHY HighSpeed block power: 0x0 = No, 0x1 = Yes */ 108 + # define USBDRD_UCTL_CTL_HS_POWER_EN BIT(12) 109 + /* Enable USB UCTL interface clock: 0xx = No, 0x1 = Yes */ 110 + # define USBDRD_UCTL_CTL_CSCLK_EN BIT(4) 111 + /* Controller mode: 0x0 = Host, 0x1 = Device */ 112 + # define USBDRD_UCTL_CTL_DRD_MODE BIT(3) 113 + /* PHY reset */ 114 + # define USBDRD_UCTL_CTL_UPHY_RST BIT(2) 115 + /* Software reset UAHC */ 116 + # define USBDRD_UCTL_CTL_UAHC_RST BIT(1) 117 + /* Software resets UCTL */ 118 + # define USBDRD_UCTL_CTL_UCTL_RST BIT(0) 19 119 20 - /* USB Control Register */ 21 - union cvm_usbdrd_uctl_ctl { 22 - uint64_t u64; 23 - struct cvm_usbdrd_uctl_ctl_s { 24 - /* 1 = BIST and set all USB RAMs to 0x0, 0 = BIST */ 25 - __BITFIELD_FIELD(uint64_t clear_bist:1, 26 - /* 1 = Start BIST and cleared by hardware */ 27 - __BITFIELD_FIELD(uint64_t start_bist:1, 28 - /* Reference clock select for SuperSpeed and HighSpeed PLLs: 29 - * 0x0 = Both PLLs use DLMC_REF_CLK0 for reference clock 30 - * 0x1 = Both PLLs use DLMC_REF_CLK1 for reference clock 31 - * 0x2 = SuperSpeed PLL uses DLMC_REF_CLK0 for reference clock & 32 - * HighSpeed PLL uses PLL_REF_CLK for reference clck 33 - * 0x3 = SuperSpeed PLL uses DLMC_REF_CLK1 for reference clock & 34 - * HighSpeed PLL uses PLL_REF_CLK for reference clck 35 - */ 36 - __BITFIELD_FIELD(uint64_t ref_clk_sel:2, 37 - /* 1 = Spread-spectrum clock enable, 0 = SS clock disable */ 38 - __BITFIELD_FIELD(uint64_t ssc_en:1, 39 - /* Spread-spectrum clock modulation range: 40 - * 0x0 = -4980 ppm downspread 41 - * 0x1 = -4492 ppm downspread 42 - * 0x2 = -4003 ppm downspread 43 - * 0x3 - 0x7 = Reserved 44 - */ 45 - __BITFIELD_FIELD(uint64_t ssc_range:3, 46 - /* Enable non-standard oscillator frequencies: 47 - * [55:53] = modules -1 48 - * [52:47] = 2's complement push amount, 0 = Feature disabled 49 - */ 50 - __BITFIELD_FIELD(uint64_t ssc_ref_clk_sel:9, 51 - /* Reference clock multiplier for non-standard frequencies: 52 - * 0x19 = 100MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 53 - * 0x28 = 125MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 54 - * 0x32 = 50MHz on DLMC_REF_CLK* if REF_CLK_SEL = 0x0 or 0x1 55 - * Other Values = Reserved 56 - */ 57 - __BITFIELD_FIELD(uint64_t mpll_multiplier:7, 58 - /* Enable reference clock to prescaler for SuperSpeed functionality. 59 - * Should always be set to "1" 60 - */ 61 - __BITFIELD_FIELD(uint64_t ref_ssp_en:1, 62 - /* Divide the reference clock by 2 before entering the 63 - * REF_CLK_FSEL divider: 64 - * If REF_CLK_SEL = 0x0 or 0x1, then only 0x0 is legal 65 - * If REF_CLK_SEL = 0x2 or 0x3, then: 66 - * 0x1 = DLMC_REF_CLK* is 125MHz 67 - * 0x0 = DLMC_REF_CLK* is another supported frequency 68 - */ 69 - __BITFIELD_FIELD(uint64_t ref_clk_div2:1, 70 - /* Select reference clock freqnuency for both PLL blocks: 71 - * 0x27 = REF_CLK_SEL is 0x0 or 0x1 72 - * 0x07 = REF_CLK_SEL is 0x2 or 0x3 73 - */ 74 - __BITFIELD_FIELD(uint64_t ref_clk_fsel:6, 75 - /* Reserved */ 76 - __BITFIELD_FIELD(uint64_t reserved_31_31:1, 77 - /* Controller clock enable. */ 78 - __BITFIELD_FIELD(uint64_t h_clk_en:1, 79 - /* Select bypass input to controller clock divider: 80 - * 0x0 = Use divided coprocessor clock from H_CLKDIV 81 - * 0x1 = Use clock from GPIO pins 82 - */ 83 - __BITFIELD_FIELD(uint64_t h_clk_byp_sel:1, 84 - /* Reset controller clock divider. */ 85 - __BITFIELD_FIELD(uint64_t h_clkdiv_rst:1, 86 - /* Reserved */ 87 - __BITFIELD_FIELD(uint64_t reserved_27_27:1, 88 - /* Clock divider select: 89 - * 0x0 = divide by 1 90 - * 0x1 = divide by 2 91 - * 0x2 = divide by 4 92 - * 0x3 = divide by 6 93 - * 0x4 = divide by 8 94 - * 0x5 = divide by 16 95 - * 0x6 = divide by 24 96 - * 0x7 = divide by 32 97 - */ 98 - __BITFIELD_FIELD(uint64_t h_clkdiv_sel:3, 99 - /* Reserved */ 100 - __BITFIELD_FIELD(uint64_t reserved_22_23:2, 101 - /* USB3 port permanently attached: 0x0 = No, 0x1 = Yes */ 102 - __BITFIELD_FIELD(uint64_t usb3_port_perm_attach:1, 103 - /* USB2 port permanently attached: 0x0 = No, 0x1 = Yes */ 104 - __BITFIELD_FIELD(uint64_t usb2_port_perm_attach:1, 105 - /* Reserved */ 106 - __BITFIELD_FIELD(uint64_t reserved_19_19:1, 107 - /* Disable SuperSpeed PHY: 0x0 = No, 0x1 = Yes */ 108 - __BITFIELD_FIELD(uint64_t usb3_port_disable:1, 109 - /* Reserved */ 110 - __BITFIELD_FIELD(uint64_t reserved_17_17:1, 111 - /* Disable HighSpeed PHY: 0x0 = No, 0x1 = Yes */ 112 - __BITFIELD_FIELD(uint64_t usb2_port_disable:1, 113 - /* Reserved */ 114 - __BITFIELD_FIELD(uint64_t reserved_15_15:1, 115 - /* Enable PHY SuperSpeed block power: 0x0 = No, 0x1 = Yes */ 116 - __BITFIELD_FIELD(uint64_t ss_power_en:1, 117 - /* Reserved */ 118 - __BITFIELD_FIELD(uint64_t reserved_13_13:1, 119 - /* Enable PHY HighSpeed block power: 0x0 = No, 0x1 = Yes */ 120 - __BITFIELD_FIELD(uint64_t hs_power_en:1, 121 - /* Reserved */ 122 - __BITFIELD_FIELD(uint64_t reserved_5_11:7, 123 - /* Enable USB UCTL interface clock: 0xx = No, 0x1 = Yes */ 124 - __BITFIELD_FIELD(uint64_t csclk_en:1, 125 - /* Controller mode: 0x0 = Host, 0x1 = Device */ 126 - __BITFIELD_FIELD(uint64_t drd_mode:1, 127 - /* PHY reset */ 128 - __BITFIELD_FIELD(uint64_t uphy_rst:1, 129 - /* Software reset UAHC */ 130 - __BITFIELD_FIELD(uint64_t uahc_rst:1, 131 - /* Software resets UCTL */ 132 - __BITFIELD_FIELD(uint64_t uctl_rst:1, 133 - ;))))))))))))))))))))))))))))))))) 134 - } s; 135 - }; 120 + #define USBDRD_UCTL_BIST_STATUS 0x08 121 + #define USBDRD_UCTL_SPARE0 0x10 122 + #define USBDRD_UCTL_INTSTAT 0x30 123 + #define USBDRD_UCTL_PORT_CFG_HS(port) (0x40 + (0x20 * port)) 124 + #define USBDRD_UCTL_PORT_CFG_SS(port) (0x48 + (0x20 * port)) 125 + #define USBDRD_UCTL_PORT_CR_DBG_CFG(port) (0x50 + (0x20 * port)) 126 + #define USBDRD_UCTL_PORT_CR_DBG_STATUS(port) (0x58 + (0x20 * port)) 136 127 137 - /* UAHC Configuration Register */ 138 - union cvm_usbdrd_uctl_host_cfg { 139 - uint64_t u64; 140 - struct cvm_usbdrd_uctl_host_cfg_s { 141 - /* Reserved */ 142 - __BITFIELD_FIELD(uint64_t reserved_60_63:4, 143 - /* Indicates minimum value of all received BELT values */ 144 - __BITFIELD_FIELD(uint64_t host_current_belt:12, 145 - /* Reserved */ 146 - __BITFIELD_FIELD(uint64_t reserved_38_47:10, 147 - /* HS jitter adjustment */ 148 - __BITFIELD_FIELD(uint64_t fla:6, 149 - /* Reserved */ 150 - __BITFIELD_FIELD(uint64_t reserved_29_31:3, 151 - /* Bus-master enable: 0x0 = Disabled (stall DMAs), 0x1 = enabled */ 152 - __BITFIELD_FIELD(uint64_t bme:1, 153 - /* Overcurrent protection enable: 0x0 = unavailable, 0x1 = available */ 154 - __BITFIELD_FIELD(uint64_t oci_en:1, 155 - /* Overcurrent sene selection: 156 - * 0x0 = Overcurrent indication from off-chip is active-low 157 - * 0x1 = Overcurrent indication from off-chip is active-high 158 - */ 159 - __BITFIELD_FIELD(uint64_t oci_active_high_en:1, 160 - /* Port power control enable: 0x0 = unavailable, 0x1 = available */ 161 - __BITFIELD_FIELD(uint64_t ppc_en:1, 162 - /* Port power control sense selection: 163 - * 0x0 = Port power to off-chip is active-low 164 - * 0x1 = Port power to off-chip is active-high 165 - */ 166 - __BITFIELD_FIELD(uint64_t ppc_active_high_en:1, 167 - /* Reserved */ 168 - __BITFIELD_FIELD(uint64_t reserved_0_23:24, 169 - ;))))))))))) 170 - } s; 171 - }; 128 + /* 129 + * UCTL Configuration Register 130 + */ 131 + #define USBDRD_UCTL_HOST_CFG 0xe0 132 + /* Indicates minimum value of all received BELT values */ 133 + # define USBDRD_UCTL_HOST_CFG_HOST_CURRENT_BELT GENMASK(59, 48) 134 + /* HS jitter adjustment */ 135 + # define USBDRD_UCTL_HOST_CFG_FLA GENMASK(37, 32) 136 + /* Bus-master enable: 0x0 = Disabled (stall DMAs), 0x1 = enabled */ 137 + # define USBDRD_UCTL_HOST_CFG_BME BIT(28) 138 + /* Overcurrent protection enable: 0x0 = unavailable, 0x1 = available */ 139 + # define USBDRD_UCTL_HOST_OCI_EN BIT(27) 140 + /* Overcurrent sene selection: 141 + * 0x0 = Overcurrent indication from off-chip is active-low 142 + * 0x1 = Overcurrent indication from off-chip is active-high 143 + */ 144 + # define USBDRD_UCTL_HOST_OCI_ACTIVE_HIGH_EN BIT(26) 145 + /* Port power control enable: 0x0 = unavailable, 0x1 = available */ 146 + # define USBDRD_UCTL_HOST_PPC_EN BIT(25) 147 + /* Port power control sense selection: 148 + * 0x0 = Port power to off-chip is active-low 149 + * 0x1 = Port power to off-chip is active-high 150 + */ 151 + # define USBDRD_UCTL_HOST_PPC_ACTIVE_HIGH_EN BIT(24) 172 152 173 - /* UCTL Shim Features Register */ 174 - union cvm_usbdrd_uctl_shim_cfg { 175 - uint64_t u64; 176 - struct cvm_usbdrd_uctl_shim_cfg_s { 177 - /* Out-of-bound UAHC register access: 0 = read, 1 = write */ 178 - __BITFIELD_FIELD(uint64_t xs_ncb_oob_wrn:1, 179 - /* Reserved */ 180 - __BITFIELD_FIELD(uint64_t reserved_60_62:3, 181 - /* SRCID error log for out-of-bound UAHC register access: 182 - * [59:58] = chipID 183 - * [57] = Request source: 0 = core, 1 = NCB-device 184 - * [56:51] = Core/NCB-device number, [56] always 0 for NCB devices 185 - * [50:48] = SubID 186 - */ 187 - __BITFIELD_FIELD(uint64_t xs_ncb_oob_osrc:12, 188 - /* Error log for bad UAHC DMA access: 0 = Read log, 1 = Write log */ 189 - __BITFIELD_FIELD(uint64_t xm_bad_dma_wrn:1, 190 - /* Reserved */ 191 - __BITFIELD_FIELD(uint64_t reserved_44_46:3, 192 - /* Encoded error type for bad UAHC DMA */ 193 - __BITFIELD_FIELD(uint64_t xm_bad_dma_type:4, 194 - /* Reserved */ 195 - __BITFIELD_FIELD(uint64_t reserved_13_39:27, 196 - /* Select the IOI read command used by DMA accesses */ 197 - __BITFIELD_FIELD(uint64_t dma_read_cmd:1, 198 - /* Reserved */ 199 - __BITFIELD_FIELD(uint64_t reserved_10_11:2, 200 - /* Select endian format for DMA accesses to the L2c: 201 - * 0x0 = Little endian 202 - *` 0x1 = Big endian 203 - * 0x2 = Reserved 204 - * 0x3 = Reserved 205 - */ 206 - __BITFIELD_FIELD(uint64_t dma_endian_mode:2, 207 - /* Reserved */ 208 - __BITFIELD_FIELD(uint64_t reserved_2_7:6, 209 - /* Select endian format for IOI CSR access to UAHC: 210 - * 0x0 = Little endian 211 - *` 0x1 = Big endian 212 - * 0x2 = Reserved 213 - * 0x3 = Reserved 214 - */ 215 - __BITFIELD_FIELD(uint64_t csr_endian_mode:2, 216 - ;)))))))))))) 217 - } s; 218 - }; 153 + /* 154 + * UCTL Shim Features Register 155 + */ 156 + #define USBDRD_UCTL_SHIM_CFG 0xe8 157 + /* Out-of-bound UAHC register access: 0 = read, 1 = write */ 158 + # define USBDRD_UCTL_SHIM_CFG_XS_NCB_OOB_WRN BIT(63) 159 + /* SRCID error log for out-of-bound UAHC register access: 160 + * [59:58] = chipID 161 + * [57] = Request source: 0 = core, 1 = NCB-device 162 + * [56:51] = Core/NCB-device number, [56] always 0 for NCB devices 163 + * [50:48] = SubID 164 + */ 165 + # define USBDRD_UCTL_SHIM_CFG_XS_NCB_OOB_OSRC GENMASK(59, 48) 166 + /* Error log for bad UAHC DMA access: 0 = Read log, 1 = Write log */ 167 + # define USBDRD_UCTL_SHIM_CFG_XM_BAD_DMA_WRN BIT(47) 168 + /* Encoded error type for bad UAHC DMA */ 169 + # define USBDRD_UCTL_SHIM_CFG_XM_BAD_DMA_TYPE GENMASK(43, 40) 170 + /* Select the IOI read command used by DMA accesses */ 171 + # define USBDRD_UCTL_SHIM_CFG_DMA_READ_CMD BIT(12) 172 + /* Select endian format for DMA accesses to the L2C: 173 + * 0x0 = Little endian 174 + * 0x1 = Big endian 175 + * 0x2 = Reserved 176 + * 0x3 = Reserved 177 + */ 178 + # define USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE GENMASK(9, 8) 179 + /* Select endian format for IOI CSR access to UAHC: 180 + * 0x0 = Little endian 181 + * 0x1 = Big endian 182 + * 0x2 = Reserved 183 + * 0x3 = Reserved 184 + */ 185 + # define USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE GENMASK(1, 0) 219 186 220 - #define OCTEON_H_CLKDIV_SEL 8 221 - #define OCTEON_MIN_H_CLK_RATE 150000000 222 - #define OCTEON_MAX_H_CLK_RATE 300000000 187 + #define USBDRD_UCTL_ECC 0xf0 188 + #define USBDRD_UCTL_SPARE1 0xf8 223 189 224 190 static DEFINE_MUTEX(dwc3_octeon_clocks_mutex); 225 - static uint8_t clk_div[OCTEON_H_CLKDIV_SEL] = {1, 2, 4, 6, 8, 16, 24, 32}; 226 191 227 - 228 - static int dwc3_octeon_config_power(struct device *dev, u64 base) 192 + #ifdef CONFIG_CAVIUM_OCTEON_SOC 193 + #include <asm/octeon/octeon.h> 194 + static inline uint64_t dwc3_octeon_readq(void __iomem *addr) 229 195 { 230 - #define UCTL_HOST_CFG 0xe0 231 - union cvm_usbdrd_uctl_host_cfg uctl_host_cfg; 196 + return cvmx_readq_csr(addr); 197 + } 198 + 199 + static inline void dwc3_octeon_writeq(void __iomem *base, uint64_t val) 200 + { 201 + cvmx_writeq_csr(base, val); 202 + } 203 + 204 + static void dwc3_octeon_config_gpio(int index, int gpio) 205 + { 232 206 union cvmx_gpio_bit_cfgx gpio_bit; 207 + 208 + if ((OCTEON_IS_MODEL(OCTEON_CN73XX) || 209 + OCTEON_IS_MODEL(OCTEON_CNF75XX)) 210 + && gpio <= 31) { 211 + gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio)); 212 + gpio_bit.s.tx_oe = 1; 213 + gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x15); 214 + cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64); 215 + } else if (gpio <= 15) { 216 + gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio)); 217 + gpio_bit.s.tx_oe = 1; 218 + gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19); 219 + cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64); 220 + } else { 221 + gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_XBIT_CFGX(gpio)); 222 + gpio_bit.s.tx_oe = 1; 223 + gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19); 224 + cvmx_write_csr(CVMX_GPIO_XBIT_CFGX(gpio), gpio_bit.u64); 225 + } 226 + } 227 + #else 228 + static inline uint64_t dwc3_octeon_readq(void __iomem *addr) 229 + { 230 + return 0; 231 + } 232 + 233 + static inline void dwc3_octeon_writeq(void __iomem *base, uint64_t val) { } 234 + 235 + static inline void dwc3_octeon_config_gpio(int index, int gpio) { } 236 + #endif 237 + 238 + static int dwc3_octeon_get_divider(void) 239 + { 240 + static const uint8_t clk_div[] = { 1, 2, 4, 6, 8, 16, 24, 32 }; 241 + int div = 0; 242 + 243 + while (div < ARRAY_SIZE(clk_div)) { 244 + uint64_t rate = octeon_get_io_clock_rate() / clk_div[div]; 245 + if (rate <= 300000000 && rate >= 150000000) 246 + break; 247 + div++; 248 + } 249 + 250 + return div; 251 + } 252 + 253 + static int dwc3_octeon_config_power(struct device *dev, void __iomem *base) 254 + { 233 255 uint32_t gpio_pwr[3]; 234 256 int gpio, len, power_active_low; 235 257 struct device_node *node = dev->of_node; 236 - int index = (base >> 24) & 1; 258 + u64 val; 259 + void __iomem *uctl_host_cfg_reg = base + USBDRD_UCTL_HOST_CFG; 237 260 238 261 if (of_find_property(node, "power", &len) != NULL) { 239 262 if (len == 12) { ··· 271 248 dev_err(dev, "invalid power configuration\n"); 272 249 return -EINVAL; 273 250 } 274 - if ((OCTEON_IS_MODEL(OCTEON_CN73XX) || 275 - OCTEON_IS_MODEL(OCTEON_CNF75XX)) 276 - && gpio <= 31) { 277 - gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio)); 278 - gpio_bit.s.tx_oe = 1; 279 - gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x15); 280 - cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64); 281 - } else if (gpio <= 15) { 282 - gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_BIT_CFGX(gpio)); 283 - gpio_bit.s.tx_oe = 1; 284 - gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19); 285 - cvmx_write_csr(CVMX_GPIO_BIT_CFGX(gpio), gpio_bit.u64); 286 - } else { 287 - gpio_bit.u64 = cvmx_read_csr(CVMX_GPIO_XBIT_CFGX(gpio)); 288 - gpio_bit.s.tx_oe = 1; 289 - gpio_bit.s.output_sel = (index == 0 ? 0x14 : 0x19); 290 - cvmx_write_csr(CVMX_GPIO_XBIT_CFGX(gpio), gpio_bit.u64); 291 - } 251 + dwc3_octeon_config_gpio(((u64)base >> 24) & 1, gpio); 292 252 293 253 /* Enable XHCI power control and set if active high or low. */ 294 - uctl_host_cfg.u64 = cvmx_read_csr(base + UCTL_HOST_CFG); 295 - uctl_host_cfg.s.ppc_en = 1; 296 - uctl_host_cfg.s.ppc_active_high_en = !power_active_low; 297 - cvmx_write_csr(base + UCTL_HOST_CFG, uctl_host_cfg.u64); 254 + val = dwc3_octeon_readq(uctl_host_cfg_reg); 255 + val |= USBDRD_UCTL_HOST_PPC_EN; 256 + if (power_active_low) 257 + val &= ~USBDRD_UCTL_HOST_PPC_ACTIVE_HIGH_EN; 258 + else 259 + val |= USBDRD_UCTL_HOST_PPC_ACTIVE_HIGH_EN; 260 + dwc3_octeon_writeq(uctl_host_cfg_reg, val); 298 261 } else { 299 262 /* Disable XHCI power control and set if active high. */ 300 - uctl_host_cfg.u64 = cvmx_read_csr(base + UCTL_HOST_CFG); 301 - uctl_host_cfg.s.ppc_en = 0; 302 - uctl_host_cfg.s.ppc_active_high_en = 0; 303 - cvmx_write_csr(base + UCTL_HOST_CFG, uctl_host_cfg.u64); 263 + val = dwc3_octeon_readq(uctl_host_cfg_reg); 264 + val &= ~USBDRD_UCTL_HOST_PPC_EN; 265 + val &= ~USBDRD_UCTL_HOST_PPC_ACTIVE_HIGH_EN; 266 + dwc3_octeon_writeq(uctl_host_cfg_reg, val); 304 267 dev_info(dev, "power control disabled\n"); 305 268 } 306 269 return 0; 307 270 } 308 271 309 - static int dwc3_octeon_clocks_start(struct device *dev, u64 base) 272 + static int dwc3_octeon_clocks_start(struct device *dev, void __iomem *base) 310 273 { 311 - union cvm_usbdrd_uctl_ctl uctl_ctl; 312 - int ref_clk_sel = 2; 313 - u64 div; 274 + int i, div, mpll_mul, ref_clk_fsel, ref_clk_sel = 2; 314 275 u32 clock_rate; 315 - int mpll_mul; 316 - int i; 317 - u64 h_clk_rate; 318 - u64 uctl_ctl_reg = base; 276 + u64 val; 277 + void __iomem *uctl_ctl_reg = base + USBDRD_UCTL_CTL; 319 278 320 279 if (dev->of_node) { 321 280 const char *ss_clock_type; ··· 361 356 /* Step 2: Select GPIO for overcurrent indication, if desired. SKIP */ 362 357 363 358 /* Step 3: Assert all resets. */ 364 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 365 - uctl_ctl.s.uphy_rst = 1; 366 - uctl_ctl.s.uahc_rst = 1; 367 - uctl_ctl.s.uctl_rst = 1; 368 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 359 + val = dwc3_octeon_readq(uctl_ctl_reg); 360 + val |= USBDRD_UCTL_CTL_UPHY_RST | 361 + USBDRD_UCTL_CTL_UAHC_RST | 362 + USBDRD_UCTL_CTL_UCTL_RST; 363 + dwc3_octeon_writeq(uctl_ctl_reg, val); 369 364 370 365 /* Step 4a: Reset the clock dividers. */ 371 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 372 - uctl_ctl.s.h_clkdiv_rst = 1; 373 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 366 + val = dwc3_octeon_readq(uctl_ctl_reg); 367 + val |= USBDRD_UCTL_CTL_H_CLKDIV_RST; 368 + dwc3_octeon_writeq(uctl_ctl_reg, val); 374 369 375 370 /* Step 4b: Select controller clock frequency. */ 376 - for (div = 0; div < OCTEON_H_CLKDIV_SEL; div++) { 377 - h_clk_rate = octeon_get_io_clock_rate() / clk_div[div]; 378 - if (h_clk_rate <= OCTEON_MAX_H_CLK_RATE && 379 - h_clk_rate >= OCTEON_MIN_H_CLK_RATE) 380 - break; 381 - } 382 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 383 - uctl_ctl.s.h_clkdiv_sel = div; 384 - uctl_ctl.s.h_clk_en = 1; 385 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 386 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 387 - if ((div != uctl_ctl.s.h_clkdiv_sel) || (!uctl_ctl.s.h_clk_en)) { 371 + div = dwc3_octeon_get_divider(); 372 + val = dwc3_octeon_readq(uctl_ctl_reg); 373 + val &= ~USBDRD_UCTL_CTL_H_CLKDIV_SEL; 374 + val |= FIELD_PREP(USBDRD_UCTL_CTL_H_CLKDIV_SEL, div); 375 + val |= USBDRD_UCTL_CTL_H_CLK_EN; 376 + dwc3_octeon_writeq(uctl_ctl_reg, val); 377 + val = dwc3_octeon_readq(uctl_ctl_reg); 378 + if ((div != FIELD_GET(USBDRD_UCTL_CTL_H_CLKDIV_SEL, val)) || 379 + (!(FIELD_GET(USBDRD_UCTL_CTL_H_CLK_EN, val)))) { 388 380 dev_err(dev, "dwc3 controller clock init failure.\n"); 389 381 return -EINVAL; 390 382 } 391 383 392 384 /* Step 4c: Deassert the controller clock divider reset. */ 393 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 394 - uctl_ctl.s.h_clkdiv_rst = 0; 395 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 385 + val &= ~USBDRD_UCTL_CTL_H_CLKDIV_RST; 386 + dwc3_octeon_writeq(uctl_ctl_reg, val); 396 387 397 388 /* Step 5a: Reference clock configuration. */ 398 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 399 - uctl_ctl.s.ref_clk_sel = ref_clk_sel; 400 - uctl_ctl.s.ref_clk_fsel = 0x07; 401 - uctl_ctl.s.ref_clk_div2 = 0; 389 + val = dwc3_octeon_readq(uctl_ctl_reg); 390 + val &= ~USBDRD_UCTL_CTL_REF_CLK_DIV2; 391 + val &= ~USBDRD_UCTL_CTL_REF_CLK_SEL; 392 + val |= FIELD_PREP(USBDRD_UCTL_CTL_REF_CLK_SEL, ref_clk_sel); 393 + 394 + ref_clk_fsel = 0x07; 402 395 switch (clock_rate) { 403 396 default: 404 397 dev_warn(dev, "Invalid ref_clk %u, using 100000000 instead\n", ··· 405 402 case 100000000: 406 403 mpll_mul = 0x19; 407 404 if (ref_clk_sel < 2) 408 - uctl_ctl.s.ref_clk_fsel = 0x27; 405 + ref_clk_fsel = 0x27; 409 406 break; 410 407 case 50000000: 411 408 mpll_mul = 0x32; ··· 414 411 mpll_mul = 0x28; 415 412 break; 416 413 } 417 - uctl_ctl.s.mpll_multiplier = mpll_mul; 414 + val &= ~USBDRD_UCTL_CTL_REF_CLK_FSEL; 415 + val |= FIELD_PREP(USBDRD_UCTL_CTL_REF_CLK_FSEL, ref_clk_fsel); 416 + 417 + val &= ~USBDRD_UCTL_CTL_MPLL_MULTIPLIER; 418 + val |= FIELD_PREP(USBDRD_UCTL_CTL_MPLL_MULTIPLIER, mpll_mul); 418 419 419 420 /* Step 5b: Configure and enable spread-spectrum for SuperSpeed. */ 420 - uctl_ctl.s.ssc_en = 1; 421 + val |= USBDRD_UCTL_CTL_SSC_EN; 421 422 422 423 /* Step 5c: Enable SuperSpeed. */ 423 - uctl_ctl.s.ref_ssp_en = 1; 424 + val |= USBDRD_UCTL_CTL_REF_SSP_EN; 424 425 425 426 /* Step 5d: Configure PHYs. SKIP */ 426 427 427 428 /* Step 6a & 6b: Power up PHYs. */ 428 - uctl_ctl.s.hs_power_en = 1; 429 - uctl_ctl.s.ss_power_en = 1; 430 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 429 + val |= USBDRD_UCTL_CTL_HS_POWER_EN; 430 + val |= USBDRD_UCTL_CTL_SS_POWER_EN; 431 + dwc3_octeon_writeq(uctl_ctl_reg, val); 431 432 432 433 /* Step 7: Wait 10 controller-clock cycles to take effect. */ 433 434 udelay(10); 434 435 435 436 /* Step 8a: Deassert UCTL reset signal. */ 436 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 437 - uctl_ctl.s.uctl_rst = 0; 438 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 437 + val = dwc3_octeon_readq(uctl_ctl_reg); 438 + val &= ~USBDRD_UCTL_CTL_UCTL_RST; 439 + dwc3_octeon_writeq(uctl_ctl_reg, val); 439 440 440 441 /* Step 8b: Wait 10 controller-clock cycles. */ 441 442 udelay(10); ··· 449 442 return -EINVAL; 450 443 451 444 /* Step 8d: Deassert UAHC reset signal. */ 452 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 453 - uctl_ctl.s.uahc_rst = 0; 454 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 445 + val = dwc3_octeon_readq(uctl_ctl_reg); 446 + val &= ~USBDRD_UCTL_CTL_UAHC_RST; 447 + dwc3_octeon_writeq(uctl_ctl_reg, val); 455 448 456 449 /* Step 8e: Wait 10 controller-clock cycles. */ 457 450 udelay(10); 458 451 459 452 /* Step 9: Enable conditional coprocessor clock of UCTL. */ 460 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 461 - uctl_ctl.s.csclk_en = 1; 462 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 453 + val = dwc3_octeon_readq(uctl_ctl_reg); 454 + val |= USBDRD_UCTL_CTL_CSCLK_EN; 455 + dwc3_octeon_writeq(uctl_ctl_reg, val); 463 456 464 457 /*Step 10: Set for host mode only. */ 465 - uctl_ctl.u64 = cvmx_read_csr(uctl_ctl_reg); 466 - uctl_ctl.s.drd_mode = 0; 467 - cvmx_write_csr(uctl_ctl_reg, uctl_ctl.u64); 458 + val = dwc3_octeon_readq(uctl_ctl_reg); 459 + val &= ~USBDRD_UCTL_CTL_DRD_MODE; 460 + dwc3_octeon_writeq(uctl_ctl_reg, val); 468 461 469 462 return 0; 470 463 } 471 464 472 - static void __init dwc3_octeon_set_endian_mode(u64 base) 465 + static void __init dwc3_octeon_set_endian_mode(void __iomem *base) 473 466 { 474 - #define UCTL_SHIM_CFG 0xe8 475 - union cvm_usbdrd_uctl_shim_cfg shim_cfg; 467 + u64 val; 468 + void __iomem *uctl_shim_cfg_reg = base + USBDRD_UCTL_SHIM_CFG; 476 469 477 - shim_cfg.u64 = cvmx_read_csr(base + UCTL_SHIM_CFG); 470 + val = dwc3_octeon_readq(uctl_shim_cfg_reg); 471 + val &= ~USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE; 472 + val &= ~USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE; 478 473 #ifdef __BIG_ENDIAN 479 - shim_cfg.s.dma_endian_mode = 1; 480 - shim_cfg.s.csr_endian_mode = 1; 481 - #else 482 - shim_cfg.s.dma_endian_mode = 0; 483 - shim_cfg.s.csr_endian_mode = 0; 474 + val |= FIELD_PREP(USBDRD_UCTL_SHIM_CFG_DMA_ENDIAN_MODE, 1); 475 + val |= FIELD_PREP(USBDRD_UCTL_SHIM_CFG_CSR_ENDIAN_MODE, 1); 484 476 #endif 485 - cvmx_write_csr(base + UCTL_SHIM_CFG, shim_cfg.u64); 477 + dwc3_octeon_writeq(uctl_shim_cfg_reg, val); 486 478 } 487 479 488 - #define CVMX_USBDRDX_UCTL_CTL(index) \ 489 - (CVMX_ADD_IO_SEG(0x0001180068000000ull) + \ 490 - ((index & 1) * 0x1000000ull)) 491 - static void __init dwc3_octeon_phy_reset(u64 base) 480 + static void __init dwc3_octeon_phy_reset(void __iomem *base) 492 481 { 493 - union cvm_usbdrd_uctl_ctl uctl_ctl; 494 - int index = (base >> 24) & 1; 482 + u64 val; 483 + void __iomem *uctl_ctl_reg = base + USBDRD_UCTL_CTL; 495 484 496 - uctl_ctl.u64 = cvmx_read_csr(CVMX_USBDRDX_UCTL_CTL(index)); 497 - uctl_ctl.s.uphy_rst = 0; 498 - cvmx_write_csr(CVMX_USBDRDX_UCTL_CTL(index), uctl_ctl.u64); 485 + val = dwc3_octeon_readq(uctl_ctl_reg); 486 + val &= ~USBDRD_UCTL_CTL_UPHY_RST; 487 + dwc3_octeon_writeq(uctl_ctl_reg, val); 499 488 } 500 489 501 490 static int __init dwc3_octeon_device_init(void) ··· 530 527 } 531 528 532 529 mutex_lock(&dwc3_octeon_clocks_mutex); 533 - if (dwc3_octeon_clocks_start(&pdev->dev, (u64)base) == 0) 530 + if (dwc3_octeon_clocks_start(&pdev->dev, base) == 0) 534 531 dev_info(&pdev->dev, "clocks initialized.\n"); 535 - dwc3_octeon_set_endian_mode((u64)base); 536 - dwc3_octeon_phy_reset((u64)base); 532 + dwc3_octeon_set_endian_mode(base); 533 + dwc3_octeon_phy_reset(base); 537 534 mutex_unlock(&dwc3_octeon_clocks_mutex); 538 535 devm_iounmap(&pdev->dev, base); 539 536 devm_release_mem_region(&pdev->dev, res->start,
+33 -14
arch/mips/configs/ci20_defconfig
··· 19 19 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 20 20 CONFIG_KALLSYMS_ALL=y 21 21 CONFIG_EMBEDDED=y 22 - # CONFIG_VM_EVENT_COUNTERS is not set 23 - # CONFIG_COMPAT_BRK is not set 24 - CONFIG_SLAB=y 25 22 CONFIG_MACH_INGENIC_SOC=y 26 23 CONFIG_JZ4780_CI20=y 27 24 CONFIG_HIGHMEM=y 28 25 CONFIG_HZ_100=y 29 - # CONFIG_SECCOMP is not set 30 26 # CONFIG_SUSPEND is not set 27 + # CONFIG_SECCOMP is not set 31 28 CONFIG_MODULES=y 32 29 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set 30 + CONFIG_SLAB=y 31 + # CONFIG_COMPAT_BRK is not set 33 32 # CONFIG_COMPACTION is not set 34 33 CONFIG_CMA=y 34 + # CONFIG_VM_EVENT_COUNTERS is not set 35 35 CONFIG_NET=y 36 36 CONFIG_PACKET=y 37 37 CONFIG_UNIX=y ··· 40 40 CONFIG_IP_PNP_DHCP=y 41 41 # CONFIG_INET_DIAG is not set 42 42 # CONFIG_IPV6 is not set 43 - # CONFIG_WIRELESS is not set 43 + CONFIG_BT=m 44 + # CONFIG_BT_LE is not set 45 + CONFIG_BT_HCIUART=m 46 + CONFIG_BT_HCIUART_BCM=y 47 + CONFIG_CFG80211=m 48 + CONFIG_CFG80211_WEXT=y 44 49 CONFIG_DEVTMPFS=y 45 50 CONFIG_FW_LOADER=m 46 51 # CONFIG_ALLOW_DEV_COREDUMP is not set ··· 73 68 # CONFIG_NET_VENDOR_STMICRO is not set 74 69 # CONFIG_NET_VENDOR_VIA is not set 75 70 # CONFIG_NET_VENDOR_WIZNET is not set 76 - # CONFIG_WLAN is not set 71 + # CONFIG_WLAN_VENDOR_ADMTEK is not set 72 + # CONFIG_WLAN_VENDOR_ATH is not set 73 + # CONFIG_WLAN_VENDOR_ATMEL is not set 74 + CONFIG_BRCMFMAC=m 75 + # CONFIG_WLAN_VENDOR_CISCO is not set 76 + # CONFIG_WLAN_VENDOR_INTEL is not set 77 + # CONFIG_WLAN_VENDOR_INTERSIL is not set 78 + # CONFIG_WLAN_VENDOR_MARVELL is not set 79 + # CONFIG_WLAN_VENDOR_MEDIATEK is not set 80 + # CONFIG_WLAN_VENDOR_MICROCHIP is not set 81 + # CONFIG_WLAN_VENDOR_PURELIFI is not set 82 + # CONFIG_WLAN_VENDOR_RALINK is not set 83 + # CONFIG_WLAN_VENDOR_REALTEK is not set 84 + # CONFIG_WLAN_VENDOR_RSI is not set 85 + # CONFIG_WLAN_VENDOR_SILABS is not set 86 + # CONFIG_WLAN_VENDOR_ST is not set 87 + # CONFIG_WLAN_VENDOR_TI is not set 88 + # CONFIG_WLAN_VENDOR_ZYDAS is not set 89 + # CONFIG_WLAN_VENDOR_QUANTENNA is not set 77 90 CONFIG_KEYBOARD_GPIO=m 78 91 # CONFIG_INPUT_MOUSE is not set 79 - CONFIG_VT_HW_CONSOLE_BINDING=y 80 92 CONFIG_LEGACY_PTY_COUNT=2 81 93 CONFIG_SERIAL_8250=y 82 94 CONFIG_SERIAL_8250_CONSOLE=y ··· 101 79 CONFIG_SERIAL_8250_RUNTIME_UARTS=5 102 80 CONFIG_SERIAL_8250_INGENIC=y 103 81 CONFIG_SERIAL_OF_PLATFORM=y 82 + CONFIG_SERIAL_DEV_BUS=y 104 83 CONFIG_I2C=y 105 84 CONFIG_I2C_JZ4780=y 106 85 CONFIG_SPI=y ··· 122 99 CONFIG_IR_GPIO_TX=m 123 100 CONFIG_MEDIA_SUPPORT=m 124 101 CONFIG_DRM=m 102 + CONFIG_DRM_DISPLAY_CONNECTOR=m 125 103 CONFIG_DRM_INGENIC=m 126 104 CONFIG_DRM_INGENIC_DW_HDMI=m 127 - CONFIG_DRM_DISPLAY_CONNECTOR=m 128 - # CONFIG_VGA_CONSOLE is not set 129 105 CONFIG_FB=y 106 + # CONFIG_VGA_CONSOLE is not set 130 107 CONFIG_FRAMEBUFFER_CONSOLE=y 131 - # CONFIG_HID is not set 132 108 CONFIG_USB=y 133 109 CONFIG_USB_STORAGE=y 134 110 CONFIG_USB_DWC2=y ··· 147 125 CONFIG_LEDS_TRIGGER_BACKLIGHT=m 148 126 CONFIG_LEDS_TRIGGER_CPU=y 149 127 CONFIG_LEDS_TRIGGER_ACTIVITY=y 150 - CONFIG_LEDS_TRIGGER_GPIO=y 151 128 CONFIG_LEDS_TRIGGER_DEFAULT_ON=y 152 129 CONFIG_LEDS_TRIGGER_TRANSIENT=y 153 130 CONFIG_LEDS_TRIGGER_CAMERA=m ··· 165 144 CONFIG_PWM=y 166 145 CONFIG_PWM_JZ4740=m 167 146 CONFIG_NVMEM_JZ4780_EFUSE=y 168 - CONFIG_JZ4770_PHY=y 169 147 CONFIG_EXT4_FS=y 170 148 # CONFIG_DNOTIFY is not set 171 149 CONFIG_AUTOFS_FS=y ··· 177 157 CONFIG_UBIFS_FS=y 178 158 CONFIG_NFS_FS=y 179 159 CONFIG_ROOT_NFS=y 180 - CONFIG_NLS=y 181 160 CONFIG_NLS_CODEPAGE_437=y 182 161 CONFIG_NLS_CODEPAGE_737=y 183 162 CONFIG_NLS_CODEPAGE_775=y ··· 215 196 CONFIG_NLS_KOI8_R=y 216 197 CONFIG_NLS_KOI8_U=y 217 198 CONFIG_NLS_UTF8=y 199 + # CONFIG_CRYPTO_AES is not set 218 200 CONFIG_DMA_CMA=y 219 201 CONFIG_CMA_SIZE_MBYTES=32 220 202 CONFIG_PRINTK_TIME=y ··· 226 206 CONFIG_PANIC_ON_OOPS=y 227 207 CONFIG_PANIC_TIMEOUT=10 228 208 # CONFIG_SCHED_DEBUG is not set 229 - # CONFIG_DEBUG_PREEMPT is not set 230 209 CONFIG_STACKTRACE=y 231 210 # CONFIG_FTRACE is not set 232 211 CONFIG_CMDLINE_BOOL=y
+7
arch/mips/configs/loongson3_defconfig
··· 276 276 CONFIG_MEDIA_USB_SUPPORT=y 277 277 CONFIG_USB_VIDEO_CLASS=m 278 278 CONFIG_DRM=y 279 + CONFIG_DRM_AMDGPU=m 280 + CONFIG_DRM_AMDGPU_SI=y 281 + CONFIG_DRM_AMDGPU_CIK=y 282 + CONFIG_DRM_AMDGPU_USERPTR=y 283 + CONFIG_DRM_AMD_ACP=y 284 + CONFIG_DRM_AMD_DC=y 285 + CONFIG_DRM_AMD_DC_SI=y 279 286 CONFIG_DRM_RADEON=m 280 287 CONFIG_DRM_QXL=y 281 288 CONFIG_DRM_VIRTIO_GPU=y
+59 -2
arch/mips/generic/board-ingenic.c
··· 17 17 #include <linux/types.h> 18 18 19 19 #include <asm/bootinfo.h> 20 + #include <asm/io.h> 20 21 #include <asm/machine.h> 21 22 #include <asm/reboot.h> 22 23 ··· 61 60 } 62 61 } 63 62 63 + #define INGENIC_CGU_BASE 0x10000000 64 + #define JZ4750_CGU_CPCCR_ECS BIT(30) 65 + #define JZ4760_CGU_CPCCR_ECS BIT(31) 66 + 67 + static __init void ingenic_force_12M_ext(const void *fdt, unsigned int mask) 68 + { 69 + const __be32 *prop; 70 + unsigned int cpccr; 71 + void __iomem *cgu; 72 + bool use_div; 73 + int offset; 74 + 75 + offset = fdt_path_offset(fdt, "/ext"); 76 + if (offset < 0) 77 + return; 78 + 79 + prop = fdt_getprop(fdt, offset, "clock-frequency", NULL); 80 + if (!prop) 81 + return; 82 + 83 + /* 84 + * If the external oscillator is 24 MHz, enable the /2 divider to 85 + * drive it down to 12 MHz, since this is what the hardware can work 86 + * with. 87 + * The 16 MHz cutoff value is arbitrary; setting it to 12 MHz would not 88 + * work as the crystal frequency (as reported in the Device Tree) might 89 + * be slightly above this value. 90 + */ 91 + use_div = be32_to_cpup(prop) >= 16000000; 92 + 93 + cgu = ioremap(INGENIC_CGU_BASE, 0x4); 94 + if (!cgu) 95 + return; 96 + 97 + cpccr = ioread32(cgu); 98 + if (use_div) 99 + cpccr |= mask; 100 + else 101 + cpccr &= ~mask; 102 + iowrite32(cpccr, cgu); 103 + 104 + iounmap(cgu); 105 + } 106 + 64 107 static __init const void *ingenic_fixup_fdt(const void *fdt, const void *match_data) 65 108 { 66 109 /* ··· 117 72 118 73 mips_machtype = (unsigned long)match_data; 119 74 system_type = ingenic_get_system_type(mips_machtype); 75 + 76 + switch (mips_machtype) { 77 + case MACH_INGENIC_JZ4750: 78 + case MACH_INGENIC_JZ4755: 79 + ingenic_force_12M_ext(fdt, JZ4750_CGU_CPCCR_ECS); 80 + break; 81 + case MACH_INGENIC_JZ4760: 82 + ingenic_force_12M_ext(fdt, JZ4760_CGU_CPCCR_ECS); 83 + break; 84 + default: 85 + break; 86 + } 120 87 121 88 return fdt; 122 89 } ··· 174 117 ingenic_wait_instr(); 175 118 } 176 119 177 - static int __maybe_unused ingenic_pm_enter(suspend_state_t state) 120 + static int ingenic_pm_enter(suspend_state_t state) 178 121 { 179 122 ingenic_wait_instr(); 180 123 181 124 return 0; 182 125 } 183 126 184 - static const struct platform_suspend_ops ingenic_pm_ops __maybe_unused = { 127 + static const struct platform_suspend_ops ingenic_pm_ops = { 185 128 .valid = suspend_valid_only_mem, 186 129 .enter = ingenic_pm_enter, 187 130 };
+2 -2
arch/mips/include/asm/cpu-features.h
··· 125 125 ({ \ 126 126 int __res; \ 127 127 \ 128 - switch (current_cpu_type()) { \ 128 + switch (boot_cpu_type()) { \ 129 129 case CPU_CAVIUM_OCTEON: \ 130 130 case CPU_CAVIUM_OCTEON_PLUS: \ 131 131 case CPU_CAVIUM_OCTEON2: \ ··· 368 368 ({ \ 369 369 int __res; \ 370 370 \ 371 - switch (current_cpu_type()) { \ 371 + switch (boot_cpu_type()) { \ 372 372 case CPU_M14KC: \ 373 373 case CPU_74K: \ 374 374 case CPU_1074K: \
+1 -1
arch/mips/include/asm/dec/prom.h
··· 70 70 */ 71 71 typedef struct { 72 72 int pagesize; 73 - unsigned char bitmap[0]; 73 + unsigned char bitmap[]; 74 74 } memmap; 75 75 76 76
+1
arch/mips/include/asm/io.h
··· 554 554 * access 555 555 */ 556 556 #define xlate_dev_mem_ptr(p) __va(p) 557 + #define unxlate_dev_mem_ptr(p, v) do { } while (0) 557 558 558 559 void __ioread64_copy(void *to, const void __iomem *from, size_t count); 559 560
-1
arch/mips/include/asm/mach-loongson32/loongson1.h
··· 48 48 #include <regs-clk.h> 49 49 #include <regs-mux.h> 50 50 #include <regs-rtc.h> 51 - #include <regs-wdt.h> 52 51 53 52 #endif /* __ASM_MACH_LOONGSON32_LOONGSON1_H */
-15
arch/mips/include/asm/mach-loongson32/regs-wdt.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - * 5 - * Loongson 1 Watchdog Register Definitions. 6 - */ 7 - 8 - #ifndef __ASM_MACH_LOONGSON32_REGS_WDT_H 9 - #define __ASM_MACH_LOONGSON32_REGS_WDT_H 10 - 11 - #define WDT_EN 0x0 12 - #define WDT_TIMER 0x4 13 - #define WDT_SET 0x8 14 - 15 - #endif /* __ASM_MACH_LOONGSON32_REGS_WDT_H */
-35
arch/mips/include/asm/mach-ralink/mt7620.h
··· 20 20 #define SYSC_REG_CHIP_REV 0x0c 21 21 #define SYSC_REG_SYSTEM_CONFIG0 0x10 22 22 #define SYSC_REG_SYSTEM_CONFIG1 0x14 23 - #define SYSC_REG_CLKCFG0 0x2c 24 - #define SYSC_REG_CPU_SYS_CLKCFG 0x3c 25 - #define SYSC_REG_CPLL_CONFIG0 0x54 26 - #define SYSC_REG_CPLL_CONFIG1 0x58 27 23 28 24 #define MT7620_CHIP_NAME0 0x3637544d 29 25 #define MT7620_CHIP_NAME1 0x20203032 30 26 #define MT7628_CHIP_NAME1 0x20203832 31 - 32 - #define SYSCFG0_XTAL_FREQ_SEL BIT(6) 33 27 34 28 #define CHIP_REV_PKG_MASK 0x1 35 29 #define CHIP_REV_PKG_SHIFT 16 36 30 #define CHIP_REV_VER_MASK 0xf 37 31 #define CHIP_REV_VER_SHIFT 8 38 32 #define CHIP_REV_ECO_MASK 0xf 39 - 40 - #define CLKCFG0_PERI_CLK_SEL BIT(4) 41 - 42 - #define CPU_SYS_CLKCFG_OCP_RATIO_SHIFT 16 43 - #define CPU_SYS_CLKCFG_OCP_RATIO_MASK 0xf 44 - #define CPU_SYS_CLKCFG_OCP_RATIO_1 0 /* 1:1 (Reserved) */ 45 - #define CPU_SYS_CLKCFG_OCP_RATIO_1_5 1 /* 1:1.5 (Reserved) */ 46 - #define CPU_SYS_CLKCFG_OCP_RATIO_2 2 /* 1:2 */ 47 - #define CPU_SYS_CLKCFG_OCP_RATIO_2_5 3 /* 1:2.5 (Reserved) */ 48 - #define CPU_SYS_CLKCFG_OCP_RATIO_3 4 /* 1:3 */ 49 - #define CPU_SYS_CLKCFG_OCP_RATIO_3_5 5 /* 1:3.5 (Reserved) */ 50 - #define CPU_SYS_CLKCFG_OCP_RATIO_4 6 /* 1:4 */ 51 - #define CPU_SYS_CLKCFG_OCP_RATIO_5 7 /* 1:5 */ 52 - #define CPU_SYS_CLKCFG_OCP_RATIO_10 8 /* 1:10 */ 53 - #define CPU_SYS_CLKCFG_CPU_FDIV_SHIFT 8 54 - #define CPU_SYS_CLKCFG_CPU_FDIV_MASK 0x1f 55 - #define CPU_SYS_CLKCFG_CPU_FFRAC_SHIFT 0 56 - #define CPU_SYS_CLKCFG_CPU_FFRAC_MASK 0x1f 57 - 58 - #define CPLL_CFG0_SW_CFG BIT(31) 59 - #define CPLL_CFG0_PLL_MULT_RATIO_SHIFT 16 60 - #define CPLL_CFG0_PLL_MULT_RATIO_MASK 0x7 61 - #define CPLL_CFG0_LC_CURFCK BIT(15) 62 - #define CPLL_CFG0_BYPASS_REF_CLK BIT(14) 63 - #define CPLL_CFG0_PLL_DIV_RATIO_SHIFT 10 64 - #define CPLL_CFG0_PLL_DIV_RATIO_MASK 0x3 65 - 66 - #define CPLL_CFG1_CPU_AUX1 BIT(25) 67 - #define CPLL_CFG1_CPU_AUX0 BIT(24) 68 33 69 34 #define SYSCFG0_DRAM_TYPE_MASK 0x3 70 35 #define SYSCFG0_DRAM_TYPE_SHIFT 4
-10
arch/mips/include/asm/mach-ralink/rt288x.h
··· 18 18 #define SYSC_REG_CHIP_NAME1 0x04 19 19 #define SYSC_REG_CHIP_ID 0x0c 20 20 #define SYSC_REG_SYSTEM_CONFIG 0x10 21 - #define SYSC_REG_CLKCFG 0x30 22 21 23 22 #define RT2880_CHIP_NAME0 0x38325452 24 23 #define RT2880_CHIP_NAME1 0x20203038 ··· 25 26 #define CHIP_ID_ID_MASK 0xff 26 27 #define CHIP_ID_ID_SHIFT 8 27 28 #define CHIP_ID_REV_MASK 0xff 28 - 29 - #define SYSTEM_CONFIG_CPUCLK_SHIFT 20 30 - #define SYSTEM_CONFIG_CPUCLK_MASK 0x3 31 - #define SYSTEM_CONFIG_CPUCLK_250 0x0 32 - #define SYSTEM_CONFIG_CPUCLK_266 0x1 33 - #define SYSTEM_CONFIG_CPUCLK_280 0x2 34 - #define SYSTEM_CONFIG_CPUCLK_300 0x3 35 - 36 - #define CLKCFG_SRAM_CS_N_WDT BIT(9) 37 29 38 30 #define RT2880_SDRAM_BASE 0x08000000 39 31 #define RT2880_MEM_SIZE_MIN 2
-21
arch/mips/include/asm/mach-ralink/rt305x.h
··· 67 67 #define CHIP_ID_ID_SHIFT 8 68 68 #define CHIP_ID_REV_MASK 0xff 69 69 70 - #define RT305X_SYSCFG_CPUCLK_SHIFT 18 71 - #define RT305X_SYSCFG_CPUCLK_MASK 0x1 72 - #define RT305X_SYSCFG_CPUCLK_LOW 0x0 73 - #define RT305X_SYSCFG_CPUCLK_HIGH 0x1 74 - 75 70 #define RT305X_SYSCFG_SRAM_CS0_MODE_SHIFT 2 76 - #define RT305X_SYSCFG_CPUCLK_MASK 0x1 77 71 #define RT305X_SYSCFG_SRAM_CS0_MODE_WDT 0x1 78 - 79 - #define RT3352_SYSCFG0_CPUCLK_SHIFT 8 80 - #define RT3352_SYSCFG0_CPUCLK_MASK 0x1 81 - #define RT3352_SYSCFG0_CPUCLK_LOW 0x0 82 - #define RT3352_SYSCFG0_CPUCLK_HIGH 0x1 83 - 84 - #define RT5350_SYSCFG0_CPUCLK_SHIFT 8 85 - #define RT5350_SYSCFG0_CPUCLK_MASK 0x3 86 - #define RT5350_SYSCFG0_CPUCLK_360 0x0 87 - #define RT5350_SYSCFG0_CPUCLK_320 0x2 88 - #define RT5350_SYSCFG0_CPUCLK_300 0x3 89 72 90 73 #define RT5350_SYSCFG0_DRAM_SIZE_SHIFT 12 91 74 #define RT5350_SYSCFG0_DRAM_SIZE_MASK 7 ··· 100 117 101 118 #define RT3352_SYSC_REG_SYSCFG0 0x010 102 119 #define RT3352_SYSC_REG_SYSCFG1 0x014 103 - #define RT3352_SYSC_REG_CLKCFG1 0x030 104 120 #define RT3352_SYSC_REG_RSTCTRL 0x034 105 121 #define RT3352_SYSC_REG_USB_PS 0x05c 106 122 107 - #define RT3352_CLKCFG0_XTAL_SEL BIT(20) 108 - #define RT3352_CLKCFG1_UPHY0_CLK_EN BIT(18) 109 - #define RT3352_CLKCFG1_UPHY1_CLK_EN BIT(20) 110 123 #define RT3352_RSTCTRL_UHST BIT(22) 111 124 #define RT3352_RSTCTRL_UDEV BIT(25) 112 125 #define RT3352_SYSCFG1_USB0_HOST_MODE BIT(10)
-8
arch/mips/include/asm/mach-ralink/rt3883.h
··· 92 92 #define RT3883_REVID_VER_ID_SHIFT 8 93 93 #define RT3883_REVID_ECO_ID_MASK 0x0f 94 94 95 - #define RT3883_SYSCFG0_DRAM_TYPE_DDR2 BIT(17) 96 - #define RT3883_SYSCFG0_CPUCLK_SHIFT 8 97 - #define RT3883_SYSCFG0_CPUCLK_MASK 0x3 98 - #define RT3883_SYSCFG0_CPUCLK_250 0x0 99 - #define RT3883_SYSCFG0_CPUCLK_384 0x1 100 - #define RT3883_SYSCFG0_CPUCLK_480 0x2 101 - #define RT3883_SYSCFG0_CPUCLK_500 0x3 102 - 103 95 #define RT3883_SYSCFG1_USB0_HOST_MODE BIT(10) 104 96 #define RT3883_SYSCFG1_PCIE_RC_MODE BIT(8) 105 97 #define RT3883_SYSCFG1_PCI_HOST_MODE BIT(7)
+2
arch/mips/include/asm/smp.h
··· 57 57 /* Mask of CPUs which are currently definitely operating coherently */ 58 58 extern cpumask_t cpu_coherent_mask; 59 59 60 + extern unsigned int smp_max_threads __initdata; 61 + 60 62 extern asmlinkage void smp_bootstrap(void); 61 63 62 64 extern void calculate_cpu_foreign_map(void);
+33
arch/mips/include/uapi/asm/inst.h
··· 273 273 }; 274 274 275 275 /* 276 + * func field for special2 MXU opcodes (Ingenic XBurst MXU). 277 + */ 278 + enum mxu_func { 279 + /* TODO, other MXU funcs */ 280 + mxu_lx_op = 0x28, 281 + }; 282 + 283 + /* 284 + * op field for special2 MXU LX opcodes (Ingenic XBurst MXU). 285 + */ 286 + enum lx_ingenic_func { 287 + mxu_lxb_op, 288 + mxu_lxh_op, 289 + /* reserved */ 290 + mxu_lxw_op = 3, 291 + mxu_lxbu_op, 292 + mxu_lxhu_op, 293 + /* more reserved */ 294 + }; 295 + 296 + /* 276 297 * BSHFL opcodes 277 298 */ 278 299 enum bshfl_func { ··· 795 774 ;)))))) 796 775 }; 797 776 777 + struct mxu_lx_format { /* SPEC2 MXU LX format instructions */ 778 + __BITFIELD_FIELD(unsigned int opcode : 6, 779 + __BITFIELD_FIELD(unsigned int rs : 5, 780 + __BITFIELD_FIELD(unsigned int rt : 5, 781 + __BITFIELD_FIELD(unsigned int rd : 5, 782 + __BITFIELD_FIELD(unsigned int strd : 2, 783 + __BITFIELD_FIELD(unsigned int op : 3, 784 + __BITFIELD_FIELD(unsigned int func : 6, 785 + ;))))))) 786 + }; 787 + 798 788 struct spec3_format { /* SPEC3 */ 799 789 __BITFIELD_FIELD(unsigned int opcode:6, 800 790 __BITFIELD_FIELD(unsigned int rs:5, ··· 1157 1125 struct loongson3_lswc2_format loongson3_lswc2_format; 1158 1126 struct loongson3_lsdc2_format loongson3_lsdc2_format; 1159 1127 struct loongson3_lscsr_format loongson3_lscsr_format; 1128 + struct mxu_lx_format mxu_lx_format; 1160 1129 }; 1161 1130 1162 1131 union mips16e_instruction {
+14
arch/mips/kernel/asm-offsets.c
··· 23 23 24 24 #include <linux/kvm_host.h> 25 25 26 + void output_ptreg_defines(void); 26 27 void output_ptreg_defines(void) 27 28 { 28 29 COMMENT("MIPS pt_regs offsets."); ··· 76 75 BLANK(); 77 76 } 78 77 78 + void output_task_defines(void); 79 79 void output_task_defines(void) 80 80 { 81 81 COMMENT("MIPS task_struct offsets."); ··· 91 89 BLANK(); 92 90 } 93 91 92 + void output_thread_info_defines(void); 94 93 void output_thread_info_defines(void) 95 94 { 96 95 COMMENT("MIPS thread_info offsets."); ··· 108 105 BLANK(); 109 106 } 110 107 108 + void output_thread_defines(void); 111 109 void output_thread_defines(void) 112 110 { 113 111 COMMENT("MIPS specific thread_struct offsets."); ··· 137 133 } 138 134 139 135 #ifdef CONFIG_MIPS_FP_SUPPORT 136 + void output_thread_fpu_defines(void); 140 137 void output_thread_fpu_defines(void) 141 138 { 142 139 OFFSET(THREAD_FPU, task_struct, thread.fpu); ··· 181 176 } 182 177 #endif 183 178 179 + void output_mm_defines(void); 184 180 void output_mm_defines(void) 185 181 { 186 182 COMMENT("Size of struct page"); ··· 216 210 } 217 211 218 212 #ifdef CONFIG_32BIT 213 + void output_sc_defines(void); 219 214 void output_sc_defines(void) 220 215 { 221 216 COMMENT("Linux sigcontext offsets."); ··· 239 232 #endif 240 233 241 234 #ifdef CONFIG_64BIT 235 + void output_sc_defines(void); 242 236 void output_sc_defines(void) 243 237 { 244 238 COMMENT("Linux sigcontext offsets."); ··· 253 245 } 254 246 #endif 255 247 248 + void output_signal_defined(void); 256 249 void output_signal_defined(void) 257 250 { 258 251 COMMENT("Linux signal numbers."); ··· 293 284 } 294 285 295 286 #ifdef CONFIG_CPU_CAVIUM_OCTEON 287 + void output_octeon_cop2_state_defines(void); 296 288 void output_octeon_cop2_state_defines(void) 297 289 { 298 290 COMMENT("Octeon specific octeon_cop2_state offsets."); ··· 325 315 #endif 326 316 327 317 #ifdef CONFIG_HIBERNATION 318 + void output_pbe_defines(void); 328 319 void output_pbe_defines(void) 329 320 { 330 321 COMMENT(" Linux struct pbe offsets. "); ··· 338 327 #endif 339 328 340 329 #ifdef CONFIG_CPU_PM 330 + void output_pm_defines(void); 341 331 void output_pm_defines(void) 342 332 { 343 333 COMMENT(" PM offsets. "); ··· 353 341 #endif 354 342 355 343 #ifdef CONFIG_MIPS_FP_SUPPORT 344 + void output_kvm_defines(void); 356 345 void output_kvm_defines(void) 357 346 { 358 347 COMMENT(" KVM/MIPS Specific offsets. "); ··· 398 385 #endif 399 386 400 387 #ifdef CONFIG_MIPS_CPS 388 + void output_cps_defines(void); 401 389 void output_cps_defines(void) 402 390 { 403 391 COMMENT(" MIPS CPS offsets. ");
+2 -13
arch/mips/kernel/smp-cps.c
··· 25 25 #include <asm/time.h> 26 26 #include <asm/uasm.h> 27 27 28 - static bool threads_disabled; 29 28 static DECLARE_BITMAP(core_power, NR_CPUS); 30 29 31 30 struct core_boot_config *mips_cps_core_bootcfg; 32 31 33 - static int __init setup_nothreads(char *s) 32 + static unsigned __init core_vpe_count(unsigned int cluster, unsigned core) 34 33 { 35 - threads_disabled = true; 36 - return 0; 37 - } 38 - early_param("nothreads", setup_nothreads); 39 - 40 - static unsigned core_vpe_count(unsigned int cluster, unsigned core) 41 - { 42 - if (threads_disabled) 43 - return 1; 44 - 45 - return mips_cps_numvps(cluster, core); 34 + return min(smp_max_threads, mips_cps_numvps(cluster, core)); 46 35 } 47 36 48 37 static void __init cps_smp_setup(void)
+2 -1
arch/mips/kernel/smp-mt.c
··· 46 46 static unsigned int __init smvp_vpe_init(unsigned int tc, unsigned int mvpconf0, 47 47 unsigned int ncpu) 48 48 { 49 - if (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT)) 49 + if (tc >= smp_max_threads || 50 + (tc > ((mvpconf0 & MVPCONF0_PVPE) >> MVPCONF0_PVPE_SHIFT))) 50 51 return ncpu; 51 52 52 53 /* Deactivate all but VPE 0 */
+18
arch/mips/kernel/smp.c
··· 73 73 74 74 cpumask_t cpu_coherent_mask; 75 75 76 + unsigned int smp_max_threads __initdata = UINT_MAX; 77 + 78 + static int __init early_nosmt(char *s) 79 + { 80 + smp_max_threads = 1; 81 + return 0; 82 + } 83 + early_param("nosmt", early_nosmt); 84 + 85 + static int __init early_smt(char *s) 86 + { 87 + get_option(&s, &smp_max_threads); 88 + /* Ensure at least one thread is available */ 89 + smp_max_threads = clamp_val(smp_max_threads, 1U, UINT_MAX); 90 + return 0; 91 + } 92 + early_param("smt", early_smt); 93 + 76 94 #ifdef CONFIG_GENERIC_IRQ_IPI 77 95 static struct irq_desc *call_desc; 78 96 static struct irq_desc *sched_desc;
+41
arch/mips/kernel/unaligned.c
··· 160 160 * The remaining opcodes are the ones that are really of 161 161 * interest. 162 162 */ 163 + #ifdef CONFIG_MACH_INGENIC 164 + case spec2_op: 165 + if (insn.mxu_lx_format.func != mxu_lx_op) 166 + goto sigbus; /* other MXU instructions we don't care */ 167 + 168 + switch (insn.mxu_lx_format.op) { 169 + case mxu_lxw_op: 170 + if (user && !access_ok(addr, 4)) 171 + goto sigbus; 172 + LoadW(addr, value, res); 173 + if (res) 174 + goto fault; 175 + compute_return_epc(regs); 176 + regs->regs[insn.mxu_lx_format.rd] = value; 177 + break; 178 + case mxu_lxh_op: 179 + if (user && !access_ok(addr, 2)) 180 + goto sigbus; 181 + LoadHW(addr, value, res); 182 + if (res) 183 + goto fault; 184 + compute_return_epc(regs); 185 + regs->regs[insn.dsp_format.rd] = value; 186 + break; 187 + case mxu_lxhu_op: 188 + if (user && !access_ok(addr, 2)) 189 + goto sigbus; 190 + LoadHWU(addr, value, res); 191 + if (res) 192 + goto fault; 193 + compute_return_epc(regs); 194 + regs->regs[insn.dsp_format.rd] = value; 195 + break; 196 + case mxu_lxb_op: 197 + case mxu_lxbu_op: 198 + goto sigbus; 199 + default: 200 + goto sigill; 201 + } 202 + break; 203 + #endif 163 204 case spec3_op: 164 205 if (insn.dsp_format.func == lx_op) { 165 206 switch (insn.dsp_format.op) {
+1 -1
arch/mips/loongson32/common/Makefile
··· 3 3 # Makefile for common code of loongson1 based machines. 4 4 # 5 5 6 - obj-y += time.o irq.o platform.o prom.o reset.o setup.o 6 + obj-y += time.o irq.o platform.o prom.o setup.o
-51
arch/mips/loongson32/common/reset.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011 Zhang, Keguang <keguang.zhang@gmail.com> 4 - */ 5 - 6 - #include <linux/io.h> 7 - #include <linux/pm.h> 8 - #include <linux/sizes.h> 9 - #include <asm/idle.h> 10 - #include <asm/reboot.h> 11 - 12 - #include <loongson1.h> 13 - 14 - static void __iomem *wdt_reg_base; 15 - 16 - static void ls1x_halt(void) 17 - { 18 - while (1) { 19 - if (cpu_wait) 20 - cpu_wait(); 21 - } 22 - } 23 - 24 - static void ls1x_restart(char *command) 25 - { 26 - __raw_writel(0x1, wdt_reg_base + WDT_EN); 27 - __raw_writel(0x1, wdt_reg_base + WDT_TIMER); 28 - __raw_writel(0x1, wdt_reg_base + WDT_SET); 29 - 30 - ls1x_halt(); 31 - } 32 - 33 - static void ls1x_power_off(void) 34 - { 35 - ls1x_halt(); 36 - } 37 - 38 - static int __init ls1x_reboot_setup(void) 39 - { 40 - wdt_reg_base = ioremap(LS1X_WDT_BASE, (SZ_4 + SZ_8)); 41 - if (!wdt_reg_base) 42 - panic("Failed to remap watchdog registers"); 43 - 44 - _machine_restart = ls1x_restart; 45 - _machine_halt = ls1x_halt; 46 - pm_power_off = ls1x_power_off; 47 - 48 - return 0; 49 - } 50 - 51 - arch_initcall(ls1x_reboot_setup);
+4 -20
arch/mips/mm/tlbex.c
··· 2123 2123 2124 2124 uasm_i_tlbr(&p); 2125 2125 2126 - switch (current_cpu_type()) { 2127 - case CPU_CAVIUM_OCTEON: 2128 - case CPU_CAVIUM_OCTEON_PLUS: 2129 - case CPU_CAVIUM_OCTEON2: 2130 - break; 2131 - default: 2132 - if (cpu_has_mips_r2_exec_hazard) 2133 - uasm_i_ehb(&p); 2134 - break; 2135 - } 2126 + if (cpu_has_mips_r2_exec_hazard) 2127 + uasm_i_ehb(&p); 2136 2128 2137 2129 /* Examine entrylo 0 or 1 based on ptr. */ 2138 2130 if (use_bbit_insns()) { ··· 2189 2197 2190 2198 uasm_i_tlbr(&p); 2191 2199 2192 - switch (current_cpu_type()) { 2193 - case CPU_CAVIUM_OCTEON: 2194 - case CPU_CAVIUM_OCTEON_PLUS: 2195 - case CPU_CAVIUM_OCTEON2: 2196 - break; 2197 - default: 2198 - if (cpu_has_mips_r2_exec_hazard) 2199 - uasm_i_ehb(&p); 2200 - break; 2201 - } 2200 + if (cpu_has_mips_r2_exec_hazard) 2201 + uasm_i_ehb(&p); 2202 2202 2203 2203 /* Examine entrylo 0 or 1 based on ptr. */ 2204 2204 if (use_bbit_insns()) {
+2 -5
arch/mips/pci/pci-mt7620.c
··· 274 274 val |= 0x50 << 8; 275 275 pci_config_write(NULL, 0, 0x70c, 4, val); 276 276 277 - pci_config_read(NULL, 0, 0x70c, 4, &val); 278 - dev_err(&pdev->dev, "Port 0 N_FTS = %x\n", (unsigned int) val); 279 - 280 277 return 0; 281 278 } 282 279 ··· 327 330 rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); 328 331 if (ralink_soc == MT762X_SOC_MT7620A) 329 332 rt_sysc_m32(LC_CKDRVPD, PDRV_SW_SET, PPLL_DRV); 330 - dev_err(&pdev->dev, "PCIE0 no card, disable it(RST&CLK)\n"); 333 + dev_info(&pdev->dev, "PCIE0 no card, disable it(RST&CLK)\n"); 331 334 return -1; 332 335 } 333 336 ··· 370 373 dev->bus->number, slot); 371 374 return 0; 372 375 } 373 - dev_err(&dev->dev, "card - bus=0x%x, slot = 0x%x irq=%d\n", 376 + dev_info(&dev->dev, "card - bus=0x%x, slot = 0x%x irq=%d\n", 374 377 dev->bus->number, slot, irq); 375 378 376 379 /* configure the cache line size to 0x14 */
+3 -5
arch/mips/pci/pci-xtalk-bridge.c
··· 733 733 return err; 734 734 } 735 735 736 - static int bridge_remove(struct platform_device *pdev) 736 + static void bridge_remove(struct platform_device *pdev) 737 737 { 738 738 struct pci_bus *bus = platform_get_drvdata(pdev); 739 739 struct bridge_controller *bc = BRIDGE_CONTROLLER(bus); ··· 745 745 pci_stop_root_bus(bus); 746 746 pci_remove_root_bus(bus); 747 747 pci_unlock_rescan_remove(); 748 - 749 - return 0; 750 748 } 751 749 752 750 static struct platform_driver bridge_driver = { 753 - .probe = bridge_probe, 754 - .remove = bridge_remove, 751 + .probe = bridge_probe, 752 + .remove_new = bridge_remove, 755 753 .driver = { 756 754 .name = "xtalk-bridge", 757 755 }
+52 -9
arch/mips/ralink/clk.c
··· 11 11 #include <linux/clkdev.h> 12 12 #include <linux/clk.h> 13 13 #include <linux/clk-provider.h> 14 + #include <asm/mach-ralink/ralink_regs.h> 14 15 15 16 #include <asm/time.h> 16 17 17 18 #include "common.h" 18 19 19 - void ralink_clk_add(const char *dev, unsigned long rate) 20 + static const char *clk_cpu(int *idx) 20 21 { 21 - struct clk *clk = clk_register_fixed_rate(NULL, dev, NULL, 0, rate); 22 - 23 - if (!clk) 24 - panic("failed to add clock"); 25 - 26 - clkdev_create(clk, NULL, "%s", dev); 22 + switch (ralink_soc) { 23 + case RT2880_SOC: 24 + *idx = 0; 25 + return "ralink,rt2880-sysc"; 26 + case RT3883_SOC: 27 + *idx = 0; 28 + return "ralink,rt3883-sysc"; 29 + case RT305X_SOC_RT3050: 30 + *idx = 0; 31 + return "ralink,rt3050-sysc"; 32 + case RT305X_SOC_RT3052: 33 + *idx = 0; 34 + return "ralink,rt3052-sysc"; 35 + case RT305X_SOC_RT3350: 36 + *idx = 1; 37 + return "ralink,rt3350-sysc"; 38 + case RT305X_SOC_RT3352: 39 + *idx = 1; 40 + return "ralink,rt3352-sysc"; 41 + case RT305X_SOC_RT5350: 42 + *idx = 1; 43 + return "ralink,rt5350-sysc"; 44 + case MT762X_SOC_MT7620A: 45 + *idx = 2; 46 + return "ralink,mt7620-sysc"; 47 + case MT762X_SOC_MT7620N: 48 + *idx = 2; 49 + return "ralink,mt7620-sysc"; 50 + case MT762X_SOC_MT7628AN: 51 + *idx = 1; 52 + return "ralink,mt7628-sysc"; 53 + case MT762X_SOC_MT7688: 54 + *idx = 1; 55 + return "ralink,mt7688-sysc"; 56 + default: 57 + *idx = -1; 58 + return "invalid"; 59 + } 27 60 } 28 61 29 62 void __init plat_time_init(void) 30 63 { 64 + struct of_phandle_args clkspec; 65 + const char *compatible; 31 66 struct clk *clk; 67 + int cpu_clk_idx; 32 68 33 69 ralink_of_remap(); 34 70 35 - ralink_clk_init(); 36 - clk = clk_get_sys("cpu", NULL); 71 + compatible = clk_cpu(&cpu_clk_idx); 72 + if (cpu_clk_idx == -1) 73 + panic("unable to get CPU clock index"); 74 + 75 + of_clk_init(NULL); 76 + clkspec.np = of_find_compatible_node(NULL, NULL, compatible); 77 + clkspec.args_count = 1; 78 + clkspec.args[0] = cpu_clk_idx; 79 + clk = of_clk_get_from_provider(&clkspec); 37 80 if (IS_ERR(clk)) 38 81 panic("unable to get CPU clock, err=%ld", PTR_ERR(clk)); 39 82 pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000);
-7
arch/mips/ralink/common.h
··· 23 23 24 24 extern void ralink_of_remap(void); 25 25 26 - extern void ralink_clk_init(void); 27 - extern void ralink_clk_add(const char *dev, unsigned long rate); 28 - 29 - extern void ralink_rst_init(void); 30 - 31 26 extern void __init prom_soc_init(struct ralink_soc_info *soc_info); 32 - 33 - __iomem void *plat_of_remap_node(const char *node); 34 27 35 28 #endif /* _RALINK_COMMON_H__ */
-235
arch/mips/ralink/mt7620.c
··· 36 36 #define PMU1_CFG 0x8C 37 37 #define DIG_SW_SEL BIT(25) 38 38 39 - /* clock scaling */ 40 - #define CLKCFG_FDIV_MASK 0x1f00 41 - #define CLKCFG_FDIV_USB_VAL 0x0300 42 - #define CLKCFG_FFRAC_MASK 0x001f 43 - #define CLKCFG_FFRAC_USB_VAL 0x0003 44 - 45 39 /* EFUSE bits */ 46 40 #define EFUSE_MT7688 0x100000 47 41 ··· 46 52 static int dram_type; 47 53 48 54 static struct ralink_soc_info *soc_info_ptr; 49 - 50 - static __init u32 51 - mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) 52 - { 53 - u64 t; 54 - 55 - t = ref_rate; 56 - t *= mul; 57 - do_div(t, div); 58 - 59 - return t; 60 - } 61 - 62 - #define MHZ(x) ((x) * 1000 * 1000) 63 - 64 - static __init unsigned long 65 - mt7620_get_xtal_rate(void) 66 - { 67 - u32 reg; 68 - 69 - reg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0); 70 - if (reg & SYSCFG0_XTAL_FREQ_SEL) 71 - return MHZ(40); 72 - 73 - return MHZ(20); 74 - } 75 - 76 - static __init unsigned long 77 - mt7620_get_periph_rate(unsigned long xtal_rate) 78 - { 79 - u32 reg; 80 - 81 - reg = rt_sysc_r32(SYSC_REG_CLKCFG0); 82 - if (reg & CLKCFG0_PERI_CLK_SEL) 83 - return xtal_rate; 84 - 85 - return MHZ(40); 86 - } 87 - 88 - static const u32 mt7620_clk_divider[] __initconst = { 2, 3, 4, 8 }; 89 - 90 - static __init unsigned long 91 - mt7620_get_cpu_pll_rate(unsigned long xtal_rate) 92 - { 93 - u32 reg; 94 - u32 mul; 95 - u32 div; 96 - 97 - reg = rt_sysc_r32(SYSC_REG_CPLL_CONFIG0); 98 - if (reg & CPLL_CFG0_BYPASS_REF_CLK) 99 - return xtal_rate; 100 - 101 - if ((reg & CPLL_CFG0_SW_CFG) == 0) 102 - return MHZ(600); 103 - 104 - mul = (reg >> CPLL_CFG0_PLL_MULT_RATIO_SHIFT) & 105 - CPLL_CFG0_PLL_MULT_RATIO_MASK; 106 - mul += 24; 107 - if (reg & CPLL_CFG0_LC_CURFCK) 108 - mul *= 2; 109 - 110 - div = (reg >> CPLL_CFG0_PLL_DIV_RATIO_SHIFT) & 111 - CPLL_CFG0_PLL_DIV_RATIO_MASK; 112 - 113 - WARN_ON(div >= ARRAY_SIZE(mt7620_clk_divider)); 114 - 115 - return mt7620_calc_rate(xtal_rate, mul, mt7620_clk_divider[div]); 116 - } 117 - 118 - static __init unsigned long 119 - mt7620_get_pll_rate(unsigned long xtal_rate, unsigned long cpu_pll_rate) 120 - { 121 - u32 reg; 122 - 123 - reg = rt_sysc_r32(SYSC_REG_CPLL_CONFIG1); 124 - if (reg & CPLL_CFG1_CPU_AUX1) 125 - return xtal_rate; 126 - 127 - if (reg & CPLL_CFG1_CPU_AUX0) 128 - return MHZ(480); 129 - 130 - return cpu_pll_rate; 131 - } 132 - 133 - static __init unsigned long 134 - mt7620_get_cpu_rate(unsigned long pll_rate) 135 - { 136 - u32 reg; 137 - u32 mul; 138 - u32 div; 139 - 140 - reg = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); 141 - 142 - mul = reg & CPU_SYS_CLKCFG_CPU_FFRAC_MASK; 143 - div = (reg >> CPU_SYS_CLKCFG_CPU_FDIV_SHIFT) & 144 - CPU_SYS_CLKCFG_CPU_FDIV_MASK; 145 - 146 - return mt7620_calc_rate(pll_rate, mul, div); 147 - } 148 - 149 - static const u32 mt7620_ocp_dividers[16] __initconst = { 150 - [CPU_SYS_CLKCFG_OCP_RATIO_2] = 2, 151 - [CPU_SYS_CLKCFG_OCP_RATIO_3] = 3, 152 - [CPU_SYS_CLKCFG_OCP_RATIO_4] = 4, 153 - [CPU_SYS_CLKCFG_OCP_RATIO_5] = 5, 154 - [CPU_SYS_CLKCFG_OCP_RATIO_10] = 10, 155 - }; 156 - 157 - static __init unsigned long 158 - mt7620_get_dram_rate(unsigned long pll_rate) 159 - { 160 - if (dram_type == SYSCFG0_DRAM_TYPE_SDRAM) 161 - return pll_rate / 4; 162 - 163 - return pll_rate / 3; 164 - } 165 - 166 - static __init unsigned long 167 - mt7620_get_sys_rate(unsigned long cpu_rate) 168 - { 169 - u32 reg; 170 - u32 ocp_ratio; 171 - u32 div; 172 - 173 - reg = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); 174 - 175 - ocp_ratio = (reg >> CPU_SYS_CLKCFG_OCP_RATIO_SHIFT) & 176 - CPU_SYS_CLKCFG_OCP_RATIO_MASK; 177 - 178 - if (WARN_ON(ocp_ratio >= ARRAY_SIZE(mt7620_ocp_dividers))) 179 - return cpu_rate; 180 - 181 - div = mt7620_ocp_dividers[ocp_ratio]; 182 - if (WARN(!div, "invalid divider for OCP ratio %u", ocp_ratio)) 183 - return cpu_rate; 184 - 185 - return cpu_rate / div; 186 - } 187 - 188 - void __init ralink_clk_init(void) 189 - { 190 - unsigned long xtal_rate; 191 - unsigned long cpu_pll_rate; 192 - unsigned long pll_rate; 193 - unsigned long cpu_rate; 194 - unsigned long sys_rate; 195 - unsigned long dram_rate; 196 - unsigned long periph_rate; 197 - unsigned long pcmi2s_rate; 198 - 199 - xtal_rate = mt7620_get_xtal_rate(); 200 - 201 - #define RFMT(label) label ":%lu.%03luMHz " 202 - #define RINT(x) ((x) / 1000000) 203 - #define RFRAC(x) (((x) / 1000) % 1000) 204 - 205 - if (is_mt76x8()) { 206 - if (xtal_rate == MHZ(40)) 207 - cpu_rate = MHZ(580); 208 - else 209 - cpu_rate = MHZ(575); 210 - dram_rate = sys_rate = cpu_rate / 3; 211 - periph_rate = MHZ(40); 212 - pcmi2s_rate = MHZ(480); 213 - 214 - ralink_clk_add("10000d00.uartlite", periph_rate); 215 - ralink_clk_add("10000e00.uartlite", periph_rate); 216 - } else { 217 - cpu_pll_rate = mt7620_get_cpu_pll_rate(xtal_rate); 218 - pll_rate = mt7620_get_pll_rate(xtal_rate, cpu_pll_rate); 219 - 220 - cpu_rate = mt7620_get_cpu_rate(pll_rate); 221 - dram_rate = mt7620_get_dram_rate(pll_rate); 222 - sys_rate = mt7620_get_sys_rate(cpu_rate); 223 - periph_rate = mt7620_get_periph_rate(xtal_rate); 224 - pcmi2s_rate = periph_rate; 225 - 226 - pr_debug(RFMT("XTAL") RFMT("CPU_PLL") RFMT("PLL"), 227 - RINT(xtal_rate), RFRAC(xtal_rate), 228 - RINT(cpu_pll_rate), RFRAC(cpu_pll_rate), 229 - RINT(pll_rate), RFRAC(pll_rate)); 230 - 231 - ralink_clk_add("10000500.uart", periph_rate); 232 - } 233 - 234 - pr_debug(RFMT("CPU") RFMT("DRAM") RFMT("SYS") RFMT("PERIPH"), 235 - RINT(cpu_rate), RFRAC(cpu_rate), 236 - RINT(dram_rate), RFRAC(dram_rate), 237 - RINT(sys_rate), RFRAC(sys_rate), 238 - RINT(periph_rate), RFRAC(periph_rate)); 239 - #undef RFRAC 240 - #undef RINT 241 - #undef RFMT 242 - 243 - ralink_clk_add("cpu", cpu_rate); 244 - ralink_clk_add("10000100.timer", periph_rate); 245 - ralink_clk_add("10000120.watchdog", periph_rate); 246 - ralink_clk_add("10000900.i2c", periph_rate); 247 - ralink_clk_add("10000a00.i2s", pcmi2s_rate); 248 - ralink_clk_add("10000b00.spi", sys_rate); 249 - ralink_clk_add("10000b40.spi", sys_rate); 250 - ralink_clk_add("10000c00.uartlite", periph_rate); 251 - ralink_clk_add("10000d00.uart1", periph_rate); 252 - ralink_clk_add("10000e00.uart2", periph_rate); 253 - ralink_clk_add("10180000.wmac", xtal_rate); 254 - 255 - if (IS_ENABLED(CONFIG_USB) && !is_mt76x8()) { 256 - /* 257 - * When the CPU goes into sleep mode, the BUS clock will be 258 - * too low for USB to function properly. Adjust the busses 259 - * fractional divider to fix this 260 - */ 261 - u32 val = rt_sysc_r32(SYSC_REG_CPU_SYS_CLKCFG); 262 - 263 - val &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK); 264 - val |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL; 265 - 266 - rt_sysc_w32(val, SYSC_REG_CPU_SYS_CLKCFG); 267 - } 268 - } 269 - 270 - void __init ralink_of_remap(void) 271 - { 272 - rt_sysc_membase = plat_of_remap_node("ralink,mt7620a-sysc"); 273 - rt_memc_membase = plat_of_remap_node("ralink,mt7620a-memc"); 274 - 275 - if (!rt_sysc_membase || !rt_memc_membase) 276 - panic("Failed to remap core resources"); 277 - } 278 55 279 56 static __init void 280 57 mt7620_dram_init(struct ralink_soc_info *soc_info)
-9
arch/mips/ralink/mt7621.c
··· 89 89 memblock_add(MT7621_HIGHMEM_BASE, MT7621_HIGHMEM_SIZE); 90 90 } 91 91 92 - void __init ralink_of_remap(void) 93 - { 94 - rt_sysc_membase = plat_of_remap_node("mediatek,mt7621-sysc"); 95 - rt_memc_membase = plat_of_remap_node("mediatek,mt7621-memc"); 96 - 97 - if (!rt_sysc_membase || !rt_memc_membase) 98 - panic("Failed to remap core resources"); 99 - } 100 - 101 92 static unsigned int __init mt7621_get_soc_name0(void) 102 93 { 103 94 return __raw_readl(MT7621_SYSC_BASE + SYSC_REG_CHIP_NAME0);
+40 -11
arch/mips/ralink/of.c
··· 29 29 __iomem void *rt_memc_membase; 30 30 EXPORT_SYMBOL_GPL(rt_sysc_membase); 31 31 32 - __iomem void *plat_of_remap_node(const char *node) 32 + static const struct of_device_id mtmips_memc_match[] = { 33 + { .compatible = "mediatek,mt7621-memc" }, 34 + { .compatible = "ralink,mt7620a-memc" }, 35 + { .compatible = "ralink,rt2880-memc" }, 36 + { .compatible = "ralink,rt3050-memc" }, 37 + { .compatible = "ralink,rt3883-memc" }, 38 + {} 39 + }; 40 + 41 + static const struct of_device_id mtmips_sysc_match[] = { 42 + { .compatible = "mediatek,mt7621-sysc" }, 43 + { .compatible = "ralink,mt7620-sysc" }, 44 + { .compatible = "ralink,mt7628-sysc" }, 45 + { .compatible = "ralink,mt7688-sysc" }, 46 + { .compatible = "ralink,rt2880-sysc" }, 47 + { .compatible = "ralink,rt3050-sysc" }, 48 + { .compatible = "ralink,rt3052-sysc" }, 49 + { .compatible = "ralink,rt3352-sysc" }, 50 + { .compatible = "ralink,rt3883-sysc" }, 51 + { .compatible = "ralink,rt5350-sysc" }, 52 + {} 53 + }; 54 + 55 + static __iomem void * 56 + mtmips_of_remap_node(const struct of_device_id *match, const char *type) 33 57 { 34 58 struct resource res; 35 59 struct device_node *np; 36 60 37 - np = of_find_compatible_node(NULL, NULL, node); 61 + np = of_find_matching_node(NULL, match); 38 62 if (!np) 39 - panic("Failed to find %s node", node); 63 + panic("Failed to find %s controller node", type); 40 64 41 65 if (of_address_to_resource(np, 0, &res)) 42 - panic("Failed to get resource for %s", node); 43 - 44 - of_node_put(np); 66 + panic("Failed to get resource for %s node", np->name); 45 67 46 68 if (!request_mem_region(res.start, 47 69 resource_size(&res), 48 70 res.name)) 49 - panic("Failed to request resources for %s", node); 71 + panic("Failed to request resources for %s node", np->name); 72 + 73 + of_node_put(np); 50 74 51 75 return ioremap(res.start, resource_size(&res)); 76 + } 77 + 78 + void __init ralink_of_remap(void) 79 + { 80 + rt_sysc_membase = mtmips_of_remap_node(mtmips_sysc_match, "system"); 81 + rt_memc_membase = mtmips_of_remap_node(mtmips_memc_match, "memory"); 82 + 83 + if (!rt_sysc_membase || !rt_memc_membase) 84 + panic("Failed to remap core resources"); 52 85 } 53 86 54 87 void __init plat_mem_setup(void) ··· 113 80 static int __init plat_of_setup(void) 114 81 { 115 82 __dt_register_buses(soc_info.compatible, "palmbus"); 116 - 117 - /* make sure that the reset controller is setup early */ 118 - if (ralink_soc != MT762X_SOC_MT7621AT) 119 - ralink_rst_init(); 120 83 121 84 return 0; 122 85 }
-61
arch/mips/ralink/reset.c
··· 10 10 #include <linux/io.h> 11 11 #include <linux/of.h> 12 12 #include <linux/delay.h> 13 - #include <linux/reset-controller.h> 14 13 15 14 #include <asm/reboot.h> 16 15 ··· 20 21 21 22 #define RSTCTL_RESET_PCI BIT(26) 22 23 #define RSTCTL_RESET_SYSTEM BIT(0) 23 - 24 - static int ralink_assert_device(struct reset_controller_dev *rcdev, 25 - unsigned long id) 26 - { 27 - u32 val; 28 - 29 - if (id == 0) 30 - return -1; 31 - 32 - val = rt_sysc_r32(SYSC_REG_RESET_CTRL); 33 - val |= BIT(id); 34 - rt_sysc_w32(val, SYSC_REG_RESET_CTRL); 35 - 36 - return 0; 37 - } 38 - 39 - static int ralink_deassert_device(struct reset_controller_dev *rcdev, 40 - unsigned long id) 41 - { 42 - u32 val; 43 - 44 - if (id == 0) 45 - return -1; 46 - 47 - val = rt_sysc_r32(SYSC_REG_RESET_CTRL); 48 - val &= ~BIT(id); 49 - rt_sysc_w32(val, SYSC_REG_RESET_CTRL); 50 - 51 - return 0; 52 - } 53 - 54 - static int ralink_reset_device(struct reset_controller_dev *rcdev, 55 - unsigned long id) 56 - { 57 - ralink_assert_device(rcdev, id); 58 - return ralink_deassert_device(rcdev, id); 59 - } 60 - 61 - static const struct reset_control_ops reset_ops = { 62 - .reset = ralink_reset_device, 63 - .assert = ralink_assert_device, 64 - .deassert = ralink_deassert_device, 65 - }; 66 - 67 - static struct reset_controller_dev reset_dev = { 68 - .ops = &reset_ops, 69 - .owner = THIS_MODULE, 70 - .nr_resets = 32, 71 - .of_reset_n_cells = 1, 72 - }; 73 - 74 - void ralink_rst_init(void) 75 - { 76 - reset_dev.of_node = of_find_compatible_node(NULL, NULL, 77 - "ralink,rt2880-reset"); 78 - if (!reset_dev.of_node) 79 - pr_err("Failed to find reset controller node"); 80 - else 81 - reset_controller_register(&reset_dev); 82 - } 83 24 84 25 static void ralink_restart(char *command) 85 26 {
-40
arch/mips/ralink/rt288x.c
··· 21 21 22 22 static struct ralink_soc_info *soc_info_ptr; 23 23 24 - void __init ralink_clk_init(void) 25 - { 26 - unsigned long cpu_rate, wmac_rate = 40000000; 27 - u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); 28 - t = ((t >> SYSTEM_CONFIG_CPUCLK_SHIFT) & SYSTEM_CONFIG_CPUCLK_MASK); 29 - 30 - switch (t) { 31 - case SYSTEM_CONFIG_CPUCLK_250: 32 - cpu_rate = 250000000; 33 - break; 34 - case SYSTEM_CONFIG_CPUCLK_266: 35 - cpu_rate = 266666667; 36 - break; 37 - case SYSTEM_CONFIG_CPUCLK_280: 38 - cpu_rate = 280000000; 39 - break; 40 - case SYSTEM_CONFIG_CPUCLK_300: 41 - cpu_rate = 300000000; 42 - break; 43 - } 44 - 45 - ralink_clk_add("cpu", cpu_rate); 46 - ralink_clk_add("300100.timer", cpu_rate / 2); 47 - ralink_clk_add("300120.watchdog", cpu_rate / 2); 48 - ralink_clk_add("300500.uart", cpu_rate / 2); 49 - ralink_clk_add("300900.i2c", cpu_rate / 2); 50 - ralink_clk_add("300c00.uartlite", cpu_rate / 2); 51 - ralink_clk_add("400000.ethernet", cpu_rate / 2); 52 - ralink_clk_add("480000.wmac", wmac_rate); 53 - } 54 - 55 - void __init ralink_of_remap(void) 56 - { 57 - rt_sysc_membase = plat_of_remap_node("ralink,rt2880-sysc"); 58 - rt_memc_membase = plat_of_remap_node("ralink,rt2880-memc"); 59 - 60 - if (!rt_sysc_membase || !rt_memc_membase) 61 - panic("Failed to remap core resources"); 62 - } 63 - 64 24 static unsigned int __init rt2880_get_soc_name0(void) 65 25 { 66 26 return __raw_readl(RT2880_SYSC_BASE + SYSC_REG_CHIP_NAME0);
-87
arch/mips/ralink/rt305x.c
··· 56 56 return ret; 57 57 } 58 58 59 - void __init ralink_clk_init(void) 60 - { 61 - unsigned long cpu_rate, sys_rate, wdt_rate, uart_rate; 62 - unsigned long wmac_rate = 40000000; 63 - 64 - u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); 65 - 66 - if (soc_is_rt305x() || soc_is_rt3350()) { 67 - t = (t >> RT305X_SYSCFG_CPUCLK_SHIFT) & 68 - RT305X_SYSCFG_CPUCLK_MASK; 69 - switch (t) { 70 - case RT305X_SYSCFG_CPUCLK_LOW: 71 - cpu_rate = 320000000; 72 - break; 73 - case RT305X_SYSCFG_CPUCLK_HIGH: 74 - cpu_rate = 384000000; 75 - break; 76 - } 77 - sys_rate = uart_rate = wdt_rate = cpu_rate / 3; 78 - } else if (soc_is_rt3352()) { 79 - t = (t >> RT3352_SYSCFG0_CPUCLK_SHIFT) & 80 - RT3352_SYSCFG0_CPUCLK_MASK; 81 - switch (t) { 82 - case RT3352_SYSCFG0_CPUCLK_LOW: 83 - cpu_rate = 384000000; 84 - break; 85 - case RT3352_SYSCFG0_CPUCLK_HIGH: 86 - cpu_rate = 400000000; 87 - break; 88 - } 89 - sys_rate = wdt_rate = cpu_rate / 3; 90 - uart_rate = 40000000; 91 - } else if (soc_is_rt5350()) { 92 - t = (t >> RT5350_SYSCFG0_CPUCLK_SHIFT) & 93 - RT5350_SYSCFG0_CPUCLK_MASK; 94 - switch (t) { 95 - case RT5350_SYSCFG0_CPUCLK_360: 96 - cpu_rate = 360000000; 97 - sys_rate = cpu_rate / 3; 98 - break; 99 - case RT5350_SYSCFG0_CPUCLK_320: 100 - cpu_rate = 320000000; 101 - sys_rate = cpu_rate / 4; 102 - break; 103 - case RT5350_SYSCFG0_CPUCLK_300: 104 - cpu_rate = 300000000; 105 - sys_rate = cpu_rate / 3; 106 - break; 107 - default: 108 - BUG(); 109 - } 110 - uart_rate = 40000000; 111 - wdt_rate = sys_rate; 112 - } else { 113 - BUG(); 114 - } 115 - 116 - if (soc_is_rt3352() || soc_is_rt5350()) { 117 - u32 val = rt_sysc_r32(RT3352_SYSC_REG_SYSCFG0); 118 - 119 - if (!(val & RT3352_CLKCFG0_XTAL_SEL)) 120 - wmac_rate = 20000000; 121 - } 122 - 123 - ralink_clk_add("cpu", cpu_rate); 124 - ralink_clk_add("sys", sys_rate); 125 - ralink_clk_add("10000900.i2c", uart_rate); 126 - ralink_clk_add("10000a00.i2s", uart_rate); 127 - ralink_clk_add("10000b00.spi", sys_rate); 128 - ralink_clk_add("10000b40.spi", sys_rate); 129 - ralink_clk_add("10000100.timer", wdt_rate); 130 - ralink_clk_add("10000120.watchdog", wdt_rate); 131 - ralink_clk_add("10000500.uart", uart_rate); 132 - ralink_clk_add("10000c00.uartlite", uart_rate); 133 - ralink_clk_add("10100000.ethernet", sys_rate); 134 - ralink_clk_add("10180000.wmac", wmac_rate); 135 - } 136 - 137 - void __init ralink_of_remap(void) 138 - { 139 - rt_sysc_membase = plat_of_remap_node("ralink,rt3050-sysc"); 140 - rt_memc_membase = plat_of_remap_node("ralink,rt3050-memc"); 141 - 142 - if (!rt_sysc_membase || !rt_memc_membase) 143 - panic("Failed to remap core resources"); 144 - } 145 - 146 59 static unsigned int __init rt305x_get_soc_name0(void) 147 60 { 148 61 return __raw_readl(RT305X_SYSC_BASE + SYSC_REG_CHIP_NAME0);
-53
arch/mips/ralink/rt3883.c
··· 21 21 22 22 static struct ralink_soc_info *soc_info_ptr; 23 23 24 - void __init ralink_clk_init(void) 25 - { 26 - unsigned long cpu_rate, sys_rate; 27 - u32 syscfg0; 28 - u32 clksel; 29 - u32 ddr2; 30 - 31 - syscfg0 = rt_sysc_r32(RT3883_SYSC_REG_SYSCFG0); 32 - clksel = ((syscfg0 >> RT3883_SYSCFG0_CPUCLK_SHIFT) & 33 - RT3883_SYSCFG0_CPUCLK_MASK); 34 - ddr2 = syscfg0 & RT3883_SYSCFG0_DRAM_TYPE_DDR2; 35 - 36 - switch (clksel) { 37 - case RT3883_SYSCFG0_CPUCLK_250: 38 - cpu_rate = 250000000; 39 - sys_rate = (ddr2) ? 125000000 : 83000000; 40 - break; 41 - case RT3883_SYSCFG0_CPUCLK_384: 42 - cpu_rate = 384000000; 43 - sys_rate = (ddr2) ? 128000000 : 96000000; 44 - break; 45 - case RT3883_SYSCFG0_CPUCLK_480: 46 - cpu_rate = 480000000; 47 - sys_rate = (ddr2) ? 160000000 : 120000000; 48 - break; 49 - case RT3883_SYSCFG0_CPUCLK_500: 50 - cpu_rate = 500000000; 51 - sys_rate = (ddr2) ? 166000000 : 125000000; 52 - break; 53 - } 54 - 55 - ralink_clk_add("cpu", cpu_rate); 56 - ralink_clk_add("10000100.timer", sys_rate); 57 - ralink_clk_add("10000120.watchdog", sys_rate); 58 - ralink_clk_add("10000500.uart", 40000000); 59 - ralink_clk_add("10000900.i2c", 40000000); 60 - ralink_clk_add("10000a00.i2s", 40000000); 61 - ralink_clk_add("10000b00.spi", sys_rate); 62 - ralink_clk_add("10000b40.spi", sys_rate); 63 - ralink_clk_add("10000c00.uartlite", 40000000); 64 - ralink_clk_add("10100000.ethernet", sys_rate); 65 - ralink_clk_add("10180000.wmac", 40000000); 66 - } 67 - 68 - void __init ralink_of_remap(void) 69 - { 70 - rt_sysc_membase = plat_of_remap_node("ralink,rt3883-sysc"); 71 - rt_memc_membase = plat_of_remap_node("ralink,rt3883-memc"); 72 - 73 - if (!rt_sysc_membase || !rt_memc_membase) 74 - panic("Failed to remap core resources"); 75 - } 76 - 77 24 static unsigned int __init rt3883_get_soc_name0(void) 78 25 { 79 26 return __raw_readl(RT3883_SYSC_BASE + RT3883_SYSC_REG_CHIPID0_3);
+7 -7
arch/mips/sibyte/swarm/platform.c
··· 88 88 #define sb1250_dev_struct(num) \ 89 89 static struct resource sb1250_res##num = { \ 90 90 .name = "SB1250 MAC " __stringify(num), \ 91 - .flags = IORESOURCE_MEM, \ 92 - .start = A_MAC_CHANNEL_BASE(num), \ 93 - .end = A_MAC_CHANNEL_BASE(num + 1) -1, \ 91 + .flags = IORESOURCE_MEM, \ 92 + .start = A_MAC_CHANNEL_BASE(num), \ 93 + .end = A_MAC_CHANNEL_BASE(num + 1) - 1, \ 94 94 };\ 95 95 static struct platform_device sb1250_dev##num = { \ 96 - .name = "sb1250-mac", \ 97 - .id = num, \ 98 - .resource = &sb1250_res##num, \ 99 - .num_resources = 1, \ 96 + .name = "sb1250-mac", \ 97 + .id = num, \ 98 + .resource = &sb1250_res##num, \ 99 + .num_resources = 1, \ 100 100 } 101 101 102 102 sb1250_dev_struct(0);
-7
drivers/char/mem.c
··· 90 90 } 91 91 #endif 92 92 93 - #ifndef unxlate_dev_mem_ptr 94 - #define unxlate_dev_mem_ptr unxlate_dev_mem_ptr 95 - void __weak unxlate_dev_mem_ptr(phys_addr_t phys, void *addr) 96 - { 97 - } 98 - #endif 99 - 100 93 static inline bool should_stop_iteration(void) 101 94 { 102 95 if (need_resched())
+7
drivers/clk/ralink/Kconfig
··· 9 9 select MFD_SYSCON 10 10 help 11 11 This driver supports MediaTek MT7621 basic clocks. 12 + 13 + config CLK_MTMIPS 14 + bool "Clock driver for MTMIPS SoCs" 15 + depends on SOC_RT305X || SOC_RT288X || SOC_RT3883 || SOC_MT7620 || COMPILE_TEST 16 + select MFD_SYSCON 17 + help 18 + This driver supports MTMIPS basic clocks.
+1
drivers/clk/ralink/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 obj-$(CONFIG_CLK_MT7621) += clk-mt7621.o 3 + obj-$(CONFIG_CLK_MTMIPS) += clk-mtmips.o
+1117
drivers/clk/ralink/clk-mtmips.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * MTMIPS SoCs Clock Driver 4 + * Author: Sergio Paracuellos <sergio.paracuellos@gmail.com> 5 + */ 6 + 7 + #include <linux/bitops.h> 8 + #include <linux/clk-provider.h> 9 + #include <linux/mfd/syscon.h> 10 + #include <linux/platform_device.h> 11 + #include <linux/regmap.h> 12 + #include <linux/reset-controller.h> 13 + #include <linux/slab.h> 14 + 15 + /* Configuration registers */ 16 + #define SYSC_REG_SYSTEM_CONFIG 0x10 17 + #define SYSC_REG_CLKCFG0 0x2c 18 + #define SYSC_REG_RESET_CTRL 0x34 19 + #define SYSC_REG_CPU_SYS_CLKCFG 0x3c 20 + #define SYSC_REG_CPLL_CONFIG0 0x54 21 + #define SYSC_REG_CPLL_CONFIG1 0x58 22 + 23 + /* RT2880 SoC */ 24 + #define RT2880_CONFIG_CPUCLK_SHIFT 20 25 + #define RT2880_CONFIG_CPUCLK_MASK 0x3 26 + #define RT2880_CONFIG_CPUCLK_250 0x0 27 + #define RT2880_CONFIG_CPUCLK_266 0x1 28 + #define RT2880_CONFIG_CPUCLK_280 0x2 29 + #define RT2880_CONFIG_CPUCLK_300 0x3 30 + 31 + /* RT305X SoC */ 32 + #define RT305X_SYSCFG_CPUCLK_SHIFT 18 33 + #define RT305X_SYSCFG_CPUCLK_MASK 0x1 34 + #define RT305X_SYSCFG_CPUCLK_LOW 0x0 35 + #define RT305X_SYSCFG_CPUCLK_HIGH 0x1 36 + 37 + /* RT3352 SoC */ 38 + #define RT3352_SYSCFG0_CPUCLK_SHIFT 8 39 + #define RT3352_SYSCFG0_CPUCLK_MASK 0x1 40 + #define RT3352_SYSCFG0_CPUCLK_LOW 0x0 41 + #define RT3352_SYSCFG0_CPUCLK_HIGH 0x1 42 + 43 + /* RT3383 SoC */ 44 + #define RT3883_SYSCFG0_DRAM_TYPE_DDR2 BIT(17) 45 + #define RT3883_SYSCFG0_CPUCLK_SHIFT 8 46 + #define RT3883_SYSCFG0_CPUCLK_MASK 0x3 47 + #define RT3883_SYSCFG0_CPUCLK_250 0x0 48 + #define RT3883_SYSCFG0_CPUCLK_384 0x1 49 + #define RT3883_SYSCFG0_CPUCLK_480 0x2 50 + #define RT3883_SYSCFG0_CPUCLK_500 0x3 51 + 52 + /* RT5350 SoC */ 53 + #define RT5350_CLKCFG0_XTAL_SEL BIT(20) 54 + #define RT5350_SYSCFG0_CPUCLK_SHIFT 8 55 + #define RT5350_SYSCFG0_CPUCLK_MASK 0x3 56 + #define RT5350_SYSCFG0_CPUCLK_360 0x0 57 + #define RT5350_SYSCFG0_CPUCLK_320 0x2 58 + #define RT5350_SYSCFG0_CPUCLK_300 0x3 59 + 60 + /* MT7620 and MT76x8 SoCs */ 61 + #define MT7620_XTAL_FREQ_SEL BIT(6) 62 + #define CPLL_CFG0_SW_CFG BIT(31) 63 + #define CPLL_CFG0_PLL_MULT_RATIO_SHIFT 16 64 + #define CPLL_CFG0_PLL_MULT_RATIO_MASK 0x7 65 + #define CPLL_CFG0_LC_CURFCK BIT(15) 66 + #define CPLL_CFG0_BYPASS_REF_CLK BIT(14) 67 + #define CPLL_CFG0_PLL_DIV_RATIO_SHIFT 10 68 + #define CPLL_CFG0_PLL_DIV_RATIO_MASK 0x3 69 + #define CPLL_CFG1_CPU_AUX1 BIT(25) 70 + #define CPLL_CFG1_CPU_AUX0 BIT(24) 71 + #define CLKCFG0_PERI_CLK_SEL BIT(4) 72 + #define CPU_SYS_CLKCFG_OCP_RATIO_SHIFT 16 73 + #define CPU_SYS_CLKCFG_OCP_RATIO_MASK 0xf 74 + #define CPU_SYS_CLKCFG_OCP_RATIO_1 0 /* 1:1 (Reserved) */ 75 + #define CPU_SYS_CLKCFG_OCP_RATIO_1_5 1 /* 1:1.5 (Reserved) */ 76 + #define CPU_SYS_CLKCFG_OCP_RATIO_2 2 /* 1:2 */ 77 + #define CPU_SYS_CLKCFG_OCP_RATIO_2_5 3 /* 1:2.5 (Reserved) */ 78 + #define CPU_SYS_CLKCFG_OCP_RATIO_3 4 /* 1:3 */ 79 + #define CPU_SYS_CLKCFG_OCP_RATIO_3_5 5 /* 1:3.5 (Reserved) */ 80 + #define CPU_SYS_CLKCFG_OCP_RATIO_4 6 /* 1:4 */ 81 + #define CPU_SYS_CLKCFG_OCP_RATIO_5 7 /* 1:5 */ 82 + #define CPU_SYS_CLKCFG_OCP_RATIO_10 8 /* 1:10 */ 83 + #define CPU_SYS_CLKCFG_CPU_FDIV_SHIFT 8 84 + #define CPU_SYS_CLKCFG_CPU_FDIV_MASK 0x1f 85 + #define CPU_SYS_CLKCFG_CPU_FFRAC_SHIFT 0 86 + #define CPU_SYS_CLKCFG_CPU_FFRAC_MASK 0x1f 87 + 88 + /* clock scaling */ 89 + #define CLKCFG_FDIV_MASK 0x1f00 90 + #define CLKCFG_FDIV_USB_VAL 0x0300 91 + #define CLKCFG_FFRAC_MASK 0x001f 92 + #define CLKCFG_FFRAC_USB_VAL 0x0003 93 + 94 + struct mtmips_clk; 95 + struct mtmips_clk_fixed; 96 + struct mtmips_clk_factor; 97 + 98 + struct mtmips_clk_data { 99 + struct mtmips_clk *clk_base; 100 + size_t num_clk_base; 101 + struct mtmips_clk_fixed *clk_fixed; 102 + size_t num_clk_fixed; 103 + struct mtmips_clk_factor *clk_factor; 104 + size_t num_clk_factor; 105 + struct mtmips_clk *clk_periph; 106 + size_t num_clk_periph; 107 + }; 108 + 109 + struct mtmips_clk_priv { 110 + struct regmap *sysc; 111 + const struct mtmips_clk_data *data; 112 + }; 113 + 114 + struct mtmips_clk { 115 + struct clk_hw hw; 116 + struct mtmips_clk_priv *priv; 117 + }; 118 + 119 + struct mtmips_clk_fixed { 120 + const char *name; 121 + const char *parent; 122 + unsigned long rate; 123 + struct clk_hw *hw; 124 + }; 125 + 126 + struct mtmips_clk_factor { 127 + const char *name; 128 + const char *parent; 129 + int mult; 130 + int div; 131 + unsigned long flags; 132 + struct clk_hw *hw; 133 + }; 134 + 135 + static unsigned long mtmips_pherip_clk_rate(struct clk_hw *hw, 136 + unsigned long parent_rate) 137 + { 138 + return parent_rate; 139 + } 140 + 141 + static const struct clk_ops mtmips_periph_clk_ops = { 142 + .recalc_rate = mtmips_pherip_clk_rate, 143 + }; 144 + 145 + #define CLK_PERIPH(_name, _parent) { \ 146 + .init = &(const struct clk_init_data) { \ 147 + .name = _name, \ 148 + .ops = &mtmips_periph_clk_ops, \ 149 + .parent_data = &(const struct clk_parent_data) {\ 150 + .name = _parent, \ 151 + .fw_name = _parent \ 152 + }, \ 153 + .num_parents = 1, \ 154 + /* \ 155 + * There are drivers for these SoCs that are \ 156 + * older than clock driver and are not prepared \ 157 + * for the clock. We don't want the kernel to \ 158 + * disable anything so we add CLK_IS_CRITICAL \ 159 + * flag here. \ 160 + */ \ 161 + .flags = CLK_SET_RATE_PARENT | CLK_IS_CRITICAL \ 162 + }, \ 163 + } 164 + 165 + static struct mtmips_clk rt2880_pherip_clks[] = { 166 + { CLK_PERIPH("300100.timer", "bus") }, 167 + { CLK_PERIPH("300120.watchdog", "bus") }, 168 + { CLK_PERIPH("300500.uart", "bus") }, 169 + { CLK_PERIPH("300900.i2c", "bus") }, 170 + { CLK_PERIPH("300c00.uartlite", "bus") }, 171 + { CLK_PERIPH("400000.ethernet", "bus") }, 172 + { CLK_PERIPH("480000.wmac", "xtal") } 173 + }; 174 + 175 + static struct mtmips_clk rt305x_pherip_clks[] = { 176 + { CLK_PERIPH("10000100.timer", "bus") }, 177 + { CLK_PERIPH("10000120.watchdog", "bus") }, 178 + { CLK_PERIPH("10000500.uart", "bus") }, 179 + { CLK_PERIPH("10000900.i2c", "bus") }, 180 + { CLK_PERIPH("10000a00.i2s", "bus") }, 181 + { CLK_PERIPH("10000b00.spi", "bus") }, 182 + { CLK_PERIPH("10000b40.spi", "bus") }, 183 + { CLK_PERIPH("10000c00.uartlite", "bus") }, 184 + { CLK_PERIPH("10100000.ethernet", "bus") }, 185 + { CLK_PERIPH("10180000.wmac", "xtal") } 186 + }; 187 + 188 + static struct mtmips_clk rt5350_pherip_clks[] = { 189 + { CLK_PERIPH("10000100.timer", "bus") }, 190 + { CLK_PERIPH("10000120.watchdog", "bus") }, 191 + { CLK_PERIPH("10000500.uart", "periph") }, 192 + { CLK_PERIPH("10000900.i2c", "periph") }, 193 + { CLK_PERIPH("10000a00.i2s", "periph") }, 194 + { CLK_PERIPH("10000b00.spi", "bus") }, 195 + { CLK_PERIPH("10000b40.spi", "bus") }, 196 + { CLK_PERIPH("10000c00.uartlite", "periph") }, 197 + { CLK_PERIPH("10100000.ethernet", "bus") }, 198 + { CLK_PERIPH("10180000.wmac", "xtal") } 199 + }; 200 + 201 + static struct mtmips_clk mt7620_pherip_clks[] = { 202 + { CLK_PERIPH("10000100.timer", "periph") }, 203 + { CLK_PERIPH("10000120.watchdog", "periph") }, 204 + { CLK_PERIPH("10000500.uart", "periph") }, 205 + { CLK_PERIPH("10000900.i2c", "periph") }, 206 + { CLK_PERIPH("10000a00.i2s", "periph") }, 207 + { CLK_PERIPH("10000b00.spi", "bus") }, 208 + { CLK_PERIPH("10000b40.spi", "bus") }, 209 + { CLK_PERIPH("10000c00.uartlite", "periph") }, 210 + { CLK_PERIPH("10180000.wmac", "xtal") } 211 + }; 212 + 213 + static struct mtmips_clk mt76x8_pherip_clks[] = { 214 + { CLK_PERIPH("10000100.timer", "periph") }, 215 + { CLK_PERIPH("10000120.watchdog", "periph") }, 216 + { CLK_PERIPH("10000900.i2c", "periph") }, 217 + { CLK_PERIPH("10000a00.i2s", "pcmi2s") }, 218 + { CLK_PERIPH("10000b00.spi", "bus") }, 219 + { CLK_PERIPH("10000b40.spi", "bus") }, 220 + { CLK_PERIPH("10000c00.uart0", "periph") }, 221 + { CLK_PERIPH("10000d00.uart1", "periph") }, 222 + { CLK_PERIPH("10000e00.uart2", "periph") }, 223 + { CLK_PERIPH("10300000.wmac", "xtal") } 224 + }; 225 + 226 + static int mtmips_register_pherip_clocks(struct device_node *np, 227 + struct clk_hw_onecell_data *clk_data, 228 + struct mtmips_clk_priv *priv) 229 + { 230 + struct clk_hw **hws = clk_data->hws; 231 + struct mtmips_clk *sclk; 232 + size_t idx_start = priv->data->num_clk_base + priv->data->num_clk_fixed + 233 + priv->data->num_clk_factor; 234 + int ret, i; 235 + 236 + for (i = 0; i < priv->data->num_clk_periph; i++) { 237 + int idx = idx_start + i; 238 + 239 + sclk = &priv->data->clk_periph[i]; 240 + ret = of_clk_hw_register(np, &sclk->hw); 241 + if (ret) { 242 + pr_err("Couldn't register peripheral clock %d\n", idx); 243 + goto err_clk_unreg; 244 + } 245 + 246 + hws[idx] = &sclk->hw; 247 + } 248 + 249 + return 0; 250 + 251 + err_clk_unreg: 252 + while (--i >= 0) { 253 + sclk = &priv->data->clk_periph[i]; 254 + clk_hw_unregister(&sclk->hw); 255 + } 256 + return ret; 257 + } 258 + 259 + #define CLK_FIXED(_name, _parent, _rate) \ 260 + { \ 261 + .name = _name, \ 262 + .parent = _parent, \ 263 + .rate = _rate \ 264 + } 265 + 266 + static struct mtmips_clk_fixed rt305x_fixed_clocks[] = { 267 + CLK_FIXED("xtal", NULL, 40000000) 268 + }; 269 + 270 + static struct mtmips_clk_fixed rt3352_fixed_clocks[] = { 271 + CLK_FIXED("periph", "xtal", 40000000) 272 + }; 273 + 274 + static struct mtmips_clk_fixed mt76x8_fixed_clocks[] = { 275 + CLK_FIXED("pcmi2s", "xtal", 480000000), 276 + CLK_FIXED("periph", "xtal", 40000000) 277 + }; 278 + 279 + static int mtmips_register_fixed_clocks(struct clk_hw_onecell_data *clk_data, 280 + struct mtmips_clk_priv *priv) 281 + { 282 + struct clk_hw **hws = clk_data->hws; 283 + struct mtmips_clk_fixed *sclk; 284 + size_t idx_start = priv->data->num_clk_base; 285 + int ret, i; 286 + 287 + for (i = 0; i < priv->data->num_clk_fixed; i++) { 288 + int idx = idx_start + i; 289 + 290 + sclk = &priv->data->clk_fixed[i]; 291 + sclk->hw = clk_hw_register_fixed_rate(NULL, sclk->name, 292 + sclk->parent, 0, 293 + sclk->rate); 294 + if (IS_ERR(sclk->hw)) { 295 + ret = PTR_ERR(sclk->hw); 296 + pr_err("Couldn't register fixed clock %d\n", idx); 297 + goto err_clk_unreg; 298 + } 299 + 300 + hws[idx] = sclk->hw; 301 + } 302 + 303 + return 0; 304 + 305 + err_clk_unreg: 306 + while (--i >= 0) { 307 + sclk = &priv->data->clk_fixed[i]; 308 + clk_hw_unregister_fixed_rate(sclk->hw); 309 + } 310 + return ret; 311 + } 312 + 313 + #define CLK_FACTOR(_name, _parent, _mult, _div) \ 314 + { \ 315 + .name = _name, \ 316 + .parent = _parent, \ 317 + .mult = _mult, \ 318 + .div = _div, \ 319 + .flags = CLK_SET_RATE_PARENT \ 320 + } 321 + 322 + static struct mtmips_clk_factor rt2880_factor_clocks[] = { 323 + CLK_FACTOR("bus", "cpu", 1, 2) 324 + }; 325 + 326 + static struct mtmips_clk_factor rt305x_factor_clocks[] = { 327 + CLK_FACTOR("bus", "cpu", 1, 3) 328 + }; 329 + 330 + static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_data, 331 + struct mtmips_clk_priv *priv) 332 + { 333 + struct clk_hw **hws = clk_data->hws; 334 + struct mtmips_clk_factor *sclk; 335 + size_t idx_start = priv->data->num_clk_base + priv->data->num_clk_fixed; 336 + int ret, i; 337 + 338 + for (i = 0; i < priv->data->num_clk_factor; i++) { 339 + int idx = idx_start + i; 340 + 341 + sclk = &priv->data->clk_factor[i]; 342 + sclk->hw = clk_hw_register_fixed_factor(NULL, sclk->name, 343 + sclk->parent, sclk->flags, 344 + sclk->mult, sclk->div); 345 + if (IS_ERR(sclk->hw)) { 346 + ret = PTR_ERR(sclk->hw); 347 + pr_err("Couldn't register factor clock %d\n", idx); 348 + goto err_clk_unreg; 349 + } 350 + 351 + hws[idx] = sclk->hw; 352 + } 353 + 354 + return 0; 355 + 356 + err_clk_unreg: 357 + while (--i >= 0) { 358 + sclk = &priv->data->clk_factor[i]; 359 + clk_hw_unregister_fixed_factor(sclk->hw); 360 + } 361 + return ret; 362 + } 363 + 364 + static inline struct mtmips_clk *to_mtmips_clk(struct clk_hw *hw) 365 + { 366 + return container_of(hw, struct mtmips_clk, hw); 367 + } 368 + 369 + static unsigned long rt5350_xtal_recalc_rate(struct clk_hw *hw, 370 + unsigned long parent_rate) 371 + { 372 + struct mtmips_clk *clk = to_mtmips_clk(hw); 373 + struct regmap *sysc = clk->priv->sysc; 374 + u32 val; 375 + 376 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &val); 377 + if (!(val & RT5350_CLKCFG0_XTAL_SEL)) 378 + return 20000000; 379 + 380 + return 40000000; 381 + } 382 + 383 + static unsigned long rt5350_cpu_recalc_rate(struct clk_hw *hw, 384 + unsigned long xtal_clk) 385 + { 386 + struct mtmips_clk *clk = to_mtmips_clk(hw); 387 + struct regmap *sysc = clk->priv->sysc; 388 + u32 t; 389 + 390 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 391 + t = (t >> RT5350_SYSCFG0_CPUCLK_SHIFT) & RT5350_SYSCFG0_CPUCLK_MASK; 392 + 393 + switch (t) { 394 + case RT5350_SYSCFG0_CPUCLK_360: 395 + return 360000000; 396 + case RT5350_SYSCFG0_CPUCLK_320: 397 + return 320000000; 398 + case RT5350_SYSCFG0_CPUCLK_300: 399 + return 300000000; 400 + default: 401 + BUG(); 402 + } 403 + } 404 + 405 + static unsigned long rt5350_bus_recalc_rate(struct clk_hw *hw, 406 + unsigned long parent_rate) 407 + { 408 + if (parent_rate == 320000000) 409 + return parent_rate / 4; 410 + 411 + return parent_rate / 3; 412 + } 413 + 414 + static unsigned long rt3352_cpu_recalc_rate(struct clk_hw *hw, 415 + unsigned long xtal_clk) 416 + { 417 + struct mtmips_clk *clk = to_mtmips_clk(hw); 418 + struct regmap *sysc = clk->priv->sysc; 419 + u32 t; 420 + 421 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 422 + t = (t >> RT3352_SYSCFG0_CPUCLK_SHIFT) & RT3352_SYSCFG0_CPUCLK_MASK; 423 + 424 + switch (t) { 425 + case RT3352_SYSCFG0_CPUCLK_LOW: 426 + return 384000000; 427 + case RT3352_SYSCFG0_CPUCLK_HIGH: 428 + return 400000000; 429 + default: 430 + BUG(); 431 + } 432 + } 433 + 434 + static unsigned long rt305x_cpu_recalc_rate(struct clk_hw *hw, 435 + unsigned long xtal_clk) 436 + { 437 + struct mtmips_clk *clk = to_mtmips_clk(hw); 438 + struct regmap *sysc = clk->priv->sysc; 439 + u32 t; 440 + 441 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 442 + t = (t >> RT305X_SYSCFG_CPUCLK_SHIFT) & RT305X_SYSCFG_CPUCLK_MASK; 443 + 444 + switch (t) { 445 + case RT305X_SYSCFG_CPUCLK_LOW: 446 + return 320000000; 447 + case RT305X_SYSCFG_CPUCLK_HIGH: 448 + return 384000000; 449 + default: 450 + BUG(); 451 + } 452 + } 453 + 454 + static unsigned long rt3883_cpu_recalc_rate(struct clk_hw *hw, 455 + unsigned long xtal_clk) 456 + { 457 + struct mtmips_clk *clk = to_mtmips_clk(hw); 458 + struct regmap *sysc = clk->priv->sysc; 459 + u32 t; 460 + 461 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 462 + t = (t >> RT3883_SYSCFG0_CPUCLK_SHIFT) & RT3883_SYSCFG0_CPUCLK_MASK; 463 + 464 + switch (t) { 465 + case RT3883_SYSCFG0_CPUCLK_250: 466 + return 250000000; 467 + case RT3883_SYSCFG0_CPUCLK_384: 468 + return 384000000; 469 + case RT3883_SYSCFG0_CPUCLK_480: 470 + return 480000000; 471 + case RT3883_SYSCFG0_CPUCLK_500: 472 + return 500000000; 473 + default: 474 + BUG(); 475 + } 476 + } 477 + 478 + static unsigned long rt3883_bus_recalc_rate(struct clk_hw *hw, 479 + unsigned long parent_rate) 480 + { 481 + struct mtmips_clk *clk = to_mtmips_clk(hw); 482 + struct regmap *sysc = clk->priv->sysc; 483 + u32 ddr2; 484 + u32 t; 485 + 486 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 487 + ddr2 = t & RT3883_SYSCFG0_DRAM_TYPE_DDR2; 488 + 489 + switch (parent_rate) { 490 + case 250000000: 491 + return (ddr2) ? 125000000 : 83000000; 492 + case 384000000: 493 + return (ddr2) ? 128000000 : 96000000; 494 + case 480000000: 495 + return (ddr2) ? 160000000 : 120000000; 496 + case 500000000: 497 + return (ddr2) ? 166000000 : 125000000; 498 + default: 499 + WARN_ON_ONCE(parent_rate == 0); 500 + return parent_rate / 4; 501 + } 502 + } 503 + 504 + static unsigned long rt2880_cpu_recalc_rate(struct clk_hw *hw, 505 + unsigned long xtal_clk) 506 + { 507 + struct mtmips_clk *clk = to_mtmips_clk(hw); 508 + struct regmap *sysc = clk->priv->sysc; 509 + u32 t; 510 + 511 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 512 + t = (t >> RT2880_CONFIG_CPUCLK_SHIFT) & RT2880_CONFIG_CPUCLK_MASK; 513 + 514 + switch (t) { 515 + case RT2880_CONFIG_CPUCLK_250: 516 + return 250000000; 517 + case RT2880_CONFIG_CPUCLK_266: 518 + return 266000000; 519 + case RT2880_CONFIG_CPUCLK_280: 520 + return 280000000; 521 + case RT2880_CONFIG_CPUCLK_300: 522 + return 300000000; 523 + default: 524 + BUG(); 525 + } 526 + } 527 + 528 + static u32 mt7620_calc_rate(u32 ref_rate, u32 mul, u32 div) 529 + { 530 + u64 t; 531 + 532 + t = ref_rate; 533 + t *= mul; 534 + t = div_u64(t, div); 535 + 536 + return t; 537 + } 538 + 539 + static unsigned long mt7620_pll_recalc_rate(struct clk_hw *hw, 540 + unsigned long parent_rate) 541 + { 542 + static const u32 clk_divider[] = { 2, 3, 4, 8 }; 543 + struct mtmips_clk *clk = to_mtmips_clk(hw); 544 + struct regmap *sysc = clk->priv->sysc; 545 + unsigned long cpu_pll; 546 + u32 t; 547 + u32 mul; 548 + u32 div; 549 + 550 + regmap_read(sysc, SYSC_REG_CPLL_CONFIG0, &t); 551 + if (t & CPLL_CFG0_BYPASS_REF_CLK) { 552 + cpu_pll = parent_rate; 553 + } else if ((t & CPLL_CFG0_SW_CFG) == 0) { 554 + cpu_pll = 600000000; 555 + } else { 556 + mul = (t >> CPLL_CFG0_PLL_MULT_RATIO_SHIFT) & 557 + CPLL_CFG0_PLL_MULT_RATIO_MASK; 558 + mul += 24; 559 + if (t & CPLL_CFG0_LC_CURFCK) 560 + mul *= 2; 561 + 562 + div = (t >> CPLL_CFG0_PLL_DIV_RATIO_SHIFT) & 563 + CPLL_CFG0_PLL_DIV_RATIO_MASK; 564 + 565 + WARN_ON_ONCE(div >= ARRAY_SIZE(clk_divider)); 566 + 567 + cpu_pll = mt7620_calc_rate(parent_rate, mul, clk_divider[div]); 568 + } 569 + 570 + regmap_read(sysc, SYSC_REG_CPLL_CONFIG1, &t); 571 + if (t & CPLL_CFG1_CPU_AUX1) 572 + return parent_rate; 573 + 574 + if (t & CPLL_CFG1_CPU_AUX0) 575 + return 480000000; 576 + 577 + return cpu_pll; 578 + } 579 + 580 + static unsigned long mt7620_cpu_recalc_rate(struct clk_hw *hw, 581 + unsigned long parent_rate) 582 + { 583 + struct mtmips_clk *clk = to_mtmips_clk(hw); 584 + struct regmap *sysc = clk->priv->sysc; 585 + u32 t; 586 + u32 mul; 587 + u32 div; 588 + 589 + regmap_read(sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); 590 + mul = t & CPU_SYS_CLKCFG_CPU_FFRAC_MASK; 591 + div = (t >> CPU_SYS_CLKCFG_CPU_FDIV_SHIFT) & 592 + CPU_SYS_CLKCFG_CPU_FDIV_MASK; 593 + 594 + return mt7620_calc_rate(parent_rate, mul, div); 595 + } 596 + 597 + static unsigned long mt7620_bus_recalc_rate(struct clk_hw *hw, 598 + unsigned long parent_rate) 599 + { 600 + static const u32 ocp_dividers[16] = { 601 + [CPU_SYS_CLKCFG_OCP_RATIO_2] = 2, 602 + [CPU_SYS_CLKCFG_OCP_RATIO_3] = 3, 603 + [CPU_SYS_CLKCFG_OCP_RATIO_4] = 4, 604 + [CPU_SYS_CLKCFG_OCP_RATIO_5] = 5, 605 + [CPU_SYS_CLKCFG_OCP_RATIO_10] = 10, 606 + }; 607 + struct mtmips_clk *clk = to_mtmips_clk(hw); 608 + struct regmap *sysc = clk->priv->sysc; 609 + u32 t; 610 + u32 ocp_ratio; 611 + u32 div; 612 + 613 + regmap_read(sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); 614 + ocp_ratio = (t >> CPU_SYS_CLKCFG_OCP_RATIO_SHIFT) & 615 + CPU_SYS_CLKCFG_OCP_RATIO_MASK; 616 + 617 + if (WARN_ON_ONCE(ocp_ratio >= ARRAY_SIZE(ocp_dividers))) 618 + return parent_rate; 619 + 620 + div = ocp_dividers[ocp_ratio]; 621 + 622 + if (WARN(!div, "invalid divider for OCP ratio %u", ocp_ratio)) 623 + return parent_rate; 624 + 625 + return parent_rate / div; 626 + } 627 + 628 + static unsigned long mt7620_periph_recalc_rate(struct clk_hw *hw, 629 + unsigned long parent_rate) 630 + { 631 + struct mtmips_clk *clk = to_mtmips_clk(hw); 632 + struct regmap *sysc = clk->priv->sysc; 633 + u32 t; 634 + 635 + regmap_read(sysc, SYSC_REG_CLKCFG0, &t); 636 + if (t & CLKCFG0_PERI_CLK_SEL) 637 + return parent_rate; 638 + 639 + return 40000000; 640 + } 641 + 642 + static unsigned long mt76x8_xtal_recalc_rate(struct clk_hw *hw, 643 + unsigned long parent_rate) 644 + { 645 + struct mtmips_clk *clk = to_mtmips_clk(hw); 646 + struct regmap *sysc = clk->priv->sysc; 647 + u32 t; 648 + 649 + regmap_read(sysc, SYSC_REG_SYSTEM_CONFIG, &t); 650 + if (t & MT7620_XTAL_FREQ_SEL) 651 + return 40000000; 652 + 653 + return 20000000; 654 + } 655 + 656 + static unsigned long mt76x8_cpu_recalc_rate(struct clk_hw *hw, 657 + unsigned long xtal_clk) 658 + { 659 + if (xtal_clk == 40000000) 660 + return 580000000; 661 + 662 + return 575000000; 663 + } 664 + 665 + #define CLK_BASE(_name, _parent, _recalc) { \ 666 + .init = &(const struct clk_init_data) { \ 667 + .name = _name, \ 668 + .ops = &(const struct clk_ops) { \ 669 + .recalc_rate = _recalc, \ 670 + }, \ 671 + .parent_data = &(const struct clk_parent_data) { \ 672 + .name = _parent, \ 673 + .fw_name = _parent \ 674 + }, \ 675 + .num_parents = _parent ? 1 : 0 \ 676 + }, \ 677 + } 678 + 679 + static struct mtmips_clk rt2880_clks_base[] = { 680 + { CLK_BASE("cpu", "xtal", rt2880_cpu_recalc_rate) } 681 + }; 682 + 683 + static struct mtmips_clk rt305x_clks_base[] = { 684 + { CLK_BASE("cpu", "xtal", rt305x_cpu_recalc_rate) } 685 + }; 686 + 687 + static struct mtmips_clk rt3352_clks_base[] = { 688 + { CLK_BASE("xtal", NULL, rt5350_xtal_recalc_rate) }, 689 + { CLK_BASE("cpu", "xtal", rt3352_cpu_recalc_rate) } 690 + }; 691 + 692 + static struct mtmips_clk rt3883_clks_base[] = { 693 + { CLK_BASE("cpu", "xtal", rt3883_cpu_recalc_rate) }, 694 + { CLK_BASE("bus", "cpu", rt3883_bus_recalc_rate) } 695 + }; 696 + 697 + static struct mtmips_clk rt5350_clks_base[] = { 698 + { CLK_BASE("xtal", NULL, rt5350_xtal_recalc_rate) }, 699 + { CLK_BASE("cpu", "xtal", rt5350_cpu_recalc_rate) }, 700 + { CLK_BASE("bus", "cpu", rt5350_bus_recalc_rate) } 701 + }; 702 + 703 + static struct mtmips_clk mt7620_clks_base[] = { 704 + { CLK_BASE("xtal", NULL, mt76x8_xtal_recalc_rate) }, 705 + { CLK_BASE("pll", "xtal", mt7620_pll_recalc_rate) }, 706 + { CLK_BASE("cpu", "pll", mt7620_cpu_recalc_rate) }, 707 + { CLK_BASE("periph", "xtal", mt7620_periph_recalc_rate) }, 708 + { CLK_BASE("bus", "cpu", mt7620_bus_recalc_rate) } 709 + }; 710 + 711 + static struct mtmips_clk mt76x8_clks_base[] = { 712 + { CLK_BASE("xtal", NULL, mt76x8_xtal_recalc_rate) }, 713 + { CLK_BASE("cpu", "xtal", mt76x8_cpu_recalc_rate) } 714 + }; 715 + 716 + static int mtmips_register_clocks(struct device_node *np, 717 + struct clk_hw_onecell_data *clk_data, 718 + struct mtmips_clk_priv *priv) 719 + { 720 + struct clk_hw **hws = clk_data->hws; 721 + struct mtmips_clk *sclk; 722 + int ret, i; 723 + 724 + for (i = 0; i < priv->data->num_clk_base; i++) { 725 + sclk = &priv->data->clk_base[i]; 726 + sclk->priv = priv; 727 + ret = of_clk_hw_register(np, &sclk->hw); 728 + if (ret) { 729 + pr_err("Couldn't register top clock %i\n", i); 730 + goto err_clk_unreg; 731 + } 732 + 733 + hws[i] = &sclk->hw; 734 + } 735 + 736 + return 0; 737 + 738 + err_clk_unreg: 739 + while (--i >= 0) { 740 + sclk = &priv->data->clk_base[i]; 741 + clk_hw_unregister(&sclk->hw); 742 + } 743 + return ret; 744 + } 745 + 746 + static const struct mtmips_clk_data rt2880_clk_data = { 747 + .clk_base = rt2880_clks_base, 748 + .num_clk_base = ARRAY_SIZE(rt2880_clks_base), 749 + .clk_fixed = rt305x_fixed_clocks, 750 + .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), 751 + .clk_factor = rt2880_factor_clocks, 752 + .num_clk_factor = ARRAY_SIZE(rt2880_factor_clocks), 753 + .clk_periph = rt2880_pherip_clks, 754 + .num_clk_periph = ARRAY_SIZE(rt2880_pherip_clks), 755 + }; 756 + 757 + static const struct mtmips_clk_data rt305x_clk_data = { 758 + .clk_base = rt305x_clks_base, 759 + .num_clk_base = ARRAY_SIZE(rt305x_clks_base), 760 + .clk_fixed = rt305x_fixed_clocks, 761 + .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), 762 + .clk_factor = rt305x_factor_clocks, 763 + .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), 764 + .clk_periph = rt305x_pherip_clks, 765 + .num_clk_periph = ARRAY_SIZE(rt305x_pherip_clks), 766 + }; 767 + 768 + static const struct mtmips_clk_data rt3352_clk_data = { 769 + .clk_base = rt3352_clks_base, 770 + .num_clk_base = ARRAY_SIZE(rt3352_clks_base), 771 + .clk_fixed = rt3352_fixed_clocks, 772 + .num_clk_fixed = ARRAY_SIZE(rt3352_fixed_clocks), 773 + .clk_factor = rt305x_factor_clocks, 774 + .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), 775 + .clk_periph = rt5350_pherip_clks, 776 + .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), 777 + }; 778 + 779 + static const struct mtmips_clk_data rt3883_clk_data = { 780 + .clk_base = rt3883_clks_base, 781 + .num_clk_base = ARRAY_SIZE(rt3883_clks_base), 782 + .clk_fixed = rt305x_fixed_clocks, 783 + .num_clk_fixed = ARRAY_SIZE(rt305x_fixed_clocks), 784 + .clk_factor = NULL, 785 + .num_clk_factor = 0, 786 + .clk_periph = rt5350_pherip_clks, 787 + .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), 788 + }; 789 + 790 + static const struct mtmips_clk_data rt5350_clk_data = { 791 + .clk_base = rt5350_clks_base, 792 + .num_clk_base = ARRAY_SIZE(rt5350_clks_base), 793 + .clk_fixed = rt3352_fixed_clocks, 794 + .num_clk_fixed = ARRAY_SIZE(rt3352_fixed_clocks), 795 + .clk_factor = NULL, 796 + .num_clk_factor = 0, 797 + .clk_periph = rt5350_pherip_clks, 798 + .num_clk_periph = ARRAY_SIZE(rt5350_pherip_clks), 799 + }; 800 + 801 + static const struct mtmips_clk_data mt7620_clk_data = { 802 + .clk_base = mt7620_clks_base, 803 + .num_clk_base = ARRAY_SIZE(mt7620_clks_base), 804 + .clk_fixed = NULL, 805 + .num_clk_fixed = 0, 806 + .clk_factor = NULL, 807 + .num_clk_factor = 0, 808 + .clk_periph = mt7620_pherip_clks, 809 + .num_clk_periph = ARRAY_SIZE(mt7620_pherip_clks), 810 + }; 811 + 812 + static const struct mtmips_clk_data mt76x8_clk_data = { 813 + .clk_base = mt76x8_clks_base, 814 + .num_clk_base = ARRAY_SIZE(mt76x8_clks_base), 815 + .clk_fixed = mt76x8_fixed_clocks, 816 + .num_clk_fixed = ARRAY_SIZE(mt76x8_fixed_clocks), 817 + .clk_factor = rt305x_factor_clocks, 818 + .num_clk_factor = ARRAY_SIZE(rt305x_factor_clocks), 819 + .clk_periph = mt76x8_pherip_clks, 820 + .num_clk_periph = ARRAY_SIZE(mt76x8_pherip_clks), 821 + }; 822 + 823 + static const struct of_device_id mtmips_of_match[] = { 824 + { 825 + .compatible = "ralink,rt2880-sysc", 826 + .data = &rt2880_clk_data, 827 + }, 828 + { 829 + .compatible = "ralink,rt3050-sysc", 830 + .data = &rt305x_clk_data, 831 + }, 832 + { 833 + .compatible = "ralink,rt3052-sysc", 834 + .data = &rt305x_clk_data, 835 + }, 836 + { 837 + .compatible = "ralink,rt3352-sysc", 838 + .data = &rt3352_clk_data, 839 + }, 840 + { 841 + .compatible = "ralink,rt3883-sysc", 842 + .data = &rt3883_clk_data, 843 + }, 844 + { 845 + .compatible = "ralink,rt5350-sysc", 846 + .data = &rt5350_clk_data, 847 + }, 848 + { 849 + .compatible = "ralink,mt7620-sysc", 850 + .data = &mt7620_clk_data, 851 + }, 852 + { 853 + .compatible = "ralink,mt7628-sysc", 854 + .data = &mt76x8_clk_data, 855 + }, 856 + { 857 + .compatible = "ralink,mt7688-sysc", 858 + .data = &mt76x8_clk_data, 859 + }, 860 + {} 861 + }; 862 + 863 + static void __init mtmips_clk_regs_init(struct device_node *node, 864 + struct mtmips_clk_priv *priv) 865 + { 866 + u32 t; 867 + 868 + if (!of_device_is_compatible(node, "ralink,mt7620-sysc")) 869 + return; 870 + 871 + /* 872 + * When the CPU goes into sleep mode, the BUS 873 + * clock will be too low for USB to function properly. 874 + * Adjust the busses fractional divider to fix this 875 + */ 876 + regmap_read(priv->sysc, SYSC_REG_CPU_SYS_CLKCFG, &t); 877 + t &= ~(CLKCFG_FDIV_MASK | CLKCFG_FFRAC_MASK); 878 + t |= CLKCFG_FDIV_USB_VAL | CLKCFG_FFRAC_USB_VAL; 879 + regmap_write(priv->sysc, SYSC_REG_CPU_SYS_CLKCFG, t); 880 + } 881 + 882 + static void __init mtmips_clk_init(struct device_node *node) 883 + { 884 + const struct of_device_id *match; 885 + const struct mtmips_clk_data *data; 886 + struct mtmips_clk_priv *priv; 887 + struct clk_hw_onecell_data *clk_data; 888 + int ret, i, count; 889 + 890 + priv = kzalloc(sizeof(*priv), GFP_KERNEL); 891 + if (!priv) 892 + return; 893 + 894 + priv->sysc = syscon_node_to_regmap(node); 895 + if (IS_ERR(priv->sysc)) { 896 + pr_err("Could not get sysc syscon regmap\n"); 897 + goto free_clk_priv; 898 + } 899 + 900 + mtmips_clk_regs_init(node, priv); 901 + 902 + match = of_match_node(mtmips_of_match, node); 903 + if (WARN_ON(!match)) 904 + return; 905 + 906 + data = match->data; 907 + priv->data = data; 908 + count = priv->data->num_clk_base + priv->data->num_clk_fixed + 909 + priv->data->num_clk_factor + priv->data->num_clk_periph; 910 + clk_data = kzalloc(struct_size(clk_data, hws, count), GFP_KERNEL); 911 + if (!clk_data) 912 + goto free_clk_priv; 913 + 914 + ret = mtmips_register_clocks(node, clk_data, priv); 915 + if (ret) { 916 + pr_err("Couldn't register top clocks\n"); 917 + goto free_clk_data; 918 + } 919 + 920 + ret = mtmips_register_fixed_clocks(clk_data, priv); 921 + if (ret) { 922 + pr_err("Couldn't register fixed clocks\n"); 923 + goto unreg_clk_top; 924 + } 925 + 926 + ret = mtmips_register_factor_clocks(clk_data, priv); 927 + if (ret) { 928 + pr_err("Couldn't register factor clocks\n"); 929 + goto unreg_clk_fixed; 930 + } 931 + 932 + ret = mtmips_register_pherip_clocks(node, clk_data, priv); 933 + if (ret) { 934 + pr_err("Couldn't register peripheral clocks\n"); 935 + goto unreg_clk_factor; 936 + } 937 + 938 + clk_data->num = count; 939 + 940 + ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data); 941 + if (ret) { 942 + pr_err("Couldn't add clk hw provider\n"); 943 + goto unreg_clk_periph; 944 + } 945 + 946 + return; 947 + 948 + unreg_clk_periph: 949 + for (i = 0; i < priv->data->num_clk_periph; i++) { 950 + struct mtmips_clk *sclk = &priv->data->clk_periph[i]; 951 + 952 + clk_hw_unregister(&sclk->hw); 953 + } 954 + 955 + unreg_clk_factor: 956 + for (i = 0; i < priv->data->num_clk_factor; i++) { 957 + struct mtmips_clk_factor *sclk = &priv->data->clk_factor[i]; 958 + 959 + clk_hw_unregister_fixed_factor(sclk->hw); 960 + } 961 + 962 + unreg_clk_fixed: 963 + for (i = 0; i < priv->data->num_clk_fixed; i++) { 964 + struct mtmips_clk_fixed *sclk = &priv->data->clk_fixed[i]; 965 + 966 + clk_hw_unregister_fixed_rate(sclk->hw); 967 + } 968 + 969 + unreg_clk_top: 970 + for (i = 0; i < priv->data->num_clk_base; i++) { 971 + struct mtmips_clk *sclk = &priv->data->clk_base[i]; 972 + 973 + clk_hw_unregister(&sclk->hw); 974 + } 975 + 976 + free_clk_data: 977 + kfree(clk_data); 978 + 979 + free_clk_priv: 980 + kfree(priv); 981 + } 982 + CLK_OF_DECLARE_DRIVER(rt2880_clk, "ralink,rt2880-sysc", mtmips_clk_init); 983 + CLK_OF_DECLARE_DRIVER(rt3050_clk, "ralink,rt3050-sysc", mtmips_clk_init); 984 + CLK_OF_DECLARE_DRIVER(rt3052_clk, "ralink,rt3052-sysc", mtmips_clk_init); 985 + CLK_OF_DECLARE_DRIVER(rt3352_clk, "ralink,rt3352-sysc", mtmips_clk_init); 986 + CLK_OF_DECLARE_DRIVER(rt3883_clk, "ralink,rt3883-sysc", mtmips_clk_init); 987 + CLK_OF_DECLARE_DRIVER(rt5350_clk, "ralink,rt5350-sysc", mtmips_clk_init); 988 + CLK_OF_DECLARE_DRIVER(mt7620_clk, "ralink,mt7620-sysc", mtmips_clk_init); 989 + CLK_OF_DECLARE_DRIVER(mt7628_clk, "ralink,mt7628-sysc", mtmips_clk_init); 990 + CLK_OF_DECLARE_DRIVER(mt7688_clk, "ralink,mt7688-sysc", mtmips_clk_init); 991 + 992 + struct mtmips_rst { 993 + struct reset_controller_dev rcdev; 994 + struct regmap *sysc; 995 + }; 996 + 997 + static struct mtmips_rst *to_mtmips_rst(struct reset_controller_dev *dev) 998 + { 999 + return container_of(dev, struct mtmips_rst, rcdev); 1000 + } 1001 + 1002 + static int mtmips_assert_device(struct reset_controller_dev *rcdev, 1003 + unsigned long id) 1004 + { 1005 + struct mtmips_rst *data = to_mtmips_rst(rcdev); 1006 + struct regmap *sysc = data->sysc; 1007 + 1008 + return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), BIT(id)); 1009 + } 1010 + 1011 + static int mtmips_deassert_device(struct reset_controller_dev *rcdev, 1012 + unsigned long id) 1013 + { 1014 + struct mtmips_rst *data = to_mtmips_rst(rcdev); 1015 + struct regmap *sysc = data->sysc; 1016 + 1017 + return regmap_update_bits(sysc, SYSC_REG_RESET_CTRL, BIT(id), 0); 1018 + } 1019 + 1020 + static int mtmips_reset_device(struct reset_controller_dev *rcdev, 1021 + unsigned long id) 1022 + { 1023 + int ret; 1024 + 1025 + ret = mtmips_assert_device(rcdev, id); 1026 + if (ret < 0) 1027 + return ret; 1028 + 1029 + return mtmips_deassert_device(rcdev, id); 1030 + } 1031 + 1032 + static int mtmips_rst_xlate(struct reset_controller_dev *rcdev, 1033 + const struct of_phandle_args *reset_spec) 1034 + { 1035 + unsigned long id = reset_spec->args[0]; 1036 + 1037 + if (id == 0 || id >= rcdev->nr_resets) 1038 + return -EINVAL; 1039 + 1040 + return id; 1041 + } 1042 + 1043 + static const struct reset_control_ops reset_ops = { 1044 + .reset = mtmips_reset_device, 1045 + .assert = mtmips_assert_device, 1046 + .deassert = mtmips_deassert_device 1047 + }; 1048 + 1049 + static int mtmips_reset_init(struct device *dev, struct regmap *sysc) 1050 + { 1051 + struct mtmips_rst *rst_data; 1052 + 1053 + rst_data = devm_kzalloc(dev, sizeof(*rst_data), GFP_KERNEL); 1054 + if (!rst_data) 1055 + return -ENOMEM; 1056 + 1057 + rst_data->sysc = sysc; 1058 + rst_data->rcdev.ops = &reset_ops; 1059 + rst_data->rcdev.owner = THIS_MODULE; 1060 + rst_data->rcdev.nr_resets = 32; 1061 + rst_data->rcdev.of_reset_n_cells = 1; 1062 + rst_data->rcdev.of_xlate = mtmips_rst_xlate; 1063 + rst_data->rcdev.of_node = dev_of_node(dev); 1064 + 1065 + return devm_reset_controller_register(dev, &rst_data->rcdev); 1066 + } 1067 + 1068 + static int mtmips_clk_probe(struct platform_device *pdev) 1069 + { 1070 + struct device_node *np = pdev->dev.of_node; 1071 + struct device *dev = &pdev->dev; 1072 + struct mtmips_clk_priv *priv; 1073 + int ret; 1074 + 1075 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 1076 + if (!priv) 1077 + return -ENOMEM; 1078 + 1079 + priv->sysc = syscon_node_to_regmap(np); 1080 + if (IS_ERR(priv->sysc)) 1081 + return dev_err_probe(dev, PTR_ERR(priv->sysc), 1082 + "Could not get sysc syscon regmap\n"); 1083 + 1084 + ret = mtmips_reset_init(dev, priv->sysc); 1085 + if (ret) 1086 + return dev_err_probe(dev, ret, "Could not init reset controller\n"); 1087 + 1088 + return 0; 1089 + } 1090 + 1091 + static const struct of_device_id mtmips_clk_of_match[] = { 1092 + { .compatible = "ralink,rt2880-reset" }, 1093 + { .compatible = "ralink,rt2880-sysc" }, 1094 + { .compatible = "ralink,rt3050-sysc" }, 1095 + { .compatible = "ralink,rt3052-sysc" }, 1096 + { .compatible = "ralink,rt3352-sysc" }, 1097 + { .compatible = "ralink,rt3883-sysc" }, 1098 + { .compatible = "ralink,rt5350-sysc" }, 1099 + { .compatible = "ralink,mt7620-sysc" }, 1100 + { .compatible = "ralink,mt7628-sysc" }, 1101 + { .compatible = "ralink,mt7688-sysc" }, 1102 + {} 1103 + }; 1104 + 1105 + static struct platform_driver mtmips_clk_driver = { 1106 + .probe = mtmips_clk_probe, 1107 + .driver = { 1108 + .name = "mtmips-clk", 1109 + .of_match_table = mtmips_clk_of_match, 1110 + }, 1111 + }; 1112 + 1113 + static int __init mtmips_clk_reset_init(void) 1114 + { 1115 + return platform_driver_register(&mtmips_clk_driver); 1116 + } 1117 + arch_initcall(mtmips_clk_reset_init);